diff --git a/.ai/03-contracts.md b/.ai/03-contracts.md index 0da379b..3fb8670 100644 --- a/.ai/03-contracts.md +++ b/.ai/03-contracts.md @@ -156,7 +156,7 @@ GET /v1/history?range=… lifetime totals + tool distribution + mod **Non-Anthropic pricing.** `pricing/pricing.json` carries rows for the models Caprock observes through OpenCode — DeepSeek and MiniMax at the providers' own published rates, fetched with a date and noted in the file. They are priced so a total that includes non-Anthropic usage is a total; before this, $155 of the owner's own spend sat outside his. `normalizeModel` strips a gateway's vendor prefix, so `minimax/minimax-m3` from OpenRouter and `MiniMax-M3` from the direct API are one row rather than two, one of them unpriced. The unpriced warning fires only on turns whose tokens are greater than zero: a turn recorded with explicit zeroes has nothing to price, and warning about it says a total is missing money it is not missing. -**Tool distribution DDL.** `idx_events_kind_ts_tool` on `events(kind, ts, tool)` exists so the ALL TIME panel's tool counts are answered from a covering index. `idx_events_kind_ts` matched the filter but not `tool`, so SQLite fetched ~80k rows from the table to read one column: `ToolDistribution` was 1780 ms cold and 139 ms warm, 60% of `GET /v1/history?range=all`. With the column in the index the same plan is covering — 46 ms warm, measured on the owner's 233k-event database (2026-08-26). The older index is left alone; it serves every other kind+range query and none of them want `tool` along for the ride. Migration `0016_events_tool_dist.sql`. +**Tool distribution DDL.** `idx_events_tool_dist` on `events(kind, ts, tool, tool_bytes)` exists so the ALL TIME panel's tool table is answered from a covering index. Without it SQLite finds rows by (kind, ts) and then fetches each from the table to read two columns — and those rows carry the whole hook payload, which was most of the 2.1s the query took. Covering, it is 0.05s, measured on the owner's 254k-event database (2026-09-02). It replaces `idx_events_kind_ts_tool` from migration 0016, which is the same index without `tool_bytes`; both would cost two copies of the same thing on every insert, so `0019_drop_superseded_tool_index.sql` drops it — as its own migration, because 0018 had already run where it mattered and an edit to an applied migration is an edit nobody receives. `idx_events_kind_ts` is left alone — it serves every other kind+range query and none of them want `tool` along for the ride. Migrations `0018_tool_bytes.sql`, `0019_drop_superseded_tool_index.sql`. **`caprock license` manages the key from the terminal** — `license` shows it, `license set ` stores it (refusing one that will not work rather than leaving someone to wonder why nothing happened), `license clear` removes it, and `license issue --days N | --lifetime` mints one. Issuing exists because the Stripe webhook was the only thing that could make a key, which leaves no way to serve a customer who paid another way, a refund reissued, or a friend. `license.Issue` and the webhook produce the same format and a cross-repository test holds them together. The random suffix is optional: nothing verifies it, it exists so two keys issued on the same day are distinguishable in an email, and a key dictated over the phone has to work without it. diff --git a/CHANGELOG.md b/CHANGELOG.md index 35846db..612a1a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,87 @@ polish (plan-limit windows, orchestrator-lifecycle fixes, Homebrew formula, firs Phase 3 (Delight) has no plan by design. +## [0.47.1] - 2026-09-02 + +### Fixed + +- **Every table says what its columns are.** Three figures in a row with + nothing over them is a puzzle: `$7,587.14 · 12.01B · 58%` reads as three + unrelated numbers until you work out which is which, and the "by cost" in the + corner describes the sort order rather than the columns. Every breakdown on + Now, Cost and Lifetime now names them, on one line with the table's own title + so it costs no vertical space. + + The tool table has two figures rather than three, and now says so. It could + have shown tokens beside calls — but 14% of Bash calls cannot be linked to + the turn that paid for them against 1% of Read's, so the number would have + understated Bash specifically, which is the comparison the table exists to + make. A figure that looks measured and is quietly skewed is worse than a + column that is not there. + +- **The all-time breakdown moved up, under the live pulse.** It was last, below + a tall activity feed, so the most legible thing on the screen was the thing + you had to scroll to find. + +- **"Nothing measured yet" appeared while the figures were still loading.** The + first screen could not tell "no answer yet" from "the answer is nothing", so + for the second it took the first response to arrive it announced, with + confidence, that a machine with thousands of turns on it had never run + anything. It says "reading your figures…" until it knows. Measured on a + 641 MB database: nothing on this screen takes longer than 0.7s, so the delay + was never the problem — the wrong answer during it was. + +- **The answers screen showed raw Markdown.** Claude writes bold text, lists + and tables; the screen kept the line breaks and showed everything else as the + markup it is made of — `**bold**` with its asterisks, a table collapsed into + `| | |`. The same renderer the release notes got now covers both, and it + learned tables and quotes on the way. + +- **A Gemini error sent people somewhere they no longer need to go.** "Set + GEMINI_API_KEY in the daemon's environment and restart it" — but the key has + a field on the Cost screen and takes effect at once. A wrong instruction is + worse than a long one. + +- **Errors carried a Go package name into the dialog box.** `agents: "/x" is + not an absolute path` was written for whoever was debugging it. + +### Added + +- **Share a week, a month, or today — not only all time.** The picker was + removed once, on the reasoning that a card showing every period at once made + choosing redundant. It does not: somebody sharing a working week does not + want their lifetime total to be the headline, and a card that answers four + questions answers none of them loudly. The choice now decides what the + heading claims and which figure is lit; every other period stays on the card, + because a week means nothing without knowing whether it was a normal one. + It opens on the week. + +- **You can see the card before you send it.** The buttons said where the + picture would go and nothing said what was in it: you pressed Save, opened + your downloads, and only then found out. The card is drawn in the sheet now, + at the size it will be seen, and it redraws as you change the period — which + is what makes the choice worth having. + +- **The Share button can be found.** It was an outlined button in a row of + 11px text, next to a solid premium button — an outline cannot win an argument + with a fill. It is filled, a size up, and carries an icon. It earns that: + sharing is the only thing on this dashboard that leaves the machine. + +### Changed + +- **Copy across the product says less.** Several tooltips explained the + attribution algorithm where the reader had asked what a number meant, and + several paragraphs defended design decisions nobody had questioned. The + longest of them — the per-directory rule — was four sentences of + specification on hover; it is now one. "Everything here is measured — no + invented numbers" is gone from the Cost screen: readers assume the figures + are real until told otherwise, so the sentence created the doubt it answered. + +- **Messages about a missing `claude` say what to do.** "Spawning is + unavailable" named an internal verb and diagnosed without a fix; it now says + the binary is not on PATH, that installing Claude Code fixes it, and that + watching works regardless. + ## [0.47.0] - 2026-09-02 ### Added diff --git a/cmd/caprock/main.go b/cmd/caprock/main.go index 3979bd6..916e445 100644 --- a/cmd/caprock/main.go +++ b/cmd/caprock/main.go @@ -271,8 +271,7 @@ func maybeInstallHooks(cmd *cobra.Command, dir string, yes bool) error { return nil } if !yes { - fmt.Fprintf(cmd.OutOrStdout(), "Caprock needs a hook entry in %s so it can see Claude Code sessions.\n", sp) - fmt.Fprintf(cmd.OutOrStdout(), "It appends `%s` under %d events, backs the file up first, and never touches your other hooks.\n", shimPath, len(hooks.Events)) + fmt.Fprintf(cmd.OutOrStdout(), "Caprock adds a hook to %s so it can see your sessions. It backs the file up first.\n", sp) if !confirm(cmd, "Install now? [Y/n] ") { fmt.Fprintln(cmd.OutOrStdout(), "Skipped. Run `caprock hooks install` later; transcript tailing still works (delayed).") return nil @@ -332,8 +331,7 @@ func maybeInstallStatusline(cmd *cobra.Command, yes bool) error { return nil } if !yes { - fmt.Fprintf(cmd.OutOrStdout(), "Caprock can also show your plan limits (5h/7d, Pro/Max) on the Cost screen via Claude Code's status line.\n") - fmt.Fprintf(cmd.OutOrStdout(), "It sets `statusLine.command` to `%s` in %s (backed up first). Skip if you use your own status line.\n", cmdStr, sp) + fmt.Fprintf(cmd.OutOrStdout(), "Caprock can also show your plan limits on the Cost screen, through Claude Code's status line (backed up first).\n") if !confirm(cmd, "Add it? [Y/n] ") { fmt.Fprintln(cmd.OutOrStdout(), "Skipped. Run `caprock statusline install` later to enable plan limits.") return nil @@ -470,7 +468,7 @@ func statusCmd() *cobra.Command { if st.ClaudeAvailable { fmt.Fprintf(out, "claude: found on PATH — Caprock can start sessions for you\n") } else { - fmt.Fprintf(out, "claude: not found on PATH — Caprock cannot start sessions, but still observes every session you start yourself\n") + fmt.Fprintf(out, "claude: not on PATH — install Claude Code to start sessions here; watching still works\n") } fmt.Fprintf(out, "ui: %s\n", map[bool]string{true: "embedded", false: "placeholder (built without dashboard)"}[st.UIBuilt]) // Which hive is in force was reported nowhere — not here, not in diff --git a/internal/agents/agents.go b/internal/agents/agents.go index 5a0e164..4bd08c6 100644 --- a/internal/agents/agents.go +++ b/internal/agents/agents.go @@ -236,11 +236,11 @@ func resolveClaude() string { // without touching anyone's repository. func (m *Manager) newChatDir() (string, error) { if m.dataDir == "" { - return "", errors.New("agents: no data directory, so a chat has nowhere to live") + return "", errors.New("no data directory, so a chat has nowhere to live") } base := config.ChatsDir(m.dataDir) if err := os.MkdirAll(base, 0o700); err != nil { - return "", fmt.Errorf("agents: create chats directory: %w", err) + return "", fmt.Errorf("create chats directory: %w", err) } // Second granularity plus a counter: two chats started inside the same // second would otherwise land in one directory and share a transcript. @@ -254,10 +254,10 @@ func (m *Manager) newChatDir() (string, error) { if err := os.Mkdir(dir, 0o700); err == nil { return dir, nil } else if !os.IsExist(err) { - return "", fmt.Errorf("agents: create chat directory: %w", err) + return "", fmt.Errorf("create chat directory: %w", err) } if i > 100 { - return "", errors.New("agents: could not find a free chat directory name") + return "", errors.New("could not find a free chat directory name") } } } @@ -275,24 +275,24 @@ func (m *Manager) newChatDir() (string, error) { // asked for a directory to exist and it does. func makeProjectDir(dir string) error { if !filepath.IsAbs(dir) { - return fmt.Errorf("agents: %q is not an absolute path", dir) + return fmt.Errorf("%q is not an absolute path", dir) } // Clean first: `/Users/me/dev/../../../etc/x` is absolute and still escapes // wherever the user thought they were. dir = filepath.Clean(dir) parent := filepath.Dir(dir) if parent == dir { - return fmt.Errorf("agents: refusing to create the filesystem root") + return fmt.Errorf("refusing to create the filesystem root") } fi, err := os.Stat(parent) if err != nil || !fi.IsDir() { - return fmt.Errorf("agents: %q does not exist, so %q cannot be created in it", parent, filepath.Base(dir)) + return fmt.Errorf("%q does not exist, so %q cannot be created in it", parent, filepath.Base(dir)) } // Mkdir, never MkdirAll — the parent check above is the guard, and this // call is what keeps it a guard. MkdirAll here would create the chain the // check just refused, so the two have to stay in agreement. if err := os.Mkdir(dir, 0o755); err != nil && !os.IsExist(err) { - return fmt.Errorf("agents: could not create %q: %w", dir, err) + return fmt.Errorf("could not create %q: %w", dir, err) } return nil } @@ -309,11 +309,11 @@ func (m *Manager) Spawn(ctx context.Context, req SpawnRequest) (*Agent, error) { req.Cwd = dir } if req.Cwd == "" { - return nil, errors.New("agents: spawn without cwd") + return nil, errors.New("spawn without cwd") } if fi, err := os.Stat(req.Cwd); err != nil || !fi.IsDir() { if !req.Create { - return nil, fmt.Errorf("agents: cwd %q is not a directory", req.Cwd) + return nil, fmt.Errorf("cwd %q is not a directory", req.Cwd) } if err := makeProjectDir(req.Cwd); err != nil { return nil, err @@ -421,7 +421,7 @@ func (m *Manager) Spawn(ctx context.Context, req SpawnRequest) (*Agent, error) { // when the caller's context (e.g. an HTTP request) ends. sess, err := m.pty.Spawn(context.WithoutCancel(ctx), spec) if err != nil { - return nil, fmt.Errorf("agents: spawn %s: %w", command, err) + return nil, fmt.Errorf("spawn %s: %w", command, err) } a := &Agent{ SessionID: sessionID, Cwd: cwd, Worktree: worktree, Command: command + " " + join(args), StartedAt: time.Now(), @@ -590,7 +590,7 @@ func (m *Manager) Shutdown() { } // ErrNotOwned is returned for control operations on a session Caprock did not spawn. -var ErrNotOwned = errors.New("session is not owned by caprock (observe-only)") +var ErrNotOwned = errors.New("caprock did not start this session, so only its own terminal can control it") func errNotOwned(id string) error { return fmt.Errorf("%w: %s", ErrNotOwned, id) } diff --git a/internal/api/api.go b/internal/api/api.go index 893d61a..e494001 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -1097,7 +1097,7 @@ func (s *Server) requireTasks(w http.ResponseWriter) bool { // "Phase 2" is our internal build order and means nothing to a user; // the detail says what to do instead. It no longer sends anyone to a // terminal first: POST /v1/hive turns the runner on where they are. - writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "the task runner is off", "detail": "turn it on with POST /v1/hive, or start the daemon with `caprock up --hive `"}) + writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "the task runner is off", "detail": "turn it on from the Tasks screen, or start the daemon with `caprock up --hive `"}) return false } return true @@ -1255,7 +1255,7 @@ func (s *Server) handleApprovals(w http.ResponseWriter, r *http.Request) { func (s *Server) requireAgents(w http.ResponseWriter) bool { if s.d.Agents == nil || !s.d.Agents.Available() { - writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "spawning is unavailable", "detail": "the `claude` binary was not found on PATH; Caprock runs in observe-only mode"}) + writeJSON(w, http.StatusNotImplemented, map[string]string{"error": "can't start sessions", "detail": "`claude` is not on your PATH — install Claude Code, or add it. Caprock still watches sessions you start yourself."}) return false } return true diff --git a/internal/api/dist/assets/index-C_Ali4sj.js b/internal/api/dist/assets/index-C_Ali4sj.js deleted file mode 100644 index 5cd5398..0000000 --- a/internal/api/dist/assets/index-C_Ali4sj.js +++ /dev/null @@ -1,101 +0,0 @@ -var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);(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 t=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function ee(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function E(e,t){return ee(e.type,t,e.props)}function te(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function D(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ne=/\/+/g;function re(e,t){return typeof e==`object`&&e&&e.key!=null?D(``+e.key):t.toString(36)}function ie(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function O(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,O(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+re(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ne,`$&/`)+`/`),O(o,r,i,``,function(e){return e})):o!=null&&(te(o)&&(o=E(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ne,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u{n.exports=t()})),r=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&&re(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-Tt&&ee());){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&&re(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?te():S=!1}}}var te;if(typeof y==`function`)te=function(){y(E)};else if(typeof MessageChannel<`u`){var D=new MessageChannel,ne=D.port2;D.port1.onmessage=E,te=function(){ne.postMessage(null)}}else te=function(){_(E,0)};function re(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,re(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,te()))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),i=e(((e,t)=>{t.exports=r()})),a=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=a()})),s=e((e=>{var t=i(),r=n(),a=o();function s(e){var t=`https://react.dev/errors/`+e;if(1P||(e.current=N[P],N[P]=null,P--)}function ce(e,t){P++,N[P]=e.current,e.current=t}var le=oe(null),ue=oe(null),de=oe(null),fe=oe(null);function pe(e,t){switch(ce(de,t),ce(ue,e),ce(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}se(le),ce(le,e)}function me(){se(le),se(ue),se(de)}function he(e){e.memoizedState!==null&&ce(fe,e);var t=le.current,n=Hd(t,e.type);t!==n&&(ce(ue,e),ce(le,n))}function ge(e){ue.current===e&&(se(le),se(ue)),fe.current===e&&(se(fe),Qf._currentValue=ae)}var _e,ve;function ye(e){if(_e===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);_e=t&&t[1]||``,ve=-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{be=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ye(n):``}function xe(e,t){switch(e.tag){case 26:case 27:case 5:return ye(e.type);case 16:return ye(`Lazy`);case 13:return e.child!==t&&t!==null?ye(`Suspense Fallback`):ye(`Suspense`);case 19:return ye(`SuspenseList`);case 0:case 15:return F(e.type,!1);case 11:return F(e.type.render,!1);case 1:return F(e.type,!0);case 31:return ye(`Activity`);default:return``}}function I(e){try{var t=``,n=null;do t+=xe(e,n),n=e,e=e.return;while(e);return t}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}var Se=Object.prototype.hasOwnProperty,Ce=t.unstable_scheduleCallback,we=t.unstable_cancelCallback,Te=t.unstable_shouldYield,Ee=t.unstable_requestPaint,De=t.unstable_now,Oe=t.unstable_getCurrentPriorityLevel,ke=t.unstable_ImmediatePriority,Ae=t.unstable_UserBlockingPriority,je=t.unstable_NormalPriority,Me=t.unstable_LowPriority,Ne=t.unstable_IdlePriority,Pe=t.log,Fe=t.unstable_setDisableYieldValue,Ie=null,Le=null;function Re(e){if(typeof Pe==`function`&&Fe(e),Le&&typeof Le.setStrictMode==`function`)try{Le.setStrictMode(Ie,e)}catch{}}var ze=Math.clz32?Math.clz32:He,Be=Math.log,Ve=Math.LN2;function He(e){return e>>>=0,e===0?32:31-(Be(e)/Ve|0)|0}var Ue=256,We=262144,Ge=4194304;function Ke(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&261888;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 qe(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=Ke(n))):i=Ke(o):i=Ke(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ke(n))):i=Ke(o)):i=Ke(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 Je(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ye(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xe(){var e=Ge;return Ge<<=1,!(Ge&62914560)&&(Ge=4194304),e}function Ze(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Qe(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function $e(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`u`||window.document===void 0||window.document.createElement===void 0),un=!1;if(ln)try{var dn={};Object.defineProperty(dn,"passive",{get:function(){un=!0}}),window.addEventListener(`test`,dn,dn),window.removeEventListener(`test`,dn,dn)}catch{un=!1}var fn=null,pn=null,mn=null;function hn(){if(mn)return mn;var e,t=pn,n=t.length,r,i=`value`in fn?fn.value:fn.textContent,a=i.length;for(e=0;e=qn),Xn=` `,Zn=!1;function Qn(e,t){switch(e){case`keyup`:return Gn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function $n(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var er=!1;function tr(e,t){switch(e){case`compositionend`:return $n(t);case`keypress`:return t.which===32?(Zn=!0,Xn):null;case`textInput`:return e=t.data,e===Xn&&Zn?null:e;default:return null}}function nr(e,t){if(er)return e===`compositionend`||!Kn&&Qn(e,t)?(e=hn(),mn=pn=fn=null,er=!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=wr(n)}}function Er(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Er(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Dr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=It(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=It(e.document)}return t}function Or(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 kr=ln&&`documentMode`in document&&11>=document.documentMode,Ar=null,jr=null,Mr=null,Nr=!1;function Pr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Nr||Ar==null||Ar!==It(r)||(r=Ar,`selectionStart`in r&&Or(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}),Mr&&Cr(Mr,r)||(Mr=r,r=Td(jr,`onSelect`),0>=o,i-=o,Ti=1<<32-ze(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),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),B&&Di(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),o=a(y,o,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),B&&Di(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return B&&Di(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(v.key===null?g:v.key),o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),B&&Di(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===y&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case _:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===y){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===te&&Ea(l)===r.type){n(e,r.sibling),c=i(r,a.props),Na(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===y?(c=fi(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=di(a.type,a.key,a.props,null,e.mode,c),Na(c,a),c.return=e,e=c)}return o(e);case v:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=hi(a,e.mode,c),c.return=e,e=c}return o(e);case te:return a=Ea(a),b(e,r,a,c)}if(A(a))return h(e,r,a,c);if(ie(a)){if(l=ie(a),typeof l!=`function`)throw Error(s(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,Ma(a),c);if(a.$$typeof===C)return b(e,r,ta(e,a),c);Pa(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=pi(a,e.mode,c),c.return=e,e=c),o(e)):n(e,r)}return function(e,t,n,r){try{ja=0;var i=b(e,t,n,r);return Aa=null,i}catch(t){if(t===ba||t===Sa)throw t;var a=si(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ia=Fa(!0),La=Fa(!1),Ra=!1;function H(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function za(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 Ba(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Va(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,K&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=z(e),ii(e,null,n),t}return ti(e,r,t,n),z(e)}function Ha(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,tt(e,n)}}function Ua(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;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Wa=!1;function Ga(){if(Wa){var e=fa;if(e!==null)throw e}}function Ka(e,t,n,r){Wa=!1;var i=e.updateQueue;Ra=!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?(J&f)===f:(r&f)===f){f!==0&&f===da&&(Wa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Ra=!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),Gl|=o,e.lanes=o,e.memoizedState=d}}function qa(e,t){if(typeof e!=`function`)throw Error(s(191,e));e.call(t)}function Ja(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=j.T,s={};j.T=s,Ns(e,!1,t,n);try{var c=i(),l=j.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ms(e,t,ha(c,r),fu(e)):Ms(e,t,r,fu(e))}catch(n){Ms(e,t,{then:function(){},status:`rejected`,reason:n},fu())}finally{M.p=a,o!==null&&s.types!==null&&(o.types=s.types),j.T=o}}function Ss(){}function Cs(e,t,n,r){if(e.tag!==5)throw Error(s(476));var i=ws(e).queue;xs(e,i,t,ae,n===null?Ss:function(){return Ts(e),n(r)})}function ws(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fo,lastRenderedState:ae},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ts(e){var t=ws(e);t.next===null&&(t=e.alternate.memoizedState),Ms(e,t.next.queue,{},fu())}function Es(){return ea(Qf)}function Ds(){return Ao().memoizedState}function Os(){return Ao().memoizedState}function ks(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=fu();e=Ba(n);var r=Va(t,e,n);r!==null&&(mu(r,t,n),Ha(r,t,n)),t={cache:sa()},e.payload=t;return}t=t.return}}function As(e,t,n){var r=fu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ps(e)?Fs(t,n):(n=ni(e,t,n,r),n!==null&&(mu(n,e,r),Is(n,t,r)))}function js(e,t,n){Ms(e,t,n,fu())}function Ms(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ps(e))Fs(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,Sr(s,o))return ti(e,t,i,0),zl===null&&ei(),!1}catch{}if(n=ni(e,t,i,r),n!==null)return mu(n,e,r),Is(n,t,r),!0}return!1}function Ns(e,t,n,r){if(r={lane:2,revertLane:ud(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ps(e)){if(t)throw Error(s(479))}else t=ni(e,n,r,2),t!==null&&mu(t,e,2)}function Ps(e){var t=e.alternate;return e===U||t!==null&&t===U}function Fs(e,t){mo=po=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Is(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,tt(e,n)}}var Ls={readContext:ea,use:No,useCallback:bo,useContext:bo,useEffect:bo,useImperativeHandle:bo,useLayoutEffect:bo,useInsertionEffect:bo,useMemo:bo,useReducer:bo,useRef:bo,useState:bo,useDebugValue:bo,useDeferredValue:bo,useTransition:bo,useSyncExternalStore:bo,useId:bo,useHostTransitionStatus:bo,useFormState:bo,useActionState:bo,useOptimistic:bo,useMemoCache:bo,useCacheRefresh:bo};Ls.useEffectEvent=bo;var Rs={readContext:ea,use:No,useCallback:function(e,t){return ko().memoizedState=[e,t===void 0?null:t],e},useContext:ea,useEffect:W,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ss(4194308,4,ms.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ss(4194308,4,e,t)},useInsertionEffect:function(e,t){ss(4,2,e,t)},useMemo:function(e,t){var n=ko();t=t===void 0?null:t;var r=e();if(ho){Re(!0);try{e()}finally{Re(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ko();if(n!==void 0){var i=n(t);if(ho){Re(!0);try{n(t)}finally{Re(!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=As.bind(null,U,e),[r.memoizedState,e]},useRef:function(e){var t=ko();return e={current:e},t.memoizedState=e},useState:function(e){e=Go(e);var t=e.queue,n=js.bind(null,U,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:gs,useDeferredValue:function(e,t){return ys(ko(),e,t)},useTransition:function(){var e=Go(!1);return e=xs.bind(null,U,e.queue,!0,!1),ko().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=U,i=ko();if(B){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),zl===null)throw Error(s(349));J&127||Bo(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,W(Ho.bind(null,r,a,e),[e]),r.flags|=2048,as(9,{destroy:void 0},Vo.bind(null,r,a,n,t),null),n},useId:function(){var e=ko(),t=zl.identifierPrefix;if(B){var n=Ei,r=Ti;n=(r&~(1<<32-ze(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=go++,0<\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?o.createElement(`select`,{is:r.is}):o.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?o.createElement(i,{is:r.is}):o.createElement(i)}}a[ct]=t,a[lt]=r;a:for(o=t.child;o!==null;){if(o.tag===5||o.tag===6)a.appendChild(o.stateNode);else if(o.tag!==4&&o.tag!==27&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break a;for(;o.sibling===null;){if(o.return===null||o.return===t)break a;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=a;a:switch(Pd(a,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&&jc(t)}}return Ic(t),Mc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&jc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(s(166));if(e=de.current,Bi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Mi,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[ct]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Li(t,!0)}else e=Bd(e).createTextNode(r),e[ct]=t,t.stateNode=e}return Ic(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Bi(t),n!==null){if(e===null){if(!r)throw Error(s(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(s(557));e[ct]=t}else Vi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ic(t),e=!1}else n=Hi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(oo(t),t):(oo(t),null);if(t.flags&128)throw Error(s(558))}return Ic(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Bi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(s(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(s(317));i[ct]=t}else Vi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ic(t),i=!1}else i=Hi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(oo(t),t):(oo(t),null)}return oo(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),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Pc(t,t.updateQueue),Ic(t),null);case 4:return me(),e===null&&xd(t.stateNode.containerInfo),Ic(t),null;case 10:return Ji(t.type),Ic(t),null;case 19:if(se(so),r=t.memoizedState,r===null)return Ic(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)Fc(r,!1);else{if(X!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=co(e),a!==null){for(t.flags|=128,Fc(r,!1),e=a.updateQueue,t.updateQueue=e,Pc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ui(n,e),n=n.sibling;return ce(so,so.current&1|2),B&&Di(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&De()>eu&&(t.flags|=128,i=!0,Fc(r,!1),t.lanes=4194304)}}else{if(!i){if(e=co(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Pc(t,e),Fc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!B)return Ic(t),null}else 2*De()-r.renderingStartTime>eu&&n!==536870912&&(t.flags|=128,i=!0,Fc(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(Ic(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=De(),e.sibling=null,n=so.current,ce(so,i?n&1|2:n&1),B&&Di(t,r.treeForkCount),e);case 22:case 23:return oo(t),$a(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ic(t),t.subtreeFlags&6&&(t.flags|=8192)):Ic(t),n=t.updateQueue,n!==null&&Pc(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&&se(_a),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ji(oa),Ic(t),null;case 25:return null;case 30:return null}throw Error(s(156,t.tag))}function Rc(e,t){switch(Ai(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ji(oa),me(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ge(t),null;case 31:if(t.memoizedState!==null){if(oo(t),t.alternate===null)throw Error(s(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(oo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return se(so),null;case 4:return me(),null;case 10:return Ji(t.type),null;case 22:case 23:return oo(t),$a(),e!==null&&se(_a),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ji(oa),null;case 25:return null;default:return null}}function zc(e,t){switch(Ai(t),t.tag){case 3:Ji(oa),me();break;case 26:case 27:case 5:ge(t);break;case 4:me();break;case 31:t.memoizedState!==null&&oo(t);break;case 13:oo(t);break;case 19:se(so);break;case 10:Ji(t.type);break;case 22:case 23:oo(t),$a(),e!==null&&se(_a);break;case 24:Ji(oa)}}function Bc(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){Q(t,t.return,e)}}function Vc(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){Q(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Q(t,t.return,e)}}function Hc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ja(t,n)}catch(t){Q(e,e.return,t)}}}function Uc(e,t,n){n.props=Gs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Q(e,t,n)}}function Wc(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:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Q(e,t,n)}}function Gc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Q(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){Q(e,t,n)}else n.current=null}}function Kc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Q(e,e.return,t)}}function qc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[lt]=t}catch(t){Q(e,e.return,t)}}function Jc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Yc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Jc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Xc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=$t));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Xc(e,t,n),e=e.sibling;e!==null;)Xc(e,t,n),e=e.sibling}function Zc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Zc(e,t,n),e=e.sibling;e!==null;)Zc(e,t,n),e=e.sibling}function Qc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[ct]=e,t[lt]=n}catch(t){Q(e,e.return,t)}}var $c=!1,el=!1,tl=!1,nl=typeof WeakSet==`function`?WeakSet:Set,rl=null;function il(e,t){if(e=e.containerInfo,Rd=sp,e=Dr(e),Or(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break a}var o=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=o+i),f!==a||r!==0&&f.nodeType!==3||(l=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=o),p===a&&++d===r&&(l=o),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,rl=t;rl!==null;)if(t=rl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,rl=e;else for(;rl!==null;){switch(t=rl,a=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(a,r,n),a[ct]=e,xt(a),r=a;break a;case`link`:var o=Vf(`link`,`href`,i).get(r+(n.href||``));if(o){for(var c=0;cg&&(o=g,g=h,h=o);var _=Tr(s,h),v=Tr(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,j.T=null,n=cu,cu=null;var a=iu,o=ou;if(ru=0,au=iu=null,ou=0,K&6)throw Error(s(331));var c=K;if(K|=4,Pl(a.current),El(a,a.current,o,n),K=c,rd(0,!1),Le&&typeof Le.onPostCommitFiberRoot==`function`)try{Le.onPostCommitFiberRoot(Ie,a)}catch{}return!0}finally{M.p=i,j.T=r,Bu(e,t)}}function Uu(e,t,n){t=_i(n,t),t=Zs(e.stateNode,t,2),e=Va(e,t,2),e!==null&&(Qe(e,2),nd(e))}function Q(e,t,n){if(e.tag===3)Uu(e,e,n);else for(;t!==null;){if(t.tag===3){Uu(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(nu===null||!nu.has(r))){e=_i(n,e),n=Qs(2),r=Va(t,n,2),r!==null&&($s(n,r,t,e),Qe(r,2),nd(r));break}}t=t.return}}function Wu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Rl;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)||(Ul=!0,i.add(n),e=Gu.bind(null,e,t,n),t.then(e,e))}function Gu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,zl===e&&(J&n)===n&&(X===4||X===3&&(J&62914560)===J&&300>De()-Ql?!(K&2)&&xu(e,0):ql|=n,Yl===J&&(Yl=0)),nd(e)}function Ku(e,t){t===0&&(t=Xe()),e=ri(e,t),e!==null&&(Qe(e,t),nd(e))}function qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ku(e,n)}function Ju(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(s(314))}r!==null&&r.delete(t),Ku(e,n)}function Yu(e,t){return Ce(e,t)}var Xu=null,Zu=null,Qu=!1,$u=!1,ed=!1,td=0;function nd(e){e!==Zu&&e.next===null&&(Zu===null?Xu=Zu=e:Zu=Zu.next=e),$u=!0,Qu||(Qu=!0,ld())}function rd(e,t){if(!ed&&$u){ed=!0;do for(var n=!1,r=Xu;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-ze(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,cd(r,a))}else a=J,a=qe(r,r===zl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Je(r,a)||(n=!0,cd(r,a))}r=r.next}while(n);ed=!1}}function id(){ad()}function ad(){$u=Qu=!1;var e=0;td!==0&&Gd()&&(e=td);for(var t=De(),n=null,r=Xu;r!==null;){var i=r.next,a=od(r,t);a===0?(r.next=null,n===null?Xu=i:n.next=i,i===null&&(Zu=n)):(n=r,(e!==0||a&3)&&($u=!0)),r=i}ru!==0&&ru!==5||rd(e,!1),td!==0&&(td=0)}function od(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&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Rt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),xt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Rt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Rt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Rt(n.imageSizes)+`"]`)):i+=`[href="`+Rt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),xt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Rt(r)+`"][href="`+Rt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),xt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=bt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);xt(c),Pd(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,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=bt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),xt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=bt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),xt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var i=(i=de.current)?gf(i):null;if(!i)throw Error(s(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=bt(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,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=Af(n.href);var a=bt(i).hoistableStyles,o=a.get(e);if(o||(i=i.ownerDocument||i,o={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,o),(a=i.querySelector(jf(e)))&&!a._p&&(o.instance=a,o.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),a||Nf(i,e,n,o.state))),t&&r===null)throw Error(s(528,``));return o}if(t&&r!==null)throw Error(s(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=bt(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(s(444,e))}}function Af(e){return`href="`+Rt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),xt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Rt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Rt(n.href)+`"]`);if(r)return t.instance=r,xt(r),r;var i=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),xt(r),Pd(r,`style`,i),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Af(n.href);var a=e.querySelector(jf(i));if(a)return t.state.loading|=4,t.instance=a,xt(a),a;r=Mf(n),(i=mf.get(i))&&Rf(r,i),a=(e.ownerDocument||e).createElement(`link`),xt(a);var o=a;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),t.state.loading|=4,Lf(a,n.precedence,e),t.instance=a;case`script`:return a=Pf(n.src),(i=e.querySelector(Ff(a)))?(t.instance=i,xt(i),i):(r=n,(i=mf.get(a))&&(r=h({},n),zf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),xt(i),Pd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(s(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(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 Uf(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 Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(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=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,xt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),xt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(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=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.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=s()})),l=n(),u=c(),d=new class{state={conn:`connecting`,lastFrameAt:0,tick:0,alerts:[]};listeners=new Set;backoff=500;timer=null;started=!1;frameSubs=new Set;getState=()=>this.state;subscribe=e=>(this.listeners.add(e),this.start(),()=>{this.listeners.delete(e)});onFrame=e=>(this.frameSubs.add(e),()=>{this.frameSubs.delete(e)});set(e){this.state={...this.state,...e};for(let e of this.listeners)e()}start(){this.started||typeof WebSocket>`u`||(this.started=!0,this.connect())}connect(){if(typeof location>`u`||typeof WebSocket>`u`)return;let e=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/v1/live`;this.set({conn:`connecting`});let t;try{t=new WebSocket(e)}catch{this.scheduleReconnect();return}t.onopen=()=>{this.backoff=500,this.set({conn:`open`})},t.onmessage=e=>{let t;try{t=JSON.parse(String(e.data))}catch{return}this.handle(t)},t.onclose=()=>{this.set({conn:`closed`}),this.scheduleReconnect()},t.onerror=()=>{t.close()}}scheduleReconnect(){this.timer===null&&(this.timer=window.setTimeout(()=>{this.timer=null,this.connect()},this.backoff),this.backoff=Math.min(this.backoff*2,1e4))}handle(e){let t=Date.now();for(let t of this.frameSubs)try{t(e)}catch(e){console.error(`[caprock] live frame subscriber failed`,e)}switch(e.type){case`alert`:this.set({lastFrameAt:t,alerts:[e.data,...this.state.alerts.filter(t=>t.session_id!==e.data.session_id)].slice(0,50),tick:this.state.tick+1});break;case`event`:this.set({lastFrameAt:t,lastEvent:e.data,tick:this.state.tick+1});break;case`session`:this.set({lastFrameAt:t,tick:this.state.tick+1});break;case`task`:this.set({lastFrameAt:t,tick:this.state.tick+1});break;default:this.set({lastFrameAt:t})}}dismissAlert(e){this.set({alerts:this.state.alerts.filter(t=>t.session_id!==e)})}};function f(){return(0,l.useSyncExternalStore)(d.subscribe,d.getState,d.getState)}function p(e=400){let{tick:t}=f(),[n,r]=m(t,e);return(0,l.useEffect)(()=>{r(t)},[t,r]),n}function m(e,t){let[n,r]=(0,l.useState)(e),i=(0,l.useRef)(null),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},[]),[n,(0,l.useCallback)(e=>{a.current=e,i.current===null&&(i.current=window.setTimeout(()=>{i.current=null,r(a.current)},t))},[t])]}function h(e){let[t,n]=e.replace(/^#\/?/,``).split(`?`),r=(t??``).split(`/`).filter(Boolean),i=new URLSearchParams(n??``),a=i.get(`tab`)??void 0,o=Number(i.get(`at`)),s=Number.isFinite(o)&&o>0?o:void 0;switch(r[0]){case void 0:case``:case`now`:return{name:`now`};case`session`:return r[1]?{name:`session`,id:decodeURIComponent(r[1]),tab:a,at:s}:{name:`now`};case`cost`:return{name:`cost`};case`history`:return{name:`history`};case`tasks`:return{name:`tasks`};case`graph`:return{name:`graph`};case`notes`:return{name:`notes`};case`settings`:return{name:`settings`};default:return{name:`now`}}}function g(e){switch(e.name){case`now`:return`#/`;case`session`:{let t=new URLSearchParams;e.tab&&t.set(`tab`,e.tab),e.at&&t.set(`at`,String(e.at));let n=t.toString();return`#/session/${encodeURIComponent(e.id)}${n?`?${n}`:``}`}case`cost`:return`#/cost`;case`history`:return`#/history`;case`tasks`:return`#/tasks`;case`graph`:return`#/graph`;case`notes`:return`#/notes`;case`settings`:return`#/settings`}}function _(){let[e,t]=(0,l.useState)(()=>h(location.hash));return(0,l.useEffect)(()=>{let e=()=>t(h(location.hash));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}function v(e){location.hash=g(e)}var y=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2}),b=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:4,maximumFractionDigits:4});function x(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function S(e){return x(e)===null?`—`:(e=e,e!==0&&Math.abs(e)<.01?b.format(e):y.format(e))}function C(e){if(x(e)===null)return`—`;e=e;let t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(2)}B`:t>=1e6?`${(e/1e6).toFixed(2)}M`:t>=1e4?`${(e/1e3).toFixed(1)}k`:new Intl.NumberFormat(`en-US`).format(e)}function w(e,t=0){if(x(e)===null)return`—`;let n=e;if(t===0){let e=Math.floor(n);return`${Number.isFinite(e)?e:0}%`}let r=Math.min(100,Math.max(0,Math.trunc(x(t)??0)));return`${e.toFixed(r)}%`}function T(e,t=Date.now()){if(!e)return`—`;let n=typeof e==`number`?e:Date.parse(e);if(Number.isNaN(n))return`—`;let r=Math.max(0,Math.round((t-n)/1e3));if(r<5)return`now`;if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<48?`${a}h ago`:`${Math.floor(a/24)}d ago`}function ee(e){if(x(e)===null)return`—`;if(e<1e3)return`${Math.round(e)}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function E(e){return e.length>8?e.slice(0,8):e}function te(e){let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n>=0?t.slice(n+1):t}function D(e){let t=/^mcp__(.+?)__(.+)$/.exec(e);return t?`${t[1]}·${t[2]}`:e}function ne(e){return e.replace(/-\d{6,}$/,`…`)}function re(e){let[t,n]=(0,l.useState)(()=>Date.now());return(0,l.useEffect)(()=>{let t=window.setInterval(()=>n(Date.now()),e);return()=>window.clearInterval(t)},[e]),t}var ie=`caprock-theme`;function O(){let e=localStorage.getItem(ie);return e===`dark`||e===`light`?e:window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`}function k(e){document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=e}function A(){let[e,t]=(0,l.useState)(O);return(0,l.useEffect)(()=>{k(e),localStorage.setItem(ie,e)},[e]),[e,()=>t(e=>e===`dark`?`light`:`dark`)]}async function j(e,t,n=`POST`){let r=await fetch(e,{method:n,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let e;try{e=await r.json()}catch{}throw new M(r.status,`${r.status} ${r.statusText}`,e)}return r.status===204?void 0:await r.json()}var M=class extends Error{status;body;constructor(e,t,n){super(t),this.status=e,this.body=n}};function ae(e){if(e instanceof M){let t=e.body,n=t?.error??e.message;return t?.detail?`${n} — ${t.detail}`:n}return e instanceof Error?e.message:String(e)}async function N(e){let t=await fetch(e,{headers:{Accept:`application/json`}});if(!t.ok){let e;try{e=await t.json()}catch{}throw new M(t.status,`${t.status} ${t.statusText}`,e)}return await t.json()}var P={sessions:(e=!1)=>N(`/v1/sessions${e?`?active=true`:``}`),session:e=>N(`/v1/sessions/${encodeURIComponent(e)}`),events:(e,t=0,n=500)=>N(`/v1/sessions/${encodeURIComponent(e)}/events?after=${t}&limit=${n}`),eventsBefore:(e,t,n=200)=>N(`/v1/sessions/${encodeURIComponent(e)}/events?before=${t}&limit=${n}`),recentEvents:(e,t=2e3)=>N(`/v1/sessions/${encodeURIComponent(e)}/events?newest=1&limit=${t}`),diff:e=>N(`/v1/sessions/${encodeURIComponent(e)}/diff`),notes:(e,t=200)=>N(`/v1/sessions/${encodeURIComponent(e)}/notes?limit=${t}`),searchNotes:(e,t=100,n=0)=>N(`/v1/notes?q=${encodeURIComponent(e)}&limit=${t}${n?`&before=${n}`:``}`),testReport:()=>j(`/v1/report/test`,{}),settings:()=>N(`/v1/settings`),update:()=>N(`/v1/update`),checkUpdate:()=>j(`/v1/update/check`,{}),saveSettings:e=>j(`/v1/settings`,e,`PUT`),summary:(e=`today`,t)=>N(`/v1/stats/summary?range=${e}${t&&t!==`all`?`&agent=${t}`:``}`),daily:(e=30)=>N(`/v1/stats/daily?days=${e}`),premium:()=>N(`/v1/premium`),gemini:()=>N(`/v1/gemini`),askGemini:(e,t)=>j(`/v1/gemini/ask`,{prompt:e,model:t}),browse:(e=``)=>N(`/v1/browse${e?`?dir=${encodeURIComponent(e)}`:``}`),recentDirs:()=>N(`/v1/recent-dirs`),history:(e=`all`)=>N(`/v1/history?range=${e}`),enableHive:(e,t)=>j(`/v1/hive`,{hive:e??``,repo:t??``}),tasks:()=>N(`/v1/tasks`),task:e=>N(`/v1/tasks/${encodeURIComponent(e)}`),createTask:e=>j(`/v1/tasks`,e),approve:(e,t)=>j(`/v1/tasks/${encodeURIComponent(e)}/${t?`approve`:`reject`}`,{}),startOrchestrator:()=>j(`/v1/orchestrator/start`,{}),stopOrchestrator:()=>j(`/v1/orchestrator/stop`,{}),status:()=>N(`/v1/status`),spawn:e=>j(`/v1/agents`,e),signal:(e,t)=>j(`/v1/agents/${encodeURIComponent(e)}/signal`,{action:t}),paste:(e,t)=>j(`/v1/paste`,{type:e,data:t}),agentInput:(e,t)=>j(`/v1/agents/${encodeURIComponent(e)}/input`,{data:t})},oe=[{id:`macos`,label:`macOS`},{id:`linux`,label:`Linux`},{id:`windows`,label:`Windows`}],se={cmd:`caprock down && caprock up`,note:`The running daemon is the old binary until it restarts. Your database is untouched.`},ce={cmd:`caprock status`,note:`Confirms the new version is the one running, and that hooks are still registered.`},le={label:`Homebrew`,steps:[{cmd:`brew update && brew upgrade caprock`,note:`The update is not optional: without it Homebrew reads a cached copy of the tap, refreshed at most once a day, and reports "already installed" for a release that is already out.`},se,ce]},ue={label:`Scoop`,steps:[{cmd:`scoop update caprock`,note:`Scoop refreshes its buckets as part of this, so no separate step.`},se,ce]},de={label:`go install`,steps:[{cmd:`go install github.com/dspv/caprock/cmd/caprock@latest`,note:`Also install the hook shim: same command with cmd/caprock-hook.`},se,ce]},fe={label:`Downloaded binary`,steps:[{cmd:``,note:`Download the archive for your platform from the release page, and replace the caprock and caprock-hook binaries with the ones inside it.`},se,ce]};function pe(e){switch(e){case`macos`:return[le,de,fe];case`linux`:return[le,de,fe];case`windows`:return[ue,de,fe]}}function me(e,t){let n=`${t??``} ${e}`.toLowerCase();return n.includes(`win`)?`windows`:n.includes(`mac`)||n.includes(`darwin`)||n.includes(`iphone`)||n.includes(`ipad`)?`macos`:`linux`}function he(e){if(e&&e.startsWith(`scoop`))return`windows`}function ge(e,t){return e?be(e,pe(t))===void 0:!1}var _e=`caprock-update-platform`;function ve(){try{let e=localStorage.getItem(_e);return oe.some(t=>t.id===e)?e:void 0}catch{return}}function ye(e){try{localStorage.setItem(_e,e)}catch{}}function be(e,t){if(!e)return;let n=e.split(/\s+/)[0];if(n)return t.find(e=>e.steps.some(e=>e.cmd.startsWith(n)))}function F(e,t=[],n={}){let{live:r=!0,intervalMs:i=0}=n,a=p(400),[o,s]=(0,l.useState)({data:void 0,error:void 0,loading:!0,refresh:()=>{},loadedAt:0}),c=(0,l.useRef)(0),u=(0,l.useRef)(e);u.current=e;let d=(0,l.useCallback)(()=>{let e=++c.current;u.current().then(t=>{e===c.current&&s(e=>({...e,data:t,error:void 0,loading:!1,loadedAt:Date.now()}))},t=>{e===c.current&&s(e=>({...e,error:t,loading:!1}))})},[]);return(0,l.useEffect)(d,[d,...t]),(0,l.useEffect)(()=>{r&&a>0&&d()},[r,a,d]),(0,l.useEffect)(()=>{if(!i)return;let e=window.setInterval(d,i);return()=>window.clearInterval(e)},[i,d]),{...o,refresh:d}}var xe=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),I=e(((e,t)=>{t.exports=xe()}))(),Se=[{label:`Pro`,kind:`flat`,usd:20,note:`$20/mo`},{label:`Max 5×`,kind:`flat`,usd:100,note:`$100/mo`},{label:`Max 20×`,kind:`flat`,usd:200,note:`$200/mo`},{label:`Team seat`,kind:`flat`,usd:30,note:`$30/seat/mo`},{label:`API / Bedrock`,kind:`metered`,usd:0,note:`billed per token`}],Ce,we=null,Te=new Set;function Ee(){for(let e of Te)e()}function De(){let[,e]=(0,l.useState)(0);return(0,l.useEffect)(()=>{let t=()=>e(e=>e+1);return Te.add(t),!Ce&&!we&&(we=P.settings().then(e=>{Ce=e}).catch(()=>{Ce={update_checks:!1,plan_kind:``,plan_label:``,plan_usd_per_month:0}}).finally(()=>{we=null,Ee()})),()=>{Te.delete(t)}},[]),[Ce,e=>{Ce={...Ce??{},...e},Ee(),P.saveSettings(e).catch(()=>{})}]}function Oe({plan:e,onSave:t}){let[n,r]=(0,l.useState)(!1),i=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]);let a=e?.plan_kind?e.plan_kind===`metered`?e.plan_label||`API`:`${e.plan_label||`plan`} · ${S(e.plan_usd_per_month)}/mo`:`set plan`;return(0,I.jsxs)(`div`,{className:`relative`,ref:i,children:[(0,I.jsx)(`button`,{onClick:()=>r(e=>!e),className:`mono text-[11px] px-1.5 py-0.5 rounded-sm border ${e?.plan_kind?`border-border text-fg-muted hover:text-fg`:`border-accent/50 text-accent`}`,title:`How you pay for Claude Code — Caprock cannot detect this, so you tell it`,children:a}),n&&(0,I.jsx)(ke,{plan:e,onSave:e=>{t(e),r(!1)}})]})}function ke({plan:e,onSave:t}){let[n,r]=(0,l.useState)(String(e?.plan_usd_per_month||``));return(0,I.jsxs)(`div`,{className:`absolute right-0 top-7 z-20 w-[268px] border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg p-2`,children:[(0,I.jsx)(`div`,{className:`text-[11px] text-fg-muted px-1 pb-1.5`,children:`How do you pay for Claude Code? Caprock can't detect this and never guesses.`}),Se.map(n=>{let r=e?.plan_label===n.label;return(0,I.jsxs)(`button`,{onClick:()=>t({plan_kind:n.kind,plan_label:n.label,plan_usd_per_month:n.usd}),className:`w-full flex items-baseline gap-2 px-1.5 py-1 rounded-sm text-left text-[12px] hover:bg-panel-2 ${r?`text-accent`:`text-fg`}`,children:[(0,I.jsx)(`span`,{children:n.label}),(0,I.jsx)(`span`,{className:`mono text-[11px] text-fg-faint ml-auto`,children:n.note})]},n.label)}),(0,I.jsxs)(`div`,{className:`border-t border-border mt-1.5 pt-1.5 px-1.5`,children:[(0,I.jsx)(`label`,{className:`text-[11px] text-fg-faint`,children:`Or a different monthly price`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,I.jsx)(`span`,{className:`mono text-[12px] text-fg-faint`,children:`$`}),(0,I.jsx)(`input`,{className:`input`,inputMode:`decimal`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. 150`}),(0,I.jsx)(`button`,{className:`text-[11px] border border-border px-1.5 py-1 rounded-sm hover:border-border-strong`,onClick:()=>{let e=Number(n);!Number.isFinite(e)||e<0||t({plan_kind:`flat`,plan_label:`plan`,plan_usd_per_month:e})},children:`set`})]})]})]})}var Ae=[{id:`bug`,label:`bug`,hint:`What did you see?`,gh:`bug`},{id:`feature`,label:`feature`,hint:`What would you want?`,gh:`enhancement`},{id:`unclear`,label:`unclear`,hint:`What did not make sense?`,gh:`question`},{id:`other`,label:`other`,hint:`Anything else — a sentence is enough.`,gh:`question`}],je=`dspv/caprock`;function Me(e,t){if(!e)return[`Screen: ${t}`];let n=e.hooks,r=n?(n.missing?.length??0)>0?`partly installed`:n.shim_exists?`installed`:`not installed`:`unknown`;return[`Caprock ${e.version}${e.platform?` (${e.platform})`:``}`,`Screen: ${t}`,`${e.events.toLocaleString(`en-US`)} events${e.owned_active?` · ${e.owned_active} owned session(s) running`:``}`,`Hooks: ${r} · Orchestration: ${e.orchestration?`on`:`off`}`]}function Ne(e,t,n){let r=n.trim().split(` -`)[0]?.trim()??``;return`[${e}] ${t}: ${r.length>60?`${r.slice(0,57)}…`:r}`}function Pe(e,t,n){let r=e===`bug`?`What happened`:e===`feature`?`What is missing`:e===`unclear`?`What is unclear`:`Feedback`,i=t.trim(),a=i.length>6e3?`${i.slice(0,Ie)}\n\n_[…truncated — the rest did not fit in the link; paste it below]_`:i;return[`### ${r}`,``,a,``,`### Context`,``,...n.map(e=>`- ${e}`),``,`Filed from the Caprock dashboard. Nothing was sent automatically — this issue was opened in your browser for you to review.`].join(` -`)}function Fe(e,t,n,r){let i=Ae.find(t=>t.id===e)??Ae[0];return`https://github.com/${je}/issues/new?${new URLSearchParams({title:Ne(e,t,n),body:Pe(e,n,r),labels:i.gh}).toString()}`}var Ie=6e3;function Le(e){return e.trim().length>=8}function Re({screen:e}){let[t,n]=(0,l.useState)(!1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{onClick:()=>n(!0),className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,title:`Report a bug, ask for something, or say what was unclear`,children:`feedback`}),t&&(0,I.jsx)(ze,{screen:e,onClose:()=>n(!1)})]})}function ze({screen:e,onClose:t}){let[n,r]=(0,l.useState)(`bug`),[i,a]=(0,l.useState)(``),o=Me(F(()=>P.status(),[],{live:!1,intervalMs:0}).data,e),s=Le(i),c=Ae.find(e=>e.id===n)??Ae[0],u=()=>{s&&(window.open(Fe(n,e,i,o),`_blank`,`noopener`),t())};return(0,I.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-start justify-center pt-[12vh] px-4`,onClick:t,children:(0,I.jsxs)(`div`,{className:`w-full max-w-[660px] border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`px-4 pt-3 pb-2 border-b border-border flex items-center`,children:[(0,I.jsx)(`span`,{className:`text-[15px] font-medium`,children:`Tell us what happened`}),(0,I.jsx)(`button`,{onClick:t,className:`ml-auto text-[16px] leading-none text-fg-faint hover:text-fg`,children:`×`})]}),(0,I.jsxs)(`div`,{className:`p-4 grid gap-3`,children:[(0,I.jsx)(`div`,{className:`flex gap-1.5`,children:Ae.map(e=>(0,I.jsx)(`button`,{onClick:()=>r(e.id),className:`text-[13px] px-3.5 py-1.5 rounded-sm border font-mono ${e.id===n?`border-accent/60 bg-accent/10 text-accent`:`border-border text-fg-muted hover:text-fg`}`,children:e.label},e.id))}),(0,I.jsx)(`textarea`,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:c.hint,rows:6,className:`input w-full resize-y text-[14px] leading-relaxed`,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&u()}}),(0,I.jsxs)(`div`,{className:`border border-border rounded-sm bg-panel-2/50 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint mb-1`,children:`Attached`}),(0,I.jsx)(`ul`,{className:`text-[11px] text-fg-muted num grid gap-0.5`,children:o.map(e=>(0,I.jsx)(`li`,{children:e},e))})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`button`,{onClick:u,disabled:!s,className:`text-[12px] px-3 py-1.5 rounded-sm border ${s?`border-accent/50 bg-accent/10 text-accent hover:bg-accent/20`:`border-border text-fg-faint cursor-not-allowed`}`,children:`Open a GitHub issue →`}),(0,I.jsx)(`span`,{className:`text-[12px] ${s?`text-fg-faint`:`text-fg-muted`}`,children:s?`⌘↵ to open`:`One sentence is enough.`})]}),(0,I.jsx)(`p`,{className:`text-[11px] text-fg-faint leading-relaxed`,children:`Nothing is sent from here — the issue opens prefilled in your browser for you to submit.`})]})]})})}var Be=1200,Ve=630;function He(e,t){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}var Ue={command:`running commands`,edit:`writing code`,read:`reading code`,mcp:`MCP tools`,web:`web research`,other:`other tools`,none:`no tool call`};function We(e){return e.slice(e.lastIndexOf(`/`)+1).replace(/^claude-/,``).replace(/-\d{8}$/,``).slice(0,18)}function Ge(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function Ke(e,t){let n=He(`--color-bg`,`#141414`),r=He(`--color-panel`,`#1a1a19`),i=He(`--color-border`,`#2a2a28`),a=He(`--color-fg`,`#e8e6e2`),o=He(`--color-fg-muted`,`#a9a59e`),s=He(`--color-fg-faint`,`#6f6b64`),c=He(`--color-accent`,`#feb157`),l=He(`--color-ok`,`#7fc99a`),u=`"JetBrains Mono", ui-monospace, monospace`,d=`"Hanken Grotesk", ui-sans-serif, system-ui, sans-serif`;e.fillStyle=n,e.fillRect(0,0,Be,Ve);let f=(t,n,r,i,a=12)=>{e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+r,n,t+r,n+i,a),e.arcTo(t+r,n+i,t,n+i,a),e.arcTo(t,n+i,t,n,a),e.arcTo(t,n,t+r,n,a),e.closePath()},p=(t,n,a,o)=>{f(t,n,a,o),e.fillStyle=r,e.fill(),e.strokeStyle=i,e.lineWidth=1,e.stroke()},m=(t,n,r,i,a,o=d,s=400,c=`left`)=>{e.fillStyle=a,e.font=`${s} ${i}px ${o}`,e.textAlign=c,e.fillText(r,t,n)};e.font=`600 32px ${d}`;let h=`My stats on`,g=e.measureText(` `).width,_=e.measureText(h).width;m(64,78,h,32,a,d,600);let v=64+_+g;m(v,78,`caprock.dev`,32,c,d,600);let y=e.measureText(`caprock.dev`).width,b=t.takenAt.toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`});m(v+y+g*2,78,`– ${b}`,26,s,d,600),[[`TODAY`,S(t.today.cost),`${t.today.sessions} sessions`,c],[`THIS WEEK`,S(t.week.cost),`${t.week.sessions} sessions`,a],[`THIS MONTH`,S(t.month.cost),`${Ge(t.month.tokens)} tokens`,a],[`ALL TIME`,S(t.allTime.cost),`${t.allTime.days} active days`,c],[`A DAY`,S(t.allTime.cost/Math.max(1,t.allTime.days)),`on average`,a],[`TOKENS`,Ge(t.allTime.tokens),`all time`,a],[`PER 1M TOKENS`,S(t.allTime.cost/Math.max(1,t.allTime.tokens/1e6)),`what a million costs`,a],[`CACHE HIT`,`${Math.round(t.cacheHitPct)}%`,`input cost cut`,l]].forEach(([e,t,n,r],i)=>{let a=64+i%4*272,c=130+Math.floor(i/4)*114;p(a,c,256,98),m(a+20,c+30,e,13,s,u),m(a+20,c+56,t,28,r,d,600),m(a+20,c+81,n,14,o)});let x=(t,n,r,i)=>{let l=44+r.length*26+12;p(t,n,524,l),m(t+20,n+30,i,13,s,u);let d=Math.max(...r.map(e=>e.cost),1),h=r.reduce((e,t)=>e+t.cost,0),g=t+170;return r.forEach((r,i)=>{let l=n+62+i*26;m(t+20,l,r.label,14,o,u),e.fillStyle=c,e.globalAlpha=.85;let p=Math.max(2,164*(r.cost/d));f(g,l-10,p,10,Math.min(3,p/2)),e.fill(),e.globalAlpha=1,m(t+524-62,l,S(r.cost),14,a,u,400,`right`);let _=h>0?Math.max(1,Math.floor(100*r.cost/h)):0;m(t+524-20,l,`${_}%`,14,s,u,400,`right`)}),l},C=x(64,372,t.models,`WHERE THE MONEY WENT`);x(612,372,t.work,`WHAT IT WENT ON`);let w=372+C+34;m(64,w,`at API list prices — not a bill, and not money saved`,14,s),m(1136,w,`What's yours?`,15,c,d,600,`right`),e.textAlign=`left`}function qe(e=new Date){let t=e=>String(e).padStart(2,`0`);return`caprock-${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}.png`}async function Je(){let[e,t,n,r]=await Promise.all([P.summary(`today`),P.summary(`7d`),P.summary(`30d`),P.history(`all`)]),i=e=>e.tokens_in+e.tokens_out+e.cache_read+e.cache_write;return{takenAt:new Date,today:{cost:e.cost_usd,sessions:e.sessions},week:{cost:t.cost_usd,sessions:t.sessions},month:{cost:n.cost_usd,tokens:i(n)},allTime:{cost:r.totals.cost_usd,days:r.totals.days,tokens:i(r.summary)},cacheHitPct:(n.savings?.hit_rate??0)*100,models:(n.models??[]).slice(0,5).map(e=>({label:We(e.model),cost:e.cost_usd})),work:(n.work??[]).slice(0,5).map(e=>({label:Ue[e.kind]??e.kind,cost:e.cost_usd}))}}async function Ye(e){let t=document.createElement(`canvas`);t.width=Be,t.height=Ve;let n=null;try{n=t.getContext(`2d`)}catch{return null}return n?(Ke(n,e),await new Promise(e=>{if(typeof t.toBlob!=`function`){e(null);return}t.toBlob(t=>e(t),`image/png`)})):null}function Xe(e){let t=`over ${e.days} active days`;return`${S(e.cost_usd)} of Claude Code ${t}, across ${e.sessions.toLocaleString(`en-US`)} sessions — measured on my own machine with Caprock. https://caprock.dev`}function Ze(){let[e,t]=(0,l.useState)(!1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{onClick:()=>t(!0),className:`rounded-md border border-accent/45 bg-accent/[0.08] px-2 py-0.5 text-accent hover:bg-accent/[0.16]`,title:`Draw a shareable image of your figures`,children:`Share`}),e&&(0,I.jsx)(Qe,{onClose:()=>t(!1)})]})}function Qe({onClose:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(``),s=async()=>{let[e,t]=await Promise.all([Je(),P.history(`all`)]);return{blob:await Ye(e),text:Xe(t.totals)}},c=async()=>{if(!r){i(!0),n(!0),o(``);try{let{blob:t}=await s();if(!t){o(`Could not draw the card in this browser.`),i(!1);return}let r=new File([t],qe(),{type:`image/png`});n(!1),await navigator.share({files:[r]}),e()}catch(e){e?.name!==`AbortError`&&o(`Sharing was not available — the card was not sent.`),i(!1)}finally{n(!1)}}},u=async e=>{if(!r){i(!0),n(!0),o(``);try{let{blob:t,text:n}=await s();if(!t){o(`Could not draw the card in this browser.`);return}let r=URL.createObjectURL(t),i=document.createElement(`a`);if(i.href=r,i.download=qe(),i.click(),URL.revokeObjectURL(r),e===`download`){o(`Saved to your downloads.`);return}let a=e===`x`?`https://x.com/intent/tweet?text=${encodeURIComponent(n)}`:`https://www.linkedin.com/feed/?shareActive=true&text=${encodeURIComponent(n)}`;window.open(a,`_blank`,`noopener`),o(`Card saved and the post opened — drag the image in.`)}finally{n(!1),i(!1)}}},d=typeof navigator<`u`&&typeof navigator.canShare==`function`&&navigator.canShare({files:[new File([],`x.png`,{type:`image/png`})]});return(0,I.jsx)(`div`,{className:`fixed inset-0 z-30 flex items-start justify-center bg-black/50 px-4 pt-[14vh]`,onClick:e,role:`dialog`,"aria-modal":`true`,"aria-label":`Share your figures`,children:(0,I.jsxs)(`div`,{className:`w-[420px] max-w-full rounded-[var(--radius-panel)] border border-border-strong bg-panel`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`header`,{className:`flex items-center border-b border-border px-4 py-3`,children:[(0,I.jsx)(`h2`,{className:`text-[13px] font-medium text-fg`,children:`Share your figures`}),(0,I.jsx)(`button`,{onClick:e,className:`ml-auto text-fg-muted hover:text-fg`,"aria-label":`Close`,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-2.5`,children:[d&&(0,I.jsxs)(`button`,{onClick:c,disabled:r,className:`rounded-md border border-accent bg-accent/15 px-4 py-3 text-[14px] font-medium text-accent hover:bg-accent/25 disabled:opacity-50`,children:[t?`Drawing the card…`:`Send it somewhere`,(0,I.jsx)(`span`,{className:`mt-0.5 block text-[12px] font-normal text-fg-muted`,children:`Opens your share menu — Messages, Mail, anywhere`})]}),(0,I.jsxs)(`button`,{onClick:()=>u(`download`),disabled:r,className:`rounded-md border border-border bg-transparent px-4 py-3 text-[14px] text-fg transition-colors hover:border-border-strong hover:bg-panel-2 disabled:opacity-50`,children:[t&&!d?`Drawing the card…`:`Save the image`,(0,I.jsx)(`span`,{className:`mt-0.5 block text-[12px] text-fg-muted`,children:`A PNG in your downloads, to post wherever you like`})]})]}),(0,I.jsxs)(`ul`,{className:`mt-4 grid gap-1 text-[13px] text-fg-muted`,children:[(0,I.jsx)(`li`,{children:`Totals only — no names, no paths, nothing Claude wrote.`}),(0,I.jsx)(`li`,{children:`Drawn on your machine. Uploaded nowhere.`})]}),a&&(0,I.jsx)(`p`,{className:`mt-2 text-[12px] text-fg-muted`,children:a})]})]})})}function $e(){let e=F(()=>P.history(`all`),[],{intervalMs:6e4}),[t,n]=(0,l.useState)(!1),r=e.data?.totals;return!r||r.sessions===0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{onClick:()=>n(!0),className:`rounded-md border border-accent/45 bg-accent/[0.08] px-2.5 py-1 text-[12px] text-accent hover:bg-accent/[0.16]`,title:`Draw a shareable image of these figures`,children:`Share these numbers`}),t&&(0,I.jsx)(Qe,{onClose:()=>n(!1)})]})}var et={cap:{title:`A daily cap that pauses sessions`,body:`A number for the day. Cross it and Caprock stops its own sessions.`,points:[`A runaway loop stops at $40 instead of finishing at $400`,`It happens while you are asleep, not in tomorrow’s summary`,`Your own sessions are never touched — only the ones Caprock started`]},gemini:{title:`Ask Gemini, on your own key`,body:`A second model inside Caprock, paid for by you, at Google’s prices.`,points:[`Ask about your own sessions without leaving the dashboard`,`What it costs is counted and shown beside your Claude spend`,`Caprock never stores the key — it reads it from your environment`],setup:`Set GEMINI_API_KEY in the daemon’s environment and restart it. Google bills you directly.`},report:{title:`A weekly report, sent where you are`,body:`Monday morning, before you open a terminal.`,points:[`What moved: the repository that cost 3× its usual week`,`Last week against the one before it, per repository and model`,`Through your own Telegram bot — nothing passes our server`],setup:`Setup: one message to BotFather, about two minutes.`}};function tt({p:e,onClose:t}){return e?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsxs)(`a`,{href:e.yearly.url,target:`_blank`,rel:`noreferrer`,onClick:t,className:`rounded-sm bg-premium/75 px-3 py-2.5 text-center text-[14px] font-medium text-white no-underline hover:bg-premium`,children:[`$`,e.yearly.charged_usd,` / year`]}),(0,I.jsxs)(`a`,{href:e.lifetime?.url,target:`_blank`,rel:`noreferrer`,onClick:t,className:`rounded-sm bg-premium-strong px-3 py-2.5 text-center text-[14px] font-medium text-white no-underline hover:brightness-110`,children:[`$`,e.lifetime?.charged_usd,` once`]})]}),(0,I.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 text-center text-[11px] leading-snug text-fg-faint`,children:[(0,I.jsx)(`span`,{children:`Every Premium feature, renews yearly`}),(0,I.jsx)(`span`,{children:`Every Premium feature, now and future — no renewal`})]})]}):(0,I.jsx)(`div`,{className:`h-[92px] text-[13px] text-fg-faint`,children:`…`})}function nt({feature:e,onClose:t}){let n=F(()=>P.premium(),[]).data,r=et[e];return(0,l.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,I.jsx)(`div`,{className:`fixed inset-0 z-30 flex items-start justify-center bg-black/50 px-4 pt-[12vh]`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-label":`Caprock Premium`,children:(0,I.jsxs)(`div`,{className:`w-[440px] max-w-full rounded-[var(--radius-panel)] border border-border-strong bg-panel`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`header`,{className:`flex items-start gap-3 px-5 pt-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[11px] uppercase tracking-wide text-premium-strong`,children:`Caprock Premium`}),(0,I.jsx)(`h2`,{className:`mt-1 text-[16px] font-medium leading-snug text-fg`,children:r.title})]}),(0,I.jsx)(`button`,{onClick:t,className:`-mr-1 ml-auto text-fg-muted hover:text-fg`,"aria-label":`Close`,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`px-5 pt-3`,children:[(0,I.jsx)(`p`,{className:`text-[13px] leading-relaxed text-fg-muted`,children:r.body}),(0,I.jsx)(`ul`,{className:`mt-3 space-y-1.5`,children:r.points.map(e=>(0,I.jsxs)(`li`,{className:`flex gap-2 text-[13px] leading-snug text-fg`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:`text-premium-strong`,children:`·`}),(0,I.jsx)(`span`,{children:e})]},e))}),r.setup&&(0,I.jsx)(`p`,{className:`mt-2.5 text-[12px] text-fg-faint`,children:r.setup})]}),(0,I.jsx)(`div`,{className:`mt-4 border-t border-border px-5 py-4`,children:(0,I.jsx)(tt,{p:n,onClose:t})}),(0,I.jsx)(`footer`,{className:`border-t border-border px-5 py-3 text-[12px]`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`a`,{href:n?.info_url??`https://caprock.dev/premium/`,target:`_blank`,rel:`noreferrer`,className:`whitespace-nowrap text-fg-muted no-underline hover:text-fg`,children:`Read more`}),(0,I.jsx)(`span`,{className:`whitespace-nowrap text-fg-faint`,children:`opens a new tab`}),(0,I.jsx)(`button`,{onClick:t,className:`ml-auto text-fg-muted hover:text-fg`,children:`Close`})]})}),(0,I.jsx)(`p`,{className:`border-t border-border px-5 py-2.5 text-[11px] leading-relaxed text-fg-faint`,children:`Everything Caprock does now stays free and Apache-2.0 — Premium only ever adds.`})]})})}function rt(){let[e,t]=(0,l.useState)(!1),n=F(()=>P.premium(),[],{live:!1,intervalMs:3e5});if(!n.data?.yearly?.url)return null;let r=n.data.license;if(r?.active){let e=r.expires_at?new Date(r.expires_at):null,t=!!e&&e.getFullYear()-new Date().getFullYear()>10;return(0,I.jsxs)(`span`,{className:`text-premium-strong`,title:e&&!t?`Covers you through ${e.toLocaleDateString()}`:`Bought outright`,children:[`premium `,(0,I.jsx)(`span`,{className:`opacity-70`,children:t?`lifetime`:`yearly`}),r.in_grace&&(0,I.jsx)(`span`,{className:`ml-1 text-warn`,children:`· renew`})]})}let i=n.data;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{onClick:()=>t(!0),title:`What Premium includes`,className:`inline-flex items-center gap-1.5 rounded-sm border border-premium/60 bg-premium px-2 py-0.5 text-white hover:brightness-110`,children:[(0,I.jsx)(`span`,{children:`Get premium`}),(0,I.jsxs)(`span`,{className:`opacity-75`,children:[`$`,i.yearly.charged_usd,`/yr`]})]}),e&&(0,I.jsx)(nt,{feature:`cap`,onClose:()=>t(!1)})]})}var it=`https://github.com/dspv/caprock`,at=`https://caprock.dev/teams`,ot=`https://caprock.dev/premium`,st=`caprock.footer.starred`;function ct(){let[e,t]=(0,l.useState)(()=>localStorage.getItem(st)===`1`);return(0,I.jsx)(`footer`,{className:`mt-6 border-t border-border`,children:(0,I.jsxs)(`div`,{className:`max-w-[1600px] mx-auto px-3 py-4 flex flex-wrap items-center gap-x-6 gap-y-3 text-[11px] text-fg-faint`,children:[(0,I.jsxs)(`a`,{href:at,target:`_blank`,rel:`noreferrer`,className:`group inline-flex items-center gap-2 no-underline`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted group-hover:text-fg`,children:`Want this for your team?`}),(0,I.jsx)(`span`,{className:`text-accent group-hover:text-accent-strong`,children:`Caprock for Teams →`})]}),(0,I.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-4`,children:[(0,I.jsx)(`a`,{href:ot,target:`_blank`,rel:`noreferrer`,className:`text-fg-muted hover:text-fg no-underline`,title:`A daily spend cap — Caprock pauses its own sessions when the day passes a limit you set`,children:`premium`}),!e&&(0,I.jsx)(`a`,{href:it,target:`_blank`,rel:`noreferrer`,onClick:()=>{localStorage.setItem(st,`1`),t(!0)},className:`text-fg-faint hover:text-fg no-underline`,title:`Opens GitHub in a new tab`,children:`★ star on GitHub`}),(0,I.jsx)(`a`,{href:`https://caprock.dev/blog`,target:`_blank`,rel:`noreferrer`,className:`text-fg-faint hover:text-fg no-underline`,children:`blog`}),(0,I.jsx)(`a`,{href:`https://caprock.dev/docs`,target:`_blank`,rel:`noreferrer`,className:`text-fg-faint hover:text-fg no-underline`,children:`docs`})]})]})})}function lt(e){let t=[],n=/\*\*([^*]+)\*\*|`([^`]+)`/g,r=0;for(let i=n.exec(e);i;i=n.exec(e))i.index>r&&t.push({text:e.slice(r,i.index),bold:!1,code:!1}),i[1]===void 0?t.push({text:i[2]??``,bold:!1,code:!0}):t.push({text:i[1],bold:!0,code:!1}),r=i.index+i[0].length;return r{n.length&&t.push({kind:`para`,parts:lt(n.join(` `))}),n=[]},a=()=>{r.length&&t.push({kind:`bullet`,parts:lt(r.join(` `))}),r=[]},o=()=>{a(),i()};for(let i of e.split(` -`)){let e=i.trimEnd().trim();if(e===``){o();continue}let a=/^#{1,6}\s+(.*)$/.exec(e);if(a){o(),t.push({kind:`heading`,text:a[1]??``});continue}let s=/^[-*•]\s+(.*)$/.exec(e);if(s){o(),r.push(s[1]??``);continue}if(r.length){r.push(e);continue}n.push(e)}return o(),t}function dt({text:e}){let t=ut(e);return(0,I.jsx)(`div`,{className:`grid gap-2.5 text-[13px] leading-relaxed text-fg-muted`,children:t.map((e,t)=>e.kind===`heading`?(0,I.jsx)(`h3`,{className:`text-[11px] uppercase tracking-[0.08em] text-fg-faint mt-1.5 first:mt-0`,children:e.text},t):e.kind===`bullet`?(0,I.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-2`,children:[(0,I.jsx)(`span`,{className:`text-accent select-none`,children:`·`}),(0,I.jsx)(`p`,{className:`m-0`,children:ft(e.parts)})]},t):(0,I.jsx)(`p`,{className:`m-0`,children:ft(e.parts)},t))})}function ft(e){return e.map((e,t)=>e.bold?(0,I.jsx)(`strong`,{className:`font-medium text-fg`,children:e.text},t):e.code?(0,I.jsx)(`code`,{className:`mono text-[12px] text-fg`,children:e.text},t):(0,I.jsx)(`span`,{children:e.text},t))}var pt=[{route:{name:`now`},label:`Now`},{route:{name:`cost`},label:`Cost`},{route:{name:`history`},label:`Lifetime`},{route:{name:`notes`},label:`Answers`},{route:{name:`tasks`},label:`Tasks`}];function mt(e){switch(e.name){case`now`:return`Now`;case`session`:return`Session detail`;case`cost`:return`Cost`;case`history`:return`Lifetime`;case`tasks`:return`Tasks`;case`graph`:return`Graph`;case`notes`:return`Answers`;case`settings`:return`Status`}}function ht({route:e,children:t}){let n=f(),[r,i]=De(),a=t=>t.name===e.name||t.name===`now`&&e.name===`session`;return(0,I.jsxs)(`div`,{className:`min-h-screen flex flex-col`,children:[(0,I.jsxs)(`header`,{className:`h-10 border-b border-border bg-panel flex items-center px-3 gap-4 sticky top-0 z-10`,children:[(0,I.jsxs)(`a`,{href:`#/`,className:`flex items-center gap-2 text-fg no-underline hover:no-underline`,children:[(0,I.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 32 32`,"aria-hidden":!0,children:[(0,I.jsx)(`path`,{d:`M6 22 L16 8 L26 22 Z`,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:`3`,strokeLinejoin:`round`}),(0,I.jsx)(`rect`,{x:`6`,y:`22`,width:`20`,height:`3`,fill:`var(--color-accent)`})]}),(0,I.jsx)(`span`,{className:`font-medium tracking-wide text-[13px]`,children:`caprock`}),(0,I.jsx)(`span`,{className:`text-fg-faint text-[11px] hidden sm:inline`,children:`mission control`})]}),(0,I.jsx)(`nav`,{className:`inline-flex items-center gap-0.5 ml-2 rounded-md bg-panel-2 p-0.5`,children:pt.map(e=>(0,I.jsxs)(`a`,{href:g(e.route),"aria-current":a(e.route)?`page`:void 0,className:`px-2.5 py-1 rounded-[5px] text-[12px] no-underline hover:no-underline transition-colors ${a(e.route)?`bg-accent text-panel font-medium`:`text-fg hover:text-accent`}`,children:[e.label,e.phase&&(0,I.jsx)(`span`,{className:`ml-1 text-[9px] uppercase tracking-wider text-fg-faint`,children:e.phase})]},e.label))}),(0,I.jsxs)(`div`,{className:`ml-auto flex items-center gap-3 text-[11px] text-fg-muted`,children:[(0,I.jsx)(Ze,{}),(0,I.jsx)(rt,{}),(0,I.jsx)(Re,{screen:mt(e)}),(0,I.jsx)(_t,{state:n.conn,lastFrameAt:n.lastFrameAt}),(0,I.jsx)(Oe,{plan:r,onSave:i}),(0,I.jsx)(gt,{}),(0,I.jsx)(vt,{}),(0,I.jsx)(`a`,{href:`#/settings`,className:`text-fg-muted hover:text-fg no-underline`,children:`status`})]})]}),(0,I.jsx)(`main`,{className:`flex-1 p-3 max-w-[1600px] w-full mx-auto`,children:t}),(0,I.jsx)(ct,{})]})}function gt(){let[e,t]=A(),n=e===`dark`;return(0,I.jsx)(`button`,{type:`button`,onClick:t,title:n?`Switch to light theme`:`Switch to dark theme`,"aria-label":n?`Switch to light theme`:`Switch to dark theme`,className:`text-fg-muted hover:text-fg inline-flex items-center`,children:n?(0,I.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":!0,children:[(0,I.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,I.jsx)(`path`,{d:`M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M19.1 4.9l-1.4 1.4M6.3 17.7l-1.4 1.4`})]}):(0,I.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,I.jsx)(`path`,{d:`M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z`})})})}function _t({state:e,lastFrameAt:t}){let n=re(1e3),r=e===`open`?`bg-ok`:e===`connecting`?`bg-warn`:`bg-danger`,i=e===`open`?`live · ${t?T(t,n):`connected`}`:e===`connecting`?`connecting…`:`disconnected — reconnecting`;return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:e===`open`?`Connected to the daemon. The time is when it last sent anything — on an idle machine that keeps counting up, which is normal.`:`WebSocket /v1/live`,children:[(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${r}`}),(0,I.jsx)(`span`,{className:`num`,children:i})]})}function vt(){let e=F(()=>P.status(),[],{live:!1,intervalMs:6e4}),t=F(()=>P.update().catch(()=>void 0),[],{live:!1,intervalMs:6e4}),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=e.data?.version;if(!o)return null;let s=/^v?\d+\.\d+\.\d+$/.test(o),c=s&&t.data?.update_available?t.data.latest:void 0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{onClick:()=>r(!0),className:c?`mono text-[11px] text-accent hover:text-accent-strong`:`mono text-[11px] text-fg-faint hover:text-fg`,title:c?`${c} is available — you are on ${o}`:`version and updates`,children:c?`${o} → ${c}`:s?o:`dev build`}),t.data?.notes&&(0,I.jsx)(`button`,{onClick:()=>a(!0),className:`text-[11px] text-fg-faint hover:text-accent`,title:`what changed in ${t.data.notes_for??`the latest release`}`,children:`what's new`}),n&&(0,I.jsx)(bt,{onClose:()=>r(!1)}),i&&t.data&&(0,I.jsx)(yt,{u:t.data,onClose:()=>a(!1)})]})}function yt({u:e,onClose:t}){return(0,I.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-start justify-center pt-[10vh] px-4`,onClick:t,children:(0,I.jsxs)(`div`,{className:`w-full max-w-[620px] max-h-[76vh] flex flex-col border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`What's new`,children:[(0,I.jsxs)(`div`,{className:`px-4 pt-3 pb-2 border-b border-border flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-[15px] font-medium`,children:`What's new`}),e.notes_for&&(0,I.jsx)(`span`,{className:`mono text-[12px] text-accent`,children:e.notes_for}),(0,I.jsx)(`button`,{onClick:t,className:`ml-auto text-[16px] leading-none text-fg-faint hover:text-fg`,children:`×`})]}),(0,I.jsx)(`div`,{className:`overflow-y-auto px-4 py-3`,children:(0,I.jsx)(dt,{text:e.notes??``})}),(0,I.jsx)(`div`,{className:`border-t border-border px-4 py-2.5`,children:(0,I.jsx)(`a`,{href:`https://caprock.dev/changelog`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[12px] text-fg-faint no-underline hover:text-accent`,children:`every release →`})})]})})}function bt({onClose:e}){let t=F(()=>P.status(),[],{live:!1,intervalMs:0}),n=F(()=>P.update().catch(()=>void 0),[],{live:!1,intervalMs:0}),[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(void 0),[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(()=>ve()??me(navigator.userAgent,navigator.userAgentData?.platform)),[f,p]=(0,l.useState)(!1),m=a??n.data,h=t.data?.version??``,g=/^v?\d+\.\d+\.\d+$/.test(h),_=!f&&ge(m?.command,u)?he(m?.command)??(u===`windows`?`macos`:u):u,v=pe(_),y=be(m?.command,v),[b,x]=(0,l.useState)(void 0),S=v.find(e=>e.label===b)??y??v[0],C=e=>{d(e),p(!0),ye(e),x(void 0)},w=async()=>{i(!0);try{o(await P.checkUpdate())}catch{}finally{i(!1)}},T=e=>{navigator.clipboard.writeText(e),c(e),setTimeout(()=>c(``),1600)};return(0,I.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-start justify-center pt-[10vh] px-4`,onClick:e,children:(0,I.jsxs)(`div`,{className:`w-full max-w-[560px] max-h-[80vh] overflow-y-auto border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Version and updates`,children:[(0,I.jsxs)(`div`,{className:`px-4 pt-3 pb-2 border-b border-border flex items-center`,children:[(0,I.jsx)(`span`,{className:`text-[15px] font-medium`,children:`Version`}),(0,I.jsx)(`button`,{onClick:e,className:`ml-auto text-[16px] leading-none text-fg-faint hover:text-fg`,children:`×`})]}),(0,I.jsxs)(`div`,{className:`p-4 grid gap-3.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2 text-[13px]`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:`running`}),(0,I.jsx)(`span`,{className:`mono text-fg`,children:g?h:`${h} (local build)`}),m?.update_available&&(0,I.jsxs)(`span`,{className:`mono text-accent`,children:[`→ `,m.latest,` is out`]})]}),m?.enabled===!1?(0,I.jsxs)(`div`,{className:`text-[13px] text-fg-muted`,children:[`Release checks are off, so this copy never asks GitHub what the latest version is. Turn them on in`,` `,(0,I.jsx)(`a`,{href:`#/status`,onClick:e,className:`text-accent no-underline hover:text-accent-strong`,children:`status`}),`.`]}):m?.update_available?null:(0,I.jsx)(`div`,{className:`text-[13px] text-fg-muted`,children:m?.latest?`Up to date — ${m.latest} is the latest release.`:`No newer release found.`}),(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[oe.map(e=>(0,I.jsx)(`button`,{onClick:()=>C(e.id),className:`rounded-sm px-2.5 py-1 text-[12px] transition-colors ${_===e.id?`bg-accent text-panel font-medium`:`text-fg-muted hover:text-fg`}`,children:e.label},e.id)),v.length>1&&(0,I.jsx)(`span`,{className:`ml-auto flex items-center gap-1`,children:v.map(e=>(0,I.jsxs)(`button`,{onClick:()=>x(e.label),className:`rounded-sm px-2 py-1 text-[11px] transition-colors ${S.label===e.label?`text-accent`:`text-fg-faint hover:text-fg-muted`}`,title:e.label===y?.label?`how this copy appears to be installed`:void 0,children:[e.label,e.label===y?.label?` ·`:``]},e.label))})]}),(0,I.jsx)(`ol`,{className:`grid gap-2.5`,children:S.steps.map((e,t)=>(0,I.jsxs)(`li`,{className:`grid gap-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`mono text-[11px] text-fg-faint`,children:t+1}),e.cmd?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`code`,{className:`mono flex-1 truncate rounded-sm border border-border bg-bg px-2 py-1.5 text-[13px] text-fg`,children:e.cmd}),(0,I.jsx)(`button`,{onClick:()=>T(e.cmd),className:`shrink-0 rounded-md border border-accent/45 bg-accent/[0.08] px-2.5 py-1.5 text-[12px] text-accent hover:bg-accent/[0.16]`,children:s===e.cmd?`copied`:`copy`})]}):(0,I.jsx)(`a`,{href:m?.url??`https://github.com/dspv/caprock/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`flex-1 rounded-sm border border-border bg-bg px-2 py-1.5 text-[13px] text-accent no-underline hover:text-accent-strong`,children:`Open the release page →`})]}),(0,I.jsx)(`p`,{className:`pl-5 text-[11px] leading-relaxed text-fg-faint`,children:e.note})]},t))})]}),(0,I.jsx)(`div`,{className:`text-[11px] leading-relaxed text-fg-faint border-t border-border pt-3`,children:`Caprock does not update itself: it would have to overwrite its own binary while running, and where a package manager owns that binary, replacing it behind their back breaks the next upgrade.`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`button`,{onClick:w,disabled:r,className:`rounded-md border border-border px-3 py-1.5 text-[13px] text-fg-muted hover:text-fg disabled:opacity-50`,children:r?`checking…`:`check now`}),(0,I.jsx)(`a`,{href:m?.url??`https://github.com/dspv/caprock/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[12px] text-fg-faint no-underline hover:text-accent`,children:`release notes →`})]})]})]})})}var xt=class extends l.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[caprock ui]`,e,t.componentStack)}render(){return this.state.error?(0,I.jsxs)(`div`,{className:`border border-danger/50 bg-danger/10 rounded-[var(--radius-panel)] px-3 py-2 text-[12px]`,children:[(0,I.jsxs)(`div`,{className:`text-danger font-medium`,children:[this.props.label??`This view`,` failed to render`]}),(0,I.jsx)(`div`,{className:`mono text-fg-muted mt-1`,children:this.state.error.message}),(0,I.jsx)(`button`,{className:`mt-2 border border-border px-2 py-0.5 rounded-sm text-fg-muted hover:text-fg`,onClick:()=>this.setState({error:null}),children:`retry`})]}):this.props.children}};function L({title:e,center:t,right:n,children:r,className:i=``,onMouseEnter:a,onMouseLeave:o}){return(0,I.jsxs)(`section`,{className:`border border-border bg-panel rounded-[var(--radius-panel)] shadow-[var(--shadow-panel)] min-w-0 ${i}`,onMouseEnter:a,onMouseLeave:o,children:[(e||t||n)&&(0,I.jsxs)(`header`,{className:`relative flex items-center justify-between px-3 py-2 border-b border-border bg-panel-2/60 rounded-t-[var(--radius-panel)]`,children:[(0,I.jsx)(`h2`,{className:`text-[11px] uppercase tracking-[0.12em] text-fg-muted font-medium`,children:e}),t?(0,I.jsx)(`div`,{className:`absolute left-1/2 -translate-x-1/2`,children:t}):null,(0,I.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:n})]}),(0,I.jsx)(`div`,{children:r})]})}function R({label:e,value:t,sub:n,tone:r,size:i=`default`}){return(0,I.jsxs)(`div`,{className:`flex h-full flex-col px-3 py-2.5 min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:e}),(0,I.jsx)(`div`,{className:`num font-semibold tracking-[-0.01em] ${i===`hero`?`text-[34px] leading-[1.05]`:i===`compact`?`text-[17px] leading-tight`:`text-[24px] leading-[1.1]`} ${r===`ok`?`text-ok`:r===`warn`?`text-warn`:r===`danger`?`text-danger`:r===`info`?`text-info`:`text-fg`}`,children:t}),n&&(0,I.jsx)(`div`,{className:`mt-auto pt-1 text-[11px] text-fg-muted num truncate`,children:n})]})}var St={working:`working`,idle:`idle`,"waiting-on-you":`waiting on you`,looping:`looping?`,error:`error`,ended:`ended`};function Ct(e){switch(e){case`working`:return`ok`;case`idle`:return`warn`;case`waiting-on-you`:return`warn`;case`looping`:return`danger`;case`error`:return`danger`;case`ended`:return`muted`}}function wt({health:e}){let t=Ct(e);return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 border rounded-sm px-1.5 py-[1px] text-[11px] leading-4 ${t===`ok`?`text-ok border-ok/40 bg-ok/10`:t===`warn`?`text-warn border-warn/40 bg-warn/10`:t===`danger`?`text-danger border-danger/40 bg-danger/10`:`text-fg-muted border-border bg-panel-2`}`,children:[(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${t===`ok`?`bg-ok`:t===`warn`?`bg-warn`:t===`danger`?`bg-danger`:`bg-fg-faint`} ${e===`working`?`animate-pulse`:``}`}),St[e]]})}function Tt({values:e,width:t=120,height:n=24,tone:r=`info`}){if(e.length<2)return(0,I.jsx)(`svg`,{width:t,height:n,"aria-hidden":!0});let i=Math.max(...e,1e-9),a=Math.min(...e,0),o=i-a||1,s=t/(e.length-1),c=e.map((e,t)=>`${(t*s).toFixed(1)},${(n-(e-a)/o*(n-2)-1).toFixed(1)}`).join(` `),l=r===`ok`?`var(--color-ok)`:r===`warn`?`var(--color-warn)`:r===`danger`?`var(--color-danger)`:r===`accent`?`var(--color-accent)`:`var(--color-info)`;return(0,I.jsx)(`svg`,{width:t,height:n,viewBox:`0 0 ${t} ${n}`,className:`block`,"aria-hidden":!0,children:(0,I.jsx)(`polyline`,{fill:`none`,stroke:l,strokeWidth:`1.25`,points:c,vectorEffect:`non-scaling-stroke`})})}function Et({title:e,children:t}){return(0,I.jsxs)(`div`,{className:`px-4 py-10 text-center`,children:[(0,I.jsx)(`div`,{className:`text-fg-muted`,children:e}),t&&(0,I.jsx)(`div`,{className:`text-[12px] text-fg-faint mt-1`,children:t})]})}function Dt({rows:e=3,className:t=``}){return(0,I.jsx)(`div`,{className:`px-3 py-2 grid gap-2 ${t}`,"aria-hidden":!0,children:Array.from({length:e},(e,t)=>(0,I.jsx)(`div`,{className:`h-3 rounded-sm bg-panel-2 skeleton-pulse`,style:{width:`${[92,74,83,61,88][t%5]}%`}},t))})}function Ot({command:e,className:t=``}){let[n,r]=(0,l.useState)(!1);return(0,I.jsx)(`button`,{className:`mono text-[12px] bg-panel-2 border border-border px-2 py-0.5 rounded-sm hover:border-border-strong text-fg text-left ${t}`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{r(!0),window.setTimeout(()=>r(!1),1500)})},title:`copy to clipboard — run it in your terminal`,children:n?`copied`:`$ ${e}`})}var kt={edit:{label:`writing code`,title:`Turns that wrote to a file — Edit, Write, NotebookEdit.`},command:{label:`running commands`,title:`Turns that ran a shell command — builds, tests, git, anything through Bash. The command itself is free; what costs is the turn that issued it and read its output.`},read:{label:`reading and searching`,title:`Turns that read or searched the codebase — Read, Grep, Glob. The file contents enter the prompt and are billed, which is why reading is not free.`},web:{label:`web research`,title:`Turns that fetched or searched the web — WebFetch, WebSearch.`},mcp:{label:`MCP tools`,title:`Turns that called one of your own MCP integrations.`},other:{label:`other tools`,title:`Turns that called a tool in none of the categories above — subagents, task and skill control, and any tool Caprock does not yet know by name.`},none:{label:`no tool call`,title:`Turns that called no tool at all. They may have been reasoning, planning, answering a question or writing prose — Caprock records which tools ran, not what a turn was thinking, so it does not claim to know which.`}},At=`Each turn counts toward one kind of work, decided by the tools it called: writing a file wins over running a command, which wins over reading or searching, then web, then an MCP tool, then anything else. A turn that called no tool is counted as exactly that. Each turn goes whole to one row, never split, so the rows add up to the total exactly.`;function jt({summary:e}){let t=e,n=t?.work??[],r=t?.work_unlinked_calls??0,i=t?.tool_calls??0,a=r>0&&i>0&&r/i>.01;return(0,I.jsxs)(L,{title:`What it went on`,right:(0,I.jsx)(`span`,{title:At,children:`by cost`}),children:[t?n.length===0&&(0,I.jsx)(Et,{title:`No priced turns in range`}):(0,I.jsx)(Dt,{rows:4}),(0,I.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,I.jsx)(`tbody`,{children:n.map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1`,title:kt[e.kind]?.title,children:kt[e.kind]?.label??e.kind}),(0,I.jsxs)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:[e.turns,` turns`]}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:S(e.cost_usd)}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-faint w-14`,children:w(e.cost_pct)})]},e.kind))})}),a&&(0,I.jsxs)(`div`,{className:`mx-3 mb-2.5 text-[11px] text-warn`,children:[r.toLocaleString(),` tool calls in this range could not be matched to the turn that paid for them, so their cost is counted under “no tool call” rather than the work they actually did. Every other row is understated by up to that much.`]})]})}function Mt({summary:e}){let t=e?.work??[],n=e?.work_unlinked_calls??0,r=e?.tool_calls??0;if(t.length===0||r===0||n/r>.2)return null;let i=t.filter(e=>e.cost_pct>=1).slice(0,5);return i.length===0?null:(0,I.jsxs)(`div`,{className:`border-t border-border px-3 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:`what it went on`}),(0,I.jsx)(`a`,{href:`#/cost`,className:`text-[10px] text-fg-faint hover:text-accent no-underline`,children:`details →`})]}),(0,I.jsx)(`div`,{className:`mt-2 flex h-1.5 w-full overflow-hidden rounded-full bg-panel-2`,title:At,children:i.map((e,t)=>(0,I.jsx)(`span`,{className:`h-full`,style:{width:`${e.cost_pct}%`,background:`var(--color-accent)`,opacity:1-t*.17}},e.kind))}),(0,I.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1`,children:i.map((e,t)=>(0,I.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 text-[11px]`,children:[(0,I.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-[2px] translate-y-[1px]`,style:{background:`var(--color-accent)`,opacity:1-t*.17}}),(0,I.jsx)(`span`,{className:`text-fg-muted`,title:kt[e.kind]?.title,children:kt[e.kind]?.label??e.kind}),(0,I.jsx)(`span`,{className:`num text-fg-faint`,children:w(e.cost_pct)})]},e.kind))})]})}var Nt=.62;function Pt(e,t){return e?t===`tokens`?e.tokens??[]:e.cost??[]:[]}function Ft(e,t,n){let r=Pt(e,t);if(!e||r.length===0)return[];let i=n>0?n:0;return r.map((t,n)=>{let r=Number.isFinite(t)&&t>0?t:0,a=i>0&&r>0?Math.min(1,r/i)**+Nt:0;return{value:r,at:e.from_ms+n*e.width_ms,height:a,empty:r<=0}})}function It(e,t){let n=0;for(let r of e)for(let e of Pt(r,t))Number.isFinite(e)&&e>n&&(n=e);return n}function Lt(e,t){let n=new Date(e);return t<864e5?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n.toLocaleDateString([],{month:`short`,day:`numeric`})}function Rt(e){return e.split(`/`).filter(Boolean)}function zt(e,t=3){let n=[],r=new Map,i=[],a=(e,t)=>{let n=r.get(e);if(n)return n;let o=Rt(e),s={path:e,name:o.length===0?`/`:o[o.length-1],depth:t,tokens:0,cost:0,turns:0,tokensPct:0,costPct:0,ownTokens:0,ownCost:0,ownTurns:0,ownTokensPct:0,ownCostPct:0,children:[],rolledUp:0};if(r.set(e,s),t===0)i.push(s);else{let e=t===1?`/`:`/`+o.slice(0,t-1).join(`/`);a(e,t-1).children.push(s)}return s};for(let r of e){if(r.unattributed||r.outside){n.push(r);continue}let e=Rt(r.path),i=e.length,o=Math.min(i,t),s=a(o===0?`/`:`/`+e.slice(0,o).join(`/`),o);s.ownTokens+=r.tokens,s.ownCost+=r.cost_usd,s.ownTurns+=r.turns,s.ownTokensPct+=r.tokens_pct,s.ownCostPct+=r.cost_pct,i>o&&s.rolledUp++;for(let t=0;t<=o;t++){let n=a(t===0?`/`:`/`+e.slice(0,t).join(`/`),t);n.tokens+=r.tokens,n.cost+=r.cost_usd,n.tokensPct+=r.tokens_pct,n.costPct+=r.cost_pct,n.turns+=r.turns}}let o=i[0],s=i;o&&o.path===`/`&&(s=[...o.children],(o.ownTokens>0||o.ownCost>0||o.ownTurns>0||o.rolledUp>0)&&s.push({...o,depth:1,tokens:o.ownTokens,cost:o.ownCost,turns:o.ownTurns,tokensPct:o.ownTokensPct,costPct:o.ownCostPct,children:[],ownTokens:o.ownTokens,ownCost:o.ownCost,ownTurns:o.ownTurns}));let c=e=>{e.sort((e,t)=>t.cost-e.cost);for(let t of e)c(t.children)};return c(s),{roots:s,buckets:n}}function Bt(e){return e.map(e=>{let t=e;for(;t.children.length===1&&t.ownTokens===0&&t.ownCost===0&&t.ownTurns===0&&t.rolledUp===0;)t=t.children[0];return{...t,children:Bt(t.children)}})}var Vt=[{key:`all`,label:`all`},{key:`claude`,label:`claude`},{key:`opencode`,label:`opencode`},{key:`gemini`,label:`gemini`}];function Ht(e){switch(e){case`opencode`:return`oc`;case`gemini`:return`gem`;default:return``}}function Ut(e){switch(e){case`opencode`:return`OpenCode`;case`gemini`:return`Gemini`;default:return`Claude Code`}}var Wt=[{key:`today`,label:`today`},{key:`7d`,label:`7d`},{key:`30d`,label:`30d`},{key:`all`,label:`all`}],Gt=`tokens`,Kt=`A turn counts toward the directory of the most recent file it touched, and keeps counting there until it touches a file somewhere else — so the commands, tests and searches between two edits count toward the directory being worked on. Reading, editing or writing a file counts as touching it; running a command does not. Each turn goes whole to one row, never split between two, so the rows add up to the repository total exactly.`,qt=`repository-wide work`,Jt=`Turns from the start of a session, before Claude had touched any file — so there is no directory yet for them to count toward. Their cost is counted here whole rather than guessed onto the directory the session reached later.`,Yt=`outside the repository`,Xt=`Turns whose most recent file touch was outside this repository — Claude’s notes on the project, agent scratchpads, test-output directories, or another checkout. This is real work and it counts toward the repository total, but it happened outside the tree, so it is not charged to any directory inside it.`;function Zt({sessions:e,agent:t}){let[n,r]=(0,l.useState)(`7d`),[i,a]=(0,l.useState)(!1),o=F(()=>P.summary(n),[n],{intervalMs:3e4}),s=o.data?.projects??[],c=(0,l.useMemo)(()=>t===`all`?s:s.filter(e=>!e.agent||e.agent===t),[s,t]),[u,d]=(0,l.useState)(null),f=(0,l.useMemo)(()=>{if(!u)return c;let e=new Map(u.map((e,t)=>[e,t]));return[...c].sort((t,n)=>(e.get(t.project)??1/0)-(e.get(n.project)??1/0))},[c,u]),p=i?f:f.slice(0,6),m=c.reduce((e,t)=>e+t.cost_usd,0),h=c.reduce((e,t)=>e+t.tokens,0),g=(0,l.useMemo)(()=>It(p.map(e=>e.spark),Gt),[p]),_=(0,l.useMemo)(()=>p.reduce((e,t)=>Math.max(e,t.tokens),0),[p]);return(0,I.jsx)(L,{onMouseEnter:()=>d(c.map(e=>e.project)),onMouseLeave:()=>d(null),title:`Projects`,right:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`span`,{className:`num text-[13px]`,children:[(0,I.jsx)(`span`,{className:`text-fg`,children:C(h)}),(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,S(m),` total`]})]}),(0,I.jsx)(`span`,{className:`inline-flex border border-border rounded-sm overflow-hidden`,children:Wt.map(e=>(0,I.jsx)(`button`,{onClick:()=>r(e.key),className:`px-1.5 py-0.5 text-[11px] mono ${n===e.key?`bg-panel-2 text-fg`:`text-fg-faint hover:text-fg-muted`}`,children:e.label},e.key))})]}),children:o.data?c.length===0?(0,I.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-fg-muted`,children:`No spend captured in this range yet.`}):(0,I.jsxs)(`div`,{className:`grid`,children:[p.map(t=>(0,I.jsx)($t,{p:t,max:_,ceiling:g,live:Qt(e).has(t.project)},t.project||`(unknown)`)),c.length>6&&(0,I.jsx)(`button`,{onClick:()=>a(e=>!e),className:`text-[11px] text-fg-faint hover:text-fg-muted px-3 py-1.5 text-left border-t border-border`,children:i?`show less`:`show all ${c.length} projects`}),(0,I.jsx)(Mt,{summary:o.data}),(0,I.jsx)(an,{count:c.length})]}):(0,I.jsx)(Dt,{rows:5})})}function Qt(e){return new Set(e.filter(e=>e.status!==`ended`).map(e=>e.project).filter(Boolean))}function $t({p:e,max:t,ceiling:n,live:r}){let i=e.paths??[],a=i.length>1,[o,s]=(0,l.useState)(!1),c=e.project||`unknown project`,u=t>0?100*e.tokens/t:0,d=(0,l.useMemo)(()=>Ft(e.spark,Gt,n),[e.spark,n]),f=(0,l.useMemo)(()=>{let e=zt(i);return{roots:Bt(e.roots),buckets:e.buckets}},[i]),p=(0,l.useMemo)(()=>Math.max(0,...f.roots.map(e=>e.tokens),...f.buckets.map(e=>e.tokens)),[f]),m=(0,I.jsxs)(`div`,{className:`grid grid-cols-[1fr_128px_auto] items-center gap-3 w-full text-left`,children:[(0,I.jsx)(`div`,{className:`min-w-0`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-ok shrink-0`,title:`a session is live in this project`}),(0,I.jsx)(`span`,{className:`truncate text-[14px]`,children:c}),Ht(e.agent)&&(0,I.jsx)(`span`,{className:`shrink-0 text-[9px] uppercase tracking-[0.08em] text-fg-faint border border-border px-1 rounded-sm`,children:Ht(e.agent)}),(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-faint num shrink-0`,children:[e.sessions,` `,e.sessions===1?`session`:`sessions`]}),a&&(0,I.jsx)(`span`,{"aria-hidden":!0,className:`text-[9px] text-fg-faint shrink-0 transition-transform ${o?`rotate-90`:``}`,children:`▶`})]})}),d.length>0?(0,I.jsx)(rn,{bars:d,widthMs:e.spark?.width_ms??0,label:c}):(0,I.jsx)(`div`,{className:`h-1 bg-panel-2 rounded-sm overflow-hidden`,title:`${c}: share of the largest project`,children:(0,I.jsx)(`div`,{className:`h-full bg-accent/70`,style:{width:`${u}%`}})}),(0,I.jsxs)(`div`,{className:`text-right shrink-0`,children:[(0,I.jsx)(`div`,{className:`num text-[17px] font-semibold leading-tight text-accent`,children:C(e.tokens)}),(0,I.jsx)(`div`,{className:`num text-[13px] leading-tight text-fg-muted`,children:S(e.cost_usd)})]})]});return(0,I.jsxs)(`div`,{className:`border-t border-border first:border-t-0`,children:[a?(0,I.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,className:`w-full px-3 py-1.5 hover:bg-panel-2/50`,title:`${c}: show cost by directory`,children:m}):(0,I.jsx)(`div`,{className:`px-3 py-1.5`,children:m}),a&&o&&(0,I.jsxs)(`div`,{className:`pb-1.5 bg-panel-2/30`,children:[(0,I.jsx)(`div`,{className:`pl-7 pr-3 pt-1 pb-0.5 text-[10px] text-fg-faint`,title:Kt,children:`by files touched · share of this repository's tokens`}),f.roots.map(e=>(0,I.jsx)(en,{n:e,max:p},e.path)),f.buckets.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`pl-7 pr-3 pt-2 pb-0.5 text-[10px] uppercase tracking-[0.08em] text-fg-faint`,children:`not a directory`}),f.buckets.map(e=>(0,I.jsx)(tn,{q:e,max:p},e.path))]})]})]})}function en({n:e,max:t}){let[n,r]=(0,l.useState)(!1),i=t>0?100*e.tokens/t:0,a=e.children.length>0,o=(0,l.useMemo)(()=>Math.max(0,...e.children.map(e=>e.tokens)),[e.children]),s=a&&e.ownCost>0,c=e.children.length,u=(0,I.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center gap-3 w-full text-left`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`truncate text-[12px] text-fg-muted mono`,children:e.path}),e.rolledUp>0&&(0,I.jsxs)(`span`,{className:`text-[10px] text-fg-faint shrink-0`,title:`${e.rolledUp} ${e.rolledUp===1?`directory`:`directories`} below this one ${e.rolledUp===1?`is`:`are`} counted here rather than shown: the breakdown stops at 3 levels.`,children:[`+`,e.rolledUp,` deeper`]}),(0,I.jsxs)(`span`,{className:`text-[10px] text-fg-faint num shrink-0`,children:[e.turns,` `,e.turns===1?`turn`:`turns`]}),a&&(0,I.jsx)(`span`,{"aria-hidden":!0,className:`text-[9px] text-fg-faint shrink-0 transition-transform ${n?`rotate-90`:``}`,children:`▶`})]}),s&&(0,I.jsxs)(`div`,{className:`text-[10px] text-fg-faint mt-0.5`,children:[S(e.ownCost),` here · `,S(e.cost-e.ownCost),` in `,c,` `,c===1?`subdirectory`:`subdirectories`]}),(0,I.jsx)(`div`,{className:`h-0.5 mt-1 bg-panel-2 rounded-sm overflow-hidden`,children:(0,I.jsx)(`div`,{className:`h-full bg-accent/40`,style:{width:`${i}%`}})})]}),(0,I.jsxs)(`div`,{className:`text-right shrink-0 num text-[12px]`,title:`${nn(e.costPct)} of this repository's cost`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:C(e.tokens)}),(0,I.jsxs)(`span`,{className:`text-fg-faint`,children:[` `,nn(e.tokensPct)]}),(0,I.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,S(e.cost)]})]})]}),d={paddingLeft:`${28+(e.depth-1)*14}px`};return(0,I.jsxs)(`div`,{children:[a?(0,I.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`w-full pr-3 py-1 hover:bg-panel-2/50`,style:d,title:`${e.path}: show the directories inside it`,children:u}):(0,I.jsx)(`div`,{className:`pr-3 py-1`,style:d,children:u}),a&&n&&e.children.map(e=>(0,I.jsx)(en,{n:e,max:o},e.path))]})}function tn({q:e,max:t}){let n=t>0?100*e.tokens/t:0,r=e.unattributed===!0;return(0,I.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center gap-3 pl-7 pr-3 py-1`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`truncate text-[12px] text-fg-muted`,title:r?Jt:Xt,children:r?qt:Yt}),(0,I.jsxs)(`span`,{className:`text-[10px] text-fg-faint num shrink-0`,children:[e.turns,` `,e.turns===1?`turn`:`turns`]})]}),(0,I.jsx)(`div`,{className:`h-0.5 mt-1 bg-panel-2 rounded-sm overflow-hidden`,children:(0,I.jsx)(`div`,{className:`h-full bg-fg-faint/30`,style:{width:`${n}%`}})})]}),(0,I.jsxs)(`div`,{className:`text-right shrink-0 num text-[12px]`,title:`${nn(e.cost_pct)} of this repository's cost`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:C(e.tokens)}),(0,I.jsxs)(`span`,{className:`text-fg-faint`,children:[` `,nn(e.tokens_pct)]}),(0,I.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,S(e.cost_usd)]})]})]})}function nn(e){return!Number.isFinite(e)||e<=0?`0%`:e<.1?`<0.1%`:w(e)}function rn({bars:e,widthMs:t,label:n}){let r=(0,l.useRef)(null);(0,l.useEffect)(()=>{let t=r.current;if(!t)return;let n=()=>{let n=t.clientWidth,r=t.clientHeight;if(n===0||r===0)return;let i=window.devicePixelRatio||1;t.width=Math.round(n*i),t.height=Math.round(r*i);let a=t.getContext(`2d`);if(!a)return;a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,n,r);let o=getComputedStyle(t),s=o.getPropertyValue(`--color-accent`).trim()||`#feb157`,c=o.getPropertyValue(`--color-fg-faint`).trim()||`#837f78`,l=n/e.length;for(let t=0;ti.disconnect()},[e]);let i=e.filter(e=>!e.empty),a=i[0],o=i[i.length-1],s=!a||!o?`no spend in this range`:a===o?`all of it on ${Lt(a.at,t)}`:`${Lt(a.at,t)} → ${Lt(o.at,t)}`;return(0,I.jsx)(`canvas`,{ref:r,className:`w-full h-[14px] block`,role:`img`,"aria-label":`${n}: ${Gt} over time, ${s}`,title:`${n}: when the spend happened — ${s}`})}function an({count:e}){return e<10?null:(0,I.jsxs)(`a`,{href:`https://caprock.dev/teams`,target:`_blank`,rel:`noreferrer`,className:`flex items-baseline gap-2 border-t border-border px-3 py-1.5 text-[11px] no-underline hover:no-underline`,children:[(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[e,` repositories on one machine.`]}),(0,I.jsx)(`span`,{className:`text-fg-faint hover:text-accent`,children:`See them across the team →`})]})}function on(e){return typeof e==`string`?e:``}function sn(e){let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}function cn(e,t){let n=e.replace(/\s+/g,` `).trim(),r=[...n];return r.length>t?r.slice(0,t-1).join(``)+`…`:n}function ln(e){return e.replace(/(\/[\w.@%+-]+){3,}/g,e=>`…/`+e.split(`/`).filter(Boolean).slice(-2).join(`/`))}function un(e,t){switch(e){case`Edit`:case`NotebookEdit`:return on(t.file_path)?{icon:`✎`,text:`editing`,detail:sn(on(t.file_path))}:null;case`Write`:return on(t.file_path)?{icon:`✎`,text:`writing`,detail:sn(on(t.file_path))}:null;case`Read`:return on(t.file_path)?{icon:`◇`,text:`reading`,detail:sn(on(t.file_path))}:null;case`Bash`:return on(t.command)?{icon:`$`,text:`running`,detail:cn(ln(on(t.command)),46)}:null;case`Grep`:case`Glob`:return{icon:`⌕`,text:`searching`,detail:cn(on(t.pattern)||on(t.query),40)||void 0};case`WebFetch`:case`WebSearch`:return{icon:`⇢`,text:`fetching`,detail:cn(on(t.url)||on(t.query),44)||void 0};case`Agent`:return{icon:`⚑`,text:`spawned a subagent`,detail:on(t.subagent_type)||void 0};case`Skill`:return{icon:`⚑`,text:`invoked skill`,detail:on(t.skill)||void 0};case`TodoWrite`:return{icon:`☑`,text:`updated its plan`};default:return e?{icon:`·`,text:`used`,detail:e}:null}}function dn(e,t){let n=e.payload??{},r=Date.parse(e.ts),i={id:`${e.id}`,ts:Number.isNaN(r)?Date.now():r,sessionId:e.session_id,project:t};switch(e.kind){case`tool.pre`:{let t=un(on(n.tool_name)||on(e.tool),n.tool_input??{});return t?{...i,...t,tone:`normal`}:null}case`tool.post`:return n.is_error?{...i,icon:`✕`,text:`a tool call failed`,tone:`danger`}:null;case`agent.spawn`:return{...i,icon:`▸`,text:`session started`,tone:`ok`};case`agent.stop`:return{...i,icon:`■`,text:`session ended`,tone:`normal`};case`context.compact`:return{...i,icon:`⇱`,text:`compacted its context`,tone:`warn`};case`throttle`:return{...i,icon:`⏳`,text:`rate-limited by the API`,tone:`warn`};case`task.created`:return{...i,icon:`+`,text:`task created`,tone:`normal`};case`task.done`:return{...i,icon:`✓`,text:`task verified — tests passed`,tone:`ok`};case`approval.requested`:return{...i,icon:`!`,text:`needs your approval`,tone:`warn`};default:return null}}function fn(e,t,n=60){return e.some(e=>e.id===t.id)?e:[t,...e].slice(0,n)}function pn({sessions:e,now:t,emptyHint:n}){let[r,i]=(0,l.useState)([]),[a,o]=(0,l.useState)(!1),s=(0,l.useRef)(new Map),c=(0,l.useRef)(a);c.current=a;for(let t of e)t.project&&s.current.set(t.session_id,t.project);(0,l.useEffect)(()=>{let t=!1;return(async()=>{let n=[...e].sort((e,t)=>t.last_event_at-e.last_event_at).slice(0,4),r=await Promise.all(n.map(e=>P.recentEvents(e.session_id,60).catch(()=>[])));if(t)return;let a=r.flat().map(e=>dn(e)).filter(e=>e!==null).sort((e,t)=>t.ts-e.ts).slice(0,40);i(e=>{let t=new Set(n.map(e=>e.session_id)),r=e.filter(e=>!e.sessionId||t.has(e.sessionId)),i=new Set(r.map(e=>e.id));return[...r,...a.filter(e=>!i.has(e.id))].sort((e,t)=>t.ts-e.ts).slice(0,60)})})(),()=>{t=!0}},[e.map(e=>e.session_id).join(`,`)]);let u=(0,l.useRef)(new Set);return u.current=new Set(e.map(e=>e.session_id)),(0,l.useEffect)(()=>d.onFrame(e=>{if(e.type!==`event`||c.current)return;let t=e.data?.session_id;if(t&&s.current.has(t)&&!u.current.has(t))return;let n=dn(e.data);n&&i(e=>fn(e,n))}),[]),(0,I.jsx)(L,{title:`Live activity`,right:(0,I.jsx)(`button`,{onClick:()=>o(e=>!e),className:`text-[11px] mono text-fg-faint hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,children:a?`resume`:`pause`}),children:r.length===0?(0,I.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-fg-muted`,children:n??(0,I.jsxs)(I.Fragment,{children:[`Nothing yet — start `,(0,I.jsx)(`span`,{className:`mono`,children:`claude`}),` in any terminal.`]})}):(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`div`,{className:`max-h-[420px] overflow-y-auto`,children:r.map(e=>(0,I.jsx)(hn,{it:e,now:t,project:s.current.get(e.sessionId)},e.id))}),(0,I.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-panel to-transparent`})]})})}function mn(e){switch(e){case`ok`:return`text-ok`;case`warn`:return`text-warn`;case`danger`:return`text-danger`;default:return`text-fg-faint`}}function hn({it:e,now:t,project:n}){return(0,I.jsxs)(`a`,{href:g({name:`session`,id:e.sessionId}),className:`grid grid-cols-[auto_auto_1fr_auto] items-baseline gap-2 px-3 py-1 border-t border-border first:border-t-0 hover:bg-panel-2 no-underline text-fg`,children:[(0,I.jsx)(`span`,{className:`mono text-[12px] w-3 text-center ${mn(e.tone)}`,children:e.icon}),(0,I.jsx)(`span`,{className:`mono text-[11px] text-fg-muted truncate max-w-[12ch]`,children:n??e.project??E(e.sessionId)}),(0,I.jsxs)(`span`,{className:`text-[12px] truncate`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:e.text}),e.detail&&(0,I.jsx)(`span`,{className:`mono text-fg ml-1.5`,children:e.detail})]}),(0,I.jsx)(`span`,{className:`num text-[11px] text-fg-faint`,children:T(e.ts,t)})]})}function gn(e){return e?.plan_kind===`metered`?`at API list price · ≈ your bill`:e?.plan_kind===`flat`?`at API list price · not a bill`:`at API list price`}function _n(e){return e?.plan_kind===`metered`?`Priced from your captured tokens at Anthropic list prices. You are billed per token, so this is approximately your actual cost.`:e?.plan_kind===`flat`?`Priced from your captured tokens at Anthropic list prices. You pay ${e.plan_label||`a flat plan`}, so this is what the same work would have cost through the API — not money out of pocket.`:`Priced from your captured tokens at Anthropic list prices. Whether that is your actual bill depends on how you pay — set your plan in the header.`}function vn({plan:e}){let t=F(()=>P.history(`all`),[],{intervalMs:6e4}).data?.totals;if(!t||t.sessions===0)return null;let n=t.days>0?t.sessions/t.days:0;return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-6 gap-y-1 rounded-[var(--radius-panel)] border border-border bg-panel px-3 py-2.5`,children:[(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:`all time`}),(0,I.jsxs)(`span`,{className:`inline-flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`num font-semibold tracking-[-0.01em] text-[22px] leading-none text-info`,children:S(t.cost_usd)}),(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,title:_n(e),children:gn(e)})]}),(0,I.jsx)(yn,{value:t.sessions.toLocaleString(`en-US`),label:`sessions`}),(0,I.jsx)(yn,{value:t.days.toLocaleString(`en-US`),label:`active days`}),(0,I.jsx)(yn,{value:t.turns.toLocaleString(`en-US`),label:`turns`}),n>=1&&(0,I.jsx)(yn,{value:n.toFixed(1),label:`sessions a day`}),(0,I.jsx)(`span`,{className:`ml-auto inline-flex items-baseline gap-4`,children:(0,I.jsx)(bn,{})})]})}function yn({value:e,label:t}){return(0,I.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,I.jsx)(`span`,{className:`num text-[13px] text-fg`,children:e}),(0,I.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:t})]})}function bn(){let e=F(()=>P.daily(30),[],{intervalMs:3e5}),t=F(()=>P.summary(`today`),[],{intervalMs:3e4}),n=e.data??[];if(n.length===0)return null;let r=new Map;for(let e of n)r.set(e.day,(r.get(e.day)??0)+e.cost_usd);let i=[...r.values()].filter(e=>e>0).sort((e,t)=>e-t);if(i.length<7)return null;let a=i[Math.floor(i.length/2)]??0,o=t.data?.cost_usd??0;return a<=0||o=99?{label:`outstanding`,color:`text-ok`}:e>=95?{label:`good`,color:`text-ok`}:e>=85?{label:`ok`,color:``}:{label:`low`,color:`text-warn`}}function Sn({hitRate:e,cutPct:t,measured:n,size:r=`compact`,label:i=`Cache hit`}){let a=n&&e!==void 0?e*100:void 0,o=xn(a);return(0,I.jsx)(R,{label:i,value:(0,I.jsxs)(`span`,{className:`inline-flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{children:a===void 0?`—`:w(a)}),o&&(0,I.jsx)(`span`,{className:`text-[11px] font-normal ${o.color||`text-fg-faint`}`,children:o.label})]}),sub:n&&t!==void 0?`${w(t)} input cost cut`:void 0,size:r})}function Cn(e,t){let n=Math.round(e.used_percentage),r=(e.resets_at??0)*1e3,i=r>t&&r85?`text-danger`:n>=60?`text-warn`:`text-fg`,resetsAt:i?new Date(r).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):null,stale:e.resets_at?!i:!1}}function wn({label:e,w:t,now:n}){let{pct:r,color:i,resetsAt:a,stale:o}=Cn(t,n);return(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:e}),(0,I.jsxs)(`span`,{className:`flex items-baseline gap-3`,children:[(0,I.jsxs)(`span`,{className:`font-mono tabular-nums ${i}`,children:[r,`%`]}),a&&(0,I.jsxs)(`span`,{className:`text-fg-faint`,children:[`resets `,a]}),o&&(0,I.jsx)(`span`,{className:`text-fg-faint`,title:`Claude Code has not refreshed this window recently`,children:`reset time stale`}),t.forecast&&(0,I.jsx)(`span`,{className:`text-warn`,children:t.forecast})]})]})}function Tn({limits:e,now:t}){let n=[];if(e?.five_hour&&n.push([`5h`,e.five_hour]),e?.seven_day&&n.push([`7d`,e.seven_day]),n.length===0)return null;let r=n.map(([e,n])=>({label:e,...Cn(n,t)})),i=r.filter(e=>!e.stale),a=i.length===0,o=(i.length?i:r).reduce((e,t)=>t.pct>e.pct?t:e),s=r.find(e=>e.label!==o.label);return(0,I.jsx)(R,{label:`Plan limits`,value:(0,I.jsxs)(`span`,{className:a?`text-fg-faint`:o.color,children:[o.pct,`%`]}),sub:a?(0,I.jsx)(`span`,{title:`Claude Code writes these to its status line; they stop updating when no session is running`,children:`last reported a while ago`}):(0,I.jsxs)(`span`,{children:[o.label,` window`,o.resetsAt?` · resets ${o.resetsAt}`:``,s?` · ${s.label} ${s.pct}%`:``]}),tone:a?void 0:o.pct>85?`danger`:o.pct>=60?`warn`:void 0,size:`compact`})}var En=`caprock-prompts`,Dn={"share-week":6048e5,"share-month":2592e6,"premium-hint":2592e6,"premium-banner":2592e6};function On(){try{let e=localStorage.getItem(En);return e?JSON.parse(e):{}}catch{return{}}}function kn(e){try{localStorage.setItem(En,JSON.stringify(e))}catch{}}function An(e,t){let n=On()[e];return!n||t-n>=Dn[e]}function jn(e,t){let n={...On(),[e]:t};e===`share-month`&&(n[`share-week`]=t),kn(n)}var Mn=`premium-banner`;function Nn({costUSD:e,days:t,now:n}){let[r]=(0,l.useState)(()=>An(Mn,n)),[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(!1);if(!r||i||e<=0||t<=0)return null;let c=e/t;return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[var(--radius-panel)] border border-border bg-panel-2 px-3 py-2 text-[12px]`,children:[(0,I.jsxs)(`span`,{className:`text-fg`,children:[(0,I.jsx)(`span`,{className:`num`,children:S(c)}),(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[` a day, on average, across `,t,` active `,t===1?`day`:`days`,`.`]})]}),(0,I.jsx)(`span`,{className:`text-fg-muted`,children:`Premium pauses sessions when the day crosses a limit you set.`}),(0,I.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,I.jsx)(`button`,{onClick:()=>s(!0),className:`rounded-sm border border-accent/50 bg-accent/10 px-2 py-0.5 text-accent hover:bg-accent/20`,children:`what it does`}),(0,I.jsx)(`button`,{onClick:()=>{jn(Mn,n),a(!0)},className:`rounded-sm border border-border px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg-muted`,title:`hide this for a month`,children:`not now`})]}),o&&(0,I.jsx)(nt,{feature:`cap`,onClose:()=>s(!1)})]})}var Pn=[1e3,5e3,1e4,25e3,5e4,1e5],Fn=e=>e>=1e3?`$${Math.round(e).toLocaleString(`en-US`)}`:`$${e.toFixed(2)}`;function In(e){let t=Pn.filter(t=>e>=t).pop();return t===void 0||e-t>t*.1?null:{kind:`milestone`,line:`You just passed ${Fn(t)} of Claude Code.`}}function Ln(e,t){return e<7||e>10?null:{kind:`first-week`,line:`A week of Claude Code: ${Fn(t)} measured.`}}function Rn(e){if(e.length<3)return null;let[t,...n]=e;if(t===void 0)return null;let r=Math.max(...n);return r<=0||tt[0].localeCompare(e[0])),r=[];for(let e=0;ee+t[1],0));return r}function Bn(e,t,n){return e.sessions===0||e.cost_usd<=0?null:In(e.cost_usd)??Ln(e.days,n.cost_usd)??Rn(zn(t))}var Vn=`share-week`;function Hn({now:e}){let[t]=(0,l.useState)(()=>An(Vn,e)),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=F(()=>P.history(`all`),[],{intervalMs:3e5}),s=F(()=>P.summary(`7d`),[],{intervalMs:3e5});if(!t||n||!o.data||!s.data)return null;let c=Bn(o.data.totals,o.data.daily??[],s.data);if(!c)return null;let u=()=>{jn(Vn,e),r(!0)};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2.5 rounded-lg border border-accent/35 bg-accent/[0.07] py-1.5 pl-3.5 pr-2 text-[13px]`,children:[(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[c.line,` Don’t be shy and share it off —`]}),(0,I.jsx)(`button`,{onClick:()=>{a(!0),u()},className:`rounded-[5px] bg-accent px-3 py-1 font-medium text-panel hover:bg-accent/90`,children:`Share`}),(0,I.jsx)(`button`,{onClick:u,title:`hide this for a week`,className:`px-1 text-fg-faint hover:text-fg-muted`,children:`✕`})]}),i&&(0,I.jsx)(Qe,{onClose:()=>a(!1)})]})}function Un(){let e=F(()=>P.history(`all`),[],{intervalMs:6e4}),t=(e.data?.tools??[]).slice(0,6),n=(e.data?.summary?.models??[]).slice(0,5);if(t.length===0&&n.length===0)return null;let r=t[0]?.count??0,i=n[0]?.cost_usd??0,a=(e.data?.tools??[]).reduce((e,t)=>e+t.count,0),o=(e.data?.summary?.models??[]).reduce((e,t)=>e+t.cost_usd,0),s=e.data?.summary,c=s&&(s.tokens_in||s.tokens_out||s.cache_read||s.cache_write)?{in:s.tokens_in,out:s.tokens_out,cacheRead:s.cache_read,cacheWrite:s.cache_write}:null;return(0,I.jsxs)(L,{title:`All time`,right:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-3`,children:[(0,I.jsx)(Hn,{now:Date.now()}),(0,I.jsx)($e,{}),(0,I.jsx)(`a`,{href:`#/history`,className:`text-fg-faint hover:text-accent no-underline`,children:`every tool, model and project →`})]}),children:[(0,I.jsxs)(`div`,{className:`grid gap-x-8 gap-y-5 px-3 py-3 md:grid-cols-2`,children:[(0,I.jsx)(Wn,{title:`Most-used tools`,note:`by calls`,rows:t.map(e=>({key:e.tool,label:D(e.tool),value:e.count.toLocaleString(`en-US`),share:a>0?100*e.count/a:null,frac:r>0?e.count/r:0}))}),(0,I.jsx)(Wn,{title:`Where the money went`,note:`by cost`,rows:n.map(e=>({key:e.model,label:e.model||`unknown`,value:S(e.cost_usd),sub:C(e.tokens),share:o>0?100*e.cost_usd/o:null,frac:i>0?e.cost_usd/i:0}))})]}),c&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-6 gap-y-1 border-t border-border px-3 py-2 text-[11px]`,children:[(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:`Tokens`}),(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[`input `,(0,I.jsx)(`span`,{className:`num text-fg`,children:C(c.in)})]}),(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[`output `,(0,I.jsx)(`span`,{className:`num text-fg`,children:C(c.out)})]}),(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[`cache read `,(0,I.jsx)(`span`,{className:`num text-fg`,children:C(c.cacheRead)})]}),(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[`cache write `,(0,I.jsx)(`span`,{className:`num text-fg`,children:C(c.cacheWrite)})]}),(0,I.jsx)(`span`,{className:`ml-auto text-fg-faint`,children:`fresh input is billed at full price`})]})]})}function Wn({title:e,note:t,rows:n}){return n.length===0?null:(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between`,children:[(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:e}),(0,I.jsx)(`span`,{className:`text-[10px] text-fg-faint`,children:t})]}),(0,I.jsx)(`div`,{className:`grid gap-1.5`,children:n.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,I.jsx)(`span`,{className:`mono w-36 shrink-0 truncate text-fg-muted`,title:e.label,children:e.label}),(0,I.jsx)(`span`,{className:`h-1.5 flex-1 rounded-full bg-panel-2`,children:(0,I.jsx)(`span`,{className:`block h-full rounded-full bg-accent/70`,style:{width:`${Math.max(2,Math.round(e.frac*100))}%`}})}),(0,I.jsx)(`span`,{className:`num w-20 shrink-0 text-right text-fg`,children:e.value}),(0,I.jsx)(`span`,{className:`num w-16 shrink-0 text-right text-fg-faint`,children:e.sub??``}),(0,I.jsx)(`span`,{className:`num w-9 shrink-0 text-right text-fg-faint`,children:e.share===null?``:e.share<1?`<1%`:`${Math.floor(e.share)}%`})]},e.key))})]})}function Gn(e){return e.bars.reduce((e,t)=>e+t.n,0)}function Kn(e){return e.bars.reduce((e,t)=>e+t.cost,0)}var qn=6,Jn=new Set([`description`,`timeout`,`run_in_background`]),Yn=new Set([`true`,`:`,`echo`,`pwd`,`clear`]);function Xn(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return``}}function Zn(e){if(e.kind!==`tool.pre`)return null;let t=typeof e.tool==`string`?e.tool:``;if(!t)return null;let n=e.payload,r=n&&typeof n==`object`?n.tool_input:void 0,i=r&&typeof r==`object`?r:{},a=Xn(i.command).trim();if(t===`Bash`&&Yn.has(a))return null;let o=[t],s=t;for(let e of Object.keys(i).sort()){if(Jn.has(e))continue;let n=Xn(i[e]);(e===`content`||e===`new_string`||e===`old_string`)&&(n=n.slice(0,200)),o.push(`${e}=${n}`),s===t&&(e===`command`||e===`file_path`||e===`pattern`)&&(s=`${t} ${n.slice(0,48)}`)}return{sig:o.join(`|`),label:s}}function Qn(e){let t=Date.parse(e.ts);return Number.isFinite(t)?t:0}function $n(e,t,n=60){let r=Array.from({length:n},()=>({n:0,turns:0,tools:0,cost:0})),i=t-n*6e4,a=[...e].sort((e,t)=>Qn(e)-Qn(t)),o=[],s=new Map,c=0,l=``;for(let e of a){let a=Qn(e);if(a<=0)continue;if(a>=i&&a<=t){let t=r[Math.min(n-1,Math.floor((a-i)/6e4))];if(t){t.n++,e.kind===`turn.assistant`?t.turns++:(e.kind===`tool.pre`||e.kind===`tool.post`)&&t.tools++;let n=typeof e.cost_usd==`number`&&Number.isFinite(e.cost_usd)?e.cost_usd:0;t.cost+=n}}let u=Zn(e);if(!u)continue;for(o.push({at:a,sig:u.sig,label:u.label});o.length>0;){let e=o[0];if(!e||a-e.at<=qn*6e4)break;o.shift();let t=(s.get(e.sig)??1)-1;t<=0?s.delete(e.sig):s.set(e.sig,t)}let d=(s.get(u.sig)??0)+1;s.set(u.sig,d),d>c&&(c=d,l=u.label)}return{bars:r,repeats:c,repeatSample:l}}function er(e,t){if(e.repeats>=8)return{kind:`repeat`,label:`×${e.repeats} same call`};switch(t){case`waiting-on-you`:return{kind:`waiting`,label:`waiting on you`};case`error`:return{kind:`error`,label:`error`};case`looping`:return{kind:`repeat`,label:`looping`};case`ended`:return{kind:`quiet`,label:`ended`};case`idle`:return{kind:`quiet`,label:`idle`};case`working`:return{kind:`working`,label:`working`}}return e.bars.filter(e=>e.n>0).length===0?{kind:`quiet`,label:`quiet`}:{kind:`working`,label:`working`}}function tr(e,t){return t<=0?`mid`:e>=t*1.8?`high`:e<=t*.5?`low`:`mid`}function nr(e){let t=e.filter(e=>e.cost>0).map(e=>e.cost).sort((e,t)=>e-t);return t.length===0?0:t[Math.floor(t.length/2)]??0}var rr=6,ir=2e3;function ar({sessions:e,now:t}){let n=(0,l.useMemo)(()=>[...e].filter(e=>e.status!==`ended`).sort((e,t)=>t.last_event_at-e.last_event_at).slice(0,rr),[e]),r=n.map(e=>e.session_id).join(`,`),[i,a]=(0,l.useState)(new Map);(0,l.useEffect)(()=>{let e=!1;return(async()=>{let t=r?r.split(`,`):[],n=await Promise.all(t.map(e=>P.recentEvents(e,ir).catch(()=>[])));e||a(new Map(t.map((e,t)=>[e,n[t]??[]])))})(),()=>{e=!0}},[r]),(0,l.useEffect)(()=>d.onFrame(e=>{if(e.type!==`event`)return;let t=e.data;a(e=>{if(!e.has(t.session_id))return e;let n=new Map(e),r=n.get(t.session_id)??[];return n.set(t.session_id,[...r,t].slice(-4e3)),n})}),[]);let o=Math.floor(t/6e4),s=(0,l.useMemo)(()=>n.map(e=>({s:e,pulse:$n(i.get(e.session_id)??[],o*6e4)})).filter(e=>Gn(e.pulse)>0),[n,i,o]);return n.length===0?null:(0,I.jsxs)(L,{title:`Live pulse`,right:(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[`last `,60,` minutes · one bar per minute`]}),children:[(0,I.jsx)(`div`,{children:s.length===0?(0,I.jsxs)(`div`,{className:`px-3 py-6 text-[12px] text-fg-faint text-center`,children:[`Nothing ran in the last `,60,` minutes.`]}):s.map(({s:e,pulse:t})=>(0,I.jsx)(sr,{s:e,pulse:t,minute:o,showId:s.length>1},e.session_id))}),(0,I.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-4 flex-wrap text-[11px] text-fg-faint border-t border-border`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,title:`They are independent: one call carrying a large context is a short bright bar, twenty greps are a tall dark one.`,children:`bar height = turns and tools · colour = what the minute cost`}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(or,{tier:lr,className:`h-[2px]`}),`idle`]}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(or,{tier:cr.low}),`below this session's median`]}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(or,{tier:cr.mid}),`around it`]}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(or,{tier:cr.high}),`well above it`]}),(0,I.jsxs)(`span`,{className:`ml-auto`,children:[(0,I.jsx)(`span`,{className:`text-warn`,children:`×N same call`}),` = most-repeated identical tool call in six minutes`]})]})]})}function or({tier:e,className:t=``}){return(0,I.jsx)(`span`,{"data-token":e.token,className:`inline-block w-3 h-3 rounded-[2px] ${t}`,style:{background:`var(${e.token}, ${e.fallback})`,opacity:e.alpha}})}function sr({s:e,pulse:t,minute:n,showId:r}){let i=er(t,e.activity?.health),a=i.kind===`repeat`||i.kind===`waiting`?`text-warn`:i.kind===`error`?`text-danger`:i.kind===`quiet`?`text-fg-faint`:`text-ok`;return(0,I.jsxs)(`a`,{href:g({name:`session`,id:e.session_id}),className:`grid grid-cols-[132px_1fr_92px_104px] items-center gap-3 px-3 py-2 border-t border-border first:border-t-0 hover:bg-panel-2 no-underline text-fg`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`text-[13px] font-medium flex items-baseline gap-1.5 min-w-0`,children:[(0,I.jsx)(`span`,{className:`shrink-0`,children:e.project||`unknown project`}),e.git_branch&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[10px] text-fg-faint mono`,title:e.git_branch,children:e.git_branch}),Ht(e.agent)&&(0,I.jsx)(`span`,{className:`shrink-0 text-[9px] uppercase tracking-[0.08em] text-fg-faint border border-border px-1 rounded-sm`,children:Ht(e.agent)})]}),(0,I.jsxs)(`div`,{className:`text-[10px] text-fg-faint mono truncate`,children:[r&&(0,I.jsxs)(`span`,{title:`session ${e.session_id} · started ${T(e.started_at)} ago`,children:[E(e.session_id),` · `]}),e.activity?.phrase??``]})]}),(0,I.jsx)(dr,{pulse:t,now:n*6e4,sessionID:e.session_id}),(0,I.jsx)(`div`,{className:`num text-[13px] font-semibold text-right`,title:`${S(e.stats?.cost_usd)} for the whole session`,children:S(Kn(t))}),(0,I.jsx)(`div`,{className:`text-[11px] text-right ${a}`,title:t.repeatSample,children:i.label})]})}var cr={low:{token:`--color-ok`,fallback:`#4fbf6b`,alpha:.55},mid:{token:`--color-accent`,fallback:`#feb157`,alpha:.85},high:{token:`--color-accent-strong`,fallback:`#ffcb85`,alpha:1}},lr={token:`--color-fg-faint`,fallback:`#837f78`,alpha:.3};function ur(e,t,n){return e.getPropertyValue(t).trim()||n}function dr({pulse:e,now:t,sessionID:n}){let r=(0,l.useRef)(null),[i,a]=(0,l.useState)(null);(0,l.useEffect)(()=>{let t=r.current;if(!t)return;let n=()=>{let n=t.clientWidth,r=t.clientHeight;if(n===0||r===0)return;let i=window.devicePixelRatio||1;t.width=Math.round(n*i),t.height=Math.round(r*i);let a=t.getContext(`2d`);if(!a)return;a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,n,r);let o=getComputedStyle(t),s=ur(o,lr.token,lr.fallback),c=e.bars,l=Math.max(...c.map(e=>e.n),1),u=nr(c),d=n/c.length;for(let e=0;e{i.disconnect(),a.disconnect()}},[e]);let o=t=>{let n=t.currentTarget.getBoundingClientRect();if(n.width===0)return;let r=Math.floor((t.clientX-n.left)/n.width*e.bars.length);a(r>=0&&ra(null),onClick:e=>{i===null||!s||s.n===0||(e.preventDefault(),e.stopPropagation(),v({name:`session`,id:n,at:u}))},"aria-hidden":!0}),s&&(0,I.jsx)(`div`,{className:`absolute -top-1 left-0 right-0 pointer-events-none flex justify-center`,children:(0,I.jsxs)(`span`,{className:`num text-[10px] bg-panel-2 border border-border-strong rounded-sm px-1.5 py-0.5 text-fg-muted whitespace-nowrap`,children:[new Date(u).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),s.n===0?` · nothing happened`:(0,I.jsxs)(I.Fragment,{children:[` · ${s.n} event${s.n===1?``:`s`}`,s.turns>0&&` · ${s.turns} turn${s.turns===1?``:`s`}`,s.cost>0&&` · ${S(s.cost)}`,s.cost>0&&c>0&&(0,I.jsx)(`span`,{className:`text-fg-faint`,children:` (median ${S(c)})`}),(0,I.jsx)(`span`,{className:`text-fg-faint`,children:` · click to open`})]})]})})]})}function fr({session:e,now:t,onClose:n}){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)();(0,l.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await P.notes(e.session_id,12);t||i(n)}catch(e){t||o(e instanceof Error?e.message:`could not load`)}})(),()=>{t=!0}},[e.session_id]);let s=r?.find(e=>!e.fragment),c=r?.[0],u=s??c;return(0,I.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-start justify-center pt-[10vh] px-4`,onClick:n,children:(0,I.jsxs)(`div`,{className:`w-full max-w-[720px] max-h-[76vh] flex flex-col border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`px-4 pt-3 pb-2 border-b border-border flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-[13px] font-medium truncate`,children:e.project||`unknown project`}),(0,I.jsx)(`span`,{className:`text-[11px] text-fg-muted truncate`,children:e.activity?.phrase}),(0,I.jsx)(`button`,{onClick:n,className:`ml-auto text-[16px] leading-none text-fg-faint hover:text-fg`,children:`×`})]}),(0,I.jsxs)(`div`,{className:`overflow-y-auto px-4 py-3 grid gap-3`,children:[!r&&!a&&(0,I.jsx)(`div`,{className:`text-[12px] text-fg-muted`,children:`loading…`}),a&&(0,I.jsx)(`div`,{className:`text-[12px] text-danger`,children:a}),r&&!u&&(0,I.jsx)(`div`,{className:`text-[12px] text-fg-muted`,children:`This session has not said anything yet — it may be running without hooks, or still on its first turn.`}),u&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:[`Last thing Claude said · `,T(u.ts,t),s&&c&&s.event_id!==c.event_id&&(0,I.jsx)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:`(the newest line was mid-thought; this is the last complete one)`})]}),(0,I.jsx)(`div`,{className:`text-[13px] leading-relaxed whitespace-pre-wrap text-fg`,children:u.text})]}),e.activity?.plan&&e.activity.plan.total>0&&(0,I.jsxs)(`div`,{className:`border-t border-border pt-3`,children:[(0,I.jsxs)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint mb-1`,children:[`Plan · `,e.activity.plan.done,`/`,e.activity.plan.total]}),e.activity.plan.next&&(0,I.jsxs)(`div`,{className:`text-[12px] text-fg-muted`,children:[`→ `,e.activity.plan.next]})]})]}),(0,I.jsxs)(`div`,{className:`px-4 py-2 border-t border-border flex items-center gap-3 text-[11px]`,children:[(0,I.jsx)(`a`,{href:g({name:`session`,id:e.session_id}),className:`link text-fg-muted hover:text-fg`,children:`open the session →`}),(0,I.jsx)(`span`,{className:`ml-auto text-fg-faint`,children:e.owned?`answer in its terminal tab`:`reply in the terminal you started it in`})]})]})})}var pr=`premium-hint`;function mr({reason:e,now:t}){let[n]=(0,l.useState)(()=>An(pr,t)),[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(!1);return!n||r?null:(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-[11px]`,children:[(0,I.jsx)(`span`,{className:`text-fg-faint`,children:e}),(0,I.jsx)(`button`,{onClick:()=>o(!0),className:`rounded-sm border border-border px-1.5 py-0.5 text-fg-muted hover:border-border-strong hover:text-fg`,children:`a cap that stops this`}),(0,I.jsx)(`button`,{title:`hide this for a month`,onClick:()=>{jn(pr,t),i(!0)},className:`text-fg-faint hover:text-fg-muted`,children:`✕`}),a&&(0,I.jsx)(nt,{feature:`cap`,onClose:()=>o(!1)})]})}function hr({items:e,now:t,onDismiss:n,sessions:r}){return e.length===0?null:(0,I.jsx)(`div`,{className:`grid gap-1.5`,children:e.map(e=>(0,I.jsx)(gr,{it:e,now:t,onDismiss:n,session:r?.find(t=>t.session_id===e.sessionId)},e.id))})}function gr({it:e,now:t,onDismiss:n,session:r}){let[i,a]=(0,l.useState)(!1),o=e.severity===`high`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`border rounded-[var(--radius-panel)] px-3 py-2 flex items-center gap-3 ${o?`border-danger/50 bg-danger/10`:`border-warn/50 bg-warn/10`}`,children:[(0,I.jsx)(`span`,{className:`font-medium text-[13px] shrink-0 ${o?`text-danger`:`text-warn`}`,children:e.title}),(0,I.jsxs)(`span`,{className:`text-[12px] text-fg-muted truncate`,children:[e.sessionId&&(0,I.jsx)(`a`,{href:g({name:`session`,id:e.sessionId}),className:`link mono text-fg`,children:e.project||E(e.sessionId)}),(0,I.jsx)(`span`,{className:e.sessionId?`ml-2`:``,children:e.detail})]}),(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 shrink-0`,children:[e.costUSD!==void 0&&e.costUSD>0&&(0,I.jsx)(`span`,{className:`num text-[13px] text-fg`,title:`spent by this session so far`,children:S(e.costUSD)}),e.since!==void 0&&(0,I.jsx)(`span`,{className:`num text-[11px] text-fg-faint`,children:T(e.since,t)}),r&&e.id.startsWith(`waiting-`)&&(0,I.jsx)(`button`,{className:`text-[11px] border border-border px-1.5 py-0.5 rounded-sm hover:border-border-strong text-fg-muted hover:text-fg`,onClick:()=>a(!0),children:`what did it ask?`}),(0,I.jsx)(`a`,{href:e.sessionId?g({name:`session`,id:e.sessionId,tab:`timeline`,at:e.at}):`#/cost`,className:`text-[11px] border border-border px-1.5 py-0.5 rounded-sm hover:border-border-strong no-underline text-fg-muted hover:text-fg`,children:e.sessionId?`open`:`details`}),(e.id.startsWith(`loop-`)||e.id.startsWith(`spent-`))&&(0,I.jsx)(mr,{reason:`this is what a cap stops`,now:t}),n&&e.id.startsWith(`loop-`)&&(0,I.jsx)(`button`,{className:`text-[11px] text-fg-faint hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,onClick:()=>n(e.sessionId),children:`dismiss`})]})]}),i&&r&&(0,I.jsx)(fr,{session:r,now:t,onClose:()=>a(!1)})]})}var _r=9e5,vr=25,yr=300,br=2,xr=864e5,Sr=90,Cr=6912e5;function wr(e){return typeof e==`number`?e:e&&Date.parse(e)||0}function Tr({sessions:e,alerts:t,now:n,limits:r,waitingMs:i=_r}){let a=[],o=Array.isArray(e)?e.filter(Boolean):[],s=Array.isArray(t)?t.filter(Boolean):[],c=new Map(o.map(e=>[e.session_id,e]));for(let e of s){let t=c.get(e.session_id);a.push({id:`loop-${e.session_id}`,sessionId:e.session_id,project:t?.project??``,severity:`high`,title:`Stuck in a loop`,detail:[`ran ${e.sample||e.tool||`the same call`}`,Number.isFinite(e.count)?`${e.count}×`:`repeatedly`,Number.isFinite(e.window_min)?`in ${e.window_min} min`:``].filter(Boolean).join(` `),costUSD:t?.stats?.cost_usd,since:wr(e.ts)||void 0,at:wr(e.first_ts)||wr(e.ts)||void 0})}for(let e of o)if(e.status!==`ended`&&e.activity){if(e.activity.health===`error`){a.push({id:`error-${e.session_id}`,sessionId:e.session_id,project:e.project,severity:`high`,title:`Session hit an error`,detail:e.activity.phrase,costUSD:e.stats?.cost_usd,since:wr(e.activity.at)||e.last_event_at});continue}if(e.activity.health===`waiting-on-you`){let t=wr(e.activity.at)||e.last_event_at;t>0&&n-t>=i&&a.push({id:`waiting-${e.session_id}`,sessionId:e.session_id,project:e.project,severity:`medium`,title:`Waiting on you`,detail:e.activity.phrase,since:t})}}for(let e of o){if(!e.stats||!e.activity)continue;let{cost_usd:t,turns:r,files_touched:i}=e.stats;if(tbr)continue;let o=wr(e.activity.at)||e.last_event_at;o>0&&n-o>xr||a.push({id:`spent-${e.session_id}`,sessionId:e.session_id,project:e.project,severity:`medium`,title:`Lots of turns, few files`,detail:`${r.toLocaleString()} turns, ${i===0?`no files`:i===1?`1 file`:`${i} files`} touched`,costUSD:t,since:wr(e.activity.at)||e.last_event_at})}let l={high:0,medium:1};for(let[e,t]of[[`5-hour`,r?.five_hour],[`7-day`,r?.seven_day]]){if(!t||t.used_percentagen&&r=95?`high`:`medium`,title:`${e} plan window ${i}% used`,detail:`resets at ${o}${t.forecast?` — ${t.forecast}`:``}`})}return a.sort((e,t)=>l[e.severity]-l[t.severity]||(e.since??0)-(t.since??0))}var Er=`caprock.update.dismissed`;function Dr({plan:e,onSave:t,now:n,owned:r=0}){let[i,a]=(0,l.useState)(),[o,s]=(0,l.useState)(()=>localStorage.getItem(Er)??``);return(0,l.useEffect)(()=>{if(!e?.update_checks){a(void 0);return}let t=!0,n=()=>{P.update().then(e=>{t&&a(e)}).catch(()=>{})};n();let r=window.setInterval(n,6e4);return()=>{t=!1,window.clearInterval(r)}},[e?.update_checks]),e&&!e.update_checks?o===`offer`?null:(0,I.jsxs)(Or,{tone:`muted`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:`Caprock can check GitHub for new releases. It's the only outbound call it makes, so it's off unless you turn it on — no usage data is sent, and you can turn it off again any time.`}),(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[(0,I.jsx)(`button`,{className:`text-[11px] border border-accent/50 text-accent bg-accent/10 px-2 py-0.5 rounded-sm hover:bg-accent/20`,onClick:()=>t({update_checks:!0}),children:`check for updates`}),(0,I.jsx)(`button`,{className:`text-[11px] text-fg-faint hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,onClick:()=>{localStorage.setItem(Er,`offer`),s(`offer`)},children:`no thanks`})]})]}):!i?.update_available||!i.latest||o===i.latest?null:(0,I.jsxs)(Or,{tone:`accent`,children:[(0,I.jsxs)(`span`,{className:`text-fg`,children:[(0,I.jsxs)(`span`,{className:`font-medium`,children:[`Caprock `,i.latest]}),` is available — you're on `,(0,I.jsx)(`span`,{className:`mono`,children:i.current}),`.`]}),r>0&&(0,I.jsx)(`span`,{className:`text-[12px] text-warn shrink-0`,children:r===1?`1 session Caprock started will close`:`${r} sessions Caprock started will close`}),i.command?(0,I.jsx)(Ot,{command:i.command}):(0,I.jsx)(`a`,{className:`link text-[12px]`,href:i.url,target:`_blank`,rel:`noreferrer`,children:`download it`}),(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[i.checked_at?(0,I.jsxs)(`span`,{className:`num text-[11px] text-fg-faint`,children:[`checked `,T(i.checked_at,n)]}):null,(0,I.jsx)(`a`,{className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-0.5 rounded-sm no-underline`,href:i.url,target:`_blank`,rel:`noreferrer`,children:`what's new`}),(0,I.jsx)(`button`,{className:`text-[11px] text-fg-faint hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,onClick:()=>{localStorage.setItem(Er,i.latest),s(i.latest)},children:`not now`})]})]})}function Or({tone:e,children:t}){return(0,I.jsx)(`div`,{className:`border rounded-[var(--radius-panel)] px-3 py-2 flex items-center gap-3 text-[12px] ${e===`accent`?`border-accent/40 bg-accent/5`:`border-border bg-panel`}`,children:t})}function kr({u:e,className:t=``}){return!e||e.turns===0?null:(0,I.jsxs)(`div`,{className:`border border-warn/50 bg-warn/10 px-3 py-2 text-[12px] rounded-[var(--radius-panel)] ${t}`,children:[(0,I.jsx)(`span`,{className:`text-warn font-medium`,children:`Cost is incomplete`}),` `,(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[C(e.tokens),` tokens over `,e.turns,` turn`,e.turns===1?``:`s`,` could not be priced, so they are missing from the total above — not free. `,e.models.length===1?`Model`:`Models`,` with no entry in the pricing table:`,` `,e.models.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0&&`, `,(0,I.jsx)(`span`,{className:`mono text-fg`,children:e||`unknown`})]},e)),`. This happens when a model ships newer than the pricing table, or when a gateway reports ids that do not normalise.`]})]})}function Ar({value:e,onPick:t}){let[n,r]=(0,l.useState)(`recent`),[i,a]=(0,l.useState)(``),o=F(()=>P.recentDirs(),[],{live:!1}),s=F(()=>P.browse(i),[i],{live:!1});return(0,l.useEffect)(()=>{o.data&&o.data.length===0&&r(`browse`)},[o.data]),(0,I.jsxs)(`div`,{className:`rounded-[3px] border border-border-strong bg-panel-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-strong px-2 py-1.5 text-[12px]`,children:[(0,I.jsx)(jr,{on:n===`recent`,onClick:()=>r(`recent`),children:`Recent`}),(0,I.jsx)(jr,{on:n===`browse`,onClick:()=>r(`browse`),children:`Browse`}),n===`browse`&&s.data&&(0,I.jsx)(`span`,{className:`mono ml-auto min-w-0 truncate pl-2 text-[11px] text-fg-faint`,title:s.data.dir,children:Ir(s.data.dir,s.data.root)})]}),(0,I.jsx)(`div`,{className:`h-[168px] overflow-y-auto overflow-x-hidden`,children:n===`recent`?(0,I.jsx)(Mr,{rows:o.data,value:e,onPick:t}):(0,I.jsx)(Nr,{data:s.data,value:e,onOpen:a,onPick:t,error:s.error?.message})})]})}function jr({on:e,onClick:t,children:n}){return(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-sm px-2 py-0.5 ${e?`bg-accent/15 text-accent`:`text-fg-muted hover:text-fg`}`,children:n})}function Mr({rows:e,value:t,onPick:n}){return e?e.length===0?(0,I.jsx)(Fr,{children:`No sessions yet — use Browse, or type a path.`}):(0,I.jsx)(`ul`,{children:e.map(e=>(0,I.jsxs)(Pr,{selected:t===e.dir,onClick:()=>n(e.dir),children:[(0,I.jsx)(`span`,{className:`shrink-0 text-fg`,children:e.name}),(0,I.jsx)(`span`,{className:`mono ml-2 min-w-0 flex-1 truncate text-[11px] text-fg-faint`,title:e.dir,children:e.dir}),(0,I.jsx)(`span`,{className:`shrink-0 pl-2 text-[11px] text-fg-faint`,children:T(e.last_event_at)})]},e.dir))}):(0,I.jsx)(Fr,{children:`…`})}function Nr({data:e,value:t,onOpen:n,onPick:r,error:i}){return i?(0,I.jsx)(Fr,{children:i}):e?(0,I.jsxs)(`ul`,{children:[e.parent&&(0,I.jsx)(Pr,{selected:!1,onClick:()=>n(e.parent),children:(0,I.jsx)(`span`,{className:`text-fg-muted`,children:`↑ up`})}),e.entries.length===0&&(0,I.jsx)(Fr,{children:`Nothing here.`}),e.entries.map(e=>(0,I.jsxs)(Pr,{selected:t===e.path,onClick:()=>e.repo?r(e.path):n(e.path),children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate ${e.repo?`text-fg`:`text-fg-muted`}`,children:e.name}),e.repo&&(0,I.jsx)(`span`,{className:`ml-2 shrink-0 text-[10px] uppercase tracking-wide text-accent`,children:`repo`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.repo?n(e.path):r(e.path)},className:`shrink-0 px-1 text-[11px] text-fg-faint hover:text-fg`,title:e.repo?`Open this folder`:`Use this folder`,children:e.repo?`›`:`use`})]},e.path))]}):(0,I.jsx)(Fr,{children:`…`})}function Pr({selected:e,onClick:t,children:n}){return(0,I.jsx)(`li`,{children:(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`flex w-full min-w-0 items-center px-2.5 py-1 text-left text-[12px] hover:bg-panel ${e?`bg-accent/10`:``}`,children:n})})}function Fr({children:e}){return(0,I.jsx)(`p`,{className:`px-2.5 py-3 text-[12px] text-fg-faint`,children:e})}function Ir(e,t){return e===t?`~`:e.startsWith(t+`/`)?`~`+e.slice(t.length):e}var Lr=`claude-opus-5`,Rr=`acceptEdits`,zr=[[`gemini-3.5-flash-lite`,`Flash Lite 3.5 · cheapest`],[`gemini-2.5-flash`,`Flash 2.5 · older, cheap`],[`gemini-3.5-flash`,`Flash 3.5 · most capable here`]],Br=[[`claude-opus-5`,`Opus 5 · most capable`],[`claude-sonnet-5`,`Sonnet 5 · faster, cheaper`],[`claude-haiku-4-5`,`Haiku 4.5 · cheapest`]],Vr=new Set([`acceptEdits`,`auto`,`bypassPermissions`,`plan`]),Hr=[[`acceptEdits`,`Accept edits · asks first`],[`plan`,`Plan · changes nothing`],[`bypassPermissions`,`Bypass · never asks`]];function Ur({available:e,geminiAvailable:t=!1,onClose:n,initialCwd:r=``}){let[i,a]=(0,l.useState)(r),[o,s]=(0,l.useState)(`claude`),[c,u]=(0,l.useState)(Lr),[d,f]=(0,l.useState)(Rr),[p,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(!1),[_,y]=(0,l.useState)(!1),[b,x]=(0,l.useState)(``),S=async()=>{if(!i.trim()){x(`Working directory is required.`);return}y(!0),x(``);try{let e={cwd:i.trim()};o!==`claude`&&(e.agent=o),c&&(e.model=c),d&&o===`claude`&&(e.permission_mode=d),p.trim()&&(e.worktree=p.trim()),h&&(e.create=!0);let{session_id:t}=await P.spawn(e);n(),v({name:`session`,id:t,tab:`terminal`})}catch(e){x(ae(e))}finally{y(!1)}};return(0,I.jsx)(`div`,{className:`fixed inset-0 z-20 bg-black/50 flex items-start justify-center pt-24`,onClick:n,children:(0,I.jsxs)(`div`,{className:`border border-border-strong bg-panel rounded-[var(--radius-panel)] w-[620px] max-w-[94vw]`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`header`,{className:`px-3 py-2 border-b border-border flex items-center`,children:[(0,I.jsx)(`h2`,{className:`text-[12px] uppercase tracking-[0.08em] text-fg-muted`,children:`New session`}),(0,I.jsx)(`button`,{onClick:n,className:`ml-auto text-fg-muted hover:text-fg`,children:`✕`})]}),e?(0,I.jsxs)(`div`,{className:`px-4 py-3 grid min-w-0 gap-3 text-[13px]`,children:[(0,I.jsxs)(Wr,{label:`Working directory`,hint:`pick one, or type a path`,children:[(0,I.jsx)(`input`,{autoFocus:!0,className:`input`,placeholder:`/Users/you/dev/project`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&S()}),(0,I.jsx)(`div`,{className:`mt-1.5 min-w-0 max-w-full`,children:(0,I.jsx)(Ar,{value:i,onPick:a})})]}),t&&(0,I.jsx)(Wr,{label:`Agent`,children:(0,I.jsxs)(`select`,{className:`input`,value:o,onChange:e=>{let t=e.target.value;s(t),u(t===`gemini`?zr[0][0]:Lr)},children:[(0,I.jsx)(`option`,{value:`claude`,children:`Claude Code`}),(0,I.jsx)(`option`,{value:`gemini`,children:`Gemini CLI · your own key`})]})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsx)(Wr,{label:`Model`,children:(0,I.jsx)(`select`,{className:`input`,value:c,onChange:e=>u(e.target.value),children:(o===`gemini`?zr:Br).map(([e,t])=>(0,I.jsx)(`option`,{value:e,children:t},e))})}),(0,I.jsx)(Wr,{label:`Permissions`,children:(0,I.jsx)(`select`,{className:`input`,value:d,onChange:e=>f(e.target.value),children:Hr.map(([e,t])=>(0,I.jsx)(`option`,{value:e,children:o===`gemini`&&!Vr.has(e)?`${t} · Gemini asks instead`:t},e))})})]}),(0,I.jsxs)(`details`,{className:`text-[12px] group`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer select-none text-fg-muted hover:text-fg list-none marker:content-none`,children:[(0,I.jsx)(`span`,{className:`inline-block transition-transform group-open:rotate-90 text-fg-faint`,children:`▶`}),` Advanced`]}),(0,I.jsxs)(`div`,{className:`grid gap-2 pt-2`,children:[(0,I.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none text-fg-muted`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--color-accent)]`,checked:h,onChange:e=>g(e.target.checked)}),`create the directory if it does not exist`]}),(0,I.jsx)(Wr,{label:`Git worktree`,hint:`creates .caprock-worktrees/ on a new branch`,children:(0,I.jsx)(`input`,{className:`input`,placeholder:`feature-x`,value:p,onChange:e=>m(e.target.value)})})]})]}),b&&(0,I.jsx)(`div`,{className:`text-danger text-[12px]`,children:b})]}):(0,I.jsxs)(`div`,{className:`px-4 py-6 text-[13px] text-fg-muted`,children:[`The `,(0,I.jsx)(`span`,{className:`mono`,children:`claude`}),` binary was not found on this machine, so Caprock cannot spawn sessions. It still observes every session you start yourself.`]}),e&&(0,I.jsxs)(`footer`,{className:`px-4 py-2 border-t border-border flex gap-2 justify-end`,children:[(0,I.jsx)(`button`,{onClick:n,className:`border border-border px-3 py-1 rounded-sm text-fg-muted hover:text-fg`,children:`Cancel`}),(0,I.jsx)(`button`,{onClick:S,disabled:_,className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:_?`starting…`:`Start session`})]})]})})}function Wr({label:e,hint:t,children:n}){return(0,I.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[e,t&&(0,I.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,t]})]}),n]})}var Gr=1728e5;function Kr(e,t){return!e.last_event_at||t-e.last_event_atP.sessions(!e),[e],{intervalMs:5e3}),s=F(()=>P.status(),[],{live:!1,intervalMs:3e4}),c=F(()=>P.summary(`today`,n),[n],{intervalMs:5e3}),u=F(()=>P.history(`all`),[],{intervalMs:6e4}),{alerts:p}=f(),m=re(1e3),h=o.data??[],g=n===`all`?h:h.filter(e=>(e.agent??`claude`)===n),_=Vt.filter(e=>e.key===`all`||e.key===`claude`||e.key===`opencode`&&!!s.data?.opencode||e.key===`gemini`&&h.some(e=>e.agent===`gemini`)),v=_.length>2,y=g.filter(e=>e.activity.health===`working`||e.activity.health===`looping`||e.activity.health===`error`||e.activity.health===`waiting-on-you`),b=g.filter(e=>!y.includes(e)&&e.status!==`ended`&&Kr(e,m)),x=g.filter(e=>e.status===`ended`),[w,ee]=De(),E=Tr({sessions:g,alerts:p,now:m,limits:c.data?.rate_limits}),te=s.data?.hooks&&(s.data.hooks.missing??[]).length>0,D=!!c.data&&c.data.turns>0,ne=s.data?.ingest_error;return(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[ne&&(0,I.jsxs)(`div`,{className:`border border-danger/50 bg-danger/10 px-3 py-2 text-[12px] rounded-[var(--radius-panel)] flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`text-danger font-medium`,children:`Ingest stopped`}),(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[`No new sessions are being captured. `,(0,I.jsx)(`span`,{className:`mono text-fg`,children:ne}),` — check that`,(0,I.jsx)(`span`,{className:`mono text-fg`,children:` ~/.claude`}),` is readable, then restart with`,(0,I.jsx)(`span`,{className:`mono text-fg`,children:` caprock down && caprock up`}),`.`]})]}),te&&(0,I.jsxs)(`div`,{className:`border border-warn/50 bg-warn/10 px-3 py-2 text-[12px] rounded-[var(--radius-panel)] flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`text-warn font-medium`,children:`Hooks not installed`}),(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[`Activity is coming from transcripts only (a few seconds late, no tool-level detail for running commands). Run `,(0,I.jsx)(`span`,{className:`mono text-fg`,children:`caprock hooks install`}),` for real-time narration.`]}),(0,I.jsx)(`a`,{href:`#/settings`,className:`link ml-auto text-[11px]`,children:`details`})]}),(0,I.jsx)(Dr,{plan:w,onSave:ee,now:m,owned:g.filter(e=>e.owned&&e.status!==`ended`).length}),(0,I.jsx)(hr,{items:E,now:m,onDismiss:e=>d.dismissAlert(e),sessions:g}),(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(vn,{plan:w})}),(0,I.jsx)(Jr,{available:s.data?.claude_available}),(0,I.jsx)(Yr,{available:s.data?.claude_available,onClick:()=>a(!0)})]}),D&&u.data?.totals&&(0,I.jsx)(Nn,{costUSD:u.data.totals.cost_usd,days:u.data.totals.days,now:m}),(0,I.jsxs)(L,{title:`Today`,center:v?(0,I.jsx)(`span`,{className:`inline-flex items-center gap-0.5 rounded-md bg-panel-2 p-0.5`,children:_.map(e=>(0,I.jsx)(`button`,{onClick:()=>r(e.key),title:e.key===`all`?`Every agent`:`Only ${e.label}`,className:`px-2.5 py-1 text-[12px] mono rounded-[5px] transition-colors ${n===e.key?`bg-accent text-panel font-medium`:`text-fg-muted hover:text-fg`}`,children:e.label},e.key))}):null,right:c.data?(0,I.jsxs)(`span`,{className:`num`,children:[`pricing `,c.data.pricing_version,` · at API list price`]}):null,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-[1.4fr_1fr_1fr_1fr_1fr_1fr] divide-x divide-border`,children:[(0,I.jsx)(R,{label:`Cost today`,value:D?S(c.data?.cost_usd):`—`,sub:(0,I.jsx)(`span`,{title:_n(w),children:D?gn(w):`nothing measured yet`}),tone:`info`,size:`hero`}),(0,I.jsx)(R,{label:`Burn now`,value:D?`${S(c.data.burn.usd_per_hour)}/h`:`—`,sub:D?`${C(Math.round(c.data.burn.tokens_per_min))} tok/min · last ${c.data.burn.window_min}m`:void 0}),(0,I.jsx)(R,{label:`Sessions`,value:D?c.data.sessions:`—`,sub:D?`${c.data.active_sessions} active`:void 0,size:`compact`}),(0,I.jsx)(R,{label:`Turns`,value:D?c.data.turns:`—`,sub:D?`${c.data.tool_calls} tool calls`:void 0,size:`compact`}),(0,I.jsx)(Tn,{limits:c.data?.rate_limits,now:m}),(0,I.jsx)(Sn,{hitRate:c.data?.savings.hit_rate,cutPct:c.data?.savings.cut_pct,measured:D})]}),(0,I.jsx)(kr,{u:c.data?.unpriced,className:`mx-3 mb-2.5`})]}),(0,I.jsx)(ar,{sessions:g,now:m}),(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,I.jsx)(pn,{sessions:g,now:m,emptyHint:n===`all`?void 0:(0,I.jsxs)(I.Fragment,{children:[`Nothing from `,Ut(n),` yet.`]})}),(0,I.jsx)(Zt,{sessions:g,agent:n})]}),(0,I.jsx)(Un,{}),o.error&&!o.data&&(0,I.jsxs)(Et,{title:`Cannot reach the daemon`,children:[o.error.message,` — is `,(0,I.jsx)(`span`,{className:`mono`,children:`caprock up`}),` running?`]}),!o.data&&!o.error&&(0,I.jsx)(Dt,{rows:4,className:`border border-border rounded-[var(--radius-panel)] bg-panel`}),o.data&&g.length===0&&(n===`all`?(0,I.jsxs)(Et,{title:`No sessions yet`,children:[`Start `,(0,I.jsx)(`span`,{className:`mono`,children:`claude`}),` in any terminal — it will show up here within seconds.`]}):(0,I.jsxs)(Et,{title:`No ${Ut(n)} sessions here`,children:[`Nothing from this agent in the current view. Switch to`,` `,(0,I.jsx)(`button`,{className:`link underline`,onClick:()=>r(`all`),children:`all`}),` `,`to see everything.`]})),(0,I.jsx)(Xr,{groups:[{label:`Active`,items:y},{label:`Idle`,items:b,dim:!0},...e?[{label:`Ended`,items:x,dim:!0}]:[]],now:m}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint px-0.5`,children:[(0,I.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--color-accent)]`,checked:e,onChange:e=>t(e.target.checked)}),`show ended sessions`]}),o.loadedAt>0&&(0,I.jsxs)(`span`,{className:`num ml-auto`,children:[`refreshed `,T(o.loadedAt,m)]})]}),i&&(0,I.jsx)(Ur,{available:s.data?.claude_available??!1,geminiAvailable:s.data?.gemini_available??!1,onClose:()=>{a(!1),o.refresh()}})]})}function Jr({available:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(``);return e===!1?null:(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)(`button`,{onClick:async()=>{n(!0),i(``);try{let{session_id:e}=await P.spawn({chat:!0});v({name:`session`,id:e,tab:`terminal`})}catch(e){i(ae(e))}finally{n(!1)}},disabled:t,title:`start a session without picking a folder`,className:`relative shrink-0 rounded-[var(--radius-panel)] border border-border-strong px-3 py-2 text-[13px] leading-5 text-fg-muted hover:text-fg hover:border-accent/50 disabled:opacity-50`,children:[t?`starting…`:`Quick chat`,r&&(0,I.jsx)(`span`,{className:`absolute right-0 top-full mt-1 block max-w-[220px] text-right text-[11px] text-danger`,children:r})]})})}function Yr({available:e,onClick:t}){let n=e===!1;return(0,I.jsxs)(`button`,{onClick:t,title:n?`claude was not found on this machine — click for details`:`start a session Caprock owns`,className:`shrink-0 rounded-[var(--radius-panel)] border px-3 py-2 text-[13px] leading-5 font-medium transition-colors ${n?`border-border text-fg-faint hover:text-fg-muted`:`border-accent/60 bg-accent/15 text-accent hover:bg-accent/25`}`,children:[`+ New session`,n?` (claude not found)`:``]})}function Xr({groups:e,now:t}){let n=e.flatMap(e=>e.items.map((t,n)=>({s:t,dim:e.dim,label:n===0?`${e.label} · ${e.items.length}`:null})));return n.length===0?null:(0,I.jsx)(`div`,{"data-testid":`session-grid`,className:`mt-3 grid gap-2 gap-y-6`,children:n.map(({s:e,dim:n,label:r})=>(0,I.jsxs)(`div`,{className:`relative ${n?`opacity-80`:``}`,children:[r&&(0,I.jsx)(`div`,{className:`absolute -top-4 left-0.5 text-[11px] uppercase tracking-[0.08em] text-fg-faint`,children:r}),(0,I.jsx)(Zr,{s:e,now:t})]},e.session_id))})}function Zr({s:e,now:t}){let n=e.context,r=n?n.pct>=85?`danger`:n.pct>=60?`warn`:void 0:void 0,[i,a]=(0,l.useState)(!1),o=e.activity?.health===`waiting-on-you`;return(0,I.jsxs)(`a`,{href:g({name:`session`,id:e.session_id}),className:`block border border-border bg-panel rounded-[var(--radius-panel)] hover:border-border-strong no-underline hover:no-underline text-fg`,children:[(0,I.jsxs)(`div`,{className:`px-3 pt-2 pb-1 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-medium truncate text-[15px]`,children:e.project||`unknown project`}),(0,I.jsx)(`span`,{className:`mono text-[11px] text-fg-faint`,children:E(e.session_id)}),e.agent&&e.agent!==`claude`&&(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.08em] text-fg-muted border border-border px-1 py-px rounded-sm`,children:e.agent}),e.git_branch&&(0,I.jsx)(`span`,{className:`mono text-[11px] text-fg-muted truncate`,children:e.git_branch}),(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[o&&(0,I.jsx)(`button`,{className:`text-[11px] border border-warn/50 text-warn bg-warn/10 px-1.5 py-0.5 rounded-sm hover:bg-warn/20`,onClick:e=>{e.preventDefault(),a(!0)},children:`what did it ask?`}),(0,I.jsx)(wt,{health:e.activity.health})]})]}),i&&(0,I.jsx)(fr,{session:e,now:t,onClose:()=>a(!1)}),(0,I.jsxs)(`div`,{className:`px-3 pb-2 text-[13px] truncate`,title:e.activity.phrase,children:[(0,I.jsx)(`span`,{className:e.activity.health===`working`?`text-fg`:`text-fg-muted`,children:e.activity.phrase}),(0,I.jsx)(`span`,{className:`text-fg-faint num text-[11px] ml-2`,children:T(e.activity.at||e.last_event_at,t)})]}),e.activity.plan&&e.activity.plan.total>0&&(0,I.jsxs)(`div`,{className:`px-3 pb-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,I.jsx)(`div`,{className:`h-1 flex-1 bg-panel-2 rounded-sm overflow-hidden`,children:(0,I.jsx)(`div`,{className:`h-full bg-accent`,style:{width:`${Math.min(100,Math.max(0,100*e.activity.plan.done/e.activity.plan.total))}%`}})}),(0,I.jsxs)(`span`,{className:`num`,children:[e.activity.plan.done,`/`,e.activity.plan.total]}),e.activity.plan.next&&(0,I.jsxs)(`span`,{className:`truncate max-w-[50%]`,children:[`→ `,e.activity.plan.next]})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 divide-x divide-border border-t border-border`,children:[(0,I.jsx)(R,{label:`Cost`,value:S(e.stats.cost_usd),sub:e.model||`—`,tone:`info`}),(0,I.jsx)(R,{label:`Tokens`,value:C(e.stats.tokens_in+e.stats.tokens_out+e.stats.cache_read+e.stats.cache_write),sub:`${w(e.savings.hit_rate*100)} cache hit`}),(0,I.jsx)(R,{label:`Context`,value:n?w(n.pct):`—`,sub:n?`${C(n.tokens)} / ${C(n.window)}`:`unknown model`,tone:r}),(0,I.jsx)(R,{label:`Activity`,value:e.stats.tool_calls,sub:`${e.stats.turns} turns · ${e.stats.files_touched} files`})]})]})}function Qr({id:e,now:t}){let n=F(()=>P.notes(e),[e],{intervalMs:1e4}),r=n.data??[],[i,a]=(0,l.useState)(!1),o=r.filter(e=>!e.fragment),s=i?r:o;return n.error&&!n.data?(0,I.jsx)(Et,{title:`Cannot load notes`,children:n.error.message}):n.data?r.length===0?(0,I.jsx)(Et,{title:`Nothing said yet`,children:`Claude's written answers appear here — the reasoning and the “what changed, what I still need from you” that otherwise lives only in your terminal scrollback.`}):(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint px-0.5`,children:[(0,I.jsxs)(`span`,{children:[o.length,` `,o.length===1?`answer`:`answers`,r.length>o.length&&` · ${r.length-o.length} short remarks`]}),r.length>o.length&&(0,I.jsx)(`button`,{className:`text-fg-muted hover:text-fg border border-border px-1.5 rounded-sm`,onClick:()=>a(e=>!e),children:i?`hide short remarks`:`show everything`}),(0,I.jsx)(`span`,{className:`ml-auto`,children:`subagent chatter excluded · newest first`})]}),s.map(e=>(0,I.jsx)(ei,{note:e,now:t},e.event_id))]}):(0,I.jsx)(Dt,{rows:4})}var $r=600;function ei({note:e,now:t,showSession:n=!1}){let[r,i]=(0,l.useState)(!1),a=typeof e.text==`string`?e.text:``,o=[...a],s=o.length>$r,c=r||!s?a:o.slice(0,$r).join(``)+`…`;return(0,I.jsxs)(`div`,{className:`border border-border bg-panel rounded-[var(--radius-panel)]`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-2 text-[11px] text-fg-faint`,children:[n&&(0,I.jsx)(`a`,{href:g({name:`session`,id:e.session_id,at:e.ts}),className:`link`,title:`Open the session at this moment`,children:(0,I.jsx)(`span`,{className:`text-fg-muted`,children:e.project||E(e.session_id)})}),(0,I.jsx)(`span`,{className:`mono`,children:e.model||`assistant`}),e.fragment&&(0,I.jsx)(`span`,{className:`text-fg-faint`,children:`· mid-thought`}),(0,I.jsx)(`span`,{className:`num ml-auto`,children:T(e.ts,t)})]}),(0,I.jsx)(`div`,{className:`px-3 py-2 text-[13px] leading-[1.55] whitespace-pre-wrap break-words`,children:c}),s&&(0,I.jsx)(`button`,{className:`text-[11px] text-fg-muted hover:text-fg px-3 pb-2`,onClick:()=>i(e=>!e),children:r?`show less`:`show all ${o.length.toLocaleString()} characters`})]})}var ti=Object.defineProperty,ni=Object.getOwnPropertyDescriptor,ri=(e,t)=>{for(var n in t)ti(e,n,{get:t[n],enumerable:!0})},ii=(e,t,n,r)=>{for(var i=r>1?void 0:r?ni(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&&ti(t,n,i),i},z=(e,t)=>(n,r)=>t(n,r,e),ai=`Terminal input`,oi={get:()=>ai,set:e=>ai=e},si=`Too much output to announce, navigate to rows manually to read`,ci={get:()=>si,set:e=>si=e};function li(e){return e.replace(/\r?\n/g,`\r`)}function ui(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function di(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function fi(e,t,n,r){e.stopPropagation(),e.clipboardData&&pi(e.clipboardData.getData(`text/plain`),t,n,r)}function pi(e,t,n,r){e=li(e),e=ui(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function mi(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 hi(e,t,n,r,i){mi(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function gi(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _i(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 vi=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);continue}i!==65279&&(t[r++]=i)}return r}},yi=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){d--;continue}if(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}},bi=``,xi=` `,Si=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ci}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}},Ci=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}},wi=class e extends Si{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ci,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?gi(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()]}},Ti=`di$target`,Ei=`di$dependencies`,Di=new Map;function Oi(e){return e[Ei]||[]}function ki(e){if(Di.has(e))return Di.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ai(t,e,r)};return t._id=e,Di.set(e,t),t}function Ai(e,t,n){t[Ti]===t?t[Ei].push({id:e,index:n}):(t[Ei]=[{id:e,index:n}],t[Ti]=t)}var ji=ki(`BufferService`),Mi=ki(`CoreMouseService`),Ni=ki(`CoreService`),B=ki(`CharsetService`),Pi=ki(`InstantiationService`),Fi=ki(`LogService`),Ii=ki(`OptionsService`),Li=ki(`OscLinkService`),Ri=ki(`UnicodeService`),zi=ki(`DecorationService`),Bi=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 wi,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;ti?i.activate(e,t,a):Vi(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)}};Bi=ii([z(0,ji),z(1,Ii),z(2,Li)],Bi);function Vi(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 Hi=ki(`CharSizeService`),Ui=ki(`CoreBrowserService`),Wi=ki(`MouseService`),Gi=ki(`RenderService`),Ki=ki(`SelectionService`),qi=ki(`CharacterJoinerService`),Ji=ki(`ThemeService`),Yi=ki(`LinkProviderService`),Xi=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?na.isErrorNoTelemetry(e)?new na(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 Zi(e){$i(e)||Xi.onUnexpectedError(e)}var Qi=`Canceled`;function $i(e){return e instanceof ea||e instanceof Error&&e.name===Qi&&e.message===Qi}var ea=class extends Error{constructor(){super(Qi),this.name=this.message}};function ta(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var na=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`}},ra=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function ia(e,t=0){return e[e.length-(1+t)]}var aa;(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})(aa||={});var oa=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||aa.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};oa.empty=new oa(e=>{});function sa(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 ca;(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 ha(...e){return ga(()=>ma(e))}function ga(e){let t=ua({dispose:sa(()=>{da(t),e()})});return t}var _a=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,ua(this)}dispose(){this._isDisposed||(da(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ma(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return fa(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),fa(e,null))}};_a.DISABLE_DISPOSED_WARNING=!1;var va=_a,V=class{constructor(){this._store=new va,ua(this),fa(this._store,this)}dispose(){da(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};V.None=Object.freeze({dispose(){}});var ya=class{constructor(){this._isDisposed=!1,ua(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&fa(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,da(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&fa(e,null),e}},ba=typeof window==`object`?window:globalThis,xa=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};xa.Undefined=new xa(void 0);var Sa=xa,Ca=class{constructor(){this._first=Sa.Undefined,this._last=Sa.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Sa.Undefined}clear(){let e=this._first;for(;e!==Sa.Undefined;){let t=e.next;e.prev=Sa.Undefined,e.next=Sa.Undefined,e=t}this._first=Sa.Undefined,this._last=Sa.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Sa(e);if(this._first===Sa.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!==Sa.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Sa.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Sa.Undefined&&e.next!==Sa.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Sa.Undefined&&e.next===Sa.Undefined?(this._first=Sa.Undefined,this._last=Sa.Undefined):e.next===Sa.Undefined?(this._last=this._last.prev,this._last.next=Sa.Undefined):e.prev===Sa.Undefined&&(this._first=this._first.next,this._first.prev=Sa.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==Sa.Undefined;)yield e.element,e=e.next}},wa=globalThis.performance&&typeof globalThis.performance.now==`function`,Ta=class e{static create(t){return new e(t)}constructor(e){this._now=wa&&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}},Ea;(e=>{e.None=()=>V.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(ha(...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 H({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 H({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 H({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 H({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 H({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 H;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{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 H(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 ee(e,t){return new T(e,t).emitter.event}e.fromObservable=ee;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 va?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(Ea||={});var Da=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 Ta,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}}};Da.all=new Set,Da._idPool=0;var Oa=Da,ka=-1,Aa=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 ja(e?.onListenerError??Zi,this._options?.leakWarningThreshold??ka):void 0,this._perfMon=this._options?._profName?new Oa(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 Pa(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Zi)(n),V.None}if(this._disposed)return V.None;t&&(e=e.bind(t));let r=new Ia(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Ma.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Ia?(this._deliveryQueue??=new za,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=ga(()=>{Ra?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof va?n.add(a):Array.isArray(n)&&n.push(a),Ra){let e=Error().stack.split(` -`).slice(2,3).join(` -`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Ra.register(a,t?.[2]??e,a)}return 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*La<=t.length){let e=0;for(let n=0;n0}},za=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}},Ba=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new H,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new H,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}};Ba.INSTANCE=new Ba;var Va=Ba;function Ha(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Va.INSTANCE.onDidChangeZoomLevel;function Ua(e){return Va.INSTANCE.getZoomFactor(e)}Va.INSTANCE.onDidChangeFullscreen;var Wa=typeof navigator==`object`?navigator.userAgent:``,Ga=Wa.indexOf(`Firefox`)>=0,Ka=Wa.indexOf(`AppleWebKit`)>=0,qa=Wa.indexOf(`Chrome`)>=0,Ja=!qa&&Wa.indexOf(`Safari`)>=0;Wa.indexOf(`Electron/`),Wa.indexOf(`Android`);var Ya=!1;if(typeof ba.matchMedia==`function`){let e=ba.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=ba.matchMedia(`(display-mode: fullscreen)`);Ya=e.matches,Ha(ba,e,({matches:e})=>{Ya&&t.matches||(Ya=e)})}function Xa(){return Ya}var Za=`en`,Qa=!1,$a=!1,eo=!1,to=!1,no=!1,ro=Za,io,ao=globalThis,oo;typeof ao.vscode<`u`&&typeof ao.vscode.process<`u`?oo=ao.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(oo=process);var so=typeof oo?.versions?.electron==`string`&&oo?.type===`renderer`;if(typeof oo==`object`){Qa=oo.platform===`win32`,$a=oo.platform===`darwin`,eo=oo.platform===`linux`,eo&&oo.env.SNAP&&oo.env.SNAP_REVISION,oo.env.CI||oo.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ro=Za;let e=oo.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,ro=t.resolvedLanguage||Za,t.languagePack?.translationsConfigFile}catch{}to=!0}else typeof navigator==`object`&&!so?(io=navigator.userAgent,Qa=io.indexOf(`Windows`)>=0,$a=io.indexOf(`Macintosh`)>=0,(io.indexOf(`Macintosh`)>=0||io.indexOf(`iPad`)>=0||io.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,eo=io.indexOf(`Linux`)>=0,io?.indexOf(`Mobi`),no=!0,ro=globalThis._VSCODE_NLS_LANGUAGE||Za,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var co=Qa,lo=$a,U=eo,uo=to;no&&typeof ao.importScripts==`function`&&ao.origin;var fo=io,po=ro,mo;(e=>{function t(){return po}e.value=t;function n(){return po.length===2?po===`en`:po.length>=3&&po[0]===`e`&&po[1]===`n`&&po[2]===`-`}e.isDefaultVariant=n;function r(){return po===`en`}e.isDefault=r})(mo||={});var ho=typeof ao.postMessage==`function`&&!ao.importScripts;(()=>{if(ho){let e=[];ao.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}),ao.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var go=!!(fo&&fo.indexOf(`Chrome`)>=0);fo&&fo.indexOf(`Firefox`),!go&&fo&&fo.indexOf(`Safari`),fo&&fo.indexOf(`Edg/`),fo&&fo.indexOf(`Android`);var _o=typeof navigator==`object`?navigator:{};uo||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||_o&&_o.clipboard&&_o.clipboard.writeText,uo||_o&&_o.clipboard&&_o.clipboard.readText,uo||Xa()||_o.keyboard,`ontouchstart`in ba||_o.maxTouchPoints,ba.PointerEvent&&(`ontouchstart`in ba||navigator.maxTouchPoints);var vo=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}},yo=new vo,bo=new vo,xo=new vo,So=Array(230),Co;(e=>{function t(e){return yo.keyCodeToStr(e)}e.toString=t;function n(e){return yo.strToKeyCode(e)}e.fromString=n;function r(e){return bo.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return xo.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return bo.strToKeyCode(e)||xo.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 yo.keyCodeToStr(e)}e.toElectronAccelerator=o})(Co||={});var wo=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 To([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},To=class{constructor(e){if(e.length===0)throw ta(`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 zo?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ea.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Lo})})(Ro||={});var zo=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?Lo:(this._emitter||=new H,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Bo=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 ra(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ra(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Vo=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 ra(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=ga(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Ho;(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})(Ho||={});var Uo=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 H,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())}};Uo.EMPTY=Uo.fromArray([]);function Wo(e){return Go(e,0)}function Go(e,t){switch(typeof e){case`object`:return e===null?Ko(349,t):Array.isArray(e)?Yo(e,t):Xo(e,t);case`string`:return Jo(e,t);case`boolean`:return qo(e,t);case`number`:return Ko(e,t);case`undefined`:return Ko(937,t);default:return Ko(617,t)}}function Ko(e,t){return(t<<5)-t+e|0}function qo(e,t){return Ko(e?433:863,t)}function Jo(e,t){t=Ko(149417,t);for(let n=0,r=e.length;nGo(t,e),t)}function Xo(e,t){return t=Ko(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Jo(n,t),Go(e[n],t)),t)}var{registerWindow:Zo,getWindow:Qo,getDocument:$o,getWindows:es,getWindowsCount:ts,getWindowId:ns,getWindowById:rs,hasWindow:is,onDidRegisterWindow:as,onWillUnregisterWindow:os,onDidUnregisterWindow:ss}=function(){let e=new Map,t={window:ba,disposables:new va};e.set(ba.vscodeWindowId,t);let n=new H,r=new H,i=new H;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 V.None;let a=new va,o={window:t,disposables:a.add(new va)};return e.set(t.vscodeWindowId,o),a.add(ga(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(W(t,_s.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:ba},getDocument(e){return Qo(e).document}}}(),cs=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 W(e,t,n,r){return new cs(e,t,n,r)}function ls(e,t){return function(n){return t(new Fo(e,n))}}function us(e){return function(t){return e(new jo(t))}}var ds=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=ls(Qo(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=us(n)),W(e,t,i,r)},fs,ps=class extends Vo{constructor(e){super(),this.defaultTarget=e&&Qo(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},ms=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){Zi(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(ms.sort),a.shift().execute();r.set(i,!1)};fs=(t,r,a=0)=>{let o=ns(t),s=new ms(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 hs=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}};hs.None=new hs(0,0);function gs(e){let t=e.getBoundingClientRect(),n=Qo(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=Wo(n),a=r.get(i);if(a)a.users+=1;else{let o=new H,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(ga(()=>{--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 _s={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:Ka?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Ka?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Ka?`webkitAnimationIteration`:`animationiteration`},vs=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=ys(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ys(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ys(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ys(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ys(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ys(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ys(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ys(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ys(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ys(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ys(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=ys(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=ys(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ys(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 ys(e){return typeof e==`number`?`${e}px`:e}function bs(e){return new vs(e)}var xs=class{constructor(){this._hooks=new va,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(ga(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Qo(e)}this._hooks.add(W(a,_s.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(W(a,_s.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Ss(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 Cs;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Cs||={});var ws=class e extends V{constructor(){super(),this.dispatched=!1,this.targets=new Ca,this.ignoreTargets=new Ca,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ea.runAndSubscribe(as,({window:e,disposables:t})=>{t.add(W(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(W(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(W(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:ba,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=pa(new e),ga(e.INSTANCE.targets.push(t))):V.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=pa(new e),ga(e.INSTANCE.ignoreTargets.push(t))):V.None}static isTouchDevice(){return`ontouchstart`in ba||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-ia(s.rollingPageX))<30&&Math.abs(s.initialPageY-ia(s.rollingPageY))<30){let e=this.newGestureEvent(Cs.Contextmenu,s.initialTarget);e.pageX=ia(s.rollingPageX),e.pageY=ia(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=ia(s.rollingPageX),n=ia(s.rollingPageY),i=ia(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(Cs.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===Cs.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===Cs.Change||t.type===Cs.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=fs(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(Cs.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)}};ws.SCROLL_FRICTION=-.005,ws.HOLD_DELAY=700,ws.CLEAR_TAP_COUNT_TIME=400,ii([Ss],ws,`isTouchDevice`,1);var Ts=ws,Es=class extends V{onclick(e,t){this._register(W(e,_s.CLICK,n=>t(new Fo(Qo(e),n))))}onmousedown(e,t){this._register(W(e,_s.MOUSE_DOWN,n=>t(new Fo(Qo(e),n))))}onmouseover(e,t){this._register(W(e,_s.MOUSE_OVER,n=>t(new Fo(Qo(e),n))))}onmouseleave(e,t){this._register(W(e,_s.MOUSE_LEAVE,n=>t(new Fo(Qo(e),n))))}onkeydown(e,t){this._register(W(e,_s.KEY_DOWN,e=>t(new jo(e))))}onkeyup(e,t){this._register(W(e,_s.KEY_UP,e=>t(new jo(e))))}oninput(e,t){this._register(W(e,_s.INPUT,t))}onblur(e,t){this._register(W(e,_s.BLUR,t))}onfocus(e,t){this._register(W(e,_s.FOCUS,t))}onchange(e,t){this._register(W(e,_s.CHANGE,t))}ignoreGesture(e){return Ts.ignoreTarget(e)}},Ds=11,Os=class extends Es{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=Ds+`px`,this.domNode.style.height=Ds+`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 xs),this._register(ds(this.bgDomNode,_s.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(ds(this.domNode,_s.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new ps),this._pointerdownScheduleRepeatTimer=this._register(new Bo)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Qo(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},ks=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}}},As=class extends V{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new H),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new ks(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 Ps(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=Ps.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)))}},js=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Ms(e,t){let n=t-e;return function(t){return e+n*Is(t)}}function Ns(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`:``)))}},Rs=140,zs=class extends Es{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 Ls(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new xs),this._shouldRender=!0,this.domNode=bs(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(W(this.domNode.domNode,_s.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Os(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=bs(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(W(this.slider.domNode,_s.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=gs(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(co&&a>Rs){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()}},Bs=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}};qs.INSTANCE=new qs;var Js=qs,Ys=class extends Es{constructor(e,t,n){super(),this._onScroll=this._register(new H),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new H),this.onWillScroll=this._onWillScroll.event,this._options=Zs(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 Hs(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new Vs(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=bs(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=bs(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=bs(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 Bo),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ma(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,lo&&(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 Io(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ma(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(W(this._listenOnDomNode,_s.MOUSE_WHEEL,e=>{this._onMouseWheel(new Io(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=Js.INSTANCE;Gs&&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=!lo&&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=Ws*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=Ws*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)&&(Gs&&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(),Us)}},Xs=class extends Ys{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 Zs(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,lo&&(t.className+=` mac`),t}var Qs=class extends V{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new H),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new As({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>fs(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Xs(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(Ea.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ga(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(ga(()=>this._styleElement.remove())),this._register(Ea.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}};Qs=ii([z(2,ji),z(3,Ui),z(4,Mi),z(5,Ji),z(6,Ii),z(7,Gi)],Qs);var $s=class extends V{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(ga(()=>{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()}};$s=ii([z(1,ji),z(2,Ui),z(3,zi),z(4,Gi)],$s);var ec=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)}},tc={full:0,left:0,center:0,right:0},nc={full:0,left:0,center:0,right:0},rc={full:0,left:0,center:0,right:0},ic=class extends V{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 ec,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(ga(()=>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);nc.full=this._canvas.width,nc.left=e,nc.center=t,nc.right=e,this._refreshDrawHeightConstants(),rc.full=1,rc.left=1,rc.center=1+nc.left,rc.right=1+nc.left+nc.center}_refreshDrawHeightConstants(){tc.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);tc.left=t,tc.center=t,tc.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*tc.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*tc.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*tc.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*tc.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(rc[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-tc[e.position||`full`]/2),nc[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+tc[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}))}};ic=ii([z(2,ji),z(3,zi),z(4,Gi),z(5,Ii),z(6,Ji),z(7,Ui)],ic);var G;(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=``))(G||={});var ac;(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=`Ÿ`))(ac||={});var oc;(e=>e.ST=`${G.ESC}\\`)(oc||={});var sc=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)}}};sc=ii([z(2,ji),z(3,Ii),z(4,Ni),z(5,Gi)],sc);var cc=0,lc=0,uc=0,dc=0,fc={css:`#00000000`,rgba:0},pc;(e=>{function t(e,t,n,r){return r===void 0?`#${vc(e)}${vc(t)}${vc(n)}`:`#${vc(e)}${vc(t)}${vc(n)}${vc(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})(pc||={});var mc;(e=>{function t(e,t){if(dc=(t.rgba&255)/255,dc===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 cc=a+Math.round((n-a)*dc),lc=o+Math.round((r-o)*dc),uc=s+Math.round((i-s)*dc),{css:pc.toCss(cc,lc,uc),rgba:pc.toRgba(cc,lc,uc)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=_c.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return pc.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[cc,lc,uc]=_c.toChannels(t),{css:pc.toCss(cc,lc,uc),rgba:t}}e.opaque=i;function a(e,t){return dc=Math.round(t*255),[cc,lc,uc]=_c.toChannels(e.rgba),{css:pc.toCss(cc,lc,uc,dc),rgba:pc.toRgba(cc,lc,uc,dc)}}e.opacity=a;function o(e,t){return dc=e.rgba&255,a(e,dc*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(mc||={});var hc;(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 cc=parseInt(e.slice(1,2).repeat(2),16),lc=parseInt(e.slice(2,3).repeat(2),16),uc=parseInt(e.slice(3,4).repeat(2),16),pc.toColor(cc,lc,uc);case 5:return cc=parseInt(e.slice(1,2).repeat(2),16),lc=parseInt(e.slice(2,3).repeat(2),16),uc=parseInt(e.slice(3,4).repeat(2),16),dc=parseInt(e.slice(4,5).repeat(2),16),pc.toColor(cc,lc,uc,dc);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 cc=parseInt(r[1]),lc=parseInt(r[2]),uc=parseInt(r[3]),dc=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),pc.toColor(cc,lc,uc,dc);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[cc,lc,uc,dc]=t.getImageData(0,0,1,1).data,dc!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:pc.toRgba(cc,lc,uc,dc),css:e}}e.toColor=r})(hc||={});var gc;(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})(gc||={});var _c;(e=>{function t(e,t){if(dc=(t&255)/255,dc===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 cc=a+Math.round((n-a)*dc),lc=o+Math.round((r-o)*dc),uc=s+Math.round((i-s)*dc),pc.toRgba(cc,lc,uc)}e.blend=t;function n(e,t,n){let a=gc.relativeLuminance(e>>8),o=gc.relativeLuminance(t>>8);if(yc(a,o)>8));if(syc(a,gc.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=yc(a,gc.relativeLuminance(s>>8));if(cyc(a,gc.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=yc(gc.relativeLuminance2(o,s,c),gc.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=yc(gc.relativeLuminance2(o,s,c),gc.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=yc(gc.relativeLuminance2(o,s,c),gc.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})(_c||={});function vc(e){let t=e.toString(16);return t.length<2?`0`+t:t}function yc(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=ee,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 bc(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),ie=r[1]-1,m=O.getWidth()):ee=r[1]}let k=this._isCellInSelection(D,t),A=n&&D===a,j=te&&D>=l&&D<=u,M=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{M=!0});let ae=O.getChars()||xi;if(ae===` `&&(O.isUnderline()||O.isOverline())&&(ae=`\xA0`),T=m*s-c.get(ae,O.isBold(),O.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(k&&w||!k&&!w&&O.bg===y)&&(k&&w&&p.selectionForeground||O.fg===b)&&O.extended.ext===x&&j===S&&T===C&&!A&&!ne&&!M&&re){O.isInvisible()?_+=xi:_+=ae,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=j,C=T,w=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`);break;default:break}}if(O.isBold()&&E.push(`xterm-bold`),O.isItalic()&&E.push(`xterm-italic`),O.isDim()&&E.push(`xterm-dim`),_=O.isInvisible()?xi:O.getChars()||xi,O.isUnderline()&&(E.push(`xterm-underline-${O.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!O.isUnderlineColorDefault())){if(O.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${Si.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`),j&&(h.style.textDecoration=`underline`);let N=O.getFgColor(),P=O.getFgColorMode(),oe=O.getBgColor(),se=O.getBgColorMode(),ce=!!O.isInverse();if(ce){let e=N;N=oe,oe=e;let t=P;P=se,se=t}let le,ue,de=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{e.options.layer!==`top`&&de||(e.backgroundColorRGB&&(se=50331648,oe=e.backgroundColorRGB.rgba>>8&16777215,le=e.backgroundColorRGB),e.foregroundColorRGB&&(P=50331648,N=e.foregroundColorRGB.rgba>>8&16777215,ue=e.foregroundColorRGB),de=e.options.layer===`top`)}),!de&&k&&(le=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,oe=le.rgba>>8&16777215,se=50331648,de=!0,p.selectionForeground&&(P=50331648,N=p.selectionForeground.rgba>>8&16777215,ue=p.selectionForeground)),de&&E.push(`xterm-decoration-top`);let fe;switch(se){case 16777216:case 33554432:fe=p.ansi[oe],E.push(`xterm-bg-${oe}`);break;case 50331648:fe=pc.toColor(oe>>16,oe>>8&255,oe&255),this._addStyle(h,`background-color:#${Oc((oe>>>0).toString(16),`0`,6)}`);break;default:ce?(fe=p.foreground,E.push(`xterm-bg-257`)):fe=p.background}switch(le||O.isDim()&&(le=mc.multiplyOpacity(fe,.5)),P){case 16777216:case 33554432:O.isBold()&&N<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(N+=8),this._applyMinimumContrast(h,fe,p.ansi[N],O,le,void 0)||E.push(`xterm-fg-${N}`);break;case 50331648:let e=pc.toColor(N>>16&255,N>>8&255,N&255);this._applyMinimumContrast(h,fe,e,O,le,ue)||this._addStyle(h,`color:#${Oc(N.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,fe,p.foreground,O,le,ue)||ce&&E.push(`xterm-fg-257`)}E.length&&=(h.className=E.join(` `),0),!A&&!ne&&!M&&re?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}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||wc(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=mc.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]}};Dc=ii([z(1,qi),z(2,Ii),z(3,Ui),z(4,Ni),z(5,zi),z(6,Ji)],Dc);function Oc(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}},Ac=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);if(s>=e.rows||c<0){this.clear();return}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 jc(){return new Ac}var Mc=`xterm-dom-renderer-owner-`,Nc=`xterm-rows`,Pc=`xterm-fg-`,Fc=`xterm-bg-`,Ic=`xterm-focus`,Lc=`xterm-selection`,Rc=1,zc=class extends V{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=Rc++,this._rowElements=[],this._selectionRenderModel=jc(),this.onRequestRedraw=this._register(new H).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Nc),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(Lc),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Tc(),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(Dc,document),this._element.classList.add(Mc+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(ga(()=>{this._element.classList.remove(Mc+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new kc(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} .${Nc} 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} .${Nc} { 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} .${Nc} .xterm-dim { color: ${mc.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} .${Nc}.${Ic} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Nc}.${Ic} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Nc}.${Ic} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Nc} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Nc} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Nc} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Nc} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Nc} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Lc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Lc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Lc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Pc}${n} { color: ${r.css}; }${this._terminalSelector} .${Pc}${n}.xterm-dim { color: ${mc.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Fc}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Pc}257 { color: ${mc.opaque(e.background).css}; }${this._terminalSelector} .${Pc}257.xterm-dim { color: ${mc.multiplyOpacity(mc.opaque(e.background),.5).css}; }${this._terminalSelector} .${Fc}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(Ic),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ic),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`.${Mc}${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))}}};zc=ii([z(7,Pi),z(8,Hi),z(9,Ii),z(10,ji),z(11,Ni),z(12,Ui),z(13,Ji)],zc);var Bc=class extends V{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new H),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Uc(this._optionsService))}catch{this._measureStrategy=this._register(new Hc(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())}};Bc=ii([z(2,Ii)],Bc);var Vc=class extends V{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)}},Hc=class extends Vc{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}},Uc=class extends Vc{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}},Wc=class extends V{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 Gc(this._window)),this._onDprChange=this._register(new H),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new H),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(Ea.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(W(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(W(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}},Gc=class extends V{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ya),this._onDprChange=this._register(new H),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ga(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=W(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)}},Kc=class extends V{constructor(){super(),this.linkProviders=[],this._register(ga(()=>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 qc(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 Jc(e,t,n,r,i,a,o,s,c){if(!a)return;let l=qc(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 Yc=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Jc(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=qc(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])}}};Yc=ii([z(0,Gi),z(1,Hi)],Yc);var Xc=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=[]}},Zc={};ri(Zc,{getSafariVersion:()=>il,isChromeOS:()=>ul,isFirefox:()=>tl,isIpad:()=>ol,isIphone:()=>sl,isLegacyEdge:()=>nl,isLinux:()=>ll,isMac:()=>al,isNode:()=>Qc,isSafari:()=>rl,isWindows:()=>cl});var Qc=typeof process<`u`&&`title`in process,$c=Qc?`node`:navigator.userAgent,el=Qc?`node`:navigator.platform,tl=$c.includes(`Firefox`),nl=$c.includes(`Edge`),rl=/^((?!chrome|android).)*safari/i.test($c);function il(){if(!rl)return 0;let e=$c.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var al=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(el),ol=el===`iPad`,sl=el===`iPhone`,cl=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(el),ll=el.indexOf(`Linux`)>=0,ul=/\bCrOS\b/.test($c),dl=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()}},fl=class extends dl{_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())}}},pl=class extends dl{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ml=!Qc&&`requestIdleCallback`in window?pl:fl,hl=class{constructor(){this._queue=new ml}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},gl=class extends V{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 ya),this._pausedResizeTask=new hl,this._observerDisposable=this._register(new ya),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 H),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new H),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new H),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new H),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Xc((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new _l(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ga(()=>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=ga(()=>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()}};gl=ii([z(2,Ii),z(3,Hi),z(4,Ni),z(5,zi),z(6,ji),z(7,Ui),z(8,Ji)],gl);var _l=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 vl(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return xl(i,a,e,t,n,r)+Sl(a,t,n,r)+Cl(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,Al(Math.abs(i-e),kl(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return Al(bl(a>t?e:i,n)+(s-1)*n.cols+1+yl(a>t?i:e,n),kl(o,r))}function yl(e,t){return e-1}function bl(e,t){return t.cols-e}function xl(e,t,n,r,i,a){return Sl(t,r,i,a).length===0?``:Al(Ol(e,t,e,t-Tl(t,i),!1,i).length,kl(`D`,a))}function Sl(e,t,n,r){let i=e-Tl(e,n),a=t-Tl(t,n);return Al(Math.abs(i-a)-wl(e,t,n),kl(Dl(e,t),r))}function Cl(e,t,n,r,i,a){let o;o=Sl(t,r,i,a).length>0?r-Tl(r,i):t;let s=r,c=El(e,t,n,r,i,a);return Al(Ol(e,o,n,s,c===`C`,i).length,kl(c,a))}function wl(e,t,n){let r=0,i=e-Tl(e,n),a=t-Tl(t,n);for(let o=0;o=0&&e0?r-Tl(r,i):t,e=n&&ot?`A`:`B`}function Ol(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 kl(e,t){let n=t?`O`:`[`;return G.ESC+n+e}function Al(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 Ml(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 Nl=50,Pl=15,Fl=50,Il=500,Ll=RegExp(`\xA0`,`g`),Rl=class extends V{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 wi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new H),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new H),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new H),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new H),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 jl(this._bufferService),this._activeSelectionMode=0,this._register(ga(()=>{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(Ll,` `)).join(cl?`\r -`:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),ll&&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=Ml(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=qc(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,-Nl),Nl),t/=Nl,t/Math.abs(t)+Math.round(t*(Pl-1)))}shouldForceSelection(e){return al?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(),Fl)}_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&&!(al&&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=Ml(n,this._bufferService.cols)}};Rl=ii([z(3,ji),z(4,Ni),z(5,Wi),z(6,Ii),z(7,Gi),z(8,Ui)],Rl);var K=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={}}},zl=class{constructor(){this._color=new K,this._css=new K}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()}},q=Object.freeze((()=>{let e=[hc.toColor(`#2e3436`),hc.toColor(`#cc0000`),hc.toColor(`#4e9a06`),hc.toColor(`#c4a000`),hc.toColor(`#3465a4`),hc.toColor(`#75507b`),hc.toColor(`#06989a`),hc.toColor(`#d3d7cf`),hc.toColor(`#555753`),hc.toColor(`#ef2929`),hc.toColor(`#8ae234`),hc.toColor(`#fce94f`),hc.toColor(`#729fcf`),hc.toColor(`#ad7fa8`),hc.toColor(`#34e2e2`),hc.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:pc.toCss(r,i,a),rgba:pc.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:pc.toCss(n,n,n),rgba:pc.toRgba(n,n,n)})}return e})()),J=hc.toColor(`#ffffff`),Y=hc.toColor(`#000000`),Bl=hc.toColor(`#ffffff`),Vl=Y,Hl={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},Ul=J,Wl=class extends V{constructor(e){super(),this._optionsService=e,this._contrastCache=new zl,this._halfContrastCache=new zl,this._onChangeColors=this._register(new H),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:J,background:Y,cursor:Bl,cursorAccent:Vl,selectionForeground:void 0,selectionBackgroundTransparent:Hl,selectionBackgroundOpaque:mc.blend(Y,Hl),selectionInactiveBackgroundTransparent:Hl,selectionInactiveBackgroundOpaque:mc.blend(Y,Hl),scrollbarSliderBackground:mc.opacity(J,.2),scrollbarSliderHoverBackground:mc.opacity(J,.4),scrollbarSliderActiveBackground:mc.opacity(J,.5),overviewRulerBorder:J,ansi:q.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=X(e.foreground,J),t.background=X(e.background,Y),t.cursor=mc.blend(t.background,X(e.cursor,Bl)),t.cursorAccent=mc.blend(t.background,X(e.cursorAccent,Vl)),t.selectionBackgroundTransparent=X(e.selectionBackground,Hl),t.selectionBackgroundOpaque=mc.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=X(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=mc.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?X(e.selectionForeground,fc):void 0,t.selectionForeground===fc&&(t.selectionForeground=void 0),mc.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=mc.opacity(t.selectionBackgroundTransparent,.3)),mc.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=mc.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=X(e.scrollbarSliderBackground,mc.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=X(e.scrollbarSliderHoverBackground,mc.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=X(e.scrollbarSliderActiveBackground,mc.opacity(t.foreground,.5)),t.overviewRulerBorder=X(e.overviewRulerBorder,Ul),t.ansi=q.slice(),t.ansi[0]=X(e.black,q[0]),t.ansi[1]=X(e.red,q[1]),t.ansi[2]=X(e.green,q[2]),t.ansi[3]=X(e.yellow,q[3]),t.ansi[4]=X(e.blue,q[4]),t.ansi[5]=X(e.magenta,q[5]),t.ansi[6]=X(e.cyan,q[6]),t.ansi[7]=X(e.white,q[7]),t.ansi[8]=X(e.brightBlack,q[8]),t.ansi[9]=X(e.brightRed,q[9]),t.ansi[10]=X(e.brightGreen,q[10]),t.ansi[11]=X(e.brightYellow,q[11]),t.ansi[12]=X(e.brightBlue,q[12]),t.ansi[13]=X(e.brightMagenta,q[13]),t.ansi[14]=X(e.brightCyan,q[14]),t.ansi[15]=X(e.brightWhite,q[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)}},ql={trace:0,debug:1,info:2,warn:3,error:4,off:5},Jl=`xterm.js: `,Yl=class extends V{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Xl=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=ql[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*Z+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*Z+0]=e|2097152|t[2]<<22):this._data[e*Z+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*Z+0]>>22}hasWidth(e){return this._data[e*Z+0]&12582912}getFg(e){return this._data[e*Z+1]}getBg(e){return this._data[e*Z+2]}hasContent(e){return this._data[e*Z+0]&4194303}getCodePoint(e){let t=this._data[e*Z+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*Z+0]&2097152}getString(e){let t=this._data[e*Z+0];return t&2097152?this._combined[e]:t&2097151?gi(t&2097151):``}isProtected(e){return this._data[e*Z+2]&536870912}loadCell(e,t){return $l=e*Z,t.content=this._data[$l+0],t.fg=this._data[$l+1],t.bg=this._data[$l+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*Z+0]=t.content,this._data[e*Z+1]=t.fg,this._data[e*Z+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Z+0]=t|n<<22,this._data[e*Z+1]=r.fg,this._data[e*Z+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*Z+0];r&2097152?this._combined[e]+=gi(t):r&2097151?(this._combined[e]=gi(r&2097151)+gi(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*Z+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*eu=0;--e)if(this._data[e*Z+0]&4194303)return e+(this._data[e*Z+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Z+0]&4194303||this._data[e*Z+2]&50331648)return e+(this._data[e*Z+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 nu(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 ru(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;oou(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 ou(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 su=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new H),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ma(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};su._nextId=1;var cu=su,lu={},uu=lu.B;lu[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},lu.A={"#":`£`},lu.B=void 0,lu[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},lu.C=lu[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},lu.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},lu.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},lu.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},lu.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},lu.E=lu[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},lu.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},lu.H=lu[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},lu[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var du=4294967295,fu=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=Ql.clone(),this.savedCharset=uu,this.markers=[],this._nullCell=wi.fromCharData([0,bi,1,0]),this._whitespaceCell=wi.fromCharData([0,xi,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ml,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Zl(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 Ci),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 Ci),this._whitespaceCell}getBlankLine(e,t){return new tu(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&&edu?du:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ql);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 Zl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ql),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 tu(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=nu(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ql),n);if(r.length>0){let n=ru(this.lines,r);iu(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Ql),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--,_=ou(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)}},pu=class extends V{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new H),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 fu(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new fu(!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)}},mu=2,hu=1,gu=class extends V{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new H),this.onResize=this._onResize.event,this._onScroll=this._register(new H),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,mu),this.rows=Math.max(e.rawOptions.rows||0,hu),this.buffers=this._register(new pu(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))}};gu=ii([z(0,Ii)],gu);var _u={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:al,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},vu=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],yu=class extends V{constructor(e){super(),this._onOptionChange=this._register(new H),this.onOptionChange=this._onOptionChange.event;let t={..._u};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(ga(()=>{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 _u))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in _u))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||=_u[e],!bu(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=_u[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=vu.includes(t)?t:_u[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 bu(e){return e===`block`||e===`underline`||e===`bar`}function xu(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]&&xu(e[r],t-1);return n}var Su=Object.freeze({insertMode:!1}),Cu=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),wu=class extends V{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 H),this.onData=this._onData.event,this._onUserInput=this._register(new H),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new H),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new H),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=xu(Su),this.decPrivateModes=xu(Cu)}reset(){this.modes=xu(Su),this.decPrivateModes=xu(Cu)}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))}};wu=ii([z(0,ji),z(1,Fi),z(2,Ii)],wu);var Tu={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 Eu(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 Du=String.fromCharCode,Ou={DEFAULT:e=>{let t=[Eu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${Du(t[0])}${Du(t[1])}${Du(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Eu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Eu(e,!0)};${e.x};${e.y}${t}`}},ku=class extends V{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 H),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(Tu))this.addProtocol(e,Tu[e]);for(let e of Object.keys(Ou))this.addEncoding(e,Ou[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}};ku=ii([z(0,ji),z(1,Ni),z(2,Ii)],ku);var Au=[[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]],ju=[[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]],Mu;function Nu(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=Fu.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Fu.createPropertyValue(0,n,r)}},Fu=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new H,this.onChange=this._onChange.event;let e=new Pu;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)}},Iu=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 Lu(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 Ru=2147483647,zu=256,Bu=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>zu)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;return}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>Ru?Ru: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>Ru?Ru: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,Ru):e}},Vu=[],Hu=class{constructor(){this._state=0,this._active=Vu,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=Vu}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=Vu,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Vu,!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`,_i(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=Vu,this._id=-1,this._state=0}}},Uu=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+=_i(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}},Q=[],Wu=class{constructor(){this._handlers=Object.create(null),this._active=Q,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Q}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=Q,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Q,!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`,_i(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=Q,this._ident=0}},Gu=new Bu;Gu.addParam(0);var Ku=class{constructor(e){this._handler=e,this._data=``,this._params=Gu,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Gu,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=_i(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=Gu,this._data=``,this._hitLimit=!1,e));return this._params=Gu,this._data=``,this._hitLimit=!1,t}},qu=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(Ju,0,2,0),e.add(Ju,8,5,8),e.add(Ju,6,0,6),e.add(Ju,11,0,11),e.add(Ju,13,13,13),e}(),Xu=class extends V{constructor(e=Yu){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 Bu,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(ga(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Hu),this._dcsParser=this._register(new Wu),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 ed(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 td(e,t=16){let[n,r,i]=e;return`rgb:${ed(n,t)}/${ed(r,t)}/${ed(i,t)}`}var nd={"(":0,")":1,"*":2,"+":3,"-":1,".":2},rd=131072,id=10;function ad(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 od=5e3,sd=0,cd=class extends V{constructor(e,t,n,r,i,a,o,s,c=new Xu){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 vi,this._utf8Decoder=new yi,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ql.clone(),this._eraseAttrDataInternal=Ql.clone(),this._onRequestBell=this._register(new H),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new H),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new H),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new H),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new H),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new H),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new H),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new H),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new H),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new H),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new H),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new H),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new H),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 ld(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(G.BEL,()=>this.bell()),this._parser.setExecuteHandler(G.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(G.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(G.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(G.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(G.BS,()=>this.backspace()),this._parser.setExecuteHandler(G.HT,()=>this.tab()),this._parser.setExecuteHandler(G.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(G.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ac.IND,()=>this.index()),this._parser.setExecuteHandler(ac.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ac.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Uu(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new Uu(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new Uu(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new Uu(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new Uu(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new Uu(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new Uu(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new Uu(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new Uu(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new Uu(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new Uu(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new Uu(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 lu)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 Ku((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`),od))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${od} 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>rd&&(a=this._parseStack.position+rd)}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.lengthrd)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 tu&&d.copyCellsFrom(e,t,0,m,!1);t=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}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=>!ad(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Ku(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Uu(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(G.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(G.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(G.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(G.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(G.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(`${G.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|=Si.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=Ql.fg,e.bg=Ql.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|=Ql.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Ql.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|=Ql.fg&16777215,r.bg&=-67108864,r.bg|=Ql.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${G.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${G.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(`${G.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=Ql.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(!ad(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(`${G.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>id&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>id&&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(ud(n)){if(r===`?`)t.push({type:0,index:n});else{let e=$u(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=$u(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=Ql.clone(),this._eraseAttrDataInternal=Ql.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 wi;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(`${G.ESC}${e}${G.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)}},ld=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&&(sd=e,e=t,t=sd),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ld=ii([z(0,ji)],ld);function ud(e){return 0<=e&&e<256}var dd=5e7,fd=12,pd=50,md=class extends V{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 H),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>dd)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>=fd?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>=fd)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>pd&&(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()}},hd=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)))}};hd=ii([z(0,ji)],hd);var gd=!1,_d=class extends V{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ya),this._onBinary=this._register(new H),this.onBinary=this._onBinary.event,this._onData=this._register(new H),this.onData=this._onData.event,this._onLineFeed=this._register(new H),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new H),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new H),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new H),this._instantiationService=new Kl,this.optionsService=this._register(new yu(e)),this._instantiationService.setService(Ii,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(gu)),this._instantiationService.setService(ji,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Yl)),this._instantiationService.setService(Fi,this._logService),this.coreService=this._register(this._instantiationService.createInstance(wu)),this._instantiationService.setService(Ni,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ku)),this._instantiationService.setService(Mi,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Fu)),this._instantiationService.setService(Ri,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Iu),this._instantiationService.setService(B,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(hd),this._instantiationService.setService(Li,this._oscLinkService),this._inputHandler=this._register(new cd(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ea.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ea.forward(this._bufferService.onResize,this._onResize)),this._register(Ea.forward(this.coreService.onData,this._onData)),this._register(Ea.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 md((e,t)=>this._inputHandler.parse(e,t))),this._register(Ea.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new H),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&&!gd&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),gd=!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,mu),t=Math.max(t,hu),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(Lu.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(Lu(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ga(()=>{for(let t of e)t.dispose()})}}},vd={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 $(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?G.ESC+`OA`:G.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?G.ESC+`OD`:G.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?G.ESC+`OC`:G.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?G.ESC+`OB`:G.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:G.DEL,e.altKey&&(i.key=G.ESC+i.key);break;case 9:if(e.shiftKey){i.key=G.ESC+`[Z`;break}i.key=G.HT,i.cancel=!0;break;case 13:i.key=e.altKey?G.ESC+G.CR:G.CR,i.cancel=!0;break;case 27:i.key=G.ESC,e.altKey&&(i.key=G.ESC+G.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?G.ESC+`[1;`+(a+1)+`D`:t?G.ESC+`OD`:G.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?G.ESC+`[1;`+(a+1)+`C`:t?G.ESC+`OC`:G.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?G.ESC+`[1;`+(a+1)+`A`:t?G.ESC+`OA`:G.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?G.ESC+`[1;`+(a+1)+`B`:t?G.ESC+`OB`:G.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=G.ESC+`[2~`);break;case 46:i.key=a?G.ESC+`[3;`+(a+1)+`~`:G.ESC+`[3~`;break;case 36:i.key=a?G.ESC+`[1;`+(a+1)+`H`:t?G.ESC+`OH`:G.ESC+`[H`;break;case 35:i.key=a?G.ESC+`[1;`+(a+1)+`F`:t?G.ESC+`OF`:G.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?G.ESC+`[5;`+(a+1)+`~`:G.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?G.ESC+`[6;`+(a+1)+`~`:G.ESC+`[6~`;break;case 112:i.key=a?G.ESC+`[1;`+(a+1)+`P`:G.ESC+`OP`;break;case 113:i.key=a?G.ESC+`[1;`+(a+1)+`Q`:G.ESC+`OQ`;break;case 114:i.key=a?G.ESC+`[1;`+(a+1)+`R`:G.ESC+`OR`;break;case 115:i.key=a?G.ESC+`[1;`+(a+1)+`S`:G.ESC+`OS`;break;case 116:i.key=a?G.ESC+`[15;`+(a+1)+`~`:G.ESC+`[15~`;break;case 117:i.key=a?G.ESC+`[17;`+(a+1)+`~`:G.ESC+`[17~`;break;case 118:i.key=a?G.ESC+`[18;`+(a+1)+`~`:G.ESC+`[18~`;break;case 119:i.key=a?G.ESC+`[19;`+(a+1)+`~`:G.ESC+`[19~`;break;case 120:i.key=a?G.ESC+`[20;`+(a+1)+`~`:G.ESC+`[20~`;break;case 121:i.key=a?G.ESC+`[21;`+(a+1)+`~`:G.ESC+`[21~`;break;case 122:i.key=a?G.ESC+`[23;`+(a+1)+`~`:G.ESC+`[23~`;break;case 123:i.key=a?G.ESC+`[24;`+(a+1)+`~`:G.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=G.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=G.DEL:e.keyCode===219?i.key=G.ESC:e.keyCode===220?i.key=G.FS:e.keyCode===221&&(i.key=G.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=vd[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=G.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=G.ESC+n}else if(e.keyCode===32)i.key=G.ESC+(e.ctrlKey?G.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=G.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=G.US),e.key===`@`&&(i.key=G.NUL))}return i}var yd=0,bd=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ml,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ml,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||(yd=this._search(t),yd===-1)||this._getKey(this._array[yd])!==t)return!1;do if(this._array[yd]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(yd),!0;while(++yde-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&&(yd=this._search(e),!(yd<0||yd>=this._array.length)&&this._getKey(this._array[yd])===e))do yield this._array[yd];while(++yd=this._array.length)&&this._getKey(this._array[yd])===e))do t(this._array[yd]);while(++yd=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}},xd=0,Sd=0,Cd=class extends V{constructor(){super(),this._decorations=new bd(e=>e?.marker.line),this._onDecorationRegistered=this._register(new H),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new H),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ga(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new wd(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{xd=t.options.x??0,Sd=xd+(t.options.width??1),e>=xd&&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)}},Dd=20,Od=class extends V{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 Ed(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(W(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ga(()=>{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===Dd+1&&(this._liveRegion.textContent+=ci.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{ma(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(W(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(W(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(W(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(W(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&&Ad(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,ma(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}}};kd=ii([z(1,Wi),z(2,Gi),z(3,ji),z(4,Yi)],kd);function Ad(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 jd=class extends _d{constructor(e={}){super(e),this._linkifier=this._register(new ya),this.browser=Zc,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ya),this._onCursorMove=this._register(new H),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new H),this.onKey=this._onKey.event,this._onRender=this._register(new H),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new H),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new H),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new H),this.onBell=this._onBell.event,this._onFocus=this._register(new H),this._onBlur=this._register(new H),this._onA11yCharEmitter=this._register(new H),this._onA11yTabEmitter=this._register(new H),this._onWillOpen=this._register(new H),this._setup(),this._decorationService=this._instantiationService.createInstance(Cd),this._instantiationService.setService(zi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Kc),this._instantiationService.setService(Yi,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bi)),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(Ea.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ea.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ea.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ea.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(ga(()=>{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=mc.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${G.ESC}]${n};${td(r)}${oc.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=pc.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=pc.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(Od,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(G.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(G.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(W(this.element,`copy`,e=>{this.hasSelection()&&di(e,this._selectionService)}));let e=e=>fi(e,this.textarea,this.coreService,this.optionsService);this._register(W(this.textarea,`paste`,e)),this._register(W(this.element,`paste`,e)),tl?this._register(W(this.element,`mousedown`,e=>{e.button===2&&hi(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(W(this.element,`contextmenu`,e=>{hi(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),ll&&this._register(W(this.element,`auxclick`,e=>{e.button===1&&mi(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(W(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(W(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(W(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(W(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(W(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(W(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(W(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(W(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`,oi.get()),ul||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(Wc,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Ui,this._coreBrowserService),this._register(W(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(W(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Bc,this._document,this._helperContainer),this._instantiationService.setService(Hi,this._charSizeService),this._themeService=this._instantiationService.createInstance(Wl),this._instantiationService.setService(Ji,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(xc),this._instantiationService.setService(qi,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(gl,this.rows,this.screenElement)),this._instantiationService.setService(Gi,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(sc,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Yc),this._instantiationService.setService(Wi,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(kd,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(Qs,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(Rl,this.element,this.screenElement,r)),this._instantiationService.setService(Ki,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(Ea.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance($s,this.screenElement)),this._register(W(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(Od,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ic,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ic,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zc,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(W(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(W(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=G.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){pi(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=$(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===G.ETX||n.key===G.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)&&(Md(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){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}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 wi)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Fd=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 Pd(t)}getNullCell(){return new wi}},Id=class extends V{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new H),this.onBufferChange=this._onBufferChange.event,this._normal=new Fd(this._core.buffers.normal,`normal`),this._alternate=new Fd(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)}},Ld=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)}},Rd=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}},zd=[`cols`,`rows`],Bd=0,Vd=class extends V{constructor(e){super(),this._core=this._register(new jd(e)),this._addonManager=this._register(new Nd),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(zd.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 Ld(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Rd(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 Id(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 oi.get()},set promptLabel(e){oi.set(e)},get tooMuchOutput(){return ci.get()},set tooMuchOutput(e){ci.set(e)}}}_verifyIntegers(...e){for(Bd of e)if(Bd===1/0||isNaN(Bd)||Bd%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Bd of e)if(Bd&&(Bd===1/0||isNaN(Bd)||Bd%1!=0||Bd<0))throw Error(`This API only accepts positive integers`)}},Hd=2,Ud=1,Wd=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(Hd,Math.floor(u/e.css.cell.width)),rows:Math.max(Ud,Math.floor(l/e.css.cell.height))}}},Gd=Object.defineProperty,Kd=Object.getOwnPropertyDescriptor,qd=(e,t,n,r)=>{for(var i=r>1?void 0:r?Kd(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&&Gd(t,n,i),i},Jd=(e,t)=>(n,r)=>t(n,r,e),Yd=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ef.isErrorNoTelemetry(e)?new ef(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 Xd(e){Qd(e)||Yd.onUnexpectedError(e)}var Zd=`Canceled`;function Qd(e){return e instanceof $d||e instanceof Error&&e.name===Zd&&e.message===Zd}var $d=class extends Error{constructor(){super(Zd),this.name=this.message}},ef=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`}},tf;(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})(tf||={});var nf=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||tf.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};nf.empty=new nf(e=>{});function rf(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 af;(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 df(...e){return ff(()=>uf(e))}function ff(e){let t=sf({dispose:rf(()=>{cf(t),e()})});return t}var pf=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,sf(this)}dispose(){this._isDisposed||(cf(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{uf(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return lf(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),lf(e,null))}};pf.DISABLE_DISPOSED_WARNING=!1;var mf=pf,hf=class{constructor(){this._store=new mf,sf(this),lf(this._store,this)}dispose(){cf(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};hf.None=Object.freeze({dispose(){}});var gf=class{constructor(){this._isDisposed=!1,sf(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&lf(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,cf(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&lf(e,null),e}},_f=typeof process<`u`&&`title`in process,vf=_f?`node`:navigator.userAgent,yf=_f?`node`:navigator.platform,bf=vf.includes(`Firefox`),xf=vf.includes(`Edge`),Sf=/^((?!chrome|android).)*safari/i.test(vf);function Cf(){if(!Sf)return 0;let e=vf.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(yf),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(yf),yf.indexOf(`Linux`),/\bCrOS\b/.test(vf);var wf=``,Tf=0,Ef=0,Df=0,Of=0,kf={css:`#00000000`,rgba:0},Af;(e=>{function t(e,t,n,r){return r===void 0?`#${Ff(e)}${Ff(t)}${Ff(n)}`:`#${Ff(e)}${Ff(t)}${Ff(n)}${Ff(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})(Af||={});var jf;(e=>{function t(e,t){if(Of=(t.rgba&255)/255,Of===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 Tf=a+Math.round((n-a)*Of),Ef=o+Math.round((r-o)*Of),Df=s+Math.round((i-s)*Of),{css:Af.toCss(Tf,Ef,Df),rgba:Af.toRgba(Tf,Ef,Df)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Pf.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Af.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Tf,Ef,Df]=Pf.toChannels(t),{css:Af.toCss(Tf,Ef,Df),rgba:t}}e.opaque=i;function a(e,t){return Of=Math.round(t*255),[Tf,Ef,Df]=Pf.toChannels(e.rgba),{css:Af.toCss(Tf,Ef,Df,Of),rgba:Af.toRgba(Tf,Ef,Df,Of)}}e.opacity=a;function o(e,t){return Of=e.rgba&255,a(e,Of*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(jf||={});var Mf;(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 Tf=parseInt(e.slice(1,2).repeat(2),16),Ef=parseInt(e.slice(2,3).repeat(2),16),Df=parseInt(e.slice(3,4).repeat(2),16),Af.toColor(Tf,Ef,Df);case 5:return Tf=parseInt(e.slice(1,2).repeat(2),16),Ef=parseInt(e.slice(2,3).repeat(2),16),Df=parseInt(e.slice(3,4).repeat(2),16),Of=parseInt(e.slice(4,5).repeat(2),16),Af.toColor(Tf,Ef,Df,Of);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 Tf=parseInt(r[1]),Ef=parseInt(r[2]),Df=parseInt(r[3]),Of=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Af.toColor(Tf,Ef,Df,Of);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Tf,Ef,Df,Of]=t.getImageData(0,0,1,1).data,Of!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Af.toRgba(Tf,Ef,Df,Of),css:e}}e.toColor=r})(Mf||={});var Nf;(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})(Nf||={});var Pf;(e=>{function t(e,t){if(Of=(t&255)/255,Of===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 Tf=a+Math.round((n-a)*Of),Ef=o+Math.round((r-o)*Of),Df=s+Math.round((i-s)*Of),Af.toRgba(Tf,Ef,Df)}e.blend=t;function n(e,t,n){let a=Nf.relativeLuminance(e>>8),o=Nf.relativeLuminance(t>>8);if(If(a,o)>8));if(sIf(a,Nf.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=If(a,Nf.relativeLuminance(s>>8));if(cIf(a,Nf.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=If(Nf.relativeLuminance2(o,s,c),Nf.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=If(Nf.relativeLuminance2(o,s,c),Nf.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=If(Nf.relativeLuminance2(o,s,c),Nf.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})(Pf||={});function Ff(e){let t=e.toString(16);return t.length<2?`0`+t:t}function If(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 Uf(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!Hf(e)&&!Rf(e)&&!Bf(e)}function Wf(e){return Rf(e)||Vf(e)}function Gf(){return{css:{canvas:Kf(),cell:Kf()},device:{canvas:Kf(),cell:Kf(),char:{width:0,height:0,left:0,top:0}}}}function Kf(){return{width:0,height:0}}function qf(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var Jf=0,Yf=0,Xf=!1,Zf=!1,Qf=!1,$f,ep=0,tp=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,Yf=0,Jf=0,Zf=!1,Xf=!1,Qf=!1,$f=this._themeService.colors,ep=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));ep=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(Yf=e.backgroundColorRGB.rgba>>8&16777215,Zf=!0),e.foregroundColorRGB&&(Jf=e.foregroundColorRGB.rgba>>8&16777215,Xf=!0)}),Qf=this._selectionRenderModel.isCellSelected(this._terminal,t,n),Qf){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:Yf=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Yf=(this.result.fg&16777215)<<8|255;break;case 0:default:Yf=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:Yf=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Yf=(this.result.bg&16777215)<<8|255;break}Yf=Pf.blend(Yf,(this._coreBrowserService.isFocused?$f.selectionBackgroundOpaque:$f.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else Yf=(this._coreBrowserService.isFocused?$f.selectionBackgroundOpaque:$f.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(Zf=!0,$f.selectionForeground&&(Jf=$f.selectionForeground.rgba>>8&16777215,Xf=!0),Wf(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))Jf=(this._coreBrowserService.isFocused?$f.selectionBackgroundOpaque:$f.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Jf=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Jf=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:Jf=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Jf=(this.result.fg&16777215)<<8|255;break;case 0:default:Jf=this._themeService.colors.foreground.rgba}Jf=Pf.blend(Jf,(this._coreBrowserService.isFocused?$f.selectionBackgroundOpaque:$f.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Xf=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(Yf=e.backgroundColorRGB.rgba>>8&16777215,Zf=!0),e.foregroundColorRGB&&(Jf=e.foregroundColorRGB.rgba>>8&16777215,Xf=!0)}),Zf&&(Yf=Qf?e.bg&-150994944|Yf|50331648:e.bg&-16777216|Yf|50331648),Xf&&(Jf=e.fg&-83886080|Jf|50331648),this.result.fg&67108864&&(Zf&&!Xf&&(Jf=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|$f.background.rgba>>8&16777215|50331648,Xf=!0),!Zf&&Xf&&(Yf=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|$f.foreground.rgba>>8&16777215|50331648,Zf=!0)),$f=void 0,this.result.bg=Zf?Yf:this.result.bg,this.result.fg=Xf?Jf:this.result.fg,this.result.ext&=536870911,this.result.ext|=ep<<29&3758096384}},np=.5,rp=bf||xf?`bottom`:`ideographic`,ip={"▀":[{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}]},ap={"░":[[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]]},op={"─":{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`}},sp={"":{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}};sp[``]=sp[``],sp[``]=sp[``];function cp(e,t,n,r,i,a,o,s){let c=ip[t];if(c)return lp(e,c,n,r,i,a),!0;let l=ap[t];if(l)return dp(e,l,n,r,i,a),!0;let u=op[t];if(u)return fp(e,u,n,r,i,a,s),!0;let d=sp[t];return d?(pp(e,d,n,r,i,a,o,s),!0):!1}function lp(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 gp(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()}},bp=class extends yp{_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())}}},xp=class extends yp{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Sp=!_f&&`requestIdleCallback`in window?xp:bp,Cp=class e{constructor(){this.fg=0,this.bg=0,this.extended=new wp}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}},wp=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}},Tp=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Tp.Undefined=new Tp(void 0);var Ep=globalThis.performance&&typeof globalThis.performance.now==`function`,Dp=class e{static create(t){return new e(t)}constructor(e){this._now=Ep&&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}},Op;(e=>{e.None=()=>hf.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(df(...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 Vp({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 Vp({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 Vp({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 Vp({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 Vp({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 Vp;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{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 Vp(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 ee(e,t){return new T(e,t).emitter.event}e.fromObservable=ee;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 mf?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(Op||={});var kp=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 Dp,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}}};kp.all=new Set,kp._idPool=0;var Ap=kp,jp=-1,Mp=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 Np(e?.onListenerError??Xd,this._options?.leakWarningThreshold??jp):void 0,this._perfMon=this._options?._profName?new Ap(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 Ip(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Xd)(n),hf.None}if(this._disposed)return hf.None;t&&(e=e.bind(t));let r=new Rp(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Pp.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Rp?(this._deliveryQueue??=new Hp,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=ff(()=>{Bp?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof mf?n.add(a):Array.isArray(n)&&n.push(a),Bp){let e=Error().stack.split(` -`).slice(2,3).join(` -`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Bp.register(a,t?.[2]??e,a)}return 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*zp<=t.length){let e=0;for(let n=0;n0}},Hp=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}},Up={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}},Wp=2,Gp,Kp=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new vp,this._cacheMapCombined=new vp,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Cp,this._textureSize=512,this._onAddTextureAtlasCanvas=new Vp,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Vp,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Xp(e,this._config.deviceCellWidth*4+Wp*2,this._config.deviceCellHeight+Wp*2),this._tmpCtx=Lf(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 Sp;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 qp(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 qp(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 kf;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=Cp.toColorRGB(t);i=Af.toColor(e[0],e[1],e[2]);break;default:i=n?jf.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(i=jf.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=Cp.toColorRGB(a);d=Af.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=jf.opaque(d)),s&&(d=jf.multiplyOpacity(d,np)),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=Pf.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=Af.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)+Wp*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=qf(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=Jp(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),x,ee,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=Jp(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),x,ee,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?Yp(re):Jp(re,x,ee,D),ie)return Up;let O=this._findGlyphBoundingBox(re,this._workBoundingBox,c,T,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 qp(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 Xp(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function Zp(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:kf,cursorAccent:kf,selectionForeground:kf,selectionBackgroundTransparent:kf,selectionBackgroundOpaque:kf,selectionInactiveBackgroundTransparent:kf,selectionInactiveBackgroundOpaque:kf,overviewRulerBorder:kf,scrollbarSliderBackground:kf,scrollbarSliderHoverBackground:kf,scrollbarSliderActiveBackground:kf,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 Qp(e,t){for(let n=0;n=0){if(Qp(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),em.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=rm){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=rm-(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=rm-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},rm)},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 am(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 ff(()=>r?.disconnect())}function om(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var sm=class e extends Cp{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new wp,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?om(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()]}},cm=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function lm(e,t,n){let r=Lf(e.createProgram());if(e.attachShader(r,Lf(um(e,e.VERTEX_SHADER,t))),e.attachShader(r,Lf(um(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 um(e,t,n){let r=Lf(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 dm(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;ti.deleteProgram(this._program))),this._projectionLocation=Lf(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=Lf(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=Lf(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(ff(()=>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(ff(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=Lf(i.createBuffer()),this._register(ff(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,gm,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,gm,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,gm,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,gm,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,gm,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,gm,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(Kp.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){if(vm=(n*this._terminal.cols+t)*hm,r===0||r===void 0){e.fill(0,vm,vm+hm-1-_m);return}this._atlas&&(ym=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),bm=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&ym.offset.x>bm?(xm=ym.offset.x-bm,e[vm]=-(ym.offset.x-xm)+this._dimensions.device.char.left,e[vm+1]=-ym.offset.y+this._dimensions.device.char.top,e[vm+2]=(ym.size.x-xm)/this._dimensions.device.canvas.width,e[vm+3]=ym.size.y/this._dimensions.device.canvas.height,e[vm+4]=ym.texturePage,e[vm+5]=ym.texturePositionClipSpace.x+xm/this._atlas.pages[ym.texturePage].canvas.width,e[vm+6]=ym.texturePositionClipSpace.y,e[vm+7]=ym.sizeClipSpace.x-xm/this._atlas.pages[ym.texturePage].canvas.width,e[vm+8]=ym.sizeClipSpace.y):(e[vm]=-ym.offset.x+this._dimensions.device.char.left,e[vm+1]=-ym.offset.y+this._dimensions.device.char.top,e[vm+2]=ym.size.x/this._dimensions.device.canvas.width,e[vm+3]=ym.size.y/this._dimensions.device.canvas.height,e[vm+4]=ym.texturePage,e[vm+5]=ym.texturePositionClipSpace.x,e[vm+6]=ym.texturePositionClipSpace.y,e[vm+7]=ym.sizeClipSpace.x,e[vm+8]=ym.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Uf(r,c,ym.size.x,this._dimensions.device.cell.width)&&(e[vm+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*hm;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();return}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 wm(){return new Cm}var Tm=4,Em=1,Dm=2,Om=3,km=2147483648,Am=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=wm()}resize(e,t){let n=e*t*Tm;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)}},jm=`#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; -}`,Mm=`#version 300 es -precision lowp float; - -in vec4 v_color; - -out vec4 outColor; - -void main() { - outColor = v_color; -}`,Nm=8,Pm=Nm*Float32Array.BYTES_PER_ELEMENT,Fm=20*Nm,Im=class{constructor(){this.attributes=new Float32Array(Fm),this.count=0}},Lm=0,Rm=0,zm=0,Bm=0,Vm=0,Hm=0,Um=0,Wm=class extends hf{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Im,this._verticesCursor=new Im;let i=this._gl;this._program=Lf(lm(i,jm,Mm)),this._register(ff(()=>i.deleteProgram(this._program))),this._projectionLocation=Lf(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(ff(()=>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(ff(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=Lf(i.createBuffer()),this._register(ff(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,Pm,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Pm,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,Pm,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,cm),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,Vm=(Lm>>16&255)/255,Hm=(Lm>>8&255)/255,Um=1,this._addRectangle(e.attributes,t,Rm,zm,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Bm,Vm,Hm,Um)}_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])}},Gm=class extends hf{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(ff(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Lf(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=tm(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=rp,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}`}},Km=class extends Gm{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&&$p(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;!(Zm.indexOf(`Chrome`)>=0)&&Zm.indexOf(`Safari`),Zm.indexOf(`Electron/`),Zm.indexOf(`Android`);var $m=!1;if(typeof qm.matchMedia==`function`){let e=qm.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=qm.matchMedia(`(display-mode: fullscreen)`);$m=e.matches,Xm(qm,e,({matches:e})=>{$m&&t.matches||($m=e)})}function eh(){return $m}var th=`en`,nh=!1,rh=!1,ih=!1,ah=th,oh,sh=globalThis,ch;typeof sh.vscode<`u`&&typeof sh.vscode.process<`u`?ch=sh.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(ch=process);var lh=typeof ch?.versions?.electron==`string`&&ch?.type===`renderer`;if(typeof ch==`object`){ch.platform,ch.platform,nh=ch.platform===`linux`,nh&&ch.env.SNAP&&ch.env.SNAP_REVISION,ch.env.CI||ch.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ah=th;let e=ch.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,ah=t.resolvedLanguage||th,t.languagePack?.translationsConfigFile}catch{}rh=!0}else typeof navigator==`object`&&!lh?(oh=navigator.userAgent,oh.indexOf(`Windows`),oh.indexOf(`Macintosh`),(oh.indexOf(`Macintosh`)>=0||oh.indexOf(`iPad`)>=0||oh.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,nh=oh.indexOf(`Linux`)>=0,oh?.indexOf(`Mobi`),ih=!0,ah=globalThis._VSCODE_NLS_LANGUAGE||th,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var uh=rh;ih&&typeof sh.importScripts==`function`&&sh.origin;var dh=oh,fh=ah,ph;(e=>{function t(){return fh}e.value=t;function n(){return fh.length===2?fh===`en`:fh.length>=3&&fh[0]===`e`&&fh[1]===`n`&&fh[2]===`-`}e.isDefaultVariant=n;function r(){return fh===`en`}e.isDefault=r})(ph||={});var mh=typeof sh.postMessage==`function`&&!sh.importScripts;(()=>{if(mh){let e=[];sh.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}),sh.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var hh=!!(dh&&dh.indexOf(`Chrome`)>=0);dh&&dh.indexOf(`Firefox`),!hh&&dh&&dh.indexOf(`Safari`),dh&&dh.indexOf(`Edg/`),dh&&dh.indexOf(`Android`);var gh=typeof navigator==`object`?navigator:{};uh||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||gh&&gh.clipboard&&gh.clipboard.writeText,uh||gh&&gh.clipboard&&gh.clipboard.readText,uh||eh()||gh.keyboard,`ontouchstart`in qm||gh.maxTouchPoints,qm.PointerEvent&&(`ontouchstart`in qm||navigator.maxTouchPoints);var _h=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}},vh=new _h,yh=new _h,bh=new _h;Array(230);var xh;(e=>{function t(e){return vh.keyCodeToStr(e)}e.toString=t;function n(e){return vh.strToKeyCode(e)}e.fromString=n;function r(e){return yh.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return bh.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return yh.strToKeyCode(e)||bh.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 vh.keyCodeToStr(e)}e.toElectronAccelerator=o})(xh||={});var Sh=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Ch;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof wh?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Op.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Sh})})(Ch||={});var wh=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?Sh:(this._emitter||=new Vp,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Th;(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})(Th||={});var Eh=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 Vp,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())}};Eh.EMPTY=Eh.fromArray([]);function Dh(e){return Oh(e,0)}function Oh(e,t){switch(typeof e){case`object`:return e===null?kh(349,t):Array.isArray(e)?Mh(e,t):Nh(e,t);case`string`:return jh(e,t);case`boolean`:return Ah(e,t);case`number`:return kh(e,t);case`undefined`:return kh(937,t);default:return kh(617,t)}}function kh(e,t){return(t<<5)-t+e|0}function Ah(e,t){return kh(e?433:863,t)}function jh(e,t){t=kh(149417,t);for(let n=0,r=e.length;nOh(t,e),t)}function Nh(e,t){return t=kh(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=jh(n,t),Oh(e[n],t)),t)}var{registerWindow:Ph,getWindow:Fh,getDocument:Ih,getWindows:Lh,getWindowsCount:Rh,getWindowId:zh,getWindowById:Bh,hasWindow:Vh,onDidRegisterWindow:Hh,onWillUnregisterWindow:Uh,onDidUnregisterWindow:Wh}=function(){let e=new Map,t={window:qm,disposables:new mf};e.set(qm.vscodeWindowId,t);let n=new Vp,r=new Vp,i=new Vp;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 hf.None;let a=new mf,o={window:t,disposables:a.add(new mf)};return e.set(t.vscodeWindowId,o),a.add(ff(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(Kh(t,Jh.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:qm},getDocument(e){return Fh(e).document}}}(),Gh=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 Kh(e,t,n,r){return new Gh(e,t,n,r)}var qh=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}};qh.None=new qh(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=Dh(n),a=r.get(i);if(a)a.users+=1;else{let o=new Vp,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(ff(()=>{--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 Jh={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:Qm?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Qm?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Qm?`webkitAnimationIteration`:`animationiteration`},Yh=class extends hf{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 gf,this._charAtlasDisposable=this._register(new gf),this._observerDisposable=this._register(new gf),this._model=new Am,this._workCell=new sm,this._workCell2=new sm,this._rectangleRenderer=this._register(new gf),this._glyphRenderer=this._register(new gf),this._onChangeTextureAtlas=this._register(new Vp),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Vp),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Vp),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Vp),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Vp),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 tp(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Km(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=Gf(),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(Kh(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(Kh(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,nm(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=am(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=am(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(ff(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),nm(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 Wm(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Sm(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=tm(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=df(Op.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Op.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 im(()=>{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=Zh(e,n.rows-1,0),t=Zh(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,C=S-n.buffer.ydisp,w=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),T=-1,ee=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 Xh(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)*Tm,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),ee&&o===S&&(y===w&&(this._model.cursor={x:w,y:C,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},T=w+r.getWidth()-1),y>=w&&y<=T&&(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+Em]!==this._cellColorResolver.result.bg||this._model.cells[v+Dm]!==this._cellColorResolver.result.fg||this._model.cells[v+Om]!==this._cellColorResolver.result.ext)&&(E=!0,h.length>1&&(g|=km),this._model.cells[v]=g,this._model.cells[v+Em]=this._cellColorResolver.result.bg,this._model.cells[v+Dm]=this._cellColorResolver.result.fg,this._model.cells[v+Om]=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)*Tm,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,wf,0,0),this._model.cells[b]=0,this._model.cells[b+Em]=this._cellColorResolver.result.bg,this._model.cells[b+Dm]=this._cellColorResolver.result.fg,this._model.cells[b+Om]=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})}},Xh=class extends Cp{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 Zh(e,t,n=0){return Math.max(Math.min(e,t),n)}var Qh=`di$target`,$h=`di$dependencies`,eg=new Map;function tg(e){if(eg.has(e))return eg.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ng(t,e,r)};return t._id=e,eg.set(e,t),t}function ng(e,t,n){t[Qh]===t?t[$h].push({id:e,index:n}):(t[$h]=[{id:e,index:n}],t[Qh]=t)}tg(`BufferService`),tg(`CoreMouseService`),tg(`CoreService`),tg(`CharsetService`),tg(`InstantiationService`),tg(`LogService`);var rg=tg(`OptionsService`);tg(`OscLinkService`),tg(`UnicodeService`),tg(`DecorationService`);var ig={trace:0,debug:1,info:2,warn:3,error:4,off:5},ag=`xterm.js: `,og=class extends hf{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),sg=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=ig[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 Yh(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(Op.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Op.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Op.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Op.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(ff(()=>{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()}};function lg({sessionId:e,owned:t,cwd:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!a.current||!t)return;let n=getComputedStyle(document.documentElement),r=(e,t)=>n.getPropertyValue(e).trim()||t,i=new Vd({convertEol:!1,cursorBlink:!0,fontFamily:r(`--font-mono`,`monospace`),fontSize:12,theme:{background:r(`--color-bg`,`#0b0e14`),foreground:r(`--color-fg`,`#d3dae3`),cursor:r(`--color-accent`,`#5ea1ff`),selectionBackground:r(`--color-border-strong`,`#2b3646`)},scrollback:1e4}),o=new Wd;i.loadAddon(o),i.open(a.current);try{let e=new cg;e.onContextLoss(()=>{e.dispose()}),i.loadAddon(e)}catch{}try{o.fit()}catch{}for(let e of[`A`,`ā`,`Ы`,`Ѣ`,`Ω`,`ế`])document.fonts?.load(`12px "JetBrains Mono Variable"`,e).catch(()=>{});document.fonts?.ready.then(()=>{try{o.fit()}catch{}});let s=location.protocol===`https:`?`wss`:`ws`,c=new WebSocket(`${s}://${location.host}/v1/agents/${encodeURIComponent(e)}/term`);c.binaryType=`arraybuffer`,c.onmessage=e=>{i.write(typeof e.data==`string`?e.data:new Uint8Array(e.data))},c.onclose=()=>i.write(`\r -\x1B[2m[session ended]\x1B[0m\r -`);let l=new TextEncoder,u=e=>{c.readyState===WebSocket.OPEN&&c.send(l.encode(e))},d=i.onData(u),f=(e,t)=>{c.readyState!==WebSocket.OPEN||e<=0||t<=0||c.send(JSON.stringify({resize:{cols:e,rows:t}}))},p=i.onResize(({cols:e,rows:t})=>f(e,t));c.onopen=()=>{try{o.fit()}catch{}f(i.cols,i.rows)};let m=e=>{e.preventDefault(),e.stopPropagation(),u(`\x1B\r`)};i.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;if(h&&e.metaKey&&!e.ctrlKey&&!e.altKey){if(e.key===`c`)return!g();if(e.key===`v`)return _(),!1}if(!h&&e.ctrlKey&&e.shiftKey&&!e.altKey&&!e.metaKey){if(e.key===`C`||e.key===`c`)return g(),!1;if(e.key===`V`||e.key===`v`)return _(),!1}return!h&&e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&(e.key===`c`||e.key===`C`)?!g()||(i.clearSelection(),!1):e.ctrlKey&&!e.altKey&&!e.metaKey&&(e.key===`j`||e.key===`J`)?(m(e),!1):e.key!==`Enter`||[e.shiftKey,e.altKey,e.ctrlKey,e.metaKey].filter(Boolean).length!==1||e.metaKey?!0:(m(e),!1)});let h=/Mac|iP(hone|ad)/.test(navigator.platform||navigator.userAgent),g=()=>{let e=i.getSelection();return e?(navigator.clipboard?.writeText(e),!0):!1},_=()=>{navigator.clipboard?.readText().then(e=>{e&&i.paste(e)}).catch(()=>{})},v=async e=>{let t=e.type||`application/octet-stream`,n=new Uint8Array(await e.arrayBuffer()),r=``;for(let e=0;e{let t=[...e.clipboardData?.items??[]].find(e=>e.kind===`file`)?.getAsFile();t&&(e.preventDefault(),v(t))},b=e=>{let t=e.dataTransfer?.files?.[0];t&&(e.preventDefault(),v(t))},x=e=>{e.preventDefault()},S=a.current;S.addEventListener(`paste`,y),S.addEventListener(`drop`,b),S.addEventListener(`dragover`,x);let C=0,w=``,T=()=>{C=0;let e=a.current;if(!e)return;let t=`${e.clientWidth}x${e.clientHeight}`;if(t!==w){w=t;try{o.fit()}catch{}}},ee=new ResizeObserver(()=>{C||=requestAnimationFrame(T)});return ee.observe(a.current),()=>{S.removeEventListener(`paste`,y),S.removeEventListener(`drop`,b),S.removeEventListener(`dragover`,x),C&&cancelAnimationFrame(C),ee.disconnect(),d.dispose(),p.dispose(),c.close(),i.dispose()}},[e,t]),t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{ref:a,className:`h-[70vh] bg-bg`}),(0,I.jsxs)(`div`,{className:`border-t border-border px-3 py-1.5 text-[11px] text-fg-faint`,children:[(0,I.jsx)(`span`,{className:`mono text-fg-muted`,children:`Shift`}),`+`,(0,I.jsx)(`span`,{className:`mono text-fg-muted`,children:`Enter`}),` for a new line —`,` `,(0,I.jsx)(`span`,{className:`mono text-fg-muted`,children:`Option`}),`+`,(0,I.jsx)(`span`,{className:`mono text-fg-muted`,children:`Enter`}),` and`,` `,(0,I.jsx)(`span`,{className:`mono text-fg-muted`,children:`Ctrl`}),`+`,(0,I.jsx)(`span`,{className:`mono text-fg-muted`,children:`J`}),` do the same.`]})]}):(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-3 px-4 py-10 text-center`,children:[(0,I.jsx)(`p`,{className:`text-[14px] text-fg`,children:`You started this session yourself, so it has no terminal here.`}),(0,I.jsx)(`button`,{onClick:()=>i(!0),className:`rounded-sm bg-accent px-3.5 py-2 text-[13px] font-medium text-bg hover:brightness-110`,children:`Launch a new Claude Code session here →`}),(0,I.jsxs)(`p`,{className:`max-w-[52ch] text-[12px] leading-relaxed text-fg-faint`,children:[`Runs a second `,(0,I.jsx)(`span`,{className:`mono`,children:`claude`}),` in`,` `,n?(0,I.jsx)(`span`,{className:`mono text-fg-muted`,children:n}):`this repository`,` and gives it a terminal you can type in. This session keeps running, untouched.`]}),r&&(0,I.jsx)(Ur,{available:!0,onClose:()=>i(!1),initialCwd:n??``}),(0,I.jsx)(`p`,{className:`mt-1 max-w-[52ch] text-[12px] leading-relaxed text-fg-faint`,children:`Caprock never types into a process it did not start — including this one, which stays visible here and keeps being measured.`})]})}function ug({sessionID:e,cwd:t,live:n}){let[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(``),u=`claude --resume ${e}`;async function d(){i(!0),c(``);try{v({name:`session`,id:(await P.spawn({cwd:t,resume:e,fork:n})).session_id,tab:`terminal`})}catch(e){c(e instanceof M?e.message:String(e))}finally{i(!1)}}async function f(){try{await navigator.clipboard.writeText(u),o(!0),window.setTimeout(()=>o(!1),2e3)}catch{c(`Could not reach the clipboard. Select the command and copy it.`)}}return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,I.jsx)(`button`,{onClick:d,disabled:r,title:n?`Open a branch of this conversation here — the original keeps running`:`Carry this conversation on, here`,className:`text-[11px] border border-accent text-accent px-1.5 rounded-sm hover:bg-accent/10 disabled:opacity-50`,children:r?`opening…`:n?`branch here`:`continue here`}),(0,I.jsx)(`button`,{onClick:f,title:u,className:`text-[11px] text-fg-faint hover:text-fg`,children:a?`copied`:`copy command`}),s&&(0,I.jsx)(`span`,{className:`text-[11px] text-danger`,children:s})]})}function dg(e){return e.agent===`gemini`?`telemetry`:[e.has_hooks?`hooks`:`no hooks`,e.has_transcript?`transcript`:`no transcript`].join(` · `)}function fg({id:e,tab:t,at:n}){let r=F(()=>P.session(e),[e],{intervalMs:5e3}),i=t===`changes`||t===`diff`||t===`files`?`changes`:t===`terminal`||t===`notes`?t:`timeline`,a=re(1e3),[o]=De(),s=r.data;if(r.error&&!s)return(0,I.jsx)(Et,{title:r.error instanceof M&&r.error.status===404?`Session not found`:`Cannot load session`,children:r.error.message});if(!s)return(0,I.jsx)(`div`,{className:`text-fg-muted px-1`,children:`loading…`});let c=t=>v({name:`session`,id:e,tab:t}),l=s.stats.tokens_in+s.stats.tokens_out+s.stats.cache_read+s.stats.cache_write,u=!s.has_hooks&&!s.has_transcript&&l===0&&s.stats.turns===0,d=u&&s.agent===`gemini`;return(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,I.jsx)(`a`,{href:g({name:`now`}),className:`link text-fg-muted text-[12px]`,children:`← Now`}),(0,I.jsx)(`h1`,{className:`text-[15px] font-medium`,children:s.project||`unknown project`}),(0,I.jsx)(`span`,{className:`mono text-[11px] text-fg-faint`,children:s.session_id}),s.git_branch&&(0,I.jsx)(`span`,{className:`mono text-[11px] text-fg-muted`,children:s.git_branch}),(0,I.jsx)(wt,{health:s.activity.health}),s.owned&&s.status!==`ended`&&(0,I.jsx)(xg,{id:e}),!s.owned&&(s.agent??`claude`)===`claude`&&(0,I.jsx)(ug,{sessionID:s.session_id,cwd:s.cwd,live:s.status!==`ended`}),(0,I.jsx)(`span`,{className:`text-[12px] text-fg-muted ml-auto num`,children:s.cwd})]}),(0,I.jsxs)(`div`,{className:`text-[13px]`,children:[(0,I.jsx)(`span`,{className:`text-fg`,children:s.activity.phrase}),(0,I.jsx)(`span`,{className:`text-fg-faint num text-[11px] ml-2`,children:T(s.activity.at||s.last_event_at,a)}),s.loop&&(0,I.jsxs)(`span`,{className:`ml-3 text-danger text-[12px]`,children:[`loop: `,s.loop.sample,` ×`,s.loop.count,` in `,s.loop.window_min,`m`]})]}),u?(0,I.jsx)(L,{children:(0,I.jsx)(`div`,{className:`px-3 py-2.5 text-[13px] text-fg-muted`,children:d?(0,I.jsxs)(I.Fragment,{children:[`Nothing measured yet — Gemini reports its own figures, and the first ones arrive with its first answer.`,` `,(0,I.jsx)(`span`,{className:`text-fg-faint`,children:`The terminal below is live.`})]}):(0,I.jsxs)(I.Fragment,{children:[`Caprock started this `,Ut(s.agent),` session but does not measure it — there are no hooks and no transcript to read, so cost, tokens and turns are not counted here.`,` `,(0,I.jsx)(`span`,{className:`text-fg-faint`,children:`The terminal below is live.`})]})})}):(0,I.jsx)(L,{children:(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 divide-x divide-border`,children:[(0,I.jsx)(R,{label:`Cost`,value:S(s.stats.cost_usd),sub:(0,I.jsx)(`span`,{title:_n(o),children:s.model||`unknown model`})}),(0,I.jsx)(R,{label:`Tokens`,value:C(l),sub:`in ${C(s.stats.tokens_in)} · out ${C(s.stats.tokens_out)} · cache ${C(s.stats.cache_read+s.stats.cache_write)}`}),(0,I.jsx)(R,{label:`Cache`,value:w(s.savings.hit_rate*100),sub:`read ${C(s.stats.cache_read)} · write ${C(s.stats.cache_write)}`,tone:s.savings.hit_rate>.5?`ok`:void 0}),(0,I.jsx)(R,{label:`Context`,value:s.context?w(s.context.pct):`—`,sub:s.context?`${C(s.context.tokens)} / ${C(s.context.window)}`:`unknown model`,tone:s.context&&s.context.pct>=85?`danger`:s.context&&s.context.pct>=60?`warn`:void 0}),(0,I.jsx)(R,{label:`Turns`,value:s.stats.turns,sub:`${s.stats.tool_calls} tool calls`}),(0,I.jsx)(R,{label:`Files`,value:s.stats.files_touched,sub:dg(s)})]})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border`,children:[[`timeline`,`notes`,`changes`,`terminal`].map(e=>(0,I.jsx)(`button`,{onClick:()=>c(e),className:`px-3 py-1.5 text-[12px] border-b-2 -mb-px ${i===e?`border-accent text-fg`:`border-transparent text-fg-muted hover:text-fg`}`,children:e===`timeline`?`Timeline`:e===`notes`?`Answers`:e===`changes`?`Changes`:`Terminal`},e)),!s.owned&&(0,I.jsx)(`span`,{className:`ml-auto text-[11px] text-fg-faint pr-1`,children:`observe-only — terminal is read/write for spawned sessions only`})]}),i===`timeline`&&(0,I.jsx)(mg,{id:e,initial:s.events,now:a,at:n}),i===`notes`&&(0,I.jsx)(Qr,{id:e,now:a}),i===`changes`&&(0,I.jsx)(vg,{id:e,s}),i===`terminal`&&(0,I.jsx)(L,{className:`overflow-hidden`,children:(0,I.jsx)(lg,{sessionId:e,owned:s.owned&&s.status!==`ended`,cwd:s.cwd})})]})}var pg=200;function mg({id:e,initial:t,now:n,at:r}){let[i,a]=(0,l.useState)(t),[o,s]=(0,l.useState)(`all`),c=(0,l.useRef)(t.length?t[t.length-1].id:0),u=(0,l.useRef)(null),[f,p]=(0,l.useState)(!1),[m,h]=(0,l.useState)(!1),g=async()=>{let t=i[0]?.id;if(!(t===void 0||f)){p(!0);try{let n=await P.eventsBefore(e,t,pg);n.length===0?h(!0):a(e=>[...n,...e])}catch{h(!0)}finally{p(!1)}}};(0,l.useEffect)(()=>{a(t),h(!1),c.current=t.length?t[t.length-1].id:0},[t]),(0,l.useEffect)(()=>d.onFrame(t=>{t.type!==`event`||t.data.session_id!==e||t.data.id<=c.current||(c.current=t.data.id,a(e=>[...e,t.data].slice(-5e3)))}),[e]);let _=(0,l.useMemo)(()=>{let e=0;return i.filter(e=>e.kind===`turn.assistant`).map(t=>e+=t.cost_usd??0)},[i]),v=(0,l.useMemo)(()=>{let e=new Map;for(let t of i)if(t.kind===`tool.pre`&&t.tool){let n=t.payload;n?.tool_use_id&&e.set(n.tool_use_id,t.tool)}return e},[i]),y=i.filter(e=>o===`all`||(o===`tools`?e.kind.startsWith(`tool.`):e.kind.startsWith(`turn.`)||e.kind===`agent.stop`)).slice().reverse();return(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_260px]`,children:[(0,I.jsx)(L,{title:`Events · ${i.length} shown`,className:`min-w-0 overflow-hidden`,right:(0,I.jsx)(`span`,{className:`inline-flex items-center gap-2`,children:[`all`,`tools`,`turns`].map(e=>(0,I.jsx)(`button`,{onClick:()=>s(e),className:`px-1.5 rounded-sm ${o===e?`bg-panel-2 text-fg`:`hover:text-fg`}`,children:e},e))}),children:(0,I.jsxs)(`ol`,{ref:u,className:`max-h-[70vh] overflow-auto`,children:[y.length===0&&(0,I.jsx)(Et,{title:`No events yet`}),y.map(e=>(0,I.jsx)(gg,{e,now:n,toolByUse:v,inMinute:r!==void 0&&hg(e.ts,r)},e.id)),!m&&i.length>0&&(0,I.jsx)(`li`,{className:`px-3 py-1.5 border-t border-border/60`,children:(0,I.jsx)(`button`,{className:`text-[11px] text-fg-muted hover:text-fg border border-border px-2 py-0.5 rounded-sm`,onClick:()=>void g(),disabled:f,children:f?`loading…`:`load earlier events`})}),m&&(0,I.jsx)(`li`,{className:`px-3 py-1 text-[11px] text-fg-faint`,children:`start of session`})]})}),(0,I.jsxs)(`div`,{className:`grid gap-3 content-start`,children:[(0,I.jsxs)(L,{title:`Cost, cumulative`,children:[(0,I.jsx)(`div`,{className:`px-3 py-2`,children:(0,I.jsx)(Tt,{values:_.length?_:[0,0],width:230,height:40,tone:`accent`})}),(0,I.jsxs)(`div`,{className:`px-3 pb-2 text-[11px] text-fg-muted num`,children:[_.length,` priced turns · `,S(_[_.length-1]??0)]})]}),(0,I.jsxs)(L,{title:`Tokens per turn`,children:[(0,I.jsx)(`div`,{className:`px-3 py-2`,children:(0,I.jsx)(Tt,{values:i.filter(e=>e.tokens).map(e=>e.tokens.in+e.tokens.cache_read+e.tokens.cache_write),width:230,height:40})}),(0,I.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-fg-muted`,children:`prompt size (input + cache) per assistant turn`})]})]})]})}function hg(e,t){let n=Date.parse(e);return Number.isFinite(n)&&Math.floor(n/6e4)===Math.floor(t/6e4)}function gg({e,now:t,toolByUse:n,inMinute:r}){let[i,a]=(0,l.useState)(!1),o=(0,l.useRef)(null);(0,l.useEffect)(()=>{r&&o.current?.scrollIntoView({block:`center`})},[r]);let s=e.payload??{},c=e.tool||(e.kind===`tool.post`?n.get(String(s.tool_use_id??``)):void 0),u=_g({...e,tool:c},s),d=e.kind===`turn.assistant`?String(s.text??``):e.kind===`turn.user`?String(s.prompt??``):e.kind===`tool.post`&&typeof s.tool_response==`string`?s.tool_response:``,f=e.kind===`turn.user`?`text-info`:e.kind===`turn.assistant`?`text-fg`:e.kind===`agent.stop`||e.kind===`context.compact`?`text-warn`:`text-fg-muted`;return(0,I.jsxs)(`li`,{ref:o,className:`border-b border-border/60 last:border-0 hover:bg-panel-2 animate-flash ${r?`bg-accent/10 border-l-2 border-l-accent`:``}`,children:[(0,I.jsxs)(`button`,{className:`w-full text-left flex items-baseline gap-2 px-3 py-[3px]`,onClick:()=>a(!i),children:[(0,I.jsx)(`span`,{className:`num text-[10px] text-fg-faint w-14 shrink-0`,children:T(e.ts,t)}),(0,I.jsx)(`span`,{className:`mono text-[10px] w-24 shrink-0 ${f}`,children:e.kind}),(0,I.jsx)(`span`,{className:`truncate text-[12px] min-w-0`,title:u,children:u}),e.tokens&&(0,I.jsxs)(`span`,{className:`ml-auto num text-[10px] text-fg-faint shrink-0`,children:[C(e.tokens.in+e.tokens.cache_read+e.tokens.cache_write),`→`,C(e.tokens.out),e.cost_usd===void 0?``:` · ${S(e.cost_usd)}`]})]}),i&&(0,I.jsxs)(`div`,{className:`px-3 pb-2`,children:[d?(0,I.jsx)(`div`,{className:`text-[12px] leading-[1.55] whitespace-pre-wrap break-words max-h-96 overflow-auto border-l-2 border-border-strong pl-3 mb-2`,children:d}):null,(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{className:`text-[10px] text-fg-faint cursor-pointer select-none`,children:`raw event`}),(0,I.jsx)(`pre`,{className:`mono text-[10px] leading-[1.4] text-fg-muted pt-1 max-h-64 overflow-auto whitespace-pre-wrap break-all`,children:JSON.stringify({id:e.id,ts:e.ts,source:e.source,key:e.key,agent_id:e.agent_id,model:e.model,tokens:e.tokens,cost_usd:e.cost_usd,payload:e.payload},null,2)})]})]})]})}function _g(e,t){let n=t.tool_input??{};switch(e.kind){case`tool.pre`:{let r=e.tool??String(t.tool_name??`tool`),i=n.command??n.file_path??n.pattern??n.query??n.url??n.prompt??``;return i?`${r} ${String(i).split(` -`)[0]}`:r}case`tool.post`:{let n=e.tool??String(t.tool_name??`tool`),r=t.tool_response,i=t.is_error===!0,a=typeof r==`string`?r:r?JSON.stringify(r):``;return`${n} ${i?`failed`:`done`}${a?` ${a.slice(0,160)}`:``}`}case`turn.user`:return`you: ${String(t.prompt??``).slice(0,200)}`;case`turn.assistant`:{let n=String(t.text??``),r=Array.isArray(t.tools)?t.tools:[];return n?n.slice(0,200):r.length?`→ ${r.join(`, `)}`:`${e.model??`assistant`} turn`}case`agent.stop`:return e.agent_id?`subagent ${e.agent_id} stopped`:`turn ended (${String(t.stop_reason??`stop`)})`;case`agent.spawn`:return`session started (${String(t.source??`startup`)})`;case`context.compact`:return`context compaction (${String(t.trigger??`auto`)})`;default:return e.kind}}function vg({id:e,s:t}){let n=F(()=>P.diff(e),[e,t.last_event_at],{live:!1,intervalMs:8e3}),[r,i]=(0,l.useState)(new Set),a=e=>i(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});if(n.error&&!n.data){let e=n.error;if(e instanceof M&&e.status===409){let n=e.body;return(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[(0,I.jsxs)(Et,{title:`No git repository`,children:[n?.cwd?(0,I.jsx)(`span`,{className:`mono`,children:n.cwd}):null,` `,n?.error]}),(0,I.jsx)(bg,{s:t})]})}return(0,I.jsx)(Et,{title:`Cannot load diff`,children:e.message})}let o=n.data;if(!o)return(0,I.jsx)(`div`,{className:`text-fg-muted px-1`,children:`loading…`});let s=new Set(o.files.map(e=>e.path)),c=t.files.filter(e=>!s.has(e)&&!s.has(e.replace(/^.*?\//,``))),u=o.files.length>0&&o.files.every(e=>r.has(e.path));return(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[(0,I.jsxs)(L,{title:`Changes · ${o.branch||`detached`}`,right:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o.base&&(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:o.base}),o.files.length>0&&(0,I.jsx)(`button`,{className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,onClick:()=>i(u?new Set:new Set(o.files.map(e=>e.path))),children:u?`collapse all`:`expand all`}),(0,I.jsxs)(`span`,{className:`num`,children:[o.files.length,` files`]})]}),children:[o.files.length===0&&(0,I.jsx)(Et,{title:`Clean working tree`}),(0,I.jsx)(`ul`,{children:o.files.map(e=>{let t=r.has(e.path);return(0,I.jsxs)(`li`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsxs)(`button`,{className:`w-full text-left px-3 py-1.5 flex items-center gap-3 hover:bg-panel-2`,onClick:()=>a(e.path),"aria-expanded":t,children:[(0,I.jsx)(`span`,{className:`text-fg-faint text-[10px] shrink-0 transition-transform ${t?`rotate-90`:``}`,children:`▶`}),(0,I.jsx)(`span`,{className:`mono text-[10px] w-16 shrink-0 ${e.status===`added`||e.status===`untracked`?`text-ok`:e.status===`deleted`?`text-danger`:`text-fg-muted`}`,children:e.status}),(0,I.jsx)(`span`,{className:`mono text-[12px] truncate`,children:e.path}),(0,I.jsxs)(`span`,{className:`ml-auto num text-[11px] shrink-0`,children:[(0,I.jsxs)(`span`,{className:`text-ok`,children:[`+`,e.additions]}),` `,(0,I.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),t&&e.patch&&(0,I.jsx)(yg,{patch:e.patch}),t&&!e.patch&&(0,I.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-fg-faint`,children:e.binary?`binary file`:`no patch`})]},e.path)})})]}),c.length>0&&(0,I.jsx)(bg,{s:t,only:c})]})}function yg({patch:e}){return(0,I.jsx)(`pre`,{className:`mono text-[11px] leading-[1.35] px-3 pb-2 overflow-auto max-h-[50vh]`,children:e.split(` -`).map((e,t)=>{let n=e.startsWith(`+`)&&!e.startsWith(`+++`)?`text-ok`:e.startsWith(`-`)&&!e.startsWith(`---`)?`text-danger`:e.startsWith(`@@`)?`text-info`:`text-fg-muted`;return(0,I.jsx)(`div`,{className:n,children:e||` `},t)})})}function bg({s:e,only:t}){let n=t??e.files,r=e.files.length(0,I.jsxs)(`li`,{className:`px-3 py-1 border-b border-border/60 last:border-0 flex gap-2 items-baseline`,children:[(0,I.jsx)(`span`,{className:`mono text-[12px]`,children:te(e)}),(0,I.jsx)(`span`,{className:`mono text-[10px] text-fg-faint truncate`,children:e})]},e))})]})}function xg({id:e}){let[t,n]=(0,l.useState)(``),r=async t=>{n(t);try{await P.signal(e,t)}catch{}finally{n(``)}};return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-ok border border-ok/40 rounded-sm px-1`,children:`owned`}),(0,I.jsx)(`button`,{disabled:!!t,onClick:()=>r(`pause`),className:`text-[11px] border border-border px-1.5 rounded-sm text-fg-muted hover:text-fg`,children:`pause`}),(0,I.jsx)(`button`,{disabled:!!t,onClick:()=>r(`resume`),className:`text-[11px] border border-border px-1.5 rounded-sm text-fg-muted hover:text-fg`,children:`resume`}),(0,I.jsx)(`button`,{disabled:!!t,onClick:()=>r(`kill`),className:`text-[11px] border border-danger/40 text-danger px-1.5 rounded-sm hover:bg-danger/10`,children:`kill`})]})}function Sg(e){if(!Number.isFinite(e)||e<=0)return[];let t=e/3,n=10**Math.floor(Math.log10(t)),r=[1,2,5,10].map(e=>e*n).find(e=>e>=t)??n*10,i=[];for(let t=r;t<=e*1.0001;t+=r)i.push(t);return i}function Cg({bars:e,active:t,onActive:n,height:r=112,showDayLabels:i=!0}){let a=e=>typeof e==`number`&&Number.isFinite(e)?e:0,o=Math.max(...e.map(e=>a(e.cost)),1e-9),s=r-16,c=Sg(o);return(0,I.jsxs)(`div`,{className:`relative px-3 py-3 flex items-end gap-[3px]`,style:{height:r},onMouseLeave:()=>n(null),children:[c.map(e=>(0,I.jsx)(`div`,{className:`pointer-events-none absolute left-3 right-3 border-t border-border/60`,style:{bottom:16+Math.round(s*e/o)},"aria-hidden":!0,children:(0,I.jsx)(`span`,{className:`num absolute -top-[7px] right-0 bg-panel pl-1 text-[9px] text-fg-faint`,children:S(e)})},e)),e.map(e=>{let r=t===e.day;return(0,I.jsxs)(`button`,{type:`button`,className:`flex-1 flex flex-col items-center justify-end gap-1 min-w-0 h-full cursor-default focus:outline-none`,onMouseEnter:()=>n(e.day),onFocus:()=>n(e.day),onBlur:()=>n(null),"aria-label":`${e.day}: ${S(a(e.cost))}`,children:[(0,I.jsx)(`div`,{className:`w-full rounded-t-sm transition-colors ${r?`bg-accent`:`bg-accent/70`}`,style:{height:Math.max(2,Math.round(s*a(e.cost)/o))}}),i&&(0,I.jsx)(`div`,{className:`num text-[9px] ${r?`text-fg`:`text-fg-faint`}`,children:e.day.slice(8)})]},e.day)})]})}function wg({bars:e,active:t,total:n}){let r=t?e.find(e=>e.day===t):void 0;return r?(0,I.jsxs)(`span`,{className:`num flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:r.day}),(0,I.jsx)(`span`,{className:`text-fg`,children:S(r.cost)}),(0,I.jsx)(`span`,{className:`text-fg-faint`,children:C(r.tokens)}),r.sessions!==void 0&&r.sessions>0&&(0,I.jsxs)(`span`,{className:`text-fg-faint`,children:[r.sessions,` `,r.sessions===1?`session`:`sessions`]})]}):(0,I.jsx)(`span`,{className:`num`,children:S(n)})}var Tg=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function Eg(e){return(new Date(`${e}T00:00:00Z`).getUTCDay()+6)%7}function Dg(e,t){if(!(e>0))return`bg-border/60`;let n=Math.sqrt(e/Math.max(t,1e-9));return n>.75?`bg-accent`:n>.5?`bg-accent/75`:n>.25?`bg-accent/50`:`bg-accent/25`}function Og({bars:e,active:t,onActive:n,maxCell:r=44}){let i=e=>typeof e==`number`&&Number.isFinite(e)?e:0,a=Math.max(...e.map(e=>i(e.cost)),1e-9),o=e[0],s=o?Eg(o.day):0;return(0,I.jsxs)(`div`,{className:`px-3 py-3`,onMouseLeave:()=>n(null),children:[(0,I.jsxs)(`div`,{className:`grid gap-1`,style:{gridTemplateColumns:`repeat(7, minmax(0, 1fr))`,maxWidth:r*7+24},children:[Tg.map((e,t)=>(0,I.jsx)(`div`,{className:`text-center text-[9px] text-fg-faint`,"aria-hidden":!0,children:e},t)),Array.from({length:s},(e,t)=>(0,I.jsx)(`div`,{"aria-hidden":!0},`lead-${t}`)),e.map(e=>{let r=i(e.cost),o=t===e.day;return(0,I.jsx)(`button`,{type:`button`,className:`flex aspect-square items-center justify-center focus:outline-none cursor-default`,onMouseEnter:()=>n(e.day),onFocus:()=>n(e.day),onBlur:()=>n(null),"aria-label":`${e.day}: ${S(r)}`,children:(0,I.jsx)(`span`,{className:`h-full w-full rounded-[3px] transition-colors ${Dg(r,a)} ${o?`ring-1 ring-accent ring-offset-1 ring-offset-panel`:``}`})},e.day)})]}),(0,I.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-[9px] text-fg-faint`,children:[(0,I.jsx)(`span`,{children:`$0`}),[`bg-border/60`,`bg-accent/25`,`bg-accent/50`,`bg-accent/75`,`bg-accent`].map(e=>(0,I.jsx)(`span`,{className:`h-2 w-2 rounded-[2px] ${e}`,"aria-hidden":!0},e)),(0,I.jsx)(`span`,{className:`num`,children:S(a)})]})]})}var kg=e=>e===1?`day`:`days`;function Ag({summary:e,plan:t,days:n}){if(!e)return null;let r=e.cost_usd;if(!t?.plan_kind)return(0,I.jsx)(L,{title:`Plan value`,children:(0,I.jsx)(`div`,{className:`px-3 py-3 text-[12px] text-fg-muted`,children:`Set your plan in the header and Caprock will show what this usage is worth against what you actually pay. It can't detect your plan, so it won't guess.`})});if(t.plan_kind===`metered`)return(0,I.jsx)(L,{title:`Spend`,right:(0,I.jsxs)(`span`,{className:`num text-[12px] text-fg-muted`,children:[t.plan_label||`API`,` · billed per token`]}),children:(0,I.jsxs)(`div`,{className:`px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`num text-3xl text-fg`,children:S(r)}),(0,I.jsxs)(`span`,{className:`text-[12px] text-fg-muted`,children:[`over the last `,n,` `,kg(n)]})]}),(0,I.jsxs)(`p`,{className:`text-[11px] text-fg-faint mt-2 max-w-[60ch]`,children:[`You are billed per token, so this is approximately your actual cost — at Anthropic list prices (`,e.pricing_version,`). Not a saving.`]})]})});let i=t.plan_usd_per_month*n/30,a=i>0?r/i:0;return(0,I.jsxs)(L,{title:`Plan value`,right:(0,I.jsxs)(`span`,{className:`num text-[12px] text-fg-muted`,children:[t.plan_label,` · `,S(t.plan_usd_per_month),`/mo`]}),children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 divide-y sm:divide-y-0 sm:divide-x divide-border`,children:[(0,I.jsx)(R,{label:`you pay · ${n}d`,value:S(i),sub:t.plan_label}),(0,I.jsx)(R,{label:`same usage at API list`,value:S(r),sub:`at list prices ${e.pricing_version}`,tone:`ok`}),(0,I.jsx)(R,{label:`which is`,value:a>0?`${a.toFixed(1)}×`:`—`,sub:a>0?`what ${n} ${kg(n)} would cost through the API`:`not enough measured usage yet`,tone:a>0?`ok`:void 0,size:`hero`})]}),(0,I.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-[11px] text-fg-faint leading-relaxed`,children:`Not a discount you received, and not money back — without the plan you would not have run this much.`})]})}function jg({feature:e,title:t,children:n}){let[r,i]=(0,l.useState)(!1);return F(()=>P.premium(),[]).data?.license?.active?(0,I.jsx)(I.Fragment,{children:n}):(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--radius-panel)] border border-border`,children:[(0,I.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none select-none opacity-70`,children:n}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-3 gap-y-2 border-t border-border bg-panel-2/60 px-4 py-2.5 text-center`,children:[(0,I.jsx)(`span`,{className:`text-[13px] font-medium text-fg`,children:t}),(0,I.jsx)(`button`,{onClick:()=>i(!0),className:`rounded-sm bg-premium px-3.5 py-1.5 text-[13px] font-medium text-white hover:brightness-110`,children:`Unlock with Premium`})]}),r&&(0,I.jsx)(nt,{feature:e,onClose:()=>i(!1)})]})}function Mg({suggestion:e}){let t=F(()=>P.settings(),[],{live:!1}),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)(!1),p=t.data?.cap_usd_per_day;(0,l.useEffect)(()=>{d||p===void 0||(r(p?String(p):``),f(!0))},[p,d]);let m=t.data?.cap_usd_per_day??0,h=m>0,g=async e=>{a(!0),s(``),u(!1);try{await P.saveSettings({cap_usd_per_day:e}),r(e?String(e):``),u(!0),t.refresh()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},_=()=>{let e=n.trim().replace(/^\$/,``).replace(/,/g,``),t=Number(e);if(e===``||!Number.isFinite(t)||t<0){s(`A daily cap has to be a positive number of dollars.`);return}g(t)};return(0,I.jsx)(L,{title:`Daily spend cap`,right:(0,I.jsx)(`span`,{className:h?`text-premium-strong`:`text-fg-faint`,children:h?`on`:`off`}),children:(0,I.jsxs)(`div`,{className:`grid gap-2.5 px-3 py-3 text-[13px]`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:`Stop the day at`}),(0,I.jsx)(`span`,{className:`text-fg-muted`,children:`$`}),(0,I.jsx)(`input`,{className:`input w-28`,inputMode:`decimal`,placeholder:`0`,value:n,onChange:e=>{r(e.target.value),u(!1)},onKeyDown:e=>e.key===`Enter`&&_(),"aria-label":`Daily spend cap in dollars`}),(0,I.jsx)(`button`,{onClick:_,disabled:i,className:`rounded-sm bg-premium px-3 py-1 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50`,children:i?`Saving…`:`Save`}),h&&(0,I.jsx)(`button`,{onClick:()=>void g(0),disabled:i,className:`text-[12px] text-fg-faint hover:text-fg`,children:`turn off`}),c&&!o&&(0,I.jsx)(`span`,{className:`text-[12px] text-fg-faint`,children:`saved`})]}),!h&&e?(0,I.jsxs)(`p`,{className:`text-[12px] text-fg-faint`,children:[`Your days run about `,S(e/2),`.`,` `,(0,I.jsxs)(`button`,{onClick:()=>void g(e),className:`text-premium-strong hover:underline`,children:[`Use `,S(e)]}),` `,`— twice that, so an ordinary day never trips it.`]}):null,o&&(0,I.jsx)(`p`,{className:`text-[12px] text-danger`,children:o}),(0,I.jsx)(`p`,{className:`border-t border-border pt-2 text-[12px] leading-relaxed text-fg-faint`,children:h?(0,I.jsxs)(I.Fragment,{children:[`When today crosses `,S(m),`, Caprock pauses the sessions it started — paused, not killed, so resuming keeps the conversation. Sessions you started yourself are never touched.`]}):(0,I.jsx)(I.Fragment,{children:`Off. Nothing is paused, whatever the day costs. Sessions you started yourself are never touched either way.`})})]})})}function Ng(e){return e>=.01?`$${e.toFixed(2)}`:`${(e*100).toFixed(1)}\u00A2`}function Pg(){let e=F(()=>P.gemini(),[],{live:!1}),[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(``),v=e.data,y=!!v?.available,b=v!==void 0&&!v.available,x=async()=>{let t=r.trim();if(!(!t||a)){o(!0),c(``);try{await P.saveSettings({gemini_api_key:t}),i(``),e.refresh?.()}catch(e){c(ae(e))}finally{o(!1)}}},S=async()=>{let e=t.trim();if(!(!e||m)){h(!0),_(``);try{p(await P.askGemini(e,u||void 0)),n(``)}catch(e){_(ae(e))}finally{h(!1)}}};return(0,I.jsx)(L,{title:`Ask Gemini`,right:(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:y?v?.model:`your key, your bill`}),children:b?(0,I.jsxs)(`div`,{className:`px-3 py-3 text-[12px] text-fg-muted grid gap-2.5`,children:[(0,I.jsxs)(`p`,{className:`m-0`,children:[`Ask Google's Gemini about your own sessions, on your own key. Get one from`,` `,(0,I.jsx)(`a`,{className:`link`,href:`https://aistudio.google.com/apikey`,target:`_blank`,rel:`noreferrer`,children:`Google AI Studio`}),` `,`and paste it here — you pay Google directly, and Caprock counts what it spends beside your Claude figures.`]}),(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:`API key`}),(0,I.jsx)(`input`,{className:`input`,type:`password`,placeholder:`AIza…`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&x()}})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`button`,{onClick:()=>void x(),disabled:a||!r.trim(),className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:a?`saving…`:`Save key`}),(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`Stored on this machine only, and never sent back to this page.`})]}),s&&(0,I.jsx)(`div`,{className:`text-danger text-[11px]`,children:s})]}):(0,I.jsxs)(`div`,{className:`px-3 py-3 grid gap-2`,children:[(0,I.jsx)(`textarea`,{className:`input min-h-[70px] resize-y`,placeholder:`Ask about your sessions, your spend, anything…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&S()}}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,I.jsx)(`button`,{onClick:()=>void S(),disabled:m||!t.trim(),className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm text-[12px] hover:bg-accent/25 disabled:opacity-50`,children:m?`asking…`:`Ask`}),(v?.models?.length??0)>0&&(0,I.jsx)(`select`,{className:`input w-auto text-[12px] py-1`,value:u||v?.model||``,onChange:e=>d(e.target.value),"aria-label":`Model`,children:v.models.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.display,` · ~`,Ng(e.typical_usd),` a question`]},e.id))}),(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`⌘↵ to send`})]}),g&&(0,I.jsx)(`div`,{className:`text-danger text-[12px]`,children:g}),(0,I.jsx)(`p`,{className:`m-0 text-[11px] text-fg-faint`,children:v?.from_env?(0,I.jsxs)(I.Fragment,{children:[`Using the key in `,(0,I.jsx)(`span`,{className:`mono`,children:v?.env_var}),`, which takes precedence over the stored one.`]}):(0,I.jsx)(I.Fragment,{children:`Using the key you saved here. Google bills you directly.`})}),f&&(0,I.jsxs)(`div`,{className:`grid gap-2 border-t border-border pt-2`,children:[(0,I.jsx)(`div`,{className:`text-[13px] whitespace-pre-wrap`,children:f.text}),(0,I.jsxs)(`div`,{className:`text-[11px] text-fg-faint num flex gap-3 flex-wrap`,children:[(0,I.jsx)(`span`,{children:f.model}),(0,I.jsxs)(`span`,{children:[`in `,C(f.usage.prompt_tokens)]}),(0,I.jsxs)(`span`,{children:[`out `,C(f.usage.output_tokens)]}),f.usage.thoughts_tokens>0&&(0,I.jsxs)(`span`,{title:`Google bills thinking tokens as output`,children:[`thinking `,C(f.usage.thoughts_tokens)]}),f.usage.cached_tokens>0&&(0,I.jsxs)(`span`,{children:[`cached `,C(f.usage.cached_tokens)]})]})]})]})})}function Fg(){let[e,t]=(0,l.useState)(`30d`),n=Date.now(),r=F(()=>P.summary(e),[e],{intervalMs:5e3}),i=F(()=>P.daily(30),[],{intervalMs:3e4}),[a]=De(),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(`calendar`),d=r.data,f=!!d&&d.turns>0,p=Ig(i.data??[]),m=Rg(p.map(e=>e.cost));return(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[[`today`,`7d`,`30d`,`all`].map(n=>(0,I.jsx)(`button`,{onClick:()=>t(n),className:`px-2 py-1 text-[12px] rounded-sm ${e===n?`bg-panel-2 text-fg`:`text-fg-muted hover:text-fg`}`,children:n},n)),(0,I.jsxs)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,children:[_n(a),d?` (table ${d.pricing_version})`:``]})]}),r.error&&!d&&(0,I.jsx)(Et,{title:`Cannot reach the daemon`,children:r.error.message}),e!==`today`&&d&&(0,I.jsx)(Nn,{costUSD:p.reduce((e,t)=>e+t.cost,0),days:p.filter(e=>e.cost>0).length,now:n}),(0,I.jsx)(Ag,{summary:d,plan:a,days:Lg(e,d?.from_ms)}),(0,I.jsxs)(L,{title:`Totals · ${e}`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 divide-x divide-border`,children:[(0,I.jsx)(R,{label:`Cost`,value:f?S(d.cost_usd):`—`,sub:(0,I.jsx)(`span`,{title:_n(a),children:f?gn(a):`nothing measured in this range`}),tone:`info`,size:`hero`}),(0,I.jsx)(R,{label:`Burn now`,value:f?`${S(d.burn.usd_per_hour)}/h`:`—`,sub:f?`${C(Math.round(d.burn.tokens_per_min))} tok/min · ${d.sessions} sessions`:void 0}),(0,I.jsx)(R,{label:`Input`,value:f?C(d.tokens_in):`—`,sub:`fresh, full price`}),(0,I.jsx)(R,{label:`Output`,value:f?C(d.tokens_out):`—`,sub:f?`${d.turns} turns`:void 0}),(0,I.jsx)(R,{label:`Cache read`,value:f?C(d.cache_read):`—`,sub:f?(0,I.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,I.jsxs)(`span`,{children:[w(d.savings.hit_rate*100),` hit rate`]}),(()=>{let e=xn(d.savings.hit_rate*100);return e?(0,I.jsx)(`span`,{className:e.color||`text-fg-faint`,children:e.label}):null})()]}):void 0}),(0,I.jsx)(R,{label:`Cache write`,value:f?C(d.cache_write):`—`,sub:f?`${w(d.savings.cut_pct)} input cost cut by cache`:void 0})]}),(0,I.jsx)(kr,{u:d?.unpriced,className:`mx-3 mb-2.5`})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:[(0,I.jsxs)(L,{title:`Model mix`,right:(0,I.jsx)(`span`,{children:`by cost`}),children:[d?d.models.length===0&&(0,I.jsx)(Et,{title:`No priced turns in range`}):(0,I.jsx)(Dt,{rows:4}),(0,I.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,I.jsx)(`tbody`,{children:(d?.models??[]).map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1 mono`,title:e.model||void 0,children:e.model?ne(e.model):`unknown`}),(0,I.jsxs)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:[e.turns,` turns`]}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:(d?.unpriced?.models??[]).includes(e.model)?(0,I.jsx)(`span`,{className:`text-warn`,title:`this model is not in the pricing table, so its cost is unknown`,children:`unpriced`}):S(e.cost_usd)}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-faint w-14`,children:d&&d.cost_usd>0&&!(d.unpriced?.models??[]).includes(e.model)?w(100*e.cost_usd/d.cost_usd):`—`})]},e.model))})})]}),(0,I.jsx)(jt,{summary:d}),(0,I.jsxs)(L,{title:`Per project`,right:(0,I.jsx)(`span`,{children:`by cost`}),children:[d?d.projects.length===0&&(0,I.jsx)(Et,{title:`No priced turns in range`}):(0,I.jsx)(Dt,{rows:4}),(0,I.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,I.jsx)(`tbody`,{children:(d?.projects??[]).map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1`,children:e.project||`unknown`}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:S(e.cost_usd)}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-faint w-14`,children:d&&d.cost_usd>0?w(100*e.cost_usd/d.cost_usd):`—`})]},e.project))})})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-3`,children:[(0,I.jsxs)(L,{className:`lg:col-span-2`,title:`Last 30 days`,right:(0,I.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(wg,{bars:p,active:o,total:p.reduce((e,t)=>e+t.cost,0)}),(0,I.jsx)(`span`,{className:`flex items-center gap-1`,children:[`calendar`,`bars`].map(e=>(0,I.jsx)(`button`,{onClick:()=>u(e),className:`px-1.5 py-0.5 rounded-sm text-[11px] ${c===e?`bg-panel-2 text-fg`:`text-fg-faint hover:text-fg`}`,children:e},e))})]}),children:[i.data?p.length===0&&(0,I.jsx)(Et,{title:`No history yet`}):(0,I.jsx)(Dt,{rows:2}),p.length>0&&(c===`calendar`?(0,I.jsx)(Og,{bars:p,active:o,onActive:s}):(0,I.jsx)(Cg,{bars:p,active:o,onActive:s}))]}),(0,I.jsx)(jg,{feature:`cap`,title:`Stop the day at a number you choose`,children:(0,I.jsx)(Mg,{suggestion:m})}),(0,I.jsx)(jg,{feature:`gemini`,title:`Ask a second model, on your own key`,children:(0,I.jsx)(Pg,{})}),d&&(0,I.jsxs)(L,{title:`Plan limits`,children:[d.rate_limits?(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 pt-1`,children:[d.rate_limits.five_hour&&(0,I.jsx)(wn,{label:`5-hour window`,w:d.rate_limits.five_hour,now:n}),d.rate_limits.seven_day&&(0,I.jsx)(wn,{label:`7-day window`,w:d.rate_limits.seven_day,now:n})]}):(0,I.jsxs)(`div`,{className:`px-3 pt-1 text-sm text-fg-muted`,children:[`No window state yet. Caprock reads this from Claude Code's status line, so it appears once a Pro or Max session has run with `,(0,I.jsx)(`span`,{className:`mono text-fg`,children:`caprock statusline`}),` registered —`,(0,I.jsx)(`span`,{className:`mono text-fg`,children:` caprock up`}),` offers to do that. API-billed usage has no windows to report.`]}),(0,I.jsx)(`div`,{className:`mt-2 px-3 pb-3 text-[11px] text-fg-faint leading-relaxed`,children:`Live from Claude Code's status line (Pro/Max). The percentage is your usage of the window; a forecast is shown only when your measured pace would reach the limit before the window resets.`})]})]}),(0,I.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[d&&d.throttles>0?`${d.throttles} rate-limit / overloaded event${d.throttles===1?``:`s`} observed in this range (from Claude Code's StopFailure hook).`:`No rate-limit events observed in this range.`,` `,`Everything here is measured — no invented numbers.`]})]})}function Ig(e){let t=new Map;for(let n of e){let e=t.get(n.day)??{day:n.day,cost:0,tokens:0,sessions:0};e.cost+=n.cost_usd,e.tokens+=n.tokens_total,e.sessions+=n.sessions,t.set(n.day,e)}return[...t.values()].sort((e,t)=>e.day.localeCompare(t.day))}function Lg(e,t){switch(e){case`today`:return 1;case`7d`:return 7;case`30d`:return 30;default:return t?Math.max(1,Math.ceil((Date.now()-t)/864e5)):30}}function Rg(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length<3)return 0;let n=t[Math.floor(t.length/2)]*2,r=n<10?1:n<100?5:10;return Math.round(n/r)*r}function zg({plan:e,save:t}){let[n,r]=(0,l.useState)(e.license_key??``),i=F(()=>P.premium(),[e.license_key]).data?.license;(0,l.useEffect)(()=>{r(e.license_key??``)},[e.license_key]);let a=n.trim()!==(e.license_key??``).trim();return(0,I.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`w-28 shrink-0 text-fg-muted`,children:`Licence`}),(0,I.jsx)(`input`,{className:`input flex-1 min-w-0`,placeholder:`CR-…`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),onKeyDown:r=>{r.key===`Enter`&&a&&t({...e,license_key:n.trim()})}}),(0,I.jsx)(`button`,{disabled:!a,onClick:()=>t({...e,license_key:n.trim()}),className:`rounded-sm border border-border px-2 py-0.5 text-fg-muted hover:border-border-strong hover:text-fg disabled:opacity-40`,children:`save`})]}),(0,I.jsxs)(`p`,{className:`mt-1.5 pl-[7.5rem] text-[11px] leading-relaxed`,children:[i?.active&&!i.in_grace&&(0,I.jsxs)(`span`,{className:`text-ok`,children:[`Premium is on`,i.expires_at?` — renews ${i.expires_at.slice(0,10)}`:``,`.`]}),i?.active&&i.in_grace&&(0,I.jsxs)(`span`,{className:`text-warn`,children:[i.reason,`. Update your key or payment method.`]}),i&&!i.active&&(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[e.license_key?i.reason:`No key — the free product is unaffected.`,` `,(0,I.jsx)(`a`,{href:`https://caprock.dev/premium/`,target:`_blank`,rel:`noreferrer`,className:`link`,children:`what Premium does`})]}),(0,I.jsx)(`span`,{className:`block text-fg-faint`,children:`Checked on this machine against the date inside the key. Caprock makes no call to us to verify it.`})]})]})}function Bg(){let e=F(()=>P.status(),[],{live:!1,intervalMs:5e3}),t=e.data;if(e.error&&!t)return(0,I.jsx)(Et,{title:`Cannot reach the daemon`,children:e.error.message});if(!t)return(0,I.jsx)(`div`,{className:`text-fg-muted`,children:`loading…`});let n=[[`version`,t.version],[`url`,t.url],[`pid`,String(t.pid)],[`uptime`,ee(t.uptime_s*1e3)],[`data dir`,t.data_dir],[`pricing`,`${t.pricing.version} · ${t.pricing.models} models · fetched ${t.pricing.fetched_at}${t.pricing.user_override?` · user override`:``}`],[`pricing source`,t.pricing.source],[`loop rule`,`≥ ${t.loop_k} same-tool calls in ${t.loop_t_minutes} min · ${t.active_loops} active`],[`events stored`,`${t.events.toLocaleString()}${t.retention_days>0?` · pruned after ${t.retention_days}d`:` · kept forever (set retention_days to cap DB growth)`}`],[`orchestration`,t.orchestration?`on (--hive)`:`off`],[`claude`,t.claude_available?`found on PATH — Caprock can start sessions for you`:`not found on PATH — Caprock cannot start sessions, but still observes every session you start yourself`],[`dashboard`,t.ui_built?`embedded build`:`dev server / placeholder`]];if(t.hooks&&n.push([`hooks`,`${(t.hooks.installed??[]).length}/${(t.hooks.installed??[]).length+(t.hooks.missing??[]).length} events registered in ${t.hooks.settings_path}${t.hooks.shim_exists?``:` (shim missing)`}`]),t.desktop){let e=t.desktop;n.push([`claude desktop`,`${e.five_hour_pct}% of the 5-hour window · ${e.seven_day_pct}% of the 7-day${e.stale?` · last seen `+new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})+`, app closed since`:` · now`}`])}return t.ingest_error&&n.push([`ingest error`,`STOPPED: ${t.ingest_error} — nothing is being captured`]),t.ingest&&n.push([`ingest`,`${t.ingest.files_known} transcripts · ${t.ingest.events_stored} events stored · ${t.ingest.events_deduped} deduped · ${t.ingest.lines_malformed} malformed lines · backfill ${t.ingest.backfill_done?`done`:`running`}`]),(0,I.jsxs)(`div`,{className:`grid gap-3 max-w-3xl`,children:[(0,I.jsx)(Vg,{}),(0,I.jsx)(L,{title:`Daemon`,children:(0,I.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,I.jsx)(`tbody`,{children:n.map(([e,t])=>(0,I.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1 text-fg-muted w-32`,children:e}),(0,I.jsx)(`td`,{className:`px-3 py-1 mono break-all`,children:t})]},e))})})}),t.ingest_error&&(0,I.jsx)(L,{title:`Ingest stopped`,children:(0,I.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-muted`,children:[`No new sessions are being captured: `,(0,I.jsx)(`span`,{className:`mono text-fg`,children:t.ingest_error}),`. Check that`,(0,I.jsx)(`span`,{className:`mono text-fg`,children:` ~/.claude`}),` is readable, then restart with`,(0,I.jsx)(`span`,{className:`mono text-fg`,children:` caprock down && caprock up`}),`.`]})}),!t.claude_available&&(0,I.jsx)(L,{title:`claude not found`,children:(0,I.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-muted`,children:[`The `,(0,I.jsx)(`span`,{className:`mono`,children:`claude`}),` binary was not found on this machine, so Caprock cannot spawn sessions. It still observes every session you start yourself. Install Claude Code, or make sure`,(0,I.jsx)(`span`,{className:`mono`,children:` claude`}),` is on the PATH the daemon was started with.`]})}),t.hooks&&(t.hooks.missing??[]).length>0&&(0,I.jsx)(L,{title:`Hooks not fully installed`,children:(0,I.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-muted`,children:[`Missing: `,(0,I.jsx)(`span`,{className:`mono`,children:(t.hooks.missing??[]).join(`, `)}),`. Run `,(0,I.jsx)(`span`,{className:`mono`,children:`caprock hooks install`}),` for real-time activity; transcript tailing keeps working with a few seconds of delay.`]})})]})}function Vg(){let[e,t]=De();return e?(0,I.jsx)(L,{title:`Settings`,children:(0,I.jsxs)(`div`,{className:`grid gap-2 px-3 py-2.5 text-[12px]`,children:[(0,I.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--color-accent)] mt-0.5`,checked:e.update_checks,onChange:n=>t({...e,update_checks:n.target.checked})}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`span`,{className:`text-fg`,children:`Check GitHub for new releases`}),(0,I.jsx)(`span`,{className:`block text-[11px] text-fg-muted`,children:`The only outbound call Caprock makes. No usage data is sent, and it is checked at most once a day.`})]})]}),(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2 border-t border-border pt-2`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted w-28 shrink-0`,children:`Your plan`}),(0,I.jsx)(`span`,{className:`mono text-fg`,children:e.plan_kind===`metered`?`${e.plan_label||`API`} · billed per token`:e.plan_kind===`flat`?`${e.plan_label||`plan`} · ${S(e.plan_usd_per_month)}/mo`:`not set`}),(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint ml-auto`,children:`change it in the header`})]}),(0,I.jsx)(zg,{plan:e,save:t})]})}):null}function Hg(){let e=F(()=>P.settings(),[],{live:!1}),t=re(3e4),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(!1),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(``),h=e.data;(0,l.useEffect)(()=>{o||h===void 0||(a(h.report_chat_id??``),s(!0))},[h,o]);let g=async()=>{u(!0),m(``);try{await P.saveSettings({report_chat_id:i.trim(),...n.trim()?{report_bot_token:n.trim()}:{}}),r(``),f(!0),e.refresh?.()}catch(e){m(ae(e))}finally{u(!1)}},_=!!h?.report_bot_set&&!!h?.report_chat_id,[v,y]=(0,l.useState)(!1),[b,x]=(0,l.useState)(!1);async function S(){y(!0),x(!1),m(``);try{await P.testReport(),x(!0),window.setTimeout(()=>x(!1),6e3)}catch(e){m(e instanceof Error?e.message:String(e))}finally{y(!1)}}return(0,I.jsx)(L,{title:`Weekly report`,right:(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:_?`Mondays, or the next day you open the lid`:`not set up`}),children:(0,I.jsxs)(`div`,{className:`px-3 py-3 grid gap-3 text-[12px]`,children:[(0,I.jsx)(`p`,{className:`m-0 text-fg-muted`,children:`What moved this week, against your usual — sent to a Telegram bot you own. Nothing passes our server, and the message carries figures only: no prompts, no replies, no file names.`}),(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-fg-muted`,children:[`Bot token`,h?.report_bot_set&&(0,I.jsx)(`span`,{className:`text-ok`,children:` · one is stored`})]}),(0,I.jsx)(`input`,{className:`input`,type:`password`,placeholder:h?.report_bot_set?`leave blank to keep the current one`:`123456:ABC-DEF…`,value:n,onChange:e=>r(e.target.value)}),(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[`Message `,(0,I.jsx)(`span`,{className:`mono`,children:`@BotFather`}),` on Telegram, send`,` `,(0,I.jsx)(`span`,{className:`mono`,children:`/newbot`}),`, and paste what it gives you. Caprock stores it on this machine and never sends it back to this page.`]}),(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`It is your own bot, not one of ours, and that is deliberate: the message goes straight from this machine to Telegram, so your figures never pass through anybody's server. A shared bot would mean shipping its token inside a public binary, and routing what you spend through us to deliver it.`})]}),(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsx)(`span`,{className:`text-fg-muted`,children:`Chat id`}),(0,I.jsx)(`input`,{className:`input`,placeholder:`123456789`,value:i,onChange:e=>a(e.target.value)}),(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[(0,I.jsx)(`strong`,{children:`Write to your bot first`}),` — find it by its username, press Start, send anything. Telegram does not let a bot message you until you have. Then open`,` `,(0,I.jsx)(`span`,{className:`mono`,children:`api.telegram.org/bot/getUpdates`}),` and copy`,` `,(0,I.jsx)(`span`,{className:`mono`,children:`chat.id`}),`. For a channel instead, add the bot as an administrator; its id starts with a minus.`]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,I.jsx)(`button`,{onClick:()=>void g(),disabled:c||!i.trim(),className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:c?`saving…`:`Save`}),(0,I.jsx)(`button`,{onClick:()=>void S(),disabled:v||!_,title:_?`Send this week's report now`:`Save a bot token and chat id first`,className:`border border-border px-3 py-1 rounded-sm hover:border-fg-faint disabled:opacity-50`,children:v?`sending…`:`Send one now`}),b&&(0,I.jsx)(`span`,{className:`text-[11px] text-ok`,children:`sent — check Telegram`}),d&&!p&&(0,I.jsx)(`span`,{className:`text-[11px] text-ok`,children:`saved`}),p&&(0,I.jsx)(`span`,{className:`text-[11px] text-danger`,children:p})]}),h?.report_last_error?(0,I.jsxs)(`p`,{className:`m-0 text-[11px] text-danger`,children:[`Last send failed: `,h.report_last_error]}):h?.report_last_sent_ms?(0,I.jsxs)(`p`,{className:`m-0 text-[11px] text-fg-faint`,children:[`Last sent `,T(h.report_last_sent_ms,t),` ago.`]}):_?(0,I.jsx)(`p`,{className:`m-0 text-[11px] text-fg-faint`,children:`Nothing sent yet — the first one goes out at the start of next week.`}):null]})})}function Ug(){let[e,t]=(0,l.useState)(`all`),[n,r]=(0,l.useState)(null),i=F(()=>P.history(e),[e],{intervalMs:15e3}),[a]=De(),o=i.data,s=!!o&&o.totals.turns>0,c=Ig(o?.daily??[]),u=Math.max(...(o?.tools??[]).map(e=>e.count),1);return(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[[`today`,`7d`,`30d`,`all`].map(n=>(0,I.jsx)(`button`,{onClick:()=>t(n),className:`px-2 py-1 text-[12px] rounded-sm ${e===n?`bg-panel-2 text-fg`:`text-fg-muted hover:text-fg`}`,children:n},n)),(0,I.jsx)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,children:`Everything you ever ran through Caprock. Measured, not estimated.`})]}),s&&o&&(0,I.jsx)(Nn,{costUSD:o.totals.cost_usd,days:o.totals.days,now:Date.now()}),i.error&&!o&&(0,I.jsx)(Et,{title:`Cannot reach the daemon`,children:i.error.message}),(0,I.jsxs)(L,{title:`Lifetime · ${e}`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-7 divide-x divide-border`,children:[(0,I.jsx)(R,{size:`compact`,label:`Sessions`,value:s?o.totals.sessions:`—`,sub:s?`${o.totals.owned_sessions} spawned by caprock`:void 0}),(0,I.jsx)(R,{size:`compact`,label:`Active days`,value:s?o.totals.days:`—`}),(0,I.jsx)(R,{size:`compact`,label:`Turns`,value:s?C(o.totals.turns):`—`,sub:s?`${C(o.totals.tool_calls)} tool calls`:void 0}),(0,I.jsx)(R,{size:`compact`,label:`Files touched`,value:s?C(o.totals.files_touched):`—`,sub:`summed per session`}),(0,I.jsx)(R,{size:`compact`,label:`Avg session span`,value:s?ee(Math.round(o.totals.avg_session_sec*1e3)):`—`,sub:`first to last event`}),(0,I.jsx)(Sn,{hitRate:o?.savings.hit_rate,cutPct:o?.savings.cut_pct,measured:s}),(0,I.jsx)(R,{label:`Cost`,value:s?S(o.totals.cost_usd):`—`,sub:(0,I.jsx)(`span`,{title:_n(a),children:s?gn(a):`nothing measured yet`}),tone:`info`,size:`hero`})]}),(0,I.jsx)(kr,{u:o?.totals.unpriced,className:`mx-3 mb-2.5`})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,I.jsxs)(L,{title:`Tool usage`,right:(0,I.jsx)(`span`,{children:`by calls`}),children:[o?o.tools.length===0&&(0,I.jsx)(Et,{title:`No tool calls yet`}):(0,I.jsx)(Dt,{rows:5}),(0,I.jsx)(`ul`,{className:`py-1`,children:(o?.tools??[]).slice(0,18).map(e=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-[3px]`,children:[(0,I.jsx)(`span`,{className:`mono text-[12px] w-44 shrink-0 truncate`,title:e.tool,children:D(e.tool)}),(0,I.jsx)(`div`,{className:`flex-1 h-2 bg-panel-2 rounded-sm overflow-hidden`,children:(0,I.jsx)(`div`,{className:`h-full bg-accent/70`,style:{width:`${100*e.count/u}%`}})}),(0,I.jsx)(`span`,{className:`num text-[11px] text-fg-muted w-12 text-right`,children:C(e.count)})]},e.tool))})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 content-start`,children:[(0,I.jsxs)(L,{title:`Model mix`,right:(0,I.jsx)(`span`,{children:`by cost`}),children:[o?o.summary.models.length===0&&(0,I.jsx)(Et,{title:`No priced turns`}):(0,I.jsx)(Dt,{rows:3}),(0,I.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,I.jsx)(`tbody`,{children:(o?.summary.models??[]).map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1 mono`,children:e.model||`unknown`}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:S(e.cost_usd)})]},e.model))})})]}),(0,I.jsx)(jg,{feature:`report`,title:`Get this every Monday, without opening the dashboard`,children:(0,I.jsx)(Hg,{})}),(0,I.jsx)(L,{title:`Top projects`,right:(0,I.jsx)(`span`,{children:`by cost`}),children:(0,I.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,I.jsx)(`tbody`,{children:(o?.summary.projects??[]).slice(0,8).map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1`,children:e.project||`unknown`}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,I.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:S(e.cost_usd)})]},e.project))})})})]})]}),(0,I.jsxs)(L,{title:`Daily cost`,right:(0,I.jsx)(wg,{bars:c,active:n,total:c.reduce((e,t)=>e+t.cost,0)}),children:[i.data?c.length===0&&(0,I.jsx)(Et,{title:`No history yet`}):(0,I.jsx)(Dt,{rows:2}),c.length>0&&(0,I.jsx)(Cg,{bars:c,active:n,onActive:r,height:96,showDayLabels:!1})]})]})}var Wg=[{key:`inbox`,label:`Inbox`},{key:`assigned`,label:`Assigned`},{key:`in_progress`,label:`In progress`},{key:`verifying`,label:`Verifying`},{key:`needs_you`,label:`Needs you`},{key:`done`,label:`Done`}];function Gg(){let e=F(()=>P.status(),[],{live:!1,intervalMs:3e4}),t=F(()=>P.tasks(),[],{intervalMs:4e3}),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(null);if(e.data&&e.data.orchestration===!1)return(0,I.jsx)(Kg,{status:e.data,onEnabled:()=>{e.refresh(),t.refresh()}});let o=e=>(t.data??[]).filter(t=>t.status===e||e===`done`&&t.status===`failed`);return(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`button`,{onClick:()=>r(!0),className:`border border-accent/50 text-accent bg-accent/10 px-2 py-1 rounded-sm text-[12px] hover:bg-accent/20`,children:`+ New task`}),(0,I.jsx)(Yg,{available:e.data?.claude_available??!1}),(t.data??[]).some(e=>e.assignee!==``&&e.status!==`done`&&e.status!==`failed`)&&(0,I.jsx)(`a`,{href:`#/graph`,className:`link text-[12px] border border-border px-2 py-1 rounded-sm hover:border-border-strong`,children:`view graph`}),(0,I.jsxs)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,children:[`Tasks are files on disk (`,(0,I.jsx)(`span`,{className:`mono`,children:`tasks/.md`}),`); the orchestrator moves them. Nothing reaches Done until its `,(0,I.jsx)(`span`,{className:`mono`,children:`done_criteria`}),` pass.`]})]}),t.error&&!t.data&&(0,I.jsx)(Et,{title:`Cannot reach the daemon`,children:t.error.message}),t.data&&t.data.length===0&&(0,I.jsxs)(`div`,{className:`border border-border bg-panel-2/60 rounded-sm px-3 py-2 text-[12px] text-fg-muted`,children:[`Start here: `,(0,I.jsx)(`span`,{className:`text-fg`,children:`+ New task`}),` — a title and the commands that have to pass. Then `,(0,I.jsx)(`span`,{className:`text-fg`,children:`▶ Start orchestrator`}),`, which assigns it to a worker and keeps going until the checks are green.`]}),(0,I.jsx)(`div`,{className:`grid gap-2 grid-cols-2 md:grid-cols-3 xl:grid-cols-6`,children:Wg.map(e=>(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-1.5 px-0.5 flex justify-between`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{className:`num`,children:o(e.key).length})]}),(0,I.jsx)(`div`,{className:`grid gap-1.5 content-start min-h-[60px]`,children:o(e.key).map(e=>(0,I.jsx)(Xg,{t:e,onApprove:()=>t.refresh(),onOpen:()=>a(e.id)},e.id))})]},e.key))}),n&&(0,I.jsx)(t_,{onClose:()=>{r(!1),t.refresh()}}),i&&(0,I.jsx)(Zg,{id:i,onClose:()=>{a(null),t.refresh()}})]})}function Kg({status:e,onEnabled:t}){let[n,r]=(0,l.useState)(!1),i=e.suggested_hive??`~/caprock-tasks`,a=e.suggested_repo??``;return(0,I.jsxs)(`div`,{className:`grid gap-3 max-w-[52rem] mx-auto`,children:[(0,I.jsxs)(L,{title:`Task runner`,right:(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`off`}),children:[(0,I.jsxs)(`div`,{className:`grid gap-3 px-3 py-3`,children:[(0,I.jsxs)(`ol`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,I.jsx)(qg,{n:1,title:`You write a task`,children:`A title, a budget, and the commands that have to pass.`}),(0,I.jsxs)(qg,{n:2,title:`Caprock runs it`,children:[`One Claude session per task, in its `,(0,I.jsx)(`span`,{className:`text-fg`,children:`own git worktree`}),` — your working tree is untouched.`]}),(0,I.jsxs)(qg,{n:3,title:`Caprock checks it`,children:[(0,I.jsx)(`span`,{className:`text-fg`,children:`Caprock`}),` runs your commands, not the agent. Only green is done.`]})]}),(0,I.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:`Best for independent tasks — nothing here merges branches. The queue directory is created for you; your repository is not modified.`})]}),(0,I.jsxs)(`footer`,{className:`px-3 py-2 border-t border-border flex items-center gap-2`,children:[(0,I.jsx)(`button`,{onClick:()=>r(!0),className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm text-[12px] hover:bg-accent/25`,children:`Turn on the task runner`}),(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`No restart. Nothing runs until you start it.`})]})]}),n&&(0,I.jsx)(Jg,{hive:i,repo:a,onClose:()=>r(!1),onDone:t})]})}function qg({n:e,title:t,children:n}){return(0,I.jsxs)(`li`,{className:`border border-border bg-panel-2/60 rounded-sm px-2.5 py-2 grid gap-1 content-start`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,I.jsx)(`span`,{className:`num text-[11px] text-accent`,children:e}),(0,I.jsx)(`span`,{className:`text-[12px] font-medium`,children:t})]}),(0,I.jsx)(`div`,{className:`text-[11px] text-fg-muted leading-[1.45]`,children:n})]})}function Jg({hive:e,repo:t,onClose:n,onDone:r}){let[i,a]=(0,l.useState)(e),[o,s]=(0,l.useState)(t),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)(``);return(0,I.jsx)(`div`,{className:`fixed inset-0 z-20 bg-black/50 flex items-start justify-center pt-24`,onClick:n,children:(0,I.jsxs)(`div`,{className:`border border-border-strong bg-panel rounded-[var(--radius-panel)] w-[560px] max-w-[92vw]`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`header`,{className:`px-3 py-2 border-b border-border flex items-center`,children:[(0,I.jsx)(`h2`,{className:`text-[12px] uppercase tracking-[0.08em] text-fg-muted`,children:`Turn on the task runner`}),(0,I.jsx)(`button`,{onClick:n,className:`ml-auto text-fg-muted hover:text-fg`,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`px-4 py-3 grid gap-3 text-[13px]`,children:[(0,I.jsxs)(`ul`,{className:`grid gap-1 text-[12px] text-fg-muted`,children:[(0,I.jsx)(`li`,{children:`· Creates the queue directory below, with a README and an example task.`}),(0,I.jsxs)(`li`,{children:[`· Lets Caprock spawn Claude sessions `,(0,I.jsx)(`span`,{className:`text-fg`,children:`with permission prompts skipped`}),`, one git worktree each under the repo below.`]}),(0,I.jsx)(`li`,{children:`· Starts nothing yet — you start the orchestrator, and only then does work begin.`})]}),(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`Queue directory`,(0,I.jsx)(`span`,{className:`text-fg-faint`,children:` · created if missing`})]}),(0,I.jsx)(`input`,{className:`input mono`,value:i,onChange:e=>a(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`Repository`,(0,I.jsx)(`span`,{className:`text-fg-faint`,children:` · workers branch from here`})]}),(0,I.jsx)(`input`,{className:`input mono`,value:o,onChange:e=>s(e.target.value)})]}),d&&(0,I.jsx)(`div`,{className:`text-danger text-[12px]`,children:d})]}),(0,I.jsxs)(`footer`,{className:`px-4 py-2 border-t border-border flex gap-2 justify-end`,children:[(0,I.jsx)(`button`,{onClick:n,className:`border border-border px-3 py-1 rounded-sm text-fg-muted hover:text-fg`,children:`Cancel`}),(0,I.jsx)(`button`,{onClick:async()=>{u(!0),f(``);try{await P.enableHive(i.trim(),o.trim()),n(),r()}catch(e){f(ae(e))}finally{u(!1)}},disabled:c,className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:c?`turning on…`:`Turn it on`})]})]})})}function Yg({available:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(``);return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,I.jsx)(`button`,{disabled:t||!e,onClick:async()=>{n(!0),i(``);try{let e=await P.startOrchestrator();i(`orchestrator: `+e.session_id.slice(0,8))}catch(e){i(ae(e))}finally{n(!1)}},title:e?`spawn the orchestrator session`:`claude not found — cannot spawn`,className:`border border-border text-fg-muted px-2 py-1 rounded-sm text-[12px] hover:text-fg disabled:opacity-50`,children:t?`starting…`:`▶ Start orchestrator`}),!e&&(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[(0,I.jsx)(`span`,{className:`mono`,children:`claude`}),` was not found on this machine, so Caprock cannot spawn the orchestrator. It still observes every session you start yourself.`]}),r&&(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint mono`,children:r})]})}function Xg({t:e,onApprove:t,onOpen:n}){let r=e.budget_usd>0&&e.cost_usd>e.budget_usd,i=e.assignee!==``;return(0,I.jsxs)(`div`,{className:`border border-border bg-panel rounded-[var(--radius-panel)] px-2 py-1.5`,children:[(0,I.jsxs)(`button`,{className:`w-full text-left disabled:cursor-default`,disabled:!i,onClick:n,title:i?`show the diff, the checks that ran, and where the branch is`:`nothing to show yet — no worker has picked this up`,children:[(0,I.jsx)(`div`,{className:`text-[12px] font-medium truncate ${i?`hover:text-accent`:``}`,title:e.title,children:e.title||e.id}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[10px] text-fg-faint`,children:[(0,I.jsx)(`span`,{className:`mono`,children:E(e.id)}),e.assignee&&(0,I.jsxs)(`span`,{className:`mono text-fg-muted`,children:[`→ `,e.assignee]}),(0,I.jsxs)(`span`,{className:`num ml-auto ${r?`text-danger`:`text-fg-muted`}`,children:[S(e.cost_usd),e.budget_usd>0?` / ${S(e.budget_usd)}`:``]})]})]}),i&&(0,I.jsxs)(`div`,{className:`mt-1 text-[10px] text-fg-faint mono truncate`,children:[`caprock/`,e.assignee]}),e.status===`needs_you`&&(0,I.jsxs)(`div`,{className:`flex gap-1 mt-1.5`,children:[(0,I.jsx)(`button`,{onClick:()=>P.approve(e.id,!0).then(t),className:`flex-1 text-[11px] border border-ok/40 text-ok rounded-sm hover:bg-ok/10`,children:`approve`}),(0,I.jsx)(`button`,{onClick:()=>P.approve(e.id,!1).then(t),className:`flex-1 text-[11px] border border-danger/40 text-danger rounded-sm hover:bg-danger/10`,children:`reject`})]})]})}function Zg({id:e,onClose:t}){let n=F(()=>P.task(e),[e],{intervalMs:6e3}),r=n.data,i=r?.work,a=i?.sessions?.[0];return(0,I.jsx)(`div`,{className:`fixed inset-0 z-20 bg-black/50 flex items-start justify-center pt-16`,onClick:t,children:(0,I.jsxs)(`div`,{className:`border border-border-strong bg-panel rounded-[var(--radius-panel)] w-[820px] max-w-[94vw] max-h-[82vh] overflow-auto`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`header`,{className:`px-3 py-2 border-b border-border flex items-center gap-2 sticky top-0 bg-panel z-10`,children:[(0,I.jsx)(`h2`,{className:`text-[12px] uppercase tracking-[0.08em] text-fg-muted`,children:`Task`}),r&&(0,I.jsx)(`span`,{className:`text-[12px] truncate`,children:r.task.title||r.task.id}),r&&(0,I.jsx)(`span`,{className:`mono text-[10px] text-fg-faint`,children:r.task.status}),(0,I.jsx)(`button`,{onClick:t,className:`ml-auto text-fg-muted hover:text-fg`,children:`✕`})]}),!r&&!n.error&&(0,I.jsx)(Dt,{rows:5}),n.error&&!r&&(0,I.jsx)(Et,{title:`Cannot load the task`,children:n.error.message}),r&&(0,I.jsxs)(`div`,{className:`px-3 py-3 grid gap-3`,children:[(0,I.jsx)(Qg,{work:i,assignee:r.task.assignee}),(0,I.jsx)($g,{criteria:r.done_criteria,runs:i?.verifications,status:r.task.status}),(0,I.jsx)(e_,{sessionID:a?.session_id,assignee:r.task.assignee}),r.body&&(0,I.jsx)(L,{title:`Brief`,children:(0,I.jsx)(`pre`,{className:`mono text-[11px] leading-[1.45] px-3 py-2 whitespace-pre-wrap`,children:r.body})})]})]})})}function Qg({work:e,assignee:t}){return e?.branch?(0,I.jsx)(L,{title:`Where the work is`,children:(0,I.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,I.jsxs)(`tbody`,{children:[(0,I.jsxs)(`tr`,{className:`border-b border-border/60`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1 text-fg-muted w-32`,children:`branch`}),(0,I.jsx)(`td`,{className:`px-3 py-1 mono break-all`,children:e.branch})]}),e.worktree&&(0,I.jsxs)(`tr`,{className:`border-b border-border/60`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1 text-fg-muted w-32`,children:`worktree`}),(0,I.jsx)(`td`,{className:`px-3 py-1 mono break-all`,children:e.worktree})]}),(0,I.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsx)(`td`,{className:`px-3 py-1 text-fg-muted w-32 align-top`,children:`take it`}),(0,I.jsxs)(`td`,{className:`px-3 py-1 grid gap-1 justify-items-start`,children:[(0,I.jsx)(Ot,{command:`git merge --no-ff ${e.branch}`}),(0,I.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[`Run it from `,e.repo?(0,I.jsx)(`span`,{className:`mono`,children:e.repo}):`your repo`,`, on the branch you want the work on. Prefer `,(0,I.jsx)(`span`,{className:`mono`,children:`git cherry-pick`}),` if you only want some of it. Worker`,` `,(0,I.jsx)(`span`,{className:`mono`,children:t}),` may still be running — check the diff below first.`]})]})]})]})})}):(0,I.jsx)(L,{title:`Where the work is`,children:(0,I.jsx)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:`No worker has been assigned yet, so there is no branch. One is created the moment the orchestrator assigns this task.`})})}function $g({criteria:e,runs:t,status:n}){let r=t?.[0],i=r?t.filter(e=>e.round===r.round):[],a=r?`round ${r.round}`:void 0;return(0,I.jsxs)(L,{title:`What has to pass`,right:a,children:[i.length===0&&(0,I.jsxs)(`div`,{className:`px-3 py-2 grid gap-1`,children:[(0,I.jsx)(`div`,{className:`text-[12px] text-fg-faint`,children:n===`done`?`This task was marked done without a recorded check.`:`Not run yet. Caprock runs these itself, in the worker’s worktree, when the worker reports it has finished.`}),(0,I.jsx)(`ul`,{className:`grid gap-0.5`,children:(e??[]).map(e=>(0,I.jsxs)(`li`,{className:`mono text-[11px] text-fg-muted`,children:[`$ `,e]},e))}),(e??[]).length===0&&(0,I.jsx)(`div`,{className:`mono text-[11px] text-danger`,children:`no done_criteria — Caprock cannot verify this task`})]}),i.length>0&&(0,I.jsx)(`ul`,{children:i.map(e=>(0,I.jsxs)(`li`,{className:`border-b border-border/60 last:border-0 px-3 py-1.5 flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`text-[10px] w-14 shrink-0 mono ${e.exit_code===0?`text-ok`:`text-danger`}`,children:e.exit_code===0?`passed`:`exit ${e.exit_code}`}),(0,I.jsx)(`span`,{className:`mono text-[12px] truncate`,title:e.command,children:e.command})]},e.command))})]})}function e_({sessionID:e,assignee:t}){let n=F(()=>e?P.diff(e):Promise.resolve(void 0),[e],{intervalMs:8e3}),[r,i]=(0,l.useState)(null);if(!e)return(0,I.jsx)(L,{title:`What changed`,children:(0,I.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:[`No session has been attributed to this task yet`,t?` (worker ${t})`:``,`, so there is nothing to diff.`]})});if(n.error&&!n.data){let e=n.error;if(e instanceof M&&e.status===409){let t=e.body;return(0,I.jsx)(L,{title:`What changed`,children:(0,I.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:[t?.error,t?.cwd?(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(`span`,{className:`mono`,children:t.cwd})]}):null]})})}return(0,I.jsx)(L,{title:`What changed`,children:(0,I.jsx)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:e.message})})}let a=n.data;return a?(0,I.jsxs)(L,{title:`What changed`,right:(0,I.jsxs)(`span`,{className:`num`,children:[a.files.length,` files`]}),children:[a.files.length===0&&(0,I.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:[`Nothing uncommitted in `,(0,I.jsx)(`span`,{className:`mono`,children:a.branch||`the worktree`}),`. If the worker committed its work, the branch above holds it.`]}),(0,I.jsx)(`ul`,{children:a.files.map(e=>(0,I.jsxs)(`li`,{className:`border-b border-border/60 last:border-0`,children:[(0,I.jsxs)(`button`,{className:`w-full text-left px-3 py-1.5 flex items-center gap-3 hover:bg-panel-2`,onClick:()=>i(r===e.path?null:e.path),children:[(0,I.jsx)(`span`,{className:`mono text-[10px] w-16 shrink-0 ${e.status===`added`||e.status===`untracked`?`text-ok`:e.status===`deleted`?`text-danger`:`text-fg-muted`}`,children:e.status}),(0,I.jsx)(`span`,{className:`mono text-[12px] truncate`,children:e.path}),(0,I.jsxs)(`span`,{className:`ml-auto num text-[11px] shrink-0`,children:[(0,I.jsxs)(`span`,{className:`text-ok`,children:[`+`,e.additions]}),` `,(0,I.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),r===e.path&&e.patch&&(0,I.jsx)(`pre`,{className:`mono text-[11px] leading-[1.35] px-3 pb-2 overflow-auto max-h-[40vh]`,children:e.patch.split(` -`).map((e,t)=>{let n=e.startsWith(`+`)&&!e.startsWith(`+++`)?`text-ok`:e.startsWith(`-`)&&!e.startsWith(`---`)?`text-danger`:e.startsWith(`@@`)?`text-info`:`text-fg-muted`;return(0,I.jsx)(`div`,{className:n,children:e||` `},t)})}),r===e.path&&!e.patch&&(0,I.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-fg-faint`,children:e.binary?`binary file`:`no patch`})]},e.path))})]}):(0,I.jsx)(L,{title:`What changed`,children:(0,I.jsx)(Dt,{rows:3})})}function t_({onClose:e}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(`3`),[a,o]=(0,l.useState)(`go test ./... -go vet ./...`),[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(!1),[f,p]=(0,l.useState)(``),m=a.split(` -`).map(e=>e.trim()).filter(Boolean);return(0,I.jsx)(`div`,{className:`fixed inset-0 z-20 bg-black/50 flex items-start justify-center pt-24`,onClick:e,children:(0,I.jsxs)(`div`,{className:`border border-border-strong bg-panel rounded-[var(--radius-panel)] w-[560px] max-w-[92vw]`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`header`,{className:`px-3 py-2 border-b border-border flex items-center`,children:[(0,I.jsx)(`h2`,{className:`text-[12px] uppercase tracking-[0.08em] text-fg-muted`,children:`New task`}),(0,I.jsx)(`button`,{onClick:e,className:`ml-auto text-fg-muted hover:text-fg`,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`px-4 py-3 grid gap-3 text-[13px]`,children:[(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:`Title`}),(0,I.jsx)(`input`,{autoFocus:!0,className:`input`,value:t,onChange:e=>n(e.target.value),placeholder:`Add /healthz endpoint`})]}),(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:`Budget (USD)`}),(0,I.jsx)(`input`,{className:`input`,value:r,onChange:e=>i(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:`Done criteria · one command per line`}),(0,I.jsx)(`textarea`,{className:`input`,rows:3,value:a,onChange:e=>o(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`grid gap-1`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:`Description`}),(0,I.jsx)(`textarea`,{className:`input`,rows:3,value:s,onChange:e=>c(e.target.value)})]}),f&&(0,I.jsx)(`div`,{className:`text-danger text-[12px]`,children:f})]}),(0,I.jsxs)(`footer`,{className:`px-4 py-2 border-t border-border flex gap-2 justify-end`,children:[(0,I.jsx)(`button`,{onClick:e,className:`border border-border px-3 py-1 rounded-sm text-fg-muted hover:text-fg`,children:`Cancel`}),(0,I.jsx)(`button`,{onClick:async()=>{if(!t.trim()){p(`Title is required.`);return}if(m.length===0){p(`At least one done criterion is required — it is what decides when the task is done.`);return}d(!0),p(``);try{await P.createTask({title:t.trim(),budget_usd:parseFloat(r)||0,done_criteria:m,body:s}),e()}catch(e){p(ae(e))}finally{d(!1)}},disabled:u,className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:u?`creating…`:`Create task`})]})]})})}var n_=72,r_=38,i_=.62;function a_(e){return{cx:e.width/2,cy:e.height/2,r:Math.max(80,Math.min(e.width,e.height)/2-n_-r_),nodeR:r_,gateT:i_}}function o_(e){return Math.max(e,6)}function s_(e,t){return-Math.PI/2+2*Math.PI*e/t}function c_(e,t,n){let r=o_(e.length),i=[];return e.forEach((e,a)=>{if(!t.has(e))return;let o=s_(a,r);i.push({id:e,angle:o,x:n.cx+n.r*Math.cos(o),y:n.cy+n.r*Math.sin(o)})}),i}function l_(e,t,n){return{x:t.cx+(e.x-t.cx)*n,y:t.cy+(e.y-t.cy)*n}}var u_={assigned:.18,in_progress:.45,verifying:i_,done:.85,needs_you:.5,failed:.5,inbox:.08};function d_(e){return u_[e]??.3}function f_(e){return e!==``&&e!==`orchestrator`&&e!==`verifier`}function p_(e,t){let n=e.registry.slice(),r=new Set(e.workers);f_(t.assignee)&&!n.includes(t.assignee)&&(n.push(t.assignee),n.sort()),f_(t.assignee)&&r.add(t.assignee);let i=new Map(e.tasks);return i.set(t.id,t),{registry:n,workers:r,tasks:i}}function m_(){return{registry:[],workers:new Set,tasks:new Map}}function h_(e,t=[]){let n={registry:t.slice(),workers:new Set,tasks:new Map};for(let t of e)n=p_(n,{id:t.id,title:t.title,assignee:t.assignee,status:t.status});return n}function g_(e){return{id:e.id,title:e.title,assignee:e.assignee,status:e.status}}function __(){let e=F(()=>P.tasks(),[],{intervalMs:8e3}),t=(0,l.useRef)([]),[n,r]=(0,l.useState)(m_);return(0,l.useEffect)(()=>{if(!e.data)return;let n=h_(e.data,t.current);t.current=n.registry,r(n)},[e.data]),(0,l.useEffect)(()=>d.onFrame(e=>{e.type===`task`&&r(n=>{let r=p_(n,g_(e.data));return t.current=r.registry,r})}),[]),n}function v_(e){return e.workers.size>0||e.tasks.size>0}function y_(e){let t=new Map;for(let n of e.tasks.values()){if(!f_(n.assignee))continue;let e=t.get(n.assignee)??[];e.push(n),t.set(n.assignee,e)}return t}var b_=260;function x_(e,t,n,r=b_){let i=e+(t-e)*(1-Math.exp(-n/r));return Math.abs(t-i)<.001?t:i}function S_(e){let t=0,n=performance.now(),r=i=>{let a=Math.min(i-n,64);n=i,e(a),t=requestAnimationFrame(r)};return t=requestAnimationFrame(r),{stop:()=>cancelAnimationFrame(t)}}var C_=class{cur=new Map;setTarget(e,t){this.cur.has(e)||this.cur.set(e,t),this.targets.set(e,t)}targets=new Map;step(e,t){let n=!1;for(let r of Array.from(this.cur.keys())){if(!t.has(r)){this.cur.delete(r),this.targets.delete(r);continue}let i=this.targets.get(r)??this.cur.get(r),a=x_(this.cur.get(r),i,e);a!==this.cur.get(r)&&(n=!0),this.cur.set(r,a)}return n}get(e){return this.cur.get(e)}};function w_(e){let t=(0,l.useRef)(new C_),[,n]=(0,l.useState)(0),r=new Set(e.tasks.keys());for(let n of e.tasks.values())t.current.setTarget(n.id,d_(n.status));return(0,l.useEffect)(()=>{let e=S_(e=>{t.current.step(e,r)&&n(e=>e+1)});return()=>e.stop()},[]),(e,n)=>t.current.get(e)??d_(n)}function T_(e){switch(e){case`done`:return`var(--color-ok)`;case`needs_you`:return`var(--color-warn)`;case`failed`:return`var(--color-danger)`;case`verifying`:case`in_progress`:case`assigned`:return`var(--color-accent)`;default:return`var(--color-fg-muted)`}}function E_(e){return e.some(e=>e.status!==`done`&&e.status!==`failed`)}function D_({model:e,viewport:t,centerLabel:n=`orchestrator`}){let r=a_(t),i=c_(e.registry,e.workers,r),a=y_(e),o=w_(e);return(0,I.jsxs)(`svg`,{width:t.width,height:t.height,className:`block`,role:`img`,"aria-label":`orchestration graph`,children:[i.map(e=>(0,I.jsx)(A_,{node:e,g:r,gateStatus:k_(a.get(e.id)??[])},`spoke-${e.id}`)),i.map(e=>(a.get(e.id)??[]).map((t,n)=>{let i=l_(e,r,o(t.id,t.status)),s=(n-(a.get(e.id).length-1)/2)*12,c=-(e.y-r.cy),l=e.x-r.cx,u=Math.hypot(c,l)||1;return(0,I.jsx)(O_,{task:t,cx:i.x+c/u*s,cy:i.y+l/u*s},`task-${t.id}`)})),i.map(e=>{let t=a.get(e.id)??[],n=E_(t),i=e.x>=r.cx?1:-1,o=i===1?`start`:`end`,s=i*(r.nodeR+10),c=t.find(e=>e.status!==`done`&&e.status!==`failed`)??t[0];return(0,I.jsxs)(`g`,{transform:`translate(${e.x},${e.y})`,children:[(0,I.jsx)(`circle`,{className:n?`graph-breathe`:void 0,r:r.nodeR,fill:`var(--color-panel)`,stroke:n?`var(--color-accent)`:`var(--color-border-strong)`,strokeWidth:n?2.5:1.5}),(0,I.jsx)(`text`,{textAnchor:`middle`,dy:`0.32em`,fontSize:`13`,fill:`var(--color-fg)`,className:`mono`,children:N_(e.id)}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`text`,{x:s,y:-4,textAnchor:o,fontSize:`12`,fill:`var(--color-fg)`,children:M_(c.title,26)}),(0,I.jsx)(`text`,{x:s,y:12,textAnchor:o,fontSize:`11`,fill:T_(c.status),className:`mono`,children:j_(c.status)})]})]},`node-${e.id}`)}),(0,I.jsxs)(`g`,{transform:`translate(${r.cx},${r.cy})`,children:[(0,I.jsx)(`circle`,{r:r.nodeR+6,fill:`var(--color-panel-2)`,stroke:`var(--color-accent)`,strokeWidth:2}),(0,I.jsx)(`text`,{textAnchor:`middle`,dy:`0.32em`,fontSize:`12`,fill:`var(--color-fg)`,className:`mono`,children:n===`orchestrator`?`orch`:n})]})]})}function O_({task:e,cx:t,cy:n}){let r=(0,l.useRef)(e.status),[i,a]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(r.current!==`done`&&e.status===`done`){a(!0);let t=setTimeout(()=>a(!1),600);return r.current=e.status,()=>clearTimeout(t)}r.current=e.status},[e.status]),(0,I.jsx)(`circle`,{className:`graph-dot${i?` graph-verified`:``}`,cx:t,cy:n,r:8,fill:T_(e.status),children:(0,I.jsx)(`title`,{children:`${e.title} · ${e.status}`})})}function k_(e){return e.some(e=>e.status===`done`)?`done`:e.some(e=>e.status===`verifying`)?`verifying`:`idle`}function A_({node:e,g:t,gateStatus:n}){let r=l_(e,t,t.gateT),i=n===`done`?`var(--color-ok)`:n===`verifying`?`var(--color-accent)`:`var(--color-bg)`,a=n===`done`?`var(--color-ok)`:n===`verifying`?`var(--color-accent)`:`var(--color-border-strong)`;return(0,I.jsxs)(`g`,{children:[(0,I.jsx)(`line`,{x1:t.cx,y1:t.cy,x2:e.x,y2:e.y,stroke:`var(--color-border)`,strokeWidth:1.5}),(0,I.jsx)(`rect`,{className:`graph-gate`,x:r.x-7,y:r.y-7,width:14,height:14,transform:`rotate(45 ${r.x} ${r.y})`,fill:i,stroke:a,strokeWidth:1.5,children:(0,I.jsx)(`title`,{children:`verify gate — a task turns green only after its tests pass`})})]})}function j_(e){switch(e){case`assigned`:return`assigned`;case`in_progress`:return`working…`;case`verifying`:return`running tests…`;case`done`:return`✓ verified`;case`needs_you`:return`needs you`;case`failed`:return`failed`;default:return e}}function M_(e,t){return e.length>t?e.slice(0,t-1)+`…`:e}function N_(e){let t=/^worker-(\d+)$/.exec(e);return t?`w${t[1]}`:e===`verifier`?`vfy`:e.slice(0,4)}function P_(e){switch(e){case`working`:return`var(--color-ok)`;case`waiting-on-you`:return`var(--color-warn)`;case`looping`:case`error`:return`var(--color-danger)`;case`ended`:return`var(--color-fg-faint)`;default:return`var(--color-fg-muted)`}}function F_({sessions:e,viewport:t}){let n=a_(t),r=e.map(e=>e.id).sort(),i=c_(r,new Set(r),n),a=new Map(e.map(e=>[e.id,e]));return(0,I.jsxs)(`svg`,{width:t.width,height:t.height,className:`block`,role:`img`,"aria-label":`session graph`,children:[i.map(e=>(0,I.jsx)(`line`,{x1:n.cx,y1:n.cy,x2:e.x,y2:e.y,stroke:`var(--color-border)`,strokeWidth:1.5},`edge-${e.id}`)),i.map(e=>{let t=a.get(e.id),r=P_(t.health);return(0,I.jsxs)(`g`,{transform:`translate(${e.x},${e.y})`,children:[(0,I.jsx)(`circle`,{className:t.health===`working`?`graph-breathe`:void 0,r:n.nodeR,fill:`var(--color-panel)`,stroke:r,strokeWidth:2}),(0,I.jsx)(`text`,{textAnchor:`middle`,dy:`0.32em`,fontSize:`9`,fill:`var(--color-fg-muted)`,className:`mono`,children:t.label}),(0,I.jsx)(`title`,{children:`${t.label} · ${t.health}`})]},`sess-${e.id}`)}),(0,I.jsxs)(`g`,{transform:`translate(${n.cx},${n.cy})`,children:[(0,I.jsx)(`circle`,{r:n.nodeR+4,fill:`var(--color-panel-2)`,stroke:`var(--color-border-strong)`,strokeWidth:1.5}),(0,I.jsx)(`text`,{textAnchor:`middle`,dy:`0.32em`,fontSize:`10`,fill:`var(--color-fg-muted)`,className:`mono`,children:`caprock`})]})]})}function I_(){let e=__(),t=F(()=>P.sessions(!0),[],{intervalMs:4e3}),n=(0,l.useRef)(null),[r,i]=(0,l.useState)({width:900,height:560});(0,l.useEffect)(()=>{if(!n.current)return;let e=n.current,t=new ResizeObserver(()=>{i({width:e.clientWidth,height:Math.max(420,e.clientHeight)})});return t.observe(e),i({width:e.clientWidth,height:Math.max(420,e.clientHeight)}),()=>t.disconnect()},[]);let a=v_(e),o=(t.data??[]).filter(e=>e.status!==`ended`).map(e=>({id:e.session_id,label:E(e.session_id),health:e.activity.health})),s=Array.from(e.tasks.values()),c=s.filter(e=>e.status===`done`).length,u=s.filter(e=>[`assigned`,`in_progress`,`verifying`].includes(e.status)).length;return(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[a&&(0,I.jsxs)(`div`,{className:`flex items-baseline gap-6 border border-border bg-panel rounded-[var(--radius-panel)] px-4 py-3`,children:[(0,I.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`num text-2xl text-ok`,children:c}),(0,I.jsx)(`span`,{className:`text-[12px] text-fg-muted`,children:`verified — tests passed, not just claimed`})]}),(0,I.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`num text-2xl text-accent`,children:u}),(0,I.jsx)(`span`,{className:`text-[12px] text-fg-muted`,children:`in flight`})]}),(0,I.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`num text-2xl text-fg`,children:e.workers.size}),(0,I.jsx)(`span`,{className:`text-[12px] text-fg-muted`,children:`workers`})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-fg-faint px-0.5`,children:[(0,I.jsx)(L_,{orchestration:a}),(0,I.jsx)(`span`,{className:`ml-auto`,children:a?`live · the orchestrator assigns work; a task turns green only after its tests pass`:(0,I.jsxs)(I.Fragment,{children:[`your live sessions — start an orchestrator with `,(0,I.jsx)(`span`,{className:`mono text-fg-muted`,children:`caprock up --hive `}),` to see the verified team`]})})]}),(0,I.jsx)(`div`,{ref:n,className:`relative w-full h-[70vh] rounded-[var(--radius-panel)] border border-border bg-panel/40 overflow-hidden`,children:a?(0,I.jsx)(D_,{model:e,viewport:r}):(0,I.jsx)(F_,{sessions:o,viewport:r})})]})}function L_({orchestration:e}){let t=(e,t)=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full`,style:{background:e}}),t]});return(0,I.jsx)(`span`,{className:`inline-flex items-center gap-3`,children:e?(0,I.jsxs)(I.Fragment,{children:[t(`var(--color-accent)`,`in flight`),t(`var(--color-ok)`,`verified`),t(`var(--color-warn)`,`needs you`),t(`var(--color-danger)`,`failed`)]}):(0,I.jsxs)(I.Fragment,{children:[t(`var(--color-ok)`,`working`),t(`var(--color-warn)`,`waiting on you`),t(`var(--color-danger)`,`loop / error`),t(`var(--color-fg-muted)`,`idle`)]})})}var R_=200;function z_(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(``),i=re(3e4),[a,o]=(0,l.useState)(!1),s=F(()=>P.searchNotes(n,R_),[n],{live:!1,intervalMs:0}),[c,u]=(0,l.useState)([]),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(!1);(0,l.useEffect)(()=>{u([]),m(!1)},[n]);let h=[...s.data??[],...c];async function g(){let e=h[h.length-1];if(!(!e||d)){f(!0);try{let t=await P.searchNotes(n,R_,e.event_id);t.length===0?m(!0):u(e=>[...e,...t])}catch{m(!0)}finally{f(!1)}}}let _=a||n?h:h.filter(e=>!e.fragment),v=h.length-_.length;return(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[(0,I.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:t=>{t.preventDefault(),r(e.trim())},children:[(0,I.jsx)(`input`,{className:`input max-w-[520px]`,value:e,onChange:e=>t(e.target.value),placeholder:`Search what Claude told you — a name, an error, a decision…`,"aria-label":`Search Claude's answers`}),(0,I.jsx)(`button`,{type:`submit`,className:`text-[12px] border border-accent/50 text-accent bg-accent/10 px-2 py-1 rounded-sm hover:bg-accent/20`,children:`search`}),n&&(0,I.jsx)(`button`,{type:`button`,className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-1 rounded-sm`,onClick:()=>{t(``),r(``)},children:`clear`}),v>0&&(0,I.jsx)(`button`,{type:`button`,className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-1 rounded-sm`,onClick:()=>o(e=>!e),children:a?`hide short remarks`:`+${v} short remarks`}),(0,I.jsx)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,children:`Claude's written answers, across every session. Local only.`})]}),s.error&&!s.data&&(0,I.jsx)(Et,{title:`Cannot search`,children:s.error.message}),!s.data&&!s.error&&(0,I.jsx)(Dt,{rows:5,className:`border border-border rounded-[var(--radius-panel)] bg-panel`}),s.data&&_.length===0&&(0,I.jsx)(Et,{title:n?`Nothing found for "${n}"`:`No answers captured yet`,children:n?`Try a shorter phrase — this matches the words Claude wrote, not what you asked.`:`Run a session and Claude’s written answers will be searchable here.`}),_.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`text-[11px] text-fg-faint px-0.5`,children:[_.length,` `,_.length===1?`answer`:`answers`,n?` matching "${n}"`:` · most recent`,` · subagent chatter excluded`]}),(0,I.jsx)(`div`,{className:`grid gap-2`,children:_.map(e=>(0,I.jsx)(ei,{note:e,now:i,showSession:!0},e.event_id))}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-0.5`,children:[!p&&(0,I.jsx)(`button`,{className:`text-[11px] text-fg-muted hover:text-fg border border-border px-2 py-1 rounded-sm`,onClick:()=>void g(),disabled:d,children:d?`loading…`:`load older answers`}),p&&(0,I.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`that is everything`})]})]})]})}function B_(){let e=_();return(0,I.jsx)(ht,{route:e,children:(0,I.jsxs)(xt,{label:e.name,children:[e.name===`now`&&(0,I.jsx)(qr,{}),e.name===`session`&&(0,I.jsx)(fg,{id:e.id,tab:e.tab,at:e.at},e.id),e.name===`cost`&&(0,I.jsx)(Fg,{}),e.name===`settings`&&(0,I.jsx)(Bg,{}),e.name===`history`&&(0,I.jsx)(Ug,{}),e.name===`tasks`&&(0,I.jsx)(Gg,{}),e.name===`graph`&&(0,I.jsx)(I_,{}),e.name===`notes`&&(0,I.jsx)(z_,{})]})})}(0,u.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(l.StrictMode,{children:(0,I.jsx)(B_,{})})); \ No newline at end of file diff --git a/internal/api/dist/assets/index-D7qL0sQJ.css b/internal/api/dist/assets/index-D7qL0sQJ.css new file mode 100644 index 0000000..572e601 --- /dev/null +++ b/internal/api/dist/assets/index-D7qL0sQJ.css @@ -0,0 +1 @@ +@font-face{font-family:Hanken Grotesk Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(data:font/woff2;base64,d09GMgABAAAAAAaEABMAAAAADFgAAAYdAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhYbbhwoP0hWQVJpBmA/U1RBVIE4AFwvbBEICoJ8gkMLFAAwhCoBNgIkAyIEIAWGUAdiDAcbvgpRVHJOI/viwCYyfSFrJjFIG8raYpYj9+IeSF0s6zD+Lk/4OGrZHhHV+wvt2ffuWPwlA51lIICIosSVmyOKEs5Uzlx3NKeXIgn1ssCydUybDV0IHga+SszIyfrQe9bLTFNxjayzgs76hNsDoSYtRe32fiJ4gxBjrP8L+w//zzHjv7Yqyr9o2vOBDXhCo2jMtr4uwAK/gV1U0PxAq/EAD+yW9EoKOL1KLw8rHrFgCSgRTQRzBzpeXVhweEDlyfY8gIoOa2CQJzrTAHIIoitTMVV2dyFwpJ2iAEQTpSkhPitxD3YwuZHEagTcAhyKAcBmUyPdhTovJThOw6HYiaF2M/J7erdi2OUutor6ES6Ac88AvfZvKpb6fJoArohb524042j6Jij36NI7P8Pb7s721naN9gcTtcjXQP4l+8BKEzFVGMxxoHqlq8Ul4LGneFJBDFaOdKpLPcg8P14YSDwIcn75hdlyJLTBlZ4voL6tT46yC/njunXqpJ0/bSvmrH1o3kRlwZ+j0DBogkF3KbDRVBlbOc+fY5HVXwPoT9hfekPnyZMaEmenYLMSg5npqegFOsgXsBv1IoF9aIVfSCNHkk6+gIzILsiYuhWQCfUtZEpbkRntQxBZgw7MwFbMcRvwJrAnBlDqs7isLtL7pO84Xru1i7ah7tckH1Wreqq6K9u0amxU1bcff/s2Y1ni3rh2I8zHzqkm3PGvv3mzC6NDBz/UcOBIg+nm88rxN8MbdtypvHUL5o1c2zG0urYpRmW+VHZdiba6GXN/3v0B3i3nt4RBsbfAu8ftLqRcTIlZ4VYheFTAS5nXLS65VZrbuW3daF2Ze1ChyGXWZN6u9nUuH1LfyTERifZXEpIueMe28vF8FOoTnsONzw+1djo9P71lZGx1vM8mH/BhvSa2HDsRZ1+Ul+RmpnPOIaEuwWnZZdkgQWAAyCDDZ1wk+0sh7wseAAwA6UlHxbftCgYAAwKAgwIAEA7ACfHIRbV7J6dwF/ZzcRRmAjXUYKAGWAlDCCFmKnH+LJEQfHKEmVrfmKwSEab36AcubXQBoDYJV/aRV+funFD8wAXLSLYbwr9+DR+h/qZIKCfeqRG5ghHpdY0zcV2nuz5iJMhAFjaTDwOcoyKGG9JHrCfdp4cC+kCvUrxc7+bliIMiHj95sPIbUeWZEP/HLnN2tlr9EBeRiktHuWvErx98fRz1MuEvHO3FDRgtsSzL/P0hsDLK2n5/uHMOjvTst0HD6t+80ZN798j7j//kjqHxIOZDFPR/FxurFD6/HxGbB799RPHLx5F89MoBOub9jVuOWtmPH3o9H3r26DIuff+LqPLwff/xryDRmiAYmjxiK0GwS9XU+k8QpUrHsCTs4qH89Fv44ubWbQmOE51M7J8Pt8+h+NKt3zZpa2L9zZqcRlyEc4MaNGdfjQCxgIygn78ne4yAzcLWA3zAJ6RRGbijvHr1W+XN8ywrG0EoZSySb0/A9KsllI7Q/Pq8hLu76tfTy5cF4X8bQxTtYp2vr6/+1oI4AhgAlNYFryt62VaX9ktO6VsAeDLeWx6fff4vdV1ts7N6+gw9GCsQnqPB0QUttB9nEc7Aaf4XM0NQ90VJ+HV1rG04znGCmXcpPCA9+nxdMPgPlT7Dz83NMfZuMJaNeRqbc+tjd2QER/b0B44d7nv5Rif7VC8svYkx9SKWwb3YzN2M3cY8jSNLl+PYZqfjxNTxOLXVCmfmduDc0ty1kLbjeiGfIrDFJXWPTTMD5TKupR8cpZgJeXTofId8NoUj6E8XfAc2k4WPdbCberDYAp8Q7L5dUo8wE8cs9QINZYvwXKzvBS4v/n+fQZkGrrFysKEIuFBgjQpxiHH1XA+ZBI+C+oAoxhYKECc42rGOc8L4mYhsiThGfFjOcKmFubPpDgwnY1918Fwo8ouenDJxvGP96HFWJ28hiOy251oKjkcbGz2POMme8CTMThx6wqOPsFtPI6j6HhDyDTxFQYnL88FcXGAGHl3ZuueRbEuxbK6Hc84ZDvRrREtLzyjj8Xkd/uShR1b0sYd8Nh8/c8znxCnadxQcf2nFVWIyw1g+4StXav9j75s+CQAA)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Hanken Grotesk Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/hanken-grotesk-vietnamese-wght-normal-CHiFlh_0.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Hanken Grotesk Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/hanken-grotesk-latin-ext-wght-normal-Dg-wlmqe.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}@font-face{font-family:Hanken Grotesk Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/hanken-grotesk-latin-wght-normal-CaVRRdDk.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 Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(data:font/woff2;base64,d09GMgABAAAAAAfsABQAAAAAEAwAAAeCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhwbHhwoP0hWQVJbBmA/U1RBVIFiJyYAdC9qEQgKhGSEAAsgADCGCAE2AiQDOgQgBYlMB4EUDAcbLQ4onoexrSC/2ZyLAa8p8VHB8/x3Vue+V0hVJalMJg2nx/TCrQXxBeqLjQG7FyM1WEa/X1tEXN7cFz9EJEMmMUz3RihWSSKeQCbcIou0izz/C8v+fq3VfajEa9gDD11CImXS7qL/RJFVzC1qiB6KmKeD6TZdQ6IRGv78dL6uSVVCfgni5mzu7kcgQBgAEAQTQRCoL++STTYybkJxNfQxAAIAGu8OdEB9teW2jh4BpgDqFjAeSEByW3zFP0CBBgNMsMCGEDjgggdhiEAUAeIIED7ABTDUEnkIE9Q9ahFgKttcVhApo4ACB4qobHaccgDfEjFO6aaWUhjMLt2SyIvHKoDqoA4CSUwEIYQCEjhAO9R1G6keDeDZGjNo+AhxOjCEGTr1WeIF3kYBiLAOKvkJSMiKX0VdAyQt3SDJClCkxJCHkCzfqyVTriJZLcolS32JZHUekq2TYNkYtCtjYHMQXSxGjXDz2t/yLWXzDzxz+o3zFwDEaN23F+13pyMdQAEaSKAR9vcGq4A4MTSKCElGW+M7UcY7xqkggITb28ZJhlqc9q2twYKTt0NjixBgYvO9BIihEBLYuOFXQzfIQ7dXGUEEEgFDooBfAzqiQbpJrhiWSuKJCRFKYbHCyJKI2G5GiZbNAvgAu5pc3vwx4G+g3aDkhklABiSz0BICXrYghtYhx/cdJ+44rY2oZ0aMNRFz3VZjb6W33F3gzltqtOCV8tTHSpOeXuItfvr5lCdfzFpqtEitvqdcdGGFd28ZqqC0tPbeChGXgrIlnhSWu/eUso4uKWFLugyDzQJhflY4659+WjQ++6x72WUMv9G8mw6QJl7BVxX5fe/kpUsOvnZwee9uQ0cGXYd0o89XB2748sDSnt8d2VphdOTTgceDVvOds0v9P/s7HPq15aGun/6Vllb56f1dl0t1LejqrNkpdRZsG8TOnM5vkBG5oiVyVGnS8LHps5cfNWJs6qKPfaNSxiQNBUm3cKNWROr0GSur7Za31k1vieq7LH11VF+jXdRIasRKflc7jkobm1Z9te1IyZA0pDkhLR98+H37Zf1c/8at+dB7x+7GfVyTfJMPiYztsnl59Y5l4j+0n1RXlpHnF3Tq7HecmNF/CJodEMAikruxiyJaGLvHOdAfoA+oDvpjBm2b91cHGRZMU9n25xEU0A8fgEEAdKI3Q1iDtc034sug5YVMkE2jsE+BIkwSoQ3gxXMqz9tELp48bd0cFKOKS7xYjEuXBnZP5ia7DyiO/X/YI+PQSbt2uSdqAkWL9nQbV1XB94/+uPfdZz8dnXYFBYrcTl2SIR/ybxJNJPz/Gupb0JaZeens2ekC7EKr8t+Ls/P5VJPYJdHKyqfg2nqU6bhlidzcddQV/7MmecTzJ5VPcKXkNKSEogHjYFx6QZ7rQ+FSe8njaiNuOnXS8H2ScQ619c2mC3VTtauL0rRbXd/CkSOP37FY9Zkjz8+GibYUMOEWF+RdrFS8Ecv1SHOpPUPZGEIpjPvFyU5cXKjd6OXqorTqy9GwRd++HVufPGnVsW+aO3vggKZ18jR9sXaTC1PWTEsVUaK0FkNySbTQDqlm2PfDjZcu4aalnSLKjnOoYQ0nUlqqXcGpPu/4VgV/xU2pAqW4BW3qzhQ8/hFKhV2qE3+BKAtDqBXjfgnVdH4y0wg5tbVNRenNdTWOrenWLcupQdmsbq5b+18piTe/xRdp1xbILxNPJGInm2z6hoB21Lal0i+ePTtd7B45+3XhFJ329evskXm7qurUVREotqSluSo/L29d3qDhI4YOQqWhI4YNvBNfsMHeXKemXrxQfKeuPOGRVayA3JtkJKEgbPp+dXUDluddutRYLFoXGXWX6N3WFaGLbQtRSitVYNacTNSdy7AaG/HSaUEANcBoGXNdcZvZsOqQ1icBDv21/gzAoYPHH/WDW0qNR3QTYKEAEHig6o13NXbND06CQPlRtYjGNnSktRc09k1mAMDvAlDKfQjgy6fssInlfzmNAjKkDxoxHOBLdVRAIVt9j4qo+hA1w9T1aNBNTUOTTNUHLbqokE+UAfJXCIGw/IxCSL5GRUJeR40rL/UxTm4Q08H6MbCs70ObuNyIIXrINHQYInF06UUlevTjbQzTh5upiDMzMMogUtEnjPs/Y7jAHCJeB0GBHh04tC6FiB6ZFB1oArUSIoFoqhzCeAN6lHwm0T4C3VVPWvjpSMXReuWesMEcoqrmgtNBGd2noWeV0hNAz9rFeShNJxHGsPa3HXeKTk8b55hahySYHaYKKFFLpCfN8rsoaJn01CR04Gkc+5k7KVTCmClX8Q10HCrUEkVlSX+XO33oQR9609tJ516H497WSobWs5Up6TLaS10/dessIskgJSLiDlWvHVUywpkQ7hdPZqGyiEF0uVQerVcPamT1A3eKXdyI1vG9OoflrSXihZ1qqGE3nhmAgiIbRCQgPLEPtOM3UQwTLYaYYomNlpA44opnjV6jkD6id80OOrzf6BzmMD6eEa1zKyeYG1fzfEf16V6jw9XYOaar1/b2kP/IYX8oR2mcFvv2GtBV3JXgd437AQAA)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2)format("woff2-variations");unicode-range:U+370-377,U+37A-37F,U+384-38A,U+38C,U+38E-3A1,U+3A3-3FF}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/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}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/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}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--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:"Hanken Grotesk Variable", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;--font-mono:"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-normal:0em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--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-bg:#1b1b1a;--color-panel:#211f1d;--color-panel-2:#262422;--color-border:#2b2927;--color-border-strong:#3a3835;--color-fg:#e8e6e2;--color-fg-muted:#a9a59e;--color-fg-faint:#837f78;--color-ok:#4fbf6b;--color-warn:#e0a33c;--color-danger:#ff8080;--color-info:#feb157;--color-accent:#feb157;--color-accent-strong:#ffcb85;--color-premium:#4d5cf0;--color-premium-strong:#6f7bff;--shadow-panel:0 12px 32px -18px #000000a6;--radius-panel:6px;--animate-flash:flash .15s ease-out}}@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-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-x-0{inset-inline:0}.-top-1{top:calc(var(--spacing) * -1)}.-top-4{top:calc(var(--spacing) * -4)}.-top-\[7px\]{top:-7px}.top-0{top:0}.top-7{top:calc(var(--spacing) * 7)}.top-full{top:100%}.right-0{right:0}.right-3{right:calc(var(--spacing) * 3)}.bottom-0{bottom:0}.left-0{left:0}.left-0\.5{left:calc(var(--spacing) * .5)}.left-1\/2{left:50%}.left-3{left:calc(var(--spacing) * 3)}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.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-0{margin:0}.mx-3{margin-inline:calc(var(--spacing) * 3)}.mx-auto{margin-inline:auto}.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)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-auto{margin-top:auto}.-mr-1{margin-right:calc(var(--spacing) * -1)}.mr-1{margin-right:var(--spacing)}.-mb-px{margin-bottom:-1px}.mb-1{margin-bottom:var(--spacing)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\.5{margin-bottom:calc(var(--spacing) * 2.5)}.mb-3\.5{margin-bottom:calc(var(--spacing) * 3.5)}.ml-1{margin-left:var(--spacing)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3{margin-left:calc(var(--spacing) * 3)}.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}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1{height:var(--spacing)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-3{height:calc(var(--spacing) * 3)}.h-8{height:calc(var(--spacing) * 8)}.h-10{height:calc(var(--spacing) * 10)}.h-\[2px\]{height:2px}.h-\[14px\]{height:14px}.h-\[44px\]{height:44px}.h-\[70vh\]{height:70vh}.h-\[92px\]{height:92px}.h-\[168px\]{height:168px}.h-full{height:100%}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-96{max-height:calc(var(--spacing) * 96)}.max-h-\[40vh\]{max-height:40vh}.max-h-\[50vh\]{max-height:50vh}.max-h-\[70vh\]{max-height:70vh}.max-h-\[76vh\]{max-height:76vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[82vh\]{max-height:82vh}.max-h-\[420px\]{max-height:420px}.min-h-\[60px\]{min-height:60px}.min-h-\[70px\]{min-height:70px}.min-h-screen{min-height:100vh}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-3{width:calc(var(--spacing) * 3)}.w-9{width:calc(var(--spacing) * 9)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-16{width:calc(var(--spacing) * 16)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-32{width:calc(var(--spacing) * 32)}.w-36{width:calc(var(--spacing) * 36)}.w-44{width:calc(var(--spacing) * 44)}.w-\[268px\]{width:268px}.w-\[420px\]{width:420px}.w-\[440px\]{width:440px}.w-\[560px\]{width:560px}.w-\[620px\]{width:620px}.w-\[820px\]{width:820px}.w-auto{width:auto}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[12ch\]{max-width:12ch}.max-w-\[50\%\]{max-width:50%}.max-w-\[52ch\]{max-width:52ch}.max-w-\[52rem\]{max-width:52rem}.max-w-\[60ch\]{max-width:60ch}.max-w-\[92vw\]{max-width:92vw}.max-w-\[94vw\]{max-width:94vw}.max-w-\[220px\]{max-width:220px}.max-w-\[520px\]{max-width:520px}.max-w-\[560px\]{max-width:560px}.max-w-\[620px\]{max-width:620px}.max-w-\[660px\]{max-width:660px}.max-w-\[720px\]{max-width:720px}.max-w-\[1600px\]{max-width:1600px}.max-w-full{max-width:100%}.min-w-0{min-width:0}.flex-1{flex:1}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-\[1px\]{--tw-translate-y:1px;translate:var(--tw-translate-x) var(--tw-translate-y)}.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-flash{animation:var(--animate-flash)}.animate-pulse{animation:var(--animate-pulse)}.cursor-default{cursor:default}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-y{resize:vertical}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[1fr_128px_auto\]{grid-template-columns:1fr 128px auto}.grid-cols-\[1fr_auto\]{grid-template-columns:1fr auto}.grid-cols-\[132px_1fr_92px_104px\]{grid-template-columns:132px 1fr 92px 104px}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.grid-cols-\[auto_auto_1fr_auto\]{grid-template-columns:auto auto 1fr auto}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.content-start{align-content:flex-start}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-items-start{justify-items:start}.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-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-3\.5{gap:calc(var(--spacing) * 3.5)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-\[3px\]{gap:3px}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-x-6{column-gap:calc(var(--spacing) * 6)}.gap-x-8{column-gap:calc(var(--spacing) * 8)}.gap-y-1{row-gap:var(--spacing)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.gap-y-3{row-gap:calc(var(--spacing) * 3)}.gap-y-5{row-gap:calc(var(--spacing) * 5)}.gap-y-6{row-gap:calc(var(--spacing) * 6)}:where(.divide-x>:not(:last-child)){--tw-divide-x-reverse:0;border-inline-style:var(--tw-border-style);border-inline-start-width:calc(1px * var(--tw-divide-x-reverse));border-inline-end-width:calc(1px * calc(1 - var(--tw-divide-x-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:var(--color-border)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-x-hidden{overflow-x:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[2px\]{border-radius:2px}.rounded-\[3px\]{border-radius:3px}.rounded-\[5px\]{border-radius:5px}.rounded-\[var\(--radius-panel\)\]{border-radius:var(--radius-panel)}.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-t-\[var\(--radius-panel\)\]{border-top-left-radius:var(--radius-panel);border-top-right-radius:var(--radius-panel)}.rounded-t-sm{border-top-left-radius:var(--radius-sm);border-top-right-radius:var(--radius-sm)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-accent{border-color:var(--color-accent)}.border-accent\/35{border-color:#feb15759}@supports (color:color-mix(in lab, red, red)){.border-accent\/35{border-color:color-mix(in oklab, var(--color-accent) 35%, transparent)}}.border-accent\/40{border-color:#feb15766}@supports (color:color-mix(in lab, red, red)){.border-accent\/40{border-color:color-mix(in oklab, var(--color-accent) 40%, transparent)}}.border-accent\/45{border-color:#feb15773}@supports (color:color-mix(in lab, red, red)){.border-accent\/45{border-color:color-mix(in oklab, var(--color-accent) 45%, transparent)}}.border-accent\/50{border-color:#feb15780}@supports (color:color-mix(in lab, red, red)){.border-accent\/50{border-color:color-mix(in oklab, var(--color-accent) 50%, transparent)}}.border-accent\/60{border-color:#feb15799}@supports (color:color-mix(in lab, red, red)){.border-accent\/60{border-color:color-mix(in oklab, var(--color-accent) 60%, transparent)}}.border-border{border-color:var(--color-border)}.border-border-strong{border-color:var(--color-border-strong)}.border-border\/60{border-color:#2b292799}@supports (color:color-mix(in lab, red, red)){.border-border\/60{border-color:color-mix(in oklab, var(--color-border) 60%, transparent)}}.border-danger\/40{border-color:#ff808066}@supports (color:color-mix(in lab, red, red)){.border-danger\/40{border-color:color-mix(in oklab, var(--color-danger) 40%, transparent)}}.border-danger\/50{border-color:#ff808080}@supports (color:color-mix(in lab, red, red)){.border-danger\/50{border-color:color-mix(in oklab, var(--color-danger) 50%, transparent)}}.border-ok\/40{border-color:#4fbf6b66}@supports (color:color-mix(in lab, red, red)){.border-ok\/40{border-color:color-mix(in oklab, var(--color-ok) 40%, transparent)}}.border-premium\/60{border-color:#4d5cf099}@supports (color:color-mix(in lab, red, red)){.border-premium\/60{border-color:color-mix(in oklab, var(--color-premium) 60%, transparent)}}.border-transparent{border-color:#0000}.border-warn\/40{border-color:#e0a33c66}@supports (color:color-mix(in lab, red, red)){.border-warn\/40{border-color:color-mix(in oklab, var(--color-warn) 40%, transparent)}}.border-warn\/50{border-color:#e0a33c80}@supports (color:color-mix(in lab, red, red)){.border-warn\/50{border-color:color-mix(in oklab, var(--color-warn) 50%, transparent)}}.border-l-accent{border-left-color:var(--color-accent)}.bg-accent{background-color:var(--color-accent)}.bg-accent\/5{background-color:#feb1570d}@supports (color:color-mix(in lab, red, red)){.bg-accent\/5{background-color:color-mix(in oklab, var(--color-accent) 5%, transparent)}}.bg-accent\/10{background-color:#feb1571a}@supports (color:color-mix(in lab, red, red)){.bg-accent\/10{background-color:color-mix(in oklab, var(--color-accent) 10%, transparent)}}.bg-accent\/15{background-color:#feb15726}@supports (color:color-mix(in lab, red, red)){.bg-accent\/15{background-color:color-mix(in oklab, var(--color-accent) 15%, transparent)}}.bg-accent\/25{background-color:#feb15740}@supports (color:color-mix(in lab, red, red)){.bg-accent\/25{background-color:color-mix(in oklab, var(--color-accent) 25%, transparent)}}.bg-accent\/40{background-color:#feb15766}@supports (color:color-mix(in lab, red, red)){.bg-accent\/40{background-color:color-mix(in oklab, var(--color-accent) 40%, transparent)}}.bg-accent\/50{background-color:#feb15780}@supports (color:color-mix(in lab, red, red)){.bg-accent\/50{background-color:color-mix(in oklab, var(--color-accent) 50%, transparent)}}.bg-accent\/70{background-color:#feb157b3}@supports (color:color-mix(in lab, red, red)){.bg-accent\/70{background-color:color-mix(in oklab, var(--color-accent) 70%, transparent)}}.bg-accent\/75{background-color:#feb157bf}@supports (color:color-mix(in lab, red, red)){.bg-accent\/75{background-color:color-mix(in oklab, var(--color-accent) 75%, transparent)}}.bg-accent\/\[0\.07\]{background-color:#feb15712}@supports (color:color-mix(in lab, red, red)){.bg-accent\/\[0\.07\]{background-color:color-mix(in oklab, var(--color-accent) 7.0%, transparent)}}.bg-accent\/\[0\.08\]{background-color:#feb15714}@supports (color:color-mix(in lab, red, red)){.bg-accent\/\[0\.08\]{background-color:color-mix(in oklab, var(--color-accent) 8%, transparent)}}.bg-bg{background-color:var(--color-bg)}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab, var(--color-black) 50%, transparent)}}.bg-border\/60{background-color:#2b292799}@supports (color:color-mix(in lab, red, red)){.bg-border\/60{background-color:color-mix(in oklab, var(--color-border) 60%, transparent)}}.bg-danger{background-color:var(--color-danger)}.bg-danger\/10{background-color:#ff80801a}@supports (color:color-mix(in lab, red, red)){.bg-danger\/10{background-color:color-mix(in oklab, var(--color-danger) 10%, transparent)}}.bg-fg-faint{background-color:var(--color-fg-faint)}.bg-fg-faint\/30{background-color:#837f784d}@supports (color:color-mix(in lab, red, red)){.bg-fg-faint\/30{background-color:color-mix(in oklab, var(--color-fg-faint) 30%, transparent)}}.bg-ok{background-color:var(--color-ok)}.bg-ok\/10{background-color:#4fbf6b1a}@supports (color:color-mix(in lab, red, red)){.bg-ok\/10{background-color:color-mix(in oklab, var(--color-ok) 10%, transparent)}}.bg-panel{background-color:var(--color-panel)}.bg-panel-2{background-color:var(--color-panel-2)}.bg-panel-2\/30{background-color:#2624224d}@supports (color:color-mix(in lab, red, red)){.bg-panel-2\/30{background-color:color-mix(in oklab, var(--color-panel-2) 30%, transparent)}}.bg-panel-2\/50{background-color:#26242280}@supports (color:color-mix(in lab, red, red)){.bg-panel-2\/50{background-color:color-mix(in oklab, var(--color-panel-2) 50%, transparent)}}.bg-panel-2\/60{background-color:#26242299}@supports (color:color-mix(in lab, red, red)){.bg-panel-2\/60{background-color:color-mix(in oklab, var(--color-panel-2) 60%, transparent)}}.bg-panel\/40{background-color:#211f1d66}@supports (color:color-mix(in lab, red, red)){.bg-panel\/40{background-color:color-mix(in oklab, var(--color-panel) 40%, transparent)}}.bg-panel\/70{background-color:#211f1db3}@supports (color:color-mix(in lab, red, red)){.bg-panel\/70{background-color:color-mix(in oklab, var(--color-panel) 70%, transparent)}}.bg-premium{background-color:var(--color-premium)}.bg-premium-strong{background-color:var(--color-premium-strong)}.bg-premium\/75{background-color:#4d5cf0bf}@supports (color:color-mix(in lab, red, red)){.bg-premium\/75{background-color:color-mix(in oklab, var(--color-premium) 75%, transparent)}}.bg-transparent{background-color:#0000}.bg-warn{background-color:var(--color-warn)}.bg-warn\/10{background-color:#e0a33c1a}@supports (color:color-mix(in lab, red, red)){.bg-warn\/10{background-color:color-mix(in oklab, var(--color-warn) 10%, transparent)}}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-panel{--tw-gradient-from:var(--color-panel);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.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-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.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)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-10{padding-block:calc(var(--spacing) * 10)}.py-\[1px\]{padding-block:1px}.py-\[3px\]{padding-block:3px}.py-px{padding-block:1px}.pt-1{padding-top:var(--spacing)}.pt-1\.5{padding-top:calc(var(--spacing) * 1.5)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-16{padding-top:calc(var(--spacing) * 16)}.pt-24{padding-top:calc(var(--spacing) * 24)}.pt-\[10vh\]{padding-top:10vh}.pt-\[12vh\]{padding-top:12vh}.pt-\[14vh\]{padding-top:14vh}.pr-1{padding-right:var(--spacing)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pr-4{padding-right:calc(var(--spacing) * 4)}.pb-0\.5{padding-bottom:calc(var(--spacing) * .5)}.pb-1{padding-bottom:var(--spacing)}.pb-1\.5{padding-bottom:calc(var(--spacing) * 1.5)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.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)}.pl-3\.5{padding-left:calc(var(--spacing) * 3.5)}.pl-5{padding-left:calc(var(--spacing) * 5)}.pl-7{padding-left:calc(var(--spacing) * 7)}.pl-\[7\.5rem\]{padding-left:7.5rem}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.text-\[14px\]{font-size:14px}.text-\[15px\]{font-size:15px}.text-\[16px\]{font-size:16px}.text-\[17px\]{font-size:17px}.text-\[22px\]{font-size:22px}.text-\[24px\]{font-size:24px}.text-\[34px\]{font-size:34px}.leading-4{--tw-leading:calc(var(--spacing) * 4);line-height:calc(var(--spacing) * 4)}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-\[1\.1\]{--tw-leading:1.1;line-height:1.1}.leading-\[1\.4\]{--tw-leading:1.4;line-height:1.4}.leading-\[1\.05\]{--tw-leading:1.05;line-height:1.05}.leading-\[1\.35\]{--tw-leading:1.35;line-height:1.35}.leading-\[1\.45\]{--tw-leading:1.45;line-height:1.45}.leading-\[1\.55\]{--tw-leading:1.55;line-height:1.55}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.01em\]{--tw-tracking:-.01em;letter-spacing:-.01em}.tracking-\[0\.08em\]{--tw-tracking:.08em;letter-spacing:.08em}.tracking-\[0\.12em\]{--tw-tracking:.12em;letter-spacing:.12em}.tracking-normal{--tw-tracking:var(--tracking-normal);letter-spacing:var(--tracking-normal)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent{color:var(--color-accent)}.text-bg{color:var(--color-bg)}.text-danger{color:var(--color-danger)}.text-fg{color:var(--color-fg)}.text-fg-faint{color:var(--color-fg-faint)}.text-fg-muted{color:var(--color-fg-muted)}.text-info{color:var(--color-info)}.text-ok{color:var(--color-ok)}.text-panel{color:var(--color-panel)}.text-premium-strong{color:var(--color-premium-strong)}.text-warn{color:var(--color-warn)}.text-white{color:var(--color-white)}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.no-underline{text-decoration-line:none}.underline{text-decoration-line:underline}.accent-\[var\(--color-accent\)\]{accent-color:var(--color-accent)}.opacity-35{opacity:.35}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.shadow-\[var\(--shadow-panel\)\]{--tw-shadow:var(--shadow-panel);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)}.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-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.ring-offset-panel{--tw-ring-offset-color:var(--color-panel)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.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{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.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))}.select-none{-webkit-user-select:none;user-select:none}.group-open\:rotate-90:is(:where(.group):is([open],:popover-open,:open) *){rotate:90deg}@media (hover:hover){.group-hover\:text-accent-strong:is(:where(.group):hover *){color:var(--color-accent-strong)}.group-hover\:text-fg:is(:where(.group):hover *){color:var(--color-fg)}}.marker\:content-none ::marker{--tw-content:none;content:none}.marker\:content-none::marker{--tw-content:none;content:none}.marker\:content-none ::-webkit-details-marker{--tw-content:none;content:none}.marker\:content-none::-webkit-details-marker{--tw-content:none;content:none}.first\:mt-0:first-child{margin-top:0}.first\:border-t-0:first-child{border-top-style:var(--tw-border-style);border-top-width:0}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}@media (hover:hover){.hover\:border-accent\/50:hover{border-color:#feb15780}@supports (color:color-mix(in lab, red, red)){.hover\:border-accent\/50:hover{border-color:color-mix(in oklab, var(--color-accent) 50%, transparent)}}.hover\:border-border-strong:hover{border-color:var(--color-border-strong)}.hover\:border-fg-faint:hover{border-color:var(--color-fg-faint)}.hover\:bg-accent\/10:hover{background-color:#feb1571a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/10:hover{background-color:color-mix(in oklab, var(--color-accent) 10%, transparent)}}.hover\:bg-accent\/20:hover{background-color:#feb15733}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/20:hover{background-color:color-mix(in oklab, var(--color-accent) 20%, transparent)}}.hover\:bg-accent\/25:hover{background-color:#feb15740}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/25:hover{background-color:color-mix(in oklab, var(--color-accent) 25%, transparent)}}.hover\:bg-accent\/90:hover{background-color:#feb157e6}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/90:hover{background-color:color-mix(in oklab, var(--color-accent) 90%, transparent)}}.hover\:bg-accent\/\[0\.16\]:hover{background-color:#feb15729}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/\[0\.16\]:hover{background-color:color-mix(in oklab, var(--color-accent) 16%, transparent)}}.hover\:bg-danger\/10:hover{background-color:#ff80801a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-danger\/10:hover{background-color:color-mix(in oklab, var(--color-danger) 10%, transparent)}}.hover\:bg-ok\/10:hover{background-color:#4fbf6b1a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-ok\/10:hover{background-color:color-mix(in oklab, var(--color-ok) 10%, transparent)}}.hover\:bg-panel:hover{background-color:var(--color-panel)}.hover\:bg-panel-2:hover{background-color:var(--color-panel-2)}.hover\:bg-panel-2\/50:hover{background-color:#26242280}@supports (color:color-mix(in lab, red, red)){.hover\:bg-panel-2\/50:hover{background-color:color-mix(in oklab, var(--color-panel-2) 50%, transparent)}}.hover\:bg-premium:hover{background-color:var(--color-premium)}.hover\:bg-warn\/20:hover{background-color:#e0a33c33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-warn\/20:hover{background-color:color-mix(in oklab, var(--color-warn) 20%, transparent)}}.hover\:text-accent:hover{color:var(--color-accent)}.hover\:text-accent-strong:hover{color:var(--color-accent-strong)}.hover\:text-fg:hover{color:var(--color-fg)}.hover\:text-fg-muted:hover{color:var(--color-fg-muted)}.hover\:no-underline:hover{text-decoration-line:none}.hover\:underline:hover{text-decoration-line:underline}.hover\:brightness-110:hover{--tw-brightness:brightness(110%);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,)}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-default:disabled{cursor:default}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media (width>=40rem){.sm\:inline{display:inline}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}:where(.sm\:divide-x>:not(:last-child)){--tw-divide-x-reverse:0;border-inline-style:var(--tw-border-style);border-inline-start-width:calc(1px * var(--tw-divide-x-reverse));border-inline-end-width:calc(1px * calc(1 - var(--tw-divide-x-reverse)))}:where(.sm\:divide-y-0>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(0px * var(--tw-divide-y-reverse));border-bottom-width:calc(0px * calc(1 - var(--tw-divide-y-reverse)))}}@media (width>=48rem){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (width>=64rem){.lg\:col-span-2{grid-column:span 2/span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.lg\:grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.lg\:grid-cols-\[1\.4fr_1fr_1fr_1fr_1fr_1fr\]{grid-template-columns:1.4fr 1fr 1fr 1fr 1fr 1fr}.lg\:grid-cols-\[minmax\(0\,1fr\)_260px\]{grid-template-columns:minmax(0,1fr) 260px}}@media (width>=80rem){.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}}[data-theme=light]{--color-bg:#faf9f7;--color-panel:#fff;--color-panel-2:#f2f0ec;--color-border:#e6e2db;--color-border-strong:#c9c3b8;--color-fg:#24211c;--color-fg-muted:#5f5a51;--color-fg-faint:#8a8479;--color-ok:#2e9e4f;--color-warn:#9a6700;--color-danger:#d64545;--color-info:#b8730d;--color-accent:#b8730d;--color-accent-strong:#8f5808;--color-premium:#3341d8;--color-premium-strong:#232fb0;--shadow-panel:0 8px 20px -14px #3c321e38}:root{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;background:var(--color-bg);color:var(--color-fg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;font-size:16px;line-height:1.45}[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}.num,.mono{font-family:var(--font-mono);font-variant-numeric:tabular-nums;font-feature-settings:"tnum" 1, "zero" 1}*{border-color:var(--color-border)}a:where(:not([class*=text-])){color:var(--color-info)}a{text-decoration:none}a.link:hover{text-decoration:underline}::selection{background:#feb15759}@supports (color:color-mix(in lab, red, red)){::selection{background:color-mix(in srgb, var(--color-accent) 35%, transparent)}}.graph-dot{transition:fill .45s}.graph-gate{transition:fill .45s,stroke .45s}.graph-verified{transform-box:fill-box;transform-origin:50%;animation:.55s cubic-bezier(.2,.7,.2,1) verifyPop}@keyframes verifyPop{0%{transform:scale(1)}40%{transform:scale(1.55)}to{transform:scale(1)}}.graph-breathe{transform-box:fill-box;transform-origin:50%;animation:2.8s ease-in-out infinite graphBreathe}@keyframes graphBreathe{0%,to{opacity:.9}50%{opacity:1;filter:drop-shadow(0 0 3px color-mix(in srgb, var(--color-ok) 55%, transparent))}}@media (prefers-reduced-motion:reduce){.graph-dot,.graph-gate{transition:none}.graph-verified,.graph-breathe{animation:none}}*{scrollbar-width:thin;scrollbar-color:var(--color-border-strong) transparent}.stale-dot{background:var(--color-warn);border-radius:9999px;width:6px;height:6px;display:inline-block}.input{background:var(--color-panel-2);border:1px solid var(--color-border-strong);color:var(--color-fg);font-family:var(--font-mono);border-radius:3px;width:100%;padding:4px 8px;font-size:12px}.input:focus{outline:1px solid var(--color-accent);border-color:var(--color-accent)}.skeleton-pulse{animation:1.4s ease-in-out infinite skeletonPulse}@keyframes skeletonPulse{0%,to{opacity:.5}50%{opacity:.9}}@media (prefers-reduced-motion:reduce){.skeleton-pulse{opacity:.6;animation:none}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@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-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@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 pulse{50%{opacity:.5}}@keyframes flash{0%{background-color:color-mix(in srgb, var(--color-accent) 22%, transparent)}to{background-color:#0000}}.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;text-decoration:overline double underline}.xterm-overline.xterm-underline-3{-webkit-text-decoration:overline wavy underline;text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{-webkit-text-decoration:overline dotted underline;text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{-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} diff --git a/internal/api/dist/assets/index-JiLc92x0.css b/internal/api/dist/assets/index-JiLc92x0.css deleted file mode 100644 index d9514b1..0000000 --- a/internal/api/dist/assets/index-JiLc92x0.css +++ /dev/null @@ -1 +0,0 @@ -@font-face{font-family:Hanken Grotesk Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(data:font/woff2;base64,d09GMgABAAAAAAaEABMAAAAADFgAAAYdAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhYbbhwoP0hWQVJpBmA/U1RBVIE4AFwvbBEICoJ8gkMLFAAwhCoBNgIkAyIEIAWGUAdiDAcbvgpRVHJOI/viwCYyfSFrJjFIG8raYpYj9+IeSF0s6zD+Lk/4OGrZHhHV+wvt2ffuWPwlA51lIICIosSVmyOKEs5Uzlx3NKeXIgn1ssCydUybDV0IHga+SszIyfrQe9bLTFNxjayzgs76hNsDoSYtRe32fiJ4gxBjrP8L+w//zzHjv7Yqyr9o2vOBDXhCo2jMtr4uwAK/gV1U0PxAq/EAD+yW9EoKOL1KLw8rHrFgCSgRTQRzBzpeXVhweEDlyfY8gIoOa2CQJzrTAHIIoitTMVV2dyFwpJ2iAEQTpSkhPitxD3YwuZHEagTcAhyKAcBmUyPdhTovJThOw6HYiaF2M/J7erdi2OUutor6ES6Ac88AvfZvKpb6fJoArohb524042j6Jij36NI7P8Pb7s721naN9gcTtcjXQP4l+8BKEzFVGMxxoHqlq8Ul4LGneFJBDFaOdKpLPcg8P14YSDwIcn75hdlyJLTBlZ4voL6tT46yC/njunXqpJ0/bSvmrH1o3kRlwZ+j0DBogkF3KbDRVBlbOc+fY5HVXwPoT9hfekPnyZMaEmenYLMSg5npqegFOsgXsBv1IoF9aIVfSCNHkk6+gIzILsiYuhWQCfUtZEpbkRntQxBZgw7MwFbMcRvwJrAnBlDqs7isLtL7pO84Xru1i7ah7tckH1Wreqq6K9u0amxU1bcff/s2Y1ni3rh2I8zHzqkm3PGvv3mzC6NDBz/UcOBIg+nm88rxN8MbdtypvHUL5o1c2zG0urYpRmW+VHZdiba6GXN/3v0B3i3nt4RBsbfAu8ftLqRcTIlZ4VYheFTAS5nXLS65VZrbuW3daF2Ze1ChyGXWZN6u9nUuH1LfyTERifZXEpIueMe28vF8FOoTnsONzw+1djo9P71lZGx1vM8mH/BhvSa2HDsRZ1+Ul+RmpnPOIaEuwWnZZdkgQWAAyCDDZ1wk+0sh7wseAAwA6UlHxbftCgYAAwKAgwIAEA7ACfHIRbV7J6dwF/ZzcRRmAjXUYKAGWAlDCCFmKnH+LJEQfHKEmVrfmKwSEab36AcubXQBoDYJV/aRV+funFD8wAXLSLYbwr9+DR+h/qZIKCfeqRG5ghHpdY0zcV2nuz5iJMhAFjaTDwOcoyKGG9JHrCfdp4cC+kCvUrxc7+bliIMiHj95sPIbUeWZEP/HLnN2tlr9EBeRiktHuWvErx98fRz1MuEvHO3FDRgtsSzL/P0hsDLK2n5/uHMOjvTst0HD6t+80ZN798j7j//kjqHxIOZDFPR/FxurFD6/HxGbB799RPHLx5F89MoBOub9jVuOWtmPH3o9H3r26DIuff+LqPLwff/xryDRmiAYmjxiK0GwS9XU+k8QpUrHsCTs4qH89Fv44ubWbQmOE51M7J8Pt8+h+NKt3zZpa2L9zZqcRlyEc4MaNGdfjQCxgIygn78ne4yAzcLWA3zAJ6RRGbijvHr1W+XN8ywrG0EoZSySb0/A9KsllI7Q/Pq8hLu76tfTy5cF4X8bQxTtYp2vr6/+1oI4AhgAlNYFryt62VaX9ktO6VsAeDLeWx6fff4vdV1ts7N6+gw9GCsQnqPB0QUttB9nEc7Aaf4XM0NQ90VJ+HV1rG04znGCmXcpPCA9+nxdMPgPlT7Dz83NMfZuMJaNeRqbc+tjd2QER/b0B44d7nv5Rif7VC8svYkx9SKWwb3YzN2M3cY8jSNLl+PYZqfjxNTxOLXVCmfmduDc0ty1kLbjeiGfIrDFJXWPTTMD5TKupR8cpZgJeXTofId8NoUj6E8XfAc2k4WPdbCberDYAp8Q7L5dUo8wE8cs9QINZYvwXKzvBS4v/n+fQZkGrrFysKEIuFBgjQpxiHH1XA+ZBI+C+oAoxhYKECc42rGOc8L4mYhsiThGfFjOcKmFubPpDgwnY1918Fwo8ouenDJxvGP96HFWJ28hiOy251oKjkcbGz2POMme8CTMThx6wqOPsFtPI6j6HhDyDTxFQYnL88FcXGAGHl3ZuueRbEuxbK6Hc84ZDvRrREtLzyjj8Xkd/uShR1b0sYd8Nh8/c8znxCnadxQcf2nFVWIyw1g+4StXav9j75s+CQAA)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Hanken Grotesk Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/hanken-grotesk-vietnamese-wght-normal-CHiFlh_0.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Hanken Grotesk Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/hanken-grotesk-latin-ext-wght-normal-Dg-wlmqe.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}@font-face{font-family:Hanken Grotesk Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/hanken-grotesk-latin-wght-normal-CaVRRdDk.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 Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(data:font/woff2;base64,d09GMgABAAAAAAfsABQAAAAAEAwAAAeCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhwbHhwoP0hWQVJbBmA/U1RBVIFiJyYAdC9qEQgKhGSEAAsgADCGCAE2AiQDOgQgBYlMB4EUDAcbLQ4onoexrSC/2ZyLAa8p8VHB8/x3Vue+V0hVJalMJg2nx/TCrQXxBeqLjQG7FyM1WEa/X1tEXN7cFz9EJEMmMUz3RihWSSKeQCbcIou0izz/C8v+fq3VfajEa9gDD11CImXS7qL/RJFVzC1qiB6KmKeD6TZdQ6IRGv78dL6uSVVCfgni5mzu7kcgQBgAEAQTQRCoL++STTYybkJxNfQxAAIAGu8OdEB9teW2jh4BpgDqFjAeSEByW3zFP0CBBgNMsMCGEDjgggdhiEAUAeIIED7ABTDUEnkIE9Q9ahFgKttcVhApo4ACB4qobHaccgDfEjFO6aaWUhjMLt2SyIvHKoDqoA4CSUwEIYQCEjhAO9R1G6keDeDZGjNo+AhxOjCEGTr1WeIF3kYBiLAOKvkJSMiKX0VdAyQt3SDJClCkxJCHkCzfqyVTriJZLcolS32JZHUekq2TYNkYtCtjYHMQXSxGjXDz2t/yLWXzDzxz+o3zFwDEaN23F+13pyMdQAEaSKAR9vcGq4A4MTSKCElGW+M7UcY7xqkggITb28ZJhlqc9q2twYKTt0NjixBgYvO9BIihEBLYuOFXQzfIQ7dXGUEEEgFDooBfAzqiQbpJrhiWSuKJCRFKYbHCyJKI2G5GiZbNAvgAu5pc3vwx4G+g3aDkhklABiSz0BICXrYghtYhx/cdJ+44rY2oZ0aMNRFz3VZjb6W33F3gzltqtOCV8tTHSpOeXuItfvr5lCdfzFpqtEitvqdcdGGFd28ZqqC0tPbeChGXgrIlnhSWu/eUso4uKWFLugyDzQJhflY4659+WjQ++6x72WUMv9G8mw6QJl7BVxX5fe/kpUsOvnZwee9uQ0cGXYd0o89XB2748sDSnt8d2VphdOTTgceDVvOds0v9P/s7HPq15aGun/6Vllb56f1dl0t1LejqrNkpdRZsG8TOnM5vkBG5oiVyVGnS8LHps5cfNWJs6qKPfaNSxiQNBUm3cKNWROr0GSur7Za31k1vieq7LH11VF+jXdRIasRKflc7jkobm1Z9te1IyZA0pDkhLR98+H37Zf1c/8at+dB7x+7GfVyTfJMPiYztsnl59Y5l4j+0n1RXlpHnF3Tq7HecmNF/CJodEMAikruxiyJaGLvHOdAfoA+oDvpjBm2b91cHGRZMU9n25xEU0A8fgEEAdKI3Q1iDtc034sug5YVMkE2jsE+BIkwSoQ3gxXMqz9tELp48bd0cFKOKS7xYjEuXBnZP5ia7DyiO/X/YI+PQSbt2uSdqAkWL9nQbV1XB94/+uPfdZz8dnXYFBYrcTl2SIR/ybxJNJPz/Gupb0JaZeens2ekC7EKr8t+Ls/P5VJPYJdHKyqfg2nqU6bhlidzcddQV/7MmecTzJ5VPcKXkNKSEogHjYFx6QZ7rQ+FSe8njaiNuOnXS8H2ScQ619c2mC3VTtauL0rRbXd/CkSOP37FY9Zkjz8+GibYUMOEWF+RdrFS8Ecv1SHOpPUPZGEIpjPvFyU5cXKjd6OXqorTqy9GwRd++HVufPGnVsW+aO3vggKZ18jR9sXaTC1PWTEsVUaK0FkNySbTQDqlm2PfDjZcu4aalnSLKjnOoYQ0nUlqqXcGpPu/4VgV/xU2pAqW4BW3qzhQ8/hFKhV2qE3+BKAtDqBXjfgnVdH4y0wg5tbVNRenNdTWOrenWLcupQdmsbq5b+18piTe/xRdp1xbILxNPJGInm2z6hoB21Lal0i+ePTtd7B45+3XhFJ329evskXm7qurUVREotqSluSo/L29d3qDhI4YOQqWhI4YNvBNfsMHeXKemXrxQfKeuPOGRVayA3JtkJKEgbPp+dXUDluddutRYLFoXGXWX6N3WFaGLbQtRSitVYNacTNSdy7AaG/HSaUEANcBoGXNdcZvZsOqQ1icBDv21/gzAoYPHH/WDW0qNR3QTYKEAEHig6o13NXbND06CQPlRtYjGNnSktRc09k1mAMDvAlDKfQjgy6fssInlfzmNAjKkDxoxHOBLdVRAIVt9j4qo+hA1w9T1aNBNTUOTTNUHLbqokE+UAfJXCIGw/IxCSL5GRUJeR40rL/UxTm4Q08H6MbCs70ObuNyIIXrINHQYInF06UUlevTjbQzTh5upiDMzMMogUtEnjPs/Y7jAHCJeB0GBHh04tC6FiB6ZFB1oArUSIoFoqhzCeAN6lHwm0T4C3VVPWvjpSMXReuWesMEcoqrmgtNBGd2noWeV0hNAz9rFeShNJxHGsPa3HXeKTk8b55hahySYHaYKKFFLpCfN8rsoaJn01CR04Gkc+5k7KVTCmClX8Q10HCrUEkVlSX+XO33oQR9609tJ516H497WSobWs5Up6TLaS10/dessIskgJSLiDlWvHVUywpkQ7hdPZqGyiEF0uVQerVcPamT1A3eKXdyI1vG9OoflrSXihZ1qqGE3nhmAgiIbRCQgPLEPtOM3UQwTLYaYYomNlpA44opnjV6jkD6id80OOrzf6BzmMD6eEa1zKyeYG1fzfEf16V6jw9XYOaar1/b2kP/IYX8oR2mcFvv2GtBV3JXgd437AQAA)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2)format("woff2-variations");unicode-range:U+370-377,U+37A-37F,U+384-38A,U+38C,U+38E-3A1,U+3A3-3FF}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/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}@font-face{font-family:JetBrains Mono Variable;font-style:normal;font-display:swap;font-weight:100 800;src:url(/assets/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}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--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-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:"Hanken Grotesk Variable", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;--font-mono:"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-normal:0em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--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-bg:#1b1b1a;--color-panel:#211f1d;--color-panel-2:#262422;--color-border:#2b2927;--color-border-strong:#3a3835;--color-fg:#e8e6e2;--color-fg-muted:#a9a59e;--color-fg-faint:#837f78;--color-ok:#4fbf6b;--color-warn:#e0a33c;--color-danger:#ff8080;--color-info:#feb157;--color-accent:#feb157;--color-accent-strong:#ffcb85;--color-premium:#4d5cf0;--color-premium-strong:#6f7bff;--shadow-panel:0 12px 32px -18px #000000a6;--radius-panel:6px;--animate-flash:flash .15s ease-out}}@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-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-x-0{inset-inline:0}.-top-1{top:calc(var(--spacing) * -1)}.-top-4{top:calc(var(--spacing) * -4)}.-top-\[7px\]{top:-7px}.top-0{top:0}.top-7{top:calc(var(--spacing) * 7)}.top-full{top:100%}.right-0{right:0}.right-3{right:calc(var(--spacing) * 3)}.bottom-0{bottom:0}.left-0{left:0}.left-0\.5{left:calc(var(--spacing) * .5)}.left-1\/2{left:50%}.left-3{left:calc(var(--spacing) * 3)}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.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-0{margin:0}.mx-3{margin-inline:calc(var(--spacing) * 3)}.mx-auto{margin-inline:auto}.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)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-auto{margin-top:auto}.-mr-1{margin-right:calc(var(--spacing) * -1)}.-mb-px{margin-bottom:-1px}.mb-1{margin-bottom:var(--spacing)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\.5{margin-bottom:calc(var(--spacing) * 2.5)}.ml-1{margin-left:var(--spacing)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3{margin-left:calc(var(--spacing) * 3)}.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}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1{height:var(--spacing)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-3{height:calc(var(--spacing) * 3)}.h-8{height:calc(var(--spacing) * 8)}.h-10{height:calc(var(--spacing) * 10)}.h-\[2px\]{height:2px}.h-\[14px\]{height:14px}.h-\[44px\]{height:44px}.h-\[70vh\]{height:70vh}.h-\[92px\]{height:92px}.h-\[168px\]{height:168px}.h-full{height:100%}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-96{max-height:calc(var(--spacing) * 96)}.max-h-\[40vh\]{max-height:40vh}.max-h-\[50vh\]{max-height:50vh}.max-h-\[70vh\]{max-height:70vh}.max-h-\[76vh\]{max-height:76vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[82vh\]{max-height:82vh}.max-h-\[420px\]{max-height:420px}.min-h-\[60px\]{min-height:60px}.min-h-\[70px\]{min-height:70px}.min-h-screen{min-height:100vh}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-3{width:calc(var(--spacing) * 3)}.w-9{width:calc(var(--spacing) * 9)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-16{width:calc(var(--spacing) * 16)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-32{width:calc(var(--spacing) * 32)}.w-36{width:calc(var(--spacing) * 36)}.w-44{width:calc(var(--spacing) * 44)}.w-\[268px\]{width:268px}.w-\[420px\]{width:420px}.w-\[440px\]{width:440px}.w-\[560px\]{width:560px}.w-\[620px\]{width:620px}.w-\[820px\]{width:820px}.w-auto{width:auto}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[12ch\]{max-width:12ch}.max-w-\[50\%\]{max-width:50%}.max-w-\[52ch\]{max-width:52ch}.max-w-\[52rem\]{max-width:52rem}.max-w-\[60ch\]{max-width:60ch}.max-w-\[92vw\]{max-width:92vw}.max-w-\[94vw\]{max-width:94vw}.max-w-\[220px\]{max-width:220px}.max-w-\[520px\]{max-width:520px}.max-w-\[560px\]{max-width:560px}.max-w-\[620px\]{max-width:620px}.max-w-\[660px\]{max-width:660px}.max-w-\[720px\]{max-width:720px}.max-w-\[1600px\]{max-width:1600px}.max-w-full{max-width:100%}.min-w-0{min-width:0}.flex-1{flex:1}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.-translate-x-1\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-\[1px\]{--tw-translate-y:1px;translate:var(--tw-translate-x) var(--tw-translate-y)}.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-flash{animation:var(--animate-flash)}.animate-pulse{animation:var(--animate-pulse)}.cursor-default{cursor:default}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-y{resize:vertical}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[1fr_128px_auto\]{grid-template-columns:1fr 128px auto}.grid-cols-\[1fr_auto\]{grid-template-columns:1fr auto}.grid-cols-\[132px_1fr_92px_104px\]{grid-template-columns:132px 1fr 92px 104px}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.grid-cols-\[auto_auto_1fr_auto\]{grid-template-columns:auto auto 1fr auto}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.content-start{align-content:flex-start}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-items-start{justify-items:start}.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-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-3\.5{gap:calc(var(--spacing) * 3.5)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-\[3px\]{gap:3px}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-x-6{column-gap:calc(var(--spacing) * 6)}.gap-x-8{column-gap:calc(var(--spacing) * 8)}.gap-y-1{row-gap:var(--spacing)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.gap-y-3{row-gap:calc(var(--spacing) * 3)}.gap-y-5{row-gap:calc(var(--spacing) * 5)}.gap-y-6{row-gap:calc(var(--spacing) * 6)}:where(.divide-x>:not(:last-child)){--tw-divide-x-reverse:0;border-inline-style:var(--tw-border-style);border-inline-start-width:calc(1px * var(--tw-divide-x-reverse));border-inline-end-width:calc(1px * calc(1 - var(--tw-divide-x-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:var(--color-border)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-hidden{overflow-x:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[2px\]{border-radius:2px}.rounded-\[3px\]{border-radius:3px}.rounded-\[5px\]{border-radius:5px}.rounded-\[var\(--radius-panel\)\]{border-radius:var(--radius-panel)}.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-t-\[var\(--radius-panel\)\]{border-top-left-radius:var(--radius-panel);border-top-right-radius:var(--radius-panel)}.rounded-t-sm{border-top-left-radius:var(--radius-sm);border-top-right-radius:var(--radius-sm)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-accent{border-color:var(--color-accent)}.border-accent\/35{border-color:#feb15759}@supports (color:color-mix(in lab, red, red)){.border-accent\/35{border-color:color-mix(in oklab, var(--color-accent) 35%, transparent)}}.border-accent\/40{border-color:#feb15766}@supports (color:color-mix(in lab, red, red)){.border-accent\/40{border-color:color-mix(in oklab, var(--color-accent) 40%, transparent)}}.border-accent\/45{border-color:#feb15773}@supports (color:color-mix(in lab, red, red)){.border-accent\/45{border-color:color-mix(in oklab, var(--color-accent) 45%, transparent)}}.border-accent\/50{border-color:#feb15780}@supports (color:color-mix(in lab, red, red)){.border-accent\/50{border-color:color-mix(in oklab, var(--color-accent) 50%, transparent)}}.border-accent\/60{border-color:#feb15799}@supports (color:color-mix(in lab, red, red)){.border-accent\/60{border-color:color-mix(in oklab, var(--color-accent) 60%, transparent)}}.border-border{border-color:var(--color-border)}.border-border-strong{border-color:var(--color-border-strong)}.border-border\/60{border-color:#2b292799}@supports (color:color-mix(in lab, red, red)){.border-border\/60{border-color:color-mix(in oklab, var(--color-border) 60%, transparent)}}.border-danger\/40{border-color:#ff808066}@supports (color:color-mix(in lab, red, red)){.border-danger\/40{border-color:color-mix(in oklab, var(--color-danger) 40%, transparent)}}.border-danger\/50{border-color:#ff808080}@supports (color:color-mix(in lab, red, red)){.border-danger\/50{border-color:color-mix(in oklab, var(--color-danger) 50%, transparent)}}.border-ok\/40{border-color:#4fbf6b66}@supports (color:color-mix(in lab, red, red)){.border-ok\/40{border-color:color-mix(in oklab, var(--color-ok) 40%, transparent)}}.border-premium\/60{border-color:#4d5cf099}@supports (color:color-mix(in lab, red, red)){.border-premium\/60{border-color:color-mix(in oklab, var(--color-premium) 60%, transparent)}}.border-transparent{border-color:#0000}.border-warn\/40{border-color:#e0a33c66}@supports (color:color-mix(in lab, red, red)){.border-warn\/40{border-color:color-mix(in oklab, var(--color-warn) 40%, transparent)}}.border-warn\/50{border-color:#e0a33c80}@supports (color:color-mix(in lab, red, red)){.border-warn\/50{border-color:color-mix(in oklab, var(--color-warn) 50%, transparent)}}.border-l-accent{border-left-color:var(--color-accent)}.bg-accent{background-color:var(--color-accent)}.bg-accent\/5{background-color:#feb1570d}@supports (color:color-mix(in lab, red, red)){.bg-accent\/5{background-color:color-mix(in oklab, var(--color-accent) 5%, transparent)}}.bg-accent\/10{background-color:#feb1571a}@supports (color:color-mix(in lab, red, red)){.bg-accent\/10{background-color:color-mix(in oklab, var(--color-accent) 10%, transparent)}}.bg-accent\/15{background-color:#feb15726}@supports (color:color-mix(in lab, red, red)){.bg-accent\/15{background-color:color-mix(in oklab, var(--color-accent) 15%, transparent)}}.bg-accent\/25{background-color:#feb15740}@supports (color:color-mix(in lab, red, red)){.bg-accent\/25{background-color:color-mix(in oklab, var(--color-accent) 25%, transparent)}}.bg-accent\/40{background-color:#feb15766}@supports (color:color-mix(in lab, red, red)){.bg-accent\/40{background-color:color-mix(in oklab, var(--color-accent) 40%, transparent)}}.bg-accent\/50{background-color:#feb15780}@supports (color:color-mix(in lab, red, red)){.bg-accent\/50{background-color:color-mix(in oklab, var(--color-accent) 50%, transparent)}}.bg-accent\/70{background-color:#feb157b3}@supports (color:color-mix(in lab, red, red)){.bg-accent\/70{background-color:color-mix(in oklab, var(--color-accent) 70%, transparent)}}.bg-accent\/75{background-color:#feb157bf}@supports (color:color-mix(in lab, red, red)){.bg-accent\/75{background-color:color-mix(in oklab, var(--color-accent) 75%, transparent)}}.bg-accent\/\[0\.07\]{background-color:#feb15712}@supports (color:color-mix(in lab, red, red)){.bg-accent\/\[0\.07\]{background-color:color-mix(in oklab, var(--color-accent) 7.0%, transparent)}}.bg-accent\/\[0\.08\]{background-color:#feb15714}@supports (color:color-mix(in lab, red, red)){.bg-accent\/\[0\.08\]{background-color:color-mix(in oklab, var(--color-accent) 8%, transparent)}}.bg-bg{background-color:var(--color-bg)}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab, var(--color-black) 50%, transparent)}}.bg-border\/60{background-color:#2b292799}@supports (color:color-mix(in lab, red, red)){.bg-border\/60{background-color:color-mix(in oklab, var(--color-border) 60%, transparent)}}.bg-danger{background-color:var(--color-danger)}.bg-danger\/10{background-color:#ff80801a}@supports (color:color-mix(in lab, red, red)){.bg-danger\/10{background-color:color-mix(in oklab, var(--color-danger) 10%, transparent)}}.bg-fg-faint{background-color:var(--color-fg-faint)}.bg-fg-faint\/30{background-color:#837f784d}@supports (color:color-mix(in lab, red, red)){.bg-fg-faint\/30{background-color:color-mix(in oklab, var(--color-fg-faint) 30%, transparent)}}.bg-ok{background-color:var(--color-ok)}.bg-ok\/10{background-color:#4fbf6b1a}@supports (color:color-mix(in lab, red, red)){.bg-ok\/10{background-color:color-mix(in oklab, var(--color-ok) 10%, transparent)}}.bg-panel{background-color:var(--color-panel)}.bg-panel-2{background-color:var(--color-panel-2)}.bg-panel-2\/30{background-color:#2624224d}@supports (color:color-mix(in lab, red, red)){.bg-panel-2\/30{background-color:color-mix(in oklab, var(--color-panel-2) 30%, transparent)}}.bg-panel-2\/50{background-color:#26242280}@supports (color:color-mix(in lab, red, red)){.bg-panel-2\/50{background-color:color-mix(in oklab, var(--color-panel-2) 50%, transparent)}}.bg-panel-2\/60{background-color:#26242299}@supports (color:color-mix(in lab, red, red)){.bg-panel-2\/60{background-color:color-mix(in oklab, var(--color-panel-2) 60%, transparent)}}.bg-panel\/40{background-color:#211f1d66}@supports (color:color-mix(in lab, red, red)){.bg-panel\/40{background-color:color-mix(in oklab, var(--color-panel) 40%, transparent)}}.bg-panel\/70{background-color:#211f1db3}@supports (color:color-mix(in lab, red, red)){.bg-panel\/70{background-color:color-mix(in oklab, var(--color-panel) 70%, transparent)}}.bg-premium{background-color:var(--color-premium)}.bg-premium-strong{background-color:var(--color-premium-strong)}.bg-premium\/75{background-color:#4d5cf0bf}@supports (color:color-mix(in lab, red, red)){.bg-premium\/75{background-color:color-mix(in oklab, var(--color-premium) 75%, transparent)}}.bg-transparent{background-color:#0000}.bg-warn{background-color:var(--color-warn)}.bg-warn\/10{background-color:#e0a33c1a}@supports (color:color-mix(in lab, red, red)){.bg-warn\/10{background-color:color-mix(in oklab, var(--color-warn) 10%, transparent)}}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-panel{--tw-gradient-from:var(--color-panel);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.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-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.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)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-10{padding-block:calc(var(--spacing) * 10)}.py-\[1px\]{padding-block:1px}.py-\[3px\]{padding-block:3px}.py-px{padding-block:1px}.pt-1{padding-top:var(--spacing)}.pt-1\.5{padding-top:calc(var(--spacing) * 1.5)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-16{padding-top:calc(var(--spacing) * 16)}.pt-24{padding-top:calc(var(--spacing) * 24)}.pt-\[10vh\]{padding-top:10vh}.pt-\[12vh\]{padding-top:12vh}.pt-\[14vh\]{padding-top:14vh}.pr-1{padding-right:var(--spacing)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pb-0\.5{padding-bottom:calc(var(--spacing) * .5)}.pb-1{padding-bottom:var(--spacing)}.pb-1\.5{padding-bottom:calc(var(--spacing) * 1.5)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.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)}.pl-3\.5{padding-left:calc(var(--spacing) * 3.5)}.pl-5{padding-left:calc(var(--spacing) * 5)}.pl-7{padding-left:calc(var(--spacing) * 7)}.pl-\[7\.5rem\]{padding-left:7.5rem}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.text-\[14px\]{font-size:14px}.text-\[15px\]{font-size:15px}.text-\[16px\]{font-size:16px}.text-\[17px\]{font-size:17px}.text-\[22px\]{font-size:22px}.text-\[24px\]{font-size:24px}.text-\[34px\]{font-size:34px}.leading-4{--tw-leading:calc(var(--spacing) * 4);line-height:calc(var(--spacing) * 4)}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-\[1\.1\]{--tw-leading:1.1;line-height:1.1}.leading-\[1\.4\]{--tw-leading:1.4;line-height:1.4}.leading-\[1\.05\]{--tw-leading:1.05;line-height:1.05}.leading-\[1\.35\]{--tw-leading:1.35;line-height:1.35}.leading-\[1\.45\]{--tw-leading:1.45;line-height:1.45}.leading-\[1\.55\]{--tw-leading:1.55;line-height:1.55}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.01em\]{--tw-tracking:-.01em;letter-spacing:-.01em}.tracking-\[0\.08em\]{--tw-tracking:.08em;letter-spacing:.08em}.tracking-\[0\.12em\]{--tw-tracking:.12em;letter-spacing:.12em}.tracking-normal{--tw-tracking:var(--tracking-normal);letter-spacing:var(--tracking-normal)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent{color:var(--color-accent)}.text-bg{color:var(--color-bg)}.text-danger{color:var(--color-danger)}.text-fg{color:var(--color-fg)}.text-fg-faint{color:var(--color-fg-faint)}.text-fg-muted{color:var(--color-fg-muted)}.text-info{color:var(--color-info)}.text-ok{color:var(--color-ok)}.text-panel{color:var(--color-panel)}.text-premium-strong{color:var(--color-premium-strong)}.text-warn{color:var(--color-warn)}.text-white{color:var(--color-white)}.lowercase{text-transform:lowercase}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.no-underline{text-decoration-line:none}.underline{text-decoration-line:underline}.accent-\[var\(--color-accent\)\]{accent-color:var(--color-accent)}.opacity-35{opacity:.35}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.shadow-\[var\(--shadow-panel\)\]{--tw-shadow:var(--shadow-panel);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)}.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-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.ring-offset-panel{--tw-ring-offset-color:var(--color-panel)}.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{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.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))}.select-none{-webkit-user-select:none;user-select:none}.group-open\:rotate-90:is(:where(.group):is([open],:popover-open,:open) *){rotate:90deg}@media (hover:hover){.group-hover\:text-accent-strong:is(:where(.group):hover *){color:var(--color-accent-strong)}.group-hover\:text-fg:is(:where(.group):hover *){color:var(--color-fg)}}.marker\:content-none ::marker{--tw-content:none;content:none}.marker\:content-none::marker{--tw-content:none;content:none}.marker\:content-none ::-webkit-details-marker{--tw-content:none;content:none}.marker\:content-none::-webkit-details-marker{--tw-content:none;content:none}.first\:mt-0:first-child{margin-top:0}.first\:border-t-0:first-child{border-top-style:var(--tw-border-style);border-top-width:0}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}@media (hover:hover){.hover\:border-accent\/50:hover{border-color:#feb15780}@supports (color:color-mix(in lab, red, red)){.hover\:border-accent\/50:hover{border-color:color-mix(in oklab, var(--color-accent) 50%, transparent)}}.hover\:border-border-strong:hover{border-color:var(--color-border-strong)}.hover\:border-fg-faint:hover{border-color:var(--color-fg-faint)}.hover\:bg-accent\/10:hover{background-color:#feb1571a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/10:hover{background-color:color-mix(in oklab, var(--color-accent) 10%, transparent)}}.hover\:bg-accent\/20:hover{background-color:#feb15733}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/20:hover{background-color:color-mix(in oklab, var(--color-accent) 20%, transparent)}}.hover\:bg-accent\/25:hover{background-color:#feb15740}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/25:hover{background-color:color-mix(in oklab, var(--color-accent) 25%, transparent)}}.hover\:bg-accent\/90:hover{background-color:#feb157e6}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/90:hover{background-color:color-mix(in oklab, var(--color-accent) 90%, transparent)}}.hover\:bg-accent\/\[0\.16\]:hover{background-color:#feb15729}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/\[0\.16\]:hover{background-color:color-mix(in oklab, var(--color-accent) 16%, transparent)}}.hover\:bg-danger\/10:hover{background-color:#ff80801a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-danger\/10:hover{background-color:color-mix(in oklab, var(--color-danger) 10%, transparent)}}.hover\:bg-ok\/10:hover{background-color:#4fbf6b1a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-ok\/10:hover{background-color:color-mix(in oklab, var(--color-ok) 10%, transparent)}}.hover\:bg-panel:hover{background-color:var(--color-panel)}.hover\:bg-panel-2:hover{background-color:var(--color-panel-2)}.hover\:bg-panel-2\/50:hover{background-color:#26242280}@supports (color:color-mix(in lab, red, red)){.hover\:bg-panel-2\/50:hover{background-color:color-mix(in oklab, var(--color-panel-2) 50%, transparent)}}.hover\:bg-premium:hover{background-color:var(--color-premium)}.hover\:bg-warn\/20:hover{background-color:#e0a33c33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-warn\/20:hover{background-color:color-mix(in oklab, var(--color-warn) 20%, transparent)}}.hover\:text-accent:hover{color:var(--color-accent)}.hover\:text-accent-strong:hover{color:var(--color-accent-strong)}.hover\:text-fg:hover{color:var(--color-fg)}.hover\:text-fg-muted:hover{color:var(--color-fg-muted)}.hover\:no-underline:hover{text-decoration-line:none}.hover\:underline:hover{text-decoration-line:underline}.hover\:brightness-110:hover{--tw-brightness:brightness(110%);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,)}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\:cursor-default:disabled{cursor:default}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media (width>=40rem){.sm\:inline{display:inline}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}:where(.sm\:divide-x>:not(:last-child)){--tw-divide-x-reverse:0;border-inline-style:var(--tw-border-style);border-inline-start-width:calc(1px * var(--tw-divide-x-reverse));border-inline-end-width:calc(1px * calc(1 - var(--tw-divide-x-reverse)))}:where(.sm\:divide-y-0>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(0px * var(--tw-divide-y-reverse));border-bottom-width:calc(0px * calc(1 - var(--tw-divide-y-reverse)))}}@media (width>=48rem){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (width>=64rem){.lg\:col-span-2{grid-column:span 2/span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.lg\:grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.lg\:grid-cols-\[1\.4fr_1fr_1fr_1fr_1fr_1fr\]{grid-template-columns:1.4fr 1fr 1fr 1fr 1fr 1fr}.lg\:grid-cols-\[minmax\(0\,1fr\)_260px\]{grid-template-columns:minmax(0,1fr) 260px}}@media (width>=80rem){.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}}[data-theme=light]{--color-bg:#faf9f7;--color-panel:#fff;--color-panel-2:#f2f0ec;--color-border:#e6e2db;--color-border-strong:#c9c3b8;--color-fg:#24211c;--color-fg-muted:#5f5a51;--color-fg-faint:#8a8479;--color-ok:#2e9e4f;--color-warn:#9a6700;--color-danger:#d64545;--color-info:#b8730d;--color-accent:#b8730d;--color-accent-strong:#8f5808;--color-premium:#3341d8;--color-premium-strong:#232fb0;--shadow-panel:0 8px 20px -14px #3c321e38}:root{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;background:var(--color-bg);color:var(--color-fg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;font-size:16px;line-height:1.45}[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}.num,.mono{font-family:var(--font-mono);font-variant-numeric:tabular-nums;font-feature-settings:"tnum" 1, "zero" 1}*{border-color:var(--color-border)}a:where(:not([class*=text-])){color:var(--color-info)}a{text-decoration:none}a.link:hover{text-decoration:underline}::selection{background:#feb15759}@supports (color:color-mix(in lab, red, red)){::selection{background:color-mix(in srgb, var(--color-accent) 35%, transparent)}}.graph-dot{transition:fill .45s}.graph-gate{transition:fill .45s,stroke .45s}.graph-verified{transform-box:fill-box;transform-origin:50%;animation:.55s cubic-bezier(.2,.7,.2,1) verifyPop}@keyframes verifyPop{0%{transform:scale(1)}40%{transform:scale(1.55)}to{transform:scale(1)}}.graph-breathe{transform-box:fill-box;transform-origin:50%;animation:2.8s ease-in-out infinite graphBreathe}@keyframes graphBreathe{0%,to{opacity:.9}50%{opacity:1;filter:drop-shadow(0 0 3px color-mix(in srgb, var(--color-ok) 55%, transparent))}}@media (prefers-reduced-motion:reduce){.graph-dot,.graph-gate{transition:none}.graph-verified,.graph-breathe{animation:none}}*{scrollbar-width:thin;scrollbar-color:var(--color-border-strong) transparent}.stale-dot{background:var(--color-warn);border-radius:9999px;width:6px;height:6px;display:inline-block}.input{background:var(--color-panel-2);border:1px solid var(--color-border-strong);color:var(--color-fg);font-family:var(--font-mono);border-radius:3px;width:100%;padding:4px 8px;font-size:12px}.input:focus{outline:1px solid var(--color-accent);border-color:var(--color-accent)}.skeleton-pulse{animation:1.4s ease-in-out infinite skeletonPulse}@keyframes skeletonPulse{0%,to{opacity:.5}50%{opacity:.9}}@media (prefers-reduced-motion:reduce){.skeleton-pulse{opacity:.6;animation:none}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@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-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@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-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 pulse{50%{opacity:.5}}@keyframes flash{0%{background-color:color-mix(in srgb, var(--color-accent) 22%, transparent)}to{background-color:#0000}}.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;text-decoration:overline double underline}.xterm-overline.xterm-underline-3{-webkit-text-decoration:overline wavy underline;text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{-webkit-text-decoration:overline dotted underline;text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{-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} diff --git a/internal/api/dist/assets/index-PB3QKXS-.js b/internal/api/dist/assets/index-PB3QKXS-.js new file mode 100644 index 0000000..fb35bf2 --- /dev/null +++ b/internal/api/dist/assets/index-PB3QKXS-.js @@ -0,0 +1,101 @@ +var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);(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 t=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function ee(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function re(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function k(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,k(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),k(o,r,i,``,function(e){return e})):o!=null&&(ee(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u{n.exports=t()})),r=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,ee());else{var t=n(l);t!==null&&ne(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&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?ee():S=!1}}}var ee;if(typeof y==`function`)ee=function(){y(D)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,te=O.port2;O.port1.onmessage=D,ee=function(){te.postMessage(null)}}else ee=function(){_(D,0)};function ne(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,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ee()))),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}}}})),i=e(((e,t)=>{t.exports=r()})),a=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=a()})),s=e((e=>{var t=i(),r=n(),a=o();function s(e){var t=`https://react.dev/errors/`+e;if(1oe||(e.current=ae[oe],ae[oe]=null,oe--)}function F(e,t){oe++,ae[oe]=e.current,e.current=t}var ce=P(null),le=P(null),ue=P(null),de=P(null);function fe(e,t){switch(F(ue,t),F(le,e),F(ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}se(ce),F(ce,e)}function pe(){se(ce),se(le),se(ue)}function me(e){e.memoizedState!==null&&F(de,e);var t=ce.current,n=Hd(t,e.type);t!==n&&(F(le,e),F(ce,n))}function he(e){le.current===e&&(se(ce),se(le)),de.current===e&&(se(de),Qf._currentValue=ie)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-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{ye=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ve(n):``}function I(e,t){switch(e.tag){case 26:case 27:case 5:return ve(e.type);case 16:return ve(`Lazy`);case 13:return e.child!==t&&t!==null?ve(`Suspense Fallback`):ve(`Suspense`);case 19:return ve(`SuspenseList`);case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return ve(`Activity`);default:return``}}function xe(e){try{var t=``,n=null;do t+=I(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var L=Object.prototype.hasOwnProperty,Se=t.unstable_scheduleCallback,Ce=t.unstable_cancelCallback,we=t.unstable_shouldYield,Te=t.unstable_requestPaint,Ee=t.unstable_now,De=t.unstable_getCurrentPriorityLevel,Oe=t.unstable_ImmediatePriority,ke=t.unstable_UserBlockingPriority,Ae=t.unstable_NormalPriority,je=t.unstable_LowPriority,Me=t.unstable_IdlePriority,Ne=t.log,Pe=t.unstable_setDisableYieldValue,Fe=null,Ie=null;function Le(e){if(typeof Ne==`function`&&Pe(e),Ie&&typeof Ie.setStrictMode==`function`)try{Ie.setStrictMode(Fe,e)}catch{}}var Re=Math.clz32?Math.clz32:Ve,ze=Math.log,Be=Math.LN2;function Ve(e){return e>>>=0,e===0?32:31-(ze(e)/Be|0)|0}var He=256,Ue=262144,We=4194304;function Ge(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&261888;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 Ke(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=Ge(n))):i=Ge(o):i=Ge(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ge(n))):i=Ge(o)):i=Ge(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 qe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Je(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ye(){var e=We;return We<<=1,!(We&62914560)&&(We=4194304),e}function Xe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ze(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Qe(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`u`||window.document===void 0||window.document.createElement===void 0),ln=!1;if(cn)try{var un={};Object.defineProperty(un,"passive",{get:function(){ln=!0}}),window.addEventListener(`test`,un,un),window.removeEventListener(`test`,un,un)}catch{ln=!1}var dn=null,fn=null,pn=null;function mn(){if(pn)return pn;var e,t=fn,n=t.length,r,i=`value`in dn?dn.value:dn.textContent,a=i.length;for(e=0;e=Kn),Yn=` `,Xn=!1;function Zn(e,t){switch(e){case`keyup`:return Wn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Qn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var $n=!1;function er(e,t){switch(e){case`compositionend`:return Qn(t);case`keypress`:return t.which===32?(Xn=!0,Yn):null;case`textInput`:return e=t.data,e===Yn&&Xn?null:e;default:return null}}function tr(e,t){if($n)return e===`compositionend`||!Gn&&Zn(e,t)?(e=mn(),pn=fn=dn=null,$n=!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=Cr(n)}}function Tr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Tr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Er(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ft(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=Ft(e.document)}return t}function Dr(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 Or=cn&&`documentMode`in document&&11>=document.documentMode,kr=null,Ar=null,jr=null,Mr=!1;function Nr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Mr||kr==null||kr!==Ft(r)||(r=kr,`selectionStart`in r&&Dr(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}),jr&&Sr(jr,r)||(jr=r,r=Td(Ar,`onSelect`),0>=o,i-=o,wi=1<<32-Re(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),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),H&&Ei(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),o=a(y,o,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),H&&Ei(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return H&&Ei(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(v.key===null?g:v.key),o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),H&&Ei(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===y&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case _:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===y){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===ee&&wa(l)===r.type){n(e,r.sibling),c=i(r,a.props),ja(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===y?(c=di(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=ui(a.type,a.key,a.props,null,e.mode,c),ja(c,a),c.return=e,e=c)}return o(e);case v:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=mi(a,e.mode,c),c.return=e,e=c}return o(e);case ee:return a=wa(a),b(e,r,a,c)}if(j(a))return h(e,r,a,c);if(re(a)){if(l=re(a),typeof l!=`function`)throw Error(s(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,Aa(a),c);if(a.$$typeof===C)return b(e,r,$i(e,a),c);Ma(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=fi(a,e.mode,c),c.return=e,e=c),o(e)):n(e,r)}return function(e,t,n,r){try{ka=0;var i=b(e,t,n,r);return Oa=null,i}catch(t){if(t===ya||t===ba)throw t;var a=B(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Pa=Na(!0),Fa=Na(!1),Ia=!1;function La(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ra(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 za(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function W(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Il&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ii(e),ri(e,null,n),t}return ei(e,r,t,n),ii(e)}function Ba(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,et(e,n)}}function Va(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;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ha=!1;function Ua(){if(Ha){var e=ua;if(e!==null)throw e}}function Wa(e,t,n,r){Ha=!1;var i=e.updateQueue;Ia=!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?(X&f)===f:(r&f)===f){f!==0&&f===la&&(Ha=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Ia=!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),Gl|=o,e.lanes=o,e.memoizedState=d}}function Ga(e,t){if(typeof e!=`function`)throw Error(s(191,e));e.call(t)}function Ka(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=M.T,s={};M.T=s,js(e,!1,t,n);try{var c=i(),l=M.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?As(e,t,pa(c,r),fu(e)):As(e,t,r,fu(e))}catch(n){As(e,t,{then:function(){},status:`rejected`,reason:n},fu())}finally{N.p=a,o!==null&&s.types!==null&&(o.types=s.types),M.T=o}}function bs(){}function xs(e,t,n,r){if(e.tag!==5)throw Error(s(476));var i=Ss(e).queue;ys(e,i,t,ie,n===null?bs:function(){return Cs(e),n(r)})}function Ss(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ie,baseState:ie,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:ie},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Cs(e){var t=Ss(e);t.next===null&&(t=e.alternate.memoizedState),As(e,t.next.queue,{},fu())}function ws(){return Qi(Qf)}function Ts(){return Oo().memoizedState}function Es(){return Oo().memoizedState}function Ds(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=fu();e=za(n);var r=W(t,e,n);r!==null&&(mu(r,t,n),Ba(r,t,n)),t={cache:aa()},e.payload=t;return}t=t.return}}function Os(e,t,n){var r=fu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ms(e)?Ns(t,n):(n=ti(e,t,n,r),n!==null&&(mu(n,e,r),Ps(n,t,r)))}function ks(e,t,n){As(e,t,n,fu())}function As(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ms(e))Ns(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,xr(s,o))return ei(e,t,i,0),Ll===null&&$r(),!1}catch{}if(n=ti(e,t,i,r),n!==null)return mu(n,e,r),Ps(n,t,r),!0}return!1}function js(e,t,n,r){if(r={lane:2,revertLane:ud(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ms(e)){if(t)throw Error(s(479))}else t=ti(e,n,r,2),t!==null&&mu(t,e,2)}function Ms(e){var t=e.alternate;return e===G||t!==null&&t===G}function Ns(e,t){fo=uo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ps(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,et(e,n)}}var Fs={readContext:Qi,use:jo,useCallback:vo,useContext:vo,useEffect:vo,useImperativeHandle:vo,useLayoutEffect:vo,useInsertionEffect:vo,useMemo:vo,useReducer:vo,useRef:vo,useState:vo,useDebugValue:vo,useDeferredValue:vo,useTransition:vo,useSyncExternalStore:vo,useId:vo,useHostTransitionStatus:vo,useFormState:vo,useActionState:vo,useOptimistic:vo,useMemoCache:vo,useCacheRefresh:vo};Fs.useEffectEvent=vo;var Is={readContext:Qi,use:jo,useCallback:function(e,t){return Do().memoizedState=[e,t===void 0?null:t],e},useContext:Qi,useEffect:ss,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),as(4194308,4,fs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return as(4194308,4,e,t)},useInsertionEffect:function(e,t){as(4,2,e,t)},useMemo:function(e,t){var n=Do();t=t===void 0?null:t;var r=e();if(po){Le(!0);try{e()}finally{Le(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Do();if(n!==void 0){var i=n(t);if(po){Le(!0);try{n(t)}finally{Le(!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=Os.bind(null,G,e),[r.memoizedState,e]},useRef:function(e){var t=Do();return e={current:e},t.memoizedState=e},useState:function(e){e=Uo(e);var t=e.queue,n=ks.bind(null,G,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ms,useDeferredValue:function(e,t){return _s(Do(),e,t)},useTransition:function(){var e=Uo(!1);return e=ys.bind(null,G,e.queue,!0,!1),Do().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=G,i=Do();if(H){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),Ll===null)throw Error(s(349));X&127||Ro(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,ss(Bo.bind(null,r,a,e),[e]),r.flags|=2048,rs(9,{destroy:void 0},zo.bind(null,r,a,n,t),null),n},useId:function(){var e=Do(),t=Ll.identifierPrefix;if(H){var n=Ti,r=wi;n=(r&~(1<<32-Re(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=mo++,0<\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?o.createElement(`select`,{is:r.is}):o.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?o.createElement(i,{is:r.is}):o.createElement(i)}}a[st]=t,a[ct]=r;a:for(o=t.child;o!==null;){if(o.tag===5||o.tag===6)a.appendChild(o.stateNode);else if(o.tag!==4&&o.tag!==27&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break a;for(;o.sibling===null;){if(o.return===null||o.return===t)break a;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=a;a:switch(Pd(a,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&&kc(t)}}return J(t),Ac(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&kc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(s(166));if(e=ue.current,Ri(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=V,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[st]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Fi(t,!0)}else e=Bd(e).createTextNode(r),e[st]=t,t.stateNode=e}return J(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ri(t),n!==null){if(e===null){if(!r)throw Error(s(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(s(557));e[st]=t}else zi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;J(t),e=!1}else n=Bi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(io(t),t):(io(t),null);if(t.flags&128)throw Error(s(558))}return J(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Ri(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(s(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(s(317));i[st]=t}else zi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;J(t),i=!1}else i=Bi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(io(t),t):(io(t),null)}return io(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),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Mc(t,t.updateQueue),J(t),null);case 4:return pe(),e===null&&xd(t.stateNode.containerInfo),J(t),null;case 10:return Ki(t.type),J(t),null;case 19:if(se(ao),r=t.memoizedState,r===null)return J(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)Nc(r,!1);else{if(Wl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=oo(e),a!==null){for(t.flags|=128,Nc(r,!1),e=a.updateQueue,t.updateQueue=e,Mc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)li(n,e),n=n.sibling;return F(ao,ao.current&1|2),H&&Ei(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ee()>Z&&(t.flags|=128,i=!0,Nc(r,!1),t.lanes=4194304)}}else{if(!i){if(e=oo(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Mc(t,e),Nc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!H)return J(t),null}else 2*Ee()-r.renderingStartTime>Z&&n!==536870912&&(t.flags|=128,i=!0,Nc(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(J(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ee(),e.sibling=null,n=ao.current,F(ao,i?n&1|2:n&1),H&&Ei(t,r.treeForkCount),e);case 22:case 23:return io(t),Za(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(J(t),t.subtreeFlags&6&&(t.flags|=8192)):J(t),n=t.updateQueue,n!==null&&Mc(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&&se(ha),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ki(ia),J(t),null;case 25:return null;case 30:return null}throw Error(s(156,t.tag))}function Fc(e,t){switch(ki(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ki(ia),pe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return he(t),null;case 31:if(t.memoizedState!==null){if(io(t),t.alternate===null)throw Error(s(340));zi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));zi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return se(ao),null;case 4:return pe(),null;case 10:return Ki(t.type),null;case 22:case 23:return io(t),Za(),e!==null&&se(ha),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ki(ia),null;case 25:return null;default:return null}}function Ic(e,t){switch(ki(t),t.tag){case 3:Ki(ia),pe();break;case 26:case 27:case 5:he(t);break;case 4:pe();break;case 31:t.memoizedState!==null&&io(t);break;case 13:io(t);break;case 19:se(ao);break;case 10:Ki(t.type);break;case 22:case 23:io(t),Za(),e!==null&&se(ha);break;case 24:Ki(ia)}}function Lc(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){Q(t,t.return,e)}}function Rc(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){Q(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Q(t,t.return,e)}}function zc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ka(t,n)}catch(t){Q(e,e.return,t)}}}function Bc(e,t,n){n.props=Us(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Q(e,t,n)}}function Vc(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:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Q(e,t,n)}}function Hc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Q(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){Q(e,t,n)}else n.current=null}}function Uc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Q(e,e.return,t)}}function Wc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[ct]=t}catch(t){Q(e,e.return,t)}}function Gc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Kc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Gc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function qc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Qt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(qc(e,t,n),e=e.sibling;e!==null;)qc(e,t,n),e=e.sibling}function Jc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Jc(e,t,n),e=e.sibling;e!==null;)Jc(e,t,n),e=e.sibling}function Yc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[st]=e,t[ct]=n}catch(t){Q(e,e.return,t)}}var Xc=!1,Zc=!1,Qc=!1,$c=typeof WeakSet==`function`?WeakSet:Set,el=null;function tl(e,t){if(e=e.containerInfo,Rd=sp,e=Er(e),Dr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break a}var o=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=o+i),f!==a||r!==0&&f.nodeType!==3||(l=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=o),p===a&&++d===r&&(l=o),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,el=t;el!==null;)if(t=el,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,el=e;else for(;el!==null;){switch(t=el,a=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(a,r,n),a[st]=e,bt(a),r=a;break a;case`link`:var o=Vf(`link`,`href`,i).get(r+(n.href||``));if(o){for(var c=0;cg&&(o=g,g=h,h=o);var _=wr(s,h),v=wr(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,M.T=null,n=cu,cu=null;var a=iu,o=ou;if(ru=0,au=iu=null,ou=0,Il&6)throw Error(s(331));var c=Il;if(Il|=4,jl(a.current),Cl(a,a.current,o,n),Il=c,rd(0,!1),Ie&&typeof Ie.onPostCommitFiberRoot==`function`)try{Ie.onPostCommitFiberRoot(Fe,a)}catch{}return!0}finally{N.p=i,M.T=r,Bu(e,t)}}function Uu(e,t,n){t=gi(n,t),t=Ys(e.stateNode,t,2),e=W(e,t,2),e!==null&&(Ze(e,2),nd(e))}function Q(e,t,n){if(e.tag===3)Uu(e,e,n);else for(;t!==null;){if(t.tag===3){Uu(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(nu===null||!nu.has(r))){e=gi(n,e),n=Xs(2),r=W(t,n,2),r!==null&&(Zs(n,r,t,e),Ze(r,2),nd(r));break}}t=t.return}}function Wu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Fl;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)||(Hl=!0,i.add(n),e=Gu.bind(null,e,t,n),t.then(e,e))}function Gu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ll===e&&(X&n)===n&&(Wl===4||Wl===3&&(X&62914560)===X&&300>Ee()-$l?!(Il&2)&&xu(e,0):ql|=n,Yl===X&&(Yl=0)),nd(e)}function Ku(e,t){t===0&&(t=Ye()),e=ni(e,t),e!==null&&(Ze(e,t),nd(e))}function qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ku(e,n)}function Ju(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(s(314))}r!==null&&r.delete(t),Ku(e,n)}function Yu(e,t){return Se(e,t)}var Xu=null,Zu=null,Qu=!1,$u=!1,ed=!1,td=0;function nd(e){e!==Zu&&e.next===null&&(Zu===null?Xu=Zu=e:Zu=Zu.next=e),$u=!0,Qu||(Qu=!0,ld())}function rd(e,t){if(!ed&&$u){ed=!0;do for(var n=!1,r=Xu;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-Re(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,cd(r,a))}else a=X,a=Ke(r,r===Ll?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||qe(r,a)||(n=!0,cd(r,a))}r=r.next}while(n);ed=!1}}function id(){ad()}function ad(){$u=Qu=!1;var e=0;td!==0&&Gd()&&(e=td);for(var t=Ee(),n=null,r=Xu;r!==null;){var i=r.next,a=od(r,t);a===0?(r.next=null,n===null?Xu=i:n.next=i,i===null&&(Zu=n)):(n=r,(e!==0||a&3)&&($u=!0)),r=i}ru!==0&&ru!==5||rd(e,!1),td!==0&&(td=0)}function od(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&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Lt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),bt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Lt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Lt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Lt(n.imageSizes)+`"]`)):i+=`[href="`+Lt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),bt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Lt(r)+`"][href="`+Lt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),bt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=yt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);bt(c),Pd(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,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=yt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),bt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=yt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),bt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var i=(i=ue.current)?gf(i):null;if(!i)throw Error(s(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=yt(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,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=Af(n.href);var a=yt(i).hoistableStyles,o=a.get(e);if(o||(i=i.ownerDocument||i,o={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,o),(a=i.querySelector(jf(e)))&&!a._p&&(o.instance=a,o.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),a||Nf(i,e,n,o.state))),t&&r===null)throw Error(s(528,``));return o}if(t&&r!==null)throw Error(s(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=yt(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(s(444,e))}}function Af(e){return`href="`+Lt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),bt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Lt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Lt(n.href)+`"]`);if(r)return t.instance=r,bt(r),r;var i=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),bt(r),Pd(r,`style`,i),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Af(n.href);var a=e.querySelector(jf(i));if(a)return t.state.loading|=4,t.instance=a,bt(a),a;r=Mf(n),(i=mf.get(i))&&Rf(r,i),a=(e.ownerDocument||e).createElement(`link`),bt(a);var o=a;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),t.state.loading|=4,Lf(a,n.precedence,e),t.instance=a;case`script`:return a=Pf(n.src),(i=e.querySelector(Ff(a)))?(t.instance=i,bt(i),i):(r=n,(i=mf.get(a))&&(r=h({},n),zf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),bt(i),Pd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(s(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(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 Uf(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 Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(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=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,bt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),bt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(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=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.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=s()})),l=n(),u=c(),d=new class{state={conn:`connecting`,lastFrameAt:0,tick:0,alerts:[]};listeners=new Set;backoff=500;timer=null;started=!1;frameSubs=new Set;getState=()=>this.state;subscribe=e=>(this.listeners.add(e),this.start(),()=>{this.listeners.delete(e)});onFrame=e=>(this.frameSubs.add(e),()=>{this.frameSubs.delete(e)});set(e){this.state={...this.state,...e};for(let e of this.listeners)e()}start(){this.started||typeof WebSocket>`u`||(this.started=!0,this.connect())}connect(){if(typeof location>`u`||typeof WebSocket>`u`)return;let e=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/v1/live`;this.set({conn:`connecting`});let t;try{t=new WebSocket(e)}catch{this.scheduleReconnect();return}t.onopen=()=>{this.backoff=500,this.set({conn:`open`})},t.onmessage=e=>{let t;try{t=JSON.parse(String(e.data))}catch{return}this.handle(t)},t.onclose=()=>{this.set({conn:`closed`}),this.scheduleReconnect()},t.onerror=()=>{t.close()}}scheduleReconnect(){this.timer===null&&(this.timer=window.setTimeout(()=>{this.timer=null,this.connect()},this.backoff),this.backoff=Math.min(this.backoff*2,1e4))}handle(e){let t=Date.now();for(let t of this.frameSubs)try{t(e)}catch(e){console.error(`[caprock] live frame subscriber failed`,e)}switch(e.type){case`alert`:this.set({lastFrameAt:t,alerts:[e.data,...this.state.alerts.filter(t=>t.session_id!==e.data.session_id)].slice(0,50),tick:this.state.tick+1});break;case`event`:this.set({lastFrameAt:t,lastEvent:e.data,tick:this.state.tick+1});break;case`session`:this.set({lastFrameAt:t,tick:this.state.tick+1});break;case`task`:this.set({lastFrameAt:t,tick:this.state.tick+1});break;default:this.set({lastFrameAt:t})}}dismissAlert(e){this.set({alerts:this.state.alerts.filter(t=>t.session_id!==e)})}};function f(){return(0,l.useSyncExternalStore)(d.subscribe,d.getState,d.getState)}function p(e=400){let{tick:t}=f(),[n,r]=m(t,e);return(0,l.useEffect)(()=>{r(t)},[t,r]),n}function m(e,t){let[n,r]=(0,l.useState)(e),i=(0,l.useRef)(null),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},[]),[n,(0,l.useCallback)(e=>{a.current=e,i.current===null&&(i.current=window.setTimeout(()=>{i.current=null,r(a.current)},t))},[t])]}function h(e){let[t,n]=e.replace(/^#\/?/,``).split(`?`),r=(t??``).split(`/`).filter(Boolean),i=new URLSearchParams(n??``),a=i.get(`tab`)??void 0,o=Number(i.get(`at`)),s=Number.isFinite(o)&&o>0?o:void 0;switch(r[0]){case void 0:case``:case`now`:return{name:`now`};case`session`:return r[1]?{name:`session`,id:decodeURIComponent(r[1]),tab:a,at:s}:{name:`now`};case`cost`:return{name:`cost`};case`history`:return{name:`history`};case`tasks`:return{name:`tasks`};case`graph`:return{name:`graph`};case`notes`:return{name:`notes`};case`settings`:return{name:`settings`};default:return{name:`now`}}}function g(e){switch(e.name){case`now`:return`#/`;case`session`:{let t=new URLSearchParams;e.tab&&t.set(`tab`,e.tab),e.at&&t.set(`at`,String(e.at));let n=t.toString();return`#/session/${encodeURIComponent(e.id)}${n?`?${n}`:``}`}case`cost`:return`#/cost`;case`history`:return`#/history`;case`tasks`:return`#/tasks`;case`graph`:return`#/graph`;case`notes`:return`#/notes`;case`settings`:return`#/settings`}}function _(){let[e,t]=(0,l.useState)(()=>h(location.hash));return(0,l.useEffect)(()=>{let e=()=>t(h(location.hash));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}function v(e){location.hash=g(e)}var y=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2}),b=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:4,maximumFractionDigits:4});function x(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function S(e){return x(e)===null?`—`:(e=e,e!==0&&Math.abs(e)<.01?b.format(e):y.format(e))}function C(e){if(x(e)===null)return`—`;e=e;let t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(2)}B`:t>=1e6?`${(e/1e6).toFixed(2)}M`:t>=1e4?`${(e/1e3).toFixed(1)}k`:new Intl.NumberFormat(`en-US`).format(e)}function w(e){if(x(e)===null)return`—`;e=e;let t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(1)}GB`:t>=1e6?`${(e/1e6).toFixed(1)}MB`:t>=1e3?`${Math.round(e/1e3)}KB`:`${e}B`}function T(e,t=0){if(x(e)===null)return`—`;let n=e;if(t===0){let e=Math.floor(n);return`${Number.isFinite(e)?e:0}%`}let r=Math.min(100,Math.max(0,Math.trunc(x(t)??0)));return`${e.toFixed(r)}%`}function E(e,t=Date.now()){if(!e)return`—`;let n=typeof e==`number`?e:Date.parse(e);if(Number.isNaN(n))return`—`;let r=Math.max(0,Math.round((t-n)/1e3));if(r<5)return`now`;if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<48?`${a}h ago`:`${Math.floor(a/24)}d ago`}function D(e){if(x(e)===null)return`—`;if(e<1e3)return`${Math.round(e)}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function ee(e){return e.length>8?e.slice(0,8):e}function O(e){let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n>=0?t.slice(n+1):t}function te(e){let t=/^mcp__(.+?)__(.+)$/.exec(e);return t?`${t[1]}·${t[2]}`:e}function ne(e){return e.replace(/-\d{6,}$/,`…`)}function re(e){let[t,n]=(0,l.useState)(()=>Date.now());return(0,l.useEffect)(()=>{let t=window.setInterval(()=>n(Date.now()),e);return()=>window.clearInterval(t)},[e]),t}var k=`caprock-theme`;function A(){let e=localStorage.getItem(k);return e===`dark`||e===`light`?e:window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`}function j(e){document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=e}function M(){let[e,t]=(0,l.useState)(A);return(0,l.useEffect)(()=>{j(e),localStorage.setItem(k,e)},[e]),[e,()=>t(e=>e===`dark`?`light`:`dark`)]}async function N(e,t,n=`POST`){let r=await fetch(e,{method:n,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let e;try{e=await r.json()}catch{}throw new ie(r.status,`${r.status} ${r.statusText}`,e)}return r.status===204?void 0:await r.json()}var ie=class extends Error{status;body;constructor(e,t,n){super(t),this.status=e,this.body=n}};function ae(e){if(e instanceof ie){let t=e.body,n=t?.error??e.message;return t?.detail?`${n} — ${t.detail}`:n}return e instanceof Error?e.message:String(e)}async function oe(e){let t=await fetch(e,{headers:{Accept:`application/json`}});if(!t.ok){let e;try{e=await t.json()}catch{}throw new ie(t.status,`${t.status} ${t.statusText}`,e)}return await t.json()}var P={sessions:(e=!1)=>oe(`/v1/sessions${e?`?active=true`:``}`),session:e=>oe(`/v1/sessions/${encodeURIComponent(e)}`),events:(e,t=0,n=500)=>oe(`/v1/sessions/${encodeURIComponent(e)}/events?after=${t}&limit=${n}`),eventsBefore:(e,t,n=200)=>oe(`/v1/sessions/${encodeURIComponent(e)}/events?before=${t}&limit=${n}`),recentEvents:(e,t=2e3)=>oe(`/v1/sessions/${encodeURIComponent(e)}/events?newest=1&limit=${t}`),diff:e=>oe(`/v1/sessions/${encodeURIComponent(e)}/diff`),notes:(e,t=200)=>oe(`/v1/sessions/${encodeURIComponent(e)}/notes?limit=${t}`),searchNotes:(e,t=100,n=0)=>oe(`/v1/notes?q=${encodeURIComponent(e)}&limit=${t}${n?`&before=${n}`:``}`),testReport:()=>N(`/v1/report/test`,{}),settings:()=>oe(`/v1/settings`),update:()=>oe(`/v1/update`),checkUpdate:()=>N(`/v1/update/check`,{}),saveSettings:e=>N(`/v1/settings`,e,`PUT`),summary:(e=`today`,t)=>oe(`/v1/stats/summary?range=${e}${t&&t!==`all`?`&agent=${t}`:``}`),daily:(e=30)=>oe(`/v1/stats/daily?days=${e}`),premium:()=>oe(`/v1/premium`),gemini:()=>oe(`/v1/gemini`),askGemini:(e,t)=>N(`/v1/gemini/ask`,{prompt:e,model:t}),browse:(e=``)=>oe(`/v1/browse${e?`?dir=${encodeURIComponent(e)}`:``}`),recentDirs:()=>oe(`/v1/recent-dirs`),history:(e=`all`)=>oe(`/v1/history?range=${e}`),enableHive:(e,t)=>N(`/v1/hive`,{hive:e??``,repo:t??``}),tasks:()=>oe(`/v1/tasks`),task:e=>oe(`/v1/tasks/${encodeURIComponent(e)}`),createTask:e=>N(`/v1/tasks`,e),approve:(e,t)=>N(`/v1/tasks/${encodeURIComponent(e)}/${t?`approve`:`reject`}`,{}),startOrchestrator:()=>N(`/v1/orchestrator/start`,{}),stopOrchestrator:()=>N(`/v1/orchestrator/stop`,{}),status:()=>oe(`/v1/status`),spawn:e=>N(`/v1/agents`,e),signal:(e,t)=>N(`/v1/agents/${encodeURIComponent(e)}/signal`,{action:t}),paste:(e,t)=>N(`/v1/paste`,{type:e,data:t}),agentInput:(e,t)=>N(`/v1/agents/${encodeURIComponent(e)}/input`,{data:t})},se=[{id:`macos`,label:`macOS`},{id:`linux`,label:`Linux`},{id:`windows`,label:`Windows`}],F={cmd:`caprock down && caprock up`,note:`The running daemon is the old binary until it restarts. Your database is untouched.`},ce={cmd:`caprock status`,note:`Confirms the new version is the one running, and that hooks are still registered.`},le={label:`Homebrew`,steps:[{cmd:`brew update && brew upgrade caprock`,note:`The update is not optional: without it Homebrew reads a cached copy of the tap, refreshed at most once a day, and reports "already installed" for a release that is already out.`},F,ce]},ue={label:`Scoop`,steps:[{cmd:`scoop update caprock`,note:`Scoop refreshes its buckets as part of this, so no separate step.`},F,ce]},de={label:`go install`,steps:[{cmd:`go install github.com/dspv/caprock/cmd/caprock@latest`,note:`Also install the hook shim: same command with cmd/caprock-hook.`},F,ce]},fe={label:`Downloaded binary`,steps:[{cmd:``,note:`Download the archive for your platform from the release page, and replace the caprock and caprock-hook binaries with the ones inside it.`},F,ce]};function pe(e){switch(e){case`macos`:return[le,de,fe];case`linux`:return[le,de,fe];case`windows`:return[ue,de,fe]}}function me(e,t){let n=`${t??``} ${e}`.toLowerCase();return n.includes(`win`)?`windows`:n.includes(`mac`)||n.includes(`darwin`)||n.includes(`iphone`)||n.includes(`ipad`)?`macos`:`linux`}function he(e){if(e&&e.startsWith(`scoop`))return`windows`}function ge(e,t){return e?be(e,pe(t))===void 0:!1}var _e=`caprock-update-platform`;function ve(){try{let e=localStorage.getItem(_e);return se.some(t=>t.id===e)?e:void 0}catch{return}}function ye(e){try{localStorage.setItem(_e,e)}catch{}}function be(e,t){if(!e)return;let n=e.split(/\s+/)[0];if(n)return t.find(e=>e.steps.some(e=>e.cmd.startsWith(n)))}function I(e,t=[],n={}){let{live:r=!0,intervalMs:i=0}=n,a=p(400),[o,s]=(0,l.useState)({data:void 0,error:void 0,loading:!0,refresh:()=>{},loadedAt:0}),c=(0,l.useRef)(0),u=(0,l.useRef)(e);u.current=e;let d=(0,l.useCallback)(()=>{let e=++c.current;u.current().then(t=>{e===c.current&&s(e=>({...e,data:t,error:void 0,loading:!1,loadedAt:Date.now()}))},t=>{e===c.current&&s(e=>({...e,error:t,loading:!1}))})},[]);return(0,l.useEffect)(d,[d,...t]),(0,l.useEffect)(()=>{r&&a>0&&d()},[r,a,d]),(0,l.useEffect)(()=>{if(!i)return;let e=window.setInterval(d,i);return()=>window.clearInterval(e)},[i,d]),{...o,refresh:d}}var xe=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),L=e(((e,t)=>{t.exports=xe()}))(),Se=[{label:`Pro`,kind:`flat`,usd:20,note:`$20/mo`},{label:`Max 5×`,kind:`flat`,usd:100,note:`$100/mo`},{label:`Max 20×`,kind:`flat`,usd:200,note:`$200/mo`},{label:`Team seat`,kind:`flat`,usd:30,note:`$30/seat/mo`},{label:`API / Bedrock`,kind:`metered`,usd:0,note:`billed per token`}],Ce,we=null,Te=new Set;function Ee(){for(let e of Te)e()}function De(){let[,e]=(0,l.useState)(0);return(0,l.useEffect)(()=>{let t=()=>e(e=>e+1);return Te.add(t),!Ce&&!we&&(we=P.settings().then(e=>{Ce=e}).catch(()=>{Ce={update_checks:!1,plan_kind:``,plan_label:``,plan_usd_per_month:0}}).finally(()=>{we=null,Ee()})),()=>{Te.delete(t)}},[]),[Ce,e=>{Ce={...Ce??{},...e},Ee(),P.saveSettings(e).catch(()=>{})}]}function Oe({plan:e,onSave:t}){let[n,r]=(0,l.useState)(!1),i=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]);let a=e?.plan_kind?e.plan_kind===`metered`?e.plan_label||`API`:`${e.plan_label||`plan`} · ${S(e.plan_usd_per_month)}/mo`:`set plan`;return(0,L.jsxs)(`div`,{className:`relative`,ref:i,children:[(0,L.jsxs)(`button`,{onClick:()=>r(e=>!e),className:`mono text-[11px] px-1.5 py-0.5 rounded-sm border inline-flex items-center gap-1 ${e?.plan_kind?`border-border-strong bg-panel-2 text-fg hover:border-fg-faint`:`border-accent/50 text-accent`}`,title:e?.plan_kind?`Your plan: ${a}. Click to change it.`:`How you pay for Claude Code — Caprock cannot detect this, so you tell it`,children:[e?.plan_kind&&(0,L.jsx)(`span`,{className:`text-ok`,"aria-hidden":!0,children:`✓`}),a]}),n&&(0,L.jsx)(ke,{plan:e,onSave:e=>{t(e),r(!1)}})]})}function ke({plan:e,onSave:t}){let[n,r]=(0,l.useState)(String(e?.plan_usd_per_month||``));return(0,L.jsxs)(`div`,{className:`absolute right-0 top-7 z-20 w-[268px] border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg p-2`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-fg-muted px-1 pb-1.5`,children:`How do you pay for Claude Code? Caprock can't detect this and never guesses.`}),Se.map(n=>{let r=e?.plan_label===n.label;return(0,L.jsxs)(`button`,{onClick:()=>t({plan_kind:n.kind,plan_label:n.label,plan_usd_per_month:n.usd}),className:`w-full flex items-baseline gap-2 px-1.5 py-1 rounded-sm text-left text-[12px] hover:bg-panel-2 ${r?`text-accent`:`text-fg`}`,children:[(0,L.jsx)(`span`,{children:n.label}),(0,L.jsx)(`span`,{className:`mono text-[11px] text-fg-faint ml-auto`,children:n.note})]},n.label)}),(0,L.jsxs)(`div`,{className:`border-t border-border mt-1.5 pt-1.5 px-1.5`,children:[(0,L.jsx)(`label`,{className:`text-[11px] text-fg-faint`,children:`Or a different monthly price`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,L.jsx)(`span`,{className:`mono text-[12px] text-fg-faint`,children:`$`}),(0,L.jsx)(`input`,{className:`input`,inputMode:`decimal`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. 150`}),(0,L.jsx)(`button`,{className:`text-[11px] border border-border px-1.5 py-1 rounded-sm hover:border-border-strong`,onClick:()=>{let e=Number(n);!Number.isFinite(e)||e<0||t({plan_kind:`flat`,plan_label:`plan`,plan_usd_per_month:e})},children:`set`})]})]})]})}var Ae=[{id:`bug`,label:`bug`,hint:`What did you see?`,gh:`bug`},{id:`feature`,label:`feature`,hint:`What would you want?`,gh:`enhancement`},{id:`unclear`,label:`unclear`,hint:`What did not make sense?`,gh:`question`},{id:`other`,label:`other`,hint:`Anything else — a sentence is enough.`,gh:`question`}],je=`dspv/caprock`;function Me(e,t){if(!e)return[`Screen: ${t}`];let n=e.hooks,r=n?(n.missing?.length??0)>0?`partly installed`:n.shim_exists?`installed`:`not installed`:`unknown`;return[`Caprock ${e.version}${e.platform?` (${e.platform})`:``}`,`Screen: ${t}`,`${e.events.toLocaleString(`en-US`)} events${e.owned_active?` · ${e.owned_active} owned session(s) running`:``}`,`Hooks: ${r} · Orchestration: ${e.orchestration?`on`:`off`}`]}function Ne(e,t,n){let r=n.trim().split(` +`)[0]?.trim()??``;return`[${e}] ${t}: ${r.length>60?`${r.slice(0,57)}…`:r}`}function Pe(e,t,n){let r=e===`bug`?`What happened`:e===`feature`?`What is missing`:e===`unclear`?`What is unclear`:`Feedback`,i=t.trim(),a=i.length>6e3?`${i.slice(0,Ie)}\n\n_[…truncated — the rest did not fit in the link; paste it below]_`:i;return[`### ${r}`,``,a,``,`### Context`,``,...n.map(e=>`- ${e}`),``,`Filed from the Caprock dashboard. Nothing was sent automatically — this issue was opened in your browser for you to review.`].join(` +`)}function Fe(e,t,n,r){let i=Ae.find(t=>t.id===e)??Ae[0];return`https://github.com/${je}/issues/new?${new URLSearchParams({title:Ne(e,t,n),body:Pe(e,n,r),labels:i.gh}).toString()}`}var Ie=6e3;function Le(e){return e.trim().length>=8}function Re({screen:e}){let[t,n]=(0,l.useState)(!1);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{onClick:()=>n(!0),className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,title:`Report a bug, ask for something, or say what was unclear`,children:`feedback`}),t&&(0,L.jsx)(ze,{screen:e,onClose:()=>n(!1)})]})}function ze({screen:e,onClose:t}){let[n,r]=(0,l.useState)(`bug`),[i,a]=(0,l.useState)(``),o=Me(I(()=>P.status(),[],{live:!1,intervalMs:0}).data,e),s=Le(i),c=Ae.find(e=>e.id===n)??Ae[0],u=()=>{s&&(window.open(Fe(n,e,i,o),`_blank`,`noopener`),t())};return(0,L.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-start justify-center pt-[12vh] px-4`,onClick:t,children:(0,L.jsxs)(`div`,{className:`w-full max-w-[660px] border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`px-4 pt-3 pb-2 border-b border-border flex items-center`,children:[(0,L.jsx)(`span`,{className:`text-[15px] font-medium`,children:`Tell us what happened`}),(0,L.jsx)(`button`,{onClick:t,className:`ml-auto text-[16px] leading-none text-fg-faint hover:text-fg`,children:`×`})]}),(0,L.jsxs)(`div`,{className:`p-4 grid gap-3`,children:[(0,L.jsx)(`div`,{className:`flex gap-1.5`,children:Ae.map(e=>(0,L.jsx)(`button`,{onClick:()=>r(e.id),className:`text-[13px] px-3.5 py-1.5 rounded-sm border font-mono ${e.id===n?`border-accent/60 bg-accent/10 text-accent`:`border-border text-fg-muted hover:text-fg`}`,children:e.label},e.id))}),(0,L.jsx)(`textarea`,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:c.hint,rows:6,className:`input w-full resize-y text-[14px] leading-relaxed`,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&u()}}),(0,L.jsxs)(`div`,{className:`border border-border rounded-sm bg-panel-2/50 px-3 py-2`,children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint mb-1`,children:`Attached`}),(0,L.jsx)(`ul`,{className:`text-[11px] text-fg-muted num grid gap-0.5`,children:o.map(e=>(0,L.jsx)(`li`,{children:e},e))})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`button`,{onClick:u,disabled:!s,className:`text-[12px] px-3 py-1.5 rounded-sm border ${s?`border-accent/50 bg-accent/10 text-accent hover:bg-accent/20`:`border-border text-fg-faint cursor-not-allowed`}`,children:`Open a GitHub issue →`}),(0,L.jsx)(`span`,{className:`text-[12px] ${s?`text-fg-faint`:`text-fg-muted`}`,children:s?`⌘↵ to open`:`One sentence is enough.`})]}),(0,L.jsx)(`p`,{className:`text-[11px] text-fg-faint leading-relaxed`,children:`Nothing is sent from here — the issue opens prefilled in your browser for you to submit.`})]})]})})}var Be=1200,Ve=630;function He(e,t){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}var Ue={today:`today`,"7d":`this week`,"30d":`this month`,all:`all time`},We={command:`running commands`,edit:`writing code`,read:`reading code`,mcp:`MCP tools`,web:`web research`,other:`other tools`,none:`no tool call`};function Ge(e){return e.slice(e.lastIndexOf(`/`)+1).replace(/^claude-/,``).replace(/-\d{8}$/,``).slice(0,18)}function Ke(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function qe(e,t){let n=He(`--color-bg`,`#141414`),r=He(`--color-panel`,`#1a1a19`),i=He(`--color-border`,`#2a2a28`),a=He(`--color-fg`,`#e8e6e2`),o=He(`--color-fg-muted`,`#a9a59e`),s=He(`--color-fg-faint`,`#6f6b64`),c=He(`--color-accent`,`#feb157`),l=He(`--color-ok`,`#7fc99a`),u=`"JetBrains Mono", ui-monospace, monospace`,d=`"Hanken Grotesk", ui-sans-serif, system-ui, sans-serif`;e.fillStyle=n,e.fillRect(0,0,Be,Ve);let f=(t,n,r,i,a=12)=>{e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+r,n,t+r,n+i,a),e.arcTo(t+r,n+i,t,n+i,a),e.arcTo(t,n+i,t,n,a),e.arcTo(t,n,t+r,n,a),e.closePath()},p=(t,n,a,o)=>{f(t,n,a,o),e.fillStyle=r,e.fill(),e.strokeStyle=i,e.lineWidth=1,e.stroke()},m=(t,n,r,i,a,o=d,s=400,c=`left`)=>{e.fillStyle=a,e.font=`${s} ${i}px ${o}`,e.textAlign=c,e.fillText(r,t,n)};e.font=`600 32px ${d}`;let h=t.period===`all`?`My stats on`:`My ${Ue[t.period].replace(`this `,``)} on`,g=e.measureText(` `).width,_=e.measureText(h).width;m(64,78,h,32,a,d,600);let v=64+_+g;m(v,78,`caprock.dev`,32,c,d,600);let y=e.measureText(`caprock.dev`).width,b=t.takenAt.toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`});m(v+y+g*2,78,`– ${b}`,26,s,d,600);let x=e=>t.period===e?c:a;[[`TODAY`,S(t.today.cost),`${t.today.sessions} sessions`,x(`today`)],[`THIS WEEK`,S(t.week.cost),`${t.week.sessions} sessions`,x(`7d`)],[`THIS MONTH`,S(t.month.cost),`${Ke(t.month.tokens)} tokens`,x(`30d`)],[`ALL TIME`,S(t.allTime.cost),`${t.allTime.days} active days`,x(`all`)],[`A DAY`,S(t.allTime.cost/Math.max(1,t.allTime.days)),`on average`,a],[`TOKENS`,Ke(t.allTime.tokens),`all time`,a],[`PER 1M TOKENS`,S(t.allTime.cost/Math.max(1,t.allTime.tokens/1e6)),`what a million costs`,a],[`CACHE HIT`,`${Math.round(t.cacheHitPct)}%`,`input cost cut`,l]].forEach(([e,t,n,r],i)=>{let a=64+i%4*272,c=130+Math.floor(i/4)*114;p(a,c,256,98),m(a+20,c+30,e,13,s,u),m(a+20,c+56,t,28,r,d,600),m(a+20,c+81,n,14,o)});let C=(t,n,r,i)=>{let l=44+r.length*26+12;p(t,n,524,l),m(t+20,n+30,i,13,s,u);let d=Math.max(...r.map(e=>e.cost),1),h=r.reduce((e,t)=>e+t.cost,0),g=t+170;return r.forEach((r,i)=>{let l=n+62+i*26;m(t+20,l,r.label,14,o,u),e.fillStyle=c,e.globalAlpha=.85;let p=Math.max(2,164*(r.cost/d));f(g,l-10,p,10,Math.min(3,p/2)),e.fill(),e.globalAlpha=1,m(t+524-62,l,S(r.cost),14,a,u,400,`right`);let _=h>0?Math.max(1,Math.floor(100*r.cost/h)):0;m(t+524-20,l,`${_}%`,14,s,u,400,`right`)}),l},w=C(64,372,t.models,`WHERE THE MONEY WENT`);C(612,372,t.work,`WHAT IT WENT ON`);let T=372+w+34;m(64,T,`at API list prices — not a bill, and not money saved`,14,s),m(1136,T,`What's yours?`,15,c,d,600,`right`),e.textAlign=`left`}function Je(e=new Date){let t=e=>String(e).padStart(2,`0`);return`caprock-${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}.png`}async function Ye(e=`all`){let[t,n,r,i]=await Promise.all([P.summary(`today`),P.summary(`7d`),P.summary(`30d`),P.history(`all`)]),a=e=>e.tokens_in+e.tokens_out+e.cache_read+e.cache_write;return{period:e,takenAt:new Date,today:{cost:t.cost_usd,sessions:t.sessions},week:{cost:n.cost_usd,sessions:n.sessions},month:{cost:r.cost_usd,tokens:a(r)},allTime:{cost:i.totals.cost_usd,days:i.totals.days,tokens:a(i.summary)},cacheHitPct:(r.savings?.hit_rate??0)*100,models:(r.models??[]).slice(0,5).map(e=>({label:Ge(e.model),cost:e.cost_usd})),work:(r.work??[]).slice(0,5).map(e=>({label:We[e.kind]??e.kind,cost:e.cost_usd}))}}async function Xe(e){let t=document.createElement(`canvas`);t.width=Be,t.height=Ve;let n=null;try{n=t.getContext(`2d`)}catch{return null}return n?(qe(n,e),await new Promise(e=>{if(typeof t.toBlob!=`function`){e(null);return}t.toBlob(t=>e(t),`image/png`)})):null}function Ze(e){let t=`over ${e.days} active days`;return`${S(e.cost_usd)} of Claude Code ${t}, across ${e.sessions.toLocaleString(`en-US`)} sessions — measured on my own machine with Caprock. https://caprock.dev`}function Qe(){let[e,t]=(0,l.useState)(!1);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{onClick:()=>t(!0),className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-2.5 py-1 text-[12px] font-medium text-bg hover:brightness-110`,title:`Draw a shareable picture of your figures`,children:[(0,L.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`}),(0,L.jsx)(`circle`,{cx:`6`,cy:`12`,r:`3`}),(0,L.jsx)(`circle`,{cx:`18`,cy:`19`,r:`3`}),(0,L.jsx)(`path`,{d:`M8.6 13.5l6.8 4M15.4 6.5l-6.8 4`})]}),`Share`]}),e&&(0,L.jsx)($e,{onClose:()=>t(!1)})]})}function $e({onClose:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(``),[s,c]=(0,l.useState)(`7d`),[u,d]=(0,l.useState)(``);(0,l.useEffect)(()=>{let e=!0,t=``;return(async()=>{let n=await Xe(await Ye(s));!n||!e||(t=URL.createObjectURL(n),d(t))})(),()=>{e=!1,t&&URL.revokeObjectURL(t)}},[s]);let f=async()=>{let[e,t]=await Promise.all([Ye(s),P.history(`all`)]);return{blob:await Xe(e),text:Ze(t.totals)}},p=async()=>{if(!r){i(!0),n(!0),o(``);try{let{blob:t}=await f();if(!t){o(`Could not draw the card in this browser.`),i(!1);return}let r=new File([t],Je(),{type:`image/png`});n(!1),await navigator.share({files:[r]}),e()}catch(e){e?.name!==`AbortError`&&o(`Sharing was not available — the card was not sent.`),i(!1)}finally{n(!1)}}},m=async e=>{if(!r){i(!0),n(!0),o(``);try{let{blob:t,text:n}=await f();if(!t){o(`Could not draw the card in this browser.`);return}let r=URL.createObjectURL(t),i=document.createElement(`a`);if(i.href=r,i.download=Je(),i.click(),URL.revokeObjectURL(r),e===`download`){o(`Saved to your downloads.`);return}let a=e===`x`?`https://x.com/intent/tweet?text=${encodeURIComponent(n)}`:`https://www.linkedin.com/feed/?shareActive=true&text=${encodeURIComponent(n)}`;window.open(a,`_blank`,`noopener`),o(`Card saved and the post opened — drag the image in.`)}finally{n(!1),i(!1)}}},h=typeof navigator<`u`&&typeof navigator.canShare==`function`&&navigator.canShare({files:[new File([],`x.png`,{type:`image/png`})]});return(0,L.jsx)(`div`,{className:`fixed inset-0 z-30 flex items-start justify-center bg-black/50 px-4 pt-[14vh]`,onClick:e,role:`dialog`,"aria-modal":`true`,"aria-label":`Share your figures`,children:(0,L.jsxs)(`div`,{className:`w-[420px] max-w-full rounded-[var(--radius-panel)] border border-border-strong bg-panel`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`header`,{className:`flex items-center border-b border-border px-4 py-3`,children:[(0,L.jsx)(`h2`,{className:`text-[13px] font-medium text-fg`,children:`Share your figures`}),(0,L.jsx)(`button`,{onClick:e,className:`ml-auto text-fg-muted hover:text-fg`,"aria-label":`Close`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3.5 flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`mr-1 text-[12px] text-fg-muted`,children:`Show`}),[`today`,`7d`,`30d`,`all`].map(e=>(0,L.jsx)(`button`,{onClick:()=>c(e),"aria-pressed":s===e,className:`rounded-sm px-2 py-1 text-[12px] ${s===e?`bg-accent text-bg font-medium`:`text-fg-muted hover:text-fg`}`,children:Ue[e]},e))]}),(0,L.jsx)(`div`,{className:`mb-3.5 overflow-hidden rounded-md border border-border bg-panel-2`,style:{aspectRatio:`1200 / 630`},children:u?(0,L.jsx)(`img`,{src:u,alt:`Your figures, as they will be shared`,className:`block w-full`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-fg-faint`,children:`drawing…`})}),(0,L.jsxs)(`div`,{className:`grid gap-2.5`,children:[h&&(0,L.jsxs)(`button`,{onClick:p,disabled:r,className:`rounded-md border border-accent bg-accent/15 px-4 py-3 text-[14px] font-medium text-accent hover:bg-accent/25 disabled:opacity-50`,children:[t?`Drawing the card…`:`Send it somewhere`,(0,L.jsx)(`span`,{className:`mt-0.5 block text-[12px] font-normal text-fg-muted`,children:`Opens your share menu — Messages, Mail, anywhere`})]}),(0,L.jsxs)(`button`,{onClick:()=>m(`download`),disabled:r,className:`rounded-md border border-border bg-transparent px-4 py-3 text-[14px] text-fg transition-colors hover:border-border-strong hover:bg-panel-2 disabled:opacity-50`,children:[t&&!h?`Drawing the card…`:`Save the image`,(0,L.jsx)(`span`,{className:`mt-0.5 block text-[12px] text-fg-muted`,children:`A PNG in your downloads, to post wherever you like`})]})]}),(0,L.jsxs)(`ul`,{className:`mt-4 grid gap-1 text-[13px] text-fg-muted`,children:[(0,L.jsx)(`li`,{children:`Totals only — no names, no paths, nothing Claude wrote.`}),(0,L.jsx)(`li`,{children:`Drawn on your machine. Uploaded nowhere.`})]}),a&&(0,L.jsx)(`p`,{className:`mt-2 text-[12px] text-fg-muted`,children:a})]})]})})}function et(){let e=I(()=>P.history(`all`),[],{intervalMs:6e4}),[t,n]=(0,l.useState)(!1),r=e.data?.totals;return!r||r.sessions===0?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{onClick:()=>n(!0),className:`rounded-md border border-accent/45 bg-accent/[0.08] px-2.5 py-1 text-[12px] text-accent hover:bg-accent/[0.16]`,title:`Draw a shareable image of these figures`,children:`Share these numbers`}),t&&(0,L.jsx)($e,{onClose:()=>n(!1)})]})}var tt={cap:{title:`A daily cap that pauses sessions`,body:`A number for the day. Cross it and Caprock stops its own sessions.`,points:[`A runaway loop stops at $40 instead of finishing at $400`,`It happens while you are asleep, not in tomorrow’s summary`,`Your own sessions are never touched — only the ones Caprock started`]},gemini:{title:`Ask Gemini, on your own key`,body:`A second model inside Caprock, paid for by you, at Google’s prices.`,points:[`Ask about your own sessions without leaving the dashboard`,`What it costs is counted and shown beside your Claude spend`,`Caprock never stores the key — it reads it from your environment`],setup:`Set GEMINI_API_KEY in the daemon’s environment and restart it. Google bills you directly.`},report:{title:`A weekly report, sent where you are`,body:`Monday morning, before you open a terminal.`,points:[`What moved: the repository that cost 3× its usual week`,`Last week against the one before it, per repository and model`,`Through your own Telegram bot — nothing passes our server`],setup:`Setup: one message to BotFather, about two minutes.`}};function nt({p:e,onClose:t}){return e?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsxs)(`a`,{href:e.yearly.url,target:`_blank`,rel:`noreferrer`,onClick:t,className:`rounded-sm bg-premium/75 px-3 py-2.5 text-center text-[14px] font-medium text-white no-underline hover:bg-premium`,children:[`$`,e.yearly.charged_usd,` / year`]}),(0,L.jsxs)(`a`,{href:e.lifetime?.url,target:`_blank`,rel:`noreferrer`,onClick:t,className:`rounded-sm bg-premium-strong px-3 py-2.5 text-center text-[14px] font-medium text-white no-underline hover:brightness-110`,children:[`$`,e.lifetime?.charged_usd,` once`]})]}),(0,L.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 text-center text-[11px] leading-snug text-fg-faint`,children:[(0,L.jsx)(`span`,{children:`Every Premium feature, renews yearly`}),(0,L.jsx)(`span`,{children:`Every Premium feature, now and future — no renewal`})]})]}):(0,L.jsx)(`div`,{className:`h-[92px] text-[13px] text-fg-faint`,children:`…`})}function rt({feature:e,onClose:t}){let n=I(()=>P.premium(),[]).data,r=tt[e];return(0,l.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,L.jsx)(`div`,{className:`fixed inset-0 z-30 flex items-start justify-center bg-black/50 px-4 pt-[12vh]`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-label":`Caprock Premium`,children:(0,L.jsxs)(`div`,{className:`w-[440px] max-w-full rounded-[var(--radius-panel)] border border-border-strong bg-panel`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`header`,{className:`flex items-start gap-3 px-5 pt-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-[11px] uppercase tracking-wide text-premium-strong`,children:`Caprock Premium`}),(0,L.jsx)(`h2`,{className:`mt-1 text-[16px] font-medium leading-snug text-fg`,children:r.title})]}),(0,L.jsx)(`button`,{onClick:t,className:`-mr-1 ml-auto text-fg-muted hover:text-fg`,"aria-label":`Close`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`px-5 pt-3`,children:[(0,L.jsx)(`p`,{className:`text-[13px] leading-relaxed text-fg-muted`,children:r.body}),(0,L.jsx)(`ul`,{className:`mt-3 space-y-1.5`,children:r.points.map(e=>(0,L.jsxs)(`li`,{className:`flex gap-2 text-[13px] leading-snug text-fg`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-premium-strong`,children:`·`}),(0,L.jsx)(`span`,{children:e})]},e))}),r.setup&&(0,L.jsx)(`p`,{className:`mt-2.5 text-[12px] text-fg-faint`,children:r.setup})]}),(0,L.jsx)(`div`,{className:`mt-4 border-t border-border px-5 py-4`,children:(0,L.jsx)(nt,{p:n,onClose:t})}),(0,L.jsx)(`footer`,{className:`border-t border-border px-5 py-3 text-[12px]`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`a`,{href:n?.info_url??`https://caprock.dev/premium/`,target:`_blank`,rel:`noreferrer`,className:`whitespace-nowrap text-fg-muted no-underline hover:text-fg`,children:`Read more`}),(0,L.jsx)(`span`,{className:`whitespace-nowrap text-fg-faint`,children:`opens a new tab`}),(0,L.jsx)(`button`,{onClick:t,className:`ml-auto text-fg-muted hover:text-fg`,children:`Close`})]})}),(0,L.jsx)(`p`,{className:`border-t border-border px-5 py-2.5 text-[11px] leading-relaxed text-fg-faint`,children:`Everything Caprock does now stays free and Apache-2.0 — Premium only ever adds.`})]})})}function it(){let[e,t]=(0,l.useState)(!1),n=I(()=>P.premium(),[],{live:!1,intervalMs:3e5});if(!n.data?.yearly?.url)return null;let r=n.data.license;if(r?.active){let e=r.expires_at?new Date(r.expires_at):null,t=!!e&&e.getFullYear()-new Date().getFullYear()>10;return(0,L.jsxs)(`span`,{className:`text-premium-strong`,title:e&&!t?`Covers you through ${e.toLocaleDateString()}`:`Bought outright`,children:[`premium `,(0,L.jsx)(`span`,{className:`opacity-70`,children:t?`lifetime`:`yearly`}),r.in_grace&&(0,L.jsx)(`span`,{className:`ml-1 text-warn`,children:`· renew`})]})}let i=n.data;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{onClick:()=>t(!0),title:`What Premium includes`,className:`inline-flex items-center gap-1.5 rounded-sm border border-premium/60 bg-premium px-2 py-0.5 text-white hover:brightness-110`,children:[(0,L.jsx)(`span`,{children:`Get premium`}),(0,L.jsxs)(`span`,{className:`opacity-75`,children:[`$`,i.yearly.charged_usd,`/yr`]})]}),e&&(0,L.jsx)(rt,{feature:`cap`,onClose:()=>t(!1)})]})}var at=`https://github.com/dspv/caprock`,ot=`https://caprock.dev/teams`,st=`https://caprock.dev/premium`,ct=`caprock.footer.starred`;function lt(){let[e,t]=(0,l.useState)(()=>localStorage.getItem(ct)===`1`);return(0,L.jsx)(`footer`,{className:`mt-6 border-t border-border`,children:(0,L.jsxs)(`div`,{className:`max-w-[1600px] mx-auto px-3 py-4 flex flex-wrap items-center gap-x-6 gap-y-3 text-[11px] text-fg-faint`,children:[(0,L.jsxs)(`a`,{href:ot,target:`_blank`,rel:`noreferrer`,className:`group inline-flex items-center gap-2 no-underline`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted group-hover:text-fg`,children:`Want this for your team?`}),(0,L.jsx)(`span`,{className:`text-accent group-hover:text-accent-strong`,children:`Caprock for Teams →`})]}),(0,L.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-4`,children:[(0,L.jsx)(`a`,{href:st,target:`_blank`,rel:`noreferrer`,className:`text-fg-muted hover:text-fg no-underline`,title:`A daily spend cap — Caprock pauses its own sessions when the day passes a limit you set`,children:`premium`}),!e&&(0,L.jsx)(`a`,{href:at,target:`_blank`,rel:`noreferrer`,onClick:()=>{localStorage.setItem(ct,`1`),t(!0)},className:`text-fg-faint hover:text-fg no-underline`,title:`Opens GitHub in a new tab`,children:`★ star on GitHub`}),(0,L.jsx)(`a`,{href:`https://caprock.dev/blog`,target:`_blank`,rel:`noreferrer`,className:`text-fg-faint hover:text-fg no-underline`,children:`blog`}),(0,L.jsx)(`a`,{href:`https://caprock.dev/docs`,target:`_blank`,rel:`noreferrer`,className:`text-fg-faint hover:text-fg no-underline`,children:`docs`})]})]})})}function ut(e){let t=[],n=/\*\*([^*]+)\*\*|`([^`]+)`/g,r=0;for(let i=n.exec(e);i;i=n.exec(e))i.index>r&&t.push({text:e.slice(r,i.index),bold:!1,code:!1}),i[1]===void 0?t.push({text:i[2]??``,bold:!1,code:!0}):t.push({text:i[1],bold:!0,code:!1}),r=i.index+i[0].length;return r{n.length&&t.push({kind:`para`,parts:ut(n.join(` `))}),n=[]},o=()=>{r.length&&t.push({kind:`bullet`,parts:ut(r.join(` `))}),r=[]},s=()=>{if(i.length){let e=i.filter(e=>!/^[|\s:-]+$/.test(e)).map(e=>e.replace(/^\||\|$/g,``).split(`|`).map(e=>ut(e.trim()))).filter(e=>e.some(e=>e.some(e=>e.text.trim()!==``)));e.length&&t.push({kind:`table`,rows:e})}i=[]},c=()=>{s(),o(),a()};for(let l of e.split(` +`)){let e=l.trimEnd().trim();if(e===``){c();continue}let u=/^#{1,6}\s+(.*)$/.exec(e);if(u){c(),t.push({kind:`heading`,text:u[1]??``});continue}if(e.startsWith(`|`)){o(),a(),i.push(e);continue}s();let d=/^>\s?(.*)$/.exec(e);if(d){c(),t.push({kind:`quote`,parts:ut(d[1]??``)});continue}let f=/^[-*•]\s+(.*)$/.exec(e);if(f){c(),r.push(f[1]??``);continue}if(r.length){r.push(e);continue}n.push(e)}return c(),t}function ft({text:e}){let t=dt(e);return(0,L.jsx)(`div`,{className:`grid gap-2.5 text-[13px] leading-relaxed text-fg-muted`,children:t.map((e,t)=>e.kind===`heading`?(0,L.jsx)(`h3`,{className:`text-[11px] uppercase tracking-[0.08em] text-fg-faint mt-1.5 first:mt-0`,children:e.text},t):e.kind===`table`?(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsx)(`table`,{className:`border-collapse text-[12px]`,children:(0,L.jsx)(`tbody`,{children:e.rows.map((e,t)=>(0,L.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map((e,t)=>(0,L.jsx)(`td`,{className:`py-1 pr-4 align-top`,children:pt(e)},t))},t))})})},t):e.kind===`quote`?(0,L.jsx)(`p`,{className:`m-0 border-l-2 border-border pl-3 text-fg-faint`,children:pt(e.parts)},t):e.kind===`bullet`?(0,L.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-2`,children:[(0,L.jsx)(`span`,{className:`text-accent select-none`,children:`·`}),(0,L.jsx)(`p`,{className:`m-0`,children:pt(e.parts)})]},t):(0,L.jsx)(`p`,{className:`m-0`,children:pt(e.parts)},t))})}function pt(e){return e.map((e,t)=>e.bold?(0,L.jsx)(`strong`,{className:`font-medium text-fg`,children:e.text},t):e.code?(0,L.jsx)(`code`,{className:`mono text-[12px] text-fg`,children:e.text},t):(0,L.jsx)(`span`,{children:e.text},t))}var mt=[{route:{name:`now`},label:`Now`},{route:{name:`cost`},label:`Cost`},{route:{name:`history`},label:`Lifetime`},{route:{name:`notes`},label:`Answers`},{route:{name:`tasks`},label:`Tasks`}];function ht(e){switch(e.name){case`now`:return`Now`;case`session`:return`Session detail`;case`cost`:return`Cost`;case`history`:return`Lifetime`;case`tasks`:return`Tasks`;case`graph`:return`Graph`;case`notes`:return`Answers`;case`settings`:return`Status`}}function gt({route:e,children:t}){let n=f(),[r,i]=De(),a=t=>t.name===e.name||t.name===`now`&&e.name===`session`;return(0,L.jsxs)(`div`,{className:`min-h-screen flex flex-col`,children:[(0,L.jsxs)(`header`,{className:`h-10 border-b border-border bg-panel flex items-center px-3 gap-4 sticky top-0 z-10`,children:[(0,L.jsxs)(`a`,{href:`#/`,className:`flex items-center gap-2 text-fg no-underline hover:no-underline`,children:[(0,L.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 32 32`,"aria-hidden":!0,children:[(0,L.jsx)(`path`,{d:`M6 22 L16 8 L26 22 Z`,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:`3`,strokeLinejoin:`round`}),(0,L.jsx)(`rect`,{x:`6`,y:`22`,width:`20`,height:`3`,fill:`var(--color-accent)`})]}),(0,L.jsx)(`span`,{className:`font-medium tracking-wide text-[13px]`,children:`caprock`}),(0,L.jsx)(`span`,{className:`text-fg-faint text-[11px] hidden sm:inline`,children:`mission control`})]}),(0,L.jsx)(`nav`,{className:`inline-flex items-center gap-0.5 ml-2 rounded-md bg-panel-2 p-0.5`,children:mt.map(e=>(0,L.jsxs)(`a`,{href:g(e.route),"aria-current":a(e.route)?`page`:void 0,className:`px-2.5 py-1 rounded-[5px] text-[12px] no-underline hover:no-underline transition-colors ${a(e.route)?`bg-accent text-panel font-medium`:`text-fg hover:text-accent`}`,children:[e.label,e.phase&&(0,L.jsx)(`span`,{className:`ml-1 text-[9px] uppercase tracking-wider text-fg-faint`,children:e.phase})]},e.label))}),(0,L.jsxs)(`div`,{className:`ml-auto flex items-center gap-3 text-[11px] text-fg-muted`,children:[(0,L.jsx)(Qe,{}),(0,L.jsx)(it,{}),(0,L.jsx)(Re,{screen:ht(e)}),(0,L.jsx)(vt,{state:n.conn,lastFrameAt:n.lastFrameAt}),(0,L.jsx)(Oe,{plan:r,onSave:i}),(0,L.jsx)(_t,{}),(0,L.jsx)(yt,{}),(0,L.jsx)(`a`,{href:`#/settings`,className:`text-fg-muted hover:text-fg no-underline`,children:`status`})]})]}),(0,L.jsx)(`main`,{className:`flex-1 p-3 max-w-[1600px] w-full mx-auto`,children:t}),(0,L.jsx)(lt,{})]})}function _t(){let[e,t]=M(),n=e===`dark`;return(0,L.jsx)(`button`,{type:`button`,onClick:t,title:n?`Switch to light theme`:`Switch to dark theme`,"aria-label":n?`Switch to light theme`:`Switch to dark theme`,className:`text-fg-muted hover:text-fg inline-flex items-center`,children:n?(0,L.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,L.jsx)(`path`,{d:`M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M19.1 4.9l-1.4 1.4M6.3 17.7l-1.4 1.4`})]}):(0,L.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z`})})})}function vt({state:e,lastFrameAt:t}){let n=re(1e3),r=e===`open`?`bg-ok`:e===`connecting`?`bg-warn`:`bg-danger`,i=e===`open`?`live · ${t?E(t,n):`connected`}`:e===`connecting`?`connecting…`:`disconnected — reconnecting`;return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:e===`open`?`Connected. Time since the daemon last sent anything.`:`WebSocket /v1/live`,children:[(0,L.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${r}`}),(0,L.jsx)(`span`,{className:`num`,children:i})]})}function yt(){let e=I(()=>P.status(),[],{live:!1,intervalMs:6e4}),t=I(()=>P.update().catch(()=>void 0),[],{live:!1,intervalMs:6e4}),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=e.data?.version;if(!o)return null;let s=/^v?\d+\.\d+\.\d+$/.test(o),c=s&&t.data?.update_available?t.data.latest:void 0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{onClick:()=>r(!0),className:c?`mono text-[11px] text-accent hover:text-accent-strong`:`mono text-[11px] text-fg-faint hover:text-fg`,title:c?`${c} is available — you are on ${o}`:`version and updates`,children:c?`${o} → ${c}`:s?o:`dev build`}),t.data?.notes&&(0,L.jsx)(`button`,{onClick:()=>a(!0),className:`text-[11px] text-fg-faint hover:text-accent`,title:`what changed in ${t.data.notes_for??`the latest release`}`,children:`what's new`}),n&&(0,L.jsx)(xt,{onClose:()=>r(!1)}),i&&t.data&&(0,L.jsx)(bt,{u:t.data,onClose:()=>a(!1)})]})}function bt({u:e,onClose:t}){return(0,L.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-start justify-center pt-[10vh] px-4`,onClick:t,children:(0,L.jsxs)(`div`,{className:`w-full max-w-[620px] max-h-[76vh] flex flex-col border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`What's new`,children:[(0,L.jsxs)(`div`,{className:`px-4 pt-3 pb-2 border-b border-border flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`text-[15px] font-medium`,children:`What's new`}),e.notes_for&&(0,L.jsx)(`span`,{className:`mono text-[12px] text-accent`,children:e.notes_for}),(0,L.jsx)(`button`,{onClick:t,className:`ml-auto text-[16px] leading-none text-fg-faint hover:text-fg`,children:`×`})]}),(0,L.jsx)(`div`,{className:`overflow-y-auto px-4 py-3`,children:(0,L.jsx)(ft,{text:e.notes??``})}),(0,L.jsx)(`div`,{className:`border-t border-border px-4 py-2.5`,children:(0,L.jsx)(`a`,{href:`https://caprock.dev/changelog`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[12px] text-fg-faint no-underline hover:text-accent`,children:`every release →`})})]})})}function xt({onClose:e}){let t=I(()=>P.status(),[],{live:!1,intervalMs:0}),n=I(()=>P.update().catch(()=>void 0),[],{live:!1,intervalMs:0}),[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(void 0),[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(()=>ve()??me(navigator.userAgent,navigator.userAgentData?.platform)),[f,p]=(0,l.useState)(!1),m=a??n.data,h=t.data?.version??``,g=/^v?\d+\.\d+\.\d+$/.test(h),_=!f&&ge(m?.command,u)?he(m?.command)??(u===`windows`?`macos`:u):u,v=pe(_),y=be(m?.command,v),[b,x]=(0,l.useState)(void 0),S=v.find(e=>e.label===b)??y??v[0],C=e=>{d(e),p(!0),ye(e),x(void 0)},w=async()=>{i(!0);try{o(await P.checkUpdate())}catch{}finally{i(!1)}},T=e=>{navigator.clipboard.writeText(e),c(e),setTimeout(()=>c(``),1600)};return(0,L.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-start justify-center pt-[10vh] px-4`,onClick:e,children:(0,L.jsxs)(`div`,{className:`w-full max-w-[560px] max-h-[80vh] overflow-y-auto border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Version and updates`,children:[(0,L.jsxs)(`div`,{className:`px-4 pt-3 pb-2 border-b border-border flex items-center`,children:[(0,L.jsx)(`span`,{className:`text-[15px] font-medium`,children:`Version`}),(0,L.jsx)(`button`,{onClick:e,className:`ml-auto text-[16px] leading-none text-fg-faint hover:text-fg`,children:`×`})]}),(0,L.jsxs)(`div`,{className:`p-4 grid gap-3.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2 text-[13px]`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:`running`}),(0,L.jsx)(`span`,{className:`mono text-fg`,children:g?h:`${h} (local build)`}),m?.update_available&&(0,L.jsxs)(`span`,{className:`mono text-accent`,children:[`→ `,m.latest,` is out`]})]}),m?.enabled===!1?(0,L.jsxs)(`div`,{className:`text-[13px] text-fg-muted`,children:[`Release checks are off, so this copy never asks GitHub what the latest version is. Turn them on in`,` `,(0,L.jsx)(`a`,{href:`#/status`,onClick:e,className:`text-accent no-underline hover:text-accent-strong`,children:`status`}),`.`]}):m?.update_available?null:(0,L.jsx)(`div`,{className:`text-[13px] text-fg-muted`,children:m?.latest?`Up to date — ${m.latest} is the latest release.`:`No newer release found.`}),(0,L.jsxs)(`div`,{className:`grid gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[se.map(e=>(0,L.jsx)(`button`,{onClick:()=>C(e.id),className:`rounded-sm px-2.5 py-1 text-[12px] transition-colors ${_===e.id?`bg-accent text-panel font-medium`:`text-fg-muted hover:text-fg`}`,children:e.label},e.id)),v.length>1&&(0,L.jsx)(`span`,{className:`ml-auto flex items-center gap-1`,children:v.map(e=>(0,L.jsxs)(`button`,{onClick:()=>x(e.label),className:`rounded-sm px-2 py-1 text-[11px] transition-colors ${S.label===e.label?`text-accent`:`text-fg-faint hover:text-fg-muted`}`,title:e.label===y?.label?`how this copy appears to be installed`:void 0,children:[e.label,e.label===y?.label?` ·`:``]},e.label))})]}),(0,L.jsx)(`ol`,{className:`grid gap-2.5`,children:S.steps.map((e,t)=>(0,L.jsxs)(`li`,{className:`grid gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`mono text-[11px] text-fg-faint`,children:t+1}),e.cmd?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`code`,{className:`mono flex-1 truncate rounded-sm border border-border bg-bg px-2 py-1.5 text-[13px] text-fg`,children:e.cmd}),(0,L.jsx)(`button`,{onClick:()=>T(e.cmd),className:`shrink-0 rounded-md border border-accent/45 bg-accent/[0.08] px-2.5 py-1.5 text-[12px] text-accent hover:bg-accent/[0.16]`,children:s===e.cmd?`copied`:`copy`})]}):(0,L.jsx)(`a`,{href:m?.url??`https://github.com/dspv/caprock/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`flex-1 rounded-sm border border-border bg-bg px-2 py-1.5 text-[13px] text-accent no-underline hover:text-accent-strong`,children:`Open the release page →`})]}),(0,L.jsx)(`p`,{className:`pl-5 text-[11px] leading-relaxed text-fg-faint`,children:e.note})]},t))})]}),(0,L.jsx)(`div`,{className:`text-[11px] leading-relaxed text-fg-faint border-t border-border pt-3`,children:`Caprock does not update itself: it would have to overwrite its own binary while running, and where a package manager owns that binary, replacing it behind their back breaks the next upgrade.`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`button`,{onClick:w,disabled:r,className:`rounded-md border border-border px-3 py-1.5 text-[13px] text-fg-muted hover:text-fg disabled:opacity-50`,children:r?`checking…`:`check now`}),(0,L.jsx)(`a`,{href:m?.url??`https://github.com/dspv/caprock/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[12px] text-fg-faint no-underline hover:text-accent`,children:`release notes →`})]})]})]})})}var St=class extends l.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[caprock ui]`,e,t.componentStack)}render(){return this.state.error?(0,L.jsxs)(`div`,{className:`border border-danger/50 bg-danger/10 rounded-[var(--radius-panel)] px-3 py-2 text-[12px]`,children:[(0,L.jsxs)(`div`,{className:`text-danger font-medium`,children:[this.props.label??`This view`,` failed to render`]}),(0,L.jsx)(`div`,{className:`mono text-fg-muted mt-1`,children:this.state.error.message}),(0,L.jsx)(`button`,{className:`mt-2 border border-border px-2 py-0.5 rounded-sm text-fg-muted hover:text-fg`,onClick:()=>this.setState({error:null}),children:`retry`})]}):this.props.children}};function R({title:e,center:t,right:n,children:r,className:i=``,onMouseEnter:a,onMouseLeave:o}){return(0,L.jsxs)(`section`,{className:`border border-border bg-panel rounded-[var(--radius-panel)] shadow-[var(--shadow-panel)] min-w-0 ${i}`,onMouseEnter:a,onMouseLeave:o,children:[(e||t||n)&&(0,L.jsxs)(`header`,{className:`relative flex items-center justify-between px-3 py-2 border-b border-border bg-panel-2/60 rounded-t-[var(--radius-panel)]`,children:[(0,L.jsx)(`h2`,{className:`text-[11px] uppercase tracking-[0.12em] text-fg-muted font-medium`,children:e}),t?(0,L.jsx)(`div`,{className:`absolute left-1/2 -translate-x-1/2`,children:t}):null,(0,L.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:n})]}),(0,L.jsx)(`div`,{children:r})]})}function z({label:e,value:t,sub:n,tone:r,size:i=`default`}){return(0,L.jsxs)(`div`,{className:`flex h-full flex-col px-3 py-2.5 min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:e}),(0,L.jsx)(`div`,{className:`num font-semibold tracking-[-0.01em] ${i===`hero`?`text-[34px] leading-[1.05]`:i===`compact`?`text-[17px] leading-tight`:`text-[24px] leading-[1.1]`} ${r===`ok`?`text-ok`:r===`warn`?`text-warn`:r===`danger`?`text-danger`:r===`info`?`text-info`:`text-fg`}`,children:t}),n&&(0,L.jsx)(`div`,{className:`mt-auto pt-1 text-[11px] text-fg-muted num truncate`,children:n})]})}var Ct={working:`working`,idle:`idle`,"waiting-on-you":`waiting on you`,looping:`looping?`,error:`error`,ended:`ended`};function wt(e){switch(e){case`working`:return`ok`;case`idle`:return`warn`;case`waiting-on-you`:return`warn`;case`looping`:return`danger`;case`error`:return`danger`;case`ended`:return`muted`}}function Tt({health:e}){let t=wt(e);return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 border rounded-sm px-1.5 py-[1px] text-[11px] leading-4 ${t===`ok`?`text-ok border-ok/40 bg-ok/10`:t===`warn`?`text-warn border-warn/40 bg-warn/10`:t===`danger`?`text-danger border-danger/40 bg-danger/10`:`text-fg-muted border-border bg-panel-2`}`,children:[(0,L.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${t===`ok`?`bg-ok`:t===`warn`?`bg-warn`:t===`danger`?`bg-danger`:`bg-fg-faint`} ${e===`working`?`animate-pulse`:``}`}),Ct[e]]})}function Et({values:e,width:t=120,height:n=24,tone:r=`info`}){if(e.length<2)return(0,L.jsx)(`svg`,{width:t,height:n,"aria-hidden":!0});let i=Math.max(...e,1e-9),a=Math.min(...e,0),o=i-a||1,s=t/(e.length-1),c=e.map((e,t)=>`${(t*s).toFixed(1)},${(n-(e-a)/o*(n-2)-1).toFixed(1)}`).join(` `),l=r===`ok`?`var(--color-ok)`:r===`warn`?`var(--color-warn)`:r===`danger`?`var(--color-danger)`:r===`accent`?`var(--color-accent)`:`var(--color-info)`;return(0,L.jsx)(`svg`,{width:t,height:n,viewBox:`0 0 ${t} ${n}`,className:`block`,"aria-hidden":!0,children:(0,L.jsx)(`polyline`,{fill:`none`,stroke:l,strokeWidth:`1.25`,points:c,vectorEffect:`non-scaling-stroke`})})}function Dt({title:e,children:t}){return(0,L.jsxs)(`div`,{className:`px-4 py-10 text-center`,children:[(0,L.jsx)(`div`,{className:`text-fg-muted`,children:e}),t&&(0,L.jsx)(`div`,{className:`text-[12px] text-fg-faint mt-1`,children:t})]})}function Ot({rows:e=3,className:t=``}){return(0,L.jsx)(`div`,{className:`px-3 py-2 grid gap-2 ${t}`,"aria-hidden":!0,children:Array.from({length:e},(e,t)=>(0,L.jsx)(`div`,{className:`h-3 rounded-sm bg-panel-2 skeleton-pulse`,style:{width:`${[92,74,83,61,88][t%5]}%`}},t))})}function kt({command:e,className:t=``}){let[n,r]=(0,l.useState)(!1);return(0,L.jsx)(`button`,{className:`mono text-[12px] bg-panel-2 border border-border px-2 py-0.5 rounded-sm hover:border-border-strong text-fg text-left ${t}`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{r(!0),window.setTimeout(()=>r(!1),1500)})},title:`copy to clipboard — run it in your terminal`,children:n?`copied`:`$ ${e}`})}var At={edit:{label:`writing code`,title:`Turns that wrote to a file — Edit, Write, NotebookEdit.`},command:{label:`running commands`,title:`Turns that ran a shell command — builds, tests, git, anything through Bash.`},read:{label:`reading and searching`,title:`Turns that read or searched the codebase — Read, Grep, Glob.`},web:{label:`web research`,title:`Turns that fetched or searched the web — WebFetch, WebSearch.`},mcp:{label:`MCP tools`,title:`Turns that called one of your own MCP integrations.`},other:{label:`other tools`,title:`Turns that called a tool in none of the categories above — subagents, task and skill control, and any tool Caprock does not yet know by name.`},none:{label:`no tool call`,title:`Turns that called no tool — reasoning, planning, or writing prose.`}},jt=`Each turn counts once, under its most expensive kind of tool. Rows add up to the total.`;function Mt({summary:e}){let t=e,n=t?.work??[],r=t?.work_unlinked_calls??0,i=t?.tool_calls??0,a=r>0&&i>0&&r/i>.01;return(0,L.jsxs)(R,{title:`What it went on`,right:(0,L.jsx)(`span`,{title:jt,children:`by cost`}),children:[t?n.length===0&&(0,L.jsx)(Dt,{title:`No priced turns in range`}):(0,L.jsx)(Ot,{rows:4}),(0,L.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,L.jsx)(`tbody`,{children:n.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1`,title:At[e.kind]?.title,children:At[e.kind]?.label??e.kind}),(0,L.jsxs)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:[e.turns,` turns`]}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:S(e.cost_usd)}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-faint w-14`,children:T(e.cost_pct)})]},e.kind))})}),a&&(0,L.jsxs)(`div`,{className:`mx-3 mb-2.5 text-[11px] text-warn`,children:[r.toLocaleString(),` tool calls could not be matched to a turn, so their cost lands under “no tool call”. The other rows are understated.`]})]})}function Nt({summary:e}){let t=e?.work??[],n=e?.work_unlinked_calls??0,r=e?.tool_calls??0;if(t.length===0||r===0||n/r>.2)return null;let i=t.filter(e=>e.cost_pct>=1).slice(0,5);return i.length===0?null:(0,L.jsxs)(`div`,{className:`border-t border-border px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,L.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:`what it went on`}),(0,L.jsx)(`a`,{href:`#/cost`,className:`text-[10px] text-fg-faint hover:text-accent no-underline`,children:`details →`})]}),(0,L.jsx)(`div`,{className:`mt-2 flex h-1.5 w-full overflow-hidden rounded-full bg-panel-2`,title:jt,children:i.map((e,t)=>(0,L.jsx)(`span`,{className:`h-full`,style:{width:`${e.cost_pct}%`,background:`var(--color-accent)`,opacity:1-t*.17}},e.kind))}),(0,L.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1`,children:i.map((e,t)=>(0,L.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 text-[11px]`,children:[(0,L.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-[2px] translate-y-[1px]`,style:{background:`var(--color-accent)`,opacity:1-t*.17}}),(0,L.jsx)(`span`,{className:`text-fg-muted`,title:At[e.kind]?.title,children:At[e.kind]?.label??e.kind}),(0,L.jsx)(`span`,{className:`num text-fg-faint`,children:T(e.cost_pct)})]},e.kind))})]})}var Pt=.62;function Ft(e,t){return e?t===`tokens`?e.tokens??[]:e.cost??[]:[]}function It(e,t,n){let r=Ft(e,t);if(!e||r.length===0)return[];let i=n>0?n:0;return r.map((t,n)=>{let r=Number.isFinite(t)&&t>0?t:0,a=i>0&&r>0?Math.min(1,r/i)**+Pt:0;return{value:r,at:e.from_ms+n*e.width_ms,height:a,empty:r<=0}})}function Lt(e,t){let n=0;for(let r of e)for(let e of Ft(r,t))Number.isFinite(e)&&e>n&&(n=e);return n}function Rt(e,t){let n=new Date(e);return t<864e5?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n.toLocaleDateString([],{month:`short`,day:`numeric`})}function zt(e){return e.split(`/`).filter(Boolean)}function Bt(e,t=3){let n=[],r=new Map,i=[],a=(e,t)=>{let n=r.get(e);if(n)return n;let o=zt(e),s={path:e,name:o.length===0?`/`:o[o.length-1],depth:t,tokens:0,cost:0,turns:0,tokensPct:0,costPct:0,ownTokens:0,ownCost:0,ownTurns:0,ownTokensPct:0,ownCostPct:0,children:[],rolledUp:0};if(r.set(e,s),t===0)i.push(s);else{let e=t===1?`/`:`/`+o.slice(0,t-1).join(`/`);a(e,t-1).children.push(s)}return s};for(let r of e){if(r.unattributed||r.outside){n.push(r);continue}let e=zt(r.path),i=e.length,o=Math.min(i,t),s=a(o===0?`/`:`/`+e.slice(0,o).join(`/`),o);s.ownTokens+=r.tokens,s.ownCost+=r.cost_usd,s.ownTurns+=r.turns,s.ownTokensPct+=r.tokens_pct,s.ownCostPct+=r.cost_pct,i>o&&s.rolledUp++;for(let t=0;t<=o;t++){let n=a(t===0?`/`:`/`+e.slice(0,t).join(`/`),t);n.tokens+=r.tokens,n.cost+=r.cost_usd,n.tokensPct+=r.tokens_pct,n.costPct+=r.cost_pct,n.turns+=r.turns}}let o=i[0],s=i;o&&o.path===`/`&&(s=[...o.children],(o.ownTokens>0||o.ownCost>0||o.ownTurns>0||o.rolledUp>0)&&s.push({...o,depth:1,tokens:o.ownTokens,cost:o.ownCost,turns:o.ownTurns,tokensPct:o.ownTokensPct,costPct:o.ownCostPct,children:[],ownTokens:o.ownTokens,ownCost:o.ownCost,ownTurns:o.ownTurns}));let c=e=>{e.sort((e,t)=>t.cost-e.cost);for(let t of e)c(t.children)};return c(s),{roots:s,buckets:n}}function Vt(e){return e.map(e=>{let t=e;for(;t.children.length===1&&t.ownTokens===0&&t.ownCost===0&&t.ownTurns===0&&t.rolledUp===0;)t=t.children[0];return{...t,children:Vt(t.children)}})}var Ht=[{key:`all`,label:`all`},{key:`claude`,label:`claude`},{key:`opencode`,label:`opencode`},{key:`gemini`,label:`gemini`}];function Ut(e){switch(e){case`opencode`:return`oc`;case`gemini`:return`gem`;default:return``}}function Wt(e){switch(e){case`opencode`:return`OpenCode`;case`gemini`:return`Gemini`;default:return`Claude Code`}}var Gt=[{key:`today`,label:`today`},{key:`7d`,label:`7d`},{key:`30d`,label:`30d`},{key:`all`,label:`all`}],Kt=`tokens`,qt=`Cost is charged to the folder Claude was last working in. Rows add up to the repository total.`,Jt=`repository-wide work`,Yt=`Turns from the start of a session, before Claude had touched any file — so there is no directory yet for them to count toward. Their cost is counted here whole rather than guessed onto the directory the session reached later.`,Xt=`outside the repository`,Zt=`Work on this project whose files live elsewhere — Claude’s notes, scratchpads, test output. Counted in the repository total, but not under any folder.`;function Qt({sessions:e,agent:t}){let[n,r]=(0,l.useState)(`7d`),[i,a]=(0,l.useState)(!1),o=I(()=>P.summary(n),[n],{intervalMs:3e4}),s=o.data?.projects??[],c=(0,l.useMemo)(()=>t===`all`?s:s.filter(e=>!e.agent||e.agent===t),[s,t]),[u,d]=(0,l.useState)(null),f=(0,l.useMemo)(()=>{if(!u)return c;let e=new Map(u.map((e,t)=>[e,t]));return[...c].sort((t,n)=>(e.get(t.project)??1/0)-(e.get(n.project)??1/0))},[c,u]),p=i?f:f.slice(0,6),m=c.reduce((e,t)=>e+t.cost_usd,0),h=c.reduce((e,t)=>e+t.tokens,0),g=(0,l.useMemo)(()=>Lt(p.map(e=>e.spark),Kt),[p]),_=(0,l.useMemo)(()=>p.reduce((e,t)=>Math.max(e,t.tokens),0),[p]);return(0,L.jsx)(R,{onMouseEnter:()=>d(c.map(e=>e.project)),onMouseLeave:()=>d(null),title:`Projects`,right:(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`span`,{className:`num text-[13px]`,children:[(0,L.jsx)(`span`,{className:`text-fg`,children:C(h)}),(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,S(m),` total`]})]}),(0,L.jsx)(`span`,{className:`inline-flex border border-border rounded-sm overflow-hidden`,children:Gt.map(e=>(0,L.jsx)(`button`,{onClick:()=>r(e.key),className:`px-1.5 py-0.5 text-[11px] mono ${n===e.key?`bg-panel-2 text-fg`:`text-fg-faint hover:text-fg-muted`}`,children:e.label},e.key))})]}),children:o.data?c.length===0?(0,L.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-fg-muted`,children:`No spend captured in this range yet.`}):(0,L.jsxs)(`div`,{className:`grid`,children:[p.map(t=>(0,L.jsx)(en,{p:t,max:_,ceiling:g,live:$t(e).has(t.project)},t.project||`(unknown)`)),c.length>6&&(0,L.jsx)(`button`,{onClick:()=>a(e=>!e),className:`text-[11px] text-fg-faint hover:text-fg-muted px-3 py-1.5 text-left border-t border-border`,children:i?`show less`:`show all ${c.length} projects`}),(0,L.jsx)(Nt,{summary:o.data}),(0,L.jsx)(on,{count:c.length})]}):(0,L.jsx)(Ot,{rows:5})})}function $t(e){return new Set(e.filter(e=>e.status!==`ended`).map(e=>e.project).filter(Boolean))}function en({p:e,max:t,ceiling:n,live:r}){let i=e.paths??[],a=i.length>1,[o,s]=(0,l.useState)(!1),c=e.project||`unknown project`,u=t>0?100*e.tokens/t:0,d=(0,l.useMemo)(()=>It(e.spark,Kt,n),[e.spark,n]),f=(0,l.useMemo)(()=>{let e=Bt(i);return{roots:Vt(e.roots),buckets:e.buckets}},[i]),p=(0,l.useMemo)(()=>Math.max(0,...f.roots.map(e=>e.tokens),...f.buckets.map(e=>e.tokens)),[f]),m=(0,L.jsxs)(`div`,{className:`grid grid-cols-[1fr_128px_auto] items-center gap-3 w-full text-left`,children:[(0,L.jsx)(`div`,{className:`min-w-0`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,L.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-ok shrink-0`,title:`a session is live in this project`}),(0,L.jsx)(`span`,{className:`truncate text-[14px]`,children:c}),Ut(e.agent)&&(0,L.jsx)(`span`,{className:`shrink-0 text-[9px] uppercase tracking-[0.08em] text-fg-faint border border-border px-1 rounded-sm`,children:Ut(e.agent)}),(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-faint num shrink-0`,children:[e.sessions,` `,e.sessions===1?`session`:`sessions`]}),a&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-[9px] text-fg-faint shrink-0 transition-transform ${o?`rotate-90`:``}`,children:`▶`})]})}),d.length>0?(0,L.jsx)(an,{bars:d,widthMs:e.spark?.width_ms??0,label:c}):(0,L.jsx)(`div`,{className:`h-1 bg-panel-2 rounded-sm overflow-hidden`,title:`${c}: share of the largest project`,children:(0,L.jsx)(`div`,{className:`h-full bg-accent/70`,style:{width:`${u}%`}})}),(0,L.jsxs)(`div`,{className:`text-right shrink-0`,children:[(0,L.jsx)(`div`,{className:`num text-[17px] font-semibold leading-tight text-accent`,children:C(e.tokens)}),(0,L.jsx)(`div`,{className:`num text-[13px] leading-tight text-fg-muted`,children:S(e.cost_usd)})]})]});return(0,L.jsxs)(`div`,{className:`border-t border-border first:border-t-0`,children:[a?(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,className:`w-full px-3 py-1.5 hover:bg-panel-2/50`,title:`${c}: show cost by directory`,children:m}):(0,L.jsx)(`div`,{className:`px-3 py-1.5`,children:m}),a&&o&&(0,L.jsxs)(`div`,{className:`pb-1.5 bg-panel-2/30`,children:[(0,L.jsx)(`div`,{className:`pl-7 pr-3 pt-1 pb-0.5 text-[10px] text-fg-faint`,title:qt,children:`by files touched · share of this repository's tokens`}),f.roots.map(e=>(0,L.jsx)(tn,{n:e,max:p},e.path)),f.buckets.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`pl-7 pr-3 pt-2 pb-0.5 text-[10px] uppercase tracking-[0.08em] text-fg-faint`,children:`not a directory`}),f.buckets.map(e=>(0,L.jsx)(nn,{q:e,max:p},e.path))]})]})]})}function tn({n:e,max:t}){let[n,r]=(0,l.useState)(!1),i=t>0?100*e.tokens/t:0,a=e.children.length>0,o=(0,l.useMemo)(()=>Math.max(0,...e.children.map(e=>e.tokens)),[e.children]),s=a&&e.ownCost>0,c=e.children.length,u=(0,L.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center gap-3 w-full text-left`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`truncate text-[12px] text-fg-muted mono`,children:e.path}),e.rolledUp>0&&(0,L.jsxs)(`span`,{className:`text-[10px] text-fg-faint shrink-0`,title:`${e.rolledUp} ${e.rolledUp===1?`directory`:`directories`} below this one ${e.rolledUp===1?`is`:`are`} counted here rather than shown: the breakdown stops at 3 levels.`,children:[`+`,e.rolledUp,` deeper`]}),(0,L.jsxs)(`span`,{className:`text-[10px] text-fg-faint num shrink-0`,children:[e.turns,` `,e.turns===1?`turn`:`turns`]}),a&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-[9px] text-fg-faint shrink-0 transition-transform ${n?`rotate-90`:``}`,children:`▶`})]}),s&&(0,L.jsxs)(`div`,{className:`text-[10px] text-fg-faint mt-0.5`,children:[S(e.ownCost),` here · `,S(e.cost-e.ownCost),` in `,c,` `,c===1?`subdirectory`:`subdirectories`]}),(0,L.jsx)(`div`,{className:`h-0.5 mt-1 bg-panel-2 rounded-sm overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full bg-accent/40`,style:{width:`${i}%`}})})]}),(0,L.jsxs)(`div`,{className:`text-right shrink-0 num text-[12px]`,title:`${rn(e.costPct)} of this repository's cost`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:C(e.tokens)}),(0,L.jsxs)(`span`,{className:`text-fg-faint`,children:[` `,rn(e.tokensPct)]}),(0,L.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,S(e.cost)]})]})]}),d={paddingLeft:`${28+(e.depth-1)*14}px`};return(0,L.jsxs)(`div`,{children:[a?(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`w-full pr-3 py-1 hover:bg-panel-2/50`,style:d,title:`${e.path}: show the directories inside it`,children:u}):(0,L.jsx)(`div`,{className:`pr-3 py-1`,style:d,children:u}),a&&n&&e.children.map(e=>(0,L.jsx)(tn,{n:e,max:o},e.path))]})}function nn({q:e,max:t}){let n=t>0?100*e.tokens/t:0,r=e.unattributed===!0;return(0,L.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center gap-3 pl-7 pr-3 py-1`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`truncate text-[12px] text-fg-muted`,title:r?Yt:Zt,children:r?Jt:Xt}),(0,L.jsxs)(`span`,{className:`text-[10px] text-fg-faint num shrink-0`,children:[e.turns,` `,e.turns===1?`turn`:`turns`]})]}),(0,L.jsx)(`div`,{className:`h-0.5 mt-1 bg-panel-2 rounded-sm overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full bg-fg-faint/30`,style:{width:`${n}%`}})})]}),(0,L.jsxs)(`div`,{className:`text-right shrink-0 num text-[12px]`,title:`${rn(e.cost_pct)} of this repository's cost`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:C(e.tokens)}),(0,L.jsxs)(`span`,{className:`text-fg-faint`,children:[` `,rn(e.tokens_pct)]}),(0,L.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,S(e.cost_usd)]})]})]})}function rn(e){return!Number.isFinite(e)||e<=0?`0%`:e<.1?`<0.1%`:T(e)}function an({bars:e,widthMs:t,label:n}){let r=(0,l.useRef)(null);(0,l.useEffect)(()=>{let t=r.current;if(!t)return;let n=()=>{let n=t.clientWidth,r=t.clientHeight;if(n===0||r===0)return;let i=window.devicePixelRatio||1;t.width=Math.round(n*i),t.height=Math.round(r*i);let a=t.getContext(`2d`);if(!a)return;a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,n,r);let o=getComputedStyle(t),s=o.getPropertyValue(`--color-accent`).trim()||`#feb157`,c=o.getPropertyValue(`--color-fg-faint`).trim()||`#837f78`,l=n/e.length;for(let t=0;ti.disconnect()},[e]);let i=e.filter(e=>!e.empty),a=i[0],o=i[i.length-1],s=!a||!o?`no spend in this range`:a===o?`all of it on ${Rt(a.at,t)}`:`${Rt(a.at,t)} → ${Rt(o.at,t)}`;return(0,L.jsx)(`canvas`,{ref:r,className:`w-full h-[14px] block`,role:`img`,"aria-label":`${n}: ${Kt} over time, ${s}`,title:`${n}: when the spend happened — ${s}`})}function on({count:e}){return e<10?null:(0,L.jsxs)(`a`,{href:`https://caprock.dev/teams`,target:`_blank`,rel:`noreferrer`,className:`flex items-baseline gap-2 border-t border-border px-3 py-1.5 text-[11px] no-underline hover:no-underline`,children:[(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[e,` repositories on one machine.`]}),(0,L.jsx)(`span`,{className:`text-fg-faint hover:text-accent`,children:`See them across the team →`})]})}function sn(e){return typeof e==`string`?e:``}function cn(e){let t=e.split(/[/\\]/).filter(Boolean);return t[t.length-1]??e}function ln(e,t){let n=e.replace(/\s+/g,` `).trim(),r=[...n];return r.length>t?r.slice(0,t-1).join(``)+`…`:n}function un(e){return e.replace(/(\/[\w.@%+-]+){3,}/g,e=>`…/`+e.split(`/`).filter(Boolean).slice(-2).join(`/`))}function dn(e,t){switch(e){case`Edit`:case`NotebookEdit`:return sn(t.file_path)?{icon:`✎`,text:`editing`,detail:cn(sn(t.file_path))}:null;case`Write`:return sn(t.file_path)?{icon:`✎`,text:`writing`,detail:cn(sn(t.file_path))}:null;case`Read`:return sn(t.file_path)?{icon:`◇`,text:`reading`,detail:cn(sn(t.file_path))}:null;case`Bash`:return sn(t.command)?{icon:`$`,text:`running`,detail:ln(un(sn(t.command)),46)}:null;case`Grep`:case`Glob`:return{icon:`⌕`,text:`searching`,detail:ln(sn(t.pattern)||sn(t.query),40)||void 0};case`WebFetch`:case`WebSearch`:return{icon:`⇢`,text:`fetching`,detail:ln(sn(t.url)||sn(t.query),44)||void 0};case`Agent`:return{icon:`⚑`,text:`spawned a subagent`,detail:sn(t.subagent_type)||void 0};case`Skill`:return{icon:`⚑`,text:`invoked skill`,detail:sn(t.skill)||void 0};case`TodoWrite`:return{icon:`☑`,text:`updated its plan`};default:return e?{icon:`·`,text:`used`,detail:e}:null}}function fn(e,t){let n=e.payload??{},r=Date.parse(e.ts),i={id:`${e.id}`,ts:Number.isNaN(r)?Date.now():r,sessionId:e.session_id,project:t};switch(e.kind){case`tool.pre`:{let t=dn(sn(n.tool_name)||sn(e.tool),n.tool_input??{});return t?{...i,...t,tone:`normal`}:null}case`tool.post`:return n.is_error?{...i,icon:`✕`,text:`a tool call failed`,tone:`danger`}:null;case`agent.spawn`:return{...i,icon:`▸`,text:`session started`,tone:`ok`};case`agent.stop`:return{...i,icon:`■`,text:`session ended`,tone:`normal`};case`context.compact`:return{...i,icon:`⇱`,text:`compacted its context`,tone:`warn`};case`throttle`:return{...i,icon:`⏳`,text:`rate-limited by the API`,tone:`warn`};case`task.created`:return{...i,icon:`+`,text:`task created`,tone:`normal`};case`task.done`:return{...i,icon:`✓`,text:`task verified — tests passed`,tone:`ok`};case`approval.requested`:return{...i,icon:`!`,text:`needs your approval`,tone:`warn`};default:return null}}function pn(e,t,n=60){return e.some(e=>e.id===t.id)?e:[t,...e].slice(0,n)}function mn({sessions:e,now:t,emptyHint:n}){let[r,i]=(0,l.useState)([]),[a,o]=(0,l.useState)(!1),s=(0,l.useRef)(new Map),c=(0,l.useRef)(a);c.current=a;for(let t of e)t.project&&s.current.set(t.session_id,t.project);(0,l.useEffect)(()=>{let t=!1;return(async()=>{let n=[...e].sort((e,t)=>t.last_event_at-e.last_event_at).slice(0,4),r=await Promise.all(n.map(e=>P.recentEvents(e.session_id,60).catch(()=>[])));if(t)return;let a=r.flat().map(e=>fn(e)).filter(e=>e!==null).sort((e,t)=>t.ts-e.ts).slice(0,40);i(e=>{let t=new Set(n.map(e=>e.session_id)),r=e.filter(e=>!e.sessionId||t.has(e.sessionId)),i=new Set(r.map(e=>e.id));return[...r,...a.filter(e=>!i.has(e.id))].sort((e,t)=>t.ts-e.ts).slice(0,60)})})(),()=>{t=!0}},[e.map(e=>e.session_id).join(`,`)]);let u=(0,l.useRef)(new Set);return u.current=new Set(e.map(e=>e.session_id)),(0,l.useEffect)(()=>d.onFrame(e=>{if(e.type!==`event`||c.current)return;let t=e.data?.session_id;if(t&&s.current.has(t)&&!u.current.has(t))return;let n=fn(e.data);n&&i(e=>pn(e,n))}),[]),(0,L.jsx)(R,{title:`Live activity`,right:(0,L.jsx)(`button`,{onClick:()=>o(e=>!e),className:`text-[11px] mono text-fg-faint hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,children:a?`resume`:`pause`}),children:r.length===0?(0,L.jsx)(`div`,{className:`px-3 py-4 text-[12px] text-fg-muted`,children:n??(0,L.jsxs)(L.Fragment,{children:[`Nothing yet — start `,(0,L.jsx)(`span`,{className:`mono`,children:`claude`}),` in any terminal.`]})}):(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`div`,{className:`max-h-[420px] overflow-y-auto`,children:r.map(e=>(0,L.jsx)(gn,{it:e,now:t,project:s.current.get(e.sessionId)},e.id))}),(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-panel to-transparent`})]})})}function hn(e){switch(e){case`ok`:return`text-ok`;case`warn`:return`text-warn`;case`danger`:return`text-danger`;default:return`text-fg-faint`}}function gn({it:e,now:t,project:n}){return(0,L.jsxs)(`a`,{href:g({name:`session`,id:e.sessionId}),className:`grid grid-cols-[auto_auto_1fr_auto] items-baseline gap-2 px-3 py-1 border-t border-border first:border-t-0 hover:bg-panel-2 no-underline text-fg`,children:[(0,L.jsx)(`span`,{className:`mono text-[12px] w-3 text-center ${hn(e.tone)}`,children:e.icon}),(0,L.jsx)(`span`,{className:`mono text-[11px] text-fg-muted truncate max-w-[12ch]`,children:n??e.project??ee(e.sessionId)}),(0,L.jsxs)(`span`,{className:`text-[12px] truncate`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:e.text}),e.detail&&(0,L.jsx)(`span`,{className:`mono text-fg ml-1.5`,children:e.detail})]}),(0,L.jsx)(`span`,{className:`num text-[11px] text-fg-faint`,children:E(e.ts,t)})]})}function _n(e){return e?.plan_kind===`metered`?`at API list price · ≈ your bill`:e?.plan_kind===`flat`?`at API list price · not a bill`:`at API list price`}function vn(e){return e?.plan_kind===`metered`?`Roughly your real bill — you pay per token. At Anthropic list prices.`:e?.plan_kind===`flat`?`At Anthropic list prices — what this work would cost through the API. You pay ${e.plan_label||`a flat plan`}, so it is not money out of pocket.`:`At Anthropic list prices. Set your plan in the header to see how it compares to your bill.`}function yn({plan:e}){let t=I(()=>P.history(`all`),[],{intervalMs:6e4}).data?.totals;if(!t||t.sessions===0)return null;let n=t.days>0?t.sessions/t.days:0;return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-6 gap-y-1 rounded-[var(--radius-panel)] border border-border bg-panel px-3 py-2.5`,children:[(0,L.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:`all time`}),(0,L.jsxs)(`span`,{className:`inline-flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`num font-semibold tracking-[-0.01em] text-[22px] leading-none text-info`,children:S(t.cost_usd)}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,title:vn(e),children:_n(e)})]}),(0,L.jsx)(bn,{value:t.sessions.toLocaleString(`en-US`),label:`sessions`}),(0,L.jsx)(bn,{value:t.days.toLocaleString(`en-US`),label:`active days`}),(0,L.jsx)(bn,{value:t.turns.toLocaleString(`en-US`),label:`turns`}),n>=1&&(0,L.jsx)(bn,{value:n.toFixed(1),label:`sessions a day`}),(0,L.jsx)(`span`,{className:`ml-auto inline-flex items-baseline gap-4`,children:(0,L.jsx)(xn,{})})]})}function bn({value:e,label:t}){return(0,L.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,L.jsx)(`span`,{className:`num text-[13px] text-fg`,children:e}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:t})]})}function xn(){let e=I(()=>P.daily(30),[],{intervalMs:3e5}),t=I(()=>P.summary(`today`),[],{intervalMs:3e4}),n=e.data??[];if(n.length===0)return null;let r=new Map;for(let e of n)r.set(e.day,(r.get(e.day)??0)+e.cost_usd);let i=[...r.values()].filter(e=>e>0).sort((e,t)=>e-t);if(i.length<7)return null;let a=i[Math.floor(i.length/2)]??0,o=t.data?.cost_usd??0;return a<=0||o=99?{label:`outstanding`,color:`text-ok`}:e>=95?{label:`good`,color:`text-ok`}:e>=85?{label:`ok`,color:``}:{label:`low`,color:`text-warn`}}function Cn({hitRate:e,cutPct:t,measured:n,size:r=`compact`,label:i=`Cache hit`}){let a=n&&e!==void 0?e*100:void 0,o=Sn(a);return(0,L.jsx)(z,{label:i,value:(0,L.jsxs)(`span`,{className:`inline-flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{children:a===void 0?`—`:T(a)}),o&&(0,L.jsx)(`span`,{className:`text-[11px] font-normal ${o.color||`text-fg-faint`}`,children:o.label})]}),sub:n&&t!==void 0?`${T(t)} input cost cut`:void 0,size:r})}function wn(e,t){let n=Math.round(e.used_percentage),r=(e.resets_at??0)*1e3,i=r>t&&r85?`text-danger`:n>=60?`text-warn`:`text-fg`,resetsAt:i?new Date(r).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):null,stale:e.resets_at?!i:!1}}function Tn({label:e,w:t,now:n}){let{pct:r,color:i,resetsAt:a,stale:o}=wn(t,n);return(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:e}),(0,L.jsxs)(`span`,{className:`flex items-baseline gap-3`,children:[(0,L.jsxs)(`span`,{className:`font-mono tabular-nums ${i}`,children:[r,`%`]}),a&&(0,L.jsxs)(`span`,{className:`text-fg-faint`,children:[`resets `,a]}),o&&(0,L.jsx)(`span`,{className:`text-fg-faint`,title:`Claude Code has not refreshed this window recently`,children:`reset time stale`}),t.forecast&&(0,L.jsx)(`span`,{className:`text-warn`,children:t.forecast})]})]})}function En({limits:e,now:t}){let n=[];if(e?.five_hour&&n.push([`5h`,e.five_hour]),e?.seven_day&&n.push([`7d`,e.seven_day]),n.length===0)return null;let r=n.map(([e,n])=>({label:e,...wn(n,t)})),i=r.filter(e=>!e.stale),a=i.length===0,o=(i.length?i:r).reduce((e,t)=>t.pct>e.pct?t:e),s=r.find(e=>e.label!==o.label);return(0,L.jsx)(z,{label:`Plan limits`,value:(0,L.jsxs)(`span`,{className:a?`text-fg-faint`:o.color,children:[o.pct,`%`]}),sub:a?(0,L.jsx)(`span`,{title:`Claude Code writes these to its status line; they stop updating when no session is running`,children:`last reported a while ago`}):(0,L.jsxs)(`span`,{children:[o.label,` window`,o.resetsAt?` · resets ${o.resetsAt}`:``,s?` · ${s.label} ${s.pct}%`:``]}),tone:a?void 0:o.pct>85?`danger`:o.pct>=60?`warn`:void 0,size:`compact`})}var Dn=`caprock-prompts`,On={"share-week":6048e5,"share-month":2592e6,"premium-hint":2592e6,"premium-banner":2592e6};function kn(){try{let e=localStorage.getItem(Dn);return e?JSON.parse(e):{}}catch{return{}}}function An(e){try{localStorage.setItem(Dn,JSON.stringify(e))}catch{}}function jn(e,t){let n=kn()[e];return!n||t-n>=On[e]}function Mn(e,t){let n={...kn(),[e]:t};e===`share-month`&&(n[`share-week`]=t),An(n)}var Nn=`premium-banner`;function Pn({costUSD:e,days:t,now:n}){let[r]=(0,l.useState)(()=>jn(Nn,n)),[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(!1);if(!r||i||e<=0||t<=0)return null;let c=e/t;return(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded-[var(--radius-panel)] border border-border bg-panel-2 px-3 py-2 text-[12px]`,children:[(0,L.jsxs)(`span`,{className:`text-fg`,children:[(0,L.jsx)(`span`,{className:`num`,children:S(c)}),(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[` a day, on average, across `,t,` active `,t===1?`day`:`days`,`.`]})]}),(0,L.jsx)(`span`,{className:`text-fg-muted`,children:`Premium pauses sessions when the day crosses a limit you set.`}),(0,L.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(`button`,{onClick:()=>s(!0),className:`rounded-sm border border-accent/50 bg-accent/10 px-2 py-0.5 text-accent hover:bg-accent/20`,children:`what it does`}),(0,L.jsx)(`button`,{onClick:()=>{Mn(Nn,n),a(!0)},className:`rounded-sm border border-border px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg-muted`,title:`hide this for a month`,children:`not now`})]}),o&&(0,L.jsx)(rt,{feature:`cap`,onClose:()=>s(!1)})]})}var Fn=[1e3,5e3,1e4,25e3,5e4,1e5],In=e=>e>=1e3?`$${Math.round(e).toLocaleString(`en-US`)}`:`$${e.toFixed(2)}`;function Ln(e){let t=Fn.filter(t=>e>=t).pop();return t===void 0||e-t>t*.1?null:{kind:`milestone`,line:`You just passed ${In(t)} of Claude Code.`}}function Rn(e,t){return e<7||e>10?null:{kind:`first-week`,line:`A week of Claude Code: ${In(t)} measured.`}}function zn(e){if(e.length<3)return null;let[t,...n]=e;if(t===void 0)return null;let r=Math.max(...n);return r<=0||tt[0].localeCompare(e[0])),r=[];for(let e=0;ee+t[1],0));return r}function Vn(e,t,n){return e.sessions===0||e.cost_usd<=0?null:Ln(e.cost_usd)??Rn(e.days,n.cost_usd)??zn(Bn(t))}var Hn=`share-week`;function Un({now:e}){let[t]=(0,l.useState)(()=>jn(Hn,e)),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=I(()=>P.history(`all`),[],{intervalMs:3e5}),s=I(()=>P.summary(`7d`),[],{intervalMs:3e5});if(!t||n||!o.data||!s.data)return null;let c=Vn(o.data.totals,o.data.daily??[],s.data);if(!c)return null;let u=()=>{Mn(Hn,e),r(!0)};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2.5 rounded-lg border border-accent/35 bg-accent/[0.07] py-1.5 pl-3.5 pr-2 text-[13px]`,children:[(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[c.line,` Don’t be shy and share it off —`]}),(0,L.jsx)(`button`,{onClick:()=>{a(!0),u()},className:`rounded-[5px] bg-accent px-3 py-1 font-medium text-panel hover:bg-accent/90`,children:`Share`}),(0,L.jsx)(`button`,{onClick:u,title:`hide this for a week`,className:`px-1 text-fg-faint hover:text-fg-muted`,children:`✕`})]}),i&&(0,L.jsx)($e,{onClose:()=>a(!1)})]})}function Wn(){let e=I(()=>P.history(`all`),[],{intervalMs:6e4}),t=(e.data?.tools??[]).slice(0,6),n=(e.data?.summary?.models??[]).slice(0,5);if(t.length===0&&n.length===0)return null;let r=t[0]?.count??0,i=n[0]?.cost_usd??0,a=(e.data?.tools??[]).reduce((e,t)=>e+t.count,0),o=(e.data?.summary?.models??[]).reduce((e,t)=>e+t.cost_usd,0),s=e.data?.summary,c=s&&(s.tokens_in||s.tokens_out||s.cache_read||s.cache_write)?{in:s.tokens_in,out:s.tokens_out,cacheRead:s.cache_read,cacheWrite:s.cache_write}:null;return(0,L.jsxs)(R,{title:`All time`,right:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-3`,children:[(0,L.jsx)(Un,{now:Date.now()}),(0,L.jsx)(et,{}),(0,L.jsx)(`a`,{href:`#/history`,className:`text-fg-faint hover:text-accent no-underline`,children:`every tool, model and project →`})]}),children:[(0,L.jsxs)(`div`,{className:`grid gap-x-8 gap-y-5 px-3 py-3 md:grid-cols-2`,children:[(0,L.jsx)(Gn,{title:`Most-used tools`,cols:{value:`calls`,sub:`returned`,share:`share`},rows:t.map(e=>({key:e.tool,label:te(e.tool),value:e.count.toLocaleString(`en-US`),sub:e.bytes>0?w(e.bytes):``,share:a>0?100*e.count/a:null,frac:r>0?e.count/r:0}))}),(0,L.jsx)(Gn,{title:`Where the money went`,cols:{value:`cost`,sub:`tokens`,share:`share`},rows:n.map(e=>({key:e.model,label:e.model||`unknown`,value:S(e.cost_usd),sub:C(e.tokens),share:o>0?100*e.cost_usd/o:null,frac:i>0?e.cost_usd/i:0}))})]}),c&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-6 gap-y-1 border-t border-border px-3 py-2 text-[11px]`,children:[(0,L.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:`Tokens`}),(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[`input `,(0,L.jsx)(`span`,{className:`num text-fg`,children:C(c.in)})]}),(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[`output `,(0,L.jsx)(`span`,{className:`num text-fg`,children:C(c.out)})]}),(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[`cache read `,(0,L.jsx)(`span`,{className:`num text-fg`,children:C(c.cacheRead)})]}),(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[`cache write `,(0,L.jsx)(`span`,{className:`num text-fg`,children:C(c.cacheWrite)})]}),(0,L.jsx)(`span`,{className:`ml-auto text-fg-faint`,children:`fresh input is billed at full price`})]})]})}function Gn({title:e,cols:t,rows:n}){return n.length===0?null:(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[10px] uppercase tracking-[0.08em] text-fg-faint`,children:[(0,L.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tracking-[0.12em]`,children:e}),(0,L.jsx)(`span`,{className:`flex-1`}),(0,L.jsx)(`span`,{className:`num w-20 shrink-0 text-right`,children:t.value}),(0,L.jsx)(`span`,{className:`num w-16 shrink-0 text-right`,children:t.sub??``}),(0,L.jsx)(`span`,{className:`num w-9 shrink-0 text-right`,children:t.share})]}),(0,L.jsx)(`div`,{className:`grid gap-1.5`,children:n.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,L.jsx)(`span`,{className:`mono w-36 shrink-0 truncate text-fg-muted`,title:e.label,children:e.label}),(0,L.jsx)(`span`,{className:`h-1.5 flex-1 rounded-full bg-panel-2`,children:(0,L.jsx)(`span`,{className:`block h-full rounded-full bg-accent/70`,style:{width:`${Math.max(2,Math.round(e.frac*100))}%`}})}),(0,L.jsx)(`span`,{className:`num w-20 shrink-0 text-right text-fg`,children:e.value}),(0,L.jsx)(`span`,{className:`num w-16 shrink-0 text-right text-fg-faint`,children:e.sub??``}),(0,L.jsx)(`span`,{className:`num w-9 shrink-0 text-right text-fg-faint`,children:e.share===null?``:e.share<1?`<1%`:`${Math.floor(e.share)}%`})]},e.key))})]})}function Kn(e){return e.bars.reduce((e,t)=>e+t.n,0)}function qn(e){return e.bars.reduce((e,t)=>e+t.cost,0)}var Jn=6,Yn=new Set([`description`,`timeout`,`run_in_background`]),Xn=new Set([`true`,`:`,`echo`,`pwd`,`clear`]);function Zn(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return``}}function Qn(e){if(e.kind!==`tool.pre`)return null;let t=typeof e.tool==`string`?e.tool:``;if(!t)return null;let n=e.payload,r=n&&typeof n==`object`?n.tool_input:void 0,i=r&&typeof r==`object`?r:{},a=Zn(i.command).trim();if(t===`Bash`&&Xn.has(a))return null;let o=[t],s=t;for(let e of Object.keys(i).sort()){if(Yn.has(e))continue;let n=Zn(i[e]);(e===`content`||e===`new_string`||e===`old_string`)&&(n=n.slice(0,200)),o.push(`${e}=${n}`),s===t&&(e===`command`||e===`file_path`||e===`pattern`)&&(s=`${t} ${n.slice(0,48)}`)}return{sig:o.join(`|`),label:s}}function $n(e){let t=Date.parse(e.ts);return Number.isFinite(t)?t:0}function er(e,t,n=60){let r=Array.from({length:n},()=>({n:0,turns:0,tools:0,cost:0})),i=t-n*6e4,a=[...e].sort((e,t)=>$n(e)-$n(t)),o=[],s=new Map,c=0,l=``;for(let e of a){let a=$n(e);if(a<=0)continue;if(a>=i&&a<=t){let t=r[Math.min(n-1,Math.floor((a-i)/6e4))];if(t){t.n++,e.kind===`turn.assistant`?t.turns++:(e.kind===`tool.pre`||e.kind===`tool.post`)&&t.tools++;let n=typeof e.cost_usd==`number`&&Number.isFinite(e.cost_usd)?e.cost_usd:0;t.cost+=n}}let u=Qn(e);if(!u)continue;for(o.push({at:a,sig:u.sig,label:u.label});o.length>0;){let e=o[0];if(!e||a-e.at<=Jn*6e4)break;o.shift();let t=(s.get(e.sig)??1)-1;t<=0?s.delete(e.sig):s.set(e.sig,t)}let d=(s.get(u.sig)??0)+1;s.set(u.sig,d),d>c&&(c=d,l=u.label)}return{bars:r,repeats:c,repeatSample:l}}function tr(e,t){if(e.repeats>=8)return{kind:`repeat`,label:`×${e.repeats} same call`};switch(t){case`waiting-on-you`:return{kind:`waiting`,label:`waiting on you`};case`error`:return{kind:`error`,label:`error`};case`looping`:return{kind:`repeat`,label:`looping`};case`ended`:return{kind:`quiet`,label:`ended`};case`idle`:return{kind:`quiet`,label:`idle`};case`working`:return{kind:`working`,label:`working`}}return e.bars.filter(e=>e.n>0).length===0?{kind:`quiet`,label:`quiet`}:{kind:`working`,label:`working`}}function nr(e,t){return t<=0?`mid`:e>=t*1.8?`high`:e<=t*.5?`low`:`mid`}function rr(e){let t=e.filter(e=>e.cost>0).map(e=>e.cost).sort((e,t)=>e-t);return t.length===0?0:t[Math.floor(t.length/2)]??0}var ir=6,ar=2e3;function or({sessions:e,now:t}){let n=(0,l.useMemo)(()=>[...e].filter(e=>e.status!==`ended`).sort((e,t)=>t.last_event_at-e.last_event_at).slice(0,ir),[e]),r=n.map(e=>e.session_id).join(`,`),[i,a]=(0,l.useState)(new Map);(0,l.useEffect)(()=>{let e=!1;return(async()=>{let t=r?r.split(`,`):[],n=await Promise.all(t.map(e=>P.recentEvents(e,ar).catch(()=>[])));e||a(new Map(t.map((e,t)=>[e,n[t]??[]])))})(),()=>{e=!0}},[r]),(0,l.useEffect)(()=>d.onFrame(e=>{if(e.type!==`event`)return;let t=e.data;a(e=>{if(!e.has(t.session_id))return e;let n=new Map(e),r=n.get(t.session_id)??[];return n.set(t.session_id,[...r,t].slice(-4e3)),n})}),[]);let o=Math.floor(t/6e4),s=(0,l.useMemo)(()=>n.map(e=>({s:e,pulse:er(i.get(e.session_id)??[],o*6e4)})).filter(e=>Kn(e.pulse)>0),[n,i,o]);return n.length===0?null:(0,L.jsxs)(R,{title:`Live pulse`,right:(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[`last `,60,` minutes · one bar per minute`]}),children:[(0,L.jsx)(`div`,{children:s.length===0?(0,L.jsxs)(`div`,{className:`px-3 py-6 text-[12px] text-fg-faint text-center`,children:[`Nothing ran in the last `,60,` minutes.`]}):s.map(({s:e,pulse:t})=>(0,L.jsx)(cr,{s:e,pulse:t,minute:o,showId:s.length>1},e.session_id))}),(0,L.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-4 flex-wrap text-[11px] text-fg-faint border-t border-border`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,title:`Height and colour are independent.`,children:`bar height = turns and tools · colour = what the minute cost`}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(sr,{tier:ur,className:`h-[2px]`}),`idle`]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(sr,{tier:lr.low}),`below this session's median`]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(sr,{tier:lr.mid}),`around it`]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(sr,{tier:lr.high}),`well above it`]}),(0,L.jsxs)(`span`,{className:`ml-auto`,children:[(0,L.jsx)(`span`,{className:`text-warn`,children:`×N same call`}),` = most-repeated identical tool call in six minutes`]})]})]})}function sr({tier:e,className:t=``}){return(0,L.jsx)(`span`,{"data-token":e.token,className:`inline-block w-3 h-3 rounded-[2px] ${t}`,style:{background:`var(${e.token}, ${e.fallback})`,opacity:e.alpha}})}function cr({s:e,pulse:t,minute:n,showId:r}){let i=tr(t,e.activity?.health),a=i.kind===`repeat`||i.kind===`waiting`?`text-warn`:i.kind===`error`?`text-danger`:i.kind===`quiet`?`text-fg-faint`:`text-ok`;return(0,L.jsxs)(`a`,{href:g({name:`session`,id:e.session_id}),className:`grid grid-cols-[132px_1fr_92px_104px] items-center gap-3 px-3 py-2 border-t border-border first:border-t-0 hover:bg-panel-2 no-underline text-fg`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`text-[13px] font-medium flex items-baseline gap-1.5 min-w-0`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:e.project||`unknown project`}),e.git_branch&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[10px] text-fg-faint mono`,title:e.git_branch,children:e.git_branch}),Ut(e.agent)&&(0,L.jsx)(`span`,{className:`shrink-0 text-[9px] uppercase tracking-[0.08em] text-fg-faint border border-border px-1 rounded-sm`,children:Ut(e.agent)})]}),(0,L.jsxs)(`div`,{className:`text-[10px] text-fg-faint mono truncate`,children:[r&&(0,L.jsxs)(`span`,{title:`session ${e.session_id} · started ${E(e.started_at)} ago`,children:[ee(e.session_id),` · `]}),e.activity?.phrase??``]})]}),(0,L.jsx)(fr,{pulse:t,now:n*6e4,sessionID:e.session_id}),(0,L.jsx)(`div`,{className:`num text-[13px] font-semibold text-right`,title:`${S(e.stats?.cost_usd)} for the whole session`,children:S(qn(t))}),(0,L.jsx)(`div`,{className:`text-[11px] text-right ${a}`,title:t.repeatSample,children:i.label})]})}var lr={low:{token:`--color-ok`,fallback:`#4fbf6b`,alpha:.55},mid:{token:`--color-accent`,fallback:`#feb157`,alpha:.85},high:{token:`--color-accent-strong`,fallback:`#ffcb85`,alpha:1}},ur={token:`--color-fg-faint`,fallback:`#837f78`,alpha:.3};function dr(e,t,n){return e.getPropertyValue(t).trim()||n}function fr({pulse:e,now:t,sessionID:n}){let r=(0,l.useRef)(null),[i,a]=(0,l.useState)(null);(0,l.useEffect)(()=>{let t=r.current;if(!t)return;let n=()=>{let n=t.clientWidth,r=t.clientHeight;if(n===0||r===0)return;let i=window.devicePixelRatio||1;t.width=Math.round(n*i),t.height=Math.round(r*i);let a=t.getContext(`2d`);if(!a)return;a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,n,r);let o=getComputedStyle(t),s=dr(o,ur.token,ur.fallback),c=e.bars,l=Math.max(...c.map(e=>e.n),1),u=rr(c),d=n/c.length;for(let e=0;e{i.disconnect(),a.disconnect()}},[e]);let o=t=>{let n=t.currentTarget.getBoundingClientRect();if(n.width===0)return;let r=Math.floor((t.clientX-n.left)/n.width*e.bars.length);a(r>=0&&ra(null),onClick:e=>{i===null||!s||s.n===0||(e.preventDefault(),e.stopPropagation(),v({name:`session`,id:n,at:u}))},"aria-hidden":!0}),s&&(0,L.jsx)(`div`,{className:`absolute -top-1 left-0 right-0 pointer-events-none flex justify-center`,children:(0,L.jsxs)(`span`,{className:`num text-[10px] bg-panel-2 border border-border-strong rounded-sm px-1.5 py-0.5 text-fg-muted whitespace-nowrap`,children:[new Date(u).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),s.n===0?` · nothing happened`:(0,L.jsxs)(L.Fragment,{children:[` · ${s.n} event${s.n===1?``:`s`}`,s.turns>0&&` · ${s.turns} turn${s.turns===1?``:`s`}`,s.cost>0&&` · ${S(s.cost)}`,s.cost>0&&c>0&&(0,L.jsx)(`span`,{className:`text-fg-faint`,children:` (median ${S(c)})`}),(0,L.jsx)(`span`,{className:`text-fg-faint`,children:` · click to open`})]})]})})]})}function pr({session:e,now:t,onClose:n}){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)();(0,l.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await P.notes(e.session_id,12);t||i(n)}catch(e){t||o(e instanceof Error?e.message:`could not load`)}})(),()=>{t=!0}},[e.session_id]);let s=r?.find(e=>!e.fragment),c=r?.[0],u=s??c;return(0,L.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-start justify-center pt-[10vh] px-4`,onClick:n,children:(0,L.jsxs)(`div`,{className:`w-full max-w-[720px] max-h-[76vh] flex flex-col border border-border-strong bg-panel rounded-[var(--radius-panel)] shadow-lg`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`px-4 pt-3 pb-2 border-b border-border flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`text-[13px] font-medium truncate`,children:e.project||`unknown project`}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-muted truncate`,children:e.activity?.phrase}),(0,L.jsx)(`button`,{onClick:n,className:`ml-auto text-[16px] leading-none text-fg-faint hover:text-fg`,children:`×`})]}),(0,L.jsxs)(`div`,{className:`overflow-y-auto px-4 py-3 grid gap-3`,children:[!r&&!a&&(0,L.jsx)(`div`,{className:`text-[12px] text-fg-muted`,children:`loading…`}),a&&(0,L.jsx)(`div`,{className:`text-[12px] text-danger`,children:a}),r&&!u&&(0,L.jsx)(`div`,{className:`text-[12px] text-fg-muted`,children:`This session has not said anything yet — it may be running without hooks, or still on its first turn.`}),u&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint`,children:[`Last thing Claude said · `,E(u.ts,t),s&&c&&s.event_id!==c.event_id&&(0,L.jsx)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:`(the newest line was mid-thought; this is the last complete one)`})]}),(0,L.jsx)(`div`,{className:`text-[13px] leading-relaxed whitespace-pre-wrap text-fg`,children:u.text})]}),e.activity?.plan&&e.activity.plan.total>0&&(0,L.jsxs)(`div`,{className:`border-t border-border pt-3`,children:[(0,L.jsxs)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-fg-faint mb-1`,children:[`Plan · `,e.activity.plan.done,`/`,e.activity.plan.total]}),e.activity.plan.next&&(0,L.jsxs)(`div`,{className:`text-[12px] text-fg-muted`,children:[`→ `,e.activity.plan.next]})]})]}),(0,L.jsxs)(`div`,{className:`px-4 py-2 border-t border-border flex items-center gap-3 text-[11px]`,children:[(0,L.jsx)(`a`,{href:g({name:`session`,id:e.session_id}),className:`link text-fg-muted hover:text-fg`,children:`open the session →`}),(0,L.jsx)(`span`,{className:`ml-auto text-fg-faint`,children:e.owned?`answer in its terminal tab`:`reply in the terminal you started it in`})]})]})})}var mr=`premium-hint`;function hr({reason:e,now:t}){let[n]=(0,l.useState)(()=>jn(mr,t)),[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(!1);return!n||r?null:(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-[11px]`,children:[(0,L.jsx)(`span`,{className:`text-fg-faint`,children:e}),(0,L.jsx)(`button`,{onClick:()=>o(!0),className:`rounded-sm border border-border px-1.5 py-0.5 text-fg-muted hover:border-border-strong hover:text-fg`,children:`a cap that stops this`}),(0,L.jsx)(`button`,{title:`hide this for a month`,onClick:()=>{Mn(mr,t),i(!0)},className:`text-fg-faint hover:text-fg-muted`,children:`✕`}),a&&(0,L.jsx)(rt,{feature:`cap`,onClose:()=>o(!1)})]})}function gr({items:e,now:t,onDismiss:n,sessions:r}){return e.length===0?null:(0,L.jsx)(`div`,{className:`grid gap-1.5`,children:e.map(e=>(0,L.jsx)(_r,{it:e,now:t,onDismiss:n,session:r?.find(t=>t.session_id===e.sessionId)},e.id))})}function _r({it:e,now:t,onDismiss:n,session:r}){let[i,a]=(0,l.useState)(!1),o=e.severity===`high`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`border rounded-[var(--radius-panel)] px-3 py-2 flex items-center gap-3 ${o?`border-danger/50 bg-danger/10`:`border-warn/50 bg-warn/10`}`,children:[(0,L.jsx)(`span`,{className:`font-medium text-[13px] shrink-0 ${o?`text-danger`:`text-warn`}`,children:e.title}),(0,L.jsxs)(`span`,{className:`text-[12px] text-fg-muted truncate`,children:[e.sessionId&&(0,L.jsx)(`a`,{href:g({name:`session`,id:e.sessionId}),className:`link mono text-fg`,children:e.project||ee(e.sessionId)}),(0,L.jsx)(`span`,{className:e.sessionId?`ml-2`:``,children:e.detail})]}),(0,L.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 shrink-0`,children:[e.costUSD!==void 0&&e.costUSD>0&&(0,L.jsx)(`span`,{className:`num text-[13px] text-fg`,title:`spent by this session so far`,children:S(e.costUSD)}),e.since!==void 0&&(0,L.jsx)(`span`,{className:`num text-[11px] text-fg-faint`,children:E(e.since,t)}),r&&e.id.startsWith(`waiting-`)&&(0,L.jsx)(`button`,{className:`text-[11px] border border-border px-1.5 py-0.5 rounded-sm hover:border-border-strong text-fg-muted hover:text-fg`,onClick:()=>a(!0),children:`what did it ask?`}),(0,L.jsx)(`a`,{href:e.sessionId?g({name:`session`,id:e.sessionId,tab:`timeline`,at:e.at}):`#/cost`,className:`text-[11px] border border-border px-1.5 py-0.5 rounded-sm hover:border-border-strong no-underline text-fg-muted hover:text-fg`,children:e.sessionId?`open`:`details`}),(e.id.startsWith(`loop-`)||e.id.startsWith(`spent-`))&&(0,L.jsx)(hr,{reason:`this is what a cap stops`,now:t}),n&&e.id.startsWith(`loop-`)&&(0,L.jsx)(`button`,{className:`text-[11px] text-fg-faint hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,onClick:()=>n(e.sessionId),children:`dismiss`})]})]}),i&&r&&(0,L.jsx)(pr,{session:r,now:t,onClose:()=>a(!1)})]})}var vr=9e5,yr=25,br=300,xr=2,Sr=864e5,Cr=90,wr=6912e5;function Tr(e){return typeof e==`number`?e:e&&Date.parse(e)||0}function Er({sessions:e,alerts:t,now:n,limits:r,waitingMs:i=vr}){let a=[],o=Array.isArray(e)?e.filter(Boolean):[],s=Array.isArray(t)?t.filter(Boolean):[],c=new Map(o.map(e=>[e.session_id,e]));for(let e of s){let t=c.get(e.session_id);a.push({id:`loop-${e.session_id}`,sessionId:e.session_id,project:t?.project??``,severity:`high`,title:`Stuck in a loop`,detail:[`ran ${e.sample||e.tool||`the same call`}`,Number.isFinite(e.count)?`${e.count}×`:`repeatedly`,Number.isFinite(e.window_min)?`in ${e.window_min} min`:``].filter(Boolean).join(` `),costUSD:t?.stats?.cost_usd,since:Tr(e.ts)||void 0,at:Tr(e.first_ts)||Tr(e.ts)||void 0})}for(let e of o)if(e.status!==`ended`&&e.activity){if(e.activity.health===`error`){a.push({id:`error-${e.session_id}`,sessionId:e.session_id,project:e.project,severity:`high`,title:`Session hit an error`,detail:e.activity.phrase,costUSD:e.stats?.cost_usd,since:Tr(e.activity.at)||e.last_event_at});continue}if(e.activity.health===`waiting-on-you`){let t=Tr(e.activity.at)||e.last_event_at;t>0&&n-t>=i&&a.push({id:`waiting-${e.session_id}`,sessionId:e.session_id,project:e.project,severity:`medium`,title:`Waiting on you`,detail:e.activity.phrase,since:t})}}for(let e of o){if(!e.stats||!e.activity)continue;let{cost_usd:t,turns:r,files_touched:i}=e.stats;if(txr)continue;let o=Tr(e.activity.at)||e.last_event_at;o>0&&n-o>Sr||a.push({id:`spent-${e.session_id}`,sessionId:e.session_id,project:e.project,severity:`medium`,title:`Lots of turns, few files`,detail:`${r.toLocaleString()} turns, ${i===0?`no files`:i===1?`1 file`:`${i} files`} touched`,costUSD:t,since:Tr(e.activity.at)||e.last_event_at})}let l={high:0,medium:1};for(let[e,t]of[[`5-hour`,r?.five_hour],[`7-day`,r?.seven_day]]){if(!t||t.used_percentagen&&r=95?`high`:`medium`,title:`${e} plan window ${i}% used`,detail:`resets at ${o}${t.forecast?` — ${t.forecast}`:``}`})}return a.sort((e,t)=>l[e.severity]-l[t.severity]||(e.since??0)-(t.since??0))}var Dr=`caprock.update.dismissed`;function Or({plan:e,onSave:t,now:n,owned:r=0}){let[i,a]=(0,l.useState)(),[o,s]=(0,l.useState)(()=>localStorage.getItem(Dr)??``);return(0,l.useEffect)(()=>{if(!e?.update_checks){a(void 0);return}let t=!0,n=()=>{P.update().then(e=>{t&&a(e)}).catch(()=>{})};n();let r=window.setInterval(n,6e4);return()=>{t=!1,window.clearInterval(r)}},[e?.update_checks]),e&&!e.update_checks?o===`offer`?null:(0,L.jsxs)(kr,{tone:`muted`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:`Caprock can check GitHub for new releases. It's the only outbound call it makes, so it's off unless you turn it on — no usage data is sent, and you can turn it off again any time.`}),(0,L.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[(0,L.jsx)(`button`,{className:`text-[11px] border border-accent/50 text-accent bg-accent/10 px-2 py-0.5 rounded-sm hover:bg-accent/20`,onClick:()=>t({update_checks:!0}),children:`check for updates`}),(0,L.jsx)(`button`,{className:`text-[11px] text-fg-faint hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,onClick:()=>{localStorage.setItem(Dr,`offer`),s(`offer`)},children:`no thanks`})]})]}):!i?.update_available||!i.latest||o===i.latest?null:(0,L.jsxs)(kr,{tone:`accent`,children:[(0,L.jsxs)(`span`,{className:`text-fg`,children:[(0,L.jsxs)(`span`,{className:`font-medium`,children:[`Caprock `,i.latest]}),` is available — you're on `,(0,L.jsx)(`span`,{className:`mono`,children:i.current}),`.`]}),r>0&&(0,L.jsx)(`span`,{className:`text-[12px] text-warn shrink-0`,children:r===1?`1 session Caprock started will close`:`${r} sessions Caprock started will close`}),i.command?(0,L.jsx)(kt,{command:i.command}):(0,L.jsx)(`a`,{className:`link text-[12px]`,href:i.url,target:`_blank`,rel:`noreferrer`,children:`download it`}),(0,L.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[i.checked_at?(0,L.jsxs)(`span`,{className:`num text-[11px] text-fg-faint`,children:[`checked `,E(i.checked_at,n)]}):null,(0,L.jsx)(`a`,{className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-0.5 rounded-sm no-underline`,href:i.url,target:`_blank`,rel:`noreferrer`,children:`what's new`}),(0,L.jsx)(`button`,{className:`text-[11px] text-fg-faint hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,onClick:()=>{localStorage.setItem(Dr,i.latest),s(i.latest)},children:`not now`})]})]})}function kr({tone:e,children:t}){return(0,L.jsx)(`div`,{className:`border rounded-[var(--radius-panel)] px-3 py-2 flex items-center gap-3 text-[12px] ${e===`accent`?`border-accent/40 bg-accent/5`:`border-border bg-panel`}`,children:t})}function Ar({u:e,className:t=``}){return!e||e.turns===0?null:(0,L.jsxs)(`div`,{className:`border border-warn/50 bg-warn/10 px-3 py-2 text-[12px] rounded-[var(--radius-panel)] ${t}`,children:[(0,L.jsx)(`span`,{className:`text-warn font-medium`,children:`Cost is incomplete`}),` `,(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[C(e.tokens),` tokens over `,e.turns,` turn`,e.turns===1?``:`s`,` could not be priced, so they are missing from the total above — not free. `,e.models.length===1?`Model`:`Models`,` with no entry in the pricing table:`,` `,e.models.map((e,t)=>(0,L.jsxs)(`span`,{children:[t>0&&`, `,(0,L.jsx)(`span`,{className:`mono text-fg`,children:e||`unknown`})]},e)),`. This happens when a model ships newer than the pricing table, or when a gateway reports ids that do not normalise.`]})]})}function jr({value:e,onPick:t}){let[n,r]=(0,l.useState)(`recent`),[i,a]=(0,l.useState)(``),o=I(()=>P.recentDirs(),[],{live:!1}),s=I(()=>P.browse(i),[i],{live:!1});return(0,l.useEffect)(()=>{o.data&&o.data.length===0&&r(`browse`)},[o.data]),(0,L.jsxs)(`div`,{className:`rounded-[3px] border border-border-strong bg-panel-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-strong px-2 py-1.5 text-[12px]`,children:[(0,L.jsx)(Mr,{on:n===`recent`,onClick:()=>r(`recent`),children:`Recent`}),(0,L.jsx)(Mr,{on:n===`browse`,onClick:()=>r(`browse`),children:`Browse`}),n===`browse`&&s.data&&(0,L.jsx)(`span`,{className:`mono ml-auto min-w-0 truncate pl-2 text-[11px] text-fg-faint`,title:s.data.dir,children:Lr(s.data.dir,s.data.root)})]}),(0,L.jsx)(`div`,{className:`h-[168px] overflow-y-auto overflow-x-hidden`,children:n===`recent`?(0,L.jsx)(Nr,{rows:o.data,value:e,onPick:t}):(0,L.jsx)(Pr,{data:s.data,value:e,onOpen:a,onPick:t,error:s.error?.message})})]})}function Mr({on:e,onClick:t,children:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-sm px-2 py-0.5 ${e?`bg-accent/15 text-accent`:`text-fg-muted hover:text-fg`}`,children:n})}function Nr({rows:e,value:t,onPick:n}){return e?e.length===0?(0,L.jsx)(Ir,{children:`No sessions yet — use Browse, or type a path.`}):(0,L.jsx)(`ul`,{children:e.map(e=>(0,L.jsxs)(Fr,{selected:t===e.dir,onClick:()=>n(e.dir),children:[(0,L.jsx)(`span`,{className:`shrink-0 text-fg`,children:e.name}),(0,L.jsx)(`span`,{className:`mono ml-2 min-w-0 flex-1 truncate text-[11px] text-fg-faint`,title:e.dir,children:e.dir}),(0,L.jsx)(`span`,{className:`shrink-0 pl-2 text-[11px] text-fg-faint`,children:E(e.last_event_at)})]},e.dir))}):(0,L.jsx)(Ir,{children:`…`})}function Pr({data:e,value:t,onOpen:n,onPick:r,error:i}){return i?(0,L.jsx)(Ir,{children:i}):e?(0,L.jsxs)(`ul`,{children:[e.parent&&(0,L.jsx)(Fr,{selected:!1,onClick:()=>n(e.parent),children:(0,L.jsx)(`span`,{className:`text-fg-muted`,children:`↑ up`})}),e.entries.length===0&&(0,L.jsx)(Ir,{children:`Nothing here.`}),e.entries.map(e=>(0,L.jsxs)(Fr,{selected:t===e.path,onClick:()=>e.repo?r(e.path):n(e.path),children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate ${e.repo?`text-fg`:`text-fg-muted`}`,children:e.name}),e.repo&&(0,L.jsx)(`span`,{className:`ml-2 shrink-0 text-[10px] uppercase tracking-wide text-accent`,children:`repo`}),(0,L.jsx)(`span`,{className:`flex-1`}),(0,L.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.repo?n(e.path):r(e.path)},className:`shrink-0 px-1 text-[11px] text-fg-faint hover:text-fg`,title:e.repo?`Open this folder`:`Use this folder`,children:e.repo?`›`:`use`})]},e.path))]}):(0,L.jsx)(Ir,{children:`…`})}function Fr({selected:e,onClick:t,children:n}){return(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`flex w-full min-w-0 items-center px-2.5 py-1 text-left text-[12px] hover:bg-panel ${e?`bg-accent/10`:``}`,children:n})})}function Ir({children:e}){return(0,L.jsx)(`p`,{className:`px-2.5 py-3 text-[12px] text-fg-faint`,children:e})}function Lr(e,t){return e===t?`~`:e.startsWith(t+`/`)?`~`+e.slice(t.length):e}var Rr=`claude-opus-5`,zr=`acceptEdits`,Br=[[`gemini-3.5-flash-lite`,`Flash Lite 3.5 · cheapest`],[`gemini-2.5-flash`,`Flash 2.5 · older, cheap`],[`gemini-3.5-flash`,`Flash 3.5 · most capable here`]],Vr=[[`claude-opus-5`,`Opus 5 · most capable`],[`claude-sonnet-5`,`Sonnet 5 · faster, cheaper`],[`claude-haiku-4-5`,`Haiku 4.5 · cheapest`]],Hr=new Set([`acceptEdits`,`auto`,`bypassPermissions`,`plan`]),Ur=[[`acceptEdits`,`Accept edits · asks first`],[`plan`,`Plan · changes nothing`],[`bypassPermissions`,`Bypass · never asks`]];function Wr({available:e,geminiAvailable:t=!1,onClose:n,initialCwd:r=``}){let[i,a]=(0,l.useState)(r),[o,s]=(0,l.useState)(`claude`),[c,u]=(0,l.useState)(Rr),[d,f]=(0,l.useState)(zr),[p,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(!1),[_,y]=(0,l.useState)(!1),[b,x]=(0,l.useState)(``),S=async()=>{if(!i.trim()){x(`Working directory is required.`);return}y(!0),x(``);try{let e={cwd:i.trim()};o!==`claude`&&(e.agent=o),c&&(e.model=c),d&&o===`claude`&&(e.permission_mode=d),p.trim()&&(e.worktree=p.trim()),h&&(e.create=!0);let{session_id:t}=await P.spawn(e);n(),v({name:`session`,id:t,tab:`terminal`})}catch(e){x(ae(e))}finally{y(!1)}};return(0,L.jsx)(`div`,{className:`fixed inset-0 z-20 bg-black/50 flex items-start justify-center pt-24`,onClick:n,children:(0,L.jsxs)(`div`,{className:`border border-border-strong bg-panel rounded-[var(--radius-panel)] w-[620px] max-w-[94vw]`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`header`,{className:`px-3 py-2 border-b border-border flex items-center`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] uppercase tracking-[0.08em] text-fg-muted`,children:`New session`}),(0,L.jsx)(`button`,{onClick:n,className:`ml-auto text-fg-muted hover:text-fg`,children:`✕`})]}),e?(0,L.jsxs)(`div`,{className:`px-4 py-3 grid min-w-0 gap-3 text-[13px]`,children:[(0,L.jsxs)(Gr,{label:`Working directory`,hint:`pick one, or type a path`,children:[(0,L.jsx)(`input`,{autoFocus:!0,className:`input`,placeholder:`/Users/you/dev/project`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&S()}),(0,L.jsx)(`div`,{className:`mt-1.5 min-w-0 max-w-full`,children:(0,L.jsx)(jr,{value:i,onPick:a})})]}),t&&(0,L.jsx)(Gr,{label:`Agent`,children:(0,L.jsxs)(`select`,{className:`input`,value:o,onChange:e=>{let t=e.target.value;s(t),u(t===`gemini`?Br[0][0]:Rr)},children:[(0,L.jsx)(`option`,{value:`claude`,children:`Claude Code`}),(0,L.jsx)(`option`,{value:`gemini`,children:`Gemini CLI · your own key`})]})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsx)(Gr,{label:`Model`,children:(0,L.jsx)(`select`,{className:`input`,value:c,onChange:e=>u(e.target.value),children:(o===`gemini`?Br:Vr).map(([e,t])=>(0,L.jsx)(`option`,{value:e,children:t},e))})}),(0,L.jsx)(Gr,{label:`Permissions`,children:(0,L.jsx)(`select`,{className:`input`,value:d,onChange:e=>f(e.target.value),children:Ur.map(([e,t])=>(0,L.jsx)(`option`,{value:e,children:o===`gemini`&&!Hr.has(e)?`${t} · Gemini asks instead`:t},e))})})]}),(0,L.jsxs)(`details`,{className:`text-[12px] group`,children:[(0,L.jsxs)(`summary`,{className:`cursor-pointer select-none text-fg-muted hover:text-fg list-none marker:content-none`,children:[(0,L.jsx)(`span`,{className:`inline-block transition-transform group-open:rotate-90 text-fg-faint`,children:`▶`}),` Advanced`]}),(0,L.jsxs)(`div`,{className:`grid gap-2 pt-2`,children:[(0,L.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none text-fg-muted`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--color-accent)]`,checked:h,onChange:e=>g(e.target.checked)}),`create the directory if it does not exist`]}),(0,L.jsx)(Gr,{label:`Git worktree`,hint:`creates .caprock-worktrees/ on a new branch`,children:(0,L.jsx)(`input`,{className:`input`,placeholder:`feature-x`,value:p,onChange:e=>m(e.target.value)})})]})]}),b&&(0,L.jsx)(`div`,{className:`text-danger text-[12px]`,children:b})]}):(0,L.jsxs)(`div`,{className:`px-4 py-6 text-[13px] text-fg-muted`,children:[`The `,(0,L.jsx)(`span`,{className:`mono`,children:`claude`}),` binary was not found on this machine, so Caprock cannot spawn sessions. It still observes every session you start yourself.`]}),e&&(0,L.jsxs)(`footer`,{className:`px-4 py-2 border-t border-border flex gap-2 justify-end`,children:[(0,L.jsx)(`button`,{onClick:n,className:`border border-border px-3 py-1 rounded-sm text-fg-muted hover:text-fg`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:S,disabled:_,className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:_?`starting…`:`Start session`})]})]})})}function Gr({label:e,hint:t,children:n}){return(0,L.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[e,t&&(0,L.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,t]})]}),n]})}var Kr=1728e5;function qr(e,t){return!e&&!t}function Jr(e,t){return!e.last_event_at||t-e.last_event_atP.sessions(!e),[e],{intervalMs:5e3}),s=I(()=>P.status(),[],{live:!1,intervalMs:3e4}),c=I(()=>P.summary(`today`,n),[n],{intervalMs:5e3}),u=I(()=>P.history(`all`),[],{intervalMs:6e4}),{alerts:p}=f(),m=re(1e3),h=o.data??[],g=n===`all`?h:h.filter(e=>(e.agent??`claude`)===n),_=Ht.filter(e=>e.key===`all`||e.key===`claude`||e.key===`opencode`&&!!s.data?.opencode||e.key===`gemini`&&h.some(e=>e.agent===`gemini`)),v=_.length>2,y=g.filter(e=>e.activity.health===`working`||e.activity.health===`looping`||e.activity.health===`error`||e.activity.health===`waiting-on-you`),b=g.filter(e=>!y.includes(e)&&e.status!==`ended`&&Jr(e,m)),x=g.filter(e=>e.status===`ended`),[w,T]=De(),D=Er({sessions:g,alerts:p,now:m,limits:c.data?.rate_limits}),ee=s.data?.hooks&&(s.data.hooks.missing??[]).length>0,O=!!c.data&&c.data.turns>0,te=qr(c.data,c.error),ne=s.data?.ingest_error;return(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[ne&&(0,L.jsxs)(`div`,{className:`border border-danger/50 bg-danger/10 px-3 py-2 text-[12px] rounded-[var(--radius-panel)] flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-danger font-medium`,children:`Ingest stopped`}),(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[`No new sessions are being captured. `,(0,L.jsx)(`span`,{className:`mono text-fg`,children:ne}),` — check that`,(0,L.jsx)(`span`,{className:`mono text-fg`,children:` ~/.claude`}),` is readable, then restart with`,(0,L.jsx)(`span`,{className:`mono text-fg`,children:` caprock down && caprock up`}),`.`]})]}),ee&&(0,L.jsxs)(`div`,{className:`border border-warn/50 bg-warn/10 px-3 py-2 text-[12px] rounded-[var(--radius-panel)] flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-warn font-medium`,children:`Hooks not installed`}),(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[`Run `,(0,L.jsx)(`span`,{className:`mono text-fg`,children:`caprock hooks install`}),` for live activity. Without it, updates lag by a few seconds.`]}),(0,L.jsx)(`a`,{href:`#/settings`,className:`link ml-auto text-[11px]`,children:`details`})]}),(0,L.jsx)(Or,{plan:w,onSave:T,now:m,owned:g.filter(e=>e.owned&&e.status!==`ended`).length}),(0,L.jsx)(gr,{items:D,now:m,onDismiss:e=>d.dismissAlert(e),sessions:g}),(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(yn,{plan:w})}),(0,L.jsx)(Xr,{available:s.data?.claude_available}),(0,L.jsx)(Zr,{available:s.data?.claude_available,onClick:()=>a(!0)})]}),O&&u.data?.totals&&(0,L.jsx)(Pn,{costUSD:u.data.totals.cost_usd,days:u.data.totals.days,now:m}),(0,L.jsxs)(R,{title:`Today`,center:v?(0,L.jsx)(`span`,{className:`inline-flex items-center gap-0.5 rounded-md bg-panel-2 p-0.5`,children:_.map(e=>(0,L.jsx)(`button`,{onClick:()=>r(e.key),title:e.key===`all`?`Every agent`:`Only ${e.label}`,className:`px-2.5 py-1 text-[12px] mono rounded-[5px] transition-colors ${n===e.key?`bg-accent text-panel font-medium`:`text-fg-muted hover:text-fg`}`,children:e.label},e.key))}):null,right:c.data?(0,L.jsxs)(`span`,{className:`num`,children:[`pricing `,c.data.pricing_version,` · at API list price`]}):null,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-[1.4fr_1fr_1fr_1fr_1fr_1fr] divide-x divide-border`,children:[(0,L.jsx)(z,{label:`Cost today`,value:O?S(c.data?.cost_usd):`—`,sub:(0,L.jsx)(`span`,{title:vn(w),children:O?_n(w):te?`reading your figures…`:`nothing measured yet`}),tone:`info`,size:`hero`}),(0,L.jsx)(z,{label:`Burn now`,value:O?`${S(c.data.burn.usd_per_hour)}/h`:`—`,sub:O?`${C(Math.round(c.data.burn.tokens_per_min))} tok/min · last ${c.data.burn.window_min}m`:void 0}),(0,L.jsx)(z,{label:`Sessions`,value:O?c.data.sessions:`—`,sub:O?`${c.data.active_sessions} active`:void 0,size:`compact`}),(0,L.jsx)(z,{label:`Turns`,value:O?c.data.turns:`—`,sub:O?`${c.data.tool_calls} tool calls`:void 0,size:`compact`}),(0,L.jsx)(En,{limits:c.data?.rate_limits,now:m}),(0,L.jsx)(Cn,{hitRate:c.data?.savings.hit_rate,cutPct:c.data?.savings.cut_pct,measured:O})]}),(0,L.jsx)(Ar,{u:c.data?.unpriced,className:`mx-3 mb-2.5`})]}),(0,L.jsx)(or,{sessions:g,now:m}),(0,L.jsx)(Wn,{}),(0,L.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,L.jsx)(mn,{sessions:g,now:m,emptyHint:n===`all`?void 0:(0,L.jsxs)(L.Fragment,{children:[`Nothing from `,Wt(n),` yet.`]})}),(0,L.jsx)(Qt,{sessions:g,agent:n})]}),o.error&&!o.data&&(0,L.jsxs)(Dt,{title:`Cannot reach the daemon`,children:[o.error.message,` — is `,(0,L.jsx)(`span`,{className:`mono`,children:`caprock up`}),` running?`]}),!o.data&&!o.error&&(0,L.jsx)(Ot,{rows:4,className:`border border-border rounded-[var(--radius-panel)] bg-panel`}),o.data&&g.length===0&&(n===`all`?(0,L.jsxs)(Dt,{title:`No sessions yet`,children:[`Start `,(0,L.jsx)(`span`,{className:`mono`,children:`claude`}),` in any terminal — it will show up here within seconds.`]}):(0,L.jsxs)(Dt,{title:`No ${Wt(n)} sessions here`,children:[`Nothing from this agent in the current view. Switch to`,` `,(0,L.jsx)(`button`,{className:`link underline`,onClick:()=>r(`all`),children:`all`}),` `,`to see everything.`]})),(0,L.jsx)(Qr,{groups:[{label:`Active`,items:y},{label:`Idle`,items:b,dim:!0},...e?[{label:`Ended`,items:x,dim:!0}]:[]],now:m}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint px-0.5`,children:[(0,L.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--color-accent)]`,checked:e,onChange:e=>t(e.target.checked)}),`show ended sessions`]}),o.loadedAt>0&&(0,L.jsxs)(`span`,{className:`num ml-auto`,children:[`refreshed `,E(o.loadedAt,m)]})]}),i&&(0,L.jsx)(Wr,{available:s.data?.claude_available??!1,geminiAvailable:s.data?.gemini_available??!1,onClose:()=>{a(!1),o.refresh()}})]})}function Xr({available:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(``);return e===!1?null:(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`button`,{onClick:async()=>{n(!0),i(``);try{let{session_id:e}=await P.spawn({chat:!0});v({name:`session`,id:e,tab:`terminal`})}catch(e){i(ae(e))}finally{n(!1)}},disabled:t,title:`start a session without picking a folder`,className:`relative shrink-0 rounded-[var(--radius-panel)] border border-border-strong px-3 py-2 text-[13px] leading-5 text-fg-muted hover:text-fg hover:border-accent/50 disabled:opacity-50`,children:[t?`starting…`:`Quick chat`,r&&(0,L.jsx)(`span`,{className:`absolute right-0 top-full mt-1 block max-w-[220px] text-right text-[11px] text-danger`,children:r})]})})}function Zr({available:e,onClick:t}){let n=e===!1;return(0,L.jsxs)(`button`,{onClick:t,title:n?`claude was not found on this machine — click for details`:`start a session Caprock owns`,className:`shrink-0 rounded-[var(--radius-panel)] border px-3 py-2 text-[13px] leading-5 font-medium transition-colors ${n?`border-border text-fg-faint hover:text-fg-muted`:`border-accent/60 bg-accent/15 text-accent hover:bg-accent/25`}`,children:[`+ New session`,n?` (claude not found)`:``]})}function Qr({groups:e,now:t}){let n=e.flatMap(e=>e.items.map((t,n)=>({s:t,dim:e.dim,label:n===0?`${e.label} · ${e.items.length}`:null})));return n.length===0?null:(0,L.jsx)(`div`,{"data-testid":`session-grid`,className:`mt-3 grid gap-2 gap-y-6`,children:n.map(({s:e,dim:n,label:r})=>(0,L.jsxs)(`div`,{className:`relative ${n?`opacity-80`:``}`,children:[r&&(0,L.jsx)(`div`,{className:`absolute -top-4 left-0.5 text-[11px] uppercase tracking-[0.08em] text-fg-faint`,children:r}),(0,L.jsx)($r,{s:e,now:t})]},e.session_id))})}function $r({s:e,now:t}){let n=e.context,r=n?n.pct>=85?`danger`:n.pct>=60?`warn`:void 0:void 0,[i,a]=(0,l.useState)(!1),o=e.activity?.health===`waiting-on-you`;return(0,L.jsxs)(`a`,{href:g({name:`session`,id:e.session_id}),className:`block border border-border bg-panel rounded-[var(--radius-panel)] hover:border-border-strong no-underline hover:no-underline text-fg`,children:[(0,L.jsxs)(`div`,{className:`px-3 pt-2 pb-1 flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-medium truncate text-[15px]`,children:e.project||`unknown project`}),(0,L.jsx)(`span`,{className:`mono text-[11px] text-fg-faint`,children:ee(e.session_id)}),e.agent&&e.agent!==`claude`&&(0,L.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.08em] text-fg-muted border border-border px-1 py-px rounded-sm`,children:e.agent}),e.git_branch&&(0,L.jsx)(`span`,{className:`mono text-[11px] text-fg-muted truncate`,children:e.git_branch}),(0,L.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[o&&(0,L.jsx)(`button`,{className:`text-[11px] border border-warn/50 text-warn bg-warn/10 px-1.5 py-0.5 rounded-sm hover:bg-warn/20`,onClick:e=>{e.preventDefault(),a(!0)},children:`what did it ask?`}),(0,L.jsx)(Tt,{health:e.activity.health})]})]}),i&&(0,L.jsx)(pr,{session:e,now:t,onClose:()=>a(!1)}),(0,L.jsxs)(`div`,{className:`px-3 pb-2 text-[13px] truncate`,title:e.activity.phrase,children:[(0,L.jsx)(`span`,{className:e.activity.health===`working`?`text-fg`:`text-fg-muted`,children:e.activity.phrase}),(0,L.jsx)(`span`,{className:`text-fg-faint num text-[11px] ml-2`,children:E(e.activity.at||e.last_event_at,t)})]}),e.activity.plan&&e.activity.plan.total>0&&(0,L.jsxs)(`div`,{className:`px-3 pb-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,L.jsx)(`div`,{className:`h-1 flex-1 bg-panel-2 rounded-sm overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full bg-accent`,style:{width:`${Math.min(100,Math.max(0,100*e.activity.plan.done/e.activity.plan.total))}%`}})}),(0,L.jsxs)(`span`,{className:`num`,children:[e.activity.plan.done,`/`,e.activity.plan.total]}),e.activity.plan.next&&(0,L.jsxs)(`span`,{className:`truncate max-w-[50%]`,children:[`→ `,e.activity.plan.next]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 divide-x divide-border border-t border-border`,children:[(0,L.jsx)(z,{label:`Cost`,value:S(e.stats.cost_usd),sub:e.model||`—`,tone:`info`}),(0,L.jsx)(z,{label:`Tokens`,value:C(e.stats.tokens_in+e.stats.tokens_out+e.stats.cache_read+e.stats.cache_write),sub:`${T(e.savings.hit_rate*100)} cache hit`}),(0,L.jsx)(z,{label:`Context`,value:n?T(n.pct):`—`,sub:n?`${C(n.tokens)} / ${C(n.window)}`:`unknown model`,tone:r}),(0,L.jsx)(z,{label:`Activity`,value:e.stats.tool_calls,sub:`${e.stats.turns} turns · ${e.stats.files_touched} files`})]})]})}function ei({id:e,now:t}){let n=I(()=>P.notes(e),[e],{intervalMs:1e4}),r=n.data??[],[i,a]=(0,l.useState)(!1),o=r.filter(e=>!e.fragment),s=i?r:o;return n.error&&!n.data?(0,L.jsx)(Dt,{title:`Cannot load notes`,children:n.error.message}):n.data?r.length===0?(0,L.jsx)(Dt,{title:`Nothing said yet`,children:`Claude's written answers appear here — the reasoning and the “what changed, what I still need from you” that otherwise lives only in your terminal scrollback.`}):(0,L.jsxs)(`div`,{className:`grid gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint px-0.5`,children:[(0,L.jsxs)(`span`,{children:[o.length,` `,o.length===1?`answer`:`answers`,r.length>o.length&&` · ${r.length-o.length} short remarks`]}),r.length>o.length&&(0,L.jsx)(`button`,{className:`text-fg-muted hover:text-fg border border-border px-1.5 rounded-sm`,onClick:()=>a(e=>!e),children:i?`hide short remarks`:`show everything`}),(0,L.jsx)(`span`,{className:`ml-auto`,children:`subagent chatter excluded · newest first`})]}),s.map(e=>(0,L.jsx)(ni,{note:e,now:t},e.event_id))]}):(0,L.jsx)(Ot,{rows:4})}var ti=600;function ni({note:e,now:t,showSession:n=!1}){let[r,i]=(0,l.useState)(!1),a=typeof e.text==`string`?e.text:``,o=[...a],s=o.length>ti,c=r||!s?a:o.slice(0,ti).join(``)+`…`;return(0,L.jsxs)(`div`,{className:`border border-border bg-panel rounded-[var(--radius-panel)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-2 text-[11px] text-fg-faint`,children:[n&&(0,L.jsx)(`a`,{href:g({name:`session`,id:e.session_id,at:e.ts}),className:`link`,title:`Open the session at this moment`,children:(0,L.jsx)(`span`,{className:`text-fg-muted`,children:e.project||ee(e.session_id)})}),(0,L.jsx)(`span`,{className:`mono`,children:e.model||`assistant`}),e.fragment&&(0,L.jsx)(`span`,{className:`text-fg-faint`,children:`· mid-thought`}),(0,L.jsx)(`span`,{className:`num ml-auto`,children:E(e.ts,t)})]}),(0,L.jsx)(`div`,{className:`px-3 py-2 break-words`,children:(0,L.jsx)(ft,{text:c})}),s&&(0,L.jsx)(`button`,{className:`text-[11px] text-fg-muted hover:text-fg px-3 pb-2`,onClick:()=>i(e=>!e),children:r?`show less`:`show all ${o.length.toLocaleString()} characters`})]})}var ri=Object.defineProperty,ii=Object.getOwnPropertyDescriptor,ai=(e,t)=>{for(var n in t)ri(e,n,{get:t[n],enumerable:!0})},oi=(e,t,n,r)=>{for(var i=r>1?void 0:r?ii(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&&ri(t,n,i),i},B=(e,t)=>(n,r)=>t(n,r,e),si=`Terminal input`,ci={get:()=>si,set:e=>si=e},li=`Too much output to announce, navigate to rows manually to read`,ui={get:()=>li,set:e=>li=e};function di(e){return e.replace(/\r?\n/g,`\r`)}function fi(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function pi(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function mi(e,t,n,r){e.stopPropagation(),e.clipboardData&&hi(e.clipboardData.getData(`text/plain`),t,n,r)}function hi(e,t,n,r){e=di(e),e=fi(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function gi(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 _i(e,t,n,r,i){gi(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function vi(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function yi(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 bi=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);continue}i!==65279&&(t[r++]=i)}return r}},xi=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){d--;continue}if(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}},Si=``,Ci=` `,wi=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ti}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}},Ti=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}},Ei=class e extends wi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ti,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?vi(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()]}},Di=`di$target`,Oi=`di$dependencies`,ki=new Map;function Ai(e){return e[Oi]||[]}function V(e){if(ki.has(e))return ki.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ji(t,e,r)};return t._id=e,ki.set(e,t),t}function ji(e,t,n){t[Di]===t?t[Oi].push({id:e,index:n}):(t[Oi]=[{id:e,index:n}],t[Di]=t)}var H=V(`BufferService`),Mi=V(`CoreMouseService`),Ni=V(`CoreService`),Pi=V(`CharsetService`),Fi=V(`InstantiationService`),Ii=V(`LogService`),Li=V(`OptionsService`),Ri=V(`OscLinkService`),zi=V(`UnicodeService`),Bi=V(`DecorationService`),Vi=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 Ei,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;ti?i.activate(e,t,a):Hi(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)}};Vi=oi([B(0,H),B(1,Li),B(2,Ri)],Vi);function Hi(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 Ui=V(`CharSizeService`),Wi=V(`CoreBrowserService`),Gi=V(`MouseService`),Ki=V(`RenderService`),qi=V(`SelectionService`),Ji=V(`CharacterJoinerService`),Yi=V(`ThemeService`),Xi=V(`LinkProviderService`),Zi=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ra.isErrorNoTelemetry(e)?new ra(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 Qi(e){ea(e)||Zi.onUnexpectedError(e)}var $i=`Canceled`;function ea(e){return e instanceof ta||e instanceof Error&&e.name===$i&&e.message===$i}var ta=class extends Error{constructor(){super($i),this.name=this.message}};function na(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var ra=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`}},ia=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function aa(e,t=0){return e[e.length-(1+t)]}var oa;(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})(oa||={});var sa=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||oa.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};sa.empty=new sa(e=>{});function ca(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 la;(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 ga(...e){return _a(()=>ha(e))}function _a(e){let t=da({dispose:ca(()=>{fa(t),e()})});return t}var va=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,da(this)}dispose(){this._isDisposed||(fa(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ha(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return pa(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),pa(e,null))}};va.DISABLE_DISPOSED_WARNING=!1;var ya=va,U=class{constructor(){this._store=new ya,da(this),pa(this._store,this)}dispose(){fa(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};U.None=Object.freeze({dispose(){}});var ba=class{constructor(){this._isDisposed=!1,da(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&pa(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,fa(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&pa(e,null),e}},xa=typeof window==`object`?window:globalThis,Sa=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Sa.Undefined=new Sa(void 0);var Ca=Sa,wa=class{constructor(){this._first=Ca.Undefined,this._last=Ca.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ca.Undefined}clear(){let e=this._first;for(;e!==Ca.Undefined;){let t=e.next;e.prev=Ca.Undefined,e.next=Ca.Undefined,e=t}this._first=Ca.Undefined,this._last=Ca.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Ca(e);if(this._first===Ca.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!==Ca.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ca.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ca.Undefined&&e.next!==Ca.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ca.Undefined&&e.next===Ca.Undefined?(this._first=Ca.Undefined,this._last=Ca.Undefined):e.next===Ca.Undefined?(this._last=this._last.prev,this._last.next=Ca.Undefined):e.prev===Ca.Undefined&&(this._first=this._first.next,this._first.prev=Ca.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==Ca.Undefined;)yield e.element,e=e.next}},Ta=globalThis.performance&&typeof globalThis.performance.now==`function`,Ea=class e{static create(t){return new e(t)}constructor(e){this._now=Ta&&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}},Da;(e=>{e.None=()=>U.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(ga(...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 W({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 W({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 W({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 W({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 W({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 W;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{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 W(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 E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(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 ya?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(Da||={});var Oa=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 Ea,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}}};Oa.all=new Set,Oa._idPool=0;var ka=Oa,Aa=-1,ja=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 Ma(e?.onListenerError??Qi,this._options?.leakWarningThreshold??Aa):void 0,this._perfMon=this._options?._profName?new ka(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 Fa(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Qi)(n),U.None}if(this._disposed)return U.None;t&&(e=e.bind(t));let r=new La(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Na.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof La?(this._deliveryQueue??=new Ba,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=_a(()=>{za?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof ya?n.add(a):Array.isArray(n)&&n.push(a),za){let e=Error().stack.split(` +`).slice(2,3).join(` +`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);za.register(a,t?.[2]??e,a)}return 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*Ra<=t.length){let e=0;for(let n=0;n0}},Ba=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}},Va=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new W,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new W,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}};Va.INSTANCE=new Va;var Ha=Va;function Ua(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Ha.INSTANCE.onDidChangeZoomLevel;function Wa(e){return Ha.INSTANCE.getZoomFactor(e)}Ha.INSTANCE.onDidChangeFullscreen;var Ga=typeof navigator==`object`?navigator.userAgent:``,Ka=Ga.indexOf(`Firefox`)>=0,qa=Ga.indexOf(`AppleWebKit`)>=0,Ja=Ga.indexOf(`Chrome`)>=0,Ya=!Ja&&Ga.indexOf(`Safari`)>=0;Ga.indexOf(`Electron/`),Ga.indexOf(`Android`);var Xa=!1;if(typeof xa.matchMedia==`function`){let e=xa.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=xa.matchMedia(`(display-mode: fullscreen)`);Xa=e.matches,Ua(xa,e,({matches:e})=>{Xa&&t.matches||(Xa=e)})}function Za(){return Xa}var Qa=`en`,$a=!1,eo=!1,to=!1,no=!1,ro=!1,io=Qa,ao,oo=globalThis,so;typeof oo.vscode<`u`&&typeof oo.vscode.process<`u`?so=oo.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(so=process);var G=typeof so?.versions?.electron==`string`&&so?.type===`renderer`;if(typeof so==`object`){$a=so.platform===`win32`,eo=so.platform===`darwin`,to=so.platform===`linux`,to&&so.env.SNAP&&so.env.SNAP_REVISION,so.env.CI||so.env.BUILD_ARTIFACTSTAGINGDIRECTORY,io=Qa;let e=so.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,io=t.resolvedLanguage||Qa,t.languagePack?.translationsConfigFile}catch{}no=!0}else typeof navigator==`object`&&!G?(ao=navigator.userAgent,$a=ao.indexOf(`Windows`)>=0,eo=ao.indexOf(`Macintosh`)>=0,(ao.indexOf(`Macintosh`)>=0||ao.indexOf(`iPad`)>=0||ao.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,to=ao.indexOf(`Linux`)>=0,ao?.indexOf(`Mobi`),ro=!0,io=globalThis._VSCODE_NLS_LANGUAGE||Qa,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var co=$a,lo=eo,uo=to,fo=no;ro&&typeof oo.importScripts==`function`&&oo.origin;var po=ao,mo=io,ho;(e=>{function t(){return mo}e.value=t;function n(){return mo.length===2?mo===`en`:mo.length>=3&&mo[0]===`e`&&mo[1]===`n`&&mo[2]===`-`}e.isDefaultVariant=n;function r(){return mo===`en`}e.isDefault=r})(ho||={});var go=typeof oo.postMessage==`function`&&!oo.importScripts;(()=>{if(go){let e=[];oo.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}),oo.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var _o=!!(po&&po.indexOf(`Chrome`)>=0);po&&po.indexOf(`Firefox`),!_o&&po&&po.indexOf(`Safari`),po&&po.indexOf(`Edg/`),po&&po.indexOf(`Android`);var vo=typeof navigator==`object`?navigator:{};fo||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||vo&&vo.clipboard&&vo.clipboard.writeText,fo||vo&&vo.clipboard&&vo.clipboard.readText,fo||Za()||vo.keyboard,`ontouchstart`in xa||vo.maxTouchPoints,xa.PointerEvent&&(`ontouchstart`in xa||navigator.maxTouchPoints);var yo=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}},bo=new yo,xo=new yo,So=new yo,Co=Array(230),wo;(e=>{function t(e){return bo.keyCodeToStr(e)}e.toString=t;function n(e){return bo.strToKeyCode(e)}e.fromString=n;function r(e){return xo.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return So.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return xo.strToKeyCode(e)||So.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 bo.keyCodeToStr(e)}e.toElectronAccelerator=o})(wo||={});var To=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 Eo([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Eo=class{constructor(e){if(e.length===0)throw na(`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 Bo?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Da.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Ro})})(zo||={});var Bo=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?Ro:(this._emitter||=new W,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Vo=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 ia(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ia(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Ho=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 ia(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=_a(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Uo;(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})(Uo||={});var Wo=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 W,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())}};Wo.EMPTY=Wo.fromArray([]);function Go(e){return Ko(e,0)}function Ko(e,t){switch(typeof e){case`object`:return e===null?qo(349,t):Array.isArray(e)?Xo(e,t):Zo(e,t);case`string`:return Yo(e,t);case`boolean`:return Jo(e,t);case`number`:return qo(e,t);case`undefined`:return qo(937,t);default:return qo(617,t)}}function qo(e,t){return(t<<5)-t+e|0}function Jo(e,t){return qo(e?433:863,t)}function Yo(e,t){t=qo(149417,t);for(let n=0,r=e.length;nKo(t,e),t)}function Zo(e,t){return t=qo(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Yo(n,t),Ko(e[n],t)),t)}var{registerWindow:Qo,getWindow:$o,getDocument:es,getWindows:ts,getWindowsCount:ns,getWindowId:rs,getWindowById:is,hasWindow:as,onDidRegisterWindow:os,onWillUnregisterWindow:ss,onDidUnregisterWindow:cs}=function(){let e=new Map,t={window:xa,disposables:new ya};e.set(xa.vscodeWindowId,t);let n=new W,r=new W,i=new W;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 U.None;let a=new ya,o={window:t,disposables:a.add(new ya)};return e.set(t.vscodeWindowId,o),a.add(_a(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(K(t,vs.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:xa},getDocument(e){return $o(e).document}}}(),ls=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 K(e,t,n,r){return new ls(e,t,n,r)}function us(e,t){return function(n){return t(new Io(e,n))}}function ds(e){return function(t){return e(new Mo(t))}}var fs=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=us($o(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=ds(n)),K(e,t,i,r)},ps,ms=class extends Ho{constructor(e){super(),this.defaultTarget=e&&$o(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},hs=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){Qi(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(hs.sort),a.shift().execute();r.set(i,!1)};ps=(t,r,a=0)=>{let o=rs(t),s=new hs(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 gs=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}};gs.None=new gs(0,0);function _s(e){let t=e.getBoundingClientRect(),n=$o(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=Go(n),a=r.get(i);if(a)a.users+=1;else{let o=new W,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(_a(()=>{--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 vs={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:qa?`webkitAnimationStart`:`animationstart`,ANIMATION_END:qa?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:qa?`webkitAnimationIteration`:`animationiteration`},ys=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=bs(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=bs(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=bs(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=bs(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=bs(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=bs(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=bs(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=bs(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=bs(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=bs(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=bs(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=bs(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=bs(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=bs(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 bs(e){return typeof e==`number`?`${e}px`:e}function xs(e){return new ys(e)}var Ss=class{constructor(){this._hooks=new ya,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(_a(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=$o(e)}this._hooks.add(K(a,vs.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(K(a,vs.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Cs(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 ws;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(ws||={});var Ts=class e extends U{constructor(){super(),this.dispatched=!1,this.targets=new wa,this.ignoreTargets=new wa,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Da.runAndSubscribe(os,({window:e,disposables:t})=>{t.add(K(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(K(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(K(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:xa,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=ma(new e),_a(e.INSTANCE.targets.push(t))):U.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=ma(new e),_a(e.INSTANCE.ignoreTargets.push(t))):U.None}static isTouchDevice(){return`ontouchstart`in xa||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-aa(s.rollingPageX))<30&&Math.abs(s.initialPageY-aa(s.rollingPageY))<30){let e=this.newGestureEvent(ws.Contextmenu,s.initialTarget);e.pageX=aa(s.rollingPageX),e.pageY=aa(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=aa(s.rollingPageX),n=aa(s.rollingPageY),i=aa(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(ws.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===ws.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===ws.Change||t.type===ws.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=ps(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(ws.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)}};Ts.SCROLL_FRICTION=-.005,Ts.HOLD_DELAY=700,Ts.CLEAR_TAP_COUNT_TIME=400,oi([Cs],Ts,`isTouchDevice`,1);var Es=Ts,Ds=class extends U{onclick(e,t){this._register(K(e,vs.CLICK,n=>t(new Io($o(e),n))))}onmousedown(e,t){this._register(K(e,vs.MOUSE_DOWN,n=>t(new Io($o(e),n))))}onmouseover(e,t){this._register(K(e,vs.MOUSE_OVER,n=>t(new Io($o(e),n))))}onmouseleave(e,t){this._register(K(e,vs.MOUSE_LEAVE,n=>t(new Io($o(e),n))))}onkeydown(e,t){this._register(K(e,vs.KEY_DOWN,e=>t(new Mo(e))))}onkeyup(e,t){this._register(K(e,vs.KEY_UP,e=>t(new Mo(e))))}oninput(e,t){this._register(K(e,vs.INPUT,t))}onblur(e,t){this._register(K(e,vs.BLUR,t))}onfocus(e,t){this._register(K(e,vs.FOCUS,t))}onchange(e,t){this._register(K(e,vs.CHANGE,t))}ignoreGesture(e){return Es.ignoreTarget(e)}},Os=11,ks=class extends Ds{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=Os+`px`,this.domNode.style.height=Os+`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 Ss),this._register(fs(this.bgDomNode,vs.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(fs(this.domNode,vs.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new ms),this._pointerdownScheduleRepeatTimer=this._register(new Vo)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,$o(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},As=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}}},js=class extends U{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new W),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new As(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 Fs(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=Fs.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)))}},Ms=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Ns(e,t){let n=t-e;return function(t){return e+n*Ls(t)}}function Ps(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`:``)))}},zs=140,Bs=class extends Ds{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 Rs(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Ss),this._shouldRender=!0,this.domNode=xs(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(K(this.domNode.domNode,vs.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new ks(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=xs(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(K(this.slider.domNode,vs.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=_s(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(co&&a>zs){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()}},Vs=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}};Js.INSTANCE=new Js;var Ys=Js,Xs=class extends Ds{constructor(e,t,n){super(),this._onScroll=this._register(new W),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new W),this.onWillScroll=this._onWillScroll.event,this._options=Qs(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 Us(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new Hs(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=xs(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=xs(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=xs(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 Vo),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ha(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,lo&&(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 Lo(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ha(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(K(this._listenOnDomNode,vs.MOUSE_WHEEL,e=>{this._onMouseWheel(new Lo(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=Ys.INSTANCE;Ks&&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=!lo&&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=Gs*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=Gs*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)&&(Ks&&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(),Ws)}},Zs=class extends Xs{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 Qs(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,lo&&(t.className+=` mac`),t}var $s=class extends U{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new W),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new js({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>ps(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Zs(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(Da.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(_a(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(_a(()=>this._styleElement.remove())),this._register(Da.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}};$s=oi([B(2,H),B(3,Wi),B(4,Mi),B(5,Yi),B(6,Li),B(7,Ki)],$s);var ec=class extends U{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(_a(()=>{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()}};ec=oi([B(1,H),B(2,Wi),B(3,Bi),B(4,Ki)],ec);var tc=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)}},nc={full:0,left:0,center:0,right:0},rc={full:0,left:0,center:0,right:0},ic={full:0,left:0,center:0,right:0},ac=class extends U{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 tc,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(_a(()=>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);rc.full=this._canvas.width,rc.left=e,rc.center=t,rc.right=e,this._refreshDrawHeightConstants(),ic.full=1,ic.left=1,ic.center=1+rc.left,ic.right=1+rc.left+rc.center}_refreshDrawHeightConstants(){nc.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);nc.left=t,nc.center=t,nc.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nc.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nc.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nc.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nc.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(ic[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-nc[e.position||`full`]/2),rc[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+nc[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}))}};ac=oi([B(2,H),B(3,Bi),B(4,Ki),B(5,Li),B(6,Yi),B(7,Wi)],ac);var q;(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=``))(q||={});var oc;(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=`Ÿ`))(oc||={});var sc;(e=>e.ST=`${q.ESC}\\`)(sc||={});var cc=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)}}};cc=oi([B(2,H),B(3,Li),B(4,Ni),B(5,Ki)],cc);var lc=0,uc=0,dc=0,fc=0,pc={css:`#00000000`,rgba:0},mc;(e=>{function t(e,t,n,r){return r===void 0?`#${yc(e)}${yc(t)}${yc(n)}`:`#${yc(e)}${yc(t)}${yc(n)}${yc(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})(mc||={});var hc;(e=>{function t(e,t){if(fc=(t.rgba&255)/255,fc===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 lc=a+Math.round((n-a)*fc),uc=o+Math.round((r-o)*fc),dc=s+Math.round((i-s)*fc),{css:mc.toCss(lc,uc,dc),rgba:mc.toRgba(lc,uc,dc)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=vc.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return mc.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[lc,uc,dc]=vc.toChannels(t),{css:mc.toCss(lc,uc,dc),rgba:t}}e.opaque=i;function a(e,t){return fc=Math.round(t*255),[lc,uc,dc]=vc.toChannels(e.rgba),{css:mc.toCss(lc,uc,dc,fc),rgba:mc.toRgba(lc,uc,dc,fc)}}e.opacity=a;function o(e,t){return fc=e.rgba&255,a(e,fc*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(hc||={});var gc;(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 lc=parseInt(e.slice(1,2).repeat(2),16),uc=parseInt(e.slice(2,3).repeat(2),16),dc=parseInt(e.slice(3,4).repeat(2),16),mc.toColor(lc,uc,dc);case 5:return lc=parseInt(e.slice(1,2).repeat(2),16),uc=parseInt(e.slice(2,3).repeat(2),16),dc=parseInt(e.slice(3,4).repeat(2),16),fc=parseInt(e.slice(4,5).repeat(2),16),mc.toColor(lc,uc,dc,fc);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 lc=parseInt(r[1]),uc=parseInt(r[2]),dc=parseInt(r[3]),fc=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),mc.toColor(lc,uc,dc,fc);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[lc,uc,dc,fc]=t.getImageData(0,0,1,1).data,fc!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:mc.toRgba(lc,uc,dc,fc),css:e}}e.toColor=r})(gc||={});var _c;(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})(_c||={});var vc;(e=>{function t(e,t){if(fc=(t&255)/255,fc===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 lc=a+Math.round((n-a)*fc),uc=o+Math.round((r-o)*fc),dc=s+Math.round((i-s)*fc),mc.toRgba(lc,uc,dc)}e.blend=t;function n(e,t,n){let a=_c.relativeLuminance(e>>8),o=_c.relativeLuminance(t>>8);if(bc(a,o)>8));if(sbc(a,_c.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=bc(a,_c.relativeLuminance(s>>8));if(cbc(a,_c.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=bc(_c.relativeLuminance2(o,s,c),_c.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=bc(_c.relativeLuminance2(o,s,c),_c.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=bc(_c.relativeLuminance2(o,s,c),_c.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})(vc||={});function yc(e){let t=e.toString(16);return t.length<2?`0`+t:t}function bc(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=E,re=O,k=this._workCell;if(f.length>0&&O===f[0][0]&&ne){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v=r[1],ne?(te=!0,k=new xc(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),re=r[1]-1,m=k.getWidth()):E=r[1]}let A=this._isCellInSelection(O,t),j=n&&O===a,M=ee&&O>=l&&O<=u,N=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,e=>{N=!0});let ie=k.getChars()||Ci;if(ie===` `&&(k.isUnderline()||k.isOverline())&&(ie=`\xA0`),T=m*s-c.get(ie,k.isBold(),k.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(A&&w||!A&&!w&&k.bg===y)&&(A&&w&&p.selectionForeground||k.fg===b)&&k.extended.ext===x&&M===S&&T===C&&!j&&!te&&!N&&ne){k.isInvisible()?_+=Ci:_+=ie,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=k.bg,b=k.fg,x=k.extended.ext,S=M,C=T,w=A,te&&a>=O&&a<=re&&(a=O),!this._coreService.isCursorHidden&&j&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`);break;default:break}}if(k.isBold()&&D.push(`xterm-bold`),k.isItalic()&&D.push(`xterm-italic`),k.isDim()&&D.push(`xterm-dim`),_=k.isInvisible()?Ci:k.getChars()||Ci,k.isUnderline()&&(D.push(`xterm-underline-${k.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!k.isUnderlineColorDefault())){if(k.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${wi.toColorRGB(k.getUnderlineColor()).join(`,`)})`;else{let e=k.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&k.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}k.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),k.isStrikethrough()&&D.push(`xterm-strikethrough`),M&&(h.style.textDecoration=`underline`);let ae=k.getFgColor(),oe=k.getFgColorMode(),P=k.getBgColor(),se=k.getBgColorMode(),F=!!k.isInverse();if(F){let e=ae;ae=P,P=e;let t=oe;oe=se,se=t}let ce,le,ue=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,e=>{e.options.layer!==`top`&&ue||(e.backgroundColorRGB&&(se=50331648,P=e.backgroundColorRGB.rgba>>8&16777215,ce=e.backgroundColorRGB),e.foregroundColorRGB&&(oe=50331648,ae=e.foregroundColorRGB.rgba>>8&16777215,le=e.foregroundColorRGB),ue=e.options.layer===`top`)}),!ue&&A&&(ce=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,P=ce.rgba>>8&16777215,se=50331648,ue=!0,p.selectionForeground&&(oe=50331648,ae=p.selectionForeground.rgba>>8&16777215,le=p.selectionForeground)),ue&&D.push(`xterm-decoration-top`);let de;switch(se){case 16777216:case 33554432:de=p.ansi[P],D.push(`xterm-bg-${P}`);break;case 50331648:de=mc.toColor(P>>16,P>>8&255,P&255),this._addStyle(h,`background-color:#${kc((P>>>0).toString(16),`0`,6)}`);break;default:F?(de=p.foreground,D.push(`xterm-bg-257`)):de=p.background}switch(ce||k.isDim()&&(ce=hc.multiplyOpacity(de,.5)),oe){case 16777216:case 33554432:k.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(h,de,p.ansi[ae],k,ce,void 0)||D.push(`xterm-fg-${ae}`);break;case 50331648:let e=mc.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(h,de,e,k,ce,le)||this._addStyle(h,`color:#${kc(ae.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,de,p.foreground,k,ce,le)||F&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!j&&!te&&!N&&ne?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),O=re}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Tc(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=hc.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]}};Oc=oi([B(1,Ji),B(2,Li),B(3,Wi),B(4,Ni),B(5,Bi),B(6,Yi)],Oc);function kc(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}},jc=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);if(s>=e.rows||c<0){this.clear();return}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 Mc(){return new jc}var Nc=`xterm-dom-renderer-owner-`,J=`xterm-rows`,Pc=`xterm-fg-`,Fc=`xterm-bg-`,Ic=`xterm-focus`,Lc=`xterm-selection`,Rc=1,zc=class extends U{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=Rc++,this._rowElements=[],this._selectionRenderModel=Mc(),this.onRequestRedraw=this._register(new W).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(J),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(Lc),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Ec(),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(Oc,document),this._element.classList.add(Nc+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(_a(()=>{this._element.classList.remove(Nc+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Ac(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} .${J} 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} .${J} { 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} .${J} .xterm-dim { color: ${hc.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} .${J}.${Ic} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${J}.${Ic} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${J}.${Ic} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${J} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${J} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${J} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${J} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${J} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Lc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Lc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Lc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Pc}${n} { color: ${r.css}; }${this._terminalSelector} .${Pc}${n}.xterm-dim { color: ${hc.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Fc}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Pc}257 { color: ${hc.opaque(e.background).css}; }${this._terminalSelector} .${Pc}257.xterm-dim { color: ${hc.multiplyOpacity(hc.opaque(e.background),.5).css}; }${this._terminalSelector} .${Fc}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(Ic),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ic),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`.${Nc}${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))}}};zc=oi([B(7,Fi),B(8,Ui),B(9,Li),B(10,H),B(11,Ni),B(12,Wi),B(13,Yi)],zc);var Bc=class extends U{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new W),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Uc(this._optionsService))}catch{this._measureStrategy=this._register(new Hc(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())}};Bc=oi([B(2,Li)],Bc);var Vc=class extends U{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)}},Hc=class extends Vc{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}},Uc=class extends Vc{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}},Wc=class extends U{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 Gc(this._window)),this._onDprChange=this._register(new W),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new W),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(Da.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(K(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(K(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}},Gc=class extends U{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ba),this._onDprChange=this._register(new W),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_a(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=K(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)}},Kc=class extends U{constructor(){super(),this.linkProviders=[],this._register(_a(()=>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 qc(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 Jc(e,t,n,r,i,a,o,s,c){if(!a)return;let l=qc(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 Yc=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Jc(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=qc(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])}}};Yc=oi([B(0,Ki),B(1,Ui)],Yc);var Xc=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=[]}},Zc={};ai(Zc,{getSafariVersion:()=>il,isChromeOS:()=>ul,isFirefox:()=>tl,isIpad:()=>ol,isIphone:()=>sl,isLegacyEdge:()=>nl,isLinux:()=>ll,isMac:()=>al,isNode:()=>Qc,isSafari:()=>rl,isWindows:()=>cl});var Qc=typeof process<`u`&&`title`in process,$c=Qc?`node`:navigator.userAgent,el=Qc?`node`:navigator.platform,tl=$c.includes(`Firefox`),nl=$c.includes(`Edge`),rl=/^((?!chrome|android).)*safari/i.test($c);function il(){if(!rl)return 0;let e=$c.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var al=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(el),ol=el===`iPad`,sl=el===`iPhone`,cl=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(el),ll=el.indexOf(`Linux`)>=0,ul=/\bCrOS\b/.test($c),dl=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()}},fl=class extends dl{_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())}}},pl=class extends dl{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ml=!Qc&&`requestIdleCallback`in window?pl:fl,hl=class{constructor(){this._queue=new ml}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},gl=class extends U{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 ba),this._pausedResizeTask=new hl,this._observerDisposable=this._register(new ba),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 W),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new W),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new W),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new W),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Xc((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new _l(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_a(()=>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=_a(()=>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()}};gl=oi([B(2,Li),B(3,Ui),B(4,Ni),B(5,Bi),B(6,H),B(7,Wi),B(8,Yi)],gl);var _l=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 vl(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return xl(i,a,e,t,n,r)+Sl(a,t,n,r)+Cl(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,Al(Math.abs(i-e),kl(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return Al(bl(a>t?e:i,n)+(s-1)*n.cols+1+yl(a>t?i:e,n),kl(o,r))}function yl(e,t){return e-1}function bl(e,t){return t.cols-e}function xl(e,t,n,r,i,a){return Sl(t,r,i,a).length===0?``:Al(Ol(e,t,e,t-Tl(t,i),!1,i).length,kl(`D`,a))}function Sl(e,t,n,r){let i=e-Tl(e,n),a=t-Tl(t,n);return Al(Math.abs(i-a)-wl(e,t,n),kl(Dl(e,t),r))}function Cl(e,t,n,r,i,a){let o;o=Sl(t,r,i,a).length>0?r-Tl(r,i):t;let s=r,c=El(e,t,n,r,i,a);return Al(Ol(e,o,n,s,c===`C`,i).length,kl(c,a))}function wl(e,t,n){let r=0,i=e-Tl(e,n),a=t-Tl(t,n);for(let o=0;o=0&&e0?r-Tl(r,i):t,e=n&&ot?`A`:`B`}function Ol(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 kl(e,t){let n=t?`O`:`[`;return q.ESC+n+e}function Al(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 Ml(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 Nl=50,Pl=15,Fl=50,Il=500,Ll=RegExp(`\xA0`,`g`),Y=class extends U{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 Ei,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new W),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new W),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new W),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new W),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 jl(this._bufferService),this._activeSelectionMode=0,this._register(_a(()=>{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(Ll,` `)).join(cl?`\r +`:` +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),ll&&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=Ml(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=qc(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,-Nl),Nl),t/=Nl,t/Math.abs(t)+Math.round(t*(Pl-1)))}shouldForceSelection(e){return al?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(),Fl)}_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&&!(al&&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=Ml(n,this._bufferService.cols)}};Y=oi([B(3,H),B(4,Ni),B(5,Gi),B(6,Li),B(7,Ki),B(8,Wi)],Y);var X=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={}}},Rl=class{constructor(){this._color=new X,this._css=new X}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()}},zl=Object.freeze((()=>{let e=[gc.toColor(`#2e3436`),gc.toColor(`#cc0000`),gc.toColor(`#4e9a06`),gc.toColor(`#c4a000`),gc.toColor(`#3465a4`),gc.toColor(`#75507b`),gc.toColor(`#06989a`),gc.toColor(`#d3d7cf`),gc.toColor(`#555753`),gc.toColor(`#ef2929`),gc.toColor(`#8ae234`),gc.toColor(`#fce94f`),gc.toColor(`#729fcf`),gc.toColor(`#ad7fa8`),gc.toColor(`#34e2e2`),gc.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:mc.toCss(r,i,a),rgba:mc.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:mc.toCss(n,n,n),rgba:mc.toRgba(n,n,n)})}return e})()),Bl=gc.toColor(`#ffffff`),Vl=gc.toColor(`#000000`),Hl=gc.toColor(`#ffffff`),Ul=Vl,Wl={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},Gl=Bl,Kl=class extends U{constructor(e){super(),this._optionsService=e,this._contrastCache=new Rl,this._halfContrastCache=new Rl,this._onChangeColors=this._register(new W),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Bl,background:Vl,cursor:Hl,cursorAccent:Ul,selectionForeground:void 0,selectionBackgroundTransparent:Wl,selectionBackgroundOpaque:hc.blend(Vl,Wl),selectionInactiveBackgroundTransparent:Wl,selectionInactiveBackgroundOpaque:hc.blend(Vl,Wl),scrollbarSliderBackground:hc.opacity(Bl,.2),scrollbarSliderHoverBackground:hc.opacity(Bl,.4),scrollbarSliderActiveBackground:hc.opacity(Bl,.5),overviewRulerBorder:Bl,ansi:zl.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=ql(e.foreground,Bl),t.background=ql(e.background,Vl),t.cursor=hc.blend(t.background,ql(e.cursor,Hl)),t.cursorAccent=hc.blend(t.background,ql(e.cursorAccent,Ul)),t.selectionBackgroundTransparent=ql(e.selectionBackground,Wl),t.selectionBackgroundOpaque=hc.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ql(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=hc.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ql(e.selectionForeground,pc):void 0,t.selectionForeground===pc&&(t.selectionForeground=void 0),hc.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=hc.opacity(t.selectionBackgroundTransparent,.3)),hc.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=hc.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ql(e.scrollbarSliderBackground,hc.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ql(e.scrollbarSliderHoverBackground,hc.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ql(e.scrollbarSliderActiveBackground,hc.opacity(t.foreground,.5)),t.overviewRulerBorder=ql(e.overviewRulerBorder,Gl),t.ansi=zl.slice(),t.ansi[0]=ql(e.black,zl[0]),t.ansi[1]=ql(e.red,zl[1]),t.ansi[2]=ql(e.green,zl[2]),t.ansi[3]=ql(e.yellow,zl[3]),t.ansi[4]=ql(e.blue,zl[4]),t.ansi[5]=ql(e.magenta,zl[5]),t.ansi[6]=ql(e.cyan,zl[6]),t.ansi[7]=ql(e.white,zl[7]),t.ansi[8]=ql(e.brightBlack,zl[8]),t.ansi[9]=ql(e.brightRed,zl[9]),t.ansi[10]=ql(e.brightGreen,zl[10]),t.ansi[11]=ql(e.brightYellow,zl[11]),t.ansi[12]=ql(e.brightBlue,zl[12]),t.ansi[13]=ql(e.brightMagenta,zl[13]),t.ansi[14]=ql(e.brightCyan,zl[14]),t.ansi[15]=ql(e.brightWhite,zl[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)}},Xl={trace:0,debug:1,info:2,warn:3,error:4,off:5},Zl=`xterm.js: `,Ql=class extends U{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),$l=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Xl[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*Z+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*Z+0]=e|2097152|t[2]<<22):this._data[e*Z+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*Z+0]>>22}hasWidth(e){return this._data[e*Z+0]&12582912}getFg(e){return this._data[e*Z+1]}getBg(e){return this._data[e*Z+2]}hasContent(e){return this._data[e*Z+0]&4194303}getCodePoint(e){let t=this._data[e*Z+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*Z+0]&2097152}getString(e){let t=this._data[e*Z+0];return t&2097152?this._combined[e]:t&2097151?vi(t&2097151):``}isProtected(e){return this._data[e*Z+2]&536870912}loadCell(e,t){return nu=e*Z,t.content=this._data[nu+0],t.fg=this._data[nu+1],t.bg=this._data[nu+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*Z+0]=t.content,this._data[e*Z+1]=t.fg,this._data[e*Z+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Z+0]=t|n<<22,this._data[e*Z+1]=r.fg,this._data[e*Z+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*Z+0];r&2097152?this._combined[e]+=vi(t):r&2097151?(this._combined[e]=vi(r&2097151)+vi(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*Z+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*ru=0;--e)if(this._data[e*Z+0]&4194303)return e+(this._data[e*Z+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Z+0]&4194303||this._data[e*Z+2]&50331648)return e+(this._data[e*Z+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 au(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 ou(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;olu(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 lu(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 uu=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new W),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ha(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};uu._nextId=1;var du=uu,fu={},pu=fu.B;fu[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},fu.A={"#":`£`},fu.B=void 0,fu[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},fu.C=fu[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},fu.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},fu.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},fu.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},fu.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},fu.E=fu[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},fu.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},fu.H=fu[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},fu[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var mu=4294967295,hu=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=tu.clone(),this.savedCharset=pu,this.markers=[],this._nullCell=Ei.fromCharData([0,Si,1,0]),this._whitespaceCell=Ei.fromCharData([0,Ci,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ml,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new eu(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 Ti),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 Ti),this._whitespaceCell}getBlankLine(e,t){return new iu(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&&emu?mu:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=tu);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 eu(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(tu),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 iu(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=au(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(tu),n);if(r.length>0){let n=ou(this.lines,r);su(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(tu),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--,_=lu(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)}},gu=class extends U{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new W),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 hu(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new hu(!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)}},_u=2,vu=1,yu=class extends U{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new W),this.onResize=this._onResize.event,this._onScroll=this._register(new W),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,_u),this.rows=Math.max(e.rawOptions.rows||0,vu),this.buffers=this._register(new gu(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))}};yu=oi([B(0,Li)],yu);var bu={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:al,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},xu=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],Su=class extends U{constructor(e){super(),this._onOptionChange=this._register(new W),this.onOptionChange=this._onOptionChange.event;let t={...bu};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(_a(()=>{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 bu))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in bu))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||=bu[e],!Cu(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=bu[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=xu.includes(t)?t:bu[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 Cu(e){return e===`block`||e===`underline`||e===`bar`}function wu(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]&&wu(e[r],t-1);return n}var Tu=Object.freeze({insertMode:!1}),Eu=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Du=class extends U{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 W),this.onData=this._onData.event,this._onUserInput=this._register(new W),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new W),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new W),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=wu(Tu),this.decPrivateModes=wu(Eu)}reset(){this.modes=wu(Tu),this.decPrivateModes=wu(Eu)}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))}};Du=oi([B(0,H),B(1,Ii),B(2,Li)],Du);var Ou={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 ku(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 Au=String.fromCharCode,ju={DEFAULT:e=>{let t=[ku(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${Au(t[0])}${Au(t[1])}${Au(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${ku(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${ku(e,!0)};${e.x};${e.y}${t}`}},Mu=class extends U{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 W),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(Ou))this.addProtocol(e,Ou[e]);for(let e of Object.keys(ju))this.addEncoding(e,ju[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}};Mu=oi([B(0,H),B(1,Ni),B(2,Li)],Mu);var Nu=[[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]],Pu=[[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]],Fu;function Iu(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=Ru.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Ru.createPropertyValue(0,n,r)}},Ru=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new W,this.onChange=this._onChange.event;let e=new Lu;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)}},zu=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 Bu(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 Vu=2147483647,Hu=256,Uu=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>Hu)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;return}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>Vu?Vu: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>Vu?Vu: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,Vu):e}},Q=[],Wu=class{constructor(){this._state=0,this._active=Q,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=Q}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=Q,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Q,!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`,yi(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=Q,this._id=-1,this._state=0}}},Gu=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+=yi(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}},Ku=[],qu=class{constructor(){this._handlers=Object.create(null),this._active=Ku,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ku}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=Ku,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ku,!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`,yi(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=Ku,this._ident=0}},Ju=new Uu;Ju.addParam(0);var Yu=class{constructor(e){this._handler=e,this._data=``,this._params=Ju,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ju,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=yi(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=Ju,this._data=``,this._hitLimit=!1,e));return this._params=Ju,this._data=``,this._hitLimit=!1,t}},Xu=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(Zu,0,2,0),e.add(Zu,8,5,8),e.add(Zu,6,0,6),e.add(Zu,11,0,11),e.add(Zu,13,13,13),e}(),$u=class extends U{constructor(e=Qu){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 Uu,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(_a(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Wu),this._dcsParser=this._register(new qu),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 rd(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 id(e,t=16){let[n,r,i]=e;return`rgb:${rd(n,t)}/${rd(r,t)}/${rd(i,t)}`}var ad={"(":0,")":1,"*":2,"+":3,"-":1,".":2},od=131072,sd=10;function cd(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 ld=5e3,ud=0,dd=class extends U{constructor(e,t,n,r,i,a,o,s,c=new $u){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 bi,this._utf8Decoder=new xi,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=tu.clone(),this._eraseAttrDataInternal=tu.clone(),this._onRequestBell=this._register(new W),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new W),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new W),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new W),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new W),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new W),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new W),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new W),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new W),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new W),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new W),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new W),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new W),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 fd(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(q.BEL,()=>this.bell()),this._parser.setExecuteHandler(q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(q.BS,()=>this.backspace()),this._parser.setExecuteHandler(q.HT,()=>this.tab()),this._parser.setExecuteHandler(q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(oc.IND,()=>this.index()),this._parser.setExecuteHandler(oc.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(oc.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Gu(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new Gu(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new Gu(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new Gu(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new Gu(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new Gu(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new Gu(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new Gu(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new Gu(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new Gu(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new Gu(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new Gu(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 fu)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 Yu((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`),ld))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${ld} 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>od&&(a=this._parseStack.position+od)}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.lengthod)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 iu&&d.copyCellsFrom(e,t,0,m,!1);t=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}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=>!cd(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Yu(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Gu(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(q.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(q.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(q.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(q.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(q.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(`${q.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|=wi.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=tu.fg,e.bg=tu.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|=tu.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=tu.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|=tu.fg&16777215,r.bg&=-67108864,r.bg|=tu.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${q.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${q.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(`${q.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=tu.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(!cd(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(`${q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>sd&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>sd&&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(pd(n)){if(r===`?`)t.push({type:0,index:n});else{let e=nd(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=nd(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=tu.clone(),this._eraseAttrDataInternal=tu.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 Ei;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(`${q.ESC}${e}${q.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)}},fd=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&&(ud=e,e=t,t=ud),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};fd=oi([B(0,H)],fd);function pd(e){return 0<=e&&e<256}var md=5e7,hd=12,gd=50,_d=class extends U{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 W),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>md)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>=hd?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>=hd)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>gd&&(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()}},vd=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)))}};vd=oi([B(0,H)],vd);var $=!1,yd=class extends U{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ba),this._onBinary=this._register(new W),this.onBinary=this._onBinary.event,this._onData=this._register(new W),this.onData=this._onData.event,this._onLineFeed=this._register(new W),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new W),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new W),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new W),this._instantiationService=new Yl,this.optionsService=this._register(new Su(e)),this._instantiationService.setService(Li,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(yu)),this._instantiationService.setService(H,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ql)),this._instantiationService.setService(Ii,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Du)),this._instantiationService.setService(Ni,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Mu)),this._instantiationService.setService(Mi,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ru)),this._instantiationService.setService(zi,this.unicodeService),this._charsetService=this._instantiationService.createInstance(zu),this._instantiationService.setService(Pi,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(vd),this._instantiationService.setService(Ri,this._oscLinkService),this._inputHandler=this._register(new dd(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Da.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Da.forward(this._bufferService.onResize,this._onResize)),this._register(Da.forward(this.coreService.onData,this._onData)),this._register(Da.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 _d((e,t)=>this._inputHandler.parse(e,t))),this._register(Da.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new W),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&&!$&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),$=!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,_u),t=Math.max(t,vu),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(Bu.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(Bu(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_a(()=>{for(let t of e)t.dispose()})}}},bd={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 xd(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?q.ESC+`OA`:q.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?q.ESC+`OD`:q.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?q.ESC+`OC`:q.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?q.ESC+`OB`:q.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:q.DEL,e.altKey&&(i.key=q.ESC+i.key);break;case 9:if(e.shiftKey){i.key=q.ESC+`[Z`;break}i.key=q.HT,i.cancel=!0;break;case 13:i.key=e.altKey?q.ESC+q.CR:q.CR,i.cancel=!0;break;case 27:i.key=q.ESC,e.altKey&&(i.key=q.ESC+q.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?q.ESC+`[1;`+(a+1)+`D`:t?q.ESC+`OD`:q.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?q.ESC+`[1;`+(a+1)+`C`:t?q.ESC+`OC`:q.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?q.ESC+`[1;`+(a+1)+`A`:t?q.ESC+`OA`:q.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?q.ESC+`[1;`+(a+1)+`B`:t?q.ESC+`OB`:q.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=q.ESC+`[2~`);break;case 46:i.key=a?q.ESC+`[3;`+(a+1)+`~`:q.ESC+`[3~`;break;case 36:i.key=a?q.ESC+`[1;`+(a+1)+`H`:t?q.ESC+`OH`:q.ESC+`[H`;break;case 35:i.key=a?q.ESC+`[1;`+(a+1)+`F`:t?q.ESC+`OF`:q.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?q.ESC+`[5;`+(a+1)+`~`:q.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?q.ESC+`[6;`+(a+1)+`~`:q.ESC+`[6~`;break;case 112:i.key=a?q.ESC+`[1;`+(a+1)+`P`:q.ESC+`OP`;break;case 113:i.key=a?q.ESC+`[1;`+(a+1)+`Q`:q.ESC+`OQ`;break;case 114:i.key=a?q.ESC+`[1;`+(a+1)+`R`:q.ESC+`OR`;break;case 115:i.key=a?q.ESC+`[1;`+(a+1)+`S`:q.ESC+`OS`;break;case 116:i.key=a?q.ESC+`[15;`+(a+1)+`~`:q.ESC+`[15~`;break;case 117:i.key=a?q.ESC+`[17;`+(a+1)+`~`:q.ESC+`[17~`;break;case 118:i.key=a?q.ESC+`[18;`+(a+1)+`~`:q.ESC+`[18~`;break;case 119:i.key=a?q.ESC+`[19;`+(a+1)+`~`:q.ESC+`[19~`;break;case 120:i.key=a?q.ESC+`[20;`+(a+1)+`~`:q.ESC+`[20~`;break;case 121:i.key=a?q.ESC+`[21;`+(a+1)+`~`:q.ESC+`[21~`;break;case 122:i.key=a?q.ESC+`[23;`+(a+1)+`~`:q.ESC+`[23~`;break;case 123:i.key=a?q.ESC+`[24;`+(a+1)+`~`:q.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=q.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=q.DEL:e.keyCode===219?i.key=q.ESC:e.keyCode===220?i.key=q.FS:e.keyCode===221&&(i.key=q.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=bd[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=q.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=q.ESC+n}else if(e.keyCode===32)i.key=q.ESC+(e.ctrlKey?q.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=q.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=q.US),e.key===`@`&&(i.key=q.NUL))}return i}var Sd=0,Cd=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ml,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ml,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||(Sd=this._search(t),Sd===-1)||this._getKey(this._array[Sd])!==t)return!1;do if(this._array[Sd]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Sd),!0;while(++Sde-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&&(Sd=this._search(e),!(Sd<0||Sd>=this._array.length)&&this._getKey(this._array[Sd])===e))do yield this._array[Sd];while(++Sd=this._array.length)&&this._getKey(this._array[Sd])===e))do t(this._array[Sd]);while(++Sd=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}},wd=0,Td=0,Ed=class extends U{constructor(){super(),this._decorations=new Cd(e=>e?.marker.line),this._onDecorationRegistered=this._register(new W),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new W),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_a(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Dd(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{wd=t.options.x??0,Td=wd+(t.options.width??1),e>=wd&&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)}},Ad=20,jd=class extends U{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 kd(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(K(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(_a(()=>{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===Ad+1&&(this._liveRegion.textContent+=ui.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{ha(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(K(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(K(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(K(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(K(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&&Nd(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,ha(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}}};Md=oi([B(1,Gi),B(2,Ki),B(3,H),B(4,Xi)],Md);function Nd(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 Pd=class extends yd{constructor(e={}){super(e),this._linkifier=this._register(new ba),this.browser=Zc,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ba),this._onCursorMove=this._register(new W),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new W),this.onKey=this._onKey.event,this._onRender=this._register(new W),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new W),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new W),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new W),this.onBell=this._onBell.event,this._onFocus=this._register(new W),this._onBlur=this._register(new W),this._onA11yCharEmitter=this._register(new W),this._onA11yTabEmitter=this._register(new W),this._onWillOpen=this._register(new W),this._setup(),this._decorationService=this._instantiationService.createInstance(Ed),this._instantiationService.setService(Bi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Kc),this._instantiationService.setService(Xi,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Vi)),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(Da.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Da.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Da.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Da.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(_a(()=>{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=hc.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${q.ESC}]${n};${id(r)}${sc.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=mc.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=mc.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(jd,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.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(q.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(K(this.element,`copy`,e=>{this.hasSelection()&&pi(e,this._selectionService)}));let e=e=>mi(e,this.textarea,this.coreService,this.optionsService);this._register(K(this.textarea,`paste`,e)),this._register(K(this.element,`paste`,e)),tl?this._register(K(this.element,`mousedown`,e=>{e.button===2&&_i(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(K(this.element,`contextmenu`,e=>{_i(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),ll&&this._register(K(this.element,`auxclick`,e=>{e.button===1&&gi(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(K(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(K(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(K(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(K(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(K(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(K(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(K(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(K(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`,ci.get()),ul||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(Wc,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Wi,this._coreBrowserService),this._register(K(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(K(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Bc,this._document,this._helperContainer),this._instantiationService.setService(Ui,this._charSizeService),this._themeService=this._instantiationService.createInstance(Kl),this._instantiationService.setService(Yi,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Sc),this._instantiationService.setService(Ji,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(gl,this.rows,this.screenElement)),this._instantiationService.setService(Ki,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(cc,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Yc),this._instantiationService.setService(Gi,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Md,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($s,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(Y,this.element,this.screenElement,r)),this._instantiationService.setService(qi,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(Da.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(ec,this.screenElement)),this._register(K(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(jd,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ac,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ac,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zc,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(K(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(K(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=q.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){hi(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=xd(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===q.ETX||n.key===q.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)&&(Fd(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){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}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 Ei)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Rd=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 Ld(t)}getNullCell(){return new Ei}},zd=class extends U{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new W),this.onBufferChange=this._onBufferChange.event,this._normal=new Rd(this._core.buffers.normal,`normal`),this._alternate=new Rd(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)}},Bd=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)}},Vd=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}},Hd=[`cols`,`rows`],Ud=0,Wd=class extends U{constructor(e){super(),this._core=this._register(new Pd(e)),this._addonManager=this._register(new Id),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(Hd.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 Bd(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Vd(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 zd(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 ci.get()},set promptLabel(e){ci.set(e)},get tooMuchOutput(){return ui.get()},set tooMuchOutput(e){ui.set(e)}}}_verifyIntegers(...e){for(Ud of e)if(Ud===1/0||isNaN(Ud)||Ud%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(Ud of e)if(Ud&&(Ud===1/0||isNaN(Ud)||Ud%1!=0||Ud<0))throw Error(`This API only accepts positive integers`)}},Gd=2,Kd=1,qd=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(Gd,Math.floor(u/e.css.cell.width)),rows:Math.max(Kd,Math.floor(l/e.css.cell.height))}}},Jd=Object.defineProperty,Yd=Object.getOwnPropertyDescriptor,Xd=(e,t,n,r)=>{for(var i=r>1?void 0:r?Yd(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&&Jd(t,n,i),i},Zd=(e,t)=>(n,r)=>t(n,r,e),Qd=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?rf.isErrorNoTelemetry(e)?new rf(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 $d(e){tf(e)||Qd.onUnexpectedError(e)}var ef=`Canceled`;function tf(e){return e instanceof nf||e instanceof Error&&e.name===ef&&e.message===ef}var nf=class extends Error{constructor(){super(ef),this.name=this.message}},rf=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`}},af;(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})(af||={});var of=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||af.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};of.empty=new of(e=>{});function sf(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 cf;(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 mf(...e){return hf(()=>pf(e))}function hf(e){let t=uf({dispose:sf(()=>{df(t),e()})});return t}var gf=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,uf(this)}dispose(){this._isDisposed||(df(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{pf(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return ff(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),ff(e,null))}};gf.DISABLE_DISPOSED_WARNING=!1;var _f=gf,vf=class{constructor(){this._store=new _f,uf(this),ff(this._store,this)}dispose(){df(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};vf.None=Object.freeze({dispose(){}});var yf=class{constructor(){this._isDisposed=!1,uf(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&ff(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,df(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&ff(e,null),e}},bf=typeof process<`u`&&`title`in process,xf=bf?`node`:navigator.userAgent,Sf=bf?`node`:navigator.platform,Cf=xf.includes(`Firefox`),wf=xf.includes(`Edge`),Tf=/^((?!chrome|android).)*safari/i.test(xf);function Ef(){if(!Tf)return 0;let e=xf.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Sf),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Sf),Sf.indexOf(`Linux`),/\bCrOS\b/.test(xf);var Df=``,Of=0,kf=0,Af=0,jf=0,Mf={css:`#00000000`,rgba:0},Nf;(e=>{function t(e,t,n,r){return r===void 0?`#${Rf(e)}${Rf(t)}${Rf(n)}`:`#${Rf(e)}${Rf(t)}${Rf(n)}${Rf(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})(Nf||={});var Pf;(e=>{function t(e,t){if(jf=(t.rgba&255)/255,jf===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 Of=a+Math.round((n-a)*jf),kf=o+Math.round((r-o)*jf),Af=s+Math.round((i-s)*jf),{css:Nf.toCss(Of,kf,Af),rgba:Nf.toRgba(Of,kf,Af)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Lf.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Nf.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Of,kf,Af]=Lf.toChannels(t),{css:Nf.toCss(Of,kf,Af),rgba:t}}e.opaque=i;function a(e,t){return jf=Math.round(t*255),[Of,kf,Af]=Lf.toChannels(e.rgba),{css:Nf.toCss(Of,kf,Af,jf),rgba:Nf.toRgba(Of,kf,Af,jf)}}e.opacity=a;function o(e,t){return jf=e.rgba&255,a(e,jf*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Pf||={});var Ff;(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 Of=parseInt(e.slice(1,2).repeat(2),16),kf=parseInt(e.slice(2,3).repeat(2),16),Af=parseInt(e.slice(3,4).repeat(2),16),Nf.toColor(Of,kf,Af);case 5:return Of=parseInt(e.slice(1,2).repeat(2),16),kf=parseInt(e.slice(2,3).repeat(2),16),Af=parseInt(e.slice(3,4).repeat(2),16),jf=parseInt(e.slice(4,5).repeat(2),16),Nf.toColor(Of,kf,Af,jf);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 Of=parseInt(r[1]),kf=parseInt(r[2]),Af=parseInt(r[3]),jf=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Nf.toColor(Of,kf,Af,jf);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Of,kf,Af,jf]=t.getImageData(0,0,1,1).data,jf!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Nf.toRgba(Of,kf,Af,jf),css:e}}e.toColor=r})(Ff||={});var If;(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})(If||={});var Lf;(e=>{function t(e,t){if(jf=(t&255)/255,jf===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 Of=a+Math.round((n-a)*jf),kf=o+Math.round((r-o)*jf),Af=s+Math.round((i-s)*jf),Nf.toRgba(Of,kf,Af)}e.blend=t;function n(e,t,n){let a=If.relativeLuminance(e>>8),o=If.relativeLuminance(t>>8);if(zf(a,o)>8));if(szf(a,If.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=zf(a,If.relativeLuminance(s>>8));if(czf(a,If.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=zf(If.relativeLuminance2(o,s,c),If.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=zf(If.relativeLuminance2(o,s,c),If.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=zf(If.relativeLuminance2(o,s,c),If.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})(Lf||={});function Rf(e){let t=e.toString(16);return t.length<2?`0`+t:t}function zf(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 Kf(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!Gf(e)&&!Vf(e)&&!Uf(e)}function qf(e){return Vf(e)||Wf(e)}function Jf(){return{css:{canvas:Yf(),cell:Yf()},device:{canvas:Yf(),cell:Yf(),char:{width:0,height:0,left:0,top:0}}}}function Yf(){return{width:0,height:0}}function Xf(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var Zf=0,Qf=0,$f=!1,ep=!1,tp=!1,np,rp=0,ip=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,Qf=0,Zf=0,ep=!1,$f=!1,tp=!1,np=this._themeService.colors,rp=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));rp=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(Qf=e.backgroundColorRGB.rgba>>8&16777215,ep=!0),e.foregroundColorRGB&&(Zf=e.foregroundColorRGB.rgba>>8&16777215,$f=!0)}),tp=this._selectionRenderModel.isCellSelected(this._terminal,t,n),tp){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:Qf=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Qf=(this.result.fg&16777215)<<8|255;break;case 0:default:Qf=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:Qf=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Qf=(this.result.bg&16777215)<<8|255;break}Qf=Lf.blend(Qf,(this._coreBrowserService.isFocused?np.selectionBackgroundOpaque:np.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else Qf=(this._coreBrowserService.isFocused?np.selectionBackgroundOpaque:np.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(ep=!0,np.selectionForeground&&(Zf=np.selectionForeground.rgba>>8&16777215,$f=!0),qf(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))Zf=(this._coreBrowserService.isFocused?np.selectionBackgroundOpaque:np.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Zf=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Zf=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:Zf=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Zf=(this.result.fg&16777215)<<8|255;break;case 0:default:Zf=this._themeService.colors.foreground.rgba}Zf=Lf.blend(Zf,(this._coreBrowserService.isFocused?np.selectionBackgroundOpaque:np.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}$f=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(Qf=e.backgroundColorRGB.rgba>>8&16777215,ep=!0),e.foregroundColorRGB&&(Zf=e.foregroundColorRGB.rgba>>8&16777215,$f=!0)}),ep&&(Qf=tp?e.bg&-150994944|Qf|50331648:e.bg&-16777216|Qf|50331648),$f&&(Zf=e.fg&-83886080|Zf|50331648),this.result.fg&67108864&&(ep&&!$f&&(Zf=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|np.background.rgba>>8&16777215|50331648,$f=!0),!ep&&$f&&(Qf=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|np.foreground.rgba>>8&16777215|50331648,ep=!0)),np=void 0,this.result.bg=ep?Qf:this.result.bg,this.result.fg=$f?Zf:this.result.fg,this.result.ext&=536870911,this.result.ext|=rp<<29&3758096384}},ap=.5,op=Cf||wf?`bottom`:`ideographic`,sp={"▀":[{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}]},cp={"░":[[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]]},lp={"─":{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`}},up={"":{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}};up[``]=up[``],up[``]=up[``];function dp(e,t,n,r,i,a,o,s){let c=sp[t];if(c)return fp(e,c,n,r,i,a),!0;let l=cp[t];if(l)return mp(e,l,n,r,i,a),!0;let u=lp[t];if(u)return hp(e,u,n,r,i,a,s),!0;let d=up[t];return d?(gp(e,d,n,r,i,a,o,s),!0):!1}function fp(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 yp(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()}},Cp=class extends Sp{_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())}}},wp=class extends Sp{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Tp=!bf&&`requestIdleCallback`in window?wp:Cp,Ep=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Dp}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}},Dp=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}},Op=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Op.Undefined=new Op(void 0);var kp=globalThis.performance&&typeof globalThis.performance.now==`function`,Ap=class e{static create(t){return new e(t)}constructor(e){this._now=kp&&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}},jp;(e=>{e.None=()=>vf.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(mf(...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 Wp({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 Wp({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 Wp({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 Wp({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 Wp({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 Wp;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{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 Wp(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 E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(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 _f?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(jp||={});var Mp=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 Ap,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}}};Mp.all=new Set,Mp._idPool=0;var Np=Mp,Pp=-1,Fp=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 Ip(e?.onListenerError??$d,this._options?.leakWarningThreshold??Pp):void 0,this._perfMon=this._options?._profName?new Np(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 zp(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||$d)(n),vf.None}if(this._disposed)return vf.None;t&&(e=e.bind(t));let r=new Vp(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Lp.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Vp?(this._deliveryQueue??=new Gp,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=hf(()=>{Up?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof _f?n.add(a):Array.isArray(n)&&n.push(a),Up){let e=Error().stack.split(` +`).slice(2,3).join(` +`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);Up.register(a,t?.[2]??e,a)}return 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*Hp<=t.length){let e=0;for(let n=0;n0}},Gp=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}},Kp={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}},qp=2,Jp,Yp=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new xp,this._cacheMapCombined=new xp,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Ep,this._textureSize=512,this._onAddTextureAtlasCanvas=new Wp,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Wp,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=$p(e,this._config.deviceCellWidth*4+qp*2,this._config.deviceCellHeight+qp*2),this._tmpCtx=Bf(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 Tp;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 Xp(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 Xp(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 Mf;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=Ep.toColorRGB(t);i=Nf.toColor(e[0],e[1],e[2]);break;default:i=n?Pf.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(i=Pf.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=Ep.toColorRGB(a);d=Nf.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=Pf.opaque(d)),s&&(d=Pf.multiplyOpacity(d,ap)),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=Lf.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=Nf.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)+qp*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=Xf(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(),!ee&&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*te,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,D,D+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(D,D+t),this._tmpCtx.lineTo(D+this._config.deviceCharWidth*te,D+t),this._tmpCtx.stroke()}if(ee||this._tmpCtx.fillText(s,D,D+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=Zp(this._tmpCtx.getImageData(D,D,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,O);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,D,D+this._config.deviceCharHeight-t),e=Zp(this._tmpCtx.getImageData(D,D,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,O),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(D,D+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(D+this._config.deviceCharWidth*te,D+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let ne=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),re;if(re=this._config.allowTransparency?Qp(ne):Zp(ne,x,E,O),re)return Kp;let k=this._findGlyphBoundingBox(ne,this._workBoundingBox,c,T,ee,D),A,j;for(;;){if(this._activePages.length===0){let e=this._createNewPage();A=e,j=e.currentRow,j.height=k.size.y;break}A=this._activePages[this._activePages.length-1],j=A.currentRow;for(let e of this._activePages)k.size.y<=e.currentRow.height&&(A=e,j=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=j.height&&k.size.y<=t.height&&(A=this._activePages[e],j=t);if(k.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Xp(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),A=this._overflowSizePage,j=this._overflowSizePage.currentRow,j.x+k.size.x>=A.canvas.width&&(j.x=0,j.y+=j.height,j.height=0);break}if(j.y+k.size.y>=A.canvas.height||j.height>k.size.y+2){let t=!1;if(A.currentRow.y+A.currentRow.height+k.size.y>=A.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+k.size.y=e.maxAtlasPages&&j.y+k.size.y<=A.canvas.height&&j.height>=k.size.y&&j.x+k.size.x<=A.canvas.width)t=!0;else{let e=this._createNewPage();A=e,j=e.currentRow,j.height=k.size.y,t=!0}}t||(A.currentRow.height>0&&A.fixedRows.push(A.currentRow),j={x:0,y:A.currentRow.y+A.currentRow.height,height:k.size.y},A.fixedRows.push(j),A.currentRow={x:0,y:j.y+j.height,height:0})}if(j.x+k.size.x<=A.canvas.width)break;j===A.currentRow?(j.x=0,j.y+=j.height,j.height=0):A.fixedRows.splice(A.fixedRows.indexOf(j),1)}return k.texturePage=this._pages.indexOf(A),k.texturePosition.x=j.x,k.texturePosition.y=j.y,k.texturePositionClipSpace.x=j.x/A.canvas.width,k.texturePositionClipSpace.y=j.y/A.canvas.height,k.sizeClipSpace.x/=A.canvas.width,k.sizeClipSpace.y/=A.canvas.height,j.height=Math.max(j.height,k.size.y),j.x+=k.size.x,A.ctx.putImageData(ne,k.texturePosition.x-this._workBoundingBox.left,k.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,k.size.x,k.size.y),A.addGlyph(k),A.version++,k}_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 $p(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function em(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:Mf,cursorAccent:Mf,selectionForeground:Mf,selectionBackgroundTransparent:Mf,selectionBackgroundOpaque:Mf,selectionInactiveBackgroundTransparent:Mf,selectionInactiveBackgroundOpaque:Mf,overviewRulerBorder:Mf,scrollbarSliderBackground:Mf,scrollbarSliderHoverBackground:Mf,scrollbarSliderActiveBackground:Mf,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 tm(e,t){for(let n=0;n=0){if(tm(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),rm.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=om){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=om-(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=om-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},om)},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 cm(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 hf(()=>r?.disconnect())}function lm(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var um=class e extends Ep{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Dp,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?lm(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()]}},dm=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function fm(e,t,n){let r=Bf(e.createProgram());if(e.attachShader(r,Bf(pm(e,e.VERTEX_SHADER,t))),e.attachShader(r,Bf(pm(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 pm(e,t,n){let r=Bf(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 mm(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;ti.deleteProgram(this._program))),this._projectionLocation=Bf(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=Bf(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=Bf(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(hf(()=>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(hf(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=Bf(i.createBuffer()),this._register(hf(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,ym,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,ym,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,ym,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,ym,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,ym,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,ym,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(Yp.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){if(xm=(n*this._terminal.cols+t)*vm,r===0||r===void 0){e.fill(0,xm,xm+vm-1-bm);return}this._atlas&&(Sm=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),Cm=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&Sm.offset.x>Cm?(wm=Sm.offset.x-Cm,e[xm]=-(Sm.offset.x-wm)+this._dimensions.device.char.left,e[xm+1]=-Sm.offset.y+this._dimensions.device.char.top,e[xm+2]=(Sm.size.x-wm)/this._dimensions.device.canvas.width,e[xm+3]=Sm.size.y/this._dimensions.device.canvas.height,e[xm+4]=Sm.texturePage,e[xm+5]=Sm.texturePositionClipSpace.x+wm/this._atlas.pages[Sm.texturePage].canvas.width,e[xm+6]=Sm.texturePositionClipSpace.y,e[xm+7]=Sm.sizeClipSpace.x-wm/this._atlas.pages[Sm.texturePage].canvas.width,e[xm+8]=Sm.sizeClipSpace.y):(e[xm]=-Sm.offset.x+this._dimensions.device.char.left,e[xm+1]=-Sm.offset.y+this._dimensions.device.char.top,e[xm+2]=Sm.size.x/this._dimensions.device.canvas.width,e[xm+3]=Sm.size.y/this._dimensions.device.canvas.height,e[xm+4]=Sm.texturePage,e[xm+5]=Sm.texturePositionClipSpace.x,e[xm+6]=Sm.texturePositionClipSpace.y,e[xm+7]=Sm.sizeClipSpace.x,e[xm+8]=Sm.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Kf(r,c,Sm.size.x,this._dimensions.device.cell.width)&&(e[xm+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*vm;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();return}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 Dm(){return new Em}var Om=4,km=1,Am=2,jm=3,Mm=2147483648,Nm=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=Dm()}resize(e,t){let n=e*t*Om;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)}},Pm=`#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; +}`,Fm=`#version 300 es +precision lowp float; + +in vec4 v_color; + +out vec4 outColor; + +void main() { + outColor = v_color; +}`,Im=8,Lm=Im*Float32Array.BYTES_PER_ELEMENT,Rm=20*Im,zm=class{constructor(){this.attributes=new Float32Array(Rm),this.count=0}},Bm=0,Vm=0,Hm=0,Um=0,Wm=0,Gm=0,Km=0,qm=class extends vf{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new zm,this._verticesCursor=new zm;let i=this._gl;this._program=Bf(fm(i,Pm,Fm)),this._register(hf(()=>i.deleteProgram(this._program))),this._projectionLocation=Bf(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(hf(()=>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(hf(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=Bf(i.createBuffer()),this._register(hf(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,Lm,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Lm,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,Lm,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,dm),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,Wm=(Bm>>16&255)/255,Gm=(Bm>>8&255)/255,Km=1,this._addRectangle(e.attributes,t,Vm,Hm,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Um,Wm,Gm,Km)}_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])}},Jm=class extends vf{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(hf(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Bf(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=im(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=op,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}`}},Ym=class extends Jm{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&&nm(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;!(eh.indexOf(`Chrome`)>=0)&&eh.indexOf(`Safari`),eh.indexOf(`Electron/`),eh.indexOf(`Android`);var nh=!1;if(typeof Xm.matchMedia==`function`){let e=Xm.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Xm.matchMedia(`(display-mode: fullscreen)`);nh=e.matches,$m(Xm,e,({matches:e})=>{nh&&t.matches||(nh=e)})}function rh(){return nh}var ih=`en`,ah=!1,oh=!1,sh=!1,ch=ih,lh,uh=globalThis,dh;typeof uh.vscode<`u`&&typeof uh.vscode.process<`u`?dh=uh.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(dh=process);var fh=typeof dh?.versions?.electron==`string`&&dh?.type===`renderer`;if(typeof dh==`object`){dh.platform,dh.platform,ah=dh.platform===`linux`,ah&&dh.env.SNAP&&dh.env.SNAP_REVISION,dh.env.CI||dh.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ch=ih;let e=dh.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,ch=t.resolvedLanguage||ih,t.languagePack?.translationsConfigFile}catch{}oh=!0}else typeof navigator==`object`&&!fh?(lh=navigator.userAgent,lh.indexOf(`Windows`),lh.indexOf(`Macintosh`),(lh.indexOf(`Macintosh`)>=0||lh.indexOf(`iPad`)>=0||lh.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ah=lh.indexOf(`Linux`)>=0,lh?.indexOf(`Mobi`),sh=!0,ch=globalThis._VSCODE_NLS_LANGUAGE||ih,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var ph=oh;sh&&typeof uh.importScripts==`function`&&uh.origin;var mh=lh,hh=ch,gh;(e=>{function t(){return hh}e.value=t;function n(){return hh.length===2?hh===`en`:hh.length>=3&&hh[0]===`e`&&hh[1]===`n`&&hh[2]===`-`}e.isDefaultVariant=n;function r(){return hh===`en`}e.isDefault=r})(gh||={});var _h=typeof uh.postMessage==`function`&&!uh.importScripts;(()=>{if(_h){let e=[];uh.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}),uh.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var vh=!!(mh&&mh.indexOf(`Chrome`)>=0);mh&&mh.indexOf(`Firefox`),!vh&&mh&&mh.indexOf(`Safari`),mh&&mh.indexOf(`Edg/`),mh&&mh.indexOf(`Android`);var yh=typeof navigator==`object`?navigator:{};ph||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||yh&&yh.clipboard&&yh.clipboard.writeText,ph||yh&&yh.clipboard&&yh.clipboard.readText,ph||rh()||yh.keyboard,`ontouchstart`in Xm||yh.maxTouchPoints,Xm.PointerEvent&&(`ontouchstart`in Xm||navigator.maxTouchPoints);var bh=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}},xh=new bh,Sh=new bh,Ch=new bh;Array(230);var wh;(e=>{function t(e){return xh.keyCodeToStr(e)}e.toString=t;function n(e){return xh.strToKeyCode(e)}e.fromString=n;function r(e){return Sh.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Ch.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Sh.strToKeyCode(e)||Ch.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 xh.keyCodeToStr(e)}e.toElectronAccelerator=o})(wh||={});var Th=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Eh;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Dh?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:jp.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Th})})(Eh||={});var Dh=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?Th:(this._emitter||=new Wp,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Oh;(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})(Oh||={});var kh=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 Wp,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())}};kh.EMPTY=kh.fromArray([]);function Ah(e){return jh(e,0)}function jh(e,t){switch(typeof e){case`object`:return e===null?Mh(349,t):Array.isArray(e)?Fh(e,t):Ih(e,t);case`string`:return Ph(e,t);case`boolean`:return Nh(e,t);case`number`:return Mh(e,t);case`undefined`:return Mh(937,t);default:return Mh(617,t)}}function Mh(e,t){return(t<<5)-t+e|0}function Nh(e,t){return Mh(e?433:863,t)}function Ph(e,t){t=Mh(149417,t);for(let n=0,r=e.length;njh(t,e),t)}function Ih(e,t){return t=Mh(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Ph(n,t),jh(e[n],t)),t)}var{registerWindow:Lh,getWindow:Rh,getDocument:zh,getWindows:Bh,getWindowsCount:Vh,getWindowId:Hh,getWindowById:Uh,hasWindow:Wh,onDidRegisterWindow:Gh,onWillUnregisterWindow:Kh,onDidUnregisterWindow:qh}=function(){let e=new Map,t={window:Xm,disposables:new _f};e.set(Xm.vscodeWindowId,t);let n=new Wp,r=new Wp,i=new Wp;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 vf.None;let a=new _f,o={window:t,disposables:a.add(new _f)};return e.set(t.vscodeWindowId,o),a.add(hf(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(Yh(t,Zh.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:Xm},getDocument(e){return Rh(e).document}}}(),Jh=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 Yh(e,t,n,r){return new Jh(e,t,n,r)}var Xh=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}};Xh.None=new Xh(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=Ah(n),a=r.get(i);if(a)a.users+=1;else{let o=new Wp,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(hf(()=>{--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 Zh={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:th?`webkitAnimationStart`:`animationstart`,ANIMATION_END:th?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:th?`webkitAnimationIteration`:`animationiteration`},Qh=class extends vf{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 yf,this._charAtlasDisposable=this._register(new yf),this._observerDisposable=this._register(new yf),this._model=new Nm,this._workCell=new um,this._workCell2=new um,this._rectangleRenderer=this._register(new yf),this._glyphRenderer=this._register(new yf),this._onChangeTextureAtlas=this._register(new Wp),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Wp),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Wp),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Wp),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Wp),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 ip(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Ym(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=Jf(),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(Yh(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(Yh(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,am(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=cm(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=cm(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(hf(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),am(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 qm(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Tm(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=im(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=mf(jp.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),jp.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 sm(()=>{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=eg(e,n.rows-1,0),t=eg(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,C=S-n.buffer.ydisp,w=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),T=-1,E=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let D=!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 $h(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)*Om,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),E&&o===S&&(y===w&&(this._model.cursor={x:w,y:C,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},T=w+r.getWidth()-1),y>=w&&y<=T&&(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+km]!==this._cellColorResolver.result.bg||this._model.cells[v+Am]!==this._cellColorResolver.result.fg||this._model.cells[v+jm]!==this._cellColorResolver.result.ext)&&(D=!0,h.length>1&&(g|=Mm),this._model.cells[v]=g,this._model.cells[v+km]=this._cellColorResolver.result.bg,this._model.cells[v+Am]=this._cellColorResolver.result.fg,this._model.cells[v+jm]=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)*Om,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,Df,0,0),this._model.cells[b]=0,this._model.cells[b+km]=this._cellColorResolver.result.bg,this._model.cells[b+Am]=this._cellColorResolver.result.fg,this._model.cells[b+jm]=this._cellColorResolver.result.ext;y--}}D&&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})}},$h=class extends Ep{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 eg(e,t,n=0){return Math.max(Math.min(e,t),n)}var tg=`di$target`,ng=`di$dependencies`,rg=new Map;function ig(e){if(rg.has(e))return rg.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ag(t,e,r)};return t._id=e,rg.set(e,t),t}function ag(e,t,n){t[tg]===t?t[ng].push({id:e,index:n}):(t[ng]=[{id:e,index:n}],t[tg]=t)}ig(`BufferService`),ig(`CoreMouseService`),ig(`CoreService`),ig(`CharsetService`),ig(`InstantiationService`),ig(`LogService`);var og=ig(`OptionsService`);ig(`OscLinkService`),ig(`UnicodeService`),ig(`DecorationService`);var sg={trace:0,debug:1,info:2,warn:3,error:4,off:5},cg=`xterm.js: `,lg=class extends vf{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),ug=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=sg[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 Qh(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(jp.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(jp.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(jp.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(jp.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(hf(()=>{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()}};function fg({sessionId:e,owned:t,cwd:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!a.current||!t)return;let n=getComputedStyle(document.documentElement),r=(e,t)=>n.getPropertyValue(e).trim()||t,i=new Wd({convertEol:!1,cursorBlink:!0,fontFamily:r(`--font-mono`,`monospace`),fontSize:12,theme:{background:r(`--color-bg`,`#0b0e14`),foreground:r(`--color-fg`,`#d3dae3`),cursor:r(`--color-accent`,`#5ea1ff`),selectionBackground:r(`--color-border-strong`,`#2b3646`)},scrollback:1e4}),o=new qd;i.loadAddon(o),i.open(a.current);try{let e=new dg;e.onContextLoss(()=>{e.dispose()}),i.loadAddon(e)}catch{}try{o.fit()}catch{}for(let e of[`A`,`ā`,`Ы`,`Ѣ`,`Ω`,`ế`])document.fonts?.load(`12px "JetBrains Mono Variable"`,e).catch(()=>{});document.fonts?.ready.then(()=>{try{o.fit()}catch{}});let s=location.protocol===`https:`?`wss`:`ws`,c=new WebSocket(`${s}://${location.host}/v1/agents/${encodeURIComponent(e)}/term`);c.binaryType=`arraybuffer`,c.onmessage=e=>{i.write(typeof e.data==`string`?e.data:new Uint8Array(e.data))},c.onclose=()=>i.write(`\r +\x1B[2m[session ended]\x1B[0m\r +`);let l=new TextEncoder,u=e=>{c.readyState===WebSocket.OPEN&&c.send(l.encode(e))},d=i.onData(u),f=(e,t)=>{c.readyState!==WebSocket.OPEN||e<=0||t<=0||c.send(JSON.stringify({resize:{cols:e,rows:t}}))},p=i.onResize(({cols:e,rows:t})=>f(e,t));c.onopen=()=>{try{o.fit()}catch{}f(i.cols,i.rows)};let m=e=>{e.preventDefault(),e.stopPropagation(),u(`\x1B\r`)};i.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;if(h&&e.metaKey&&!e.ctrlKey&&!e.altKey){if(e.key===`c`)return!g();if(e.key===`v`)return _(),!1}if(!h&&e.ctrlKey&&e.shiftKey&&!e.altKey&&!e.metaKey){if(e.key===`C`||e.key===`c`)return g(),!1;if(e.key===`V`||e.key===`v`)return _(),!1}return!h&&e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&(e.key===`c`||e.key===`C`)?!g()||(i.clearSelection(),!1):e.ctrlKey&&!e.altKey&&!e.metaKey&&(e.key===`j`||e.key===`J`)?(m(e),!1):e.key!==`Enter`||[e.shiftKey,e.altKey,e.ctrlKey,e.metaKey].filter(Boolean).length!==1||e.metaKey?!0:(m(e),!1)});let h=/Mac|iP(hone|ad)/.test(navigator.platform||navigator.userAgent),g=()=>{let e=i.getSelection();return e?(navigator.clipboard?.writeText(e),!0):!1},_=()=>{navigator.clipboard?.readText().then(e=>{e&&i.paste(e)}).catch(()=>{})},v=async e=>{let t=e.type||`application/octet-stream`,n=new Uint8Array(await e.arrayBuffer()),r=``;for(let e=0;e{let t=[...e.clipboardData?.items??[]].find(e=>e.kind===`file`)?.getAsFile();t&&(e.preventDefault(),v(t))},b=e=>{let t=e.dataTransfer?.files?.[0];t&&(e.preventDefault(),v(t))},x=e=>{e.preventDefault()},S=a.current;S.addEventListener(`paste`,y),S.addEventListener(`drop`,b),S.addEventListener(`dragover`,x);let C=0,w=``,T=()=>{C=0;let e=a.current;if(!e)return;let t=`${e.clientWidth}x${e.clientHeight}`;if(t!==w){w=t;try{o.fit()}catch{}}},E=new ResizeObserver(()=>{C||=requestAnimationFrame(T)});return E.observe(a.current),()=>{S.removeEventListener(`paste`,y),S.removeEventListener(`drop`,b),S.removeEventListener(`dragover`,x),C&&cancelAnimationFrame(C),E.disconnect(),d.dispose(),p.dispose(),c.close(),i.dispose()}},[e,t]),t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{ref:a,className:`h-[70vh] bg-bg`}),(0,L.jsxs)(`div`,{className:`border-t border-border px-3 py-1.5 text-[11px] text-fg-faint`,children:[(0,L.jsx)(`span`,{className:`mono text-fg-muted`,children:`Shift`}),`+`,(0,L.jsx)(`span`,{className:`mono text-fg-muted`,children:`Enter`}),` for a new line —`,` `,(0,L.jsx)(`span`,{className:`mono text-fg-muted`,children:`Option`}),`+`,(0,L.jsx)(`span`,{className:`mono text-fg-muted`,children:`Enter`}),` and`,` `,(0,L.jsx)(`span`,{className:`mono text-fg-muted`,children:`Ctrl`}),`+`,(0,L.jsx)(`span`,{className:`mono text-fg-muted`,children:`J`}),` do the same.`]})]}):(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-3 px-4 py-10 text-center`,children:[(0,L.jsx)(`p`,{className:`text-[14px] text-fg`,children:`You started this session yourself, so it has no terminal here.`}),(0,L.jsx)(`button`,{onClick:()=>i(!0),className:`rounded-sm bg-accent px-3.5 py-2 text-[13px] font-medium text-bg hover:brightness-110`,children:`Start a session here →`}),(0,L.jsxs)(`p`,{className:`max-w-[52ch] text-[12px] leading-relaxed text-fg-faint`,children:[`Opens a second `,(0,L.jsx)(`span`,{className:`mono`,children:`claude`}),` in`,` `,n?(0,L.jsx)(`span`,{className:`mono text-fg-muted`,children:n}):`this repository`,`, with a terminal you can type in. This one keeps running.`]}),r&&(0,L.jsx)(Wr,{available:!0,onClose:()=>i(!1),initialCwd:n??``})]})}function pg({sessionID:e,cwd:t,live:n}){let[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(``),u=`claude --resume ${e}`;async function d(){i(!0),c(``);try{v({name:`session`,id:(await P.spawn({cwd:t,resume:e,fork:n})).session_id,tab:`terminal`})}catch(e){c(e instanceof ie?e.message:String(e))}finally{i(!1)}}async function f(){try{await navigator.clipboard.writeText(u),o(!0),window.setTimeout(()=>o(!1),2e3)}catch{c(`Could not reach the clipboard. Select the command and copy it.`)}}return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(`button`,{onClick:d,disabled:r,title:n?`Open a branch of this conversation here — the original keeps running`:`Carry this conversation on, here`,className:`text-[11px] border border-accent text-accent px-1.5 rounded-sm hover:bg-accent/10 disabled:opacity-50`,children:r?`opening…`:n?`branch here`:`continue here`}),(0,L.jsx)(`button`,{onClick:f,title:u,className:`text-[11px] text-fg-faint hover:text-fg`,children:a?`copied`:`copy command`}),s&&(0,L.jsx)(`span`,{className:`text-[11px] text-danger`,children:s})]})}function mg(e){return e.agent===`gemini`?`telemetry`:[e.has_hooks?`hooks`:`no hooks`,e.has_transcript?`transcript`:`no transcript`].join(` · `)}function hg({id:e,tab:t,at:n}){let r=I(()=>P.session(e),[e],{intervalMs:5e3}),i=t===`changes`||t===`diff`||t===`files`?`changes`:t===`terminal`||t===`notes`?t:`timeline`,a=re(1e3),[o]=De(),s=r.data;if(r.error&&!s)return(0,L.jsx)(Dt,{title:r.error instanceof ie&&r.error.status===404?`Session not found`:`Cannot load session`,children:r.error.message});if(!s)return(0,L.jsx)(`div`,{className:`text-fg-muted px-1`,children:`loading…`});let c=t=>v({name:`session`,id:e,tab:t}),l=s.stats.tokens_in+s.stats.tokens_out+s.stats.cache_read+s.stats.cache_write,u=!s.has_hooks&&!s.has_transcript&&l===0&&s.stats.turns===0,d=u&&s.agent===`gemini`;return(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,L.jsx)(`a`,{href:g({name:`now`}),className:`link text-fg-muted text-[12px]`,children:`← Now`}),(0,L.jsx)(`h1`,{className:`text-[15px] font-medium`,children:s.project||`unknown project`}),(0,L.jsx)(`span`,{className:`mono text-[11px] text-fg-faint`,children:s.session_id}),s.git_branch&&(0,L.jsx)(`span`,{className:`mono text-[11px] text-fg-muted`,children:s.git_branch}),(0,L.jsx)(Tt,{health:s.activity.health}),s.owned&&s.status!==`ended`&&(0,L.jsx)(wg,{id:e}),!s.owned&&(s.agent??`claude`)===`claude`&&(0,L.jsx)(pg,{sessionID:s.session_id,cwd:s.cwd,live:s.status!==`ended`}),(0,L.jsx)(`span`,{className:`text-[12px] text-fg-muted ml-auto num`,children:s.cwd})]}),(0,L.jsxs)(`div`,{className:`text-[13px]`,children:[(0,L.jsx)(`span`,{className:`text-fg`,children:s.activity.phrase}),(0,L.jsx)(`span`,{className:`text-fg-faint num text-[11px] ml-2`,children:E(s.activity.at||s.last_event_at,a)}),s.loop&&(0,L.jsxs)(`span`,{className:`ml-3 text-danger text-[12px]`,children:[`loop: `,s.loop.sample,` ×`,s.loop.count,` in `,s.loop.window_min,`m`]})]}),u?(0,L.jsx)(R,{children:(0,L.jsx)(`div`,{className:`px-3 py-2.5 text-[13px] text-fg-muted`,children:d?(0,L.jsxs)(L.Fragment,{children:[`Nothing measured yet — Gemini reports its own figures, and the first ones arrive with its first answer.`,` `,(0,L.jsx)(`span`,{className:`text-fg-faint`,children:`The terminal below is live.`})]}):(0,L.jsxs)(L.Fragment,{children:[`Caprock started this `,Wt(s.agent),` session but does not measure it — there are no hooks and no transcript to read, so cost, tokens and turns are not counted here.`,` `,(0,L.jsx)(`span`,{className:`text-fg-faint`,children:`The terminal below is live.`})]})})}):(0,L.jsx)(R,{children:(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 divide-x divide-border`,children:[(0,L.jsx)(z,{label:`Cost`,value:S(s.stats.cost_usd),sub:(0,L.jsx)(`span`,{title:vn(o),children:s.model||`unknown model`})}),(0,L.jsx)(z,{label:`Tokens`,value:C(l),sub:`in ${C(s.stats.tokens_in)} · out ${C(s.stats.tokens_out)} · cache ${C(s.stats.cache_read+s.stats.cache_write)}`}),(0,L.jsx)(z,{label:`Cache`,value:T(s.savings.hit_rate*100),sub:`read ${C(s.stats.cache_read)} · write ${C(s.stats.cache_write)}`,tone:s.savings.hit_rate>.5?`ok`:void 0}),(0,L.jsx)(z,{label:`Context`,value:s.context?T(s.context.pct):`—`,sub:s.context?`${C(s.context.tokens)} / ${C(s.context.window)}`:`unknown model`,tone:s.context&&s.context.pct>=85?`danger`:s.context&&s.context.pct>=60?`warn`:void 0}),(0,L.jsx)(z,{label:`Turns`,value:s.stats.turns,sub:`${s.stats.tool_calls} tool calls`}),(0,L.jsx)(z,{label:`Files`,value:s.stats.files_touched,sub:mg(s)})]})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border`,children:[[`timeline`,`notes`,`changes`,`terminal`].map(e=>(0,L.jsx)(`button`,{onClick:()=>c(e),className:`px-3 py-1.5 text-[12px] border-b-2 -mb-px ${i===e?`border-accent text-fg`:`border-transparent text-fg-muted hover:text-fg`}`,children:e===`timeline`?`Timeline`:e===`notes`?`Answers`:e===`changes`?`Changes`:`Terminal`},e)),!s.owned&&(0,L.jsx)(`span`,{className:`ml-auto text-[11px] text-fg-faint pr-1`,children:`observe-only — terminal is read/write for spawned sessions only`})]}),i===`timeline`&&(0,L.jsx)(_g,{id:e,initial:s.events,now:a,at:n}),i===`notes`&&(0,L.jsx)(ei,{id:e,now:a}),i===`changes`&&(0,L.jsx)(xg,{id:e,s}),i===`terminal`&&(0,L.jsx)(R,{className:`overflow-hidden`,children:(0,L.jsx)(fg,{sessionId:e,owned:s.owned&&s.status!==`ended`,cwd:s.cwd})})]})}var gg=200;function _g({id:e,initial:t,now:n,at:r}){let[i,a]=(0,l.useState)(t),[o,s]=(0,l.useState)(`all`),c=(0,l.useRef)(t.length?t[t.length-1].id:0),u=(0,l.useRef)(null),[f,p]=(0,l.useState)(!1),[m,h]=(0,l.useState)(!1),g=async()=>{let t=i[0]?.id;if(!(t===void 0||f)){p(!0);try{let n=await P.eventsBefore(e,t,gg);n.length===0?h(!0):a(e=>[...n,...e])}catch{h(!0)}finally{p(!1)}}};(0,l.useEffect)(()=>{a(t),h(!1),c.current=t.length?t[t.length-1].id:0},[t]),(0,l.useEffect)(()=>d.onFrame(t=>{t.type!==`event`||t.data.session_id!==e||t.data.id<=c.current||(c.current=t.data.id,a(e=>[...e,t.data].slice(-5e3)))}),[e]);let _=(0,l.useMemo)(()=>{let e=0;return i.filter(e=>e.kind===`turn.assistant`).map(t=>e+=t.cost_usd??0)},[i]),v=(0,l.useMemo)(()=>{let e=new Map;for(let t of i)if(t.kind===`tool.pre`&&t.tool){let n=t.payload;n?.tool_use_id&&e.set(n.tool_use_id,t.tool)}return e},[i]),y=i.filter(e=>o===`all`||(o===`tools`?e.kind.startsWith(`tool.`):e.kind.startsWith(`turn.`)||e.kind===`agent.stop`)).slice().reverse();return(0,L.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_260px]`,children:[(0,L.jsx)(R,{title:`Events · ${i.length} shown`,className:`min-w-0 overflow-hidden`,right:(0,L.jsx)(`span`,{className:`inline-flex items-center gap-2`,children:[`all`,`tools`,`turns`].map(e=>(0,L.jsx)(`button`,{onClick:()=>s(e),className:`px-1.5 rounded-sm ${o===e?`bg-panel-2 text-fg`:`hover:text-fg`}`,children:e},e))}),children:(0,L.jsxs)(`ol`,{ref:u,className:`max-h-[70vh] overflow-auto`,children:[y.length===0&&(0,L.jsx)(Dt,{title:`No events yet`}),y.map(e=>(0,L.jsx)(yg,{e,now:n,toolByUse:v,inMinute:r!==void 0&&vg(e.ts,r)},e.id)),!m&&i.length>0&&(0,L.jsx)(`li`,{className:`px-3 py-1.5 border-t border-border/60`,children:(0,L.jsx)(`button`,{className:`text-[11px] text-fg-muted hover:text-fg border border-border px-2 py-0.5 rounded-sm`,onClick:()=>void g(),disabled:f,children:f?`loading…`:`load earlier events`})}),m&&(0,L.jsx)(`li`,{className:`px-3 py-1 text-[11px] text-fg-faint`,children:`start of session`})]})}),(0,L.jsxs)(`div`,{className:`grid gap-3 content-start`,children:[(0,L.jsxs)(R,{title:`Cost, cumulative`,children:[(0,L.jsx)(`div`,{className:`px-3 py-2`,children:(0,L.jsx)(Et,{values:_.length?_:[0,0],width:230,height:40,tone:`accent`})}),(0,L.jsxs)(`div`,{className:`px-3 pb-2 text-[11px] text-fg-muted num`,children:[_.length,` priced turns · `,S(_[_.length-1]??0)]})]}),(0,L.jsxs)(R,{title:`Tokens per turn`,children:[(0,L.jsx)(`div`,{className:`px-3 py-2`,children:(0,L.jsx)(Et,{values:i.filter(e=>e.tokens).map(e=>e.tokens.in+e.tokens.cache_read+e.tokens.cache_write),width:230,height:40})}),(0,L.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-fg-muted`,children:`prompt size (input + cache) per assistant turn`})]})]})]})}function vg(e,t){let n=Date.parse(e);return Number.isFinite(n)&&Math.floor(n/6e4)===Math.floor(t/6e4)}function yg({e,now:t,toolByUse:n,inMinute:r}){let[i,a]=(0,l.useState)(!1),o=(0,l.useRef)(null);(0,l.useEffect)(()=>{r&&o.current?.scrollIntoView({block:`center`})},[r]);let s=e.payload??{},c=e.tool||(e.kind===`tool.post`?n.get(String(s.tool_use_id??``)):void 0),u=bg({...e,tool:c},s),d=e.kind===`turn.assistant`?String(s.text??``):e.kind===`turn.user`?String(s.prompt??``):e.kind===`tool.post`&&typeof s.tool_response==`string`?s.tool_response:``,f=e.kind===`turn.user`?`text-info`:e.kind===`turn.assistant`?`text-fg`:e.kind===`agent.stop`||e.kind===`context.compact`?`text-warn`:`text-fg-muted`;return(0,L.jsxs)(`li`,{ref:o,className:`border-b border-border/60 last:border-0 hover:bg-panel-2 animate-flash ${r?`bg-accent/10 border-l-2 border-l-accent`:``}`,children:[(0,L.jsxs)(`button`,{className:`w-full text-left flex items-baseline gap-2 px-3 py-[3px]`,onClick:()=>a(!i),children:[(0,L.jsx)(`span`,{className:`num text-[10px] text-fg-faint w-14 shrink-0`,children:E(e.ts,t)}),(0,L.jsx)(`span`,{className:`mono text-[10px] w-24 shrink-0 ${f}`,children:e.kind}),(0,L.jsx)(`span`,{className:`truncate text-[12px] min-w-0`,title:u,children:u}),e.tokens&&(0,L.jsxs)(`span`,{className:`ml-auto num text-[10px] text-fg-faint shrink-0`,children:[C(e.tokens.in+e.tokens.cache_read+e.tokens.cache_write),`→`,C(e.tokens.out),e.cost_usd===void 0?``:` · ${S(e.cost_usd)}`]})]}),i&&(0,L.jsxs)(`div`,{className:`px-3 pb-2`,children:[d?(0,L.jsx)(`div`,{className:`text-[12px] leading-[1.55] whitespace-pre-wrap break-words max-h-96 overflow-auto border-l-2 border-border-strong pl-3 mb-2`,children:d}):null,(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{className:`text-[10px] text-fg-faint cursor-pointer select-none`,children:`raw event`}),(0,L.jsx)(`pre`,{className:`mono text-[10px] leading-[1.4] text-fg-muted pt-1 max-h-64 overflow-auto whitespace-pre-wrap break-all`,children:JSON.stringify({id:e.id,ts:e.ts,source:e.source,key:e.key,agent_id:e.agent_id,model:e.model,tokens:e.tokens,cost_usd:e.cost_usd,payload:e.payload},null,2)})]})]})]})}function bg(e,t){let n=t.tool_input??{};switch(e.kind){case`tool.pre`:{let r=e.tool??String(t.tool_name??`tool`),i=n.command??n.file_path??n.pattern??n.query??n.url??n.prompt??``;return i?`${r} ${String(i).split(` +`)[0]}`:r}case`tool.post`:{let n=e.tool??String(t.tool_name??`tool`),r=t.tool_response,i=t.is_error===!0,a=typeof r==`string`?r:r?JSON.stringify(r):``;return`${n} ${i?`failed`:`done`}${a?` ${a.slice(0,160)}`:``}`}case`turn.user`:return`you: ${String(t.prompt??``).slice(0,200)}`;case`turn.assistant`:{let n=String(t.text??``),r=Array.isArray(t.tools)?t.tools:[];return n?n.slice(0,200):r.length?`→ ${r.join(`, `)}`:`${e.model??`assistant`} turn`}case`agent.stop`:return e.agent_id?`subagent ${e.agent_id} stopped`:`turn ended (${String(t.stop_reason??`stop`)})`;case`agent.spawn`:return`session started (${String(t.source??`startup`)})`;case`context.compact`:return`context compaction (${String(t.trigger??`auto`)})`;default:return e.kind}}function xg({id:e,s:t}){let n=I(()=>P.diff(e),[e,t.last_event_at],{live:!1,intervalMs:8e3}),[r,i]=(0,l.useState)(new Set),a=e=>i(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});if(n.error&&!n.data){let e=n.error;if(e instanceof ie&&e.status===409){let n=e.body;return(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(Dt,{title:`No git repository`,children:[n?.cwd?(0,L.jsx)(`span`,{className:`mono`,children:n.cwd}):null,` `,n?.error]}),(0,L.jsx)(Cg,{s:t})]})}return(0,L.jsx)(Dt,{title:`Cannot load diff`,children:e.message})}let o=n.data;if(!o)return(0,L.jsx)(`div`,{className:`text-fg-muted px-1`,children:`loading…`});let s=new Set(o.files.map(e=>e.path)),c=t.files.filter(e=>!s.has(e)&&!s.has(e.replace(/^.*?\//,``))),u=o.files.length>0&&o.files.every(e=>r.has(e.path));return(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(R,{title:`Changes · ${o.branch||`detached`}`,right:(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o.base&&(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:o.base}),o.files.length>0&&(0,L.jsx)(`button`,{className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-0.5 rounded-sm`,onClick:()=>i(u?new Set:new Set(o.files.map(e=>e.path))),children:u?`collapse all`:`expand all`}),(0,L.jsxs)(`span`,{className:`num`,children:[o.files.length,` files`]})]}),children:[o.files.length===0&&(0,L.jsx)(Dt,{title:`Clean working tree`}),(0,L.jsx)(`ul`,{children:o.files.map(e=>{let t=r.has(e.path);return(0,L.jsxs)(`li`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsxs)(`button`,{className:`w-full text-left px-3 py-1.5 flex items-center gap-3 hover:bg-panel-2`,onClick:()=>a(e.path),"aria-expanded":t,children:[(0,L.jsx)(`span`,{className:`text-fg-faint text-[10px] shrink-0 transition-transform ${t?`rotate-90`:``}`,children:`▶`}),(0,L.jsx)(`span`,{className:`mono text-[10px] w-16 shrink-0 ${e.status===`added`||e.status===`untracked`?`text-ok`:e.status===`deleted`?`text-danger`:`text-fg-muted`}`,children:e.status}),(0,L.jsx)(`span`,{className:`mono text-[12px] truncate`,children:e.path}),(0,L.jsxs)(`span`,{className:`ml-auto num text-[11px] shrink-0`,children:[(0,L.jsxs)(`span`,{className:`text-ok`,children:[`+`,e.additions]}),` `,(0,L.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),t&&e.patch&&(0,L.jsx)(Sg,{patch:e.patch}),t&&!e.patch&&(0,L.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-fg-faint`,children:e.binary?`binary file`:`no patch`})]},e.path)})})]}),c.length>0&&(0,L.jsx)(Cg,{s:t,only:c})]})}function Sg({patch:e}){return(0,L.jsx)(`pre`,{className:`mono text-[11px] leading-[1.35] px-3 pb-2 overflow-auto max-h-[50vh]`,children:e.split(` +`).map((e,t)=>{let n=e.startsWith(`+`)&&!e.startsWith(`+++`)?`text-ok`:e.startsWith(`-`)&&!e.startsWith(`---`)?`text-danger`:e.startsWith(`@@`)?`text-info`:`text-fg-muted`;return(0,L.jsx)(`div`,{className:n,children:e||` `},t)})})}function Cg({s:e,only:t}){let n=t??e.files,r=e.files.length(0,L.jsxs)(`li`,{className:`px-3 py-1 border-b border-border/60 last:border-0 flex gap-2 items-baseline`,children:[(0,L.jsx)(`span`,{className:`mono text-[12px]`,children:O(e)}),(0,L.jsx)(`span`,{className:`mono text-[10px] text-fg-faint truncate`,children:e})]},e))})]})}function wg({id:e}){let[t,n]=(0,l.useState)(``),r=async t=>{n(t);try{await P.signal(e,t)}catch{}finally{n(``)}};return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-ok border border-ok/40 rounded-sm px-1`,children:`owned`}),(0,L.jsx)(`button`,{disabled:!!t,onClick:()=>r(`pause`),className:`text-[11px] border border-border px-1.5 rounded-sm text-fg-muted hover:text-fg`,children:`pause`}),(0,L.jsx)(`button`,{disabled:!!t,onClick:()=>r(`resume`),className:`text-[11px] border border-border px-1.5 rounded-sm text-fg-muted hover:text-fg`,children:`resume`}),(0,L.jsx)(`button`,{disabled:!!t,onClick:()=>r(`kill`),className:`text-[11px] border border-danger/40 text-danger px-1.5 rounded-sm hover:bg-danger/10`,children:`kill`})]})}function Tg(e){if(!Number.isFinite(e)||e<=0)return[];let t=e/3,n=10**Math.floor(Math.log10(t)),r=[1,2,5,10].map(e=>e*n).find(e=>e>=t)??n*10,i=[];for(let t=r;t<=e*1.0001;t+=r)i.push(t);return i}function Eg({bars:e,active:t,onActive:n,height:r=112,showDayLabels:i=!0}){let a=e=>typeof e==`number`&&Number.isFinite(e)?e:0,o=Math.max(...e.map(e=>a(e.cost)),1e-9),s=r-16,c=Tg(o);return(0,L.jsxs)(`div`,{className:`relative px-3 py-3 flex items-end gap-[3px]`,style:{height:r},onMouseLeave:()=>n(null),children:[c.map(e=>(0,L.jsx)(`div`,{className:`pointer-events-none absolute left-3 right-3 border-t border-border/60`,style:{bottom:16+Math.round(s*e/o)},"aria-hidden":!0,children:(0,L.jsx)(`span`,{className:`num absolute -top-[7px] right-0 bg-panel pl-1 text-[9px] text-fg-faint`,children:S(e)})},e)),e.map(e=>{let r=t===e.day;return(0,L.jsxs)(`button`,{type:`button`,className:`flex-1 flex flex-col items-center justify-end gap-1 min-w-0 h-full cursor-default focus:outline-none`,onMouseEnter:()=>n(e.day),onFocus:()=>n(e.day),onBlur:()=>n(null),"aria-label":`${e.day}: ${S(a(e.cost))}`,children:[(0,L.jsx)(`div`,{className:`w-full rounded-t-sm transition-colors ${r?`bg-accent`:`bg-accent/70`}`,style:{height:Math.max(2,Math.round(s*a(e.cost)/o))}}),i&&(0,L.jsx)(`div`,{className:`num text-[9px] ${r?`text-fg`:`text-fg-faint`}`,children:e.day.slice(8)})]},e.day)})]})}function Dg({bars:e,active:t,total:n}){let r=t?e.find(e=>e.day===t):void 0;return r?(0,L.jsxs)(`span`,{className:`num flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:r.day}),(0,L.jsx)(`span`,{className:`text-fg`,children:S(r.cost)}),(0,L.jsx)(`span`,{className:`text-fg-faint`,children:C(r.tokens)}),r.sessions!==void 0&&r.sessions>0&&(0,L.jsxs)(`span`,{className:`text-fg-faint`,children:[r.sessions,` `,r.sessions===1?`session`:`sessions`]})]}):(0,L.jsx)(`span`,{className:`num`,children:S(n)})}var Og=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function kg(e){return(new Date(`${e}T00:00:00Z`).getUTCDay()+6)%7}function Ag(e,t){if(!(e>0))return`bg-border/60`;let n=Math.sqrt(e/Math.max(t,1e-9));return n>.75?`bg-accent`:n>.5?`bg-accent/75`:n>.25?`bg-accent/50`:`bg-accent/25`}function jg({bars:e,active:t,onActive:n,maxCell:r=44}){let i=e=>typeof e==`number`&&Number.isFinite(e)?e:0,a=Math.max(...e.map(e=>i(e.cost)),1e-9),o=e[0],s=o?kg(o.day):0;return(0,L.jsxs)(`div`,{className:`px-3 py-3`,onMouseLeave:()=>n(null),children:[(0,L.jsxs)(`div`,{className:`grid gap-1`,style:{gridTemplateColumns:`repeat(7, minmax(0, 1fr))`,maxWidth:r*7+24},children:[Og.map((e,t)=>(0,L.jsx)(`div`,{className:`text-center text-[9px] text-fg-faint`,"aria-hidden":!0,children:e},t)),Array.from({length:s},(e,t)=>(0,L.jsx)(`div`,{"aria-hidden":!0},`lead-${t}`)),e.map(e=>{let r=i(e.cost),o=t===e.day;return(0,L.jsx)(`button`,{type:`button`,className:`flex aspect-square items-center justify-center focus:outline-none cursor-default`,onMouseEnter:()=>n(e.day),onFocus:()=>n(e.day),onBlur:()=>n(null),"aria-label":`${e.day}: ${S(r)}`,children:(0,L.jsx)(`span`,{className:`h-full w-full rounded-[3px] transition-colors ${Ag(r,a)} ${o?`ring-1 ring-accent ring-offset-1 ring-offset-panel`:``}`})},e.day)})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-[9px] text-fg-faint`,children:[(0,L.jsx)(`span`,{children:`$0`}),[`bg-border/60`,`bg-accent/25`,`bg-accent/50`,`bg-accent/75`,`bg-accent`].map(e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-[2px] ${e}`,"aria-hidden":!0},e)),(0,L.jsx)(`span`,{className:`num`,children:S(a)})]})]})}var Mg=e=>e===1?`day`:`days`;function Ng({summary:e,plan:t,days:n}){if(!e)return null;let r=e.cost_usd;if(!t?.plan_kind)return(0,L.jsx)(R,{title:`Plan value`,children:(0,L.jsx)(`div`,{className:`px-3 py-3 text-[12px] text-fg-muted`,children:`Set your plan in the header and Caprock will show what this usage is worth against what you actually pay. It can't detect your plan, so it won't guess.`})});if(t.plan_kind===`metered`)return(0,L.jsx)(R,{title:`Spend`,right:(0,L.jsxs)(`span`,{className:`num text-[12px] text-fg-muted`,children:[t.plan_label||`API`,` · billed per token`]}),children:(0,L.jsxs)(`div`,{className:`px-3 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`num text-3xl text-fg`,children:S(r)}),(0,L.jsxs)(`span`,{className:`text-[12px] text-fg-muted`,children:[`over the last `,n,` `,Mg(n)]})]}),(0,L.jsxs)(`p`,{className:`text-[11px] text-fg-faint mt-2 max-w-[60ch]`,children:[`You are billed per token, so this is approximately your actual cost — at Anthropic list prices (`,e.pricing_version,`). Not a saving.`]})]})});let i=t.plan_usd_per_month*n/30,a=i>0?r/i:0;return(0,L.jsxs)(R,{title:`Plan value`,right:(0,L.jsxs)(`span`,{className:`num text-[12px] text-fg-muted`,children:[t.plan_label,` · `,S(t.plan_usd_per_month),`/mo`]}),children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 divide-y sm:divide-y-0 sm:divide-x divide-border`,children:[(0,L.jsx)(z,{label:`you pay · ${n}d`,value:S(i),sub:t.plan_label}),(0,L.jsx)(z,{label:`same usage at API list`,value:S(r),sub:`at list prices ${e.pricing_version}`,tone:`ok`}),(0,L.jsx)(z,{label:`which is`,value:a>0?`${a.toFixed(1)}×`:`—`,sub:a>0?`what ${n} ${Mg(n)} would cost through the API`:`not enough measured usage yet`,tone:a>0?`ok`:void 0,size:`hero`})]}),(0,L.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-[11px] text-fg-faint leading-relaxed`,children:`Not a discount you received, and not money back — without the plan you would not have run this much.`})]})}function Pg({feature:e,title:t,children:n}){let[r,i]=(0,l.useState)(!1);return I(()=>P.premium(),[]).data?.license?.active?(0,L.jsx)(L.Fragment,{children:n}):(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--radius-panel)] border border-border`,children:[(0,L.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none select-none opacity-70`,children:n}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-3 gap-y-2 border-t border-border bg-panel-2/60 px-4 py-2.5 text-center`,children:[(0,L.jsx)(`span`,{className:`text-[13px] font-medium text-fg`,children:t}),(0,L.jsx)(`button`,{onClick:()=>i(!0),className:`rounded-sm bg-premium px-3.5 py-1.5 text-[13px] font-medium text-white hover:brightness-110`,children:`Unlock with Premium`})]}),r&&(0,L.jsx)(rt,{feature:e,onClose:()=>i(!1)})]})}function Fg({suggestion:e}){let t=I(()=>P.settings(),[],{live:!1}),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)(!1),p=t.data?.cap_usd_per_day;(0,l.useEffect)(()=>{d||p===void 0||(r(p?String(p):``),f(!0))},[p,d]);let m=t.data?.cap_usd_per_day??0,h=m>0,g=async e=>{a(!0),s(``),u(!1);try{await P.saveSettings({cap_usd_per_day:e}),r(e?String(e):``),u(!0),t.refresh()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},_=()=>{let e=n.trim().replace(/^\$/,``).replace(/,/g,``),t=Number(e);if(e===``||!Number.isFinite(t)||t<0){s(`A daily cap has to be a positive number of dollars.`);return}g(t)};return(0,L.jsx)(R,{title:`Daily spend cap`,right:(0,L.jsx)(`span`,{className:h?`text-premium-strong`:`text-fg-faint`,children:h?`on`:`off`}),children:(0,L.jsxs)(`div`,{className:`grid gap-2.5 px-3 py-3 text-[13px]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:`Stop the day at`}),(0,L.jsx)(`span`,{className:`text-fg-muted`,children:`$`}),(0,L.jsx)(`input`,{className:`input w-28`,inputMode:`decimal`,placeholder:`0`,value:n,onChange:e=>{r(e.target.value),u(!1)},onKeyDown:e=>e.key===`Enter`&&_(),"aria-label":`Daily spend cap in dollars`}),(0,L.jsx)(`button`,{onClick:_,disabled:i,className:`rounded-sm bg-premium px-3 py-1 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50`,children:i?`Saving…`:`Save`}),h&&(0,L.jsx)(`button`,{onClick:()=>void g(0),disabled:i,className:`text-[12px] text-fg-faint hover:text-fg`,children:`turn off`}),c&&!o&&(0,L.jsx)(`span`,{className:`text-[12px] text-fg-faint`,children:`saved`})]}),!h&&e?(0,L.jsxs)(`p`,{className:`text-[12px] text-fg-faint`,children:[`Your days run about `,S(e/2),`.`,` `,(0,L.jsxs)(`button`,{onClick:()=>void g(e),className:`text-premium-strong hover:underline`,children:[`Use `,S(e)]}),` `,`— twice that, so an ordinary day never trips it.`]}):null,o&&(0,L.jsx)(`p`,{className:`text-[12px] text-danger`,children:o}),(0,L.jsx)(`p`,{className:`border-t border-border pt-2 text-[12px] leading-relaxed text-fg-faint`,children:h?(0,L.jsxs)(L.Fragment,{children:[`When today crosses `,S(m),`, Caprock pauses the sessions it started — paused, not killed, so resuming keeps the conversation. Sessions you started yourself are never touched.`]}):(0,L.jsx)(L.Fragment,{children:`Off. Nothing is paused, whatever the day costs. Sessions you started yourself are never touched either way.`})})]})})}function Ig(e){return e>=.01?`$${e.toFixed(2)}`:`${(e*100).toFixed(1)}\u00A2`}function Lg(){let e=I(()=>P.gemini(),[],{live:!1}),[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(!1),[g,_]=(0,l.useState)(``),v=e.data,y=!!v?.available,b=v!==void 0&&!v.available,x=async()=>{let t=r.trim();if(!(!t||a)){o(!0),c(``);try{await P.saveSettings({gemini_api_key:t}),i(``),e.refresh?.()}catch(e){c(ae(e))}finally{o(!1)}}},S=async()=>{let e=t.trim();if(!(!e||m)){h(!0),_(``);try{p(await P.askGemini(e,u||void 0)),n(``)}catch(e){_(ae(e))}finally{h(!1)}}};return(0,L.jsx)(R,{title:`Ask Gemini`,right:(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:y?v?.model:`your key, your bill`}),children:b?(0,L.jsxs)(`div`,{className:`px-3 py-3 text-[12px] text-fg-muted grid gap-2.5`,children:[(0,L.jsxs)(`p`,{className:`m-0`,children:[`Ask Google's Gemini about your own sessions, on your own key. Get one from`,` `,(0,L.jsx)(`a`,{className:`link`,href:`https://aistudio.google.com/apikey`,target:`_blank`,rel:`noreferrer`,children:`Google AI Studio`}),` `,`and paste it here — you pay Google directly, and Caprock counts what it spends beside your Claude figures.`]}),(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:`API key`}),(0,L.jsx)(`input`,{className:`input`,type:`password`,placeholder:`AIza…`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&x()}})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`button`,{onClick:()=>void x(),disabled:a||!r.trim(),className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:a?`saving…`:`Save key`}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`Stored on this machine only, and never sent back to this page.`})]}),s&&(0,L.jsx)(`div`,{className:`text-danger text-[11px]`,children:s})]}):(0,L.jsxs)(`div`,{className:`px-3 py-3 grid gap-2`,children:[(0,L.jsx)(`textarea`,{className:`input min-h-[70px] resize-y`,placeholder:`Ask about your sessions, your spend, anything…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&S()}}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,L.jsx)(`button`,{onClick:()=>void S(),disabled:m||!t.trim(),className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm text-[12px] hover:bg-accent/25 disabled:opacity-50`,children:m?`asking…`:`Ask`}),(v?.models?.length??0)>0&&(0,L.jsx)(`select`,{className:`input w-auto text-[12px] py-1`,value:u||v?.model||``,onChange:e=>d(e.target.value),"aria-label":`Model`,children:v.models.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.display,` · ~`,Ig(e.typical_usd),` a question`]},e.id))}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`⌘↵ to send`})]}),g&&(0,L.jsx)(`div`,{className:`text-danger text-[12px]`,children:g}),(0,L.jsx)(`p`,{className:`m-0 text-[11px] text-fg-faint`,children:v?.from_env?(0,L.jsxs)(L.Fragment,{children:[`Using the key in `,(0,L.jsx)(`span`,{className:`mono`,children:v?.env_var}),`, which takes precedence over the stored one.`]}):(0,L.jsx)(L.Fragment,{children:`Using the key you saved here. Google bills you directly.`})}),f&&(0,L.jsxs)(`div`,{className:`grid gap-2 border-t border-border pt-2`,children:[(0,L.jsx)(`div`,{className:`text-[13px] whitespace-pre-wrap`,children:f.text}),(0,L.jsxs)(`div`,{className:`text-[11px] text-fg-faint num flex gap-3 flex-wrap`,children:[(0,L.jsx)(`span`,{children:f.model}),(0,L.jsxs)(`span`,{children:[`in `,C(f.usage.prompt_tokens)]}),(0,L.jsxs)(`span`,{children:[`out `,C(f.usage.output_tokens)]}),f.usage.thoughts_tokens>0&&(0,L.jsxs)(`span`,{title:`Google bills thinking tokens as output`,children:[`thinking `,C(f.usage.thoughts_tokens)]}),f.usage.cached_tokens>0&&(0,L.jsxs)(`span`,{children:[`cached `,C(f.usage.cached_tokens)]})]})]})]})})}function Rg(){let[e,t]=(0,l.useState)(`30d`),n=Date.now(),r=I(()=>P.summary(e),[e],{intervalMs:5e3}),i=I(()=>P.daily(30),[],{intervalMs:3e4}),[a]=De(),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(`calendar`),d=r.data,f=!!d&&d.turns>0,p=zg(i.data??[]),m=Vg(p.map(e=>e.cost));return(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[[`today`,`7d`,`30d`,`all`].map(n=>(0,L.jsx)(`button`,{onClick:()=>t(n),className:`px-2 py-1 text-[12px] rounded-sm ${e===n?`bg-panel-2 text-fg`:`text-fg-muted hover:text-fg`}`,children:n},n)),(0,L.jsxs)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,children:[vn(a),d?` (table ${d.pricing_version})`:``]})]}),r.error&&!d&&(0,L.jsx)(Dt,{title:`Cannot reach the daemon`,children:r.error.message}),e!==`today`&&d&&(0,L.jsx)(Pn,{costUSD:p.reduce((e,t)=>e+t.cost,0),days:p.filter(e=>e.cost>0).length,now:n}),(0,L.jsx)(Ng,{summary:d,plan:a,days:Bg(e,d?.from_ms)}),(0,L.jsxs)(R,{title:`Totals · ${e}`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 divide-x divide-border`,children:[(0,L.jsx)(z,{label:`Cost`,value:f?S(d.cost_usd):`—`,sub:(0,L.jsx)(`span`,{title:vn(a),children:f?_n(a):`nothing measured in this range`}),tone:`info`,size:`hero`}),(0,L.jsx)(z,{label:`Burn now`,value:f?`${S(d.burn.usd_per_hour)}/h`:`—`,sub:f?`${C(Math.round(d.burn.tokens_per_min))} tok/min · ${d.sessions} sessions`:void 0}),(0,L.jsx)(z,{label:`Input`,value:f?C(d.tokens_in):`—`,sub:`fresh, full price`}),(0,L.jsx)(z,{label:`Output`,value:f?C(d.tokens_out):`—`,sub:f?`${d.turns} turns`:void 0}),(0,L.jsx)(z,{label:`Cache read`,value:f?C(d.cache_read):`—`,sub:f?(0,L.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,L.jsxs)(`span`,{children:[T(d.savings.hit_rate*100),` hit rate`]}),(()=>{let e=Sn(d.savings.hit_rate*100);return e?(0,L.jsx)(`span`,{className:e.color||`text-fg-faint`,children:e.label}):null})()]}):void 0}),(0,L.jsx)(z,{label:`Cache write`,value:f?C(d.cache_write):`—`,sub:f?`${T(d.savings.cut_pct)} input cost cut by cache`:void 0})]}),(0,L.jsx)(Ar,{u:d?.unpriced,className:`mx-3 mb-2.5`})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:[(0,L.jsxs)(R,{title:`Model mix`,right:(0,L.jsx)(`span`,{children:`by cost`}),children:[d?d.models.length===0&&(0,L.jsx)(Dt,{title:`No priced turns in range`}):(0,L.jsx)(Ot,{rows:4}),(0,L.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-[0.08em] text-fg-faint`,children:[(0,L.jsx)(`th`,{className:`px-3 pb-1 text-left font-normal`,children:`model`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`turns`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`tokens`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`cost`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`share`})]})}),(0,L.jsx)(`tbody`,{children:(d?.models??[]).map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1 mono`,title:e.model||void 0,children:e.model?ne(e.model):`unknown`}),(0,L.jsxs)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:[e.turns,` turns`]}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:(d?.unpriced?.models??[]).includes(e.model)?(0,L.jsx)(`span`,{className:`text-warn`,title:`this model is not in the pricing table, so its cost is unknown`,children:`unpriced`}):S(e.cost_usd)}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-faint w-14`,children:d&&d.cost_usd>0&&!(d.unpriced?.models??[]).includes(e.model)?T(100*e.cost_usd/d.cost_usd):`—`})]},e.model))})]})]}),(0,L.jsx)(Mt,{summary:d}),(0,L.jsxs)(R,{title:`Per project`,right:(0,L.jsx)(`span`,{children:`by cost`}),children:[d?d.projects.length===0&&(0,L.jsx)(Dt,{title:`No priced turns in range`}):(0,L.jsx)(Ot,{rows:4}),(0,L.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-[0.08em] text-fg-faint`,children:[(0,L.jsx)(`th`,{className:`px-3 pb-1 text-left font-normal`,children:`project`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`tokens`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`cost`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`share`})]})}),(0,L.jsx)(`tbody`,{children:(d?.projects??[]).map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1`,children:e.project||`unknown`}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:S(e.cost_usd)}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-faint w-14`,children:d&&d.cost_usd>0?T(100*e.cost_usd/d.cost_usd):`—`})]},e.project))})]})]})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-3`,children:[(0,L.jsxs)(R,{className:`lg:col-span-2`,title:`Last 30 days`,right:(0,L.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(Dg,{bars:p,active:o,total:p.reduce((e,t)=>e+t.cost,0)}),(0,L.jsx)(`span`,{className:`flex items-center gap-1`,children:[`calendar`,`bars`].map(e=>(0,L.jsx)(`button`,{onClick:()=>u(e),className:`px-1.5 py-0.5 rounded-sm text-[11px] ${c===e?`bg-panel-2 text-fg`:`text-fg-faint hover:text-fg`}`,children:e},e))})]}),children:[i.data?p.length===0&&(0,L.jsx)(Dt,{title:`No history yet`}):(0,L.jsx)(Ot,{rows:2}),p.length>0&&(c===`calendar`?(0,L.jsx)(jg,{bars:p,active:o,onActive:s}):(0,L.jsx)(Eg,{bars:p,active:o,onActive:s}))]}),(0,L.jsx)(Pg,{feature:`cap`,title:`Stop the day at a number you choose`,children:(0,L.jsx)(Fg,{suggestion:m})}),(0,L.jsx)(Pg,{feature:`gemini`,title:`Ask a second model, on your own key`,children:(0,L.jsx)(Lg,{})}),d&&(0,L.jsxs)(R,{title:`Plan limits`,children:[d.rate_limits?(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 pt-1`,children:[d.rate_limits.five_hour&&(0,L.jsx)(Tn,{label:`5-hour window`,w:d.rate_limits.five_hour,now:n}),d.rate_limits.seven_day&&(0,L.jsx)(Tn,{label:`7-day window`,w:d.rate_limits.seven_day,now:n})]}):(0,L.jsxs)(`div`,{className:`px-3 pt-1 text-sm text-fg-muted`,children:[`Nothing yet. Run `,(0,L.jsx)(`span`,{className:`mono text-fg`,children:`caprock statusline`}),` in a Pro or Max session and your limits appear here. API billing has no windows.`]}),(0,L.jsx)(`div`,{className:`mt-2 px-3 pb-3 text-[11px] text-fg-faint leading-relaxed`,children:`From Claude Code's status line. A forecast appears only when your pace would hit the limit before the window resets.`})]})]}),(0,L.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:d&&d.throttles>0?`${d.throttles} rate-limit / overloaded event${d.throttles===1?``:`s`} observed in this range (from Claude Code's StopFailure hook).`:`No rate-limit events observed in this range.`})]})}function zg(e){let t=new Map;for(let n of e){let e=t.get(n.day)??{day:n.day,cost:0,tokens:0,sessions:0};e.cost+=n.cost_usd,e.tokens+=n.tokens_total,e.sessions+=n.sessions,t.set(n.day,e)}return[...t.values()].sort((e,t)=>e.day.localeCompare(t.day))}function Bg(e,t){switch(e){case`today`:return 1;case`7d`:return 7;case`30d`:return 30;default:return t?Math.max(1,Math.ceil((Date.now()-t)/864e5)):30}}function Vg(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length<3)return 0;let n=t[Math.floor(t.length/2)]*2,r=n<10?1:n<100?5:10;return Math.round(n/r)*r}function Hg({plan:e,save:t}){let[n,r]=(0,l.useState)(e.license_key??``),i=I(()=>P.premium(),[e.license_key]).data?.license;(0,l.useEffect)(()=>{r(e.license_key??``)},[e.license_key]);let a=n.trim()!==(e.license_key??``).trim();return(0,L.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`w-28 shrink-0 text-fg-muted`,children:`Licence`}),(0,L.jsx)(`input`,{className:`input flex-1 min-w-0`,placeholder:`CR-…`,spellCheck:!1,value:n,onChange:e=>r(e.target.value),onKeyDown:r=>{r.key===`Enter`&&a&&t({...e,license_key:n.trim()})}}),(0,L.jsx)(`button`,{disabled:!a,onClick:()=>t({...e,license_key:n.trim()}),className:`rounded-sm border border-border px-2 py-0.5 text-fg-muted hover:border-border-strong hover:text-fg disabled:opacity-40`,children:`save`})]}),(0,L.jsxs)(`p`,{className:`mt-1.5 pl-[7.5rem] text-[11px] leading-relaxed`,children:[i?.active&&!i.in_grace&&(0,L.jsxs)(`span`,{className:`text-ok`,children:[`Premium is on`,i.expires_at?` — renews ${i.expires_at.slice(0,10)}`:``,`.`]}),i?.active&&i.in_grace&&(0,L.jsxs)(`span`,{className:`text-warn`,children:[i.reason,`. Update your key or payment method.`]}),i&&!i.active&&(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[e.license_key?i.reason:`No key — the free product is unaffected.`,` `,(0,L.jsx)(`a`,{href:`https://caprock.dev/premium/`,target:`_blank`,rel:`noreferrer`,className:`link`,children:`what Premium does`})]}),(0,L.jsx)(`span`,{className:`block text-fg-faint`,children:`Checked on this machine against the date inside the key. Caprock makes no call to us to verify it.`})]})]})}function Ug(){let e=I(()=>P.status(),[],{live:!1,intervalMs:5e3}),t=e.data;if(e.error&&!t)return(0,L.jsx)(Dt,{title:`Cannot reach the daemon`,children:e.error.message});if(!t)return(0,L.jsx)(`div`,{className:`text-fg-muted`,children:`loading…`});let n=[[`version`,t.version],[`url`,t.url],[`pid`,String(t.pid)],[`uptime`,D(t.uptime_s*1e3)],[`data dir`,t.data_dir],[`pricing`,`${t.pricing.version} · ${t.pricing.models} models · fetched ${t.pricing.fetched_at}${t.pricing.user_override?` · user override`:``}`],[`pricing source`,t.pricing.source],[`loop rule`,`≥ ${t.loop_k} same-tool calls in ${t.loop_t_minutes} min · ${t.active_loops} active`],[`events stored`,`${t.events.toLocaleString()}${t.retention_days>0?` · pruned after ${t.retention_days}d`:` · kept forever (set retention_days to cap DB growth)`}`],[`orchestration`,t.orchestration?`on (--hive)`:`off`],[`claude`,t.claude_available?`found on PATH — Caprock can start sessions for you`:`not found on PATH — Caprock cannot start sessions, but still observes every session you start yourself`],[`dashboard`,t.ui_built?`embedded build`:`dev server / placeholder`]];if(t.hooks&&n.push([`hooks`,`${(t.hooks.installed??[]).length}/${(t.hooks.installed??[]).length+(t.hooks.missing??[]).length} events registered in ${t.hooks.settings_path}${t.hooks.shim_exists?``:` (shim missing)`}`]),t.desktop){let e=t.desktop;n.push([`claude desktop`,`${e.five_hour_pct}% of the 5-hour window · ${e.seven_day_pct}% of the 7-day${e.stale?` · last seen `+new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})+`, app closed since`:` · now`}`])}return t.ingest_error&&n.push([`ingest error`,`STOPPED: ${t.ingest_error} — nothing is being captured`]),t.ingest&&n.push([`ingest`,`${t.ingest.files_known} transcripts · ${t.ingest.events_stored} events stored · ${t.ingest.events_deduped} deduped · ${t.ingest.lines_malformed} malformed lines · backfill ${t.ingest.backfill_done?`done`:`running`}`]),(0,L.jsxs)(`div`,{className:`grid gap-3 max-w-3xl`,children:[(0,L.jsx)(Wg,{}),(0,L.jsx)(R,{title:`Daemon`,children:(0,L.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,L.jsx)(`tbody`,{children:n.map(([e,t])=>(0,L.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1 text-fg-muted w-32`,children:e}),(0,L.jsx)(`td`,{className:`px-3 py-1 mono break-all`,children:t})]},e))})})}),t.ingest_error&&(0,L.jsx)(R,{title:`Ingest stopped`,children:(0,L.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-muted`,children:[`No new sessions are being captured: `,(0,L.jsx)(`span`,{className:`mono text-fg`,children:t.ingest_error}),`. Check that`,(0,L.jsx)(`span`,{className:`mono text-fg`,children:` ~/.claude`}),` is readable, then restart with`,(0,L.jsx)(`span`,{className:`mono text-fg`,children:` caprock down && caprock up`}),`.`]})}),!t.claude_available&&(0,L.jsx)(R,{title:`claude not found`,children:(0,L.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-muted`,children:[`The `,(0,L.jsx)(`span`,{className:`mono`,children:`claude`}),` binary was not found on this machine, so Caprock cannot spawn sessions. It still observes every session you start yourself. Install Claude Code, or make sure`,(0,L.jsx)(`span`,{className:`mono`,children:` claude`}),` is on the PATH the daemon was started with.`]})}),t.hooks&&(t.hooks.missing??[]).length>0&&(0,L.jsx)(R,{title:`Hooks not fully installed`,children:(0,L.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-muted`,children:[`Missing: `,(0,L.jsx)(`span`,{className:`mono`,children:(t.hooks.missing??[]).join(`, `)}),`. Run `,(0,L.jsx)(`span`,{className:`mono`,children:`caprock hooks install`}),` for real-time activity; transcript tailing keeps working with a few seconds of delay.`]})})]})}function Wg(){let[e,t]=De();return e?(0,L.jsx)(R,{title:`Settings`,children:(0,L.jsxs)(`div`,{className:`grid gap-2 px-3 py-2.5 text-[12px]`,children:[(0,L.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--color-accent)] mt-0.5`,checked:e.update_checks,onChange:n=>t({...e,update_checks:n.target.checked})}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`span`,{className:`text-fg`,children:`Check GitHub for new releases`}),(0,L.jsx)(`span`,{className:`block text-[11px] text-fg-muted`,children:`The only outbound call Caprock makes. No usage data is sent, and it is checked at most once a day.`})]})]}),(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2 border-t border-border pt-2`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted w-28 shrink-0`,children:`Your plan`}),(0,L.jsx)(`span`,{className:`mono text-fg`,children:e.plan_kind===`metered`?`${e.plan_label||`API`} · billed per token`:e.plan_kind===`flat`?`${e.plan_label||`plan`} · ${S(e.plan_usd_per_month)}/mo`:`not set`}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint ml-auto`,children:`change it in the header`})]}),(0,L.jsx)(Hg,{plan:e,save:t})]})}):null}function Gg(){let e=I(()=>P.settings(),[],{live:!1}),t=re(3e4),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(!1),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(``),h=e.data;(0,l.useEffect)(()=>{o||h===void 0||(a(h.report_chat_id??``),s(!0))},[h,o]);let g=async()=>{u(!0),m(``);try{await P.saveSettings({report_chat_id:i.trim(),...n.trim()?{report_bot_token:n.trim()}:{}}),r(``),f(!0),e.refresh?.()}catch(e){m(ae(e))}finally{u(!1)}},_=!!h?.report_bot_set&&!!h?.report_chat_id,[v,y]=(0,l.useState)(!1),[b,x]=(0,l.useState)(!1);async function S(){y(!0),x(!1),m(``);try{await P.testReport(),x(!0),window.setTimeout(()=>x(!1),6e3)}catch(e){m(e instanceof Error?e.message:String(e))}finally{y(!1)}}return(0,L.jsx)(R,{title:`Weekly report`,right:(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:_?`Mondays, or the next day you open the lid`:`not set up`}),children:(0,L.jsxs)(`div`,{className:`px-3 py-3 grid gap-3 text-[12px]`,children:[(0,L.jsx)(`p`,{className:`m-0 text-fg-muted`,children:`What moved this week, against your usual — sent to a Telegram bot you own. Nothing passes our server, and the message carries figures only: no prompts, no replies, no file names.`}),(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsxs)(`span`,{className:`text-fg-muted`,children:[`Bot token`,h?.report_bot_set&&(0,L.jsx)(`span`,{className:`text-ok`,children:` · one is stored`})]}),(0,L.jsx)(`input`,{className:`input`,type:`password`,placeholder:h?.report_bot_set?`leave blank to keep the current one`:`123456:ABC-DEF…`,value:n,onChange:e=>r(e.target.value)}),(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[`Message `,(0,L.jsx)(`span`,{className:`mono`,children:`@BotFather`}),` on Telegram, send`,` `,(0,L.jsx)(`span`,{className:`mono`,children:`/newbot`}),`, and paste what it gives you. Caprock stores it on this machine and never sends it back to this page.`]}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`Your own bot, so your figures go straight from this machine to Telegram — never through anybody's server.`})]}),(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsx)(`span`,{className:`text-fg-muted`,children:`Chat id`}),(0,L.jsx)(`input`,{className:`input`,placeholder:`123456789`,value:i,onChange:e=>a(e.target.value)}),(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[(0,L.jsx)(`strong`,{children:`Message your bot first`}),` — find it by username, press Start, send anything. Then open`,` `,(0,L.jsx)(`span`,{className:`mono`,children:`api.telegram.org/bot/getUpdates`}),` and copy`,` `,(0,L.jsx)(`span`,{className:`mono`,children:`chat.id`}),`.`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,L.jsx)(`button`,{onClick:()=>void g(),disabled:c||!i.trim(),className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:c?`saving…`:`Save`}),(0,L.jsx)(`button`,{onClick:()=>void S(),disabled:v||!_,title:_?`Send this week's report now`:`Save a bot token and chat id first`,className:`border border-border px-3 py-1 rounded-sm hover:border-fg-faint disabled:opacity-50`,children:v?`sending…`:`Send one now`}),b&&(0,L.jsx)(`span`,{className:`text-[11px] text-ok`,children:`sent — check Telegram`}),d&&!p&&(0,L.jsx)(`span`,{className:`text-[11px] text-ok`,children:`saved`}),p&&(0,L.jsx)(`span`,{className:`text-[11px] text-danger`,children:p})]}),h?.report_last_error?(0,L.jsxs)(`p`,{className:`m-0 text-[11px] text-danger`,children:[`Last send failed: `,h.report_last_error]}):h?.report_last_sent_ms?(0,L.jsxs)(`p`,{className:`m-0 text-[11px] text-fg-faint`,children:[`Last sent `,E(h.report_last_sent_ms,t),` ago.`]}):_?(0,L.jsx)(`p`,{className:`m-0 text-[11px] text-fg-faint`,children:`Nothing sent yet — the first one goes out at the start of next week.`}):null]})})}function Kg(){let[e,t]=(0,l.useState)(`all`),[n,r]=(0,l.useState)(null),i=I(()=>P.history(e),[e],{intervalMs:15e3}),[a]=De(),o=i.data,s=!!o&&o.totals.turns>0,c=zg(o?.daily??[]),u=Math.max(...(o?.tools??[]).map(e=>e.count),1);return(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[[`today`,`7d`,`30d`,`all`].map(n=>(0,L.jsx)(`button`,{onClick:()=>t(n),className:`px-2 py-1 text-[12px] rounded-sm ${e===n?`bg-panel-2 text-fg`:`text-fg-muted hover:text-fg`}`,children:n},n)),(0,L.jsx)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,children:`Everything you ever ran through Caprock. Measured, not estimated.`})]}),s&&o&&(0,L.jsx)(Pn,{costUSD:o.totals.cost_usd,days:o.totals.days,now:Date.now()}),i.error&&!o&&(0,L.jsx)(Dt,{title:`Cannot reach the daemon`,children:i.error.message}),(0,L.jsxs)(R,{title:`Lifetime · ${e}`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-7 divide-x divide-border`,children:[(0,L.jsx)(z,{size:`compact`,label:`Sessions`,value:s?o.totals.sessions:`—`,sub:s?`${o.totals.owned_sessions} spawned by caprock`:void 0}),(0,L.jsx)(z,{size:`compact`,label:`Active days`,value:s?o.totals.days:`—`}),(0,L.jsx)(z,{size:`compact`,label:`Turns`,value:s?C(o.totals.turns):`—`,sub:s?`${C(o.totals.tool_calls)} tool calls`:void 0}),(0,L.jsx)(z,{size:`compact`,label:`Files touched`,value:s?C(o.totals.files_touched):`—`,sub:`summed per session`}),(0,L.jsx)(z,{size:`compact`,label:`Avg session span`,value:s?D(Math.round(o.totals.avg_session_sec*1e3)):`—`,sub:`first to last event`}),(0,L.jsx)(Cn,{hitRate:o?.savings.hit_rate,cutPct:o?.savings.cut_pct,measured:s}),(0,L.jsx)(z,{label:`Cost`,value:s?S(o.totals.cost_usd):`—`,sub:(0,L.jsx)(`span`,{title:vn(a),children:s?_n(a):`nothing measured yet`}),tone:`info`,size:`hero`})]}),(0,L.jsx)(Ar,{u:o?.totals.unpriced,className:`mx-3 mb-2.5`})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,L.jsxs)(R,{title:`Tool usage`,right:(0,L.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.08em]`,children:`calls`}),children:[o?o.tools.length===0&&(0,L.jsx)(Dt,{title:`No tool calls yet`}):(0,L.jsx)(Ot,{rows:5}),(0,L.jsx)(`ul`,{className:`py-1`,children:(o?.tools??[]).slice(0,18).map(e=>(0,L.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-[3px]`,children:[(0,L.jsx)(`span`,{className:`mono text-[12px] w-44 shrink-0 truncate`,title:e.tool,children:te(e.tool)}),(0,L.jsx)(`div`,{className:`flex-1 h-2 bg-panel-2 rounded-sm overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full bg-accent/70`,style:{width:`${100*e.count/u}%`}})}),(0,L.jsx)(`span`,{className:`num text-[11px] text-fg-muted w-12 text-right`,children:C(e.count)})]},e.tool))})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 content-start`,children:[(0,L.jsxs)(R,{title:`Model mix`,right:(0,L.jsx)(`span`,{children:`by cost`}),children:[o?o.summary.models.length===0&&(0,L.jsx)(Dt,{title:`No priced turns`}):(0,L.jsx)(Ot,{rows:3}),(0,L.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-[0.08em] text-fg-faint`,children:[(0,L.jsx)(`th`,{className:`px-3 pb-1 text-left font-normal`,children:`model`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`tokens`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`cost`})]})}),(0,L.jsx)(`tbody`,{children:(o?.summary.models??[]).map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1 mono`,children:e.model||`unknown`}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:S(e.cost_usd)})]},e.model))})]})]}),(0,L.jsx)(Pg,{feature:`report`,title:`Get this every Monday, without opening the dashboard`,children:(0,L.jsx)(Gg,{})}),(0,L.jsx)(R,{title:`Top projects`,right:(0,L.jsx)(`span`,{children:`by cost`}),children:(0,L.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-[0.08em] text-fg-faint`,children:[(0,L.jsx)(`th`,{className:`px-3 pb-1 text-left font-normal`,children:`project`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`tokens`}),(0,L.jsx)(`th`,{className:`px-3 pb-1 text-right font-normal`,children:`cost`})]})}),(0,L.jsx)(`tbody`,{children:(o?.summary.projects??[]).slice(0,8).map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1`,children:e.project||`unknown`}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right text-fg-muted`,children:C(e.tokens)}),(0,L.jsx)(`td`,{className:`px-3 py-1 num text-right`,children:S(e.cost_usd)})]},e.project))})]})})]})]}),(0,L.jsxs)(R,{title:`Daily cost`,right:(0,L.jsx)(Dg,{bars:c,active:n,total:c.reduce((e,t)=>e+t.cost,0)}),children:[i.data?c.length===0&&(0,L.jsx)(Dt,{title:`No history yet`}):(0,L.jsx)(Ot,{rows:2}),c.length>0&&(0,L.jsx)(Eg,{bars:c,active:n,onActive:r,height:96,showDayLabels:!1})]})]})}var qg=[{key:`inbox`,label:`Inbox`},{key:`assigned`,label:`Assigned`},{key:`in_progress`,label:`In progress`},{key:`verifying`,label:`Verifying`},{key:`needs_you`,label:`Needs you`},{key:`done`,label:`Done`}];function Jg(){let e=I(()=>P.status(),[],{live:!1,intervalMs:3e4}),t=I(()=>P.tasks(),[],{intervalMs:4e3}),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(null);if(e.data&&e.data.orchestration===!1)return(0,L.jsx)(Yg,{status:e.data,onEnabled:()=>{e.refresh(),t.refresh()}});let o=e=>(t.data??[]).filter(t=>t.status===e||e===`done`&&t.status===`failed`);return(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`button`,{onClick:()=>r(!0),className:`border border-accent/50 text-accent bg-accent/10 px-2 py-1 rounded-sm text-[12px] hover:bg-accent/20`,children:`+ New task`}),(0,L.jsx)(Qg,{available:e.data?.claude_available??!1}),(t.data??[]).some(e=>e.assignee!==``&&e.status!==`done`&&e.status!==`failed`)&&(0,L.jsx)(`a`,{href:`#/graph`,className:`link text-[12px] border border-border px-2 py-1 rounded-sm hover:border-border-strong`,children:`view graph`}),(0,L.jsxs)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,children:[`Tasks are files on disk (`,(0,L.jsx)(`span`,{className:`mono`,children:`tasks/.md`}),`); the orchestrator moves them. Nothing reaches Done until its `,(0,L.jsx)(`span`,{className:`mono`,children:`done_criteria`}),` pass.`]})]}),t.error&&!t.data&&(0,L.jsx)(Dt,{title:`Cannot reach the daemon`,children:t.error.message}),t.data&&t.data.length===0&&(0,L.jsxs)(`div`,{className:`border border-border bg-panel-2/60 rounded-sm px-3 py-2 text-[12px] text-fg-muted`,children:[`Start here: `,(0,L.jsx)(`span`,{className:`text-fg`,children:`+ New task`}),` — a title and the commands that have to pass. Then `,(0,L.jsx)(`span`,{className:`text-fg`,children:`▶ Start orchestrator`}),`, which assigns it to a worker and keeps going until the checks are green.`]}),(0,L.jsx)(`div`,{className:`grid gap-2 grid-cols-2 md:grid-cols-3 xl:grid-cols-6`,children:qg.map(e=>(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`text-[11px] uppercase tracking-[0.08em] text-fg-faint mb-1.5 px-0.5 flex justify-between`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`span`,{className:`num`,children:o(e.key).length})]}),(0,L.jsx)(`div`,{className:`grid gap-1.5 content-start min-h-[60px]`,children:o(e.key).map(e=>(0,L.jsx)($g,{t:e,onApprove:()=>t.refresh(),onOpen:()=>a(e.id)},e.id))})]},e.key))}),n&&(0,L.jsx)(i_,{onClose:()=>{r(!1),t.refresh()}}),i&&(0,L.jsx)(e_,{id:i,onClose:()=>{a(null),t.refresh()}})]})}function Yg({status:e,onEnabled:t}){let[n,r]=(0,l.useState)(!1),i=e.suggested_hive??`~/caprock-tasks`,a=e.suggested_repo??``;return(0,L.jsxs)(`div`,{className:`grid gap-3 max-w-[52rem] mx-auto`,children:[(0,L.jsxs)(R,{title:`Task runner`,right:(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`off`}),children:[(0,L.jsxs)(`div`,{className:`grid gap-3 px-3 py-3`,children:[(0,L.jsxs)(`ol`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,L.jsx)(Xg,{n:1,title:`You write a task`,children:`A title, a budget, and the commands that have to pass.`}),(0,L.jsxs)(Xg,{n:2,title:`Caprock runs it`,children:[`One Claude session per task, in its `,(0,L.jsx)(`span`,{className:`text-fg`,children:`own git worktree`}),` — your working tree is untouched.`]}),(0,L.jsxs)(Xg,{n:3,title:`Caprock checks it`,children:[(0,L.jsx)(`span`,{className:`text-fg`,children:`Caprock`}),` runs your commands, not the agent. Only green is done.`]})]}),(0,L.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:`Best for independent tasks — nothing here merges branches. The queue directory is created for you; your repository is not modified.`})]}),(0,L.jsxs)(`footer`,{className:`px-3 py-2 border-t border-border flex items-center gap-2`,children:[(0,L.jsx)(`button`,{onClick:()=>r(!0),className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm text-[12px] hover:bg-accent/25`,children:`Turn on the task runner`}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`No restart. Nothing runs until you start it.`})]})]}),n&&(0,L.jsx)(Zg,{hive:i,repo:a,onClose:()=>r(!1),onDone:t})]})}function Xg({n:e,title:t,children:n}){return(0,L.jsxs)(`li`,{className:`border border-border bg-panel-2/60 rounded-sm px-2.5 py-2 grid gap-1 content-start`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,L.jsx)(`span`,{className:`num text-[11px] text-accent`,children:e}),(0,L.jsx)(`span`,{className:`text-[12px] font-medium`,children:t})]}),(0,L.jsx)(`div`,{className:`text-[11px] text-fg-muted leading-[1.45]`,children:n})]})}function Zg({hive:e,repo:t,onClose:n,onDone:r}){let[i,a]=(0,l.useState)(e),[o,s]=(0,l.useState)(t),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)(``);return(0,L.jsx)(`div`,{className:`fixed inset-0 z-20 bg-black/50 flex items-start justify-center pt-24`,onClick:n,children:(0,L.jsxs)(`div`,{className:`border border-border-strong bg-panel rounded-[var(--radius-panel)] w-[560px] max-w-[92vw]`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`header`,{className:`px-3 py-2 border-b border-border flex items-center`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] uppercase tracking-[0.08em] text-fg-muted`,children:`Turn on the task runner`}),(0,L.jsx)(`button`,{onClick:n,className:`ml-auto text-fg-muted hover:text-fg`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`px-4 py-3 grid gap-3 text-[13px]`,children:[(0,L.jsxs)(`ul`,{className:`grid gap-1 text-[12px] text-fg-muted`,children:[(0,L.jsx)(`li`,{children:`· Creates the queue directory below, with a README and an example task.`}),(0,L.jsxs)(`li`,{children:[`· Lets Caprock spawn Claude sessions `,(0,L.jsx)(`span`,{className:`text-fg`,children:`with permission prompts skipped`}),`, one git worktree each under the repo below.`]}),(0,L.jsx)(`li`,{children:`· Starts nothing yet — you start the orchestrator, and only then does work begin.`})]}),(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`Queue directory`,(0,L.jsx)(`span`,{className:`text-fg-faint`,children:` · created if missing`})]}),(0,L.jsx)(`input`,{className:`input mono`,value:i,onChange:e=>a(e.target.value)})]}),(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`Repository`,(0,L.jsx)(`span`,{className:`text-fg-faint`,children:` · workers branch from here`})]}),(0,L.jsx)(`input`,{className:`input mono`,value:o,onChange:e=>s(e.target.value)})]}),d&&(0,L.jsx)(`div`,{className:`text-danger text-[12px]`,children:d})]}),(0,L.jsxs)(`footer`,{className:`px-4 py-2 border-t border-border flex gap-2 justify-end`,children:[(0,L.jsx)(`button`,{onClick:n,className:`border border-border px-3 py-1 rounded-sm text-fg-muted hover:text-fg`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:async()=>{u(!0),f(``);try{await P.enableHive(i.trim(),o.trim()),n(),r()}catch(e){f(ae(e))}finally{u(!1)}},disabled:c,className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:c?`turning on…`:`Turn it on`})]})]})})}function Qg({available:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(``);return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(`button`,{disabled:t||!e,onClick:async()=>{n(!0),i(``);try{let e=await P.startOrchestrator();i(`orchestrator: `+e.session_id.slice(0,8))}catch(e){i(ae(e))}finally{n(!1)}},title:e?`spawn the orchestrator session`:`claude not found — cannot spawn`,className:`border border-border text-fg-muted px-2 py-1 rounded-sm text-[12px] hover:text-fg disabled:opacity-50`,children:t?`starting…`:`▶ Start orchestrator`}),!e&&(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[(0,L.jsx)(`span`,{className:`mono`,children:`claude`}),` was not found on this machine, so Caprock cannot spawn the orchestrator. It still observes every session you start yourself.`]}),r&&(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint mono`,children:r})]})}function $g({t:e,onApprove:t,onOpen:n}){let r=e.budget_usd>0&&e.cost_usd>e.budget_usd,i=e.assignee!==``;return(0,L.jsxs)(`div`,{className:`border border-border bg-panel rounded-[var(--radius-panel)] px-2 py-1.5`,children:[(0,L.jsxs)(`button`,{className:`w-full text-left disabled:cursor-default`,disabled:!i,onClick:n,title:i?`show the diff, the checks that ran, and where the branch is`:`nothing to show yet — no worker has picked this up`,children:[(0,L.jsx)(`div`,{className:`text-[12px] font-medium truncate ${i?`hover:text-accent`:``}`,title:e.title,children:e.title||e.id}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[10px] text-fg-faint`,children:[(0,L.jsx)(`span`,{className:`mono`,children:ee(e.id)}),e.assignee&&(0,L.jsxs)(`span`,{className:`mono text-fg-muted`,children:[`→ `,e.assignee]}),(0,L.jsxs)(`span`,{className:`num ml-auto ${r?`text-danger`:`text-fg-muted`}`,children:[S(e.cost_usd),e.budget_usd>0?` / ${S(e.budget_usd)}`:``]})]})]}),i&&(0,L.jsxs)(`div`,{className:`mt-1 text-[10px] text-fg-faint mono truncate`,children:[`caprock/`,e.assignee]}),e.status===`needs_you`&&(0,L.jsxs)(`div`,{className:`flex gap-1 mt-1.5`,children:[(0,L.jsx)(`button`,{onClick:()=>P.approve(e.id,!0).then(t),className:`flex-1 text-[11px] border border-ok/40 text-ok rounded-sm hover:bg-ok/10`,children:`approve`}),(0,L.jsx)(`button`,{onClick:()=>P.approve(e.id,!1).then(t),className:`flex-1 text-[11px] border border-danger/40 text-danger rounded-sm hover:bg-danger/10`,children:`reject`})]})]})}function e_({id:e,onClose:t}){let n=I(()=>P.task(e),[e],{intervalMs:6e3}),r=n.data,i=r?.work,a=i?.sessions?.[0];return(0,L.jsx)(`div`,{className:`fixed inset-0 z-20 bg-black/50 flex items-start justify-center pt-16`,onClick:t,children:(0,L.jsxs)(`div`,{className:`border border-border-strong bg-panel rounded-[var(--radius-panel)] w-[820px] max-w-[94vw] max-h-[82vh] overflow-auto`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`header`,{className:`px-3 py-2 border-b border-border flex items-center gap-2 sticky top-0 bg-panel z-10`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] uppercase tracking-[0.08em] text-fg-muted`,children:`Task`}),r&&(0,L.jsx)(`span`,{className:`text-[12px] truncate`,children:r.task.title||r.task.id}),r&&(0,L.jsx)(`span`,{className:`mono text-[10px] text-fg-faint`,children:r.task.status}),(0,L.jsx)(`button`,{onClick:t,className:`ml-auto text-fg-muted hover:text-fg`,children:`✕`})]}),!r&&!n.error&&(0,L.jsx)(Ot,{rows:5}),n.error&&!r&&(0,L.jsx)(Dt,{title:`Cannot load the task`,children:n.error.message}),r&&(0,L.jsxs)(`div`,{className:`px-3 py-3 grid gap-3`,children:[(0,L.jsx)(t_,{work:i,assignee:r.task.assignee}),(0,L.jsx)(n_,{criteria:r.done_criteria,runs:i?.verifications,status:r.task.status}),(0,L.jsx)(r_,{sessionID:a?.session_id,assignee:r.task.assignee}),r.body&&(0,L.jsx)(R,{title:`Brief`,children:(0,L.jsx)(`pre`,{className:`mono text-[11px] leading-[1.45] px-3 py-2 whitespace-pre-wrap`,children:r.body})})]})]})})}function t_({work:e,assignee:t}){return e?.branch?(0,L.jsx)(R,{title:`Where the work is`,children:(0,L.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,L.jsxs)(`tbody`,{children:[(0,L.jsxs)(`tr`,{className:`border-b border-border/60`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1 text-fg-muted w-32`,children:`branch`}),(0,L.jsx)(`td`,{className:`px-3 py-1 mono break-all`,children:e.branch})]}),e.worktree&&(0,L.jsxs)(`tr`,{className:`border-b border-border/60`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1 text-fg-muted w-32`,children:`worktree`}),(0,L.jsx)(`td`,{className:`px-3 py-1 mono break-all`,children:e.worktree})]}),(0,L.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsx)(`td`,{className:`px-3 py-1 text-fg-muted w-32 align-top`,children:`take it`}),(0,L.jsxs)(`td`,{className:`px-3 py-1 grid gap-1 justify-items-start`,children:[(0,L.jsx)(kt,{command:`git merge --no-ff ${e.branch}`}),(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[`Run it from `,e.repo?(0,L.jsx)(`span`,{className:`mono`,children:e.repo}):`your repo`,`, on the branch you want the work on. Prefer `,(0,L.jsx)(`span`,{className:`mono`,children:`git cherry-pick`}),` if you only want some of it. Worker`,` `,(0,L.jsx)(`span`,{className:`mono`,children:t}),` may still be running — check the diff below first.`]})]})]})]})})}):(0,L.jsx)(R,{title:`Where the work is`,children:(0,L.jsx)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:`No worker has been assigned yet, so there is no branch. One is created the moment the orchestrator assigns this task.`})})}function n_({criteria:e,runs:t,status:n}){let r=t?.[0],i=r?t.filter(e=>e.round===r.round):[],a=r?`round ${r.round}`:void 0;return(0,L.jsxs)(R,{title:`What has to pass`,right:a,children:[i.length===0&&(0,L.jsxs)(`div`,{className:`px-3 py-2 grid gap-1`,children:[(0,L.jsx)(`div`,{className:`text-[12px] text-fg-faint`,children:n===`done`?`This task was marked done without a recorded check.`:`Not run yet. Caprock runs these itself, in the worker’s worktree, when the worker reports it has finished.`}),(0,L.jsx)(`ul`,{className:`grid gap-0.5`,children:(e??[]).map(e=>(0,L.jsxs)(`li`,{className:`mono text-[11px] text-fg-muted`,children:[`$ `,e]},e))}),(e??[]).length===0&&(0,L.jsx)(`div`,{className:`mono text-[11px] text-danger`,children:`no done_criteria — Caprock cannot verify this task`})]}),i.length>0&&(0,L.jsx)(`ul`,{children:i.map(e=>(0,L.jsxs)(`li`,{className:`border-b border-border/60 last:border-0 px-3 py-1.5 flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-[10px] w-14 shrink-0 mono ${e.exit_code===0?`text-ok`:`text-danger`}`,children:e.exit_code===0?`passed`:`exit ${e.exit_code}`}),(0,L.jsx)(`span`,{className:`mono text-[12px] truncate`,title:e.command,children:e.command})]},e.command))})]})}function r_({sessionID:e,assignee:t}){let n=I(()=>e?P.diff(e):Promise.resolve(void 0),[e],{intervalMs:8e3}),[r,i]=(0,l.useState)(null);if(!e)return(0,L.jsx)(R,{title:`What changed`,children:(0,L.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:[`No session has been attributed to this task yet`,t?` (worker ${t})`:``,`, so there is nothing to diff.`]})});if(n.error&&!n.data){let e=n.error;if(e instanceof ie&&e.status===409){let t=e.body;return(0,L.jsx)(R,{title:`What changed`,children:(0,L.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:[t?.error,t?.cwd?(0,L.jsxs)(L.Fragment,{children:[` · `,(0,L.jsx)(`span`,{className:`mono`,children:t.cwd})]}):null]})})}return(0,L.jsx)(R,{title:`What changed`,children:(0,L.jsx)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:e.message})})}let a=n.data;return a?(0,L.jsxs)(R,{title:`What changed`,right:(0,L.jsxs)(`span`,{className:`num`,children:[a.files.length,` files`]}),children:[a.files.length===0&&(0,L.jsxs)(`div`,{className:`px-3 py-2 text-[12px] text-fg-faint`,children:[`Nothing uncommitted in `,(0,L.jsx)(`span`,{className:`mono`,children:a.branch||`the worktree`}),`. If the worker committed its work, the branch above holds it.`]}),(0,L.jsx)(`ul`,{children:a.files.map(e=>(0,L.jsxs)(`li`,{className:`border-b border-border/60 last:border-0`,children:[(0,L.jsxs)(`button`,{className:`w-full text-left px-3 py-1.5 flex items-center gap-3 hover:bg-panel-2`,onClick:()=>i(r===e.path?null:e.path),children:[(0,L.jsx)(`span`,{className:`mono text-[10px] w-16 shrink-0 ${e.status===`added`||e.status===`untracked`?`text-ok`:e.status===`deleted`?`text-danger`:`text-fg-muted`}`,children:e.status}),(0,L.jsx)(`span`,{className:`mono text-[12px] truncate`,children:e.path}),(0,L.jsxs)(`span`,{className:`ml-auto num text-[11px] shrink-0`,children:[(0,L.jsxs)(`span`,{className:`text-ok`,children:[`+`,e.additions]}),` `,(0,L.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),r===e.path&&e.patch&&(0,L.jsx)(`pre`,{className:`mono text-[11px] leading-[1.35] px-3 pb-2 overflow-auto max-h-[40vh]`,children:e.patch.split(` +`).map((e,t)=>{let n=e.startsWith(`+`)&&!e.startsWith(`+++`)?`text-ok`:e.startsWith(`-`)&&!e.startsWith(`---`)?`text-danger`:e.startsWith(`@@`)?`text-info`:`text-fg-muted`;return(0,L.jsx)(`div`,{className:n,children:e||` `},t)})}),r===e.path&&!e.patch&&(0,L.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-fg-faint`,children:e.binary?`binary file`:`no patch`})]},e.path))})]}):(0,L.jsx)(R,{title:`What changed`,children:(0,L.jsx)(Ot,{rows:3})})}function i_({onClose:e}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(`3`),[a,o]=(0,l.useState)(`go test ./... +go vet ./...`),[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(!1),[f,p]=(0,l.useState)(``),m=a.split(` +`).map(e=>e.trim()).filter(Boolean);return(0,L.jsx)(`div`,{className:`fixed inset-0 z-20 bg-black/50 flex items-start justify-center pt-24`,onClick:e,children:(0,L.jsxs)(`div`,{className:`border border-border-strong bg-panel rounded-[var(--radius-panel)] w-[560px] max-w-[92vw]`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`header`,{className:`px-3 py-2 border-b border-border flex items-center`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] uppercase tracking-[0.08em] text-fg-muted`,children:`New task`}),(0,L.jsx)(`button`,{onClick:e,className:`ml-auto text-fg-muted hover:text-fg`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`px-4 py-3 grid gap-3 text-[13px]`,children:[(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:`Title`}),(0,L.jsx)(`input`,{autoFocus:!0,className:`input`,value:t,onChange:e=>n(e.target.value),placeholder:`Add /healthz endpoint`})]}),(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:`Budget (USD)`}),(0,L.jsx)(`input`,{className:`input`,value:r,onChange:e=>i(e.target.value)})]}),(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:`Done criteria · one command per line`}),(0,L.jsx)(`textarea`,{className:`input`,rows:3,value:a,onChange:e=>o(e.target.value)})]}),(0,L.jsxs)(`label`,{className:`grid gap-1`,children:[(0,L.jsx)(`span`,{className:`text-[11px] text-fg-muted`,children:`Description`}),(0,L.jsx)(`textarea`,{className:`input`,rows:3,value:s,onChange:e=>c(e.target.value)})]}),f&&(0,L.jsx)(`div`,{className:`text-danger text-[12px]`,children:f})]}),(0,L.jsxs)(`footer`,{className:`px-4 py-2 border-t border-border flex gap-2 justify-end`,children:[(0,L.jsx)(`button`,{onClick:e,className:`border border-border px-3 py-1 rounded-sm text-fg-muted hover:text-fg`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:async()=>{if(!t.trim()){p(`Title is required.`);return}if(m.length===0){p(`At least one done criterion is required — it is what decides when the task is done.`);return}d(!0),p(``);try{await P.createTask({title:t.trim(),budget_usd:parseFloat(r)||0,done_criteria:m,body:s}),e()}catch(e){p(ae(e))}finally{d(!1)}},disabled:u,className:`border border-accent bg-accent/15 text-accent px-3 py-1 rounded-sm hover:bg-accent/25 disabled:opacity-50`,children:u?`creating…`:`Create task`})]})]})})}var a_=72,o_=38,s_=.62;function c_(e){return{cx:e.width/2,cy:e.height/2,r:Math.max(80,Math.min(e.width,e.height)/2-a_-o_),nodeR:o_,gateT:s_}}function l_(e){return Math.max(e,6)}function u_(e,t){return-Math.PI/2+2*Math.PI*e/t}function d_(e,t,n){let r=l_(e.length),i=[];return e.forEach((e,a)=>{if(!t.has(e))return;let o=u_(a,r);i.push({id:e,angle:o,x:n.cx+n.r*Math.cos(o),y:n.cy+n.r*Math.sin(o)})}),i}function f_(e,t,n){return{x:t.cx+(e.x-t.cx)*n,y:t.cy+(e.y-t.cy)*n}}var p_={assigned:.18,in_progress:.45,verifying:s_,done:.85,needs_you:.5,failed:.5,inbox:.08};function m_(e){return p_[e]??.3}function h_(e){return e!==``&&e!==`orchestrator`&&e!==`verifier`}function g_(e,t){let n=e.registry.slice(),r=new Set(e.workers);h_(t.assignee)&&!n.includes(t.assignee)&&(n.push(t.assignee),n.sort()),h_(t.assignee)&&r.add(t.assignee);let i=new Map(e.tasks);return i.set(t.id,t),{registry:n,workers:r,tasks:i}}function __(){return{registry:[],workers:new Set,tasks:new Map}}function v_(e,t=[]){let n={registry:t.slice(),workers:new Set,tasks:new Map};for(let t of e)n=g_(n,{id:t.id,title:t.title,assignee:t.assignee,status:t.status});return n}function y_(e){return{id:e.id,title:e.title,assignee:e.assignee,status:e.status}}function b_(){let e=I(()=>P.tasks(),[],{intervalMs:8e3}),t=(0,l.useRef)([]),[n,r]=(0,l.useState)(__);return(0,l.useEffect)(()=>{if(!e.data)return;let n=v_(e.data,t.current);t.current=n.registry,r(n)},[e.data]),(0,l.useEffect)(()=>d.onFrame(e=>{e.type===`task`&&r(n=>{let r=g_(n,y_(e.data));return t.current=r.registry,r})}),[]),n}function x_(e){return e.workers.size>0||e.tasks.size>0}function S_(e){let t=new Map;for(let n of e.tasks.values()){if(!h_(n.assignee))continue;let e=t.get(n.assignee)??[];e.push(n),t.set(n.assignee,e)}return t}var C_=260;function w_(e,t,n,r=C_){let i=e+(t-e)*(1-Math.exp(-n/r));return Math.abs(t-i)<.001?t:i}function T_(e){let t=0,n=performance.now(),r=i=>{let a=Math.min(i-n,64);n=i,e(a),t=requestAnimationFrame(r)};return t=requestAnimationFrame(r),{stop:()=>cancelAnimationFrame(t)}}var E_=class{cur=new Map;setTarget(e,t){this.cur.has(e)||this.cur.set(e,t),this.targets.set(e,t)}targets=new Map;step(e,t){let n=!1;for(let r of Array.from(this.cur.keys())){if(!t.has(r)){this.cur.delete(r),this.targets.delete(r);continue}let i=this.targets.get(r)??this.cur.get(r),a=w_(this.cur.get(r),i,e);a!==this.cur.get(r)&&(n=!0),this.cur.set(r,a)}return n}get(e){return this.cur.get(e)}};function D_(e){let t=(0,l.useRef)(new E_),[,n]=(0,l.useState)(0),r=new Set(e.tasks.keys());for(let n of e.tasks.values())t.current.setTarget(n.id,m_(n.status));return(0,l.useEffect)(()=>{let e=T_(e=>{t.current.step(e,r)&&n(e=>e+1)});return()=>e.stop()},[]),(e,n)=>t.current.get(e)??m_(n)}function O_(e){switch(e){case`done`:return`var(--color-ok)`;case`needs_you`:return`var(--color-warn)`;case`failed`:return`var(--color-danger)`;case`verifying`:case`in_progress`:case`assigned`:return`var(--color-accent)`;default:return`var(--color-fg-muted)`}}function k_(e){return e.some(e=>e.status!==`done`&&e.status!==`failed`)}function A_({model:e,viewport:t,centerLabel:n=`orchestrator`}){let r=c_(t),i=d_(e.registry,e.workers,r),a=S_(e),o=D_(e);return(0,L.jsxs)(`svg`,{width:t.width,height:t.height,className:`block`,role:`img`,"aria-label":`orchestration graph`,children:[i.map(e=>(0,L.jsx)(N_,{node:e,g:r,gateStatus:M_(a.get(e.id)??[])},`spoke-${e.id}`)),i.map(e=>(a.get(e.id)??[]).map((t,n)=>{let i=f_(e,r,o(t.id,t.status)),s=(n-(a.get(e.id).length-1)/2)*12,c=-(e.y-r.cy),l=e.x-r.cx,u=Math.hypot(c,l)||1;return(0,L.jsx)(j_,{task:t,cx:i.x+c/u*s,cy:i.y+l/u*s},`task-${t.id}`)})),i.map(e=>{let t=a.get(e.id)??[],n=k_(t),i=e.x>=r.cx?1:-1,o=i===1?`start`:`end`,s=i*(r.nodeR+10),c=t.find(e=>e.status!==`done`&&e.status!==`failed`)??t[0];return(0,L.jsxs)(`g`,{transform:`translate(${e.x},${e.y})`,children:[(0,L.jsx)(`circle`,{className:n?`graph-breathe`:void 0,r:r.nodeR,fill:`var(--color-panel)`,stroke:n?`var(--color-accent)`:`var(--color-border-strong)`,strokeWidth:n?2.5:1.5}),(0,L.jsx)(`text`,{textAnchor:`middle`,dy:`0.32em`,fontSize:`13`,fill:`var(--color-fg)`,className:`mono`,children:I_(e.id)}),c&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`text`,{x:s,y:-4,textAnchor:o,fontSize:`12`,fill:`var(--color-fg)`,children:F_(c.title,26)}),(0,L.jsx)(`text`,{x:s,y:12,textAnchor:o,fontSize:`11`,fill:O_(c.status),className:`mono`,children:P_(c.status)})]})]},`node-${e.id}`)}),(0,L.jsxs)(`g`,{transform:`translate(${r.cx},${r.cy})`,children:[(0,L.jsx)(`circle`,{r:r.nodeR+6,fill:`var(--color-panel-2)`,stroke:`var(--color-accent)`,strokeWidth:2}),(0,L.jsx)(`text`,{textAnchor:`middle`,dy:`0.32em`,fontSize:`12`,fill:`var(--color-fg)`,className:`mono`,children:n===`orchestrator`?`orch`:n})]})]})}function j_({task:e,cx:t,cy:n}){let r=(0,l.useRef)(e.status),[i,a]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(r.current!==`done`&&e.status===`done`){a(!0);let t=setTimeout(()=>a(!1),600);return r.current=e.status,()=>clearTimeout(t)}r.current=e.status},[e.status]),(0,L.jsx)(`circle`,{className:`graph-dot${i?` graph-verified`:``}`,cx:t,cy:n,r:8,fill:O_(e.status),children:(0,L.jsx)(`title`,{children:`${e.title} · ${e.status}`})})}function M_(e){return e.some(e=>e.status===`done`)?`done`:e.some(e=>e.status===`verifying`)?`verifying`:`idle`}function N_({node:e,g:t,gateStatus:n}){let r=f_(e,t,t.gateT),i=n===`done`?`var(--color-ok)`:n===`verifying`?`var(--color-accent)`:`var(--color-bg)`,a=n===`done`?`var(--color-ok)`:n===`verifying`?`var(--color-accent)`:`var(--color-border-strong)`;return(0,L.jsxs)(`g`,{children:[(0,L.jsx)(`line`,{x1:t.cx,y1:t.cy,x2:e.x,y2:e.y,stroke:`var(--color-border)`,strokeWidth:1.5}),(0,L.jsx)(`rect`,{className:`graph-gate`,x:r.x-7,y:r.y-7,width:14,height:14,transform:`rotate(45 ${r.x} ${r.y})`,fill:i,stroke:a,strokeWidth:1.5,children:(0,L.jsx)(`title`,{children:`verify gate — a task turns green only after its tests pass`})})]})}function P_(e){switch(e){case`assigned`:return`assigned`;case`in_progress`:return`working…`;case`verifying`:return`running tests…`;case`done`:return`✓ verified`;case`needs_you`:return`needs you`;case`failed`:return`failed`;default:return e}}function F_(e,t){return e.length>t?e.slice(0,t-1)+`…`:e}function I_(e){let t=/^worker-(\d+)$/.exec(e);return t?`w${t[1]}`:e===`verifier`?`vfy`:e.slice(0,4)}function L_(e){switch(e){case`working`:return`var(--color-ok)`;case`waiting-on-you`:return`var(--color-warn)`;case`looping`:case`error`:return`var(--color-danger)`;case`ended`:return`var(--color-fg-faint)`;default:return`var(--color-fg-muted)`}}function R_({sessions:e,viewport:t}){let n=c_(t),r=e.map(e=>e.id).sort(),i=d_(r,new Set(r),n),a=new Map(e.map(e=>[e.id,e]));return(0,L.jsxs)(`svg`,{width:t.width,height:t.height,className:`block`,role:`img`,"aria-label":`session graph`,children:[i.map(e=>(0,L.jsx)(`line`,{x1:n.cx,y1:n.cy,x2:e.x,y2:e.y,stroke:`var(--color-border)`,strokeWidth:1.5},`edge-${e.id}`)),i.map(e=>{let t=a.get(e.id),r=L_(t.health);return(0,L.jsxs)(`g`,{transform:`translate(${e.x},${e.y})`,children:[(0,L.jsx)(`circle`,{className:t.health===`working`?`graph-breathe`:void 0,r:n.nodeR,fill:`var(--color-panel)`,stroke:r,strokeWidth:2}),(0,L.jsx)(`text`,{textAnchor:`middle`,dy:`0.32em`,fontSize:`9`,fill:`var(--color-fg-muted)`,className:`mono`,children:t.label}),(0,L.jsx)(`title`,{children:`${t.label} · ${t.health}`})]},`sess-${e.id}`)}),(0,L.jsxs)(`g`,{transform:`translate(${n.cx},${n.cy})`,children:[(0,L.jsx)(`circle`,{r:n.nodeR+4,fill:`var(--color-panel-2)`,stroke:`var(--color-border-strong)`,strokeWidth:1.5}),(0,L.jsx)(`text`,{textAnchor:`middle`,dy:`0.32em`,fontSize:`10`,fill:`var(--color-fg-muted)`,className:`mono`,children:`caprock`})]})]})}function z_(){let e=b_(),t=I(()=>P.sessions(!0),[],{intervalMs:4e3}),n=(0,l.useRef)(null),[r,i]=(0,l.useState)({width:900,height:560});(0,l.useEffect)(()=>{if(!n.current)return;let e=n.current,t=new ResizeObserver(()=>{i({width:e.clientWidth,height:Math.max(420,e.clientHeight)})});return t.observe(e),i({width:e.clientWidth,height:Math.max(420,e.clientHeight)}),()=>t.disconnect()},[]);let a=x_(e),o=(t.data??[]).filter(e=>e.status!==`ended`).map(e=>({id:e.session_id,label:ee(e.session_id),health:e.activity.health})),s=Array.from(e.tasks.values()),c=s.filter(e=>e.status===`done`).length,u=s.filter(e=>[`assigned`,`in_progress`,`verifying`].includes(e.status)).length;return(0,L.jsxs)(`div`,{className:`grid gap-2`,children:[a&&(0,L.jsxs)(`div`,{className:`flex items-baseline gap-6 border border-border bg-panel rounded-[var(--radius-panel)] px-4 py-3`,children:[(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`num text-2xl text-ok`,children:c}),(0,L.jsx)(`span`,{className:`text-[12px] text-fg-muted`,children:`verified — tests passed, not just claimed`})]}),(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`num text-2xl text-accent`,children:u}),(0,L.jsx)(`span`,{className:`text-[12px] text-fg-muted`,children:`in flight`})]}),(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`num text-2xl text-fg`,children:e.workers.size}),(0,L.jsx)(`span`,{className:`text-[12px] text-fg-muted`,children:`workers`})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-fg-faint px-0.5`,children:[(0,L.jsx)(B_,{orchestration:a}),(0,L.jsx)(`span`,{className:`ml-auto`,children:a?`live · the orchestrator assigns work; a task turns green only after its tests pass`:(0,L.jsxs)(L.Fragment,{children:[`your live sessions — start an orchestrator with `,(0,L.jsx)(`span`,{className:`mono text-fg-muted`,children:`caprock up --hive `}),` to see the verified team`]})})]}),(0,L.jsx)(`div`,{ref:n,className:`relative w-full h-[70vh] rounded-[var(--radius-panel)] border border-border bg-panel/40 overflow-hidden`,children:a?(0,L.jsx)(A_,{model:e,viewport:r}):(0,L.jsx)(R_,{sessions:o,viewport:r})})]})}function B_({orchestration:e}){let t=(e,t)=>(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full`,style:{background:e}}),t]});return(0,L.jsx)(`span`,{className:`inline-flex items-center gap-3`,children:e?(0,L.jsxs)(L.Fragment,{children:[t(`var(--color-accent)`,`in flight`),t(`var(--color-ok)`,`verified`),t(`var(--color-warn)`,`needs you`),t(`var(--color-danger)`,`failed`)]}):(0,L.jsxs)(L.Fragment,{children:[t(`var(--color-ok)`,`working`),t(`var(--color-warn)`,`waiting on you`),t(`var(--color-danger)`,`loop / error`),t(`var(--color-fg-muted)`,`idle`)]})})}var V_=200;function H_(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(``),i=re(3e4),[a,o]=(0,l.useState)(!1),s=I(()=>P.searchNotes(n,V_),[n],{live:!1,intervalMs:0}),[c,u]=(0,l.useState)([]),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(!1);(0,l.useEffect)(()=>{u([]),m(!1)},[n]);let h=[...s.data??[],...c];async function g(){let e=h[h.length-1];if(!(!e||d)){f(!0);try{let t=await P.searchNotes(n,V_,e.event_id);t.length===0?m(!0):u(e=>[...e,...t])}catch{m(!0)}finally{f(!1)}}}let _=a||n?h:h.filter(e=>!e.fragment),v=h.length-_.length;return(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:t=>{t.preventDefault(),r(e.trim())},children:[(0,L.jsx)(`input`,{className:`input max-w-[520px]`,value:e,onChange:e=>t(e.target.value),placeholder:`Search what Claude told you — a name, an error, a decision…`,"aria-label":`Search Claude's answers`}),(0,L.jsx)(`button`,{type:`submit`,className:`text-[12px] border border-accent/50 text-accent bg-accent/10 px-2 py-1 rounded-sm hover:bg-accent/20`,children:`search`}),n&&(0,L.jsx)(`button`,{type:`button`,className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-1 rounded-sm`,onClick:()=>{t(``),r(``)},children:`clear`}),v>0&&(0,L.jsx)(`button`,{type:`button`,className:`text-[11px] text-fg-muted hover:text-fg border border-border px-1.5 py-1 rounded-sm`,onClick:()=>o(e=>!e),children:a?`hide short remarks`:`+${v} short remarks`}),(0,L.jsx)(`span`,{className:`ml-auto text-[11px] text-fg-faint`,children:`Claude's written answers, across every session. Local only.`})]}),s.error&&!s.data&&(0,L.jsx)(Dt,{title:`Cannot search`,children:s.error.message}),!s.data&&!s.error&&(0,L.jsx)(Ot,{rows:5,className:`border border-border rounded-[var(--radius-panel)] bg-panel`}),s.data&&_.length===0&&(0,L.jsx)(Dt,{title:n?`Nothing found for "${n}"`:`No answers captured yet`,children:n?`Try a shorter phrase — this matches the words Claude wrote, not what you asked.`:`Run a session and Claude’s written answers will be searchable here.`}),_.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`text-[11px] text-fg-faint px-0.5`,children:[_.length,` `,_.length===1?`answer`:`answers`,n?` matching "${n}"`:` · most recent`,` · subagent chatter excluded`]}),(0,L.jsx)(`div`,{className:`grid gap-2`,children:_.map(e=>(0,L.jsx)(ni,{note:e,now:i,showSession:!0},e.event_id))}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 px-0.5`,children:[!p&&(0,L.jsx)(`button`,{className:`text-[11px] text-fg-muted hover:text-fg border border-border px-2 py-1 rounded-sm`,onClick:()=>void g(),disabled:d,children:d?`loading…`:`load older answers`}),p&&(0,L.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:`that is everything`})]})]})]})}function U_(){let e=_();return(0,L.jsx)(gt,{route:e,children:(0,L.jsxs)(St,{label:e.name,children:[e.name===`now`&&(0,L.jsx)(Yr,{}),e.name===`session`&&(0,L.jsx)(hg,{id:e.id,tab:e.tab,at:e.at},e.id),e.name===`cost`&&(0,L.jsx)(Rg,{}),e.name===`settings`&&(0,L.jsx)(Ug,{}),e.name===`history`&&(0,L.jsx)(Kg,{}),e.name===`tasks`&&(0,L.jsx)(Jg,{}),e.name===`graph`&&(0,L.jsx)(z_,{}),e.name===`notes`&&(0,L.jsx)(H_,{})]})})}(0,u.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(l.StrictMode,{children:(0,L.jsx)(U_,{})})); \ No newline at end of file diff --git a/internal/api/dist/index.html b/internal/api/dist/index.html index ff5aeee..24c7c9a 100644 --- a/internal/api/dist/index.html +++ b/internal/api/dist/index.html @@ -20,8 +20,8 @@ } catch (e) {} })(); - - + +
diff --git a/internal/api/gemini.go b/internal/api/gemini.go index 0dacffe..120dfb7 100644 --- a/internal/api/gemini.go +++ b/internal/api/gemini.go @@ -75,8 +75,8 @@ func (s *Server) handleGeminiAsk(w http.ResponseWriter, r *http.Request) { if !gemini.Available(s.d.Settings.Get().GeminiAPIKey) { // Not an error the user did wrong: the feature is simply not set up. writeJSON(w, http.StatusPreconditionFailed, map[string]string{ - "error": "no api key", - "detail": "set " + gemini.EnvKey + " in the daemon's environment and restart it", + "error": "no Gemini key", + "detail": "add one on the Cost screen — it works straight away, no restart", }) return } diff --git a/internal/board/board.go b/internal/board/board.go index 2416ded..76c6a96 100644 --- a/internal/board/board.go +++ b/internal/board/board.go @@ -110,7 +110,7 @@ func (cr *CreateRequest) validate() error { case len(cr.Body) > maxBody: return fmt.Errorf("task body is %d bytes; the limit is %d", len(cr.Body), maxBody) case len(cr.DoneCriteria) == 0: - return errors.New("done_criteria is required: at least one command that must pass before the task can be done. Caprock cannot verify a task without one, and will not mark it done on the worker's say-so") + return errors.New("done_criteria is required — at least one command that must exit 0 before the task is done") case math.IsNaN(cr.BudgetUSD) || math.IsInf(cr.BudgetUSD, 0): return errors.New("budget_usd must be a real number") case cr.BudgetUSD < 0: diff --git a/internal/license/license.go b/internal/license/license.go index b2dc4de..cfe9041 100644 --- a/internal/license/license.go +++ b/internal/license/license.go @@ -63,22 +63,22 @@ func Parse(key string, now time.Time) State { return State{Reason: "no key"} } if !strings.HasPrefix(k, Prefix) { - return State{Reason: fmt.Sprintf("a Caprock key starts with %q", Prefix)} + return State{Reason: fmt.Sprintf("that is not a Caprock key — they start with %q", Prefix)} } rest := strings.TrimPrefix(k, Prefix) // A date is all a key needs. The suffix exists so two keys issued on the // same day can be told apart in an email; nothing verifies it, so a key // dictated over the phone and typed without one still has to work. if len(rest) < len("2006-01-02") { - return State{Reason: "key is too short to carry a date"} + return State{Reason: "that key looks cut short — check you copied all of it"} } day := rest[:len("2006-01-02")] exp, err := time.Parse("2006-01-02", day) if err != nil { - return State{Reason: "key does not carry a readable date"} + return State{Reason: "that key is not readable — check you copied all of it"} } if len(rest) > len(day) && rest[len(day)] != '-' { - return State{Reason: "key is missing the separator after its date"} + return State{Reason: "that key is not readable — check you copied all of it"} } // The date names the last day covered, so the key is good until the end of // it — an expiry of 2026-08-26 that stops working at midnight on the 26th diff --git a/internal/license/license_test.go b/internal/license/license_test.go index 030566f..cacf70b 100644 --- a/internal/license/license_test.go +++ b/internal/license/license_test.go @@ -37,10 +37,10 @@ func TestParse(t *testing.T) { // Every rejection has to say what is wrong. "Invalid" sends someone to // support; naming the problem lets them fix it. {name: "no key at all", key: "", now: "2026-08-26", wantWhy: "no key"}, - {name: "the wrong kind of string", key: "sk_live_abc123", now: "2026-08-26", wantWhy: "starts with"}, - {name: "prefix but no date", key: "CR-hello", now: "2026-08-26", wantWhy: "too short"}, - {name: "a date that is not one", key: "CR-2026-13-45-A1B2C3D4", now: "2026-08-26", wantWhy: "readable date"}, - {name: "date runs into the random part", key: "CR-2026-08-26A1B2C3D4", now: "2026-08-26", wantWhy: "separator"}, + {name: "the wrong kind of string", key: "sk_live_abc123", now: "2026-08-26", wantWhy: "not a Caprock key"}, + {name: "prefix but no date", key: "CR-hello", now: "2026-08-26", wantWhy: "cut short"}, + {name: "a date that is not one", key: "CR-2026-13-45-A1B2C3D4", now: "2026-08-26", wantWhy: "not readable"}, + {name: "date runs into the random part", key: "CR-2026-08-26A1B2C3D4", now: "2026-08-26", wantWhy: "not readable"}, } { t.Run(tc.name, func(t *testing.T) { got := Parse(tc.key, at(tc.now)) diff --git a/internal/store/migrations/0018_tool_bytes.sql b/internal/store/migrations/0018_tool_bytes.sql new file mode 100644 index 0000000..650eab2 --- /dev/null +++ b/internal/store/migrations/0018_tool_bytes.sql @@ -0,0 +1,36 @@ +-- How much each tool call handed back. +-- +-- The tool tables could say how OFTEN a tool was used and nothing about how +-- much it cost, and the honest version of "cost" turns out not to exist: tool +-- events carry no tokens, because a tool does not spend them — the turn that +-- reads its output does. Splitting a turn's tokens between its calls would put +-- a number on screen that looks measured and is not. +-- +-- What IS measured is the size of what came back, which the PostToolUse hook +-- already delivers in `tool_response`. It answers the question the call count +-- cannot: on one real machine Bash was called 22× more often than Read and +-- returned a quarter as much text. Read is what fills a context; Bash is what +-- fills a list. +-- +-- Stored rather than derived. `SUM(LENGTH(json_extract(payload, ...)))` over +-- 89k tool events takes 1.3s on a 641MB database — fine once, far too slow for +-- a screen that refreshes every five seconds. +ALTER TABLE events ADD COLUMN tool_bytes INTEGER NOT NULL DEFAULT 0; + +-- Backfilled here rather than lazily: the figure is a lifetime total, so a +-- column that only fills going forward would read as "Read returned nothing" +-- until enough new history accumulated to hide the gap. +UPDATE events +SET tool_bytes = COALESCE(LENGTH(json_extract(payload, '$.tool_response')), 0) +WHERE kind = 'tool.post'; + +-- Covering index for the tool tables. +-- +-- Without it the query finds its rows by (kind, ts) and then fetches each one +-- from the table to read `tool` and `tool_bytes` — and those rows also hold the +-- whole payload, which on a 641MB database was most of the 2.1s it took. With +-- every column in the index the table is never touched: 0.05s, measured on the +-- owner's 254k-event database. +CREATE INDEX IF NOT EXISTS idx_events_tool_dist + ON events(kind, ts, tool, tool_bytes) + WHERE tool IS NOT NULL AND tool != ''; diff --git a/internal/store/migrations/0019_drop_superseded_tool_index.sql b/internal/store/migrations/0019_drop_superseded_tool_index.sql new file mode 100644 index 0000000..4f1215c --- /dev/null +++ b/internal/store/migrations/0019_drop_superseded_tool_index.sql @@ -0,0 +1,12 @@ +-- Drop the index 0018 superseded. +-- +-- 0016 added (kind, ts, tool) so the ALL TIME tool table was answered from a +-- covering index. 0018 needs `tool_bytes` in it too, and its index is the same +-- three columns with that one on the end — so the older index now answers +-- nothing the newer one doesn't, and keeping both means maintaining two copies +-- of the same thing on every event insert. +-- +-- This is its own migration rather than a line in 0018 because 0018 has already +-- run on the databases that matter; an edit to an applied migration is an edit +-- nobody receives. +DROP INDEX IF EXISTS idx_events_kind_ts_tool; diff --git a/internal/store/queries.go b/internal/store/queries.go index c12f722..2bf8212 100644 --- a/internal/store/queries.go +++ b/internal/store/queries.go @@ -136,12 +136,17 @@ func InsertEvent(ctx context.Context, q Querier, ev *event.Event) (int64, error) touch = d } } + // How much this call handed back, measured once here rather than extracted + // from the payload on every read: over 89k tool events that cost 1.3s on a + // 641MB database, and this screen refreshes every five seconds. + toolBytes := toolResponseLen(ev) + res, err := q.ExecContext(ctx, ` - INSERT INTO events(ts, session_id, source, kind, tool, payload, tokens_in, tokens_out, cache_read, cache_write, cost_usd, key, model, cache_write_1h, agent_id, msg_id, touch_dir) - VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + INSERT INTO events(ts, session_id, source, kind, tool, payload, tokens_in, tokens_out, cache_read, cache_write, cost_usd, key, model, cache_write_1h, agent_id, msg_id, touch_dir, tool_bytes) + VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(session_id, key) WHERE key IS NOT NULL DO NOTHING`, ev.Ts.UnixMilli(), ev.SessionID, string(ev.Source), string(ev.Kind), nullStr(ev.Tool), string(ev.Payload), - tin, tout, cr, cw, cost, key, nullStr(ev.Model), cw1h, nullStr(ev.AgentID), nullStr(ev.MsgID), touch) + tin, tout, cr, cw, cost, key, nullStr(ev.Model), cw1h, nullStr(ev.AgentID), nullStr(ev.MsgID), touch, toolBytes) if err != nil { return 0, fmt.Errorf("insert event: %w", err) } @@ -1717,6 +1722,32 @@ func b2i(b bool) int { type ToolCount struct { Tool string `json:"tool"` Count int64 `json:"count"` + // Bytes is how much this tool handed back, summed. Not tokens: a tool + // spends none — the turn that reads its output does — and splitting a + // turn's tokens between its calls would put a figure on screen that looks + // measured and is not. This is the size of what came back, which is + // measured exactly and answers what the call count cannot: on one machine + // Bash was called 22x more often than Read and returned a quarter as much. + Bytes int64 `json:"bytes"` +} + +// toolResponseLen measures what a tool handed back, in bytes of its response. +// +// Zero for anything that is not a completed tool call. It is deliberately a +// size and not a token count: a tool spends no tokens — the turn that reads its +// output does — so any per-tool token figure would be a turn's tokens divided +// up, which looks measured and is not. +func toolResponseLen(ev *event.Event) int64 { + if ev.Kind != event.KindToolPost || len(ev.Payload) == 0 { + return 0 + } + var p struct { + ToolResponse json.RawMessage `json:"tool_response"` + } + if err := json.Unmarshal(ev.Payload, &p); err != nil { + return 0 + } + return int64(len(p.ToolResponse)) } // ToolDistribution counts tool.pre events by tool since fromMs (0 = all time). @@ -1724,7 +1755,23 @@ func ToolDistribution(ctx context.Context, q Querier, fromMs int64, limit int) ( if limit <= 0 { limit = 50 } - rows, err := q.QueryContext(ctx, `SELECT COALESCE(tool,'?'), COUNT(*) FROM events WHERE kind = 'tool.pre' AND ts >= ? GROUP BY tool ORDER BY 2 DESC LIMIT ?`, fromMs, limit) + // Counts come from tool.pre and sizes from tool.post, because only the + // post carries the response — one pass over both kinds rather than two + // queries and a join in Go. + // + // tool_bytes is a stored column, not `json_extract` at read time: over 89k + // tool events that took 1.3s on a 641MB database, which is far too slow for + // a screen that refreshes every five seconds. Computed once when the event + // is written, where it costs nothing. + rows, err := q.QueryContext(ctx, ` + SELECT COALESCE(tool,'?') AS t, + SUM(CASE WHEN kind = 'tool.pre' THEN 1 ELSE 0 END) AS calls, + COALESCE(SUM(tool_bytes), 0) AS bytes + FROM events + WHERE kind IN ('tool.pre','tool.post') AND tool != '' AND ts >= ? + GROUP BY tool + ORDER BY calls DESC + LIMIT ?`, fromMs, limit) if err != nil { return nil, err } @@ -1732,7 +1779,7 @@ func ToolDistribution(ctx context.Context, q Querier, fromMs int64, limit int) ( var out []ToolCount for rows.Next() { var t ToolCount - if err := rows.Scan(&t.Tool, &t.Count); err != nil { + if err := rows.Scan(&t.Tool, &t.Count, &t.Bytes); err != nil { return nil, err } out = append(out, t) diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 9aa109f..f567d20 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -815,3 +815,94 @@ func TestUnpricedIgnoresTurnsWithNoTokens(t *testing.T) { } func intPtr(v int) *int { return &v } + +// What a tool handed back is measured; what it cost in tokens is not. +// +// A tool spends no tokens — the turn that reads its output does — so any +// per-tool token figure could only be a turn's tokens divided between its +// calls, which looks measured and is not. The size of the response is the +// honest thing the call count cannot say: on one real machine Bash was called +// 22x more often than Read and handed back a quarter as much text. +func TestToolBytesAreMeasuredFromTheResponse(t *testing.T) { + ctx := context.Background() + s := openTest(t) + + n := 0 + post := func(tool, response string) { + t.Helper() + n++ + payload := fmt.Sprintf(`{"tool_name":%q,"tool_response":%q}`, tool, response) + if _, err := InsertEvent(ctx, s.DB(), &event.Event{ + Ts: time.Unix(1000, 0), SessionID: "s1", Source: event.SourceHook, + Kind: event.KindToolPost, Tool: tool, Payload: json.RawMessage(payload), + Key: fmt.Sprintf("post-%d", n), + }); err != nil { + t.Fatal(err) + } + } + pre := func(tool, key string) { + t.Helper() + if _, err := InsertEvent(ctx, s.DB(), &event.Event{ + Ts: time.Unix(1000, 0), SessionID: "s1", Source: event.SourceHook, + Kind: event.KindToolPre, Tool: tool, Payload: json.RawMessage(`{}`), Key: key, + }); err != nil { + t.Fatal(err) + } + } + + // Read: called twice, hands back a lot. Bash: called four times, hands back + // almost nothing. That inversion is the whole point of the column. + big := strings.Repeat("x", 4000) + pre("Read", "r1") + pre("Read", "r2") + post("Read", big) + post("Read", big) + for i := 0; i < 4; i++ { + pre("Bash", fmt.Sprintf("b%d", i)) + post("Bash", fmt.Sprintf("ok%d", i)) + } + + got, err := ToolDistribution(ctx, s.DB(), 0, 10) + if err != nil { + t.Fatal(err) + } + by := map[string]ToolCount{} + for _, r := range got { + by[r.Tool] = r + } + if by["Bash"].Count != 4 { + t.Errorf("Bash calls = %d, want 4", by["Bash"].Count) + } + if by["Read"].Count != 2 { + t.Errorf("Read calls = %d, want 2", by["Read"].Count) + } + // The inversion: fewer calls, far more returned. + if by["Read"].Bytes <= by["Bash"].Bytes { + t.Errorf("Read returned %d bytes and Bash %d — the column shows nothing the count does not", + by["Read"].Bytes, by["Bash"].Bytes) + } + // Counted from tool.post only: counting the pre as well would double it. + if by["Read"].Bytes < 8000 { + t.Errorf("Read bytes = %d, want about 8000 for two 4000-byte responses", by["Read"].Bytes) + } +} + +func TestAToolCallWithNoResponseCountsZeroBytes(t *testing.T) { + // A pre event, a payload without the field, a payload that is not JSON: + // none of them is an error, and none of them should invent a size. + ctx := context.Background() + s := openTest(t) + if _, err := InsertEvent(ctx, s.DB(), &event.Event{ + Ts: time.Unix(1000, 0), SessionID: "s1", Source: event.SourceHook, + Kind: event.KindToolPre, Tool: "Bash", Payload: json.RawMessage(`{"tool_name":"Bash"}`), Key: "k1", + }); err != nil { + t.Fatal(err) + } + got, err := ToolDistribution(ctx, s.DB(), 0, 10) + if err != nil { + t.Fatal(err) + } + if len(got) != 1 || got[0].Bytes != 0 { + t.Errorf("a call with no response reported %+v", got) + } +} diff --git a/ui/src/components/Breakdown.tsx b/ui/src/components/Breakdown.tsx index 1eb67d4..d5e1a38 100644 --- a/ui/src/components/Breakdown.tsx +++ b/ui/src/components/Breakdown.tsx @@ -16,7 +16,7 @@ */ import { api } from '@/lib/api' import { useApi } from '@/lib/useApi' -import { fmtTokens, fmtTool, fmtUSD } from '@/lib/format' +import { fmtBytes, fmtTokens, fmtTool, fmtUSD } from '@/lib/format' import { Panel } from '@/components/ui' import { ShareCard } from '@/components/Share' import { ShareNudge } from '@/components/ShareNudge' @@ -68,18 +68,23 @@ export function BreakdownPanel() {
({ key: t.tool, label: fmtTool(t.tool), value: t.count.toLocaleString('en-US'), + // What came back, which the call count cannot say: Bash is called + // far more often than Read and hands back a fraction as much. Not + // tokens — see ToolCount — but the size is measured exactly, and + // it is what fills a context and gets billed on the next turn. + sub: t.bytes > 0 ? fmtBytes(t.bytes) : '', share: allCalls > 0 ? (100 * t.count) / allCalls : null, frac: topCalls > 0 ? t.count / topCalls : 0, }))} /> ({ key: m.model, label: m.model || 'unknown', @@ -123,11 +128,15 @@ export function BreakdownPanel() { /** A short ranked list — label, bar, figure — used for both breakdowns. */ function Bars({ title, - note, + cols, rows, }: { title: string - note: string + /** What each numeric column is, in the order they appear. Three figures in a + * row with nothing over them is a puzzle: `$7,587.14 · 12.01B · 58%` reads + * as three unrelated numbers until you have worked out which is which, and + * a note saying "by cost" describes the sort order, not the columns. */ + cols: { value: string; sub?: string; share: string } rows: { key: string label: string @@ -142,9 +151,21 @@ function Bars({ if (rows.length === 0) return null return (
-
- {title} - {note} + {/* One row: the table's name on the left, its column names over their own + * figures on the right. Two stacked rows — a title, then a header — + * spent a line of vertical space saying what one line says, and put a + * gap between the heading and the first row it heads. The widths match + * the rows below, so each name sits over its column. */} +
+ {/* Allowed to run past the label column rather than wrap: "Where the + * money went" broke onto a second line inside w-36 and pushed the + * column names above the title they sit beside. It is a heading, not + * a cell — nothing is lining up underneath it. */} + {title} + + {cols.value} + {cols.sub ?? ''} + {cols.share}
{rows.map((r) => ( diff --git a/ui/src/components/CostBasis.test.tsx b/ui/src/components/CostBasis.test.tsx index d9f5f9f..52c0312 100644 --- a/ui/src/components/CostBasis.test.tsx +++ b/ui/src/components/CostBasis.test.tsx @@ -24,7 +24,10 @@ describe('costBasis', () => { const s = costBasis(plan({ plan_kind: 'metered', plan_label: 'API' })) expect(s).not.toContain('not a bill') expect(s).toContain('your bill') - expect(costBasisLong(plan({ plan_kind: 'metered' }))).toContain('approximately') + // Hedged, but as a bill rather than as an equivalent. The word itself does + // not matter — "approximately" and "roughly" both do the job — so this + // asserts the claim, not the vocabulary. + expect(costBasisLong(plan({ plan_kind: 'metered' }))).toMatch(/roughly|approximate/i) }) it('claims neither when the plan is unknown', () => { diff --git a/ui/src/components/CostBasis.tsx b/ui/src/components/CostBasis.tsx index 1da68c0..5a02001 100644 --- a/ui/src/components/CostBasis.tsx +++ b/ui/src/components/CostBasis.tsx @@ -33,12 +33,12 @@ export function costBasis(plan?: Settings): string { /** The longer form, for a panel header or a tooltip. */ export function costBasisLong(plan?: Settings): string { if (plan?.plan_kind === 'metered') { - return 'Priced from your captured tokens at Anthropic list prices. You are billed per token, so this is approximately your actual cost.' + return 'Roughly your real bill — you pay per token. At Anthropic list prices.' } if (plan?.plan_kind === 'flat') { - return `Priced from your captured tokens at Anthropic list prices. You pay ${plan.plan_label || 'a flat plan'}, so this is what the same work would have cost through the API — not money out of pocket.` + return `At Anthropic list prices — what this work would cost through the API. You pay ${plan.plan_label || 'a flat plan'}, so it is not money out of pocket.` } - return 'Priced from your captured tokens at Anthropic list prices. Whether that is your actual bill depends on how you pay — set your plan in the header.' + return 'At Anthropic list prices. Set your plan in the header to see how it compares to your bill.' } /** A small inline note for a panel header. */ diff --git a/ui/src/components/Notes.test.tsx b/ui/src/components/Notes.test.tsx index 63af9c3..c997dc1 100644 --- a/ui/src/components/Notes.test.tsx +++ b/ui/src/components/Notes.test.tsx @@ -59,10 +59,16 @@ describe('NoteCard', () => { expect(screen.getByText('caprock')).toBeTruthy() }) - it('preserves the newlines a summary depends on', () => { - const text = 'What changed:\n\n- one\n- two' - const { container } = render() - const body = container.querySelector('.whitespace-pre-wrap') - expect(body?.textContent).toBe(text) + it('renders the structure a summary depends on, rather than its markup', () => { + // This used to assert the opposite — that the raw text survived intact — + // and it passed while readers saw `**bold**` with its asterisks and a + // table collapsed into `| | |`. Keeping the line breaks is not the same as + // keeping the structure, and only the second one is readable. + const text = 'What changed:\n\n- one\n- **two**' + render() + expect(screen.getByText('one')).toBeInTheDocument() + expect(screen.getByText('two').tagName).toBe('STRONG') + expect(document.body.textContent).not.toContain('**') + expect(document.body.textContent).not.toContain('- one') }) }) diff --git a/ui/src/components/Notes.tsx b/ui/src/components/Notes.tsx index e16e827..4a252cc 100644 --- a/ui/src/components/Notes.tsx +++ b/ui/src/components/Notes.tsx @@ -19,6 +19,7 @@ import { useApi } from '@/lib/useApi' import { fmtAgo, shortId } from '@/lib/format' import { Empty, Skeleton } from '@/components/ui' import { href } from '@/lib/router' +import { Prose } from './Prose' export function SessionNotes({ id, now }: { id: string; now: number }) { const q = useApi(() => api.notes(id), [id], { intervalMs: 10000 }) @@ -102,10 +103,14 @@ export function NoteCard({ note, now, showSession = false }: { {note.fragment && · mid-thought} {fmtAgo(note.ts, now)}
- {/* Preserve the newlines and spacing Claude wrote — the structure of a - * summary (lists, code, headings) is most of its readability. */} -
- {body} + {/* Rendered, not preserved. The comment here used to say the structure + * of a summary is most of its readability — true, and the code then + * kept only the line breaks, so a reader got `**bold**` with its + * asterisks and a Markdown table collapsed into `| | |`. Claude writes + * lists, headings and tables; showing them as the markup they are made + * of is showing the reader the wrong half. */} +
+
{long && ( {open && { onSave(s); setOpen(false) }} />} diff --git a/ui/src/components/Projects.test.tsx b/ui/src/components/Projects.test.tsx index eec0138..4b8baee 100644 --- a/ui/src/components/Projects.test.tsx +++ b/ui/src/components/Projects.test.tsx @@ -316,7 +316,7 @@ describe('ProjectsPanel figures', () => { // Each explanation rides on its own row, and they must say DIFFERENT things // — the whole point of splitting them is that the reasons differ. const outsideHover = screen.getByText('outside the repository').getAttribute('title') ?? '' - expect(outsideHover).toMatch(/outside this repository/i) + expect(outsideHover).toMatch(/files live elsewhere/i) expect(outsideHover).toMatch(/scratchpad|notes|test-output/i) const wideHover = screen.getByText('repository-wide work').getAttribute('title') ?? '' expect(wideHover).toMatch(/before Claude had touched any file/i) diff --git a/ui/src/components/Projects.tsx b/ui/src/components/Projects.tsx index e4c2f1d..219aabf 100644 --- a/ui/src/components/Projects.tsx +++ b/ui/src/components/Projects.tsx @@ -178,11 +178,7 @@ const SPARK_BASIS = 'tokens' as const * sentence shown on hover. */ const TOUCH_RULE = - 'A turn counts toward the directory of the most recent file it touched, and keeps counting there ' + - 'until it touches a file somewhere else — so the commands, tests and searches between two edits ' + - 'count toward the directory being worked on. Reading, editing or writing a file counts as touching ' + - 'it; running a command does not. Each turn goes whole to one row, never split between two, so the ' + - 'rows add up to the repository total exactly.' + 'Cost is charged to the folder Claude was last working in. Rows add up to the repository total.' /** * The two rows that are NOT directories, and the sentences that explain them. @@ -218,10 +214,8 @@ const REPO_WIDE_RULE = 'guessed onto the directory the session reached later.' const OUTSIDE_LABEL = 'outside the repository' const OUTSIDE_RULE = - 'Turns whose most recent file touch was outside this repository — Claude’s notes on the ' + - 'project, agent scratchpads, test-output directories, or another checkout. This is real ' + - 'work and it counts toward the repository total, but it happened outside the tree, so it ' + - 'is not charged to any directory inside it.' + 'Work on this project whose files live elsewhere — Claude’s notes, scratchpads, test output. ' + + 'Counted in the repository total, but not under any folder.' export function ProjectsPanel({ sessions, agent }: { sessions: SessionSummary[]; agent: AgentFilter }) { // 7d is the default. "today" is near-empty most mornings and would make the diff --git a/ui/src/components/ReleaseNotes.test.tsx b/ui/src/components/Prose.test.tsx similarity index 88% rename from ui/src/components/ReleaseNotes.test.tsx rename to ui/src/components/Prose.test.tsx index 6fd7f4a..52fdc84 100644 --- a/ui/src/components/ReleaseNotes.test.tsx +++ b/ui/src/components/Prose.test.tsx @@ -8,7 +8,7 @@ */ import { render, screen } from '@testing-library/react' import { describe, expect, it } from 'vitest' -import { ReleaseNotes, parseNotes, inlines } from './ReleaseNotes' +import { Prose, parseNotes, inlines } from './Prose' const real = `### Fixed @@ -20,13 +20,13 @@ const real = `### Fixed describe('what a reader actually sees', () => { it('turns a heading into a heading, not into hashes', () => { - render() + render() expect(screen.getByText('Fixed').tagName).toBe('H3') expect(screen.queryByText(/###/)).toBeNull() }) it('bolds without showing the asterisks', () => { - render() + render() const strong = screen.getByText(/Why a weekly report never arrived/) expect(strong.tagName).toBe('STRONG') expect(document.body.textContent).not.toContain('**') @@ -44,7 +44,7 @@ describe('what a reader actually sees', () => { }) it('renders a bullet as one, without the dash', () => { - render() + render() expect(screen.getByText('something changed')).toBeInTheDocument() expect(document.body.textContent).not.toContain('- something') }) @@ -56,14 +56,14 @@ describe('remote text cannot become markup', () => { // open — which was the right instinct behind showing raw text, kept here // without the cost of being unreadable. it('shows html as text', () => { - render( and bold'} />) + render( and bold'} />) expect(document.querySelector('img')).toBeNull() expect(document.querySelector('b')).toBeNull() expect(document.body.textContent).toContain('') }) it('never produces a link', () => { - render() + render() expect(document.querySelector('a')).toBeNull() }) diff --git a/ui/src/components/ReleaseNotes.tsx b/ui/src/components/Prose.tsx similarity index 63% rename from ui/src/components/ReleaseNotes.tsx rename to ui/src/components/Prose.tsx index 347eda0..5314fdc 100644 --- a/ui/src/components/ReleaseNotes.tsx +++ b/ui/src/components/Prose.tsx @@ -1,5 +1,9 @@ /** - * Release notes, rendered rather than dumped. + * The Markdown Caprock displays, rendered rather than dumped. + * + * Used for release notes and for the answers Claude wrote. Both arrived as raw + * text for the same reason and looked equally wrong: `### Fixed` as a literal + * heading, asterisks around bold phrases, and a table collapsed into `| | |`. * * These used to be shown as preformatted text on the reasoning that release * bodies are remote content and a local-first tool has no business rendering @@ -21,6 +25,8 @@ type Block = | { kind: 'heading'; text: string } | { kind: 'bullet'; parts: Inline[] } | { kind: 'para'; parts: Inline[] } + | { kind: 'table'; rows: Inline[][][] } + | { kind: 'quote'; parts: Inline[] } type Inline = { text: string; bold: boolean; code: boolean } @@ -52,6 +58,7 @@ export function parseNotes(src: string): Block[] { const out: Block[] = [] let para: string[] = [] let bullet: string[] = [] + let table: string[] = [] const flushPara = () => { if (para.length) out.push({ kind: 'para', parts: inlines(para.join(' ')) }) @@ -61,7 +68,29 @@ export function parseNotes(src: string): Block[] { if (bullet.length) out.push({ kind: 'bullet', parts: inlines(bullet.join(' ')) }) bullet = [] } + // A Markdown table read as plain text is the worst case of all: `| | |` + // followed by `|---|---|` and then rows whose columns no longer line up, + // which is what an answer containing one looked like on the Answers screen. + const flushTable = () => { + if (table.length) { + const rows = table + // The separator row carries no content — it only told a parser which + // line was the header, and there is no header row worth keeping when + // the table is two columns of a summary. + .filter((line) => !/^[|\s:-]+$/.test(line)) + .map((line) => + line + .replace(/^\||\|$/g, '') + .split('|') + .map((cell) => inlines(cell.trim())), + ) + .filter((cells) => cells.some((c) => c.some((p) => p.text.trim() !== ''))) + if (rows.length) out.push({ kind: 'table', rows }) + } + table = [] + } const flush = () => { + flushTable() flushBullet() flushPara() } @@ -80,6 +109,21 @@ export function parseNotes(src: string): Block[] { out.push({ kind: 'heading', text: heading[1] ?? '' }) continue } + if (trimmed.startsWith('|')) { + flushBullet() + flushPara() + table.push(trimmed) + continue + } + flushTable() + + const quoted = /^>\s?(.*)$/.exec(trimmed) + if (quoted) { + flush() + out.push({ kind: 'quote', parts: inlines(quoted[1] ?? '') }) + continue + } + const item = /^[-*•]\s+(.*)$/.exec(trimmed) if (item) { flush() @@ -98,7 +142,7 @@ export function parseNotes(src: string): Block[] { } /** Renders parsed notes. No `dangerouslySetInnerHTML` anywhere in this file. */ -export function ReleaseNotes({ text }: { text: string }) { +export function Prose({ text }: { text: string }) { const blocks = parseNotes(text) return (
@@ -113,6 +157,32 @@ export function ReleaseNotes({ text }: { text: string }) { ) } + if (b.kind === 'table') { + return ( +
+ + + {b.rows.map((cells, r) => ( + + {cells.map((cell, c) => ( + + ))} + + ))} + +
+ {renderInline(cell)} +
+
+ ) + } + if (b.kind === 'quote') { + return ( +

+ {renderInline(b.parts)} +

+ ) + } if (b.kind === 'bullet') { return (
diff --git a/ui/src/components/Pulse.tsx b/ui/src/components/Pulse.tsx index 4734945..66d4f01 100644 --- a/ui/src/components/Pulse.tsx +++ b/ui/src/components/Pulse.tsx @@ -118,7 +118,7 @@ export function PulsePanel({ sessions, now }: { sessions: SessionSummary[]; now: * lot of context — so they name the comparison rather than implying an * absolute scale. */}
- bar height = turns and tools · colour = what the minute cost + bar height = turns and tools · colour = what the minute cost idle diff --git a/ui/src/components/Share.tsx b/ui/src/components/Share.tsx index dc11ca7..545cd34 100644 --- a/ui/src/components/Share.tsx +++ b/ui/src/components/Share.tsx @@ -21,10 +21,10 @@ * The card itself carries `caprock.dev`, so the link travels with the image * even when someone posts it without the text. */ -import { useState } from 'react' +import { useEffect, useState } from 'react' import { useApi } from '@/lib/useApi' import { api, type History } from '@/lib/api' -import { cardFilename, collectCardData, drawShareCard } from './ShareCard' +import { cardFilename, collectCardData, drawShareCard, PERIOD_LABEL, type SharePeriod } from './ShareCard' import { fmtUSD } from '@/lib/format' /** The words that travel with the image. Measured figures, no adjectives. */ @@ -37,16 +37,26 @@ export function ShareButton() { const [open, setOpen] = useState(false) return ( <> - {/* Loud on purpose. As grey 11px lowercase text between "feedback" and - * the build label, this was invisible — the owner, who wrote the - * feature, could not find it on his own dashboard. Sharing is the one - * thing here that travels, so it gets a border and the accent colour - * rather than the muted tone every other topbar item wears. */} + {/* Loud on purpose, and twice now not loud enough. + * + * A tinted border in the accent colour still lost, because everything + * around it is the same 11px and the premium button beside it is a + * solid block of colour: an outline cannot win an argument with a fill. + * This is filled, a size up, and carries an icon, so the eye finds it + * without reading the row. + * + * It earns that: sharing is the only thing on this dashboard that + * leaves the machine, and somebody who has just had a good week has + * nowhere to say so. */} {open && setOpen(false)} />} @@ -66,12 +76,40 @@ export function ShareDialog({ onClose }: { onClose: () => void }) { const [drawing, setDrawing] = useState(false) const [locked, setLocked] = useState(false) const [note, setNote] = useState('') + // Which stretch the card is about. Defaults to the week: a working week is + // the thing people actually finish and want to show, and an all-time total + // shared on its own reads as a boast rather than a result. + const [period, setPeriod] = useState('7d') + // The picture itself, drawn as soon as the sheet opens and again whenever + // the period changes. + // + // Without it the period buttons are a promise about a file nobody has seen: + // you press Save, open your downloads, and only then find out what you + // chose. A card is a picture — the way to choose one is to look at it. + const [preview, setPreview] = useState('') + + // Redrawn on every period change. Each draw is one canvas and three cached + // API calls, so it costs less than the click that opened the sheet. + useEffect(() => { + let live = true + let url = '' + void (async () => { + const d = await collectCardData(period) + const blob = await drawShareCard(d) + if (!blob || !live) return + url = URL.createObjectURL(blob) + setPreview(url) + })() + return () => { + live = false + // Revoked on the way out: a blob URL held after its is gone keeps + // the whole bitmap alive, and this component redraws on every click. + if (url) URL.revokeObjectURL(url) + } + }, [period]) const build = async () => { - // No period to choose any more: the card shows today, the week, the month - // and all time at once, which is what made the picker redundant rather - // than a feature worth keeping. - const [d, h] = await Promise.all([collectCardData(), api.history('all')]) + const [d, h] = await Promise.all([collectCardData(period), api.history('all')]) const blob = await drawShareCard(d) return { blob, text: caption(h.totals) } } @@ -154,6 +192,44 @@ export function ShareDialog({ onClose }: { onClose: () => void }) { * were all true and none of them was the question a person has * standing in front of this dialog, which is: what happens if I * press it. */} + {/* Which stretch, before where it goes. The card shows every period + * either way — this decides which one is the headline, and what the + * heading claims. */} +
+ Show + {(['today', '7d', '30d', 'all'] as SharePeriod[]).map((p) => ( + + ))} +
+ + {/* The card, at the size it will be seen. Above the buttons, because + * it is the thing being decided — the buttons only choose where it + * goes. A fixed aspect box so switching period does not make the + * dialog jump while the next draw lands. */} +
+ {preview ? ( + Your figures, as they will be shared + ) : ( +
+ drawing… +
+ )} +
+
{canNative && (
- +
{/* The changelog on the site, not the release on GitHub. Somebody diff --git a/ui/src/components/Terminal.test.tsx b/ui/src/components/Terminal.test.tsx index 6a297dc..c9c0d57 100644 --- a/ui/src/components/Terminal.test.tsx +++ b/ui/src/components/Terminal.test.tsx @@ -158,12 +158,13 @@ describe('a session Caprock did not start', () => { // It was a link to the main screen, which is navigation dressed as an // offer: it moved the reader away from what they were doing and left them // to find the real button themselves. - expect(screen.getByRole('button', { name: /launch a new claude code session/i })).toBeTruthy() + expect(screen.getByRole('button', { name: /start a session here/i })).toBeTruthy() expect(screen.queryByRole('link', { name: /start|launch/i })).toBeNull() // And it must say what happens to the session already running, because the // reasonable fear about a button on this screen is that it disturbs it. - expect(document.body.textContent).toMatch(/keeps running, untouched/i) + // The wording may change; the promise may not. + expect(document.body.textContent).toMatch(/this one keeps running|keeps running, untouched/i) // And none of the vocabulary that only makes sense from inside. for (const jargon of [/externally started/i, /does not own/i, /spawn/i]) { diff --git a/ui/src/components/Terminal.tsx b/ui/src/components/Terminal.tsx index eedaf1e..fb43be2 100644 --- a/ui/src/components/Terminal.tsx +++ b/ui/src/components/Terminal.tsx @@ -365,19 +365,18 @@ export function TerminalView({ onClick={() => setSpawning(true)} className="rounded-sm bg-accent px-3.5 py-2 text-[13px] font-medium text-bg hover:brightness-110" > - Launch a new Claude Code session here → + Start a session here → + {/* One paragraph, not three. The two that used to follow this both said + * the same thing — your session is safe — and the second said it as an + * apology for a policy the reader had not questioned. What they need + * to know is what the button does. */}

- Runs a second claude in{' '} - {cwd ? {cwd} : 'this repository'} and gives it a - terminal you can type in. This session keeps running, untouched. + Opens a second claude in{' '} + {cwd ? {cwd} : 'this repository'}, with a + terminal you can type in. This one keeps running.

{spawning && setSpawning(false)} initialCwd={cwd ?? ''} />} - -

- Caprock never types into a process it did not start — including this - one, which stays visible here and keeps being measured. -

) } diff --git a/ui/src/components/WeeklyReport.tsx b/ui/src/components/WeeklyReport.tsx index 2f35734..f834910 100644 --- a/ui/src/components/WeeklyReport.tsx +++ b/ui/src/components/WeeklyReport.tsx @@ -119,10 +119,8 @@ export function WeeklyReport() { * this it reads as three minutes of setup for no reason, and the * reason is the whole point of the product. */} - It is your own bot, not one of ours, and that is deliberate: the message goes - straight from this machine to Telegram, so your figures never pass through - anybody's server. A shared bot would mean shipping its token inside a public - binary, and routing what you spend through us to deliver it. + Your own bot, so your figures go straight from this machine to Telegram — never + through anybody's server. @@ -135,11 +133,10 @@ export function WeeklyReport() { onChange={(e) => setChat(e.target.value)} /> - Write to your bot first — find it by its username, press Start, send - anything. Telegram does not let a bot message you until you have. Then open{' '} + Message your bot first — find it by username, press Start, send + anything. Then open{' '} api.telegram.org/bot<token>/getUpdates and copy{' '} - chat.id. For a channel instead, add the bot as an - administrator; its id starts with a minus. + chat.id. diff --git a/ui/src/components/WorkMix.tsx b/ui/src/components/WorkMix.tsx index d872ed6..fbf5464 100644 --- a/ui/src/components/WorkMix.tsx +++ b/ui/src/components/WorkMix.tsx @@ -45,14 +45,12 @@ const LABELS: Record = { command: { label: 'running commands', title: - 'Turns that ran a shell command — builds, tests, git, anything through Bash. ' + - 'The command itself is free; what costs is the turn that issued it and read its output.', + 'Turns that ran a shell command — builds, tests, git, anything through Bash.', }, read: { label: 'reading and searching', title: - 'Turns that read or searched the codebase — Read, Grep, Glob. ' + - 'The file contents enter the prompt and are billed, which is why reading is not free.', + 'Turns that read or searched the codebase — Read, Grep, Glob.', }, web: { label: 'web research', @@ -71,9 +69,7 @@ const LABELS: Record = { none: { label: 'no tool call', title: - 'Turns that called no tool at all. They may have been reasoning, planning, answering a ' + - 'question or writing prose — Caprock records which tools ran, not what a turn was thinking, ' + - 'so it does not claim to know which.', + 'Turns that called no tool — reasoning, planning, or writing prose.', }, } @@ -84,10 +80,7 @@ const LABELS: Record = { * Kept in sync with store.WorkKindRule (Go), which is the definition. */ const WORK_RULE = - 'Each turn counts toward one kind of work, decided by the tools it called: writing a file wins ' + - 'over running a command, which wins over reading or searching, then web, then an MCP tool, then ' + - 'anything else. A turn that called no tool is counted as exactly that. Each turn goes whole to ' + - 'one row, never split, so the rows add up to the total exactly.' + 'Each turn counts once, under its most expensive kind of tool. Rows add up to the total.' export function WorkMix({ summary }: { summary?: Summary }) { const s = summary @@ -122,9 +115,8 @@ export function WorkMix({ summary }: { summary?: Summary }) { {degraded && (
- {unlinked.toLocaleString()} tool calls in this range could not be matched to the turn that - paid for them, so their cost is counted under “no tool call” rather than the work they - actually did. Every other row is understated by up to that much. + {unlinked.toLocaleString()} tool calls could not be matched to a turn, so their cost lands + under “no tool call”. The other rows are understated.
)} diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index 560d024..399a695 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -318,7 +318,14 @@ export interface UpdateStatus { export interface DailyStat { day: string; project: string; model: string; tokens_total: number; cost_usd: number; sessions: number } -export interface ToolCount { tool: string; count: number } +export interface ToolCount { + tool: string + count: number + /** Bytes this tool handed back, summed. Not tokens: a tool spends none — the + * turn that reads its output does — so a per-tool token figure could only + * be a turn's tokens divided up, which looks measured and is not. */ + bytes: number +} export interface HistoryTotals { sessions: number; owned_sessions: number; turns: number; tool_calls: number; files_touched: number; cost_usd: number; avg_session_sec: number; days: number; unpriced?: Unpriced } export interface Task { id: string; title: string; status: string; assignee: string; budget_usd: number; verify_rounds: number; cost_usd: number; created_at: number; updated_at: number } // The live WS "task" frame carries the on-disk hive.Task (no cost_usd — that's diff --git a/ui/src/lib/format.ts b/ui/src/lib/format.ts index bd127e3..5d2b395 100644 --- a/ui/src/lib/format.ts +++ b/ui/src/lib/format.ts @@ -30,6 +30,22 @@ export function fmtTokens(v: number | undefined | null): string { return new Intl.NumberFormat('en-US').format(v) } +/** Bytes, in the units a person reads them in. + * + * Kept separate from fmtTokens because these are not tokens and must never + * read as though they were: a tool's output is text that gets billed on the + * *next* turn, at a ratio that depends on what the text is. MB and KB say + * "this is a size"; a bare "58.7M" beside a token column would not. */ +export function fmtBytes(v: number | undefined | null): string { + if (finite(v) === null) return '—' + v = v as number + const abs = Math.abs(v) + if (abs >= 1_000_000_000) return `${(v / 1_000_000_000).toFixed(1)}GB` + if (abs >= 1_000_000) return `${(v / 1_000_000).toFixed(1)}MB` + if (abs >= 1_000) return `${Math.round(v / 1_000)}KB` + return `${v}B` +} + export function fmtPct(v: number | undefined | null, digits = 0): string { if (finite(v) === null) return '—' // Round DOWN, not to nearest: a 99.514% cache hit rate shown as "100%" reads diff --git a/ui/src/screens/Cost.tsx b/ui/src/screens/Cost.tsx index 76bc8ce..80bfbf6 100644 --- a/ui/src/screens/Cost.tsx +++ b/ui/src/screens/Cost.tsx @@ -107,6 +107,18 @@ export function CostScreen() { by cost}> {!s ? : s.models.length === 0 && } + {/* Named columns. Four figures in a row with nothing over them is a + * puzzle, and "by cost" in the corner describes the sort order + * rather than the columns. */} + + + + + + + + + {(s?.models ?? []).map((m) => ( @@ -129,6 +141,14 @@ export function CostScreen() { by cost}> {!s ? : s.projects.length === 0 && }
modelturnstokenscostshare
+ + + + + + + + {(s?.projects ?? []).map((p) => ( @@ -212,14 +232,13 @@ export function CostScreen() { ) : (
- No window state yet. Caprock reads this from Claude Code's status line, so it appears - once a Pro or Max session has run with caprock statusline registered — - caprock up offers to do that. API-billed usage has no windows to report. + Nothing yet. Run caprock statusline in a Pro or + Max session and your limits appear here. API billing has no windows.
)}
- Live from Claude Code's status line (Pro/Max). The percentage is your usage of the window; a - forecast is shown only when your measured pace would reach the limit before the window resets. + From Claude Code's status line. A forecast appears only when your pace would hit the + limit before the window resets.
)} @@ -227,8 +246,7 @@ export function CostScreen() {
{s && s.throttles > 0 ? `${s.throttles} rate-limit / overloaded event${s.throttles === 1 ? "" : "s"} observed in this range (from Claude Code's StopFailure hook).` - : "No rate-limit events observed in this range."}{" "} - Everything here is measured — no invented numbers. + : "No rate-limit events observed in this range."}
) diff --git a/ui/src/screens/History.tsx b/ui/src/screens/History.tsx index 4db7bb0..18d51ec 100644 --- a/ui/src/screens/History.tsx +++ b/ui/src/screens/History.tsx @@ -78,7 +78,7 @@ export function HistoryScreen() {
- by calls}> + calls}> {!d ? : d.tools.length === 0 && }
    {(d?.tools ?? []).slice(0, 18).map((t) => ( @@ -98,6 +98,17 @@ export function HistoryScreen() { by cost}> {!d ? : d.summary.models.length === 0 && }
projecttokenscostshare
+ {/* Named columns. Three figures in a row with nothing over them + * is a puzzle — "12.02B $7,595.32" reads as two unrelated + * numbers until you work out which is which, and "by cost" in + * the corner describes the sort order, not the columns. */} + + + + + + + {(d?.summary.models ?? []).map((m) => ( @@ -122,6 +133,17 @@ export function HistoryScreen() { by cost}>
modeltokenscost
+ {/* Named columns. Three figures in a row with nothing over them + * is a puzzle — "12.02B $7,595.32" reads as two unrelated + * numbers until you work out which is which, and "by cost" in + * the corner describes the sort order, not the columns. */} + + + + + + + {(d?.summary.projects ?? []).slice(0, 8).map((p) => ( diff --git a/ui/src/screens/Now.tsx b/ui/src/screens/Now.tsx index b9f149c..119b069 100644 --- a/ui/src/screens/Now.tsx +++ b/ui/src/screens/Now.tsx @@ -32,6 +32,15 @@ import { useNow } from '@/lib/useNow' * ended" toggle, which is where history belongs. */ export const NOW_WINDOW_MS = 2 * 24 * 60 * 60 * 1000 +/** Whether an answer is still on its way — as opposed to having arrived empty. + * + * Exported so the distinction is testable: conflating the two is what made a + * screen full of figures announce "nothing measured yet" for the second it + * took the first response to land. */ +export function isLoading(data: unknown, error: unknown): boolean { + return !data && !error +} + export function recentEnough(s: { last_event_at?: number | null }, now: number): boolean { // A row with no timestamp is shown rather than hidden: not knowing when // something happened is not evidence that it was long ago, and hiding a @@ -105,6 +114,11 @@ export function NowScreen() { // "Cache hit 0%" — the only coloured thing on the page was a warning about a // cache that had never been used. Nothing measured means no number to show. const measured = !!summary.data && summary.data.turns > 0 + // Not the same as "nothing measured", and saying so was a lie the first + // screen told on every load: until the first response lands there is no + // answer yet, and "nothing measured yet" is an answer. On a large database + // the all-time query takes about half a second — long enough to read. + const loading = isLoading(summary.data, summary.error) const ingestError = status.data?.ingest_error return (
@@ -124,7 +138,7 @@ export function NowScreen() { {hooksMissing && (
Hooks not installed - Activity is coming from transcripts only (a few seconds late, no tool-level detail for running commands). Run caprock hooks install for real-time narration. + Run caprock hooks install for live activity. Without it, updates lag by a few seconds. details
)} @@ -207,7 +221,7 @@ export function NowScreen() { * colour pointed away from the money. The rest are reference figures * and step down, which is what makes room for the headline. */}
- {measured ? costBasis(plan) : 'nothing measured yet'}} tone="info" size="hero" /> + {measured ? costBasis(plan) : loading ? 'reading your figures…' : 'nothing measured yet'}} tone="info" size="hero" /> @@ -230,6 +244,18 @@ export function NowScreen() { * sessions are busy, which are grinding, and which have gone quiet. */} + {/* Straight after the pulse, not at the bottom of the screen. + * + * It was last, below the activity feed and the project list, and the + * feed is tall — so the most legible thing on this screen was the thing + * you had to scroll to find. It reads as a continuation of the pulse: + * that shows the shape of the work, this shows what the work was. + * + * It was moved out of the all-time line at the top for a reason that + * still holds — expanded up there it pushed Today and the pulse below + * the fold — so it goes under the pulse rather than above it. */} + + {/* What is happening (left) beside what it costs (right). */}
- {/* The lifetime figures sit here rather than in the all-time line at the - * top: hidden in that line nobody found them, expanded there they - * pushed Today and the live pulse below the fold. Between the live - * panels and the session rows there is room, and nothing they compete - * with. */} - - {sessions.error && !sessions.data && ( {sessions.error.message} — is caprock up running? )} diff --git a/ui/src/screens/NowWindow.test.tsx b/ui/src/screens/NowWindow.test.tsx index 09b9802..8dcf451 100644 --- a/ui/src/screens/NowWindow.test.tsx +++ b/ui/src/screens/NowWindow.test.tsx @@ -8,7 +8,7 @@ * rows marked idle: true, and useless. */ import { describe, expect, it } from 'vitest' -import { recentEnough, NOW_WINDOW_MS } from './Now' +import { recentEnough, isLoading, NOW_WINDOW_MS } from './Now' const now = Date.UTC(2026, 8, 2, 12, 0, 0) const ago = (ms: number) => ({ last_event_at: now - ms }) @@ -40,3 +40,29 @@ describe('what belongs on the Now screen', () => { expect(NOW_WINDOW_MS).toBeGreaterThanOrEqual(24 * 60 * 60 * 1000) }) }) + +/** + * "Nothing measured yet" is an answer. Until the first response lands there is + * no answer, and showing one is a lie the first screen used to tell on every + * load — reported as "the data took very long to load" by someone whose data + * was there all along and arrived in under a second. + */ +describe('waiting is not the same as empty', () => { + const empty = { turns: 0 } as const + + it('is loading while nothing has arrived and nothing failed', () => { + expect(isLoading(undefined, undefined)).toBe(true) + }) + + it('is not loading once the answer is in, even when the answer is zero', () => { + // A genuinely empty machine must still see "nothing measured yet" — the + // fix is to stop guessing, not to never say it. + expect(isLoading(empty, undefined)).toBe(false) + }) + + it('is not loading when the request failed', () => { + // An error has its own message; a spinner that never stops is worse than + // a failure that says so. + expect(isLoading(undefined, new Error('nope'))).toBe(false) + }) +})
projecttokenscost