@straiffi/archon 1.2.14 → 1.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{TestsDialog-BtSHirWO.js → TestsDialog-uqH8RzXV.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CeChQYkP.js → dropdown-menu-CHiEwVjq.js} +1 -1
- package/dist/client/assets/{index-C4ASxO0G.js → index-BpEzCfrc.js} +38 -40
- package/dist/client/assets/index-U0-u592N.css +2 -0
- package/dist/client/index.html +3 -3
- package/dist/server/lib/projectMemoryPrompt.js +14 -1
- package/dist/server/lib/projectMemoryPrompt.js.map +1 -1
- package/dist/server/lib/reviewContext.js +44 -0
- package/dist/server/lib/reviewContext.js.map +1 -0
- package/dist/server/workers/review.js +62 -11
- package/dist/server/workers/review.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/index-DLjBRuBj.css +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TestsDialog-
|
|
2
|
-
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-BYbx6iT9.js";import{$ as a,A as o,At as s,B as c,Bt as l,C as u,Ct as d,D as f,Dt as p,E as m,Et as h,F as g,Ft as _,G as v,H as y,Ht as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,R as I,Rt as L,S as R,St as z,T as B,Tt as ee,U as te,Ut as ne,V,Vt as re,W as H,Wt as ie,X as ae,Y as oe,Z as se,_ as ce,_t as le,a as U,at as ue,b as de,bt as fe,c as pe,ct as me,d as he,dt as ge,et as W,f as _e,ft as ve,g as ye,gt as be,h as G,ht as xe,i as Se,it as Ce,j as we,jt as Te,k as Ee,kt as De,l as Oe,lt as ke,m as K,mt as Ae,n as je,nt as Me,o as Ne,ot as Pe,p as Fe,pt as Ie,q as Le,r as Re,rt as ze,s as Be,st as Ve,t as He,tt as Ue,u as We,ut as Ge,v as Ke,vt as qe,w as Je,wt as Ye,x as Xe,xt as Ze,y as Qe,yt as $e,z as et,zt as q}from"./dropdown-menu-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TestsDialog-uqH8RzXV.js","assets/rolldown-runtime-BYbx6iT9.js","assets/dropdown-menu-CHiEwVjq.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-BYbx6iT9.js";import{$ as a,A as o,At as s,B as c,Bt as l,C as u,Ct as d,D as f,Dt as p,E as m,Et as h,F as g,Ft as _,G as v,H as y,Ht as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,R as I,Rt as L,S as R,St as z,T as B,Tt as ee,U as te,Ut as ne,V,Vt as re,W as H,Wt as ie,X as ae,Y as oe,Z as se,_ as ce,_t as le,a as U,at as ue,b as de,bt as fe,c as pe,ct as me,d as he,dt as ge,et as W,f as _e,ft as ve,g as ye,gt as be,h as G,ht as xe,i as Se,it as Ce,j as we,jt as Te,k as Ee,kt as De,l as Oe,lt as ke,m as K,mt as Ae,n as je,nt as Me,o as Ne,ot as Pe,p as Fe,pt as Ie,q as Le,r as Re,rt as ze,s as Be,st as Ve,t as He,tt as Ue,u as We,ut as Ge,v as Ke,vt as qe,w as Je,wt as Ye,x as Xe,xt as Ze,y as Qe,yt as $e,z as et,zt as q}from"./dropdown-menu-CHiEwVjq.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var J=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(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,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&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&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),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}}}})),tt=i(((e,t)=>{t.exports=J()})),nt=i((e=>{var t=tt(),n=ie(),r=ne();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function z(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var ee=R(null),te=R(null),V=R(null),re=R(null);function H(e,t){switch(B(V,t),B(te,e),B(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(ee),B(ee,e)}function ae(){z(ee),z(te),z(V)}function oe(e){e.memoizedState!==null&&B(re,e);var t=ee.current,n=Ud(t,e.type);t!==n&&(B(te,e),B(ee,n))}function se(e){te.current===e&&(z(ee),z(te)),re.current===e&&(z(re),$f._currentValue=F)}var ce,le;function U(e){if(ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ce=t&&t[1]||``,le=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ce+e+le}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -83,38 +83,36 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
83
83
|
`)){if(!r.startsWith(` `)&&!r.startsWith(`+`)&&!r.startsWith(`-`)){n&&t.push(n),n={filePath:r,lines:[]};continue}n||={filePath:`Patch`,lines:[]},n.lines.push(r)}return n&&t.push(n),t},RM=({content:e})=>{let t=LM(e);return t.length===0?(0,Z.jsx)(`pre`,{children:(0,Z.jsx)(`code`,{children:e})}):(0,Z.jsx)(`div`,{className:`overflow-hidden rounded-md border border-border/70 bg-background/60`,children:t.map((e,t)=>(0,Z.jsxs)(`div`,{className:G(t>0&&`border-t border-border/70`),children:[(0,Z.jsx)(`div`,{className:`border-b border-border/80 bg-zinc-900 px-3 py-2 font-mono text-[11px] font-medium text-zinc-100`,children:e.filePath}),(0,Z.jsx)(`div`,{className:`py-1`,children:e.lines.map((e,t)=>{let n=e[0]??` `,r=e.length>0?e.slice(1):``,i=n===`+`,a=n===`-`,o=i?`bg-emerald-500/12 text-emerald-100`:a?`bg-rose-500/12 text-rose-100`:`text-zinc-100`,s=i?`text-emerald-200`:a?`text-rose-200`:`text-zinc-300`;return(0,Z.jsxs)(`div`,{className:G(`flex gap-3 px-3 py-1 font-mono text-xs leading-5`,o),children:[(0,Z.jsx)(`span`,{className:G(`w-3 shrink-0 text-center`,s),children:n===` `?` `:n}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:r||`\xA0`})]},t)})})]},`${e.filePath}-${t}`))})},zM=({content:e})=>(0,Z.jsx)(`div`,{className:`not-prose flex flex-col gap-1`,"data-transcript-segment":`todo-list`,children:jM(e).map((e,t)=>(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6`,children:e},`${e}-${t}`))}),BM=e=>e.replace(/\r\n/g,`
|
|
84
84
|
`).replace(MM,``),VM=e=>{let t=IM(e);if(t)return[{kind:`apply_patch`,content:t}];let n=[],r=[],i=()=>{let e=r.join(`
|
|
85
85
|
`);if(!e.trim()){r.length=0;return}n.push({kind:jM(e).length>0?`todo`:`markdown`,content:e}),r.length=0};for(let t of BM(e).split(`
|
|
86
|
-
`))r.push(t);return i(),n},HM=({content:e,className:t})=>{let n=VM(e);return(0,Z.jsx)(`div`,{className:G(`prose prose-invert prose-sm max-w-none break-words text-sm text-foreground [overflow-wrap:anywhere] [&_code]:break-words [&_code]:text-violet-300 [&_h1]:mb-2 [&_h1]:mt-4 [&_h1]:text-base [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-base [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:my-1 [&_li>p]:my-1 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_pre]:overflow-x-auto [&_pre]:rounded [&_pre]:bg-secondary [&_pre]:p-2 [&_pre]:whitespace-pre-wrap [&_p]:mb-3 [&_strong]:text-foreground [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5 [&_br+br]:mt-3 [&_br+br]:block`,t),children:n.map((e,t)=>e.kind===`apply_patch`?(0,Z.jsx)(RM,{content:e.content},`apply-patch-${t}`):e.kind===`code`?(0,Z.jsx)(`pre`,{children:(0,Z.jsx)(`code`,{children:e.content})},`code-${t}`):e.kind===`todo`?(0,Z.jsx)(zM,{content:e.content},`todo-${t}`):(0,Z.jsx)(gM,{remarkPlugins:[OM],children:e.content},`markdown-${t}`))})},UM=({item:e,index:t})=>{let{t:n}=X(`common`);return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-sky-500/20 bg-background/40 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.source===`archon_review_finding`?n(`reviewFollowUpBubble.finding`,{count:e.findingNumber??t}):e.source===`external_review_comment`?n(`reviewFollowUpBubble.externalFix`,{count:t}):e.source===`preview_comment`?n(`reviewFollowUpBubble.previewComment`,{count:t}):n(`reviewFollowUpBubble.comment`,{count:t})}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-xs text-foreground`,children:e.filePath??e.page??n(`reviewFollowUpBubble.unknownTarget`)})]}),e.line&&(0,Z.jsx)(`div`,{className:`rounded-full border border-border bg-background/60 px-2 py-0.5 font-mono text-[11px] text-muted-foreground`,children:e.line})]}),(e.title||e.element)&&(0,Z.jsx)(`div`,{className:`mt-3 text-sm font-medium text-foreground`,children:e.title??e.element}),e.selectorHint&&(0,Z.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.selectorHint}),(0,Z.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e.comment}),e.text&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.textLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 text-xs text-foreground`,children:e.text})]}),e.href&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.hrefLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.href})]}),e.src&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.srcLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.src})]}),e.lineContent&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.changedLineLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground`,children:e.lineContent})]})]})},
|
|
86
|
+
`))r.push(t);return i(),n},HM=({content:e,className:t})=>{let n=VM(e);return(0,Z.jsx)(`div`,{className:G(`prose prose-invert prose-sm max-w-none break-words text-sm text-foreground [overflow-wrap:anywhere] [&_code]:break-words [&_code]:text-violet-300 [&_h1]:mb-2 [&_h1]:mt-4 [&_h1]:text-base [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-base [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:my-1 [&_li>p]:my-1 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_pre]:overflow-x-auto [&_pre]:rounded [&_pre]:bg-secondary [&_pre]:p-2 [&_pre]:whitespace-pre-wrap [&_p]:mb-3 [&_strong]:text-foreground [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5 [&_br+br]:mt-3 [&_br+br]:block`,t),children:n.map((e,t)=>e.kind===`apply_patch`?(0,Z.jsx)(RM,{content:e.content},`apply-patch-${t}`):e.kind===`code`?(0,Z.jsx)(`pre`,{children:(0,Z.jsx)(`code`,{children:e.content})},`code-${t}`):e.kind===`todo`?(0,Z.jsx)(zM,{content:e.content},`todo-${t}`):(0,Z.jsx)(gM,{remarkPlugins:[OM],children:e.content},`markdown-${t}`))})},UM=e=>(0,Y.isValidElement)(e)?(typeof e.props.className==`string`?e.props.className:``).match(/language-([\w-]+)/)?.[1]?.toLowerCase()??null:null,WM=({children:e})=>{let{t}=X(`common`);return UM(e)===`suggestion`?(0,Z.jsxs)(`div`,{className:`not-prose overflow-hidden rounded-lg border border-emerald-400/30 bg-emerald-500/10`,children:[(0,Z.jsx)(`div`,{className:`border-b border-emerald-400/30 bg-emerald-500/12 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-emerald-100`,children:t(`githubCommentMarkdown.suggestionLabel`)}),(0,Z.jsx)(`pre`,{className:`m-0 overflow-x-auto px-3 py-3 text-xs leading-5 text-foreground`,children:e})]}):(0,Z.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap rounded-lg border border-border/70 bg-background/70 p-3 text-xs leading-5 text-foreground`,children:e})},GM=({content:e,className:t})=>(0,Z.jsx)(`div`,{className:G(`prose prose-invert prose-sm mt-2 max-w-none break-words text-xs text-foreground [overflow-wrap:anywhere] [&_code]:rounded [&_code]:bg-background/70 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.95em] [&_p]:mb-3 [&_p:last-child]:mb-0 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-border/70 [&_pre]:bg-background/70 [&_pre]:p-3 [&_pre]:text-xs [&_pre]:leading-5 [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-inherit`,t),children:(0,Z.jsx)(gM,{components:{pre:WM},remarkPlugins:[OM],children:e})}),KM=({item:e,index:t})=>{let{t:n}=X(`common`);return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-sky-500/20 bg-background/40 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.source===`archon_review_finding`?n(`reviewFollowUpBubble.finding`,{count:e.findingNumber??t}):e.source===`external_review_comment`?n(`reviewFollowUpBubble.externalFix`,{count:t}):e.source===`preview_comment`?n(`reviewFollowUpBubble.previewComment`,{count:t}):n(`reviewFollowUpBubble.comment`,{count:t})}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-xs text-foreground`,children:e.filePath??e.page??n(`reviewFollowUpBubble.unknownTarget`)})]}),e.line&&(0,Z.jsx)(`div`,{className:`rounded-full border border-border bg-background/60 px-2 py-0.5 font-mono text-[11px] text-muted-foreground`,children:e.line})]}),(e.title||e.element)&&(0,Z.jsx)(`div`,{className:`mt-3 text-sm font-medium text-foreground`,children:e.title??e.element}),e.selectorHint&&(0,Z.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.selectorHint}),e.source===`external_review_comment`?(0,Z.jsx)(GM,{content:e.comment,className:`mt-3 text-sm leading-relaxed`}):(0,Z.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e.comment}),e.text&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.textLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 text-xs text-foreground`,children:e.text})]}),e.href&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.hrefLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.href})]}),e.src&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.srcLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground break-all`,children:e.src})]}),e.lineContent&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 text-[11px] uppercase tracking-wide text-muted-foreground`,children:n(`reviewFollowUpBubble.changedLineLabel`)}),(0,Z.jsx)(`div`,{className:`mt-1 rounded-md bg-background/60 px-2 py-1 font-mono text-xs text-foreground`,children:e.lineContent})]})]})},qM=({content:e,parsed:t})=>{let{t:n}=X(`common`),[r,i]=(0,Y.useState)(!1),a=n(`reviewFollowUpBubble.fixCount`,{count:t.items.length}),o=t.locationLabel===`file`?n(`reviewFollowUpBubble.locationFile`,{count:t.locationCount}):t.locationLabel===`page`?n(`reviewFollowUpBubble.locationPage`,{count:t.locationCount}):n(`reviewFollowUpBubble.locationTarget`,{count:t.locationCount});return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:n(`reviewFollowUpBubble.selectedFixes`)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[a,` across `,o]})]}),(0,Z.jsxs)(K,{type:`button`,size:`xs`,variant:`ghost`,className:`gap-1.5 self-start`,onClick:()=>{i(e=>!e)},children:[(0,Z.jsx)(Oe,{className:`h-3.5 w-3.5 transition-transform ${r?`rotate-180`:``}`}),n(r?`reviewFollowUpBubble.hideRawPrompt`:`reviewFollowUpBubble.showRawPrompt`)]})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:t.items.map((e,t)=>(0,Z.jsx)(KM,{item:e,index:t+1},`${e.filePath??e.page??`target`}:${e.line??e.element??t}:${t+1}`))}),r&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/40 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-widest text-muted-foreground`,children:n(`reviewFollowUpBubble.rawPrompt`)}),(0,Z.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap text-xs leading-relaxed text-foreground`,children:e})]})]})},JM=2,YM=18,XM=288,ZM=(e,t)=>{let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t).trimEnd()}...`},QM=e=>{if(typeof document>`u`)return{text:e,truncated:!1};let t=document.createElement(`span`);t.setAttribute(`aria-hidden`,`true`),t.style.position=`absolute`,t.style.visibility=`hidden`,t.style.pointerEvents=`none`,t.style.whiteSpace=`pre-wrap`,t.style.wordBreak=`break-word`,t.style.overflowWrap=`anywhere`,t.style.width=`${XM}px`,t.style.fontSize=`12px`,t.style.lineHeight=`${YM}px`,t.style.fontFamily=`inherit`,t.textContent=e,document.body.appendChild(t);let n=YM*JM;if(!(t.getBoundingClientRect().height>n+.5))return document.body.removeChild(t),{text:e,truncated:!1};let r=0,i=e.length,a=ZM(e,Math.max(1,Math.floor(e.length/2)));for(;r<=i;){let o=Math.floor((r+i)/2),s=ZM(e,o);t.textContent=s,t.getBoundingClientRect().height<=n+.5?(a=s,r=o+1):i=o-1}return document.body.removeChild(t),{text:a,truncated:!0}},$M=`Please address the following review comments in the current diff.`,eN=`Please address the following selected fixes in the current diff.`,tN=`Please address the following selected fixes from the current preview.`,nN=`Please address the following selected fixes from the current diff and preview.`,rN=`Apply only the selected fixes. Keep unrelated changes intact.`,iN=/^Reviewer suggestion \d+ \(optional\):$/,aN=/^\d+\. Source: /m,oN=(e,t)=>{if(e[t]!==`Context:`||e[t+1]!=="```diff")return null;let n=[],r=t+2;for(;r<e.length;){if(e[r]==="```")return{diffSnippet:n.join(`
|
|
87
|
+
`),nextIndex:r+1};n.push(e[r]),r+=1}return null},sN=(e,t)=>{if(!iN.test(e[t]??``))return null;let n=t+1;for(;n<e.length&&e[n]!=="```suggestion";)n+=1;if(n>=e.length)return e.length;for(n+=1;n<e.length&&e[n]!=="```";)n+=1;return Math.min(e.length,n+1)},cN=e=>{let t=[...e];for(;t.length>0&&t[t.length-1]?.trim()===``;)t.pop();return t},lN=e=>{let t=e.trimEnd(),n=t.indexOf(`
|
|
87
88
|
Context:
|
|
88
89
|
\`\`\`diff
|
|
89
90
|
`);if(n===-1)return null;let r=t.slice(0,n),i=t.slice(n+18);if(!i.endsWith("\n```"))return null;let a=r.split(`
|
|
90
91
|
`);if(a.length<5)return null;let[o,s,c,l,...u]=a;return!/^\d+\. File: /.test(o)||!s.startsWith(`Line: `)||!c.startsWith(`Hunk: `)||!l.startsWith(`Changed line: `)||u.length===0||!u[0].startsWith(`Comment: `)?null:{source:`manual_comment`,filePath:o.replace(/^\d+\. File: /,``),page:null,line:s.slice(6),element:null,selectorHint:null,text:null,href:null,src:null,hunk:c.slice(6),lineContent:l.slice(14),comment:[u[0].slice(9),...u.slice(1)].join(`
|
|
91
|
-
`),diffSnippet:i.slice(0,-4)}},
|
|
92
|
-
`)[0];if(!/^\d+\. Source: /.test(n))return null;let r=n.replace(/^\d+\. Source: /,``).trim().toLowerCase(),i=r===`archon review finding`?`archon_review_finding`:r===`external review comment`||r.startsWith(`github review `)?`external_review_comment`:r===`preview comment`?`preview_comment`:`manual_comment`,a=new Map,o=null,s=t.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
`),
|
|
96
|
-
`)
|
|
97
|
-
`).
|
|
98
|
-
`),
|
|
99
|
-
`)
|
|
100
|
-
`).
|
|
101
|
-
`):``},SN=e=>{let t=gN(xN(e));if(!t)return[];let n=[],r=[],i=!1,a=()=>{let e=r.join(`
|
|
102
|
-
`).trim();if(r.length=0,e){if(oN.test(e))return;n.push(e)}};for(let e of t.split(`
|
|
103
|
-
`)){if(e===sN){a(),r.push(e),i=!0;continue}if(i){r.push(e),e===cN&&(a(),i=!1);continue}if(!e.trim()){a();continue}r.push(e)}return a(),n},CN=(e,t)=>e.length>=t.length?!1:e.every((e,n)=>e===t[n]),wN=e=>{let t=[];for(let n of e){let e=t[t.length-1];if(!e||!AM(e)||!AM(n)){t.push(n);continue}if(CN(e.split(`
|
|
92
|
+
`),diffSnippet:i.slice(0,-4)}},uN=e=>{let t=e.trimEnd().split(`
|
|
93
|
+
`),n=t[0];if(!/^\d+\. Source: /.test(n))return null;let r=n.replace(/^\d+\. Source: /,``).trim().toLowerCase(),i=r===`archon review finding`?`archon_review_finding`:r===`external review comment`||r.startsWith(`github review `)?`external_review_comment`:r===`preview comment`?`preview_comment`:`manual_comment`,a=new Map,o=null,s=1;for(;s<t.length;){let e=t[s],n=sN(t,s);if(typeof n==`number`){s=n;continue}let r=oN(t,s);if(r){o=r.diffSnippet,s=r.nextIndex;continue}if(e.startsWith(`Comment:`)){let n=[e.slice(8).trimStart()];for(s+=1;s<t.length;){let e=t[s];if(e===`Context:`||e.startsWith(`GitHub URL: `)||iN.test(e))break;n.push(e),s+=1}a.set(`Comment`,cN(n).join(`
|
|
94
|
+
`).trimEnd());continue}let i=e.indexOf(`: `);if(i===-1){s+=1;continue}a.set(e.slice(0,i),e.slice(i+2)),s+=1}let c=a.get(`Comment`)??a.get(`What`)??``;return c?i===`preview_comment`?{source:i,filePath:null,page:a.get(`Page`)??null,line:null,element:a.get(`Element`)??null,selectorHint:a.get(`Selector hint`)??null,text:a.get(`Text`)??null,href:a.get(`Href`)??null,src:a.get(`Src`)??null,hunk:null,lineContent:null,comment:c,diffSnippet:null,severity:null,title:null,findingNumber:null}:{source:i,filePath:a.get(`File`)??`Unknown file`,page:null,line:a.get(`Line`)??`line unavailable`,element:null,selectorHint:null,text:null,href:null,src:null,hunk:a.get(`Hunk`)??null,lineContent:a.get(`Changed line`)??null,comment:c,diffSnippet:o,severity:a.get(`Severity`)??null,title:a.get(`Title`)??null,findingNumber:a.has(`Finding`)&&Number(a.get(`Finding`))||null}:null},dN=e=>{let t=e.trim(),n=t.startsWith($M),r=[eN,tN,nN].find(e=>t.startsWith(e));if(!n&&!r)return null;let i=n?$M:r??eN,a=t.slice(i.length).trim();if(!a)return null;let o=(n?a.split(/\n(?=\d+\. File: )/):(()=>{let e=a.replace(RegExp(`\\n${rN.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}$`),``).trim(),t=aN.exec(e);return!t||t.index===void 0?[]:e.slice(t.index).split(/\n(?=\d+\. Source: )/)})()).map(n?lN:uN);if(o.some(e=>e===null))return null;let s=o.filter(e=>e!==null);return s.length===0?null:{items:s,locationCount:new Set(s.map(e=>e.filePath??e.page??`Unknown target`)).size,locationLabel:s.every(e=>e.page&&!e.filePath)?`page`:s.every(e=>e.filePath&&!e.page)?`file`:`target`}},fN=24,pN=`archon.show-thinking`,mN=new Set([`step started`,`step finished`]),hN=/^_?todo[_-]?write_?$/i,gN=`[[archon-apply-patch]]`,_N=`[[/archon-apply-patch]]`,vN=[/(^|\n)\s*<system-reminder>[\s\S]*?<\/system-reminder>\s*(?=\n|$)/g,/(^|\n)\s*<archon-[a-z0-9-]+>[\s\S]*?<\/archon-[a-z0-9-]+>\s*(?=\n|$)/g,/(^|\n)\s*<selected_skills>[\s\S]*?<\/selected_skills>\s*(?=\n|$)/g,/(^|\n)\s*<ticket>[\s\S]*?<\/ticket>\s*(?=\n|$)/g,/(^|\n)\s*<follow_up_instruction>[\s\S]*?<\/follow_up_instruction>\s*(?=\n|$)/g,/(^|\n)\s*<review_findings>[\s\S]*?<\/review_findings>\s*(?=\n|$)/g,/(^|\n)\s*<diff>[\s\S]*?<\/diff>\s*(?=\n|$)/g],yN=/^<(?<tag>archon-[a-z0-9-]+)>$/i,bN=/^<\/(?<tag>archon-[a-z0-9-]+)>$/i,xN=()=>{try{return window.localStorage.getItem(pN)===`true`}catch{return!1}},SN=e=>{if(typeof queueMicrotask==`function`){queueMicrotask(e);return}Promise.resolve().then(e)},CN=e=>{e.scrollTop=e.scrollHeight},wN=e=>e.scrollHeight-e.clientHeight-e.scrollTop<=fN,TN=e=>e.replace(/\r\n/g,`
|
|
95
|
+
`).trim(),EN=e=>vN.reduce((e,t)=>e.replace(t,`$1`),e),DN=e=>{let t=e.trim();return t?t.startsWith(`{`)||t.startsWith(`[`)||t.startsWith(`"`)||t.startsWith(`- `)||/^\d+\.\s/.test(t):!0},ON=e=>{let t=e.split(`
|
|
96
|
+
`),n=[],r=null;for(let e of t){let t=e.trim();if(r===null){let i=t.match(yN);if(i?.groups?.tag){r=i.groups.tag.toLowerCase();continue}n.push(e);continue}if(t.match(bN)?.groups?.tag?.toLowerCase()===r){r=null;continue}DN(t)||(r=null,n.push(e))}return n.join(`
|
|
97
|
+
`)},kN=e=>{let t=e.trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return!1;try{let e=JSON.parse(t);return Object.keys(e).length===1&&Array.isArray(e.open_questions)}catch{return!1}},AN=e=>{let t=TN(ON(EN(e??``)));return t?t.split(`
|
|
98
|
+
`).filter(e=>{let t=e.trim();return!mN.has(t.toLowerCase())&&!kN(t)}).join(`
|
|
99
|
+
`):``},jN=e=>{let t=TN(AN(e));if(!t)return[];let n=[],r=[],i=!1,a=()=>{let e=r.join(`
|
|
100
|
+
`).trim();if(r.length=0,e){if(hN.test(e))return;n.push(e)}};for(let e of t.split(`
|
|
101
|
+
`)){if(e===gN){a(),r.push(e),i=!0;continue}if(i){r.push(e),e===_N&&(a(),i=!1);continue}if(!e.trim()){a();continue}r.push(e)}return a(),n},MN=(e,t)=>e.length>=t.length?!1:e.every((e,n)=>e===t[n]),NN=e=>{let t=[];for(let n of e){let e=t[t.length-1];if(!e||!AM(e)||!AM(n)){t.push(n);continue}if(MN(e.split(`
|
|
104
102
|
`),n.split(`
|
|
105
|
-
`))){t[t.length-1]=n;continue}t[t.length-1]=`${e}\n${n}`}return t},TN=({visibleContent:e,internalLog:t,showThinking:n})=>{let r=wN(SN(e));if(!n||!t||t.trim().length===0)return r.map(e=>({tone:`primary`,content:e}));let i=wN(SN(t));if(i.length===0)return r.map(e=>({tone:`primary`,content:e}));let a=[],o=0;for(let e of i){let t=r[o];if(t&&gN(t)===gN(e)){a.push({tone:`primary`,content:e}),o+=1;continue}a.push({tone:`secondary`,content:e})}for(;o<r.length;)a.push({tone:`primary`,content:r[o]}),o+=1;return a},EN=(0,Y.memo)(({visibleContent:e,internalLog:t,showThinking:n})=>{let r=(0,Y.useMemo)(()=>TN({visibleContent:e,internalLog:t,showThinking:n}),[t,n,e]);return r.length===0?null:(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:r.map((e,t)=>(0,Z.jsx)(HM,{content:e.content,className:e.tone===`secondary`?`text-muted-foreground [&_code]:text-violet-200 [&_pre]:bg-background/70`:void 0},`${e.tone}:${t+1}`))})});EN.displayName=`AssistantMessageContent`;var DN=(0,Y.memo)(({attachments:e})=>{let{t}=X(`common`),[n,r]=(0,Y.useState)(null);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[e.map(e=>{let n=l(e.content_url);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/80 bg-background/70 transition-colors hover:border-border`,children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":t(`attachmentPreviewDialog.previewImageAriaLabel`,{name:e.original_name}),className:`block w-full cursor-zoom-in overflow-hidden text-left outline-none transition-opacity hover:opacity-95 focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:()=>{r(e)},children:(0,Z.jsx)(`img`,{src:n,alt:t(`conversationPane.attachmentPreviewAlt`,{name:e.original_name}),className:`h-28 w-full object-cover`,loading:`lazy`})}),(0,Z.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:e.original_name}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:zp(e.size_bytes)})]})]},e.id)}),(0,Z.jsx)(Bp,{attachment:n,onClose:()=>{r(null)}})]})});DN.displayName=`MessageAttachments`;var ON=(0,Y.memo)(({message:e,showThinking:t=!1,internalLog:n=null,footer:r=null})=>{let i=e.role===`user`,a=i&&e.kind===`description`,o=e.attachments??[],[s,c]=(0,Y.useState)(!1),l=i?nN(e.content):null,u=(0,Y.useMemo)(()=>!a||!e.content?{text:e.content,truncated:!1}:YM(e.content),[a,e.content]);return(0,Z.jsx)(`div`,{"data-message-role":e.role,className:`flex ${i?`justify-end`:`justify-start`}`,children:(0,Z.jsxs)(mu,{className:i?`min-w-0 max-w-full w-[94%] border-sky-500/30 bg-sky-500/10 shadow-none sm:w-auto sm:max-w-[85%]`:`min-w-0 max-w-full w-[94%] border-slate-400/30 bg-slate-400/10 shadow-none sm:w-auto sm:max-w-[85%]`,size:`sm`,children:[(0,Z.jsxs)(yu,{className:`min-w-0 flex flex-col gap-2 px-3 py-3 sm:px-4 sm:py-4 ${i?`[overflow-wrap:anywhere]`:``}`,children:[e.displayTitle&&(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.displayTitle}),i?l?(0,Z.jsx)(WM,{content:e.content,parsed:l}):a?(0,Z.jsx)(vT,{description:e.content,descriptionClass:`whitespace-pre-wrap text-sm leading-relaxed text-foreground`,isExpanded:s,collapsedState:u,useStaleLikeStyling:!1,onExpand:()=>c(!0),onCollapse:()=>c(!1)}):e.content?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground [overflow-wrap:anywhere]`,children:e.content}):null:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Wd,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(EN,{visibleContent:e.content,internalLog:n,showThinking:t})})]}),i&&o.length>0?(0,Z.jsx)(DN,{attachments:o}):null]}),r?(0,Z.jsx)(bu,{className:`border-t border-border/60 px-4 py-3`,children:r}):null]})})});ON.displayName=`MessageBubble`;var kN=()=>{let{t:e}=X(`common`);return(0,Z.jsxs)(`div`,{role:`status`,"aria-label":e(`conversationPane.agentActivityAriaLabel`),"aria-live":`polite`,className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,"aria-hidden":`true`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_infinite_backwards] motion-reduce:animate-none`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.3s_infinite_backwards] motion-reduce:animate-none`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.6s_infinite_backwards] motion-reduce:animate-none`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e(`conversationPane.agentWorkingSrText`)})]})},AN=(0,Y.memo)(({ticketTitle:e,streamingResponse:t,internalLog:n,showThinking:r,statusLabel:i,showActivity:a=!0})=>{let{t:o}=X(`common`),s=i??o(`conversationPane.statusWorking`);return(0,Z.jsx)(`div`,{className:`flex justify-start`,children:(0,Z.jsx)(mu,{className:`min-w-0 max-w-full w-[94%] border-slate-400/30 bg-slate-400/10 shadow-none sm:w-full sm:max-w-[85%]`,size:`sm`,children:(0,Z.jsxs)(yu,{className:`flex flex-col gap-3 px-3 py-3 sm:px-4 sm:py-4`,children:[e?(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e}):null,(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(Wd,{className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{children:s})]}),t||r&&n?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Wd,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(EN,{visibleContent:t,internalLog:n,showThinking:r})})]}):null,a?(0,Z.jsx)(kN,{}):null]})})})});AN.displayName=`PendingAgentMessage`;var jN=(0,Y.memo)(({messages:e,messageThinkingLogs:t,effectiveShowThinking:n,internalLog:r,pendingAgentTitle:i,streamingResponse:a,isRunning:o,isPendingAgentVisible:s,interruptedPendingSnapshot:c,isLoading:l,emptyStateText:u,renderMessageFooter:d,hidePendingAgentTitle:f=!1})=>{let{t:p}=X(`common`),m=c?e.findIndex(e=>e.id===c.latestMessageIdAtCapture):-1,h=m>=0?e.slice(0,m+1):e,g=m>=0?e.slice(m+1):[],_=e=>(0,Z.jsx)(ON,{message:e,footer:d?.(e)??null,showThinking:n&&t.has(e.id),internalLog:t.get(e.id)??null},`${e.ticket_id}:${e.id}`);return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-5`,children:[e.length===0&&!o&&u&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-6 text-sm text-muted-foreground`,children:l?p(`conversationPane.loadingConversation`):u}),h.map(_),o&&s&&(0,Z.jsx)(AN,{ticketTitle:f?null:i,streamingResponse:a,internalLog:r,showThinking:n}),!o&&c?(0,Z.jsx)(AN,{ticketTitle:f?null:c.ticketTitle,streamingResponse:c.streamingResponse,internalLog:c.internalLog,showThinking:c.showThinking,statusLabel:p(`conversationPane.statusInterrupted`),showActivity:!1}):null,g.map(_)]})});jN.displayName=`ConversationTranscript`;var MN=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,legacyThinkingTicketId:a=null,previousThinkingLog:o=null,previousThinkingMessageId:s=null,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d=!1,autoScrollBehavior:f=`sticky`,surfaceVariant:p=`default`,canShowComposer:m,cardClassName:h,header:g,composerControls:_,composerInlineControls:v,composerTheme:y=`default`,composerSize:b=`default`,showThinkingPlacement:x=`body`,pinComposerToBottom:S=!1,isExternallyResizing:C=!1,pendingAgentRevealKey:w=null,pendingAgentRevealDelayMs:T=0,composerFocusNonce:E=0,forceScrollToBottomKey:D,layoutKey:O,scrollLayoutKey:k,blurComposerOnSendStart:A=!1,followUpPrompt:j,draftAttachments:M=[],followUpPlaceholder:N,emptyStateText:P,autoFocusComposer:F=!1,renderMessageFooter:I,isSendingFollowUp:L,isUploadingAttachments:R=!1,canAttachImages:z=!1,followUpDisabledReason:B,hidePendingAgentTitle:ee=!1,onFollowUpPromptChange:te,onFollowUpKeyDown:ne,onFollowUpPaste:V,onUploadAttachments:re,onRemoveAttachment:H,onFollowUpSubmit:ie})=>{let ae=(0,Y.useRef)(null),oe=(0,Y.useRef)(null),se=(0,Y.useRef)(!1),ce=(0,Y.useRef)(null),le=(0,Y.useRef)(r),U=(0,Y.useRef)(k),ue=(0,Y.useRef)(!1),de=(0,Y.useRef)(j),fe=(0,Y.useRef)(E),pe=(0,Y.useRef)(D),me=(0,Y.useRef)(C),he=(0,Y.useRef)(!0),ge=(0,Y.useRef)(!1),W=(0,Y.useRef)(!1),_e=(0,Y.useRef)(L),ve=(0,Y.useRef)(null),ye=(0,Y.useRef)(null),[be,xe]=(0,Y.useState)(fN),[Se,Ce]=(0,Y.useState)(null),[we,Te]=(0,Y.useState)(null),Ee=(0,Y.useId)(),{t:De}=X(`common`),Oe=n.length>0?n[n.length-1].id:null,ke=!u||!w||Se===w,K=!!(r&&r.trim().length>0||o&&o.trim().length>0),Ae=be&&K,je=!!(l||Ae&&r),Me=p===`chat`,Ne=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ud,{id:Ee,"aria-label":De(`conversationPane.showThinkingAriaLabel`),checked:be,onCheckedChange:xe}),(0,Z.jsx)(Xs,{htmlFor:Ee,className:`text-sm text-muted-foreground`,children:De(`conversationPane.showThinkingLabel`)})]}),Pe=P===void 0?De(`conversationPane.noMessagesYet`):P,Fe=typeof g==`function`?g({showThinkingControl:Ne}):g,Ie=x===`header`&&!!Fe&&typeof g!=`function`,Le=!Ie&&typeof g!=`function`,Re=(0,Y.useMemo)(()=>i||u||!r?null:[...n].reverse().find(e=>e.role===`assistant`?a?e.ticket_id===a:!0:!1)?.id??null,[i,r,u,a,n]),ze=(0,Y.useMemo)(()=>{let e=new Map;if(!Ae)return e;s&&o&&e.set(s,o);let t=i??Re;return!u&&t&&r&&e.set(t,r),e},[i,Ae,Re,r,u,o,s]),Be=e=>{pN(()=>{Te(e)})};return(0,Y.useEffect)(()=>{Be(null)},[O]),(0,Y.useEffect)(()=>{u&&Be(null)},[u]),(0,Y.useEffect)(()=>{!u||!ke||!je||Be(e=>e&&e.latestMessageIdAtCapture===Oe&&e.internalLog===r&&e.showThinking===Ae&&e.streamingResponse===l&&e.ticketTitle===c?e:{latestMessageIdAtCapture:Oe,internalLog:r,showThinking:Ae,streamingResponse:l,ticketTitle:c})},[Ae,je,r,ke,u,Oe,c,l]),(0,Y.useEffect)(()=>{Be(e=>e&&(Oe!==e.latestMessageIdAtCapture&&n[n.length-1]?.role===`assistant`?null:e))},[Oe,n]),(0,Y.useEffect)(()=>{try{if(be){window.localStorage.setItem(iN,`true`);return}window.localStorage.removeItem(iN)}catch{}},[be]),(0,Y.useEffect)(()=>()=>{ve.current!==null&&window.clearTimeout(ve.current)},[]),(0,Y.useEffect)(()=>{ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),!(!w||T<=0||Se===w)&&(ve.current=window.setTimeout(()=>{ve.current=null,Ce(w)},T))},[T,w,Se]),(0,Y.useEffect)(()=>{let e=ae.current;if(!e)return;let t=null,n=oe.current===null,i=oe.current!==Oe,a=!se.current&&u,o=ce.current!==l,s=le.current!==r,c=U.current!==k,d=ue.current!==Ae,p=hN(e),m=f===`always`||n||he.current,h=m||p;return c&&(he.current=h),m&&(n||i||a||o||d||Ae&&s)&&mN(e),c&&h&&(mN(e),t=window.requestAnimationFrame(()=>{mN(e)})),oe.current=Oe,se.current=u,ce.current=l,le.current=r,U.current=k,ue.current=Ae,()=>{t!==null&&window.cancelAnimationFrame(t)}},[Ae,r,u,k,Oe,l,f]),(0,Y.useEffect)(()=>{let e=ae.current,t=!_e.current&&L;e&&t&&(A&&ye.current?.blur(),he.current=!0,mN(e)),_e.current=L},[A,L]),(0,Y.useEffect)(()=>{let e=ae.current,t=pe.current!==D;if(pe.current=D,!e||!D||!t)return;he.current=!0,mN(e);let n=requestAnimationFrame(()=>{mN(e)});return()=>{cancelAnimationFrame(n)}},[D]),(0,Y.useEffect)(()=>{let e=ae.current;if(!e){me.current=C;return}let t=!me.current&&C,n=me.current&&!C;t&&(ge.current=he.current||hN(e)),n&&(he.current=hN(e),ge.current=!1),me.current=C},[C]),(0,Y.useEffect)(()=>{let e=ae.current;if(!e||typeof ResizeObserver!=`function`)return;let t=new ResizeObserver(()=>{(he.current||ge.current||W.current)&&mN(e)});return t.observe(e),()=>{t.disconnect()}},[]),(0,Y.useEffect)(()=>{let e=ae.current;!e||!ke||!u||(f===`always`||he.current)&&mN(e)},[f,ke,u]),(0,Y.useEffect)(()=>{let e=fe.current!==E;if(fe.current=E,!F&&!e||!m||L)return;let t=ye.current;if(!t)return;let n=requestAnimationFrame(()=>{t.focus()});return()=>{cancelAnimationFrame(n)}},[F,m,E,L,O]),(0,Y.useEffect)(()=>{let e=ye.current;if(!e||!m){de.current=j;return}let t=ae.current,n=de.current!==j;de.current=j;let r=!!(n&&t&&(he.current||hN(t)));if(W.current=r,fm(e),!t||!r){W.current=!1;return}let i=requestAnimationFrame(()=>{he.current=!0,mN(t),W.current=!1});return()=>{cancelAnimationFrame(i),W.current=!1}},[m,j,O]),(0,Z.jsx)(`section`,{"aria-label":De(`conversationPane.sectionAriaLabel`),className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Z.jsxs)(mu,{size:`sm`,className:G(`min-h-0 flex-1 gap-0 overflow-hidden border-border/80 bg-card/70 shadow-none`,Me&&`rounded-none`,h),children:[Fe&&(0,Z.jsxs)(`div`,{className:G(`flex items-start justify-between gap-3 border-b border-border/80 px-4`,Me?`pt-3 pb-1`:`py-3`),children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:Fe}),Ie&&Ne]}),Le&&(0,Z.jsx)(`div`,{className:`flex justify-end px-4 pt-3`,children:Ne}),(0,Z.jsx)(yu,{"aria-label":De(`conversationPane.contentAriaLabel`),ref:ae,onScroll:e=>{C&&ge.current||W.current||(he.current=hN(e.currentTarget))},className:G(`min-h-0 flex-1 overflow-y-auto`,Me?`border-b border-border/80 px-2 pt-0 !pb-2.5 data-[size=sm]:!pb-2.5 sm:px-4`:`border-b border-border/80 px-4 py-4`),children:(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-col`,children:(0,Z.jsx)(jN,{messages:n,messageThinkingLogs:ze,effectiveShowThinking:Ae,internalLog:r,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isPendingAgentVisible:ke,interruptedPendingSnapshot:we,isLoading:d,emptyStateText:Pe,renderMessageFooter:I,hidePendingAgentTitle:ee})})}),m&&(0,Z.jsx)(bu,{className:G(`mt-auto`,Me?`pt-1`:S&&`border-t border-border/80 bg-card/95 pt-4 backdrop-blur supports-[backdrop-filter]:bg-card/80`),children:(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[_?(0,Z.jsx)(`div`,{children:_}):null,(0,Z.jsx)($p,{projectId:e,suggestionTicketId:t,value:j,attachments:M,placeholder:N,disabled:L,isSubmitDisabled:u,isSending:L,isUploadingAttachments:R,canAttachImages:z,disabledReason:B,onValueChange:te,onKeyDown:ne,onPaste:V,onUploadAttachments:re,onRemoveAttachment:H,onSubmit:ie,textareaRef:ye,composerInlineControls:v,composerTheme:y,composerSize:b})]})})]})})},NN=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,previousThinkingLog:a=null,previousThinkingMessageId:o=null,streamingResponse:s,isRunning:c,canShowComposer:l,header:u,followUpComposerControls:d,composerTheme:f=`default`,surfaceVariant:p=`default`,composerSize:m=`default`,forceScrollToBottomKey:h,layoutKey:g,scrollLayoutKey:_,followUpPlaceholder:v=`Follow up on this ticket`,emptyStateText:y,autoFocusComposer:b=!1,pendingAgentTitle:x=null,followUpPrompt:S,isSendingFollowUp:C,followUpDisabledReason:w,onFollowUpPromptChange:T,onFollowUpKeyDown:E,onFollowUpSubmit:D})=>(0,Z.jsx)(MN,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,currentThinkingMessageId:i,previousThinkingLog:a,previousThinkingMessageId:o,pendingAgentTitle:x,streamingResponse:s,isRunning:c,autoScrollBehavior:`sticky`,surfaceVariant:p,canShowComposer:l,header:u,composerInlineControls:d,composerTheme:f,composerSize:m,forceScrollToBottomKey:h,layoutKey:g,scrollLayoutKey:_,followUpPrompt:S,followUpPlaceholder:v,emptyStateText:y,autoFocusComposer:b,isSendingFollowUp:C,followUpDisabledReason:w,onFollowUpPromptChange:T,onFollowUpKeyDown:E,onFollowUpSubmit:D}),PN=({title:e,items:t,resolveTicket:n,resolveOtherTicketId:r,onDeleteDependency:i})=>{let{t:a}=X(`common`);return t.length===0?null:(0,Z.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 truncate text-sm text-foreground`,children:n(r(e))?.title??a(`ticketDependencyDetails.unknownTicket`)}),i&&(0,Z.jsx)(K,{type:`button`,onClick:()=>{i(e)},variant:`destructive`,size:`xs`,children:a(`ticketDependencyDetails.remove`)})]},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`))})]})},FN=({items:e,resolveTicket:t,onDeleteDependency:n})=>{let{t:r}=X(`common`);if(e.length===0)return null;let i=e.map(e=>{let n=t(e.blocker_ticket_id);return{dependency:e,ready:Gw(n),title:n?.title??r(`ticketDependencyDetails.unknownTicket`)}}),a=i.filter(e=>!e.ready),o=a.length===0?r(`ticketDependencyDetails.summaryReady`):r(`ticketDependencyDetails.summaryBlocked`,{count:a.length});return(0,Z.jsxs)(`section`,{"aria-label":r(`ticketDependencyDetails.buildReadinessAriaLabel`),className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:r(`ticketDependencyDetails.buildReadinessTitle`)}),(0,Z.jsx)(U,{variant:a.length===0?`success`:`warning`,children:a.length===0?r(`ticketDependencyDetails.ready`):r(`ticketDependencyDetails.blocked`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.title}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(U,{variant:e.ready?`success`:`warning`,children:e.ready?r(`ticketDependencyDetails.buildDone`):r(`ticketDependencyDetails.waitingOnBuild`)}),n&&(0,Z.jsx)(K,{type:`button`,onClick:()=>{n(e.dependency)},variant:`destructive`,size:`xs`,children:r(`ticketDependencyDetails.remove`)})]})]},`${e.dependency.blocker_ticket_id}:${e.dependency.dependent_ticket_id}`))})]})},IN=({blocks:e,blockedBy:t,resolveTicket:n,onDeleteDependency:r})=>{let{t:i}=X(`common`),[a,o]=(0,Y.useState)(!1);return e.length===0&&t.length===0?null:(0,Z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>{o(e=>!e)},className:`flex w-full cursor-pointer items-center justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/60`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:i(`ticketDependencyDetails.dependencyDetails`)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(a?`ticketDependencyDetails.hide`:`ticketDependencyDetails.show`)})]}),a&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 border-t border-border px-4 py-3 lg:grid-cols-2`,children:[(0,Z.jsx)(PN,{title:i(`ticketDependencyDetails.blocksTitle`),items:e,resolveTicket:n,resolveOtherTicketId:e=>e.dependent_ticket_id,onDeleteDependency:r}),(0,Z.jsx)(FN,{items:t,resolveTicket:n,onDeleteDependency:r})]})]})},LN=({initialTitle:e=``,initialDescription:t=``,initialModel:n=``,initialVariant:r=``,initialSkills:i=[],initialWorktreeBundleId:a=null,validWorktreeBundleIds:o,availableModels:s=[],availableSkills:c=[],showModelSelector:l=!1,showSkillsSelector:u=!1,disableEscapeClose:d=!1,onDirtyChange:f,onAgentSettingsChange:p,onSubmit:m,onCancel:h,children:g})=>{let[_,v]=(0,Y.useState)(e),[y,b]=(0,Y.useState)(t),[x,S]=(0,Y.useState)(n),[C,w]=(0,Y.useState)(r),[T,E]=(0,Y.useState)(i),[D,O]=(0,Y.useState)({worktree_bundle_id:a});lu(h,{disabled:d});let k=D.worktree_bundle_id!==null&&o&&!o.includes(D.worktree_bundle_id)?null:D.worktree_bundle_id,A=_.trim()&&y.trim(),j=_!==e||y!==t||x!==n||C!==r||T.length!==i.length||T.some((e,t)=>e!==i[t])||k!==a;(0,Y.useEffect)(()=>{f?.(j)},[j,f]),(0,Y.useEffect)(()=>{p?.({model:x.trim()||null,variant:C.trim()||null,skills:T})},[x,p,T,C]);let M=(0,Y.useCallback)(()=>{A&&m?.({title:_.trim(),description:y.trim(),model:x.trim()||null,variant:C.trim()||null,skills:T,worktree_bundle_id:k})},[y,A,x,m,k,T,_,C]),N={title:_,description:y,model:x,variant:C,skills:T,extra:{worktree_bundle_id:k},availableModels:s,availableSkills:c,showModelSelector:l,showSkillsSelector:u,setTitle:v,setDescription:b,setModel:S,setVariant:w,setSkills:E,setExtra:O,isValid:!!A,onSubmit:M,onCancel:h};return g?(0,Z.jsx)(Z.Fragment,{children:g(N)}):null},RN=2,zN=e=>e.length===0?`No skills`:e.length<=RN?e.join(`, `):`${e.slice(0,RN).join(`, `)} +${e.length-RN}`,BN=({skills:e,availableSkills:t,onSkillsChange:n,selectId:r,label:i=`Skills`,triggerAriaLabel:a,disabled:o=!1,className:s,triggerClassName:c,showSelectedBadges:l=!0})=>{let u=e.map(e=>t.find(t=>t.name===e)?.name??e).filter(Boolean),d=u.slice(0,RN),f=Math.max(0,u.length-d.length);return(0,Z.jsxs)(`div`,{className:G(`flex flex-col gap-2`,s),children:[(0,Z.jsx)(qd,{label:i,triggerLabel:zN(u),triggerAriaLabel:a??`Skills`,selectId:r,selectedValues:e,onToggle:t=>{n(e.includes(t)?e.filter(e=>e!==t):[...e,t])},disabled:o,contentClassName:`min-w-[22rem]`,triggerClassName:c,groups:[{label:``,options:t.map(e=>({value:e.name,label:e.name}))}]}),l&&u.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[d.map(e=>(0,Z.jsx)(U,{variant:`outline`,className:`border-border/80 bg-background/70 text-[11px] text-foreground`,children:e},e)),f>0&&(0,Z.jsxs)(U,{variant:`ghost`,className:`px-1.5 text-[11px] text-muted-foreground`,children:[`+`,f,` more`]})]})]})},VN=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h,layout:g=`wrap`})=>{let _=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,Z.jsx)(`section`,{className:G(`rounded-2xl border border-border/70 bg-secondary/20 p-3`,h),"aria-label":`AI settings`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`}),(0,Z.jsx)(CT,{model:e,variant:t,skills:n})]}),(0,Z.jsxs)(`div`,{className:G(`gap-3`,g===`stacked`?`flex flex-col`:`flex flex-wrap`),children:[(0,Z.jsx)(fc,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[10rem] flex-[1.35_1_10rem]`}),_&&(0,Z.jsx)(pc,{variant:t,selectedModel:s,showVariantSelector:_,onVariantChange:l,selectId:f,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[7rem] flex-[0.7_1_7rem]`}),i&&(0,Z.jsx)(BN,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[8rem] flex-[0.95_1_8rem]`,showSelectedBadges:!1})]})]})})},HN=({model:e,variant:t,skills:n,selectedModel:r})=>{let i=[];return e&&i.push(r?.label??e),t&&i.push(t),n.length>0&&i.push(`${n.length} skill${n.length===1?``:`s`}`),i.length===0?`AI defaults`:i.join(` / `)},UN=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0,_=HN({model:e,variant:t,skills:n,selectedModel:s});return!r&&!i?null:(0,Z.jsxs)(Zs,{children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,variant:`outline`,disabled:m,className:G(`max-w-full w-fit justify-start gap-2 text-left sm:max-w-80`,h),"aria-label":`AI settings`,children:[(0,Z.jsx)(Wd,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:_})]})}),(0,Z.jsx)($s,{align:`start`,className:`w-80 max-w-[calc(100vw-2rem)] p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(fc,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m}),(0,Z.jsx)(pc,{variant:t,selectedModel:s,showVariantSelector:g,onVariantChange:l,selectId:f,disabled:m}),i&&(0,Z.jsx)(BN,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,showSelectedBadges:!1})]})]})})]})},WN=({jiraImportState:e,onImportFromJira:t,onImported:n,inputId:r,className:i})=>{let{t:a}=X(`common`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(!1);if(e!==`enabled`)return null;let u=!!t,d=async()=>{if(!(!t||!o.trim())){l(!0);try{n(await t(o.trim())),s(``)}catch(e){Q.error(e instanceof Error?e.message:a(`jiraImportField.error`),{id:`jira-import-error`})}finally{l(!1)}}};return(0,Z.jsx)(xu,{label:a(`jiraImportField.label`),htmlFor:r,className:i,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(We,{id:r,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||!u||(e.preventDefault(),d())},placeholder:a(`jiraImportField.placeholder`),disabled:!u||c})}),(0,Z.jsxs)(K,{type:`button`,variant:`outline`,disabled:!u||!o.trim()||c,onClick:()=>{d()},className:`sm:min-w-[7.5rem]`,children:[(0,Z.jsx)(Ef,{className:`h-4 w-4`}),a(c?`jiraImportField.importing`:`jiraImportField.import`)]})]})})},GN=({bundles:e,value:t,onChange:n,label:r,selectId:i=`bundle-selector`,emptyLabel:a,showEmptyOption:o=!0,disabled:s=!1,hideProjectRootBundles:c=!1,projectRootWarning:l=null,projectRootUnavailableReason:u=null,className:d,contentClassName:f,triggerClassName:p})=>{let{t:m}=X(`common`),h=r??m(`bundleSelector.label`),g=a??m(`bundleSelector.emptyLabel`),_=[...c?e.filter(e=>e.kind!==`project_root`):e].sort((e,t)=>e.kind===`project_root`&&t.kind!==`project_root`?-1:+(e.kind!==`project_root`&&t.kind===`project_root`)),v=_.find(e=>e.id===t),y=v?El(v):g,b=v?.kind===`project_root`;return(0,Z.jsxs)(`div`,{className:G(`space-y-2`,d),children:[b&&l&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs font-medium text-amber-100`,children:l}),(0,Z.jsx)(dc,{label:h,triggerLabel:y,selectId:i,selectedValue:t,onChange:n,disabled:s,contentClassName:f,triggerClassName:p,groups:[{label:``,options:[...o?[{value:``,label:g}]:[],..._.map(e=>({value:e.id,label:El(e),disabled:e.kind===`project_root`&&!!u}))]}]}),u&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:u})]})},KN=e=>{let t=e.trim();return t?t.replace(/[^a-zA-Z0-9\s-]/g,``).trim().replace(/\s+/g,`-`).slice(0,60)||`bundle`:null},qN={subtle:`outline`,brand:`default`},JN=({heading:e,bundles:t,stackConfigurationSections:n=!1,showModelSelector:r=!1,agentSettingsPresentation:i=`panel`,preferWideBundleSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialTitle:c=``,initialDescription:l=``,initialModel:u=``,initialVariant:d=``,initialSkills:f=[],initialWorktreeBundleId:p=null,projectId:m=null,jiraImportState:h=`hidden`,onImportFromJira:g,onCancel:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,titleInputId:x,descriptionInputId:S,bundleSelectId:C,modelSelectId:w,variantSelectId:T,skillsSelectId:E,showEmptyBundleOption:D=!0,primaryAction:O,secondaryAction:k,tertiaryAction:A,planAction:j,beforeActionsContent:M,footerLeadingContent:N,onPlanActiveChange:P,onDirtyChange:F,onAgentSettingsChange:I})=>{let{t:L}=X(`common`),[R,z]=(0,Y.useState)([]),[B,ee]=(0,Y.useState)([]),[te,ne]=(0,Y.useState)(!1),[V,re]=(0,Y.useState)(!1),[H,ie]=(0,Y.useState)(null),ae=(0,Y.useRef)(null),oe=L(D?`ticketEditor.automaticBundleLabel`:`bundleSelector.emptyLabel`),se=[...R.filter(e=>!B.includes(e.id)),...t.filter(e=>!B.includes(e.id)&&!R.some(t=>t.id===e.id))],ce=h!==`hidden`;return(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,Z.jsx)(LN,{initialTitle:c,initialDescription:l,initialModel:u,initialVariant:d,initialSkills:f,initialWorktreeBundleId:p,validWorktreeBundleIds:se.map(e=>e.id),showModelSelector:r,availableModels:o,availableSkills:s,showSkillsSelector:r,onCancel:_,disableEscapeClose:te,onDirtyChange:F,onAgentSettingsChange:I,children:({title:e,description:t,model:r,variant:o,skills:s,extra:c,availableModels:l,availableSkills:u,showModelSelector:d,showSkillsSelector:f,setTitle:p,setDescription:F,setModel:I,setVariant:R,setSkills:B,setExtra:le,isValid:U})=>{let ue=l.find(e=>e.id===r)??null,de=c.worktree_bundle_id?null:KN(e),fe={title:e.trim(),description:t.trim(),model:r.trim()||null,variant:o.trim()||null,skills:s,worktree_bundle_id:c.worktree_bundle_id,...H?{external_source:H}:{}},pe=async()=>{if(!j)return;re(!0);let e=new AbortController;ae.current=e,P?.(!0);try{await j.onClick(fe),P?.(!1)}catch(t){e.signal.aborted||(P?.(!1),Q.error(t instanceof Error?t.message:L(`ticketEditor.planningFailed`),{id:`ticket-planning-error`}))}finally{ae.current=null,re(!1)}},me=async e=>{if(!v)throw Error(L(`ticketEditor.bundleCreationUnavailable`));let t=await v(e);return z(e=>[t,...e.filter(e=>e.id!==t.id)]),ee(e=>e.filter(e=>e!==t.id)),le({worktree_bundle_id:t.id}),ne(!1),t},he=async e=>{y&&(await y(e),ee(t=>t.includes(e)?t:[...t,e]),z(t=>t.filter(t=>t.id!==e)),c.worktree_bundle_id===e&&le({worktree_bundle_id:null}))},ge=()=>{U&&(V&&ae.current?.abort(),O.onClick(fe))},W=i===`popover`&&!n,_e=a&&i===`popover`,ve=n?`flex flex-col gap-3`:W?`grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_max-content]`:`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,0.82fr)_minmax(0,1.18fr)]`,ye=n?`flex items-end gap-3`:W?`flex flex-col gap-2 sm:grid sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end sm:gap-3`:`flex flex-col gap-2 sm:flex-row sm:items-end`,be=i===`popover`?(0,Z.jsx)(UN,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:ue,onModelChange:I,onVariantChange:R,onSkillsChange:B,modelSelectId:w,variantSelectId:T,skillsSelectId:E,className:`h-10 self-end`}):(0,Z.jsx)(VN,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:ue,onModelChange:I,onVariantChange:R,onSkillsChange:B,modelSelectId:w,variantSelectId:T,skillsSelectId:E,layout:n?`stacked`:`wrap`});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ge()},className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:ce?`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,1fr)_22rem]`:`grid grid-cols-1 gap-3`,children:[(0,Z.jsx)(xu,{label:L(`ticketEditor.titleLabel`),htmlFor:x,children:(0,Z.jsx)(We,{id:x,type:`text`,value:e,onChange:e=>p(e.target.value),placeholder:L(`ticketEditor.titlePlaceholder`),autoFocus:!0})}),ce&&(0,Z.jsx)(WN,{jiraImportState:h,onImportFromJira:g,onImported:e=>{p(e.title),F(e.description),ie(e.external_source)},inputId:`jira-import-reference`,className:`lg:min-h-[90px]`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2`,children:[(0,Z.jsx)(xu,{label:L(`ticketEditor.descriptionLabel`),htmlFor:S,className:`gap-0`,children:(0,Z.jsx)(Z.Fragment,{})}),(0,Z.jsx)(Zp,{projectId:m,suggestionAnchor:`caret`,wrapperClassName:`flex flex-1 min-h-0`,id:S,value:t,onValueChange:F,placeholder:L(`ticketEditor.descriptionPlaceholder`),disabled:V,className:V?`flex-1 min-h-0 animate-pulse`:`flex-1 min-h-0`})]}),(0,Z.jsxs)(`div`,{className:ve,children:[(0,Z.jsxs)(`div`,{className:ye,children:[(0,Z.jsxs)(`div`,{className:_e?`min-w-0 flex-1 sm:min-w-[19rem]`:`min-w-0 flex-1`,children:[(0,Z.jsx)(GN,{bundles:se,value:c.worktree_bundle_id??``,onChange:e=>le({worktree_bundle_id:e||null}),label:n?``:void 0,selectId:C,emptyLabel:oe,showEmptyOption:D,hideProjectRootBundles:!0,triggerClassName:_e?`sm:min-w-[19rem]`:void 0,contentClassName:_e?`w-[min(30rem,calc(100vw-2rem))] min-w-[24rem] max-w-[calc(100vw-2rem)]`:void 0}),de&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground absolute max-w-80`,children:[L(`ticketEditor.bundlePreview`),` `,(0,Z.jsx)(`span`,{className:`text-foreground`,children:de})]})]}),v&&y&&(0,Z.jsx)(K,{type:`button`,onClick:()=>{(async()=>{try{b&&await b()}catch{}ne(!0)})()},variant:`outline`,size:n?`sm`:`default`,className:n?`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`:`h-10 whitespace-nowrap border-sky-500/35 bg-sky-500/12 px-4 text-sky-100 hover:border-sky-400 hover:bg-sky-500/20 hover:text-white`,children:L(`ticketEditor.manageBundles`)})]}),be]})]}),M,(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex min-h-8 items-center`,children:N}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,onClick:_,variant:`ghost`,children:L(`ticketEditor.cancel`)}),j&&(V?(0,Z.jsx)(rT,{label:L(`ticketEditor.planning`)}):(0,Z.jsxs)(K,{type:`button`,disabled:!U,variant:`outline`,onClick:()=>{U&&pe()},children:[(0,Z.jsx)(Wd,{className:`h-4 w-4`}),j.label]})),(0,Z.jsxs)(K,{type:`submit`,disabled:!U||V,variant:qN[O.variant],children:[O.label,O.showAdvanceIcon&&(0,Z.jsx)(yw,{className:`h-3.5 w-3.5`})]}),k&&(0,Z.jsxs)(K,{type:`button`,disabled:!U||V,onClick:()=>{!U||V||k.onClick(fe)},variant:qN[k.variant],children:[k.label,k.showAdvanceIcon&&(0,Z.jsx)(yw,{className:`h-3.5 w-3.5`})]}),A&&(0,Z.jsxs)(K,{type:`button`,disabled:!U||V,onClick:()=>{!U||V||A.onClick(fe)},variant:qN[A.variant],children:[A.label,A.showAdvanceIcon&&(0,Z.jsx)(yw,{className:`h-3.5 w-3.5`})]})]})]})]}),te&&v&&y&&(0,Z.jsx)(wu,{bundles:se,selectedBundleId:c.worktree_bundle_id,onSelectBundle:e=>le({worktree_bundle_id:e}),onCreateBundle:me,onDeleteBundle:he,onClose:()=>ne(!1)})]})}})]})},YN=(e,t)=>Ne.t(`projects:memory.${e}`,t),XN=e=>YN(`stageLabels.${e}`),ZN=e=>YN(`priorityLabels.${e}`),QN=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
|
|
103
|
+
`))){t[t.length-1]=n;continue}t[t.length-1]=`${e}\n${n}`}return t},PN=({visibleContent:e,internalLog:t,showThinking:n})=>{let r=NN(jN(e));if(!n||!t||t.trim().length===0)return r.map(e=>({tone:`primary`,content:e}));let i=NN(jN(t));if(i.length===0)return r.map(e=>({tone:`primary`,content:e}));let a=[],o=0;for(let e of i){let t=r[o];if(t&&TN(t)===TN(e)){a.push({tone:`primary`,content:e}),o+=1;continue}a.push({tone:`secondary`,content:e})}for(;o<r.length;)a.push({tone:`primary`,content:r[o]}),o+=1;return a},FN=(0,Y.memo)(({visibleContent:e,internalLog:t,showThinking:n})=>{let r=(0,Y.useMemo)(()=>PN({visibleContent:e,internalLog:t,showThinking:n}),[t,n,e]);return r.length===0?null:(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:r.map((e,t)=>(0,Z.jsx)(HM,{content:e.content,className:e.tone===`secondary`?`text-muted-foreground [&_code]:text-violet-200 [&_pre]:bg-background/70`:void 0},`${e.tone}:${t+1}`))})});FN.displayName=`AssistantMessageContent`;var IN=(0,Y.memo)(({attachments:e})=>{let{t}=X(`common`),[n,r]=(0,Y.useState)(null);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[e.map(e=>{let n=l(e.content_url);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/80 bg-background/70 transition-colors hover:border-border`,children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":t(`attachmentPreviewDialog.previewImageAriaLabel`,{name:e.original_name}),className:`block w-full cursor-zoom-in overflow-hidden text-left outline-none transition-opacity hover:opacity-95 focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:()=>{r(e)},children:(0,Z.jsx)(`img`,{src:n,alt:t(`conversationPane.attachmentPreviewAlt`,{name:e.original_name}),className:`h-28 w-full object-cover`,loading:`lazy`})}),(0,Z.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:e.original_name}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:zp(e.size_bytes)})]})]},e.id)}),(0,Z.jsx)(Bp,{attachment:n,onClose:()=>{r(null)}})]})});IN.displayName=`MessageAttachments`;var LN=(0,Y.memo)(({message:e,showThinking:t=!1,internalLog:n=null,footer:r=null})=>{let i=e.role===`user`,a=i&&e.kind===`description`,o=e.attachments??[],[s,c]=(0,Y.useState)(!1),l=i?dN(e.content):null,u=(0,Y.useMemo)(()=>!a||!e.content?{text:e.content,truncated:!1}:QM(e.content),[a,e.content]);return(0,Z.jsx)(`div`,{"data-message-role":e.role,className:`flex ${i?`justify-end`:`justify-start`}`,children:(0,Z.jsxs)(mu,{className:i?`min-w-0 max-w-full w-[94%] border-sky-500/30 bg-sky-500/10 shadow-none sm:w-auto sm:max-w-[85%]`:`min-w-0 max-w-full w-[94%] border-slate-400/30 bg-slate-400/10 shadow-none sm:w-auto sm:max-w-[85%]`,size:`sm`,children:[(0,Z.jsxs)(yu,{className:`min-w-0 flex flex-col gap-2 px-3 py-3 sm:px-4 sm:py-4 ${i?`[overflow-wrap:anywhere]`:``}`,children:[e.displayTitle&&(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e.displayTitle}),i?l?(0,Z.jsx)(qM,{content:e.content,parsed:l}):a?(0,Z.jsx)(vT,{description:e.content,descriptionClass:`whitespace-pre-wrap text-sm leading-relaxed text-foreground`,isExpanded:s,collapsedState:u,useStaleLikeStyling:!1,onExpand:()=>c(!0),onCollapse:()=>c(!1)}):e.content?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground [overflow-wrap:anywhere]`,children:e.content}):null:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Wd,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(FN,{visibleContent:e.content,internalLog:n,showThinking:t})})]}),i&&o.length>0?(0,Z.jsx)(IN,{attachments:o}):null]}),r?(0,Z.jsx)(bu,{className:`border-t border-border/60 px-4 py-3`,children:r}):null]})})});LN.displayName=`MessageBubble`;var RN=()=>{let{t:e}=X(`common`);return(0,Z.jsxs)(`div`,{role:`status`,"aria-label":e(`conversationPane.agentActivityAriaLabel`),"aria-live":`polite`,className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,"aria-hidden":`true`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_infinite_backwards] motion-reduce:animate-none`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.3s_infinite_backwards] motion-reduce:animate-none`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-current motion-safe:animate-[dot-wave_2s_ease-in-out_0.6s_infinite_backwards] motion-reduce:animate-none`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e(`conversationPane.agentWorkingSrText`)})]})},zN=(0,Y.memo)(({ticketTitle:e,streamingResponse:t,internalLog:n,showThinking:r,statusLabel:i,showActivity:a=!0})=>{let{t:o}=X(`common`),s=i??o(`conversationPane.statusWorking`);return(0,Z.jsx)(`div`,{className:`flex justify-start`,children:(0,Z.jsx)(mu,{className:`min-w-0 max-w-full w-[94%] border-slate-400/30 bg-slate-400/10 shadow-none sm:w-full sm:max-w-[85%]`,size:`sm`,children:(0,Z.jsxs)(yu,{className:`flex flex-col gap-3 px-3 py-3 sm:px-4 sm:py-4`,children:[e?(0,Z.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-muted-foreground`,children:e}):null,(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(Wd,{className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{children:s})]}),t||r&&n?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Wd,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(FN,{visibleContent:t,internalLog:n,showThinking:r})})]}):null,a?(0,Z.jsx)(RN,{}):null]})})})});zN.displayName=`PendingAgentMessage`;var BN=(0,Y.memo)(({messages:e,messageThinkingLogs:t,effectiveShowThinking:n,internalLog:r,pendingAgentTitle:i,streamingResponse:a,isRunning:o,isPendingAgentVisible:s,interruptedPendingSnapshot:c,isLoading:l,emptyStateText:u,renderMessageFooter:d,hidePendingAgentTitle:f=!1})=>{let{t:p}=X(`common`),m=c?e.findIndex(e=>e.id===c.latestMessageIdAtCapture):-1,h=m>=0?e.slice(0,m+1):e,g=m>=0?e.slice(m+1):[],_=e=>(0,Z.jsx)(LN,{message:e,footer:d?.(e)??null,showThinking:n&&t.has(e.id),internalLog:t.get(e.id)??null},`${e.ticket_id}:${e.id}`);return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-5`,children:[e.length===0&&!o&&u&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-6 text-sm text-muted-foreground`,children:l?p(`conversationPane.loadingConversation`):u}),h.map(_),o&&s&&(0,Z.jsx)(zN,{ticketTitle:f?null:i,streamingResponse:a,internalLog:r,showThinking:n}),!o&&c?(0,Z.jsx)(zN,{ticketTitle:f?null:c.ticketTitle,streamingResponse:c.streamingResponse,internalLog:c.internalLog,showThinking:c.showThinking,statusLabel:p(`conversationPane.statusInterrupted`),showActivity:!1}):null,g.map(_)]})});BN.displayName=`ConversationTranscript`;var VN=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,legacyThinkingTicketId:a=null,previousThinkingLog:o=null,previousThinkingMessageId:s=null,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d=!1,autoScrollBehavior:f=`sticky`,surfaceVariant:p=`default`,canShowComposer:m,cardClassName:h,header:g,composerControls:_,composerInlineControls:v,composerTheme:y=`default`,composerSize:b=`default`,showThinkingPlacement:x=`body`,pinComposerToBottom:S=!1,isExternallyResizing:C=!1,pendingAgentRevealKey:w=null,pendingAgentRevealDelayMs:T=0,composerFocusNonce:E=0,forceScrollToBottomKey:D,layoutKey:O,scrollLayoutKey:k,blurComposerOnSendStart:A=!1,followUpPrompt:j,draftAttachments:M=[],followUpPlaceholder:N,emptyStateText:P,autoFocusComposer:F=!1,renderMessageFooter:I,isSendingFollowUp:L,isUploadingAttachments:R=!1,canAttachImages:z=!1,followUpDisabledReason:B,hidePendingAgentTitle:ee=!1,onFollowUpPromptChange:te,onFollowUpKeyDown:ne,onFollowUpPaste:V,onUploadAttachments:re,onRemoveAttachment:H,onFollowUpSubmit:ie})=>{let ae=(0,Y.useRef)(null),oe=(0,Y.useRef)(null),se=(0,Y.useRef)(!1),ce=(0,Y.useRef)(null),le=(0,Y.useRef)(r),U=(0,Y.useRef)(k),ue=(0,Y.useRef)(!1),de=(0,Y.useRef)(j),fe=(0,Y.useRef)(E),pe=(0,Y.useRef)(D),me=(0,Y.useRef)(C),he=(0,Y.useRef)(!0),ge=(0,Y.useRef)(!1),W=(0,Y.useRef)(!1),_e=(0,Y.useRef)(L),ve=(0,Y.useRef)(null),ye=(0,Y.useRef)(null),[be,xe]=(0,Y.useState)(xN),[Se,Ce]=(0,Y.useState)(null),[we,Te]=(0,Y.useState)(null),Ee=(0,Y.useId)(),{t:De}=X(`common`),Oe=n.length>0?n[n.length-1].id:null,ke=!u||!w||Se===w,K=!!(r&&r.trim().length>0||o&&o.trim().length>0),Ae=be&&K,je=!!(l||Ae&&r),Me=p===`chat`,Ne=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ud,{id:Ee,"aria-label":De(`conversationPane.showThinkingAriaLabel`),checked:be,onCheckedChange:xe}),(0,Z.jsx)(Xs,{htmlFor:Ee,className:`text-sm text-muted-foreground`,children:De(`conversationPane.showThinkingLabel`)})]}),Pe=P===void 0?De(`conversationPane.noMessagesYet`):P,Fe=typeof g==`function`?g({showThinkingControl:Ne}):g,Ie=x===`header`&&!!Fe&&typeof g!=`function`,Le=!Ie&&typeof g!=`function`,Re=(0,Y.useMemo)(()=>i||u||!r?null:[...n].reverse().find(e=>e.role===`assistant`?a?e.ticket_id===a:!0:!1)?.id??null,[i,r,u,a,n]),ze=(0,Y.useMemo)(()=>{let e=new Map;if(!Ae)return e;s&&o&&e.set(s,o);let t=i??Re;return!u&&t&&r&&e.set(t,r),e},[i,Ae,Re,r,u,o,s]),Be=e=>{SN(()=>{Te(e)})};return(0,Y.useEffect)(()=>{Be(null)},[O]),(0,Y.useEffect)(()=>{u&&Be(null)},[u]),(0,Y.useEffect)(()=>{!u||!ke||!je||Be(e=>e&&e.latestMessageIdAtCapture===Oe&&e.internalLog===r&&e.showThinking===Ae&&e.streamingResponse===l&&e.ticketTitle===c?e:{latestMessageIdAtCapture:Oe,internalLog:r,showThinking:Ae,streamingResponse:l,ticketTitle:c})},[Ae,je,r,ke,u,Oe,c,l]),(0,Y.useEffect)(()=>{Be(e=>e&&(Oe!==e.latestMessageIdAtCapture&&n[n.length-1]?.role===`assistant`?null:e))},[Oe,n]),(0,Y.useEffect)(()=>{try{if(be){window.localStorage.setItem(pN,`true`);return}window.localStorage.removeItem(pN)}catch{}},[be]),(0,Y.useEffect)(()=>()=>{ve.current!==null&&window.clearTimeout(ve.current)},[]),(0,Y.useEffect)(()=>{ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),!(!w||T<=0||Se===w)&&(ve.current=window.setTimeout(()=>{ve.current=null,Ce(w)},T))},[T,w,Se]),(0,Y.useEffect)(()=>{let e=ae.current;if(!e)return;let t=null,n=oe.current===null,i=oe.current!==Oe,a=!se.current&&u,o=ce.current!==l,s=le.current!==r,c=U.current!==k,d=ue.current!==Ae,p=wN(e),m=f===`always`||n||he.current,h=m||p;return c&&(he.current=h),m&&(n||i||a||o||d||Ae&&s)&&CN(e),c&&h&&(CN(e),t=window.requestAnimationFrame(()=>{CN(e)})),oe.current=Oe,se.current=u,ce.current=l,le.current=r,U.current=k,ue.current=Ae,()=>{t!==null&&window.cancelAnimationFrame(t)}},[Ae,r,u,k,Oe,l,f]),(0,Y.useEffect)(()=>{let e=ae.current,t=!_e.current&&L;e&&t&&(A&&ye.current?.blur(),he.current=!0,CN(e)),_e.current=L},[A,L]),(0,Y.useEffect)(()=>{let e=ae.current,t=pe.current!==D;if(pe.current=D,!e||!D||!t)return;he.current=!0,CN(e);let n=requestAnimationFrame(()=>{CN(e)});return()=>{cancelAnimationFrame(n)}},[D]),(0,Y.useEffect)(()=>{let e=ae.current;if(!e){me.current=C;return}let t=!me.current&&C,n=me.current&&!C;t&&(ge.current=he.current||wN(e)),n&&(he.current=wN(e),ge.current=!1),me.current=C},[C]),(0,Y.useEffect)(()=>{let e=ae.current;if(!e||typeof ResizeObserver!=`function`)return;let t=new ResizeObserver(()=>{(he.current||ge.current||W.current)&&CN(e)});return t.observe(e),()=>{t.disconnect()}},[]),(0,Y.useEffect)(()=>{let e=ae.current;!e||!ke||!u||(f===`always`||he.current)&&CN(e)},[f,ke,u]),(0,Y.useEffect)(()=>{let e=fe.current!==E;if(fe.current=E,!F&&!e||!m||L)return;let t=ye.current;if(!t)return;let n=requestAnimationFrame(()=>{t.focus()});return()=>{cancelAnimationFrame(n)}},[F,m,E,L,O]),(0,Y.useEffect)(()=>{let e=ye.current;if(!e||!m){de.current=j;return}let t=ae.current,n=de.current!==j;de.current=j;let r=!!(n&&t&&(he.current||wN(t)));if(W.current=r,fm(e),!t||!r){W.current=!1;return}let i=requestAnimationFrame(()=>{he.current=!0,CN(t),W.current=!1});return()=>{cancelAnimationFrame(i),W.current=!1}},[m,j,O]),(0,Z.jsx)(`section`,{"aria-label":De(`conversationPane.sectionAriaLabel`),className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Z.jsxs)(mu,{size:`sm`,className:G(`min-h-0 flex-1 gap-0 overflow-hidden border-border/80 bg-card/70 shadow-none`,Me&&`rounded-none`,h),children:[Fe&&(0,Z.jsxs)(`div`,{className:G(`flex items-start justify-between gap-3 border-b border-border/80 px-4`,Me?`pt-3 pb-1`:`py-3`),children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:Fe}),Ie&&Ne]}),Le&&(0,Z.jsx)(`div`,{className:`flex justify-end px-4 pt-3`,children:Ne}),(0,Z.jsx)(yu,{"aria-label":De(`conversationPane.contentAriaLabel`),ref:ae,onScroll:e=>{C&&ge.current||W.current||(he.current=wN(e.currentTarget))},className:G(`min-h-0 flex-1 overflow-y-auto`,Me?`border-b border-border/80 px-2 pt-0 !pb-2.5 data-[size=sm]:!pb-2.5 sm:px-4`:`border-b border-border/80 px-4 py-4`),children:(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-col`,children:(0,Z.jsx)(BN,{messages:n,messageThinkingLogs:ze,effectiveShowThinking:Ae,internalLog:r,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isPendingAgentVisible:ke,interruptedPendingSnapshot:we,isLoading:d,emptyStateText:Pe,renderMessageFooter:I,hidePendingAgentTitle:ee})})}),m&&(0,Z.jsx)(bu,{className:G(`mt-auto`,Me?`pt-1`:S&&`border-t border-border/80 bg-card/95 pt-4 backdrop-blur supports-[backdrop-filter]:bg-card/80`),children:(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[_?(0,Z.jsx)(`div`,{children:_}):null,(0,Z.jsx)($p,{projectId:e,suggestionTicketId:t,value:j,attachments:M,placeholder:N,disabled:L,isSubmitDisabled:u,isSending:L,isUploadingAttachments:R,canAttachImages:z,disabledReason:B,onValueChange:te,onKeyDown:ne,onPaste:V,onUploadAttachments:re,onRemoveAttachment:H,onSubmit:ie,textareaRef:ye,composerInlineControls:v,composerTheme:y,composerSize:b})]})})]})})},HN=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,previousThinkingLog:a=null,previousThinkingMessageId:o=null,streamingResponse:s,isRunning:c,canShowComposer:l,header:u,followUpComposerControls:d,composerTheme:f=`default`,surfaceVariant:p=`default`,composerSize:m=`default`,forceScrollToBottomKey:h,layoutKey:g,scrollLayoutKey:_,followUpPlaceholder:v=`Follow up on this ticket`,emptyStateText:y,autoFocusComposer:b=!1,pendingAgentTitle:x=null,followUpPrompt:S,isSendingFollowUp:C,followUpDisabledReason:w,onFollowUpPromptChange:T,onFollowUpKeyDown:E,onFollowUpSubmit:D})=>(0,Z.jsx)(VN,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,currentThinkingMessageId:i,previousThinkingLog:a,previousThinkingMessageId:o,pendingAgentTitle:x,streamingResponse:s,isRunning:c,autoScrollBehavior:`sticky`,surfaceVariant:p,canShowComposer:l,header:u,composerInlineControls:d,composerTheme:f,composerSize:m,forceScrollToBottomKey:h,layoutKey:g,scrollLayoutKey:_,followUpPrompt:S,followUpPlaceholder:v,emptyStateText:y,autoFocusComposer:b,isSendingFollowUp:C,followUpDisabledReason:w,onFollowUpPromptChange:T,onFollowUpKeyDown:E,onFollowUpSubmit:D}),UN=({title:e,items:t,resolveTicket:n,resolveOtherTicketId:r,onDeleteDependency:i})=>{let{t:a}=X(`common`);return t.length===0?null:(0,Z.jsxs)(`section`,{"aria-label":e,className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 truncate text-sm text-foreground`,children:n(r(e))?.title??a(`ticketDependencyDetails.unknownTicket`)}),i&&(0,Z.jsx)(K,{type:`button`,onClick:()=>{i(e)},variant:`destructive`,size:`xs`,children:a(`ticketDependencyDetails.remove`)})]},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`))})]})},WN=({items:e,resolveTicket:t,onDeleteDependency:n})=>{let{t:r}=X(`common`);if(e.length===0)return null;let i=e.map(e=>{let n=t(e.blocker_ticket_id);return{dependency:e,ready:Gw(n),title:n?.title??r(`ticketDependencyDetails.unknownTicket`)}}),a=i.filter(e=>!e.ready),o=a.length===0?r(`ticketDependencyDetails.summaryReady`):r(`ticketDependencyDetails.summaryBlocked`,{count:a.length});return(0,Z.jsxs)(`section`,{"aria-label":r(`ticketDependencyDetails.buildReadinessAriaLabel`),className:`flex flex-col gap-2 rounded-lg border border-border bg-card/70 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:r(`ticketDependencyDetails.buildReadinessTitle`)}),(0,Z.jsx)(U,{variant:a.length===0?`success`:`warning`,children:a.length===0?r(`ticketDependencyDetails.ready`):r(`ticketDependencyDetails.blocked`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.title}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(U,{variant:e.ready?`success`:`warning`,children:e.ready?r(`ticketDependencyDetails.buildDone`):r(`ticketDependencyDetails.waitingOnBuild`)}),n&&(0,Z.jsx)(K,{type:`button`,onClick:()=>{n(e.dependency)},variant:`destructive`,size:`xs`,children:r(`ticketDependencyDetails.remove`)})]})]},`${e.dependency.blocker_ticket_id}:${e.dependency.dependent_ticket_id}`))})]})},GN=({blocks:e,blockedBy:t,resolveTicket:n,onDeleteDependency:r})=>{let{t:i}=X(`common`),[a,o]=(0,Y.useState)(!1);return e.length===0&&t.length===0?null:(0,Z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>{o(e=>!e)},className:`flex w-full cursor-pointer items-center justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-accent/60`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:i(`ticketDependencyDetails.dependencyDetails`)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(a?`ticketDependencyDetails.hide`:`ticketDependencyDetails.show`)})]}),a&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 border-t border-border px-4 py-3 lg:grid-cols-2`,children:[(0,Z.jsx)(UN,{title:i(`ticketDependencyDetails.blocksTitle`),items:e,resolveTicket:n,resolveOtherTicketId:e=>e.dependent_ticket_id,onDeleteDependency:r}),(0,Z.jsx)(WN,{items:t,resolveTicket:n,onDeleteDependency:r})]})]})},KN=({initialTitle:e=``,initialDescription:t=``,initialModel:n=``,initialVariant:r=``,initialSkills:i=[],initialWorktreeBundleId:a=null,validWorktreeBundleIds:o,availableModels:s=[],availableSkills:c=[],showModelSelector:l=!1,showSkillsSelector:u=!1,disableEscapeClose:d=!1,onDirtyChange:f,onAgentSettingsChange:p,onSubmit:m,onCancel:h,children:g})=>{let[_,v]=(0,Y.useState)(e),[y,b]=(0,Y.useState)(t),[x,S]=(0,Y.useState)(n),[C,w]=(0,Y.useState)(r),[T,E]=(0,Y.useState)(i),[D,O]=(0,Y.useState)({worktree_bundle_id:a});lu(h,{disabled:d});let k=D.worktree_bundle_id!==null&&o&&!o.includes(D.worktree_bundle_id)?null:D.worktree_bundle_id,A=_.trim()&&y.trim(),j=_!==e||y!==t||x!==n||C!==r||T.length!==i.length||T.some((e,t)=>e!==i[t])||k!==a;(0,Y.useEffect)(()=>{f?.(j)},[j,f]),(0,Y.useEffect)(()=>{p?.({model:x.trim()||null,variant:C.trim()||null,skills:T})},[x,p,T,C]);let M=(0,Y.useCallback)(()=>{A&&m?.({title:_.trim(),description:y.trim(),model:x.trim()||null,variant:C.trim()||null,skills:T,worktree_bundle_id:k})},[y,A,x,m,k,T,_,C]),N={title:_,description:y,model:x,variant:C,skills:T,extra:{worktree_bundle_id:k},availableModels:s,availableSkills:c,showModelSelector:l,showSkillsSelector:u,setTitle:v,setDescription:b,setModel:S,setVariant:w,setSkills:E,setExtra:O,isValid:!!A,onSubmit:M,onCancel:h};return g?(0,Z.jsx)(Z.Fragment,{children:g(N)}):null},qN=2,JN=e=>e.length===0?`No skills`:e.length<=qN?e.join(`, `):`${e.slice(0,qN).join(`, `)} +${e.length-qN}`,YN=({skills:e,availableSkills:t,onSkillsChange:n,selectId:r,label:i=`Skills`,triggerAriaLabel:a,disabled:o=!1,className:s,triggerClassName:c,showSelectedBadges:l=!0})=>{let u=e.map(e=>t.find(t=>t.name===e)?.name??e).filter(Boolean),d=u.slice(0,qN),f=Math.max(0,u.length-d.length);return(0,Z.jsxs)(`div`,{className:G(`flex flex-col gap-2`,s),children:[(0,Z.jsx)(qd,{label:i,triggerLabel:JN(u),triggerAriaLabel:a??`Skills`,selectId:r,selectedValues:e,onToggle:t=>{n(e.includes(t)?e.filter(e=>e!==t):[...e,t])},disabled:o,contentClassName:`min-w-[22rem]`,triggerClassName:c,groups:[{label:``,options:t.map(e=>({value:e.name,label:e.name}))}]}),l&&u.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[d.map(e=>(0,Z.jsx)(U,{variant:`outline`,className:`border-border/80 bg-background/70 text-[11px] text-foreground`,children:e},e)),f>0&&(0,Z.jsxs)(U,{variant:`ghost`,className:`px-1.5 text-[11px] text-muted-foreground`,children:[`+`,f,` more`]})]})]})},XN=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h,layout:g=`wrap`})=>{let _=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,Z.jsx)(`section`,{className:G(`rounded-2xl border border-border/70 bg-secondary/20 p-3`,h),"aria-label":`AI settings`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`}),(0,Z.jsx)(CT,{model:e,variant:t,skills:n})]}),(0,Z.jsxs)(`div`,{className:G(`gap-3`,g===`stacked`?`flex flex-col`:`flex flex-wrap`),children:[(0,Z.jsx)(fc,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[10rem] flex-[1.35_1_10rem]`}),_&&(0,Z.jsx)(pc,{variant:t,selectedModel:s,showVariantSelector:_,onVariantChange:l,selectId:f,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[7rem] flex-[0.7_1_7rem]`}),i&&(0,Z.jsx)(YN,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,className:g===`stacked`?`min-w-0`:`min-w-[8rem] flex-[0.95_1_8rem]`,showSelectedBadges:!1})]})]})})},ZN=({model:e,variant:t,skills:n,selectedModel:r})=>{let i=[];return e&&i.push(r?.label??e),t&&i.push(t),n.length>0&&i.push(`${n.length} skill${n.length===1?``:`s`}`),i.length===0?`AI defaults`:i.join(` / `)},QN=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0,_=ZN({model:e,variant:t,skills:n,selectedModel:s});return!r&&!i?null:(0,Z.jsxs)(Zs,{children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,variant:`outline`,disabled:m,className:G(`max-w-full w-fit justify-start gap-2 text-left sm:max-w-80`,h),"aria-label":`AI settings`,children:[(0,Z.jsx)(Wd,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:_})]})}),(0,Z.jsx)($s,{align:`start`,className:`w-80 max-w-[calc(100vw-2rem)] p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,children:`AI settings`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(fc,{model:e,showModelSelector:r,availableModels:a,onModelChange:c,selectId:d,disabled:m}),(0,Z.jsx)(pc,{variant:t,selectedModel:s,showVariantSelector:g,onVariantChange:l,selectId:f,disabled:m}),i&&(0,Z.jsx)(YN,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,disabled:m,showSelectedBadges:!1})]})]})})]})},$N=({jiraImportState:e,onImportFromJira:t,onImported:n,inputId:r,className:i})=>{let{t:a}=X(`common`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(!1);if(e!==`enabled`)return null;let u=!!t,d=async()=>{if(!(!t||!o.trim())){l(!0);try{n(await t(o.trim())),s(``)}catch(e){Q.error(e instanceof Error?e.message:a(`jiraImportField.error`),{id:`jira-import-error`})}finally{l(!1)}}};return(0,Z.jsx)(xu,{label:a(`jiraImportField.label`),htmlFor:r,className:i,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(We,{id:r,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||!u||(e.preventDefault(),d())},placeholder:a(`jiraImportField.placeholder`),disabled:!u||c})}),(0,Z.jsxs)(K,{type:`button`,variant:`outline`,disabled:!u||!o.trim()||c,onClick:()=>{d()},className:`sm:min-w-[7.5rem]`,children:[(0,Z.jsx)(Ef,{className:`h-4 w-4`}),a(c?`jiraImportField.importing`:`jiraImportField.import`)]})]})})},eP=({bundles:e,value:t,onChange:n,label:r,selectId:i=`bundle-selector`,emptyLabel:a,showEmptyOption:o=!0,disabled:s=!1,hideProjectRootBundles:c=!1,projectRootWarning:l=null,projectRootUnavailableReason:u=null,className:d,contentClassName:f,triggerClassName:p})=>{let{t:m}=X(`common`),h=r??m(`bundleSelector.label`),g=a??m(`bundleSelector.emptyLabel`),_=[...c?e.filter(e=>e.kind!==`project_root`):e].sort((e,t)=>e.kind===`project_root`&&t.kind!==`project_root`?-1:+(e.kind!==`project_root`&&t.kind===`project_root`)),v=_.find(e=>e.id===t),y=v?El(v):g,b=v?.kind===`project_root`;return(0,Z.jsxs)(`div`,{className:G(`space-y-2`,d),children:[b&&l&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs font-medium text-amber-100`,children:l}),(0,Z.jsx)(dc,{label:h,triggerLabel:y,selectId:i,selectedValue:t,onChange:n,disabled:s,contentClassName:f,triggerClassName:p,groups:[{label:``,options:[...o?[{value:``,label:g}]:[],..._.map(e=>({value:e.id,label:El(e),disabled:e.kind===`project_root`&&!!u}))]}]}),u&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:u})]})},tP=e=>{let t=e.trim();return t?t.replace(/[^a-zA-Z0-9\s-]/g,``).trim().replace(/\s+/g,`-`).slice(0,60)||`bundle`:null},nP={subtle:`outline`,brand:`default`},rP=({heading:e,bundles:t,stackConfigurationSections:n=!1,showModelSelector:r=!1,agentSettingsPresentation:i=`panel`,preferWideBundleSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialTitle:c=``,initialDescription:l=``,initialModel:u=``,initialVariant:d=``,initialSkills:f=[],initialWorktreeBundleId:p=null,projectId:m=null,jiraImportState:h=`hidden`,onImportFromJira:g,onCancel:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,titleInputId:x,descriptionInputId:S,bundleSelectId:C,modelSelectId:w,variantSelectId:T,skillsSelectId:E,showEmptyBundleOption:D=!0,primaryAction:O,secondaryAction:k,tertiaryAction:A,planAction:j,beforeActionsContent:M,footerLeadingContent:N,onPlanActiveChange:P,onDirtyChange:F,onAgentSettingsChange:I})=>{let{t:L}=X(`common`),[R,z]=(0,Y.useState)([]),[B,ee]=(0,Y.useState)([]),[te,ne]=(0,Y.useState)(!1),[V,re]=(0,Y.useState)(!1),[H,ie]=(0,Y.useState)(null),ae=(0,Y.useRef)(null),oe=L(D?`ticketEditor.automaticBundleLabel`:`bundleSelector.emptyLabel`),se=[...R.filter(e=>!B.includes(e.id)),...t.filter(e=>!B.includes(e.id)&&!R.some(t=>t.id===e.id))],ce=h!==`hidden`;return(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:e}),(0,Z.jsx)(KN,{initialTitle:c,initialDescription:l,initialModel:u,initialVariant:d,initialSkills:f,initialWorktreeBundleId:p,validWorktreeBundleIds:se.map(e=>e.id),showModelSelector:r,availableModels:o,availableSkills:s,showSkillsSelector:r,onCancel:_,disableEscapeClose:te,onDirtyChange:F,onAgentSettingsChange:I,children:({title:e,description:t,model:r,variant:o,skills:s,extra:c,availableModels:l,availableSkills:u,showModelSelector:d,showSkillsSelector:f,setTitle:p,setDescription:F,setModel:I,setVariant:R,setSkills:B,setExtra:le,isValid:U})=>{let ue=l.find(e=>e.id===r)??null,de=c.worktree_bundle_id?null:tP(e),fe={title:e.trim(),description:t.trim(),model:r.trim()||null,variant:o.trim()||null,skills:s,worktree_bundle_id:c.worktree_bundle_id,...H?{external_source:H}:{}},pe=async()=>{if(!j)return;re(!0);let e=new AbortController;ae.current=e,P?.(!0);try{await j.onClick(fe),P?.(!1)}catch(t){e.signal.aborted||(P?.(!1),Q.error(t instanceof Error?t.message:L(`ticketEditor.planningFailed`),{id:`ticket-planning-error`}))}finally{ae.current=null,re(!1)}},me=async e=>{if(!v)throw Error(L(`ticketEditor.bundleCreationUnavailable`));let t=await v(e);return z(e=>[t,...e.filter(e=>e.id!==t.id)]),ee(e=>e.filter(e=>e!==t.id)),le({worktree_bundle_id:t.id}),ne(!1),t},he=async e=>{y&&(await y(e),ee(t=>t.includes(e)?t:[...t,e]),z(t=>t.filter(t=>t.id!==e)),c.worktree_bundle_id===e&&le({worktree_bundle_id:null}))},ge=()=>{U&&(V&&ae.current?.abort(),O.onClick(fe))},W=i===`popover`&&!n,_e=a&&i===`popover`,ve=n?`flex flex-col gap-3`:W?`grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_max-content]`:`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,0.82fr)_minmax(0,1.18fr)]`,ye=n?`flex items-end gap-3`:W?`flex flex-col gap-2 sm:grid sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end sm:gap-3`:`flex flex-col gap-2 sm:flex-row sm:items-end`,be=i===`popover`?(0,Z.jsx)(QN,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:ue,onModelChange:I,onVariantChange:R,onSkillsChange:B,modelSelectId:w,variantSelectId:T,skillsSelectId:E,className:`h-10 self-end`}):(0,Z.jsx)(XN,{model:r,variant:o,skills:s,showModelSelector:d,showSkillsSelector:f,availableModels:l,availableSkills:u,selectedModel:ue,onModelChange:I,onVariantChange:R,onSkillsChange:B,modelSelectId:w,variantSelectId:T,skillsSelectId:E,layout:n?`stacked`:`wrap`});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ge()},className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:ce?`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,1fr)_22rem]`:`grid grid-cols-1 gap-3`,children:[(0,Z.jsx)(xu,{label:L(`ticketEditor.titleLabel`),htmlFor:x,children:(0,Z.jsx)(We,{id:x,type:`text`,value:e,onChange:e=>p(e.target.value),placeholder:L(`ticketEditor.titlePlaceholder`),autoFocus:!0})}),ce&&(0,Z.jsx)($N,{jiraImportState:h,onImportFromJira:g,onImported:e=>{p(e.title),F(e.description),ie(e.external_source)},inputId:`jira-import-reference`,className:`lg:min-h-[90px]`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2`,children:[(0,Z.jsx)(xu,{label:L(`ticketEditor.descriptionLabel`),htmlFor:S,className:`gap-0`,children:(0,Z.jsx)(Z.Fragment,{})}),(0,Z.jsx)(Zp,{projectId:m,suggestionAnchor:`caret`,wrapperClassName:`flex flex-1 min-h-0`,id:S,value:t,onValueChange:F,placeholder:L(`ticketEditor.descriptionPlaceholder`),disabled:V,className:V?`flex-1 min-h-0 animate-pulse`:`flex-1 min-h-0`})]}),(0,Z.jsxs)(`div`,{className:ve,children:[(0,Z.jsxs)(`div`,{className:ye,children:[(0,Z.jsxs)(`div`,{className:_e?`min-w-0 flex-1 sm:min-w-[19rem]`:`min-w-0 flex-1`,children:[(0,Z.jsx)(eP,{bundles:se,value:c.worktree_bundle_id??``,onChange:e=>le({worktree_bundle_id:e||null}),label:n?``:void 0,selectId:C,emptyLabel:oe,showEmptyOption:D,hideProjectRootBundles:!0,triggerClassName:_e?`sm:min-w-[19rem]`:void 0,contentClassName:_e?`w-[min(30rem,calc(100vw-2rem))] min-w-[24rem] max-w-[calc(100vw-2rem)]`:void 0}),de&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground absolute max-w-80`,children:[L(`ticketEditor.bundlePreview`),` `,(0,Z.jsx)(`span`,{className:`text-foreground`,children:de})]})]}),v&&y&&(0,Z.jsx)(K,{type:`button`,onClick:()=>{(async()=>{try{b&&await b()}catch{}ne(!0)})()},variant:`outline`,size:n?`sm`:`default`,className:n?`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`:`h-10 whitespace-nowrap border-sky-500/35 bg-sky-500/12 px-4 text-sky-100 hover:border-sky-400 hover:bg-sky-500/20 hover:text-white`,children:L(`ticketEditor.manageBundles`)})]}),be]})]}),M,(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex min-h-8 items-center`,children:N}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,onClick:_,variant:`ghost`,children:L(`ticketEditor.cancel`)}),j&&(V?(0,Z.jsx)(rT,{label:L(`ticketEditor.planning`)}):(0,Z.jsxs)(K,{type:`button`,disabled:!U,variant:`outline`,onClick:()=>{U&&pe()},children:[(0,Z.jsx)(Wd,{className:`h-4 w-4`}),j.label]})),(0,Z.jsxs)(K,{type:`submit`,disabled:!U||V,variant:nP[O.variant],children:[O.label,O.showAdvanceIcon&&(0,Z.jsx)(yw,{className:`h-3.5 w-3.5`})]}),k&&(0,Z.jsxs)(K,{type:`button`,disabled:!U||V,onClick:()=>{!U||V||k.onClick(fe)},variant:nP[k.variant],children:[k.label,k.showAdvanceIcon&&(0,Z.jsx)(yw,{className:`h-3.5 w-3.5`})]}),A&&(0,Z.jsxs)(K,{type:`button`,disabled:!U||V,onClick:()=>{!U||V||A.onClick(fe)},variant:nP[A.variant],children:[A.label,A.showAdvanceIcon&&(0,Z.jsx)(yw,{className:`h-3.5 w-3.5`})]})]})]})]}),te&&v&&y&&(0,Z.jsx)(wu,{bundles:se,selectedBundleId:c.worktree_bundle_id,onSelectBundle:e=>le({worktree_bundle_id:e}),onCreateBundle:me,onDeleteBundle:he,onClose:()=>ne(!1)})]})}})]})},iP=(e,t)=>Ne.t(`projects:memory.${e}`,t),aP=e=>iP(`stageLabels.${e}`),oP=e=>iP(`priorityLabels.${e}`),sP=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
|
|
106
104
|
`),priority:e.priority}:{kind:`decision`,title:e.title,scope:e.scope??``,content:e.decision,rationale:e.rationale??``,implications:e.implications.join(`
|
|
107
|
-
`),stages:``,priority:`normal`}
|
|
108
|
-
`).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),eP=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},tP=e=>(e?.decisions.length??0)>0?`decisions`:(e?.conventions.length??0)>0?`conventions`:`generated-context`,nP=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=YN(a?`suggested.saveAsNewDecision`:`suggested.accept`),s=e.kind===`decision`?e.decision:e.instruction;return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(U,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,children:YN(`suggested.badge`,{kind:e.kind})}),a&&(0,Z.jsx)(U,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`,children:YN(`suggested.duplicateBadge`)})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:YN(`suggested.review`)}),(0,Z.jsx)(K,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:YN(`suggested.dismiss`)})]})]})})},rP=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?YN(`suggested.saveAsNewDecision`):YN(`suggested.acceptAs`,{kind:e.kind});return(0,Z.jsx)(Os,{open:t,onOpenChange:a,children:(0,Z.jsxs)(Ms,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Ns,{children:[(0,Z.jsx)(Fs,{children:e.title}),(0,Z.jsx)(Is,{children:YN(`suggested.reviewDescription`,{kind:e.kind})})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:YN(`suggested.duplicateTitle`)}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}),n?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:YN(`editor.titleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":YN(`editor.titleAriaLabel`),value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:YN(`editor.contentLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":YN(`editor.contentAriaLabel`),value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:YN(`editor.scopeLabel`)}),(0,Z.jsx)(`input`,{"aria-label":YN(`editor.scopeAriaLabel`),value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:YN(`editor.rationaleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":YN(`editor.rationaleAriaLabel`),value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:YN(`editor.implicationsLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":YN(`editor.implicationsAriaLabel`),value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:4,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:YN(`editor.stagesLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":YN(`editor.stagesLabel`),value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:YN(`editor.priorityLabel`)}),(0,Z.jsxs)(`select`,{"aria-label":YN(`editor.priorityAriaLabel`),value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,Z.jsx)(`option`,{value:`critical`,children:YN(`priorityLabels.critical`)}),(0,Z.jsx)(`option`,{value:`normal`,children:YN(`priorityLabels.normal`)}),(0,Z.jsx)(`option`,{value:`low`,children:YN(`priorityLabels.low`)})]})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-3 text-sm text-foreground`,children:e.kind===`decision`?e.decision:e.instruction}),(0,Z.jsxs)(`div`,{className:`space-y-2 text-xs leading-5 text-muted-foreground`,children:[e.scope&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:YN(`suggested.scope`)}),` `,e.scope]}),e.rationale&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:YN(`suggested.why`)}),` `,e.rationale]}),e.kind===`decision`&&e.implications.length>0&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:YN(`suggested.implications`)}),` `,e.implications.join(`; `)]}),e.kind===`convention`&&e.stages.length>0&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:YN(`suggested.stages`)}),` `,e.stages.map(e=>XN(e)).join(`, `)]}),e.kind===`convention`&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:YN(`suggested.priority`)}),` `,ZN(e.priority)]})]})]})]}),(0,Z.jsx)(Ps,{className:`border-t border-border pt-4`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:YN(`editor.cancel`)}),(0,Z.jsx)(K,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:YN(`suggested.dismissKind`,{kind:e.kind})}),d&&(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:YN(`suggested.updateExistingDecision`)}),(0,Z.jsx)(K,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>a(!1),children:YN(`suggested.close`)}),(0,Z.jsx)(K,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:YN(`suggested.dismissKind`,{kind:e.kind})}),(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:YN(`suggested.edit`)}),d&&(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:YN(`suggested.updateExistingDecision`)}),(0,Z.jsx)(K,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})})]})})},iP=({activeTab:e,isLoading:t,memory:n,onActiveTabChange:r,onOpenChange:i,open:a})=>(0,Z.jsx)(Os,{open:a,onOpenChange:i,children:(0,Z.jsxs)(Ms,{className:`max-h-[85vh] overflow-y-auto sm:max-w-4xl`,children:[(0,Z.jsxs)(Ns,{children:[(0,Z.jsx)(Fs,{children:YN(`ticketPanel.title`)}),(0,Z.jsx)(Is,{children:YN(`ticketPanel.dialogDescription`)})]}),(0,Z.jsxs)(Nd,{value:e,onValueChange:e=>r(e),className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Pd,{className:`flex h-auto w-full flex-wrap justify-start`,children:[(0,Z.jsx)(Fd,{value:`decisions`,children:YN(`ticketPanel.decisionsTab`)}),(0,Z.jsx)(Fd,{value:`conventions`,children:YN(`ticketPanel.conventionsTab`)}),(0,Z.jsx)(Fd,{value:`generated-context`,children:YN(`ticketPanel.generatedContextTab`)})]}),(0,Z.jsx)(Id,{value:`decisions`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:YN(`ticketPanel.loading`)}):n&&n.decisions.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.decisions.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.decision]},e.id))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:YN(`ticketPanel.noAcceptedDecisions`)})}),(0,Z.jsx)(Id,{value:`conventions`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:YN(`ticketPanel.loading`)}):n&&n.conventions.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.conventions.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.instruction]},e.id))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:YN(`ticketPanel.noConventions`)})}),(0,Z.jsx)(Id,{value:`generated-context`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:YN(`ticketPanel.loading`)}):n?.generated_context?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[n.generated_context.is_stale&&(0,Z.jsx)(`p`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:YN(`ticketPanel.generatedContextStaleWarning`)}),n.generated_context.architecture_summary&&(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2 text-sm text-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:YN(`ticketPanel.architecture`)}),` `,n.generated_context.architecture_summary]}),n.generated_context.key_areas.length>0?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`h5`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:YN(`ticketPanel.relevantAreas`)}),(0,Z.jsx)(`ul`,{className:`mt-2 space-y-2 text-sm text-foreground`,children:n.generated_context.key_areas.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:YN(`ticketPanel.noRelevantAreas`)})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:YN(`ticketPanel.noGeneratedContext`)})})]}),(0,Z.jsx)(Ps,{className:`border-t border-border pt-4`,showCloseButton:!0})]})}),aP=({projectId:e,ticketId:t,memoryEnabled:n,refreshKey:r,onSuggestionsChanged:i})=>{let[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)([]),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(`decisions`),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),[x,S]=(0,Y.useState)(null),[C,T]=(0,Y.useState)(0);if((0,Y.useEffect)(()=>{if(!e||!n){u(!1),o(null),c([]);return}let r=new AbortController;return u(!0),o(null),c([]),Promise.all([Ge(e,t,r.signal),be(e,t,r.signal)]).then(([e,t])=>{r.signal.aborted||(o(e),c(t.suggestions),v(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e),g(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e))}).catch(e=>{if(!r.signal.aborted){if(e instanceof O&&(e.status===404||e.status===409)){o(null),c([]);return}o(null),c([])}}).finally(()=>{r.signal.aborted||u(!1)}),()=>{r.abort()}},[n,e,r,C,t]),!n||!e)return null;let E=s.length>0,D=a?.decisions.length??0,k=a?.conventions.length??0,A=!!a?.generated_context,j=YN(l?`ticketPanel.summaryLoading`:D>0||k>0||A?`ticketPanel.summarySaved`:`ticketPanel.summaryEmpty`),M=h?s.find(e=>e.id===h)??null:null,N=e=>{e&&m(tP(a)),f(e)},P=e=>{g(e.id),v(e.id),b(QN(e))},F=()=>{v(null),b({title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`})},I=e=>{_&&_!==e.id&&F(),g(e.id)},L=e=>{e||(g(null),_&&F())},R=async(t,n)=>{if(!e)return;let r=_===t.id?y:QN(t),a=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:$N(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:eP(r.stages),priority:r.priority};S(t.id);try{if(n){if(t.kind!==`decision`)throw Error(YN(`messages.onlyDecisionSuggestionsCanUpdate`));let n=t.duplicate_match?.decision;if(!n)throw Error(YN(`messages.noExistingDecision`));await Le(e,t.id,n.id,a)}else await w(e,t.id,a);F(),g(null),T(e=>e+1),i?.()}catch(e){Q.error(e instanceof Error?e.message:YN(`messages.saveSuggestionError`),{id:`project-memory-suggestion-error`})}finally{S(null)}},z=async t=>{if(e){S(t.id);try{await Me(e,t.id),_===t.id&&F(),h===t.id&&g(null),T(e=>e+1),i?.()}catch(e){Q.error(e instanceof Error?e.message:YN(`messages.dismissSuggestionError`),{id:`project-memory-suggestion-error`})}finally{S(null)}}};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:YN(`ticketPanel.title`)}),l&&(0,Z.jsx)(U,{variant:`outline`,children:YN(`ticketPanel.loadingBadge`)}),!l&&a?.generated_context?.is_stale&&(0,Z.jsx)(U,{variant:`outline`,className:`border-amber-500/40 bg-amber-500/10 text-amber-100`,children:YN(`ticketPanel.scanStaleBadge`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:justify-end`,children:[!l&&(0,Z.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 whitespace-nowrap`,children:[(0,Z.jsx)(U,{variant:`outline`,children:YN(`ticketPanel.decisionCount`,{count:D})}),(0,Z.jsx)(U,{variant:`outline`,children:YN(`ticketPanel.conventionCount`,{count:k})}),(0,Z.jsx)(U,{variant:`outline`,children:YN(`ticketPanel.scanCount`,{count:+!!A})})]}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>N(!0),children:YN(`ticketPanel.viewDetails`)})]})]})}),E&&(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:YN(`ticketPanel.suggestionsTitle`,{count:s.length})}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:YN(`ticketPanel.suggestionsDescription`)})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:s.map(e=>(0,Z.jsx)(nP,{suggestion:e,isPending:x===e.id,onReview:I,onAccept:e=>R(e,!1),onDismiss:z},e.id))})]}),(0,Z.jsx)(iP,{open:d,onOpenChange:N,isLoading:l,memory:a,activeTab:p,onActiveTabChange:m}),(0,Z.jsx)(rP,{suggestion:M,isOpen:!!M,isEditing:_===M?.id,isPending:x===M?.id,draft:_===M?.id?y:M?QN(M):y,onOpenChange:L,onStartEdit:P,onDraftChange:b,onCancelEdit:F,onAccept:R,onDismiss:z})]})},oP=({content:e,externalSource:t=null})=>{let{t:n}=X(`common`);return(0,Z.jsxs)(`section`,{"aria-label":n(`ticketStaticDescription.ariaLabel`),className:`min-h-0 flex-1 overflow-y-auto rounded-xl border border-border/80 bg-card/70 px-4 py-4`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-widest text-muted-foreground`,children:n(`ticketStaticDescription.title`)}),(0,Z.jsx)(ET,{externalSource:t,className:`mt-3`}),(0,Z.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e})]})},sP=[`h-7 w-auto max-w-full rounded-md border-border/70 bg-transparent px-2.5 text-[11px] text-muted-foreground shadow-none`,`hover:border-border hover:bg-background/60 hover:text-foreground`,`focus-visible:border-ring/70 focus-visible:ring-2 focus-visible:ring-ring/20`,`disabled:border-border/40 disabled:bg-transparent disabled:text-muted-foreground/50`,`[&_svg]:ml-1 [&_svg]:h-3.5 [&_svg]:w-3.5 [&_svg]:text-muted-foreground`].join(` `),cP=[`flex h-7 shrink-0 items-center rounded-md border border-border/70 bg-transparent px-2.5`].join(` `),lP=[`h-2 rounded-full`,`h-2 rounded-full`,`h-2 rounded-full`],uP=[`w-[4.75rem]`,`w-[4.25rem]`,`w-[3.5rem]`],dP=({className:e,dataTestId:t})=>(0,Z.jsx)(`div`,{"data-testid":t,className:G(`flex min-w-0 flex-wrap items-center gap-1.5`,e),children:uP.map((e,t)=>(0,Z.jsx)(`div`,{className:cP,children:(0,Z.jsx)(Ec,{className:G(lP[t],e)})},e))}),fP=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,Z.jsxs)(`div`,{className:G(`flex min-w-0 flex-wrap items-center gap-1.5`,h),children:[r?(0,Z.jsx)(fc,{model:e,showModelSelector:!0,availableModels:a,onModelChange:c,selectId:d,label:``,triggerAriaLabel:`Choose model`,disabled:m,className:`min-w-0`,triggerClassName:sP}):null,g?(0,Z.jsx)(pc,{variant:t,selectedModel:s,showVariantSelector:!0,onVariantChange:l,selectId:f,label:``,triggerAriaLabel:`Choose model variant`,disabled:m,className:`min-w-0`,triggerClassName:sP}):null,i?(0,Z.jsx)(BN,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,label:``,triggerAriaLabel:`Choose skills`,disabled:m,className:`min-w-0`,triggerClassName:sP,showSelectedBadges:!1}):null]})},pP=2,mP=1,hP=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(pP,Math.floor(u/e.css.cell.width)),rows:Math.max(mP,Math.floor(l/e.css.cell.height))}}},gP=Object.defineProperty,_P=Object.getOwnPropertyDescriptor,vP=(e,t)=>{for(var n in t)gP(e,n,{get:t[n],enumerable:!0})},yP=(e,t,n,r)=>{for(var i=r>1?void 0:r?_P(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&&gP(t,n,i),i},bP=(e,t)=>(n,r)=>t(n,r,e),xP=`Terminal input`,SP={get:()=>xP,set:e=>xP=e},CP=`Too much output to announce, navigate to rows manually to read`,wP={get:()=>CP,set:e=>CP=e};function TP(e){return e.replace(/\r?\n/g,`\r`)}function EP(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function DP(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function OP(e,t,n,r){e.stopPropagation(),e.clipboardData&&kP(e.clipboardData.getData(`text/plain`),t,n,r)}function kP(e,t,n,r){e=TP(e),e=EP(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function AP(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 jP(e,t,n,r,i){AP(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function MP(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function NP(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var PP=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;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++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}},FP=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<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else 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;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(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}},IP=``,LP=` `,RP=class e{constructor(){this.fg=0,this.bg=0,this.extended=new zP}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)==0}isBgDefault(){return(this.bg&50331648)==0}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)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},zP=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}},BP=class e extends RP{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new zP,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?MP(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()]}},VP=`di$target`,HP=`di$dependencies`,UP=new Map;function WP(e){return e[HP]||[]}function GP(e){if(UP.has(e))return UP.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);KP(t,e,r)};return t._id=e,UP.set(e,t),t}function KP(e,t,n){t[VP]===t?t[HP].push({id:e,index:n}):(t[HP]=[{id:e,index:n}],t[VP]=t)}var qP=GP(`BufferService`),JP=GP(`CoreMouseService`),YP=GP(`CoreService`),XP=GP(`CharsetService`),ZP=GP(`InstantiationService`),QP=GP(`LogService`),$P=GP(`OptionsService`),eF=GP(`OscLinkService`),tF=GP(`UnicodeService`),nF=GP(`DecorationService`),rF=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 BP,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):iF(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)}};rF=yP([bP(0,qP),bP(1,$P),bP(2,eF)],rF);function iF(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
105
|
+
`),stages:``,priority:`normal`},cP=e=>e.split(`
|
|
106
|
+
`).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),lP=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},uP=e=>(e?.decisions.length??0)>0?`decisions`:(e?.conventions.length??0)>0?`conventions`:`generated-context`,dP=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=iP(a?`suggested.saveAsNewDecision`:`suggested.accept`),s=e.kind===`decision`?e.decision:e.instruction;return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(U,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,children:iP(`suggested.badge`,{kind:e.kind})}),a&&(0,Z.jsx)(U,{variant:`outline`,className:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`,children:iP(`suggested.duplicateBadge`)})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:iP(`suggested.review`)}),(0,Z.jsx)(K,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:iP(`suggested.dismiss`)})]})]})})},fP=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?iP(`suggested.saveAsNewDecision`):iP(`suggested.acceptAs`,{kind:e.kind});return(0,Z.jsx)(Os,{open:t,onOpenChange:a,children:(0,Z.jsxs)(Ms,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Ns,{children:[(0,Z.jsx)(Fs,{children:e.title}),(0,Z.jsx)(Is,{children:iP(`suggested.reviewDescription`,{kind:e.kind})})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:iP(`suggested.duplicateTitle`)}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}),n?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:iP(`editor.titleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":iP(`editor.titleAriaLabel`),value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:iP(`editor.contentLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":iP(`editor.contentAriaLabel`),value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:iP(`editor.scopeLabel`)}),(0,Z.jsx)(`input`,{"aria-label":iP(`editor.scopeAriaLabel`),value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:iP(`editor.rationaleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":iP(`editor.rationaleAriaLabel`),value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:iP(`editor.implicationsLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":iP(`editor.implicationsAriaLabel`),value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:4,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:iP(`editor.stagesLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":iP(`editor.stagesLabel`),value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:iP(`editor.priorityLabel`)}),(0,Z.jsxs)(`select`,{"aria-label":iP(`editor.priorityAriaLabel`),value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,Z.jsx)(`option`,{value:`critical`,children:iP(`priorityLabels.critical`)}),(0,Z.jsx)(`option`,{value:`normal`,children:iP(`priorityLabels.normal`)}),(0,Z.jsx)(`option`,{value:`low`,children:iP(`priorityLabels.low`)})]})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background/40 px-3 py-3 text-sm text-foreground`,children:e.kind===`decision`?e.decision:e.instruction}),(0,Z.jsxs)(`div`,{className:`space-y-2 text-xs leading-5 text-muted-foreground`,children:[e.scope&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:iP(`suggested.scope`)}),` `,e.scope]}),e.rationale&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:iP(`suggested.why`)}),` `,e.rationale]}),e.kind===`decision`&&e.implications.length>0&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:iP(`suggested.implications`)}),` `,e.implications.join(`; `)]}),e.kind===`convention`&&e.stages.length>0&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:iP(`suggested.stages`)}),` `,e.stages.map(e=>aP(e)).join(`, `)]}),e.kind===`convention`&&(0,Z.jsxs)(`p`,{children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:iP(`suggested.priority`)}),` `,oP(e.priority)]})]})]})]}),(0,Z.jsx)(Ps,{className:`border-t border-border pt-4`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:iP(`editor.cancel`)}),(0,Z.jsx)(K,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:iP(`suggested.dismissKind`,{kind:e.kind})}),d&&(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:iP(`suggested.updateExistingDecision`)}),(0,Z.jsx)(K,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>a(!1),children:iP(`suggested.close`)}),(0,Z.jsx)(K,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void u(e),children:iP(`suggested.dismissKind`,{kind:e.kind})}),(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:iP(`suggested.edit`)}),d&&(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:iP(`suggested.updateExistingDecision`)}),(0,Z.jsx)(K,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})})]})})},pP=({activeTab:e,isLoading:t,memory:n,onActiveTabChange:r,onOpenChange:i,open:a})=>(0,Z.jsx)(Os,{open:a,onOpenChange:i,children:(0,Z.jsxs)(Ms,{className:`max-h-[85vh] overflow-y-auto sm:max-w-4xl`,children:[(0,Z.jsxs)(Ns,{children:[(0,Z.jsx)(Fs,{children:iP(`ticketPanel.title`)}),(0,Z.jsx)(Is,{children:iP(`ticketPanel.dialogDescription`)})]}),(0,Z.jsxs)(Nd,{value:e,onValueChange:e=>r(e),className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Pd,{className:`flex h-auto w-full flex-wrap justify-start`,children:[(0,Z.jsx)(Fd,{value:`decisions`,children:iP(`ticketPanel.decisionsTab`)}),(0,Z.jsx)(Fd,{value:`conventions`,children:iP(`ticketPanel.conventionsTab`)}),(0,Z.jsx)(Fd,{value:`generated-context`,children:iP(`ticketPanel.generatedContextTab`)})]}),(0,Z.jsx)(Id,{value:`decisions`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:iP(`ticketPanel.loading`)}):n&&n.decisions.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.decisions.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.decision]},e.id))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:iP(`ticketPanel.noAcceptedDecisions`)})}),(0,Z.jsx)(Id,{value:`conventions`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:iP(`ticketPanel.loading`)}):n&&n.conventions.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2 text-sm text-foreground`,children:n.conventions.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[e.title,`:`]}),` `,e.instruction]},e.id))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:iP(`ticketPanel.noConventions`)})}),(0,Z.jsx)(Id,{value:`generated-context`,className:`mt-0 outline-none`,children:t?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:iP(`ticketPanel.loading`)}):n?.generated_context?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[n.generated_context.is_stale&&(0,Z.jsx)(`p`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:iP(`ticketPanel.generatedContextStaleWarning`)}),n.generated_context.architecture_summary&&(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2 text-sm text-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:iP(`ticketPanel.architecture`)}),` `,n.generated_context.architecture_summary]}),n.generated_context.key_areas.length>0?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-background/40 px-3 py-2`,children:[(0,Z.jsx)(`h5`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:iP(`ticketPanel.relevantAreas`)}),(0,Z.jsx)(`ul`,{className:`mt-2 space-y-2 text-sm text-foreground`,children:n.generated_context.key_areas.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:iP(`ticketPanel.noRelevantAreas`)})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:iP(`ticketPanel.noGeneratedContext`)})})]}),(0,Z.jsx)(Ps,{className:`border-t border-border pt-4`,showCloseButton:!0})]})}),mP=({projectId:e,ticketId:t,memoryEnabled:n,refreshKey:r,onSuggestionsChanged:i})=>{let[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)([]),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(`decisions`),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),[x,S]=(0,Y.useState)(null),[C,T]=(0,Y.useState)(0);if((0,Y.useEffect)(()=>{if(!e||!n){u(!1),o(null),c([]);return}let r=new AbortController;return u(!0),o(null),c([]),Promise.all([Ge(e,t,r.signal),be(e,t,r.signal)]).then(([e,t])=>{r.signal.aborted||(o(e),c(t.suggestions),v(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e),g(e=>e&&!t.suggestions.some(t=>t.id===e)?null:e))}).catch(e=>{if(!r.signal.aborted){if(e instanceof O&&(e.status===404||e.status===409)){o(null),c([]);return}o(null),c([])}}).finally(()=>{r.signal.aborted||u(!1)}),()=>{r.abort()}},[n,e,r,C,t]),!n||!e)return null;let E=s.length>0,D=a?.decisions.length??0,k=a?.conventions.length??0,A=!!a?.generated_context,j=iP(l?`ticketPanel.summaryLoading`:D>0||k>0||A?`ticketPanel.summarySaved`:`ticketPanel.summaryEmpty`),M=h?s.find(e=>e.id===h)??null:null,N=e=>{e&&m(uP(a)),f(e)},P=e=>{g(e.id),v(e.id),b(sP(e))},F=()=>{v(null),b({title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`})},I=e=>{_&&_!==e.id&&F(),g(e.id)},L=e=>{e||(g(null),_&&F())},R=async(t,n)=>{if(!e)return;let r=_===t.id?y:sP(t),a=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:cP(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:lP(r.stages),priority:r.priority};S(t.id);try{if(n){if(t.kind!==`decision`)throw Error(iP(`messages.onlyDecisionSuggestionsCanUpdate`));let n=t.duplicate_match?.decision;if(!n)throw Error(iP(`messages.noExistingDecision`));await Le(e,t.id,n.id,a)}else await w(e,t.id,a);F(),g(null),T(e=>e+1),i?.()}catch(e){Q.error(e instanceof Error?e.message:iP(`messages.saveSuggestionError`),{id:`project-memory-suggestion-error`})}finally{S(null)}},z=async t=>{if(e){S(t.id);try{await Me(e,t.id),_===t.id&&F(),h===t.id&&g(null),T(e=>e+1),i?.()}catch(e){Q.error(e instanceof Error?e.message:iP(`messages.dismissSuggestionError`),{id:`project-memory-suggestion-error`})}finally{S(null)}}};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(`section`,{className:`rounded-lg border border-border bg-card/70`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:iP(`ticketPanel.title`)}),l&&(0,Z.jsx)(U,{variant:`outline`,children:iP(`ticketPanel.loadingBadge`)}),!l&&a?.generated_context?.is_stale&&(0,Z.jsx)(U,{variant:`outline`,className:`border-amber-500/40 bg-amber-500/10 text-amber-100`,children:iP(`ticketPanel.scanStaleBadge`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:justify-end`,children:[!l&&(0,Z.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 whitespace-nowrap`,children:[(0,Z.jsx)(U,{variant:`outline`,children:iP(`ticketPanel.decisionCount`,{count:D})}),(0,Z.jsx)(U,{variant:`outline`,children:iP(`ticketPanel.conventionCount`,{count:k})}),(0,Z.jsx)(U,{variant:`outline`,children:iP(`ticketPanel.scanCount`,{count:+!!A})})]}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>N(!0),children:iP(`ticketPanel.viewDetails`)})]})]})}),E&&(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:iP(`ticketPanel.suggestionsTitle`,{count:s.length})}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:iP(`ticketPanel.suggestionsDescription`)})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:s.map(e=>(0,Z.jsx)(dP,{suggestion:e,isPending:x===e.id,onReview:I,onAccept:e=>R(e,!1),onDismiss:z},e.id))})]}),(0,Z.jsx)(pP,{open:d,onOpenChange:N,isLoading:l,memory:a,activeTab:p,onActiveTabChange:m}),(0,Z.jsx)(fP,{suggestion:M,isOpen:!!M,isEditing:_===M?.id,isPending:x===M?.id,draft:_===M?.id?y:M?sP(M):y,onOpenChange:L,onStartEdit:P,onDraftChange:b,onCancelEdit:F,onAccept:R,onDismiss:z})]})},hP=({content:e,externalSource:t=null})=>{let{t:n}=X(`common`);return(0,Z.jsxs)(`section`,{"aria-label":n(`ticketStaticDescription.ariaLabel`),className:`min-h-0 flex-1 overflow-y-auto rounded-xl border border-border/80 bg-card/70 px-4 py-4`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-widest text-muted-foreground`,children:n(`ticketStaticDescription.title`)}),(0,Z.jsx)(ET,{externalSource:t,className:`mt-3`}),(0,Z.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:e})]})},gP=[`h-7 w-auto max-w-full rounded-md border-border/70 bg-transparent px-2.5 text-[11px] text-muted-foreground shadow-none`,`hover:border-border hover:bg-background/60 hover:text-foreground`,`focus-visible:border-ring/70 focus-visible:ring-2 focus-visible:ring-ring/20`,`disabled:border-border/40 disabled:bg-transparent disabled:text-muted-foreground/50`,`[&_svg]:ml-1 [&_svg]:h-3.5 [&_svg]:w-3.5 [&_svg]:text-muted-foreground`].join(` `),_P=[`flex h-7 shrink-0 items-center rounded-md border border-border/70 bg-transparent px-2.5`].join(` `),vP=[`h-2 rounded-full`,`h-2 rounded-full`,`h-2 rounded-full`],yP=[`w-[4.75rem]`,`w-[4.25rem]`,`w-[3.5rem]`],bP=({className:e,dataTestId:t})=>(0,Z.jsx)(`div`,{"data-testid":t,className:G(`flex min-w-0 flex-wrap items-center gap-1.5`,e),children:yP.map((e,t)=>(0,Z.jsx)(`div`,{className:_P,children:(0,Z.jsx)(Ec,{className:G(vP[t],e)})},e))}),xP=({model:e,variant:t,skills:n,showModelSelector:r,showSkillsSelector:i,availableModels:a,availableSkills:o,selectedModel:s,onModelChange:c,onVariantChange:l,onSkillsChange:u,modelSelectId:d,variantSelectId:f,skillsSelectId:p,disabled:m=!1,className:h})=>{let g=r&&s!==null&&s.variants.length>0;return!r&&!i?null:(0,Z.jsxs)(`div`,{className:G(`flex min-w-0 flex-wrap items-center gap-1.5`,h),children:[r?(0,Z.jsx)(fc,{model:e,showModelSelector:!0,availableModels:a,onModelChange:c,selectId:d,label:``,triggerAriaLabel:`Choose model`,disabled:m,className:`min-w-0`,triggerClassName:gP}):null,g?(0,Z.jsx)(pc,{variant:t,selectedModel:s,showVariantSelector:!0,onVariantChange:l,selectId:f,label:``,triggerAriaLabel:`Choose model variant`,disabled:m,className:`min-w-0`,triggerClassName:gP}):null,i?(0,Z.jsx)(YN,{skills:n,availableSkills:o,onSkillsChange:u,selectId:p,label:``,triggerAriaLabel:`Choose skills`,disabled:m,className:`min-w-0`,triggerClassName:gP,showSelectedBadges:!1}):null]})},SP=2,CP=1,wP=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(SP,Math.floor(u/e.css.cell.width)),rows:Math.max(CP,Math.floor(l/e.css.cell.height))}}},TP=Object.defineProperty,EP=Object.getOwnPropertyDescriptor,DP=(e,t)=>{for(var n in t)TP(e,n,{get:t[n],enumerable:!0})},OP=(e,t,n,r)=>{for(var i=r>1?void 0:r?EP(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&&TP(t,n,i),i},kP=(e,t)=>(n,r)=>t(n,r,e),AP=`Terminal input`,jP={get:()=>AP,set:e=>AP=e},MP=`Too much output to announce, navigate to rows manually to read`,NP={get:()=>MP,set:e=>MP=e};function PP(e){return e.replace(/\r?\n/g,`\r`)}function FP(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function IP(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function LP(e,t,n,r){e.stopPropagation(),e.clipboardData&&RP(e.clipboardData.getData(`text/plain`),t,n,r)}function RP(e,t,n,r){e=PP(e),e=FP(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function zP(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 BP(e,t,n,r,i){zP(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function VP(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function HP(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var UP=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;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++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}},WP=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<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else 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;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(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}},GP=``,KP=` `,qP=class e{constructor(){this.fg=0,this.bg=0,this.extended=new JP}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)==0}isBgDefault(){return(this.bg&50331648)==0}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)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},JP=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}},YP=class e extends qP{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new JP,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?VP(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()]}},XP=`di$target`,ZP=`di$dependencies`,QP=new Map;function $P(e){return e[ZP]||[]}function eF(e){if(QP.has(e))return QP.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);tF(t,e,r)};return t._id=e,QP.set(e,t),t}function tF(e,t,n){t[XP]===t?t[ZP].push({id:e,index:n}):(t[ZP]=[{id:e,index:n}],t[XP]=t)}var nF=eF(`BufferService`),rF=eF(`CoreMouseService`),iF=eF(`CoreService`),aF=eF(`CharsetService`),oF=eF(`InstantiationService`),sF=eF(`LogService`),cF=eF(`OptionsService`),lF=eF(`OscLinkService`),uF=eF(`UnicodeService`),dF=eF(`DecorationService`),fF=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 YP,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):pF(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)}};fF=OP([kP(0,nF),kP(1,cF),kP(2,lF)],fF);function pF(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
109
107
|
|
|
110
|
-
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
|
|
108
|
+
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 mF=eF(`CharSizeService`),hF=eF(`CoreBrowserService`),gF=eF(`MouseService`),_F=eF(`RenderService`),vF=eF(`SelectionService`),yF=eF(`CharacterJoinerService`),bF=eF(`ThemeService`),xF=eF(`LinkProviderService`),SF=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?OF.isErrorNoTelemetry(e)?new OF(e.message+`
|
|
111
109
|
|
|
112
110
|
`+e.stack):Error(e.message+`
|
|
113
111
|
|
|
114
|
-
`+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
|
|
115
|
-
`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new
|
|
116
|
-
`),e)}n.sort(
|
|
117
|
-
`)).size}/${n.length} leaks) at ${a}`;let o=
|
|
112
|
+
`+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 CF(e){TF(e)||SF.onUnexpectedError(e)}var wF=`Canceled`;function TF(e){return e instanceof EF?!0:e instanceof Error&&e.name===wF&&e.message===wF}var EF=class extends Error{constructor(){super(wF),this.name=this.message}};function DF(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var OF=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`}},kF=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function AF(e,t,n=0,r=e.length){let i=n,a=r;for(;i<a;){let n=Math.floor((i+a)/2);t(e[n])?i=n+1:a=n}return i-1}var jF=class e{constructor(e){this._array=e,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(e.assertInvariants){if(this._prevFindLastPredicate){for(let e of this._array)if(this._prevFindLastPredicate(e)&&!t(e))throw Error(`MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.`)}this._prevFindLastPredicate=t}let n=AF(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=n+1,n===-1?void 0:this._array[n]}};jF.assertInvariants=!1;function MF(e,t=0){return e[e.length-(1+t)]}var NF;(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})(NF||={});function PF(e,t){return(n,r)=>t(e(n),e(r))}var FF=(e,t)=>e-t,IF=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):!0))}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):!0),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||NF.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};IF.empty=new IF(e=>{});function LF(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var RF=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function zF(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 BF;(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);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(BF||={});var VF=!1,HF=null,UF=class e{constructor(){this.livingDisposables=new Map}getDisposableData(t){let n=this.livingDisposables.get(t);return n||(n={parent:null,source:null,isSingleton:!1,value:t,idx:e.idx++},this.livingDisposables.set(t,n)),n}trackDisposable(e){let t=this.getDisposableData(e);t.source||=Error().stack}setParent(e,t){let n=this.getDisposableData(e);n.parent=t}markAsDisposed(e){this.livingDisposables.delete(e)}markAsSingleton(e){this.getDisposableData(e).isSingleton=!0}getRootParent(e,t){let n=t.get(e);if(n)return n;let r=e.parent?this.getRootParent(this.getDisposableData(e.parent),t):e;return t.set(e,r),r}getTrackedDisposables(){let e=new Map;return[...this.livingDisposables.entries()].filter(([,t])=>t.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(`
|
|
113
|
+
`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new RF;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(`
|
|
114
|
+
`),e)}n.sort(PF(e=>e.idx,FF));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;t<e.length;t++){let a=e[t];a=`(shared with ${i.get(e.slice(0,t+1).join(`
|
|
115
|
+
`)).size}/${n.length} leaks) at ${a}`;let o=LF([...i.get(e.slice(0,t).join(`
|
|
118
116
|
`))].map(e=>r(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=`
|
|
119
117
|
|
|
120
118
|
|
|
@@ -128,25 +126,25 @@ ${s.join(`
|
|
|
128
126
|
|
|
129
127
|
... and ${n.length-e} more leaking disposables
|
|
130
128
|
|
|
131
|
-
`),{leaks:n,details:a}}};PF.idx=0;function FF(e){NF=e}if(MF){let e=`__is_disposable_tracked__`;FF(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==KF.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==KF.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function IF(e){return NF?.trackDisposable(e),e}function LF(e){NF?.markAsDisposed(e)}function RF(e,t){NF?.setParent(e,t)}function zF(e,t){if(NF)for(let n of e)NF.setParent(n,t)}function BF(e){return NF?.markAsSingleton(e),e}function VF(e){if(jF.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function HF(...e){let t=UF(()=>VF(e));return zF(e,t),t}function UF(e){let t=IF({dispose:AF(()=>{LF(t),e()})});return t}var WF=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,IF(this)}dispose(){this._isDisposed||(LF(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{VF(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return RF(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),RF(e,null))}};WF.DISABLE_DISPOSED_WARNING=!1;var GF=WF,KF=class{constructor(){this._store=new GF,IF(this),RF(this._store,this)}dispose(){LF(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};KF.None=Object.freeze({dispose(){}});var qF=class{constructor(){this._isDisposed=!1,IF(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&RF(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,LF(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&RF(e,null),e}},JF=typeof window==`object`?window:globalThis,YF=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};YF.Undefined=new YF(void 0);var XF=YF,ZF=class{constructor(){this._first=XF.Undefined,this._last=XF.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===XF.Undefined}clear(){let e=this._first;for(;e!==XF.Undefined;){let t=e.next;e.prev=XF.Undefined,e.next=XF.Undefined,e=t}this._first=XF.Undefined,this._last=XF.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new XF(e);if(this._first===XF.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!==XF.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==XF.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==XF.Undefined&&e.next!==XF.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===XF.Undefined&&e.next===XF.Undefined?(this._first=XF.Undefined,this._last=XF.Undefined):e.next===XF.Undefined?(this._last=this._last.prev,this._last.next=XF.Undefined):e.prev===XF.Undefined&&(this._first=this._first.next,this._first.prev=XF.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==XF.Undefined;)yield e.element,e=e.next}},QF=globalThis.performance&&typeof globalThis.performance.now==`function`,$F=class e{static create(t){return new e(t)}constructor(e){this._now=QF&&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}},eI=!1,tI=!1,nI=!1,rI;(e=>{e.None=()=>KF.None;function t(e){if(nI){let{onDidAddListener:t}=e,n=lI.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(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=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(HF(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new _I(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new _I(p);return s?.add(m),m.event}e.debounce=f;function p(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=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new _I({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{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:v),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:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new _I({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new _I({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function S(e){return new Promise(t=>r(e)(t))}e.toPromise=S;function C(e){let t=new _I;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=C;function w(e,t){return e(e=>t.fire(e))}e.forward=w;function T(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=T;class E{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new _I(r),n&&n.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 D(e,t){return new E(e,t).emitter.event}e.fromObservable=D;function O(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 GF?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=O})(rI||={});var iI=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 $F,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}}};iI.all=new Set,iI._idPool=0;var aI=iI,oI=-1,sI=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<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new uI(i,e);this._errorHandler(a)}return()=>{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||t<r)&&(e=[n,r],t=r);return e}};sI._idPool=1;var cI=sI,lI=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
129
|
+
`),{leaks:n,details:a}}};UF.idx=0;function WF(e){HF=e}if(VF){let e=`__is_disposable_tracked__`;WF(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==tI.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==tI.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function GF(e){return HF?.trackDisposable(e),e}function KF(e){HF?.markAsDisposed(e)}function qF(e,t){HF?.setParent(e,t)}function JF(e,t){if(HF)for(let n of e)HF.setParent(n,t)}function YF(e){return HF?.markAsSingleton(e),e}function XF(e){if(BF.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function ZF(...e){let t=QF(()=>XF(e));return JF(e,t),t}function QF(e){let t=GF({dispose:zF(()=>{KF(t),e()})});return t}var $F=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,GF(this)}dispose(){this._isDisposed||(KF(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{XF(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return qF(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),qF(e,null))}};$F.DISABLE_DISPOSED_WARNING=!1;var eI=$F,tI=class{constructor(){this._store=new eI,GF(this),qF(this._store,this)}dispose(){KF(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};tI.None=Object.freeze({dispose(){}});var nI=class{constructor(){this._isDisposed=!1,GF(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&qF(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,KF(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&qF(e,null),e}},rI=typeof window==`object`?window:globalThis,iI=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};iI.Undefined=new iI(void 0);var aI=iI,oI=class{constructor(){this._first=aI.Undefined,this._last=aI.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===aI.Undefined}clear(){let e=this._first;for(;e!==aI.Undefined;){let t=e.next;e.prev=aI.Undefined,e.next=aI.Undefined,e=t}this._first=aI.Undefined,this._last=aI.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new aI(e);if(this._first===aI.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!==aI.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==aI.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==aI.Undefined&&e.next!==aI.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===aI.Undefined&&e.next===aI.Undefined?(this._first=aI.Undefined,this._last=aI.Undefined):e.next===aI.Undefined?(this._last=this._last.prev,this._last.next=aI.Undefined):e.prev===aI.Undefined&&(this._first=this._first.next,this._first.prev=aI.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==aI.Undefined;)yield e.element,e=e.next}},sI=globalThis.performance&&typeof globalThis.performance.now==`function`,cI=class e{static create(t){return new e(t)}constructor(e){this._now=sI&&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}},lI=!1,uI=!1,dI=!1,fI;(e=>{e.None=()=>tI.None;function t(e){if(dI){let{onDidAddListener:t}=e,n=vI.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(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=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(ZF(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new EI(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new EI(p);return s?.add(m),m.event}e.debounce=f;function p(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=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(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 EI({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=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{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:v),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:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new EI({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new EI({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function S(e){return new Promise(t=>r(e)(t))}e.toPromise=S;function C(e){let t=new EI;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=C;function w(e,t){return e(e=>t.fire(e))}e.forward=w;function T(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=T;class E{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new EI(r),n&&n.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 D(e,t){return new E(e,t).emitter.event}e.fromObservable=D;function O(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 eI?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=O})(fI||={});var pI=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 cI,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}}};pI.all=new Set,pI._idPool=0;var mI=pI,hI=-1,gI=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<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new yI(i,e);this._errorHandler(a)}return()=>{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||t<r)&&(e=[n,r],t=r);return e}};gI._idPool=1;var _I=gI,vI=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
132
130
|
`).slice(2).join(`
|
|
133
|
-
`))}},
|
|
134
|
-
`)),e.length=0)},3e3),
|
|
131
|
+
`))}},yI=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},bI=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},xI=0,SI=class{constructor(e){this.value=e,this.id=xI++}},CI=2,wI=(e,t)=>{if(e instanceof SI)t(e);else for(let n=0;n<e.length;n++){let r=e[n];r&&t(r)}},TI;if(lI){let e=[];setInterval(()=>{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(`
|
|
132
|
+
`)),e.length=0)},3e3),TI=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var EI=class{constructor(e){this._size=0,this._options=e,this._leakageMon=hI>0||this._options?.leakWarningThreshold?new _I(e?.onListenerError??CF,this._options?.leakWarningThreshold??hI):void 0,this._perfMon=this._options?._profName?new mI(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(uI){let e=this._listeners;queueMicrotask(()=>{wI(e,e=>e.stack?.print())})}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 bI(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||CF)(n),tI.None}if(this._disposed)return tI.None;t&&(e=e.bind(t));let r=new SI(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=vI.create(),i=this._leakageMon.check(r.stack,this._size+1)),uI&&(r.stack=vI.create()),this._listeners?this._listeners instanceof SI?(this._deliveryQueue??=new DI,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=QF(()=>{TI?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof eI?n.add(a):Array.isArray(n)&&n.push(a),TI){let e=Error().stack.split(`
|
|
135
133
|
`).slice(2,3).join(`
|
|
136
|
-
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);gI.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*mI<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||mF;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof pI)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},vI=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}},yI=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new _I,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new _I,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};yI.INSTANCE=new yI;var bI=yI;function xI(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}bI.INSTANCE.onDidChangeZoomLevel;function SI(e){return bI.INSTANCE.getZoomFactor(e)}bI.INSTANCE.onDidChangeFullscreen;var CI=typeof navigator==`object`?navigator.userAgent:``,wI=CI.indexOf(`Firefox`)>=0,TI=CI.indexOf(`AppleWebKit`)>=0,EI=CI.indexOf(`Chrome`)>=0,DI=!EI&&CI.indexOf(`Safari`)>=0;CI.indexOf(`Electron/`),CI.indexOf(`Android`);var OI=!1;if(typeof JF.matchMedia==`function`){let e=JF.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=JF.matchMedia(`(display-mode: fullscreen)`);OI=e.matches,xI(JF,e,({matches:e})=>{OI&&t.matches||(OI=e)})}function kI(){return OI}var AI=`en`,jI=!1,MI=!1,NI=!1,PI=!1,FI=!1,II=AI,LI,RI=globalThis,zI;typeof RI.vscode<`u`&&typeof RI.vscode.process<`u`?zI=RI.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(zI=process);var BI=typeof zI?.versions?.electron==`string`&&zI?.type===`renderer`;if(typeof zI==`object`){jI=zI.platform===`win32`,MI=zI.platform===`darwin`,NI=zI.platform===`linux`,NI&&zI.env.SNAP&&zI.env.SNAP_REVISION,zI.env.CI||zI.env.BUILD_ARTIFACTSTAGINGDIRECTORY,II=AI;let e=zI.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,II=t.resolvedLanguage||AI,t.languagePack?.translationsConfigFile}catch{}PI=!0}else typeof navigator==`object`&&!BI?(LI=navigator.userAgent,jI=LI.indexOf(`Windows`)>=0,MI=LI.indexOf(`Macintosh`)>=0,(LI.indexOf(`Macintosh`)>=0||LI.indexOf(`iPad`)>=0||LI.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,NI=LI.indexOf(`Linux`)>=0,LI?.indexOf(`Mobi`),FI=!0,II=globalThis._VSCODE_NLS_LANGUAGE||AI,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var VI=jI,HI=MI,UI=NI,WI=PI;FI&&typeof RI.importScripts==`function`&&RI.origin;var GI=LI,KI=II,qI;(e=>{function t(){return KI}e.value=t;function n(){return KI.length===2?KI===`en`:KI.length>=3?KI[0]===`e`&&KI[1]===`n`&&KI[2]===`-`:!1}e.isDefaultVariant=n;function r(){return KI===`en`}e.isDefault=r})(qI||={});var JI=typeof RI.postMessage==`function`&&!RI.importScripts;(()=>{if(JI){let e=[];RI.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),RI.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var YI=!!(GI&&GI.indexOf(`Chrome`)>=0);GI&&GI.indexOf(`Firefox`),!YI&&GI&&GI.indexOf(`Safari`),GI&&GI.indexOf(`Edg/`),GI&&GI.indexOf(`Android`);var XI=typeof navigator==`object`?navigator:{};WI||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||XI&&XI.clipboard&&XI.clipboard.writeText,WI||XI&&XI.clipboard&&XI.clipboard.readText,WI||kI()||XI.keyboard,`ontouchstart`in JF||XI.maxTouchPoints,JF.PointerEvent&&(`ontouchstart`in JF||navigator.maxTouchPoints);var ZI=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}},QI=new ZI,$I=new ZI,eL=new ZI,tL=Array(230),nL;(e=>{function t(e){return QI.keyCodeToStr(e)}e.toString=t;function n(e){return QI.strToKeyCode(e)}e.fromString=n;function r(e){return $I.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return eL.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return $I.strToKeyCode(e)||eL.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 QI.keyCodeToStr(e)}e.toElectronAccelerator=o})(nL||={});var rL=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 iL([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},iL=class{constructor(e){if(e.length===0)throw vF(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function aL(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return nL.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(wI)switch(t){case 59:return 85;case 60:if(UI)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(HI)return 57;break}else if(TI&&(HI&&t===93||!HI&&t===92))return 57;return tL[t]||0}var oL=HI?256:2048,sL=512,cL=1024,lL=HI?2048:256,uL=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=aL(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=oL),this.altKey&&(t|=sL),this.shiftKey&&(t|=cL),this.metaKey&&(t|=lL),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new rL(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},dL=new WeakMap;function fL(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var pL=class{static getSameOriginWindowChain(e){let t=dL.get(e);if(!t){t=[],dL.set(e,t);let n=e,r;do r=fL(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},mL=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=pL.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},hL=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(EI){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)r?this.deltaY=t.wheelDeltaY/(120*i):this.deltaY=t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?wI&&!HI?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)DI&&VI?this.deltaX=-(t.wheelDeltaX/120):r?this.deltaX=t.wheelDeltaX/(120*i):this.deltaX=t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?wI&&!HI?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},gL=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),_L;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof vL?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:rI.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:gL})})(_L||={});var vL=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?gL:(this._emitter||=new _I,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},yL=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 bF(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new bF(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},bL=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 bF(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=UF(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var xL;(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})(xL||={});var SL=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new _I,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await rI.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(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())}};SL.EMPTY=SL.fromArray([]);function CL(e){return 55296<=e&&e<=56319}function wL(e){return 56320<=e&&e<=57343}function TL(e,t){return(e-55296<<10)+(t-56320)+65536}function EL(e){return DL(e,0)}function DL(e,t){switch(typeof e){case`object`:return e===null?OL(349,t):Array.isArray(e)?jL(e,t):ML(e,t);case`string`:return AL(e,t);case`boolean`:return kL(e,t);case`number`:return OL(e,t);case`undefined`:return OL(937,t);default:return OL(617,t)}}function OL(e,t){return(t<<5)-t+e|0}function kL(e,t){return OL(e?433:863,t)}function AL(e,t){t=OL(149417,t);for(let n=0,r=e.length;n<r;n++)t=OL(e.charCodeAt(n),t);return t}function jL(e,t){return t=OL(104579,t),e.reduce((e,t)=>DL(t,e),t)}function ML(e,t){return t=OL(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=AL(n,t),DL(e[n],t)),t)}function NL(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function PL(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function FL(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function IL(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):FL((e>>>0).toString(16),t/4)}var LL=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(CL(a))if(o+1<t){let t=e.charCodeAt(o+1);wL(t)?(o++,s=TL(a,t)):s=65533}else{i=a;break}else wL(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),IL(this._h0)+IL(this._h1)+IL(this._h2)+IL(this._h3)+IL(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,PL(this._buff,this._buffLen),this._buffLen>56&&(this._step(),PL(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,NL(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=NL(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=NL(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};LL._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:RL,getWindow:zL,getDocument:BL,getWindows:VL,getWindowsCount:HL,getWindowId:UL,getWindowById:WL,hasWindow:GL,onDidRegisterWindow:KL,onWillUnregisterWindow:qL,onDidUnregisterWindow:JL}=function(){let e=new Map,t={window:JF,disposables:new GF};e.set(JF.vscodeWindowId,t);let n=new _I,r=new _I,i=new _I;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return KF.None;let a=new GF,o={window:t,disposables:a.add(new GF)};return e.set(t.vscodeWindowId,o),a.add(UF(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(XL(t,aR.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:JF},getDocument(e){return zL(e).document}}}(),YL=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 XL(e,t,n,r){return new YL(e,t,n,r)}function ZL(e,t){return function(n){return t(new mL(e,n))}}function QL(e){return function(t){return e(new uL(t))}}var $L=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=ZL(zL(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=QL(n)),XL(e,t,i,r)},eR,tR=class extends bL{constructor(e){super(),this.defaultTarget=e&&zL(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},nR=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){mF(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(nR.sort),a.shift().execute();r.set(i,!1)};eR=(t,r,a=0)=>{let o=UL(t),s=new nR(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 rR=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}};rR.None=new rR(0,0);function iR(e){let t=e.getBoundingClientRect(),n=zL(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=EL(n),a=r.get(i);if(a)a.users+=1;else{let o=new _I,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(UF(()=>{--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 aR={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:TI?`webkitAnimationStart`:`animationstart`,ANIMATION_END:TI?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:TI?`webkitAnimationIteration`:`animationiteration`},oR=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function sR(e,t,n,...r){let i=oR.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function cR(e,t,...n){return sR(`http://www.w3.org/1999/xhtml`,e,t,...n)}cR.SVG=function(e,t,...n){return sR(`http://www.w3.org/2000/svg`,e,t,...n)};var lR=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=uR(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=uR(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=uR(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=uR(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=uR(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=uR(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=uR(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=uR(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=uR(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=uR(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=uR(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=uR(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=uR(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=uR(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 uR(e){return typeof e==`number`?`${e}px`:e}function dR(e){return new lR(e)}var fR=class{constructor(){this._hooks=new GF,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(UF(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=zL(e)}this._hooks.add(XL(a,aR.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(XL(a,aR.POINTER_UP,e=>this.stopMonitoring(!0)))}};function pR(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 mR;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(mR||={});var hR=class e extends KF{constructor(){super(),this.dispatched=!1,this.targets=new ZF,this.ignoreTargets=new ZF,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(rI.runAndSubscribe(KL,({window:e,disposables:t})=>{t.add(XL(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(XL(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(XL(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:JF,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=BF(new e),UF(e.INSTANCE.targets.push(t))):KF.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=BF(new e),UF(e.INSTANCE.ignoreTargets.push(t))):KF.None}static isTouchDevice(){return`ontouchstart`in JF||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<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(mR.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-CF(s.rollingPageX))<30&&Math.abs(s.initialPageY-CF(s.rollingPageY))<30){let e=this.newGestureEvent(mR.Tap,s.initialTarget);e.pageX=CF(s.rollingPageX),e.pageY=CF(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-CF(s.rollingPageX))<30&&Math.abs(s.initialPageY-CF(s.rollingPageY))<30){let e=this.newGestureEvent(mR.Contextmenu,s.initialTarget);e.pageX=CF(s.rollingPageX),e.pageY=CF(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=CF(s.rollingPageX),n=CF(s.rollingPageY),i=CF(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(mR.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===mR.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===mR.Change||t.type===mR.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=eR(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(mR.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;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(mR.Change,i.initialTarget);a.translationX=r.pageX-CF(i.rollingPageX),a.translationY=r.pageY-CF(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(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)}};hR.SCROLL_FRICTION=-.005,hR.HOLD_DELAY=700,hR.CLEAR_TAP_COUNT_TIME=400,yP([pR],hR,`isTouchDevice`,1);var gR=hR,_R=class extends KF{onclick(e,t){this._register(XL(e,aR.CLICK,n=>t(new mL(zL(e),n))))}onmousedown(e,t){this._register(XL(e,aR.MOUSE_DOWN,n=>t(new mL(zL(e),n))))}onmouseover(e,t){this._register(XL(e,aR.MOUSE_OVER,n=>t(new mL(zL(e),n))))}onmouseleave(e,t){this._register(XL(e,aR.MOUSE_LEAVE,n=>t(new mL(zL(e),n))))}onkeydown(e,t){this._register(XL(e,aR.KEY_DOWN,e=>t(new uL(e))))}onkeyup(e,t){this._register(XL(e,aR.KEY_UP,e=>t(new uL(e))))}oninput(e,t){this._register(XL(e,aR.INPUT,t))}onblur(e,t){this._register(XL(e,aR.BLUR,t))}onfocus(e,t){this._register(XL(e,aR.FOCUS,t))}onchange(e,t){this._register(XL(e,aR.CHANGE,t))}ignoreGesture(e){return gR.ignoreTarget(e)}},vR=11,yR=class extends _R{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=vR+`px`,this.domNode.style.height=vR+`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 fR),this._register($L(this.bgDomNode,aR.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register($L(this.domNode,aR.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new tR),this._pointerdownScheduleRepeatTimer=this._register(new yL)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,zL(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},bR=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}}},xR=class extends KF{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new _I),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new bR(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 TR(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=TR.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)))}},SR=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function CR(e,t){let n=t-e;return function(t){return e+n*DR(t)}}function wR(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var TR=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),wR(CR(e,r),CR(i,t),.33)}return CR(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new SR(this.scrollLeft(t),this.scrollTop(t),!1):new SR(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){return r+=10,new e(t,n,Date.now()-10,r)}};function ER(e){return e**3}function DR(e){return 1-ER(1-e)}var OR=class extends KF{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new yL)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},kR=140,AR=class extends _R{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 OR(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new fR),this._shouldRender=!0,this.domNode=dR(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(XL(this.domNode.domNode,aR.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new yR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=dR(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(XL(this.slider.domNode,aR.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=iR(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(VI&&a>kR){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()}},jR=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?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(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 t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},MR=class extends AR{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new jR(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},NR=class extends AR{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new jR(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},PR=500,FR=50,IR=!0,LR=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},RR=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(EI){let t=SI(zL(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new LR(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&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}};RR.INSTANCE=new RR;var zR=RR,BR=class extends _R{constructor(e,t,n){super(),this._onScroll=this._register(new _I),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new _I),this.onWillScroll=this._onWillScroll.event,this._options=HR(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 NR(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new MR(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=dR(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=dR(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=dR(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 yL),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=VF(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,HI&&(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 hL(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=VF(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(XL(this._listenOnDomNode,aR.MOUSE_WHEEL,e=>{this._onMouseWheel(new hL(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=zR.INSTANCE;IR&&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=!HI&&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=FR*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=FR*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)&&(IR&&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(),PR)}},VR=class extends BR{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 HR(e){let t={lazyRender:typeof e.lazyRender<`u`?e.lazyRender:!1,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:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<`u`?e.scrollYToX:!1,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:!1,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,HI&&(t.className+=` mac`),t}var UR=class extends KF{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new _I),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new xR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>eR(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new VR(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(rI.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(UF(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(UF(()=>this._styleElement.remove())),this._register(rI.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(`
|
|
137
|
-
`)})),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}};UR=yP([bP(2,qP),bP(3,oF),bP(4,JP),bP(5,dF),bP(6,$P),bP(7,cF)],UR);var WR=class extends KF{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(UF(()=>{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()}};WR=yP([bP(1,qP),bP(2,oF),bP(3,nF),bP(4,cF)],WR);var GR=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<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=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)}},KR={full:0,left:0,center:0,right:0},qR={full:0,left:0,center:0,right:0},JR={full:0,left:0,center:0,right:0},YR=class extends KF{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 GR,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(UF(()=>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);qR.full=this._canvas.width,qR.left=e,qR.center=t,qR.right=e,this._refreshDrawHeightConstants(),JR.full=1,JR.left=1,JR.center=1+qR.left,JR.right=1+qR.left+qR.center}_refreshDrawHeightConstants(){KR.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);KR.left=t,KR.center=t,KR.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*KR.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*KR.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*KR.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*KR.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(JR[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-KR[e.position||`full`]/2),qR[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+KR[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}))}};YR=yP([bP(2,qP),bP(3,nF),bP(4,cF),bP(5,$P),bP(6,dF),bP(7,oF)],YR);var $;(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=`
|
|
138
|
-
`,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=``))($||={});var XR;(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=``))(XR||={});var ZR;(e=>e.ST=`${$.ESC}\\`)(ZR||={});var QR=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):!0}_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.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};QR=yP([bP(2,qP),bP(3,$P),bP(4,YP),bP(5,cF)],QR);var $R=0,ez=0,tz=0,nz=0,rz={css:`#00000000`,rgba:0},iz;(e=>{function t(e,t,n,r){return r===void 0?`#${lz(e)}${lz(t)}${lz(n)}`:`#${lz(e)}${lz(t)}${lz(n)}${lz(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})(iz||={});var az;(e=>{function t(e,t){if(nz=(t.rgba&255)/255,nz===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 $R=a+Math.round((n-a)*nz),ez=o+Math.round((r-o)*nz),tz=s+Math.round((i-s)*nz),{css:iz.toCss($R,ez,tz),rgba:iz.toRgba($R,ez,tz)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=cz.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return iz.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[$R,ez,tz]=cz.toChannels(t),{css:iz.toCss($R,ez,tz),rgba:t}}e.opaque=i;function a(e,t){return nz=Math.round(t*255),[$R,ez,tz]=cz.toChannels(e.rgba),{css:iz.toCss($R,ez,tz,nz),rgba:iz.toRgba($R,ez,tz,nz)}}e.opacity=a;function o(e,t){return nz=e.rgba&255,a(e,nz*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(az||={});var oz;(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 $R=parseInt(e.slice(1,2).repeat(2),16),ez=parseInt(e.slice(2,3).repeat(2),16),tz=parseInt(e.slice(3,4).repeat(2),16),iz.toColor($R,ez,tz);case 5:return $R=parseInt(e.slice(1,2).repeat(2),16),ez=parseInt(e.slice(2,3).repeat(2),16),tz=parseInt(e.slice(3,4).repeat(2),16),nz=parseInt(e.slice(4,5).repeat(2),16),iz.toColor($R,ez,tz,nz);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 $R=parseInt(r[1]),ez=parseInt(r[2]),tz=parseInt(r[3]),nz=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),iz.toColor($R,ez,tz,nz);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[$R,ez,tz,nz]=t.getImageData(0,0,1,1).data,nz!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:iz.toRgba($R,ez,tz,nz),css:e}}e.toColor=r})(oz||={});var sz;(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})(sz||={});var cz;(e=>{function t(e,t){if(nz=(t&255)/255,nz===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 $R=a+Math.round((n-a)*nz),ez=o+Math.round((r-o)*nz),tz=s+Math.round((i-s)*nz),iz.toRgba($R,ez,tz)}e.blend=t;function n(e,t,n){let a=sz.relativeLuminance(e>>8),o=sz.relativeLuminance(t>>8);if(uz(a,o)<n){if(o<a){let o=r(e,t,n),s=uz(a,sz.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>uz(a,sz.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=uz(a,sz.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>uz(a,sz.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=uz(sz.relativeLuminance2(o,s,c),sz.relativeLuminance2(r,i,a));for(;l<n&&(o>0||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=uz(sz.relativeLuminance2(o,s,c),sz.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=uz(sz.relativeLuminance2(o,s,c),sz.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=uz(sz.relativeLuminance2(o,s,c),sz.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(cz||={});function lz(e){let t=e.toString(16);return t.length<2?`0`+t:t}function uz(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var dz=class extends RP{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()]}},fz=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new BP}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||LP.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)fz._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||LP.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};fz=yP([bP(0,qP)],fz);function pz(e){return 57508<=e&&e<=57558}function mz(e){return 9472<=e&&e<=9631}function hz(e){return pz(e)||mz(e)}function gz(){return{css:{canvas:_z(),cell:_z()},device:{canvas:_z(),cell:_z(),char:{width:0,height:0,left:0,top:0}}}}function _z(){return{width:0,height:0}}var vz=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new BP,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new dz(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),F=n&&k===a,I=O&&k>=l&&k<=u,L=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{L=!0});let R=N.getChars()||LP;if(R===` `&&(N.isUnderline()||N.isOverline())&&(R=`\xA0`),T=m*s-c.get(R,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&I===S&&T===C&&!F&&!A&&!L&&j){N.isInvisible()?_+=LP:_+=R,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=I,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&F&&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(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?LP:N.getChars()||LP,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${RP.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),I&&(h.style.textDecoration=`underline`);let z=N.getFgColor(),B=N.getFgColorMode(),ee=N.getBgColor(),te=N.getBgColorMode(),ne=!!N.isInverse();if(ne){let e=z;z=ee,ee=e;let t=B;B=te,te=t}let V,re,H=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&H||(e.backgroundColorRGB&&(te=50331648,ee=e.backgroundColorRGB.rgba>>8&16777215,V=e.backgroundColorRGB),e.foregroundColorRGB&&(B=50331648,z=e.foregroundColorRGB.rgba>>8&16777215,re=e.foregroundColorRGB),H=e.options.layer===`top`)}),!H&&P&&(V=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ee=V.rgba>>8&16777215,te=50331648,H=!0,p.selectionForeground&&(B=50331648,z=p.selectionForeground.rgba>>8&16777215,re=p.selectionForeground)),H&&D.push(`xterm-decoration-top`);let ie;switch(te){case 16777216:case 33554432:ie=p.ansi[ee],D.push(`xterm-bg-${ee}`);break;case 50331648:ie=iz.toColor(ee>>16,ee>>8&255,ee&255),this._addStyle(h,`background-color:#${yz((ee>>>0).toString(16),`0`,6)}`);break;default:ne?(ie=p.foreground,D.push(`xterm-bg-257`)):ie=p.background}switch(V||N.isDim()&&(V=az.multiplyOpacity(ie,.5)),B){case 16777216:case 33554432:N.isBold()&&z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(z+=8),this._applyMinimumContrast(h,ie,p.ansi[z],N,V,void 0)||D.push(`xterm-fg-${z}`);break;case 50331648:let e=iz.toColor(z>>16&255,z>>8&255,z&255);this._applyMinimumContrast(h,ie,e,N,V,re)||this._addStyle(h,`color:#${yz(z.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ie,p.foreground,N,V,re)||ne&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!F&&!A&&!L&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||hz(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=az.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<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};vz=yP([bP(1,uF),bP(2,$P),bP(3,oF),bP(4,YP),bP(5,nF),bP(6,dF)],vz);function yz(e,t,n){for(;e.length<n;)e=t+e;return e}var bz=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(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}},xz=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.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function Sz(){return new xz}var Cz=`xterm-dom-renderer-owner-`,wz=`xterm-rows`,Tz=`xterm-fg-`,Ez=`xterm-bg-`,Dz=`xterm-focus`,Oz=`xterm-selection`,kz=1,Az=class extends KF{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=kz++,this._rowElements=[],this._selectionRenderModel=Sz(),this.onRequestRedraw=this._register(new _I).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(wz),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(Oz),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=gz(),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(vz,document),this._element.classList.add(Cz+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(UF(()=>{this._element.classList.remove(Cz+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new bz(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} .${wz} 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} .${wz} { 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} .${wz} .xterm-dim { color: ${az.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} .${wz}.${Dz} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${wz}.${Dz} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${wz}.${Dz} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${wz} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${wz} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${wz} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${wz} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${wz} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Oz} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Oz} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Oz} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Tz}${n} { color: ${r.css}; }${this._terminalSelector} .${Tz}${n}.xterm-dim { color: ${az.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Ez}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Tz}257 { color: ${az.opaque(e.background).css}; }${this._terminalSelector} .${Tz}257.xterm-dim { color: ${az.multiplyOpacity(az.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ez}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(Dz),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Dz),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`.${Cz}${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))}}};Az=yP([bP(7,ZP),bP(8,aF),bP(9,$P),bP(10,qP),bP(11,YP),bP(12,oF),bP(13,dF)],Az);var jz=class extends KF{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new _I),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Pz(this._optionsService))}catch{this._measureStrategy=this._register(new Nz(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())}};jz=yP([bP(2,$P)],jz);var Mz=class extends KF{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)}},Nz=class extends Mz{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}},Pz=class extends Mz{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}},Fz=class extends KF{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 Iz(this._window)),this._onDprChange=this._register(new _I),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new _I),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(rI.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(XL(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(XL(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}},Iz=class extends KF{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new qF),this._onDprChange=this._register(new _I),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(UF(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=XL(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)}},Lz=class extends KF{constructor(){super(),this.linkProviders=[],this._register(UF(()=>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 Rz(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 zz(e,t,n,r,i,a,o,s,c){if(!a)return;let l=Rz(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 Bz=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return zz(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=Rz(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])}}};Bz=yP([bP(0,cF),bP(1,aF)],Bz);var Vz=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=[]}},Hz={};vP(Hz,{getSafariVersion:()=>Yz,isChromeOS:()=>tB,isFirefox:()=>Kz,isIpad:()=>Zz,isIphone:()=>Qz,isLegacyEdge:()=>qz,isLinux:()=>eB,isMac:()=>Xz,isNode:()=>Uz,isSafari:()=>Jz,isWindows:()=>$z});var Uz=typeof process<`u`&&`title`in process,Wz=Uz?`node`:navigator.userAgent,Gz=Uz?`node`:navigator.platform,Kz=Wz.includes(`Firefox`),qz=Wz.includes(`Edge`),Jz=/^((?!chrome|android).)*safari/i.test(Wz);function Yz(){if(!Jz)return 0;let e=Wz.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Xz=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Gz),Zz=Gz===`iPad`,Qz=Gz===`iPhone`,$z=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Gz),eB=Gz.indexOf(`Linux`)>=0,tB=/\bCrOS\b/.test(Wz),nB=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){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()}},rB=class extends nB{_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())}}},iB=class extends nB{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},aB=!Uz&&`requestIdleCallback`in window?iB:rB,oB=class{constructor(){this._queue=new aB}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},sB=class extends KF{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 qF),this._pausedResizeTask=new oB,this._observerDisposable=this._register(new qF),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new _I),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new _I),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new _I),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new _I),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Vz((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new cB(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(UF(()=>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=UF(()=>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()}};sB=yP([bP(2,$P),bP(3,aF),bP(4,YP),bP(5,nF),bP(6,qP),bP(7,oF),bP(8,dF)],sB);var cB=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 lB(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return fB(i,a,e,t,n,r)+pB(a,t,n,r)+mB(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,xB(Math.abs(i-e),bB(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return xB(dB(a>t?e:i,n)+(s-1)*n.cols+1+uB(a>t?i:e,n),bB(o,r))}function uB(e,t){return e-1}function dB(e,t){return t.cols-e}function fB(e,t,n,r,i,a){return pB(t,r,i,a).length===0?``:xB(yB(e,t,e,t-gB(t,i),!1,i).length,bB(`D`,a))}function pB(e,t,n,r){let i=e-gB(e,n),a=t-gB(t,n);return xB(Math.abs(i-a)-hB(e,t,n),bB(vB(e,t),r))}function mB(e,t,n,r,i,a){let o;o=pB(t,r,i,a).length>0?r-gB(r,i):t;let s=r,c=_B(e,t,n,r,i,a);return xB(yB(e,o,n,s,c===`C`,i).length,bB(c,a))}function hB(e,t,n){let r=0,i=e-gB(e,n),a=t-gB(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=vB(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function gB(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function _B(e,t,n,r,i,a){let o;return o=pB(n,r,i,a).length>0?r-gB(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function vB(e,t){return e>t?`A`:`B`}function yB(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.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 bB(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function xB(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var SB=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._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 CB(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 wB=50,TB=15,EB=50,DB=500,OB=RegExp(`\xA0`,`g`),kB=class extends KF{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 BP,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new _I),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new _I),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new _I),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new _I),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new SB(this._bufferService),this._activeSelectionMode=0,this._register(UF(()=>{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]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(OB,` `)).join($z?`\r
|
|
134
|
+
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);TI.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*CI<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||CF;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof SI)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},DI=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}},OI=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new EI,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new EI,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}};OI.INSTANCE=new OI;var kI=OI;function AI(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}kI.INSTANCE.onDidChangeZoomLevel;function jI(e){return kI.INSTANCE.getZoomFactor(e)}kI.INSTANCE.onDidChangeFullscreen;var MI=typeof navigator==`object`?navigator.userAgent:``,NI=MI.indexOf(`Firefox`)>=0,PI=MI.indexOf(`AppleWebKit`)>=0,FI=MI.indexOf(`Chrome`)>=0,II=!FI&&MI.indexOf(`Safari`)>=0;MI.indexOf(`Electron/`),MI.indexOf(`Android`);var LI=!1;if(typeof rI.matchMedia==`function`){let e=rI.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=rI.matchMedia(`(display-mode: fullscreen)`);LI=e.matches,AI(rI,e,({matches:e})=>{LI&&t.matches||(LI=e)})}function RI(){return LI}var zI=`en`,BI=!1,VI=!1,HI=!1,UI=!1,WI=!1,GI=zI,KI,qI=globalThis,JI;typeof qI.vscode<`u`&&typeof qI.vscode.process<`u`?JI=qI.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(JI=process);var YI=typeof JI?.versions?.electron==`string`&&JI?.type===`renderer`;if(typeof JI==`object`){BI=JI.platform===`win32`,VI=JI.platform===`darwin`,HI=JI.platform===`linux`,HI&&JI.env.SNAP&&JI.env.SNAP_REVISION,JI.env.CI||JI.env.BUILD_ARTIFACTSTAGINGDIRECTORY,GI=zI;let e=JI.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,GI=t.resolvedLanguage||zI,t.languagePack?.translationsConfigFile}catch{}UI=!0}else typeof navigator==`object`&&!YI?(KI=navigator.userAgent,BI=KI.indexOf(`Windows`)>=0,VI=KI.indexOf(`Macintosh`)>=0,(KI.indexOf(`Macintosh`)>=0||KI.indexOf(`iPad`)>=0||KI.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,HI=KI.indexOf(`Linux`)>=0,KI?.indexOf(`Mobi`),WI=!0,GI=globalThis._VSCODE_NLS_LANGUAGE||zI,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var XI=BI,ZI=VI,QI=HI,$I=UI;WI&&typeof qI.importScripts==`function`&&qI.origin;var eL=KI,tL=GI,nL;(e=>{function t(){return tL}e.value=t;function n(){return tL.length===2?tL===`en`:tL.length>=3?tL[0]===`e`&&tL[1]===`n`&&tL[2]===`-`:!1}e.isDefaultVariant=n;function r(){return tL===`en`}e.isDefault=r})(nL||={});var rL=typeof qI.postMessage==`function`&&!qI.importScripts;(()=>{if(rL){let e=[];qI.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),qI.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var iL=!!(eL&&eL.indexOf(`Chrome`)>=0);eL&&eL.indexOf(`Firefox`),!iL&&eL&&eL.indexOf(`Safari`),eL&&eL.indexOf(`Edg/`),eL&&eL.indexOf(`Android`);var aL=typeof navigator==`object`?navigator:{};$I||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||aL&&aL.clipboard&&aL.clipboard.writeText,$I||aL&&aL.clipboard&&aL.clipboard.readText,$I||RI()||aL.keyboard,`ontouchstart`in rI||aL.maxTouchPoints,rI.PointerEvent&&(`ontouchstart`in rI||navigator.maxTouchPoints);var oL=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}},sL=new oL,cL=new oL,lL=new oL,uL=Array(230),dL;(e=>{function t(e){return sL.keyCodeToStr(e)}e.toString=t;function n(e){return sL.strToKeyCode(e)}e.fromString=n;function r(e){return cL.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return lL.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return cL.strToKeyCode(e)||lL.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 sL.keyCodeToStr(e)}e.toElectronAccelerator=o})(dL||={});var fL=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 pL([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},pL=class{constructor(e){if(e.length===0)throw DF(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function mL(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return dL.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(NI)switch(t){case 59:return 85;case 60:if(QI)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ZI)return 57;break}else if(PI&&(ZI&&t===93||!ZI&&t===92))return 57;return uL[t]||0}var hL=ZI?256:2048,gL=512,_L=1024,vL=ZI?2048:256,yL=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=mL(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=hL),this.altKey&&(t|=gL),this.shiftKey&&(t|=_L),this.metaKey&&(t|=vL),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new fL(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},bL=new WeakMap;function xL(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var SL=class{static getSameOriginWindowChain(e){let t=bL.get(e);if(!t){t=[],bL.set(e,t);let n=e,r;do r=xL(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},CL=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=SL.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},wL=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(FI){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)r?this.deltaY=t.wheelDeltaY/(120*i):this.deltaY=t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?NI&&!ZI?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)II&&XI?this.deltaX=-(t.wheelDeltaX/120):r?this.deltaX=t.wheelDeltaX/(120*i):this.deltaX=t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?NI&&!ZI?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},TL=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),EL;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof DL?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:fI.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:TL})})(EL||={});var DL=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?TL:(this._emitter||=new EI,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},OL=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 kF(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new kF(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},kL=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 kF(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=QF(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var AL;(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})(AL||={});var jL=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 EI,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._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await fI.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(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())}};jL.EMPTY=jL.fromArray([]);function ML(e){return 55296<=e&&e<=56319}function NL(e){return 56320<=e&&e<=57343}function PL(e,t){return(e-55296<<10)+(t-56320)+65536}function FL(e){return IL(e,0)}function IL(e,t){switch(typeof e){case`object`:return e===null?LL(349,t):Array.isArray(e)?BL(e,t):VL(e,t);case`string`:return zL(e,t);case`boolean`:return RL(e,t);case`number`:return LL(e,t);case`undefined`:return LL(937,t);default:return LL(617,t)}}function LL(e,t){return(t<<5)-t+e|0}function RL(e,t){return LL(e?433:863,t)}function zL(e,t){t=LL(149417,t);for(let n=0,r=e.length;n<r;n++)t=LL(e.charCodeAt(n),t);return t}function BL(e,t){return t=LL(104579,t),e.reduce((e,t)=>IL(t,e),t)}function VL(e,t){return t=LL(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=zL(n,t),IL(e[n],t)),t)}function HL(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function UL(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function WL(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function GL(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):WL((e>>>0).toString(16),t/4)}var KL=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(ML(a))if(o+1<t){let t=e.charCodeAt(o+1);NL(t)?(o++,s=PL(a,t)):s=65533}else{i=a;break}else NL(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),GL(this._h0)+GL(this._h1)+GL(this._h2)+GL(this._h3)+GL(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,UL(this._buff,this._buffLen),this._buffLen>56&&(this._step(),UL(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,HL(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=HL(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=HL(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};KL._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:qL,getWindow:JL,getDocument:YL,getWindows:XL,getWindowsCount:ZL,getWindowId:QL,getWindowById:$L,hasWindow:eR,onDidRegisterWindow:tR,onWillUnregisterWindow:nR,onDidUnregisterWindow:rR}=function(){let e=new Map,t={window:rI,disposables:new eI};e.set(rI.vscodeWindowId,t);let n=new EI,r=new EI,i=new EI;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 tI.None;let a=new eI,o={window:t,disposables:a.add(new eI)};return e.set(t.vscodeWindowId,o),a.add(QF(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(aR(t,mR.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:rI},getDocument(e){return JL(e).document}}}(),iR=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 aR(e,t,n,r){return new iR(e,t,n,r)}function oR(e,t){return function(n){return t(new CL(e,n))}}function sR(e){return function(t){return e(new yL(t))}}var cR=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=oR(JL(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=sR(n)),aR(e,t,i,r)},lR,uR=class extends kL{constructor(e){super(),this.defaultTarget=e&&JL(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},dR=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){CF(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(dR.sort),a.shift().execute();r.set(i,!1)};lR=(t,r,a=0)=>{let o=QL(t),s=new dR(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 fR=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}};fR.None=new fR(0,0);function pR(e){let t=e.getBoundingClientRect(),n=JL(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=FL(n),a=r.get(i);if(a)a.users+=1;else{let o=new EI,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(QF(()=>{--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 mR={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:PI?`webkitAnimationStart`:`animationstart`,ANIMATION_END:PI?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:PI?`webkitAnimationIteration`:`animationiteration`},hR=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function gR(e,t,n,...r){let i=hR.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function _R(e,t,...n){return gR(`http://www.w3.org/1999/xhtml`,e,t,...n)}_R.SVG=function(e,t,...n){return gR(`http://www.w3.org/2000/svg`,e,t,...n)};var vR=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=yR(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=yR(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=yR(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=yR(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=yR(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=yR(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=yR(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=yR(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=yR(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=yR(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=yR(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=yR(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=yR(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=yR(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 yR(e){return typeof e==`number`?`${e}px`:e}function bR(e){return new vR(e)}var xR=class{constructor(){this._hooks=new eI,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(QF(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=JL(e)}this._hooks.add(aR(a,mR.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(aR(a,mR.POINTER_UP,e=>this.stopMonitoring(!0)))}};function SR(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 CR;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(CR||={});var wR=class e extends tI{constructor(){super(),this.dispatched=!1,this.targets=new oI,this.ignoreTargets=new oI,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(fI.runAndSubscribe(tR,({window:e,disposables:t})=>{t.add(aR(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(aR(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(aR(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:rI,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=YF(new e),QF(e.INSTANCE.targets.push(t))):tI.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=YF(new e),QF(e.INSTANCE.ignoreTargets.push(t))):tI.None}static isTouchDevice(){return`ontouchstart`in rI||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<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(CR.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-MF(s.rollingPageX))<30&&Math.abs(s.initialPageY-MF(s.rollingPageY))<30){let e=this.newGestureEvent(CR.Tap,s.initialTarget);e.pageX=MF(s.rollingPageX),e.pageY=MF(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-MF(s.rollingPageX))<30&&Math.abs(s.initialPageY-MF(s.rollingPageY))<30){let e=this.newGestureEvent(CR.Contextmenu,s.initialTarget);e.pageX=MF(s.rollingPageX),e.pageY=MF(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=MF(s.rollingPageX),n=MF(s.rollingPageY),i=MF(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(CR.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===CR.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===CR.Change||t.type===CR.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=lR(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(CR.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;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(CR.Change,i.initialTarget);a.translationX=r.pageX-MF(i.rollingPageX),a.translationY=r.pageY-MF(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(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)}};wR.SCROLL_FRICTION=-.005,wR.HOLD_DELAY=700,wR.CLEAR_TAP_COUNT_TIME=400,OP([SR],wR,`isTouchDevice`,1);var TR=wR,ER=class extends tI{onclick(e,t){this._register(aR(e,mR.CLICK,n=>t(new CL(JL(e),n))))}onmousedown(e,t){this._register(aR(e,mR.MOUSE_DOWN,n=>t(new CL(JL(e),n))))}onmouseover(e,t){this._register(aR(e,mR.MOUSE_OVER,n=>t(new CL(JL(e),n))))}onmouseleave(e,t){this._register(aR(e,mR.MOUSE_LEAVE,n=>t(new CL(JL(e),n))))}onkeydown(e,t){this._register(aR(e,mR.KEY_DOWN,e=>t(new yL(e))))}onkeyup(e,t){this._register(aR(e,mR.KEY_UP,e=>t(new yL(e))))}oninput(e,t){this._register(aR(e,mR.INPUT,t))}onblur(e,t){this._register(aR(e,mR.BLUR,t))}onfocus(e,t){this._register(aR(e,mR.FOCUS,t))}onchange(e,t){this._register(aR(e,mR.CHANGE,t))}ignoreGesture(e){return TR.ignoreTarget(e)}},DR=11,OR=class extends ER{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=DR+`px`,this.domNode.style.height=DR+`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 xR),this._register(cR(this.bgDomNode,mR.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(cR(this.domNode,mR.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new uR),this._pointerdownScheduleRepeatTimer=this._register(new OL)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,JL(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},kR=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}}},AR=class extends tI{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new EI),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new kR(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 PR(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=PR.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)))}},jR=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function MR(e,t){let n=t-e;return function(t){return e+n*IR(t)}}function NR(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var PR=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),NR(MR(e,r),MR(i,t),.33)}return MR(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new jR(this.scrollLeft(t),this.scrollTop(t),!1):new jR(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){return r+=10,new e(t,n,Date.now()-10,r)}};function FR(e){return e**3}function IR(e){return 1-FR(1-e)}var LR=class extends tI{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new OL)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},RR=140,zR=class extends ER{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 LR(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new xR),this._shouldRender=!0,this.domNode=bR(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(aR(this.domNode.domNode,mR.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new OR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=bR(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(aR(this.slider.domNode,mR.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=pR(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(XI&&a>RR){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()}},BR=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?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(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 t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},VR=class extends zR{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new BR(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},HR=class extends zR{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new BR(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},UR=500,WR=50,GR=!0,KR=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},qR=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(FI){let t=jI(JL(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new KR(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&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}};qR.INSTANCE=new qR;var JR=qR,YR=class extends ER{constructor(e,t,n){super(),this._onScroll=this._register(new EI),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new EI),this.onWillScroll=this._onWillScroll.event,this._options=ZR(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 HR(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new VR(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=bR(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=bR(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=bR(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 OL),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=XF(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,ZI&&(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 wL(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=XF(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(aR(this._listenOnDomNode,mR.MOUSE_WHEEL,e=>{this._onMouseWheel(new wL(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=JR.INSTANCE;GR&&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=!ZI&&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=WR*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=WR*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)&&(GR&&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(),UR)}},XR=class extends YR{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 ZR(e){let t={lazyRender:typeof e.lazyRender<`u`?e.lazyRender:!1,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:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<`u`?e.scrollYToX:!1,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:!1,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,ZI&&(t.className+=` mac`),t}var QR=class extends tI{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new EI),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new AR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>lR(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new XR(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(fI.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(QF(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(QF(()=>this._styleElement.remove())),this._register(fI.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(`
|
|
135
|
+
`)})),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}};QR=OP([kP(2,nF),kP(3,hF),kP(4,rF),kP(5,bF),kP(6,cF),kP(7,_F)],QR);var $R=class extends tI{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(QF(()=>{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()}};$R=OP([kP(1,nF),kP(2,hF),kP(3,dF),kP(4,_F)],$R);var ez=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<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=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)}},tz={full:0,left:0,center:0,right:0},nz={full:0,left:0,center:0,right:0},rz={full:0,left:0,center:0,right:0},iz=class extends tI{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 ez,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(QF(()=>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);nz.full=this._canvas.width,nz.left=e,nz.center=t,nz.right=e,this._refreshDrawHeightConstants(),rz.full=1,rz.left=1,rz.center=1+nz.left,rz.right=1+nz.left+nz.center}_refreshDrawHeightConstants(){tz.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);tz.left=t,tz.center=t,tz.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*tz.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*tz.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*tz.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*tz.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(rz[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-tz[e.position||`full`]/2),nz[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+tz[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}))}};iz=OP([kP(2,nF),kP(3,dF),kP(4,_F),kP(5,cF),kP(6,bF),kP(7,hF)],iz);var $;(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=`
|
|
136
|
+
`,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=``))($||={});var az;(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=``))(az||={});var oz;(e=>e.ST=`${$.ESC}\\`)(oz||={});var sz=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):!0}_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.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};sz=OP([kP(2,nF),kP(3,cF),kP(4,iF),kP(5,_F)],sz);var cz=0,lz=0,uz=0,dz=0,fz={css:`#00000000`,rgba:0},pz;(e=>{function t(e,t,n,r){return r===void 0?`#${vz(e)}${vz(t)}${vz(n)}`:`#${vz(e)}${vz(t)}${vz(n)}${vz(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})(pz||={});var mz;(e=>{function t(e,t){if(dz=(t.rgba&255)/255,dz===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 cz=a+Math.round((n-a)*dz),lz=o+Math.round((r-o)*dz),uz=s+Math.round((i-s)*dz),{css:pz.toCss(cz,lz,uz),rgba:pz.toRgba(cz,lz,uz)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=_z.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return pz.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[cz,lz,uz]=_z.toChannels(t),{css:pz.toCss(cz,lz,uz),rgba:t}}e.opaque=i;function a(e,t){return dz=Math.round(t*255),[cz,lz,uz]=_z.toChannels(e.rgba),{css:pz.toCss(cz,lz,uz,dz),rgba:pz.toRgba(cz,lz,uz,dz)}}e.opacity=a;function o(e,t){return dz=e.rgba&255,a(e,dz*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(mz||={});var hz;(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 cz=parseInt(e.slice(1,2).repeat(2),16),lz=parseInt(e.slice(2,3).repeat(2),16),uz=parseInt(e.slice(3,4).repeat(2),16),pz.toColor(cz,lz,uz);case 5:return cz=parseInt(e.slice(1,2).repeat(2),16),lz=parseInt(e.slice(2,3).repeat(2),16),uz=parseInt(e.slice(3,4).repeat(2),16),dz=parseInt(e.slice(4,5).repeat(2),16),pz.toColor(cz,lz,uz,dz);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 cz=parseInt(r[1]),lz=parseInt(r[2]),uz=parseInt(r[3]),dz=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),pz.toColor(cz,lz,uz,dz);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[cz,lz,uz,dz]=t.getImageData(0,0,1,1).data,dz!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:pz.toRgba(cz,lz,uz,dz),css:e}}e.toColor=r})(hz||={});var gz;(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})(gz||={});var _z;(e=>{function t(e,t){if(dz=(t&255)/255,dz===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 cz=a+Math.round((n-a)*dz),lz=o+Math.round((r-o)*dz),uz=s+Math.round((i-s)*dz),pz.toRgba(cz,lz,uz)}e.blend=t;function n(e,t,n){let a=gz.relativeLuminance(e>>8),o=gz.relativeLuminance(t>>8);if(yz(a,o)<n){if(o<a){let o=r(e,t,n),s=yz(a,gz.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>yz(a,gz.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=yz(a,gz.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>yz(a,gz.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=yz(gz.relativeLuminance2(o,s,c),gz.relativeLuminance2(r,i,a));for(;l<n&&(o>0||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=yz(gz.relativeLuminance2(o,s,c),gz.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=yz(gz.relativeLuminance2(o,s,c),gz.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=yz(gz.relativeLuminance2(o,s,c),gz.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(_z||={});function vz(e){let t=e.toString(16);return t.length<2?`0`+t:t}function yz(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var bz=class extends qP{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()]}},xz=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new YP}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||KP.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)xz._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||KP.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};xz=OP([kP(0,nF)],xz);function Sz(e){return 57508<=e&&e<=57558}function Cz(e){return 9472<=e&&e<=9631}function wz(e){return Sz(e)||Cz(e)}function Tz(){return{css:{canvas:Ez(),cell:Ez()},device:{canvas:Ez(),cell:Ez(),char:{width:0,height:0,left:0,top:0}}}}function Ez(){return{width:0,height:0}}var Dz=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new YP,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new bz(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),F=n&&k===a,I=O&&k>=l&&k<=u,L=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{L=!0});let R=N.getChars()||KP;if(R===` `&&(N.isUnderline()||N.isOverline())&&(R=`\xA0`),T=m*s-c.get(R,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&I===S&&T===C&&!F&&!A&&!L&&j){N.isInvisible()?_+=KP:_+=R,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=I,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&F&&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(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?KP:N.getChars()||KP,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${qP.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),I&&(h.style.textDecoration=`underline`);let z=N.getFgColor(),B=N.getFgColorMode(),ee=N.getBgColor(),te=N.getBgColorMode(),ne=!!N.isInverse();if(ne){let e=z;z=ee,ee=e;let t=B;B=te,te=t}let V,re,H=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&H||(e.backgroundColorRGB&&(te=50331648,ee=e.backgroundColorRGB.rgba>>8&16777215,V=e.backgroundColorRGB),e.foregroundColorRGB&&(B=50331648,z=e.foregroundColorRGB.rgba>>8&16777215,re=e.foregroundColorRGB),H=e.options.layer===`top`)}),!H&&P&&(V=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ee=V.rgba>>8&16777215,te=50331648,H=!0,p.selectionForeground&&(B=50331648,z=p.selectionForeground.rgba>>8&16777215,re=p.selectionForeground)),H&&D.push(`xterm-decoration-top`);let ie;switch(te){case 16777216:case 33554432:ie=p.ansi[ee],D.push(`xterm-bg-${ee}`);break;case 50331648:ie=pz.toColor(ee>>16,ee>>8&255,ee&255),this._addStyle(h,`background-color:#${Oz((ee>>>0).toString(16),`0`,6)}`);break;default:ne?(ie=p.foreground,D.push(`xterm-bg-257`)):ie=p.background}switch(V||N.isDim()&&(V=mz.multiplyOpacity(ie,.5)),B){case 16777216:case 33554432:N.isBold()&&z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(z+=8),this._applyMinimumContrast(h,ie,p.ansi[z],N,V,void 0)||D.push(`xterm-fg-${z}`);break;case 50331648:let e=pz.toColor(z>>16&255,z>>8&255,z&255);this._applyMinimumContrast(h,ie,e,N,V,re)||this._addStyle(h,`color:#${Oz(z.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ie,p.foreground,N,V,re)||ne&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!F&&!A&&!L&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||wz(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=mz.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<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};Dz=OP([kP(1,yF),kP(2,cF),kP(3,hF),kP(4,iF),kP(5,dF),kP(6,bF)],Dz);function Oz(e,t,n){for(;e.length<n;)e=t+e;return e}var kz=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(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}},Az=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.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function jz(){return new Az}var Mz=`xterm-dom-renderer-owner-`,Nz=`xterm-rows`,Pz=`xterm-fg-`,Fz=`xterm-bg-`,Iz=`xterm-focus`,Lz=`xterm-selection`,Rz=1,zz=class extends tI{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=Rz++,this._rowElements=[],this._selectionRenderModel=jz(),this.onRequestRedraw=this._register(new EI).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Nz),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(Lz),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Tz(),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(Dz,document),this._element.classList.add(Mz+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(QF(()=>{this._element.classList.remove(Mz+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new kz(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} .${Nz} 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} .${Nz} { 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} .${Nz} .xterm-dim { color: ${mz.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} .${Nz}.${Iz} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Nz}.${Iz} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Nz}.${Iz} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Nz} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Nz} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Nz} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Nz} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Nz} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Lz} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Lz} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Lz} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Pz}${n} { color: ${r.css}; }${this._terminalSelector} .${Pz}${n}.xterm-dim { color: ${mz.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Fz}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Pz}257 { color: ${mz.opaque(e.background).css}; }${this._terminalSelector} .${Pz}257.xterm-dim { color: ${mz.multiplyOpacity(mz.opaque(e.background),.5).css}; }${this._terminalSelector} .${Fz}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(Iz),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Iz),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`.${Mz}${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))}}};zz=OP([kP(7,oF),kP(8,mF),kP(9,cF),kP(10,nF),kP(11,iF),kP(12,hF),kP(13,bF)],zz);var Bz=class extends tI{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new EI),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Uz(this._optionsService))}catch{this._measureStrategy=this._register(new Hz(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())}};Bz=OP([kP(2,cF)],Bz);var Vz=class extends tI{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)}},Hz=class extends Vz{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}},Uz=class extends Vz{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}},Wz=class extends tI{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 Gz(this._window)),this._onDprChange=this._register(new EI),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new EI),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(fI.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(aR(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(aR(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}},Gz=class extends tI{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new nI),this._onDprChange=this._register(new EI),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(QF(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=aR(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)}},Kz=class extends tI{constructor(){super(),this.linkProviders=[],this._register(QF(()=>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 qz(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 Jz(e,t,n,r,i,a,o,s,c){if(!a)return;let l=qz(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 Yz=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Jz(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=qz(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])}}};Yz=OP([kP(0,_F),kP(1,mF)],Yz);var Xz=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=[]}},Zz={};DP(Zz,{getSafariVersion:()=>iB,isChromeOS:()=>uB,isFirefox:()=>tB,isIpad:()=>oB,isIphone:()=>sB,isLegacyEdge:()=>nB,isLinux:()=>lB,isMac:()=>aB,isNode:()=>Qz,isSafari:()=>rB,isWindows:()=>cB});var Qz=typeof process<`u`&&`title`in process,$z=Qz?`node`:navigator.userAgent,eB=Qz?`node`:navigator.platform,tB=$z.includes(`Firefox`),nB=$z.includes(`Edge`),rB=/^((?!chrome|android).)*safari/i.test($z);function iB(){if(!rB)return 0;let e=$z.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var aB=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(eB),oB=eB===`iPad`,sB=eB===`iPhone`,cB=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(eB),lB=eB.indexOf(`Linux`)>=0,uB=/\bCrOS\b/.test($z),dB=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){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()}},fB=class extends dB{_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())}}},pB=class extends dB{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},mB=!Qz&&`requestIdleCallback`in window?pB:fB,hB=class{constructor(){this._queue=new mB}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},gB=class extends tI{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 nI),this._pausedResizeTask=new hB,this._observerDisposable=this._register(new nI),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 EI),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new EI),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new EI),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new EI),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Xz((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new _B(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(QF(()=>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=QF(()=>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()}};gB=OP([kP(2,cF),kP(3,mF),kP(4,iF),kP(5,dF),kP(6,nF),kP(7,hF),kP(8,bF)],gB);var _B=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 vB(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return xB(i,a,e,t,n,r)+SB(a,t,n,r)+CB(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,AB(Math.abs(i-e),kB(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return AB(bB(a>t?e:i,n)+(s-1)*n.cols+1+yB(a>t?i:e,n),kB(o,r))}function yB(e,t){return e-1}function bB(e,t){return t.cols-e}function xB(e,t,n,r,i,a){return SB(t,r,i,a).length===0?``:AB(OB(e,t,e,t-TB(t,i),!1,i).length,kB(`D`,a))}function SB(e,t,n,r){let i=e-TB(e,n),a=t-TB(t,n);return AB(Math.abs(i-a)-wB(e,t,n),kB(DB(e,t),r))}function CB(e,t,n,r,i,a){let o;o=SB(t,r,i,a).length>0?r-TB(r,i):t;let s=r,c=EB(e,t,n,r,i,a);return AB(OB(e,o,n,s,c===`C`,i).length,kB(c,a))}function wB(e,t,n){let r=0,i=e-TB(e,n),a=t-TB(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=DB(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function TB(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function EB(e,t,n,r,i,a){let o;return o=SB(n,r,i,a).length>0?r-TB(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function DB(e,t){return e>t?`A`:`B`}function OB(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.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 kB(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function AB(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var jB=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._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 MB(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 NB=50,PB=15,FB=50,IB=500,LB=RegExp(`\xA0`,`g`),RB=class extends tI{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 YP,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new EI),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new EI),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new EI),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new EI),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 jB(this._bufferService),this._activeSelectionMode=0,this._register(QF(()=>{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]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(LB,` `)).join(cB?`\r
|
|
139
137
|
`:`
|
|
140
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),eB&&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]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&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=CB(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=Rz(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,-wB),wB),t/=wB,t/Math.abs(t)+Math.round(t*(TB-1)))}shouldForceSelection(e){return Xz?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(),EB)}_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&&!(Xz&&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]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>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]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<DB&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=lB(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(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(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(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?!1: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=CB(n,this._bufferService.cols)}};kB=yP([bP(3,qP),bP(4,YP),bP(5,sF),bP(6,$P),bP(7,cF),bP(8,oF)],kB);var AB=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={}}},jB=class{constructor(){this._color=new AB,this._css=new AB}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()}},MB=Object.freeze((()=>{let e=[oz.toColor(`#2e3436`),oz.toColor(`#cc0000`),oz.toColor(`#4e9a06`),oz.toColor(`#c4a000`),oz.toColor(`#3465a4`),oz.toColor(`#75507b`),oz.toColor(`#06989a`),oz.toColor(`#d3d7cf`),oz.toColor(`#555753`),oz.toColor(`#ef2929`),oz.toColor(`#8ae234`),oz.toColor(`#fce94f`),oz.toColor(`#729fcf`),oz.toColor(`#ad7fa8`),oz.toColor(`#34e2e2`),oz.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:iz.toCss(r,i,a),rgba:iz.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:iz.toCss(n,n,n),rgba:iz.toRgba(n,n,n)})}return e})()),NB=oz.toColor(`#ffffff`),PB=oz.toColor(`#000000`),FB=oz.toColor(`#ffffff`),IB=PB,LB={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},RB=NB,zB=class extends KF{constructor(e){super(),this._optionsService=e,this._contrastCache=new jB,this._halfContrastCache=new jB,this._onChangeColors=this._register(new _I),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:NB,background:PB,cursor:FB,cursorAccent:IB,selectionForeground:void 0,selectionBackgroundTransparent:LB,selectionBackgroundOpaque:az.blend(PB,LB),selectionInactiveBackgroundTransparent:LB,selectionInactiveBackgroundOpaque:az.blend(PB,LB),scrollbarSliderBackground:az.opacity(NB,.2),scrollbarSliderHoverBackground:az.opacity(NB,.4),scrollbarSliderActiveBackground:az.opacity(NB,.5),overviewRulerBorder:NB,ansi:MB.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=BB(e.foreground,NB),t.background=BB(e.background,PB),t.cursor=az.blend(t.background,BB(e.cursor,FB)),t.cursorAccent=az.blend(t.background,BB(e.cursorAccent,IB)),t.selectionBackgroundTransparent=BB(e.selectionBackground,LB),t.selectionBackgroundOpaque=az.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=BB(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=az.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?BB(e.selectionForeground,rz):void 0,t.selectionForeground===rz&&(t.selectionForeground=void 0),az.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=az.opacity(t.selectionBackgroundTransparent,.3)),az.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=az.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=BB(e.scrollbarSliderBackground,az.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=BB(e.scrollbarSliderHoverBackground,az.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=BB(e.scrollbarSliderActiveBackground,az.opacity(t.foreground,.5)),t.overviewRulerBorder=BB(e.overviewRulerBorder,RB),t.ansi=MB.slice(),t.ansi[0]=BB(e.black,MB[0]),t.ansi[1]=BB(e.red,MB[1]),t.ansi[2]=BB(e.green,MB[2]),t.ansi[3]=BB(e.yellow,MB[3]),t.ansi[4]=BB(e.blue,MB[4]),t.ansi[5]=BB(e.magenta,MB[5]),t.ansi[6]=BB(e.cyan,MB[6]),t.ansi[7]=BB(e.white,MB[7]),t.ansi[8]=BB(e.brightBlack,MB[8]),t.ansi[9]=BB(e.brightRed,MB[9]),t.ansi[10]=BB(e.brightGreen,MB[10]),t.ansi[11]=BB(e.brightYellow,MB[11]),t.ansi[12]=BB(e.brightBlue,MB[12]),t.ansi[13]=BB(e.brightMagenta,MB[13]),t.ansi[14]=BB(e.brightCyan,MB[14]),t.ansi[15]=BB(e.brightWhite,MB[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=BB(e.extendedAnsi[r],MB[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};zB=yP([bP(0,$P)],zB);function BB(e,t){if(e!==void 0)try{return oz.toColor(e)}catch{}return t}var VB=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},HB=class{constructor(){this._services=new VB,this._services.set(ZP,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=WP(e).sort((e,t)=>e.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)}},UB={trace:0,debug:1,info:2,warn:3,error:4,off:5},WB=`xterm.js: `,GB=class extends KF{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),KB=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=UB[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:WB)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};GB=yP([bP(0,$P)],GB);var KB,qB=class extends KF{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new _I),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new _I),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new _I),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._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<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},JB=3,YB=Object.freeze(new RP),XB=0,ZB=2,QB=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*JB);let r=t||BP.fromCharData([0,IP,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*JB+0],n=t&2097151;return[this._data[e*JB+1],t&2097152?this._combined[e]:n?MP(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*JB+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*JB+0]=e|2097152|t[2]<<22):this._data[e*JB+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*JB+0]>>22}hasWidth(e){return this._data[e*JB+0]&12582912}getFg(e){return this._data[e*JB+1]}getBg(e){return this._data[e*JB+2]}hasContent(e){return this._data[e*JB+0]&4194303}getCodePoint(e){let t=this._data[e*JB+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*JB+0]&2097152}getString(e){let t=this._data[e*JB+0];return t&2097152?this._combined[e]:t&2097151?MP(t&2097151):``}isProtected(e){return this._data[e*JB+2]&536870912}loadCell(e,t){return XB=e*JB,t.content=this._data[XB+0],t.fg=this._data[XB+1],t.bg=this._data[XB+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*JB+0]=t.content,this._data[e*JB+1]=t.fg,this._data[e*JB+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*JB+0]=t|n<<22,this._data[e*JB+1]=r.fg,this._data[e*JB+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*JB+0];r&2097152?this._combined[e]+=MP(t):r&2097151?(this._combined[e]=MP(r&2097151)+MP(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*JB+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new BP;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new BP;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*ZB<this._data.buffer.byteLength;let n=e*JB;if(e>this.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;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*ZB<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ZB<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*JB+0]&4194303)return e+(this._data[e*JB+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*JB+0]&4194303||this._data[e*JB+2]&50331648)return e+(this._data[e*JB+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<JB;e++)this._data[(n+i)*JB+e]=a[(t+i)*JB+e];a[(t+i)*JB+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<JB;e++)this._data[(n+i)*JB+e]=a[(t+i)*JB+e];a[(t+i)*JB+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=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<n;){let e=this._data[t*JB+0],n=e&2097151,a=e&2097152?this._combined[t]:n?MP(n):LP;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function $B(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=rV(u,d,t),p=1,m=0;for(;p<u.length;){let e=rV(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(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 eV(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function tV(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function nV(e,t,n){let r=[],i=e.map((n,r)=>rV(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=rV(e,o,t);a>c&&(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 rV(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 iV=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new _I),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),VF(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};iV._nextId=1;var aV=iV,oV={},sV=oV.B;oV[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},oV.A={"#":`£`},oV.B=void 0,oV[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},oV.C=oV[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},oV.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},oV.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},oV.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},oV.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},oV.E=oV[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},oV.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},oV.H=oV[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},oV[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var cV=4294967295,lV=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=YB.clone(),this.savedCharset=sV,this.markers=[],this._nullCell=BP.fromCharData([0,IP,1,0]),this._whitespaceCell=BP.fromCharData([0,LP,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new aB,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new qB(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 zP),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 zP),this._whitespaceCell}getBlankLine(e,t){return new QB(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&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>cV?cV:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=YB);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 qB(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(YB),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new QB(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new QB(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(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(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<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.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._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)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=$B(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(YB),n);if(r.length>0){let n=eV(this.lines,r);tV(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(YB),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new QB(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(YB),i=[],a=0;for(let o=this.lines.length-1;o>=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&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=nV(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(YB,!0);p.push(e)}p.length>0&&(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--,_=rV(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=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+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new aV(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{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.line<e.index+e.amount&&t.dispose(),t.line>e.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)}},uV=class extends KF{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new _I),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new lV(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new lV(!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)}},dV=2,fV=1,pV=class extends KF{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new _I),this.onResize=this._onResize.event,this._onScroll=this._register(new _I),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,dV),this.rows=Math.max(e.rawOptions.rows||0,fV),this.buffers=this._register(new uV(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))}};pV=yP([bP(0,$P)],pV);var mV={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:Xz,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},hV=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],gV=class extends KF{constructor(e){super(),this._onOptionChange=this._register(new _I),this.onOptionChange=this._onOptionChange.event;let t={...mV};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(UF(()=>{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 mV))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in mV))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||=mV[e],!_V(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=mV[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=hV.includes(t)?t:mV[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??={};break}return t}};function _V(e){return e===`block`||e===`underline`||e===`bar`}function vV(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]&&vV(e[r],t-1);return n}var yV=Object.freeze({insertMode:!1}),bV=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),xV=class extends KF{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new _I),this.onData=this._onData.event,this._onUserInput=this._register(new _I),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new _I),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new _I),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=vV(yV),this.decPrivateModes=vV(bV)}reset(){this.modes=vV(yV),this.decPrivateModes=vV(bV)}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))}};xV=yP([bP(0,qP),bP(1,QP),bP(2,$P)],xV);var SV={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 CV(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 wV=String.fromCharCode,TV={DEFAULT:e=>{let t=[CV(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${wV(t[0])}${wV(t[1])}${wV(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${CV(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${CV(e,!0)};${e.x};${e.y}${t}`}},EV=class extends KF{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new _I),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(SV))this.addProtocol(e,SV[e]);for(let e of Object.keys(TV))this.addEncoding(e,TV[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)}};EV=yP([bP(0,qP),bP(1,YP),bP(2,$P)],EV);var DV=[[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]],OV=[[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]],kV;function AV(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var jV=class{constructor(){if(this.version=`6`,!kV){kV=new Uint8Array(65536),kV.fill(1),kV[0]=0,kV.fill(0,1,32),kV.fill(0,127,160),kV.fill(2,4352,4448),kV[9001]=2,kV[9002]=2,kV.fill(2,11904,42192),kV[12351]=1,kV.fill(2,44032,55204),kV.fill(2,63744,64256),kV.fill(2,65040,65050),kV.fill(2,65072,65136),kV.fill(2,65280,65377),kV.fill(2,65504,65511);for(let e=0;e<DV.length;++e)kV.fill(0,DV[e][0],DV[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?kV[e]:AV(e,OV)?0: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=MV.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return MV.createPropertyValue(0,n,r)}},MV=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new _I,this.onChange=this._onChange.event;let e=new jV;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}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;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++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)}},NV=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 PV(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 FV=2147483647,IV=256,LV=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>IV)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<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>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>FV?FV: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>FV?FV: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<this.length;++t){let n=this._subParamsIdx[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,FV):e}},RV=[],zV=class{constructor(){this._state=0,this._active=RV,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=RV}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=RV,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||RV,!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`,NP(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(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&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=RV,this._id=-1,this._state=0}}},BV=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+=NP(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}},VV=[],HV=class{constructor(){this._handlers=Object.create(null),this._active=VV,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=VV}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=VV,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||VV,!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`,NP(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=VV,this._ident=0}},UV=new LV;UV.addParam(0);var WV=class{constructor(e){this._handler=e,this._data=``,this._params=UV,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():UV,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=NP(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=UV,this._data=``,this._hitLimit=!1,e));return this._params=UV,this._data=``,this._hitLimit=!1,t}},GV=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;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},KV=160,qV=function(){let e=new GV(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),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(KV,0,2,0),e.add(KV,8,5,8),e.add(KV,6,0,6),e.add(KV,11,0,11),e.add(KV,13,13,13),e}(),JV=class extends KF{constructor(e=qV){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 LV,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(UF(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new zV),this._dcsParser=this._register(new HV),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;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||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;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:KV)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<KV){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<KV){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<KV){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<KV){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=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(++n<t&&(r=e[n])>47&&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<KV){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<KV){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},YV=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,XV=/^[\da-f]+$/;function ZV(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=YV.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),XV.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function QV(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 $V(e,t=16){let[n,r,i]=e;return`rgb:${QV(n,t)}/${QV(r,t)}/${QV(i,t)}`}var eH={"(":0,")":1,"*":2,"+":3,"-":1,".":2},tH=131072,nH=10;function rH(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 iH=5e3,aH=0,oH=class extends KF{constructor(e,t,n,r,i,a,o,s,c=new JV){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 PP,this._utf8Decoder=new FP,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=YB.clone(),this._eraseAttrDataInternal=YB.clone(),this._onRequestBell=this._register(new _I),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new _I),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new _I),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new _I),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new _I),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new _I),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new _I),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new _I),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new _I),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new _I),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new _I),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new _I),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new _I),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new sH(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($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(XR.IND,()=>this.index()),this._parser.setExecuteHandler(XR.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(XR.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new BV(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new BV(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new BV(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new BV(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new BV(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new BV(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new BV(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new BV(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new BV(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new BV(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new BV(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new BV(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 oV)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 WV((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`),iH))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${iH} 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>tH&&(a=this._parseStack.position+tH)}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.length<e.length&&this._parseBuffer.length<tH&&(this._parseBuffer=new Uint32Array(Math.min(e.length,tH))),o||this._dirtyRowTracker.clearRange(),e.length>tH)for(let t=a;t<e.length;t+=tH){let a=t+tH<e.length?t+tH:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&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;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=MV.extractWidth(t);let n=MV.extractShouldJoin(t),m=n?MV.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(MP(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){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 QB&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=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.x<s&&n-t>0&&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=>rH(e.params[0],this._optionsService.rawOptions.windowOptions)?t(e):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new WV(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new BV(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.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=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));break}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);break}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.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(YB));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=MV.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,sV),this._charsetService.setgCharset(1,sV),this._charsetService.setgCharset(2,sV),this._charsetService.setgCharset(3,sV);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(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(`${$.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|=RP.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<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=YB.fg,e.bg=YB.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<t;i++)n=e.params[i],n>=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|=YB.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=YB.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|=YB.fg&16777215,r.bg&=-67108864,r.bg|=YB.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}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=YB.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`;break}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(!rH(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(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>nH&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>nH&&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());break}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(cH(n))if(r===`?`)t.push({type:0,index:n});else{let e=ZV(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()?!1: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<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=ZV(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<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);cH(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,sV),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(eH[e[0]],oV[e[1]]||sV),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),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._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=YB.clone(),this._eraseAttrDataInternal=YB.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 BP;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.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)}},sH=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(aH=e,e=t,t=aH),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};sH=yP([bP(0,qP)],sH);function cH(e){return 0<=e&&e<256}var lH=5e7,uH=12,dH=50,fH=class extends KF{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new _I),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>lH)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>=uH?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>=uH)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>dH&&(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()}},pH=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)))}};pH=yP([bP(0,qP)],pH);var mH=!1,hH=class extends KF{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new qF),this._onBinary=this._register(new _I),this.onBinary=this._onBinary.event,this._onData=this._register(new _I),this.onData=this._onData.event,this._onLineFeed=this._register(new _I),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new _I),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new _I),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new _I),this._instantiationService=new HB,this.optionsService=this._register(new gV(e)),this._instantiationService.setService($P,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(pV)),this._instantiationService.setService(qP,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(GB)),this._instantiationService.setService(QP,this._logService),this.coreService=this._register(this._instantiationService.createInstance(xV)),this._instantiationService.setService(YP,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(EV)),this._instantiationService.setService(JP,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(MV)),this._instantiationService.setService(tF,this.unicodeService),this._charsetService=this._instantiationService.createInstance(NV),this._instantiationService.setService(XP,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(pH),this._instantiationService.setService(eF,this._oscLinkService),this._inputHandler=this._register(new oH(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(rI.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(rI.forward(this._bufferService.onResize,this._onResize)),this._register(rI.forward(this.coreService.onData,this._onData)),this._register(rI.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 fH((e,t)=>this._inputHandler.parse(e,t))),this._register(rI.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new _I),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!mH&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),mH=!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,dV),t=Math.max(t,fV),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(PV.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(PV(this._bufferService),!1))),this._windowsWrappingHeuristics.value=UF(()=>{for(let t of e)t.dispose()})}}},gH={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 _H(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`?t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`D`:t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`C`:t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`A`:t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`B`:t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:a?i.key=$.ESC+`[3;`+(a+1)+`~`:i.key=$.ESC+`[3~`;break;case 36:a?i.key=$.ESC+`[1;`+(a+1)+`H`:t?i.key=$.ESC+`OH`:i.key=$.ESC+`[H`;break;case 35:a?i.key=$.ESC+`[1;`+(a+1)+`F`:t?i.key=$.ESC+`OF`:i.key=$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=$.ESC+`[5;`+(a+1)+`~`:i.key=$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=$.ESC+`[6;`+(a+1)+`~`:i.key=$.ESC+`[6~`;break;case 112:a?i.key=$.ESC+`[1;`+(a+1)+`P`:i.key=$.ESC+`OP`;break;case 113:a?i.key=$.ESC+`[1;`+(a+1)+`Q`:i.key=$.ESC+`OQ`;break;case 114:a?i.key=$.ESC+`[1;`+(a+1)+`R`:i.key=$.ESC+`OR`;break;case 115:a?i.key=$.ESC+`[1;`+(a+1)+`S`:i.key=$.ESC+`OS`;break;case 116:a?i.key=$.ESC+`[15;`+(a+1)+`~`:i.key=$.ESC+`[15~`;break;case 117:a?i.key=$.ESC+`[17;`+(a+1)+`~`:i.key=$.ESC+`[17~`;break;case 118:a?i.key=$.ESC+`[18;`+(a+1)+`~`:i.key=$.ESC+`[18~`;break;case 119:a?i.key=$.ESC+`[19;`+(a+1)+`~`:i.key=$.ESC+`[19~`;break;case 120:a?i.key=$.ESC+`[20;`+(a+1)+`~`:i.key=$.ESC+`[20~`;break;case 121:a?i.key=$.ESC+`[21;`+(a+1)+`~`:i.key=$.ESC+`[21~`;break;case 122:a?i.key=$.ESC+`[23;`+(a+1)+`~`:i.key=$.ESC+`[23~`;break;case 123:a?i.key=$.ESC+`[24;`+(a+1)+`~`:i.key=$.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=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=gH[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.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=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.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=$.US),e.key===`@`&&(i.key=$.NUL));break}return i}var vH=0,yH=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new aB,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new aB,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<r.length;i++)n>=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||(vH=this._search(t),vH===-1)||this._getKey(this._array[vH])!==t)return!1;do if(this._array[vH]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(vH),!0;while(++vH<this._array.length&&this._getKey(this._array[vH])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(vH=this._search(e),!(vH<0||vH>=this._array.length)&&this._getKey(this._array[vH])===e))do yield this._array[vH];while(++vH<this._array.length&&this._getKey(this._array[vH])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(vH=this._search(e),!(vH<0||vH>=this._array.length)&&this._getKey(this._array[vH])===e))do t(this._array[vH]);while(++vH<this._array.length&&this._getKey(this._array[vH])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},bH=0,xH=0,SH=class extends KF{constructor(){super(),this._decorations=new yH(e=>e?.marker.line),this._onDecorationRegistered=this._register(new _I),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new _I),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(UF(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new CH(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<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{bH=t.options.x??0,xH=bH+(t.options.width??1),e>=bH&&e<xH&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},CH=class extends GF{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new _I),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new _I),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=oz.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=oz.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},wH=1e3,TH=class{constructor(e,t=wH){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}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);let r=performance.now();if(r-this._lastRefreshMs>=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)}},EH=20,DH=!1,OH=class extends KF{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;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._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 TH(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);DH?(this._accessibilityContainer.classList.add(`debug`),this._rowContainer.classList.add(`debug`),this._debugRootContainer=i.createElement(`div`),this._debugRootContainer.classList.add(`xterm`),this._debugRootContainer.appendChild(i.createTextNode(`------start a11y------`)),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode(`------end a11y------`)),this._terminal.element.insertAdjacentElement(`afterend`,this._debugRootContainer)):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(`
|
|
141
|
-
`))),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(
|
|
142
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===EH+1&&(this._liveRegion.textContent+=wP.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<i.length?i[t]:i.slice(-1)[0]+1;return a>=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;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)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<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};OH=yP([bP(1,ZP),bP(2,oF),bP(3,cF)],OH);var kH=class extends KF{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new _I),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new _I),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(UF(()=>{VF(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(XL(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(XL(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(XL(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(XL(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<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(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;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?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;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._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&&AH(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,VF(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?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!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}}};kH=yP([bP(1,sF),bP(2,cF),bP(3,qP),bP(4,fF)],kH);function AH(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 jH=class extends hH{constructor(e={}){super(e),this._linkifier=this._register(new qF),this.browser=Hz,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new qF),this._onCursorMove=this._register(new _I),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new _I),this.onKey=this._onKey.event,this._onRender=this._register(new _I),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new _I),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new _I),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new _I),this.onBell=this._onBell.event,this._onFocus=this._register(new _I),this._onBlur=this._register(new _I),this._onA11yCharEmitter=this._register(new _I),this._onA11yTabEmitter=this._register(new _I),this._onWillOpen=this._register(new _I),this._setup(),this._decorationService=this._instantiationService.createInstance(SH),this._instantiationService.setService(nF,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Lz),this._instantiationService.setService(fF,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(rF)),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(rI.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(rI.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(rI.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(rI.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(UF(()=>{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=az.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${$V(r)}${ZR.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=iz.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=iz.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_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(OH,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.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($.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(XL(this.element,`copy`,e=>{this.hasSelection()&&DP(e,this._selectionService)}));let e=e=>OP(e,this.textarea,this.coreService,this.optionsService);this._register(XL(this.textarea,`paste`,e)),this._register(XL(this.element,`paste`,e)),Kz?this._register(XL(this.element,`mousedown`,e=>{e.button===2&&jP(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(XL(this.element,`contextmenu`,e=>{jP(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),eB&&this._register(XL(this.element,`auxclick`,e=>{e.button===1&&AP(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(XL(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(XL(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(XL(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(XL(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(XL(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(XL(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(XL(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(XL(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`,SP.get()),tB||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(Fz,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(oF,this._coreBrowserService),this._register(XL(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(XL(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(jz,this._document,this._helperContainer),this._instantiationService.setService(aF,this._charSizeService),this._themeService=this._instantiationService.createInstance(zB),this._instantiationService.setService(dF,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(fz),this._instantiationService.setService(uF,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(sB,this.rows,this.screenElement)),this._instantiationService.setService(cF,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(QR,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Bz),this._instantiationService.setService(sF,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(kH,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(UR,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(kB,this.element,this.screenElement,r)),this._instantiationService.setService(lF,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(rI.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(WR,this.screenElement)),this._register(XL(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(OH,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(YR,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(YR,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Az,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(XL(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(XL(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=$.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){kP(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=_H(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===$.ETX||n.key===$.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)&&(MH(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<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(YB));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function MH(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var NH=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-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._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},PH=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new BP)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},FH=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 PH(t)}getNullCell(){return new BP}},IH=class extends KF{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new _I),this.onBufferChange=this._onBufferChange.event,this._normal=new FH(this._core.buffers.normal,`normal`),this._alternate=new FH(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)}},LH=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)}},RH=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}},zH=[`cols`,`rows`],BH=0,VH=class extends KF{constructor(e){super(),this._core=this._register(new jH(e)),this._addonManager=this._register(new NH),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(zH.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 LH(this._core),this._parser}get unicode(){return this._checkProposedApi(),new RH(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 IH(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`;break}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
|
|
143
|
-
`,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 SP.get()},set promptLabel(e){SP.set(e)},get tooMuchOutput(){return wP.get()},set tooMuchOutput(e){wP.set(e)}}}_verifyIntegers(...e){for(BH of e)if(BH===1/0||isNaN(BH)||BH%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(BH of e)if(BH&&(BH===1/0||isNaN(BH)||BH%1!=0||BH<0))throw Error(`This API only accepts positive integers`)}},HH=Object.create(null);HH.open=`0`,HH.close=`1`,HH.ping=`2`,HH.pong=`3`,HH.message=`4`,HH.upgrade=`5`,HH.noop=`6`;var UH=Object.create(null);Object.keys(HH).forEach(e=>{UH[HH[e]]=e});var WH={type:`error`,data:`parser error`},GH=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,KH=typeof ArrayBuffer==`function`,qH=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,JH=({type:e,data:t},n,r)=>GH&&t instanceof Blob?n?r(t):YH(t,r):KH&&(t instanceof ArrayBuffer||qH(t))?n?r(t):YH(new Blob([t]),r):r(HH[e]+(t||``)),YH=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function XH(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var ZH;function QH(e,t){if(GH&&e.data instanceof Blob)return e.data.arrayBuffer().then(XH).then(t);if(KH&&(e.data instanceof ArrayBuffer||qH(e.data)))return t(XH(e.data));JH(e,!1,e=>{ZH||=new TextEncoder,t(ZH.encode(e))})}var $H=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,eU=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)eU[$H.charCodeAt(e)]=e;var tU=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=eU[e.charCodeAt(r)],o=eU[e.charCodeAt(r+1)],s=eU[e.charCodeAt(r+2)],c=eU[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},nU=typeof ArrayBuffer==`function`,rU=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:aU(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:iU(e.substring(1),t)}:UH[n]?e.length>1?{type:UH[n],data:e.substring(1)}:{type:UH[n]}:WH},iU=(e,t)=>nU?aU(tU(e),t):{base64:!0,data:e},aU=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},oU=``,sU=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{JH(e,!1,e=>{r[a]=e,++i===n&&t(r.join(oU))})})},cU=(e,t)=>{let n=e.split(oU),r=[];for(let e=0;e<n.length;e++){let i=rU(n[e],t);if(r.push(i),i.type===`error`)break}return r};function lU(){return new TransformStream({transform(e,t){QH(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var uU;function dU(e){return e.reduce((e,t)=>e+t.length,0)}function fU(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function pU(e,t){uU||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(dU(n)<1)break;let e=fU(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(dU(n)<2)break;let e=fU(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(dU(n)<8)break;let e=fU(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(WH);break}i=a*2**32+t.getUint32(4),r=3}else{if(dU(n)<i)break;let e=fU(n,i);s.enqueue(rU(a?e:uU.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(WH);break}}}})}function mU(e){if(e)return hU(e)}function hU(e){for(var t in mU.prototype)e[t]=mU.prototype[t];return e}mU.prototype.on=mU.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},mU.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},mU.prototype.off=mU.prototype.removeListener=mU.prototype.removeAllListeners=mU.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},mU.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},mU.prototype.emitReserved=mU.prototype.emit,mU.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},mU.prototype.hasListeners=function(e){return!!this.listeners(e).length};var gU=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),_U=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),vU=`arraybuffer`;function yU(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var bU=_U.setTimeout,xU=_U.clearTimeout;function SU(e,t){t.useNativeTimers?(e.setTimeoutFn=bU.bind(_U),e.clearTimeoutFn=xU.bind(_U)):(e.setTimeoutFn=_U.setTimeout.bind(_U),e.clearTimeoutFn=_U.clearTimeout.bind(_U))}var CU=1.33;function wU(e){return typeof e==`string`?TU(e):Math.ceil((e.byteLength||e.size)*CU)}function TU(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function EU(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function DU(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function OU(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var kU=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},AU=class extends mU{constructor(e){super(),this.writable=!1,SU(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new kU(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=rU(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=DU(e);return t.length?`?`+t:``}},jU=class extends AU{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){cU(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,sU(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=EU()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},MU=!1;try{MU=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var NU=MU;function PU(){}var FU=class extends jU{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},IU=class e extends mU{constructor(e,t,n){super(),this.createRequest=e,SU(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=yU(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=PU,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(IU.requestsCount=0,IU.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,LU);else if(typeof addEventListener==`function`){let e=`onpagehide`in _U?`pagehide`:`unload`;addEventListener(e,LU,!1)}}function LU(){for(let e in IU.requests)IU.requests.hasOwnProperty(e)&&IU.requests[e].abort()}var RU=(function(){let e=BU({xdomain:!1});return e&&e.responseType!==null})(),zU=class extends FU{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=RU&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new IU(BU,this.uri(),e)}};function BU(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||NU))return new XMLHttpRequest}catch{}if(!t)try{return new _U[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var VU=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,HU=class extends AU{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=VU?{}:yU(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;JH(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&gU(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=EU()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},UU=_U.WebSocket||_U.MozWebSocket,WU={websocket:class extends HU{createSocket(e,t,n){return VU?new UU(e,t,n):t?new UU(e,t):new UU(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends AU{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=pU(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=lU();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&gU(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:zU},GU=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,KU=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function qU(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=GU.exec(e||``),a={},o=14;for(;o--;)a[KU[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=JU(a,a.path),a.queryKey=YU(a,a.query),a}function JU(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function YU(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var XU=typeof addEventListener==`function`&&typeof removeEventListener==`function`,ZU=[];XU&&addEventListener(`offline`,()=>{ZU.forEach(e=>e())},!1);var QU=class e extends mU{constructor(e,t){if(super(),this.binaryType=vU,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=qU(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=qU(t.host).host);SU(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=OU(this.opts.query)),XU&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},ZU.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=wU(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,gU(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),XU&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=ZU.indexOf(this._offlineEventListener);e!==-1&&ZU.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};QU.protocol=4;var $U=class extends QU{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;QU.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;QU.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},eW=class extends $U{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>WU[e]).filter(e=>!!e)),super(e,n)}};eW.protocol;function tW(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=qU(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var nW=typeof ArrayBuffer==`function`,rW=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,iW=Object.prototype.toString,aW=typeof Blob==`function`||typeof Blob<`u`&&iW.call(Blob)===`[object BlobConstructor]`,oW=typeof File==`function`||typeof File<`u`&&iW.call(File)===`[object FileConstructor]`;function sW(e){return nW&&(e instanceof ArrayBuffer||rW(e))||aW&&e instanceof Blob||oW&&e instanceof File}function cW(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(cW(e[t]))return!0;return!1}if(sW(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return cW(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&cW(e[t]))return!0;return!1}function lW(e){let t=[],n=e.data,r=e;return r.data=uW(n,t),r.attachments=t.length,{packet:r,buffers:t}}function uW(e,t){if(!e)return e;if(sW(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=uW(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=uW(e[r],t));return n}return e}function dW(e,t){return e.data=fW(e.data,t),delete e.attachments,e}function fW(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=fW(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=fW(e[n],t));return e}var pW=r({Decoder:()=>_W,Encoder:()=>gW,PacketType:()=>hW,isPacketValid:()=>wW,protocol:()=>5}),mW=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],hW;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(hW||={});var gW=class{constructor(e){this.replacer=e}encode(e){return(e.type===hW.EVENT||e.type===hW.ACK)&&cW(e)?this.encodeAsBinary({type:e.type===hW.EVENT?hW.BINARY_EVENT:hW.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===hW.BINARY_EVENT||e.type===hW.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=lW(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},_W=class e extends mU{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===hW.BINARY_EVENT;n||t.type===hW.BINARY_ACK?(t.type=n?hW.EVENT:hW.ACK,this.reconstructor=new vW(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(sW(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(hW[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===hW.BINARY_EVENT||r.type===hW.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!bW(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case hW.CONNECT:return SW(t);case hW.DISCONNECT:return t===void 0;case hW.CONNECT_ERROR:return typeof t==`string`||SW(t);case hW.EVENT:case hW.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&mW.indexOf(t[0])===-1);case hW.ACK:case hW.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},vW=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=dW(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function yW(e){return typeof e==`string`}var bW=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function xW(e){return e===void 0||bW(e)}function SW(e){return Object.prototype.toString.call(e)===`[object Object]`}function CW(e,t){switch(e){case hW.CONNECT:return t===void 0||SW(t);case hW.DISCONNECT:return t===void 0;case hW.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&mW.indexOf(t[0])===-1);case hW.ACK:return Array.isArray(t);case hW.CONNECT_ERROR:return typeof t==`string`||SW(t);default:return!1}}function wW(e){return yW(e.nsp)&&xW(e.id)&&CW(e.type,e.data)}function TW(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var EW=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),DW=class extends mU{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[TW(e,`open`,this.onopen.bind(this)),TW(e,`packet`,this.onpacket.bind(this)),TW(e,`error`,this.onerror.bind(this)),TW(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(EW.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:hW.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:hW.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case hW.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case hW.EVENT:case hW.BINARY_EVENT:this.onevent(e);break;case hW.ACK:case hW.BINARY_ACK:this.onack(e);break;case hW.DISCONNECT:this.ondisconnect();break;case hW.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:hW.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:hW.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function OW(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}OW.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},OW.prototype.reset=function(){this.attempts=0},OW.prototype.setMin=function(e){this.ms=e},OW.prototype.setMax=function(e){this.max=e},OW.prototype.setJitter=function(e){this.jitter=e};var kW=class extends mU{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,SU(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new OW({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||pW;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new eW(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=TW(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=TW(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(TW(e,`ping`,this.onping.bind(this)),TW(e,`data`,this.ondata.bind(this)),TW(e,`error`,this.onerror.bind(this)),TW(e,`close`,this.onclose.bind(this)),TW(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){gU(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new DW(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},AW={};function jW(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=tW(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=AW[i]&&a in AW[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new kW(r,t):(AW[i]||(AW[i]=new kW(r,t)),c=AW[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(jW,{Manager:kW,Socket:DW,io:jW,connect:jW});var MW=((e=Te)=>jW(e))(),NW=({label:e,onClick:t,children:n})=>(0,Z.jsx)(K,{type:`button`,"aria-label":e,onClick:t,variant:`outline`,size:`icon-sm`,className:`bg-secondary/60`,children:n}),PW=({exitCode:e,signal:t})=>t>0?`[archon] Shell exited with signal ${t}`:`[archon] Shell exited with code ${e}`,FW=({createSession:e,isExpanded:t,isVisible:n,onClose:r,onToggleExpanded:i,className:a=``,ariaLabel:o=`Terminal`,title:s=`Terminal`,closeLabel:c=`Close terminal`,headerMeta:l})=>{let u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=(0,Y.useRef)(e),h=(0,Y.useRef)(!1),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!0);return(0,Y.useEffect)(()=>{m.current=e},[e]),(0,Y.useEffect)(()=>{if(!u.current)return;let e=new VH({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,fontSize:13,theme:{background:`#0b0d14`,foreground:`#d8deef`,cursor:`#c4b5fd`}}),t=new hP,n=null,r=!1;e.loadAddon(t),e.open(u.current),d.current=e,f.current=t;let i=()=>{let e=p.current;!e||h.current||(h.current=!0,ST(e))};window.addEventListener(`pagehide`,i),window.addEventListener(`beforeunload`,i);let a=()=>{p.current&&MW.emit(`terminal:resize`,{sessionId:p.current,cols:e.cols,rows:e.rows})},o=()=>{!u.current||r||(t.fit(),a())},s=t=>{t.sessionId===p.current&&(y(!1),window.setTimeout(()=>{o(),e.focus()},0))},c=t=>{t.sessionId===p.current&&(y(!1),e.write(t.data))},l=t=>{t.sessionId===p.current&&(e.writeln(``),e.writeln(PW(t)))},g=t=>{t.sessionId&&t.sessionId!==p.current||(y(!1),_(t.message),e.writeln(``),e.writeln(`[archon] ${t.message}`))};MW.on(`terminal:ready`,s),MW.on(`terminal:data`,c),MW.on(`terminal:exit`,l),MW.on(`terminal:error`,g);let v=e.onData(e=>{p.current&&MW.emit(`terminal:input`,{sessionId:p.current,input:e})});return typeof ResizeObserver==`function`&&(n=new ResizeObserver(()=>{o()}),n.observe(u.current)),window.setTimeout(()=>{o()},0),m.current().then(e=>{r||(p.current=e.session_id,MW.emit(`terminal:join`,{sessionId:e.session_id}))}).catch(t=>{if(r)return;y(!1);let n=t instanceof Error?t.message:`Unable to open the terminal right now.`;_(n),e.writeln(``),e.writeln(`[archon] ${n}`)}),()=>{r=!0,window.removeEventListener(`pagehide`,i),window.removeEventListener(`beforeunload`,i),p.current&&(h.current||MW.emit(`terminal:destroy`,{sessionId:p.current})),n?.disconnect(),v.dispose(),MW.off(`terminal:ready`,s),MW.off(`terminal:data`,c),MW.off(`terminal:exit`,l),MW.off(`terminal:error`,g),e.dispose(),d.current=null,f.current=null,p.current=null}},[]),(0,Y.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{f.current?.fit(),d.current&&p.current&&(MW.emit(`terminal:resize`,{sessionId:p.current,cols:d.current.cols,rows:d.current.rows}),d.current.focus())},0);return()=>{window.clearTimeout(e)}},[t,n]),(0,Z.jsxs)(mu,{"aria-label":o,"data-terminal-pane":`true`,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden rounded-xl border-border bg-[#0c1119] ${a}`.trim(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border bg-card/80 px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,Z.jsx)(Pc,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),l&&(0,Z.jsx)(`div`,{className:`mt-1 min-w-0 text-xs text-muted-foreground`,children:l})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v&&!g&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Opening terminal...`}),g&&(0,Z.jsx)(`span`,{className:`max-w-56 truncate text-xs text-red-300`,children:g}),(0,Z.jsx)(NW,{label:t?`Collapse terminal`:`Expand terminal`,onClick:i,children:t?(0,Z.jsx)(gf,{className:`h-4 w-4`}):(0,Z.jsx)(_f,{className:`h-4 w-4`})}),(0,Z.jsx)(NW,{label:c,onClick:r,children:(0,Z.jsx)(Be,{className:`h-4 w-4`})})]})]}),(0,Z.jsx)(`div`,{ref:u,"data-testid":`terminal-viewport`,onClick:()=>d.current?.focus(),className:`min-h-0 flex-1 overflow-hidden bg-[#0b0d14] pb-4`})]})},IW=({actions:e,activeAction:t=null,disableWhenActive:n=!1,className:r,heading:i,headingClassName:a,actionsClassName:o,showDisabledReason:s=!1,disabledReasonClassName:c,error:l,errorClassName:u,leadingContent:d,renderAction:f})=>{if(e.length===0&&!d)return null;let p=e.find(e=>e.disabled&&e.disabledReason)?.disabledReason??null;return(0,Z.jsxs)(`div`,{className:r,children:[i&&(0,Z.jsx)(`div`,{className:a,children:i}),(0,Z.jsxs)(`div`,{className:o,children:[d,e.map(e=>{let r=t===e.id,i=e.disabled||n&&t!==null;return f({action:e,label:r?e.pendingLabel:e.label,disabled:i,title:e.disabledReason??e.title,ariaLabel:e.ariaLabel})})]}),s&&p&&(0,Z.jsx)(`p`,{className:c,children:p}),l&&(0,Z.jsx)(`p`,{className:u,children:l})]})},LW=({id:e,label:t,pendingLabel:n,ariaLabel:r=t,title:i,disabled:a=!1,disabledReason:o=null})=>({id:e,label:t,pendingLabel:n,ariaLabel:r,title:i,disabled:a,disabledReason:o}),RW=(e,t={})=>{let{isEditing:n=!1,includePlanAdvance:r=!0,hideAdvanceWhenBlocked:i=!1,hasOpenBlockers:a=!1,canRun:o=!0,canStopRun:s=!0,canPauseBuild:c=!0,canResumeBuild:l=!0,runDisabled:u=!1,runDisabledReason:d,buildLabel:f=`Build`,reviewLabel:p=`Review`}=t,m=Sw(e.state),h=m?Nw(e,m):!1,g=Pw(e),_=e.bundle?.branch??e.branch,v=e.has_worktree??!!_,y=e.worktree_bundle_id!==null,b=e.state===`plan`&&e.agent_status===`running`,x=d??(e.has_run_config===!1?`No run config is available for this project.`:null),S=[];return r&&e.state===`plan`&&!e.parked_at&&S.push(LW({id:`build`,label:f,pendingLabel:`Building...`,ariaLabel:f,disabled:!h,disabledReason:g})),e.state===`build`&&!e.parked_at&&!(i&&a)&&S.push(LW({id:`review`,label:p,pendingLabel:`Starting review...`,ariaLabel:p,disabled:!h,disabledReason:g})),_&&v&&!b&&!n&&!y&&e.is_running!==!0&&o&&S.push(LW({id:`run`,label:`Run`,pendingLabel:`Starting run...`,ariaLabel:`Run`,disabled:u||!!x,disabledReason:x,title:u?x??`Stop the currently running ticket before starting another run.`:void 0})),_&&!n&&!y&&e.is_running===!0&&s&&S.push(LW({id:`stop-run`,label:`Stop Run`,pendingLabel:`Stopping run...`,ariaLabel:`Stop Run`,title:`Stop the currently running ticket.`,disabled:!1,disabledReason:null})),!n&&Tw(e)&&e.agent_status===`running`&&e.session_id&&c&&S.push(LW({id:`pause-build`,label:`Pause Build`,pendingLabel:`Pausing build...`,ariaLabel:`Pause Build`,title:`Pause the build session. You can resume it later.`,disabled:!1,disabledReason:null})),!n&&Tw(e)&&e.agent_status===`stopped`&&e.session_id&&l&&S.push(LW({id:`resume-build`,label:`Resume`,pendingLabel:`Resuming build...`,ariaLabel:`Resume`,disabled:!1,disabledReason:null})),S},zW=(e,t={})=>{let n=e.state===`plan`,r=e.bundle?.branch??e.branch,i=e.has_worktree??!!r;return{isPlan:n,hasWorktree:i,disabledReason:e.agent_status===`running`?n?`Wait for planning to finish before sending another message.`:`Wait for the current build to finish before sending a follow-up prompt.`:t.requireWorktree===!0&&!n&&!i?`Worktree not ready yet.`:null,heading:n?`Planning follow-up`:`Ticket follow-up`,description:n?`Ask the agent to refine this plan.`:`Send a follow-up prompt for this ticket.`,placeholder:n?`Ask the agent to refine this plan...`:`Send a follow-up for this ticket...`}},BW=(e,t,n={})=>{let r=e.tool===`opencode`||n.persistPlanSettings===!0,i=r&&t.model?t.model:null,a=r&&t.model&&t.variant?t.variant:null,o=r?t.skills:[],s=e.skills??[],c=o.length!==s.length||o.some((e,t)=>e!==s[t]);return{model:i,variant:a,skills:o,shouldPersist:r&&(i!==e.model||a!==e.variant||c)}},VW=`modulepreload`,HW=function(e){return`/`+e},UW={},WW=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=HW(t,n),t in UW)return;UW[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:VW,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},GW=(0,Y.lazy)(()=>WW(()=>Promise.resolve().then(()=>nJ).then(e=>({default:e.TicketChangesModal})),void 0)),KW=(0,Y.lazy)(()=>WW(()=>import(`./TestsDialog-BtSHirWO.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),qW=`(min-width: 1280px)`,JW=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches,YW=e=>{let[t,n]=(0,Y.useState)(()=>JW(e));return(0,Y.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>{n(t.matches)};return r(),t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}},[e]),t},XW=({onClose:e})=>{let{t}=X(`common`);return(0,Z.jsx)(du,{onClose:e,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-full w-full max-w-none items-center justify-center rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:t(`ticketModal.loadingDiff`)})})},ZW=({ariaLabel:e,title:t,closeAriaLabel:n,className:r,showTopSpacer:i=!0,description:a,onClose:o,...s})=>(0,Z.jsxs)(`aside`,{className:`min-h-0 flex flex-col gap-3 overflow-hidden${r?` ${r}`:``}`,"aria-label":e,children:[i?(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`h-9 shrink-0`}):null,(0,Z.jsx)(NN,{...s,header:({showThinkingControl:e})=>(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:t}),e]}),a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:a}):null]}),(0,Z.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n,onClick:o,children:(0,Z.jsx)(Be,{className:`h-4 w-4`})})]})})]}),QW=(e,t)=>e?t.find(t=>t.id===e)?.label??e:null,$W=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectTestCommands:i=[],showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],projectBranchState:c=null,projectMemoryEnabled:l=!1,runDisabled:u=!1,runDisabledReason:d,onClose:f,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onUpdate:g,onDeleteDependency:_,onAdvance:v,onBuildChain:y,onRun:b,onOpenIde:x,onStop:S,onStopBuild:C,onStopBuildChain:w,onResumeBuild:T,onFollowUp:E,onRequestTicketRefresh:D,onProjectMemorySuggestionsChanged:O})=>{let{t:k}=X(`common`),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)(!1),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,ee]=(0,Y.useState)(!1),[te,ne]=(0,Y.useState)(!1),[V,re]=(0,Y.useState)(``),[H,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(0),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(!1),[he,ge]=(0,Y.useState)(null),W=A??e,[_e,ve]=(0,Y.useState)(W.model??``),[ye,be]=(0,Y.useState)(W.variant??``),[G,xe]=(0,Y.useState)(W.skills??[]),[Se,Ce]=(0,Y.useState)(()=>QW(W.model,o)??`Agent`),we=(0,Y.useRef)(W.id),Te=(0,Y.useRef)(null),Ee=(0,Y.useRef)(null),De=(0,Y.useRef)(!1),Oe=(0,Y.useRef)(W.id),ke=(0,Y.useRef)(W.build_completed_at),Ae=YW(qW),[je,Me]=(0,Y.useState)(!1),[Ne,Pe]=(0,Y.useState)({model:W.model,variant:W.variant,skills:W.skills??[]}),Fe=W.state===`plan`,Ie=Cw(W.state),Le=W.worktree_bundle_id!==null,Re=Fe&&W.agent_status===`running`,ze=Fe&&W.agent_status===`error`,Be=Fe&&!Re||M,Ve=async e=>{let t=await Yt(W.id,W.project_id,e);return j(t),g?.(t),h&&await h(),t},He=async e=>{try{await Ve(e),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Ue=async e=>{try{if(await Ve(e),!v){f();return}await v(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},We=async()=>{!v||it?.disabled||(await v(),f())},Ge=e=>{if(e===`review`){We();return}if(e===`run`){b?.();return}if(e===`stop-run`){S?.();return}if(e===`pause-build`){C?.();return}e===`resume-build`&&T?.()},Ke=async e=>{try{if(await Ve(e),!y){f();return}await y(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},qe=Fe?W.planning_session_id:W.session_id,Je=qe?qe.startsWith(`ses_`)?`opencode --session ${qe}`:`claude --resume ${qe}`:null,Ye=W.bundle?.branch??W.branch,Xe=W.has_worktree??!!Ye,Ze=`Stop Build Chain`,Qe=new Map(t.map(e=>[e.id,e])),$e=n.filter(e=>e.blocker_ticket_id===W.id),et=n.filter(e=>e.dependent_ticket_id===W.id),q=Qw(W,Qe,n),J=q.pendingBuildChainOrder.length>0?`Will build in order: ${q.pendingBuildChainOrder.map(e=>e.title).join(` -> `)}`:`All tickets in this chain have already finished build.`,tt=q.skippedBuildChainCount>0?`Skips ${q.skippedBuildChainCount} ticket${q.skippedBuildChainCount===1?``:`s`} that already finished build.`:null,nt=q.hasOpenBlockers,rt=RW(W,{isEditing:Be,includePlanAdvance:!1,hideAdvanceWhenBlocked:!0,hasOpenBlockers:nt,canRun:!!b,canStopRun:!!S,canPauseBuild:!!C,canResumeBuild:!!T,runDisabled:u,runDisabledReason:d,reviewLabel:`Review Bundle`}),it=rt.find(e=>e.id===`review`)??null,at=Ow(W),ot=W.build_chain?.active_ticket_id?`Currently building ${Qe.get(W.build_chain.active_ticket_id)?.title??`Unknown ticket`}.`:`Build chain is active.`,st=W.build_chain&&W.build_chain.queued_ticket_ids.length>0?`Queued next: ${W.build_chain.queued_ticket_ids.map(e=>Qe.get(e)?.title??`Unknown ticket`).join(` -> `)}`:`No additional tickets are queued after the current build.`,ct=Fe&&!!v&&!q.hasOpenBlockers,lt=Fe&&!!y&&q.canStartBuildChain,ut=!!W.project_id&&!Fe&&!Le,dt=Fe,ft=Le&&!Fe,pt=!!W.project_id&&!!Ye&&Xe&&!Be&&!Re&&!Le,mt=!!W.project_id&&Xe&&!Be&&!Re&&!!x&&!Le,ht=!!W.project_id&&i.length>0&&Xe,gt=ut&&!R,_t=k(`workspaceControls.openTerminalAriaLabel`),vt=ut&&te,yt=V.trim(),bt=!Be&&!Re&&W.state!==`plan`&&Xe&&!!E,xt=dt&&ae,St=ft&&se,Ct=(W.planning_context?.open_questions.length??0)>0,wt=bt&&a&&W.tool===`opencode`,Tt=k(`ticketModal.discardUnsavedDescription`),Et=o.find(e=>e.id===_e)??null,Dt=W.agent_status===`running`,Ot=cT(W,{allTickets:t,preferBundleReviewStatus:!0}),kt=W.skills??[],At=zW(W),jt=Dt?At.disabledReason??void 0:void 0,Mt=Re?At.disabledReason??void 0:void 0,Nt=[...Re?[]:[{label:`Worktree`,value:Ye??``}],{label:`Session`,value:Je??``},...Re?[{label:W.bundle?.kind===`project_root`?`Project root branch`:`Bundle`,value:(W.bundle?.kind,W.bundle?Tl(W.bundle):``)}]:Fe?[{label:`Bundle`,value:W.bundle?Tl(W.bundle):``},{label:`Model`,value:W.model??``},{label:`Variant`,value:W.variant??``},{label:`Skills`,value:kt.length>0?`${kt.length} skill${kt.length===1?``:`s`}`:``},{label:`Initiative`,value:W.planning_context?.initiative_prompt??``}]:[]],Pt=Re?{model:W.model??``,variant:W.variant??``,skills:kt}:null,Ft=dt&&ae,It=ft&&se,Lt=(Ft||It)&&!Ae,Rt=Ft&&!Lt,zt=Rt||It&&!Lt,Bt=Fe&&(Ft||!Ae),Vt=R?`flex h-[92vh] w-[96vw] max-w-7xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:zt?`flex h-[92vh] w-[98vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Lt?`flex h-[92vh] w-[98vw] max-w-6xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-6xl flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,Ht=R&&!B?`grid min-h-0 flex-1 grid-cols-1 gap-3 lg:grid-cols-2`:zt?`grid min-h-0 flex-1 grid-cols-1 gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(30rem,1fr)]`:`flex min-h-0 flex-1 flex-col`,Ut=()=>{ne(!0),z(e=>(e&&ee(!1),!e))},Wt=()=>{z(!1),ee(!1),ne(!1),D?.(W.id)},Gt=()=>{me(!1),ge(null)},Kt=()=>{me(!1),he===`cancel_edit`&&!Fe?N(!1):f(),ge(null)},qt=()=>{if(!Be){f();return}if(!de){f();return}ge(`close_modal`),me(!0)},Jt=()=>{if(Fe){qt();return}if(!de){N(!1);return}ge(`cancel_edit`),me(!0)};(0,Y.useEffect)(()=>{j(t=>!t||t.id!==e.id||e.updated_at>=t.updated_at?null:t)},[e]),(0,Y.useEffect)(()=>{if(Oe.current!==W.id){Oe.current=W.id,ke.current=W.build_completed_at;return}if(ke.current===W.build_completed_at)return;let e=ke.current;ke.current=W.build_completed_at,W.build_completed_at&&W.build_completed_at!==e&&ue(e=>e+1)},[W.build_completed_at,W.id]),(0,Y.useEffect)(()=>{ve(W.model??``),be(W.variant??``),xe(W.skills??[])},[W.model,W.skills,W.variant]),(0,Y.useEffect)(()=>{we.current!==W.id&&(we.current=W.id,Ce(QW(W.model,o)??`Agent`))},[o,W.id,W.model]),(0,Y.useEffect)(()=>{let e=QW(W.model,o);e&&Ce(e)},[o,W.model]),(0,Y.useEffect)(()=>{Pe({model:W.model,variant:W.variant,skills:W.skills??[]})},[W.id,W.model,W.skills,W.variant]),(0,Y.useEffect)(()=>{Be||(fe(!1),me(!1),ge(null))},[Be]),(0,Y.useEffect)(()=>{de||(me(!1),ge(null))},[de]),(0,Y.useEffect)(()=>{if(!Fe){Te.current=null,De.current=!1;return}let e=Te.current!==W.id,t=!De.current&&Ct;(e&&Ct||t)&&oe(!0),Te.current=W.id,De.current=Ct},[Ct,Fe,W.id]),(0,Y.useEffect)(()=>{if(!ft){Ee.current=null;return}Ee.current!==W.id&&ce(!1),Ee.current=W.id},[ft,W.id]);let Xt=async(e,t,n)=>{Me(!0);try{let r=await Yt(W.id,W.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});j(r),g?.(r)}catch(e){ve(W.model??``),be(W.variant??``),xe(W.skills??[]),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{Me(!1)}},Zt=e=>{let t=(o.find(t=>t.id===e)??null)?.variants.includes(ye)?ye:``;ve(e),be(t),Xt(e,t,G)},Qt=e=>{be(e),Xt(_e,e,G)},$t=e=>{xe(e),Xt(_e,ye,e)},en=async()=>{if(!(!E||H||Dt||!yt)){ie(!0);try{await E(yt),re(``)}finally{ie(!1)}}},tn=async()=>{if(!(H||Re||!yt||!xt)){ie(!0);try{let e=BW(W,Ne,{persistPlanSettings:!0});if(e.shouldPersist){let t=await Yt(W.id,W.project_id,{model:e.model,variant:e.variant,skills:e.skills});j(t),g?.(t)}let t=await bn(W.id,W.project_id,yt);j(t),g?.(t),re(``)}finally{ie(!1)}}},nn=(W.messages??[]).filter(MT).map(e=>e.role===`assistant`?{...e,displayTitle:Se}:e.kind===`follow_up`?{...e,displayTitle:k(`chatView.user.you`)}:e),rn=(W.messages??[]).filter(e=>(e.kind===`planning_follow_up`||e.kind===`planning_response`)&&MT(e)).map(e=>e.role===`assistant`?{...e,displayTitle:Se}:e.kind===`planning_follow_up`?{...e,displayTitle:k(`chatView.user.you`)}:e),an=Ft?(0,Z.jsx)(ZW,{ariaLabel:k(`ticketModal.planningChatAriaLabel`),title:k(`ticketModal.planningChatTitle`),closeAriaLabel:k(`ticketModal.closePlanningChatAriaLabel`),className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,description:Ct?(0,Z.jsx)(`p`,{children:k(`ticketModal.planningOpenQuestions`,{count:W.planning_context?.open_questions.length??0})}):void 0,projectId:W.project_id,followUpTicketId:null,messages:rn,internalLog:W.agent_log??null,currentThinkingMessageId:W.agent_message_id??null,previousThinkingLog:W.previous_agent_log??null,previousThinkingMessageId:W.previous_agent_message_id??null,streamingResponse:W.streaming_response??null,isRunning:W.agent_status===`running`,canShowComposer:xt,pendingAgentTitle:Se,composerTheme:Ie,followUpPlaceholder:k(`ticketModal.planningFollowUpPlaceholder`),emptyStateText:null,autoFocusComposer:ae,followUpPrompt:V,isSendingFollowUp:H,followUpDisabledReason:Mt,onFollowUpPromptChange:re,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Re||H||(e.preventDefault(),tn())},onFollowUpSubmit:()=>{tn()},onClose:()=>{oe(!1)}}):It?(0,Z.jsx)(ZW,{ariaLabel:k(`ticketModal.ticketChatAriaLabel`),title:k(`ticketModal.ticketChatTitle`),closeAriaLabel:k(`ticketModal.closeTicketChatAriaLabel`),className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,projectId:W.project_id,followUpTicketId:W.id,messages:nn,internalLog:W.agent_log??null,currentThinkingMessageId:W.agent_message_id??null,previousThinkingLog:W.previous_agent_log??null,previousThinkingMessageId:W.previous_agent_message_id??null,streamingResponse:W.streaming_response??null,isRunning:W.agent_status===`running`,canShowComposer:St,pendingAgentTitle:Se,composerTheme:Ie,autoFocusComposer:se,followUpPrompt:V,isSendingFollowUp:H,followUpDisabledReason:jt,followUpComposerControls:wt?(0,Z.jsx)(fP,{model:_e,variant:ye,skills:G,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Et,onModelChange:Zt,onVariantChange:Qt,onSkillsChange:$t,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:je}):void 0,onFollowUpPromptChange:re,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Dt||H||(e.preventDefault(),en())},onFollowUpSubmit:()=>{en()},onClose:()=>{ce(!1)}}):null;return(0,Z.jsx)(du,{onClose:qt,overlayClassName:`bg-black/60`,panelClassName:Vt,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:[pt&&W.diff_stats&&(0,Z.jsx)(Dc,{stats:W.diff_stats,showFiles:!0,className:`text-xs`}),pt&&(0,Z.jsxs)(K,{type:`button`,"aria-label":k(`workspaceControls.changes`),onClick:()=>{D?.(W.id),F(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(kc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.changes`)})]}),ht&&(0,Z.jsxs)(K,{type:`button`,"aria-label":k(`workspaceControls.tests`),onClick:()=>{L(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Oc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.tests`)})]}),mt&&(0,Z.jsxs)(K,{type:`button`,"aria-label":k(`workspaceControls.openIde`),onClick:()=>{x?.()},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ac,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.openIde`)})]}),gt&&(0,Z.jsxs)(K,{type:`button`,"aria-label":_t,"aria-pressed":R,onClick:Ut,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Pc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.terminal`)})]}),(dt||ft)&&(0,Z.jsxs)(K,{type:`button`,"aria-label":k(`workspaceControls.chat`),"aria-pressed":Fe?ae:se,onClick:()=>{if(Fe){oe(e=>!e);return}ce(e=>!e)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(em,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.chat`)})]}),e]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-modal-layout`,"data-terminal-mode":R?B?`expanded`:`split`:`closed`,"data-side-chat-mode":zt?`inline`:Lt?`overlay`:`closed`,className:Ht,children:[(0,Z.jsxs)(`div`,{className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[Be?(0,Z.jsxs)(Z.Fragment,{children:[ze&&W.agent_log&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-red-500/40 bg-destructive/15 px-3 py-2 text-xs text-red-300`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:k(`ticketModal.planningFailedPrefix`)}),W.agent_log]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(TT,{tool:W.tool,className:`text-[11px]`})}),(0,Z.jsx)(ET,{externalSource:W.external_source}),(0,Z.jsx)(JN,{heading:`Edit Ticket`,bundles:r,initialTitle:W.title,initialDescription:W.description??``,initialModel:W.model??``,initialVariant:W.variant??``,initialSkills:W.skills??[],initialWorktreeBundleId:W.worktree_bundle_id,projectBranchState:c,projectId:W.project_id,stackConfigurationSections:Rt&&!Bt,preferWideBundleSelector:Rt&&Bt,agentSettingsPresentation:Bt?`popover`:`panel`,showModelSelector:a,availableModels:o,availableSkills:s,onAgentSettingsChange:Pe,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onCancel:Jt,onDirtyChange:fe,titleInputId:`edit-title`,descriptionInputId:`edit-description`,bundleSelectId:`edit-ticket-bundle`,modelSelectId:`edit-model`,variantSelectId:`edit-variant`,skillsSelectId:`edit-skills`,showEmptyBundleOption:!1,planAction:{label:`Plan`,onClick:async({title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a})=>{let o=await Yt(W.id,W.project_id,{title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a});g?.(o),f(),await xn(W.id,W.project_id)}},primaryAction:{label:`Save`,variant:ct?`subtle`:`brand`,onClick:He},secondaryAction:ct?{label:`Save & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:Ue}:void 0,tertiaryAction:lt?{label:`Save & Build Chain`,variant:`brand`,showAdvanceIcon:!0,onClick:Ke}:void 0,beforeActionsContent:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(aP,{projectId:W.project_id,ticketId:W.id,memoryEnabled:l,refreshKey:le,onSuggestionsChanged:O}),q.hasDependents&&(0,Z.jsx)(NT,{summary:J,detail:tt}),(0,Z.jsx)(IN,{blocks:$e,blockedBy:et,resolveTicket:e=>Qe.get(e),onDeleteDependency:_})]}),footerLeadingContent:de?(0,Z.jsx)(U,{variant:`outline`,className:`border-amber-500/35 bg-amber-500/10 text-amber-200`,children:`Unsaved changes`}):null},`${W.id}:${W.updated_at}:${W.title}:${W.description}`)]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`sticky top-0 -my-1 bg-card py-1 pr-12 sm:pr-24`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:W.title}),(0,Z.jsx)(TT,{tool:W.tool,className:`text-[11px]`}),(Ot===`building`||Ot===`done`)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[W.is_running&&(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(iT,{status:Ot,showBuildGlyph:!0})]}),Ot!==null&&Ot!==`building`&&Ot!==`done`&&(0,Z.jsx)(iT,{status:Ot,showBuildGlyph:!0}),Ct&&(0,Z.jsx)(U,{variant:`warning`,children:k(`ticketModal.openQuestionsBadge`)}),at&&(0,Z.jsx)(U,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]})}),Le?(0,Z.jsx)(`div`,{className:`mt-3 min-h-0 flex flex-1 flex-col`,children:(0,Z.jsx)(oP,{content:W.description,externalSource:W.external_source})}):(0,Z.jsx)(Z.Fragment,{children:Fe?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 flex flex-col${Re?` mt-3`:``}`,children:(0,Z.jsx)(oP,{content:W.description,externalSource:W.external_source})}):(0,Z.jsx)(NN,{projectId:W.project_id,followUpTicketId:W.id,messages:nn,internalLog:W.agent_log??null,currentThinkingMessageId:W.agent_message_id??null,previousThinkingLog:W.previous_agent_log??null,previousThinkingMessageId:W.previous_agent_message_id??null,streamingResponse:W.streaming_response??null,isRunning:W.agent_status===`running`,canShowComposer:bt,pendingAgentTitle:Se,composerTheme:Ie,followUpComposerControls:wt?(0,Z.jsx)(fP,{model:_e,variant:ye,skills:G,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Et,onModelChange:Zt,onVariantChange:Qt,onSkillsChange:$t,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:je}):void 0,followUpPrompt:V,isSendingFollowUp:H,followUpDisabledReason:jt,onFollowUpPromptChange:re,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Dt||H||(e.preventDefault(),en())},onFollowUpSubmit:()=>{en()}})}),Re&&(0,Z.jsxs)(`section`,{"aria-label":k(`workspaceControls.ticketMetadataAriaLabel`),className:`flex flex-wrap items-center gap-2`,children:[Nt.filter(e=>e.value.trim().length>0).map(e=>(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,Z.jsx)(OT,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`)),(0,Z.jsx)(`div`,{className:`min-w-0 sm:flex-none`,children:(0,Z.jsx)(CT,{model:Pt.model,variant:Pt.variant,skills:Pt.skills})})]}),!Re&&!zt&&(0,Z.jsx)(kT,{ariaLabel:k(`workspaceControls.ticketMetadataAriaLabel`),items:Nt}),(0,Z.jsx)(aP,{projectId:W.project_id,ticketId:W.id,memoryEnabled:l,refreshKey:le,onSuggestionsChanged:O}),(0,Z.jsx)(IN,{blocks:$e,blockedBy:et,resolveTicket:e=>Qe.get(e),onDeleteDependency:_}),W.build_chain&&(0,Z.jsx)(NT,{summary:ot,detail:st})]}),!Be&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,onClick:f,variant:`ghost`,children:k(`workspaceControls.close`)}),W.build_chain&&w&&(0,Z.jsxs)(K,{type:`button`,onClick:()=>{w()},title:`Stop scheduling the remaining tickets in this build chain.`,"aria-label":Ze,variant:`destructive`,children:[(0,Z.jsx)(Nc,{className:`w-3.5 h-3.5`}),Ze]}),(0,Z.jsx)(IW,{actions:rt,actionsClassName:`contents`,renderAction:({action:e,label:t,disabled:n,title:r,ariaLabel:i})=>{let a=e.id===`review`?(0,Z.jsx)(yw,{className:`w-3.5 h-3.5`}):e.id===`run`||e.id===`resume-build`?(0,Z.jsx)(jc,{className:`w-3.5 h-3.5`}):(0,Z.jsx)(Nc,{className:`w-3.5 h-3.5`});return(0,Z.jsxs)(K,{type:`button`,disabled:n,title:r,"aria-label":i,variant:e.id===`stop-run`?`destructive`:e.id===`pause-build`||e.id===`resume-build`?`warning`:e.id===`run`?`secondary`:`default`,className:e.id===`run`?`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`:e.id===`resume-build`?`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`:void 0,onClick:()=>Ge(e.id),children:[e.id===`review`?t:a,e.id===`review`?a:t]},e.id)}})]})]})]}),zt&&an,vt&&(0,Z.jsx)(`div`,{className:R?B?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`mt-12 min-h-0 flex flex-1 flex-col overflow-hidden`:`hidden`,children:(0,Z.jsx)(FW,{createSession:()=>bT(W.id,W.project_id),isExpanded:B,isVisible:R,ariaLabel:k(`ticketModal.ticketTerminalAriaLabel`),className:B?`h-full w-full max-w-none rounded-2xl shadow-2xl`:void 0,onClose:Wt,onToggleExpanded:()=>{ee(e=>!e)}})})]}),Lt&&an,P&&(0,Z.jsx)(Y.Suspense,{fallback:(0,Z.jsx)(XW,{onClose:()=>{F(!1),D?.(W.id)}}),children:(0,Z.jsx)(GW,{ticketId:W.id,projectId:W.project_id,title:W.title,onTicketUpdate:g,onRequestTicketRefresh:D,onSubmitReviewPrompt:E,canSubmitReviewPrompt:!Dt,reviewSubmitDisabledReason:jt,onClose:()=>{F(!1),D?.(W.id)}})}),I&&ht&&W.project_id&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(KW,{scope:`ticket`,ticketId:W.id,projectId:W.project_id,testCommands:i,onClose:()=>{L(!1)}})}),pe&&(0,Z.jsx)(fu,{title:k(`ticketModal.discardUnsavedTitle`),description:Tt,confirmLabel:k(`ticketModal.discardUnsavedConfirm`),cancelLabel:k(`ticketModal.discardUnsavedCancel`),confirmVariant:`destructive`,onConfirm:Kt,onCancel:Gt})]})})},eG=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectMemoryEnabled:i=!1,overlay:a=!1,showModelSelector:o,availableModels:s,runDisabled:c=!1,runDisabledReason:l,dependencyTargetState:u=`idle`,onDependencyStart:d,onDeleteDependency:f,onRegisterNode:p,onRegisterOverlayNode:m,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onDelete:y,onUndo:b,onRetry:x,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:E,onOpenTests:D,onOpenChanges:O,onOpenIde:k,onAddTicketToBundle:A,onStop:j,onStopBuild:M,onStopBuildChain:N,onResumeBuild:P,onFollowUp:F,onOpenBundleDetails:I,onOpenTicketDetails:L,preferBundleDetailsOnClick:R=!1,hideBundleScopedControls:z=!1,hideStatusBadge:B=!1,onRequestTicketRefresh:ee,undoInProgress:te=!1})=>{let{t:ne}=X(`common`),[V,re]=(0,Y.useState)(!1),[H,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(!1),he=e.agent_status===`running`||te,ge=z,W=e.bundle?.branch??e.branch,_e=e.has_worktree??(e.state===`plan`?!1:!!W),ve=!z&&_e,ye=Qw(e,new Map(t.map(e=>[e.id,e])),n),be=Sw(e.state),G=e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`,xe=e.worktree_bundle_id!==null,Se=Ew(e),Ce=Dw(e),we=Ow(e),Te=!z&&Ce!==`plan`&&e.diff_stats===void 0,Ee=(we||Se)&&!a,De=be?ne(be===`review`?`card.advance.reviewBundle`:`card.columnLabels.${be}`):G?ne(`card.advance.rerunReview`):null,Oe=Nw(e,`trash`),ke=e.undo,Ae=!!b&&ke?.stage!==null,je=G||(be?Nw(e,be):!1),Me=!Se&&!!S&&!!De&&!ye.hasOpenBlockers,Ne=!!C&&jw(e),Pe=Se&&typeof e.state==`string`?ne(`card.returnTo`,{state:ne(`card.columnLabels.${e.state}`)}):null,Fe=!!w&&Pe!==null&&e.state!==`plan`,Ie=!Se&&!!T&&ye.canStartBuildChain,Le=Tw(e)&&e.agent_status===`running`&&!!e.session_id&&!!M,Re=Tw(e)&&e.agent_status===`stopped`&&!!e.session_id&&!!P,ze=ve&&!!O,Be=ve&&!!e.project_id&&!!D,Ve=ve&&!!k,He=!Se&&!z&&xe&&!!A,Ue=!ge&&_e&&!!W&&!e.is_running&&!!E,We=!ge&&_e&&!!W&&!!e.is_running&&!!j,Ge=!!e.build_chain&&!!N,Ke=!!y||Ae||Me||Ne||Fe||Ie||Le||Re||He||Ue||We||Be||ze||Ve||Ge,qe=Se&&!e.is_running?`opacity-0 pointer-events-none transition-opacity group-hover/card:opacity-100 group-hover/card:pointer-events-auto group-focus-within/card:opacity-100 group-focus-within/card:pointer-events-auto`:``,Je=async()=>{if(!(!E||c||de)){fe(!0);try{await E()}finally{fe(!1)}}},Ye=async()=>{if(!(!j||pe)){me(!0);try{await j()}finally{me(!1)}}},Xe=!ge&&_e&&W&&e.is_running&&j&&!te?(0,Z.jsx)(oT,{isRunning:!0,isStopPending:pe,onStop:Ye}):!ge&&_e&&W&&!e.is_running&&E?(0,Z.jsx)(oT,{isRunning:!1,isRunPending:de,runDisabled:c,runDisabledReason:l,onRun:Je,className:qe}):null;(0,Y.useEffect)(()=>{if(!se)return;let e=()=>{ce(!1)};return window.addEventListener(`click`,e,{once:!0}),()=>{window.removeEventListener(`click`,e)}},[se]);let Ze=()=>{if(a||se||te){ce(!1);return}if(R&&I){I();return}if(L){L();return}ee?.(e.id),oe(!0)},{attributes:Qe,listeners:$e,setNodeRef:et,isDragging:q}=XC({id:e.id,disabled:a||he}),J=(0,Y.useRef)(et);(0,Y.useEffect)(()=>{J.current=et},[et]);let tt=(0,Y.useCallback)(t=>{if(a){m?.(t);return}J.current(t),p?.(e.id,t)},[p,m,a,e.id]),nt=u===`valid`?`border-emerald-400 shadow-[0_0_0_1px_rgba(52,211,153,0.35)]`:u===`invalid`?`border-red-400 shadow-[0_0_0_1px_rgba(248,113,113,0.35)]`:a?`border-violet-400`:ye.isVisibleStartPoint?`border-violet-500/35 shadow-[0_0_0_1px_rgba(168,85,247,0.18)] hover:border-violet-400/55`:`border-border hover:border-primary/40`,rt=a||te?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,it=q?`opacity-30`:Ee?`opacity-90`:`opacity-100`,at=Ee?`bg-card/60`:`bg-secondary/30`,ot=Ee?`p-3 text-foreground/70`:`p-3`,st=Ee?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,ct=Ee?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,lt=Ee?`whitespace-pre-line text-xs leading-relaxed text-foreground/55 wrap-anywhere`:`whitespace-pre-line text-xs leading-relaxed text-muted-foreground wrap-anywhere`,ut=e.model??``,dt=!!e.bundle&&!z,ft=!!e.bundle?.pull_request&&!z,pt=dt||ft,mt=pt||ut.length>0,ht=le===e.id,gt=(0,Y.useMemo)(()=>{let t=e.description??``;return t?YM(t):{text:``,truncated:!1}},[e.description]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(mu,{"data-testid":`ticket-card-${e.id}`,className:`group/card shrink-0 select-none transition-colors ${nt} ${rt} ${it} ${at} gap-0 rounded-xl border shadow-none`,ref:tt,onClick:Ze,...$e,...Qe,children:[te&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(U,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Df,{className:`h-3.5 w-3.5 animate-spin`}),ne(`card.undoInProgress`)]})}),(0,Z.jsxs)(yu,{className:ot,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`div`,{className:st,children:e.title})}),(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,Z.jsx)(`div`,{className:`mr-1`,children:Xe}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:d&&(0,Z.jsx)(yc,{content:ne(`card.drawDependency`),children:(0,Z.jsx)(K,{type:`button`,"aria-label":ne(`card.createDependencyAriaLabel`,{title:e.title}),variant:`ghost`,size:`icon-xs`,className:`cursor-crosshair opacity-0 transition-all group-hover/card:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.stopPropagation(),ce(!0),d(e.id,t)},children:(0,Z.jsx)(Kd,{className:`h-4 w-4`})})})}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:Ke&&(0,Z.jsx)(gT,{title:e.title,canDelete:Oe,undo:ke,undoInProgress:te,runDisabled:c,isRunPending:de,isStopPending:pe,showTestsAction:Be,showOpenChangesAction:ze,showOpenIdeAction:Ve,showAddTicketToBundleAction:He,showRunAction:Ue,showStopRunAction:We,showAdvanceAction:Me,advanceLabel:De,canAdvance:je,showParkAction:Ne,showReturnAction:Fe,returnLabel:Pe,showBuildChainAction:Ie,showPauseBuildAction:Le,showResumeBuildAction:Re,showStopBuildChainAction:Ge,onDelete:y,onConfirmDelete:()=>re(!0),onConfirmUndo:()=>ie(!0),onOpenTests:D,onOpenChanges:O,onOpenIde:k,onAddTicketToBundle:He?()=>A?.(e.worktree_bundle_id):void 0,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:Je,onStop:Ye,onStopBuild:M,onResumeBuild:P,onStopBuildChain:N})})]})]}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(yT,{ticket:e,hideStatusBadge:B,hideBundleScopedControls:z,isStale:we,runControl:null,onRetry:x,undoInProgress:te,isChainStart:ye.isVisibleStartPoint})}),mt&&(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[pt&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${ct}`,children:[dt&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:Tl(e.bundle)}),ft&&e.bundle?.pull_request&&(0,Z.jsx)(_w,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})]}),ut.length>0&&(0,Z.jsx)(`div`,{className:ct,children:(0,Z.jsx)(`span`,{className:`truncate`,children:ut})})]}),e.description&&(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(vT,{description:e.description,descriptionClass:lt,isExpanded:ht,collapsedState:gt,useStaleLikeStyling:Ee,onExpand:()=>ue(e.id),onCollapse:()=>ue(null)})}),!z&&(Aw(Ce,e.diff_stats)||Te)&&(0,Z.jsx)(Dc,{stats:e.diff_stats,isLoading:Te,showFiles:!0,className:`mt-2`})]})]}),ae&&(0,Z.jsx)($W,{ticket:e,allTickets:t,dependencies:n,bundles:r,projectMemoryEnabled:i,onClose:()=>{oe(!1),ee?.(e.id)},showModelSelector:o,availableModels:s,runDisabled:c,runDisabledReason:l,onDeleteDependency:f,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onAdvance:S,onBuildChain:T,onRun:E,onOpenIde:k,onStop:j,onStopBuild:M,onStopBuildChain:N,onResumeBuild:P,onFollowUp:F}),V&&(0,Z.jsx)(_T,{title:e.title,bundleName:e.bundle?Tl(e.bundle):void 0,onConfirm:()=>{re(!1),y?.()},onCancel:()=>re(!1)}),H&&ke?.stage&&(0,Z.jsx)(aT,{title:e.title,stage:ke.stage,onConfirm:()=>{ie(!1),b?.()},onCancel:()=>ie(!1)})]})},tG=({index:e})=>{let{t}=X(`common`);return(0,Z.jsx)(mu,{"aria-hidden":`true`,"data-testid":`ticket-card-skeleton`,className:`group shrink-0 select-none gap-0 rounded-xl border border-border/70 bg-secondary/20 shadow-none`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(Ec,{className:`h-3.5 w-3/5 rounded-full`}),(0,Z.jsx)(Ec,{className:`h-5 w-11 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Ec,{className:`h-3 w-full rounded-full`}),(0,Z.jsx)(Ec,{className:`h-3 w-11/12 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ec,{className:`h-4 w-14 rounded-full`}),(0,Z.jsx)(Ec,{className:`h-4 w-10 rounded-full`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:t(`column.loadingCard`,{index:e+1})})]})})},nG=({id:e,title:t,items:n,ticketCount:r,pinnedContent:i=null,allTickets:a,dependencies:o,showModelSelector:s,availableModels:c,activeRunContextKey:l,isProjectRootRunActive:u=!1,isBundleRunDisabled:d,bundles:f,getDependencyTargetState:p,onDependencyStart:m,onDeleteDependency:h,onRegisterTicketNode:g,onAddTicket:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdateTicket:x,onDeleteTicket:S,onUndoTicket:C,undoingColumn:w=null,onRetryTicket:T,onAdvanceTicket:E,onParkTicket:D,onUnparkTicket:O,onBuildChainTicket:k,onRunTicket:A,onOpenTestsTicket:j,canOpenChangesForTicket:M,onOpenChangesTicket:N,canOpenIdeForTicket:P,onOpenIdeTicket:F,onStopTicket:I,onStopBuildTicket:L,onStopBuildChainTicket:R,onResumeBuildTicket:z,onFollowUpTicket:B,onBuildBundle:ee,onReviewBundle:te,onUndoBundleReview:ne,onRunBundle:V,onStopBundle:re,onParkBundleWrapper:H,onUnparkBundleWrapper:ie,bundleActionState:ae,onOpenTicketDetails:oe,onOpenBundleDetails:se,onOpenBundleChanges:ce,onOpenBundleTests:le,onOpenBundleIde:ue,onDeleteBundleWrapper:de,onAddTicketToBundle:fe,onRequestBundleRefresh:pe,onRequestTicketRefresh:me,className:he=``,headerAccessory:ge=null,loadingSkeletonCount:W=0})=>{let{t:_e}=X(`common`),{setNodeRef:ve,isOver:ye}=ew({id:e}),be=(0,Y.useRef)(null),[G,xe]=(0,Y.useState)(!1),[Se,Ce]=(0,Y.useState)(!1),we=e=>e.has_worktree??!!(e.bundle?.branch??e.branch),Te=ye?`border-primary`:`border-border`,Ee=w===e&&(e===`build`||e===`review`),De=(0,Y.useCallback)(()=>{let e=be.current;if(!e){xe(!1),Ce(!1);return}if(!(e.scrollHeight>e.clientHeight+1)){xe(!1),Ce(!1);return}let t=e.scrollHeight-e.clientHeight;xe(e.scrollTop>1),Ce(e.scrollTop<t-1)},[]);(0,Y.useEffect)(()=>{let e=window.requestAnimationFrame(De),t=be.current;if(!t){window.cancelAnimationFrame(e);return}return t.addEventListener(`scroll`,De),window.addEventListener(`resize`,De),()=>{window.cancelAnimationFrame(e),t.removeEventListener(`scroll`,De),window.removeEventListener(`resize`,De)}},[n.length,W,De]);let Oe=(0,Y.useCallback)((t,n)=>{let r=t.worktree_bundle_id!==null,i=n?.nestedInBundle??!1,d=n?.hideStatusBadge??!1,_=r&&e!==`plan`,w=qw(t),ee=u||l!==null&&l!==ww(t)?_e(`column.runDisabledReason`):w;return(0,Z.jsx)(eG,{ticket:t,allTickets:a,dependencies:o,bundles:f,showModelSelector:s,availableModels:c,runDisabled:ee!==void 0,runDisabledReason:ee,dependencyTargetState:p?.(t.id)??`idle`,onDependencyStart:m,onDeleteDependency:h,onRegisterNode:g,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdate:x,onDelete:()=>S(t.id),onUndo:C?()=>C(t.id):void 0,undoInProgress:!1,onRetry:()=>T(t.id),onAdvance:E?()=>E(t.id):void 0,onPark:D?()=>D(t.id):void 0,onUnpark:O?()=>O(t.id):void 0,onBuildChain:k?()=>k(t.id):void 0,onRun:we(t)&&t.has_run_config&&A?()=>A(t.id):void 0,onOpenTests:j&&t.project_id&&we(t)?()=>j(t.id):void 0,onOpenChanges:M?.(t)&&N?()=>N(t.id):void 0,onOpenIde:P?.(t)&&F?()=>F(t.id):void 0,onStop:I?()=>I(t.id):void 0,onStopBuild:L?()=>L(t.id):void 0,onStopBuildChain:R?()=>R(t.id):void 0,onResumeBuild:z?()=>z(t.id):void 0,onFollowUp:B?e=>B(t.id,e):void 0,onAddTicketToBundle:fe,onOpenBundleDetails:_&&se?()=>se(t.worktree_bundle_id,e):void 0,onOpenTicketDetails:()=>oe(t),preferBundleDetailsOnClick:_,hideBundleScopedControls:i,hideStatusBadge:d,onRequestTicketRefresh:me})},[l,a,c,f,M,P,o,p,e,u,fe,E,k,v,y,h,S,m,B,se,N,F,j,oe,D,b,g,me,z,T,A,R,L,I,C,O,x,s,_e]);return(0,Z.jsxs)(mu,{className:`flex min-h-0 min-w-[280px] flex-1 flex-col rounded-2xl bg-card/80 p-4 transition-colors ${he} ${Te}`,ref:ve,children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex min-h-7 items-center justify-between`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:t}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ge,(0,Z.jsx)(U,{variant:`outline`,children:r}),_&&(0,Z.jsxs)(K,{type:`button`,onClick:_,size:`xs`,variant:`success`,className:`gap-2 shadow-[0_8px_20px_rgba(16,185,129,0.22)]`,children:[(0,Z.jsx)(`span`,{children:_e(`column.newTicket`)}),(0,Z.jsx)(U,{"aria-hidden":`true`,variant:`hotkeyDark`,className:`rounded-md px-1.5 py-0.5 text-[10px] leading-none`,children:`N`})]})]})]}),(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{ref:be,className:`flex min-h-0 h-full flex-col gap-2.5 overflow-y-auto pr-1`,children:[i,n.map(e=>{if(e.kind===`bundle`)return(0,Z.jsx)(mT,{group:e.group,renderTicket:t=>Oe(t,{nestedInBundle:!0,hideStatusBadge:e.group.column===`review`}),runDisabled:d?.(e.group.bundle.id)??!1,onBuildBundle:ee,onReviewBundle:te,onUndoBundleReview:ne,onRunBundle:V,onStopBundle:re,onParkBundleWrapper:H,onUnparkBundleWrapper:ie,bundleActionState:ae,onStopBuildTicket:L,onResumeBuildTicket:z,onOpenBundleDetails:se,onOpenBundleChanges:ce,onOpenBundleTests:le,onOpenBundleIde:ue,onDeleteBundleWrapper:de,onAddTicketToBundle:fe,onRequestBundleRefresh:pe},e.group.id);let t=e.ticket;return(0,Z.jsx)(Y.Fragment,{children:Oe(t)},t.id)}),Array.from({length:W},(t,n)=>(0,Z.jsx)(tG,{index:n},`loading-card-${e}-${n}`))]}),Ee&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-undo-overlay-${e}`,className:`absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(U,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Df,{className:`h-3.5 w-3.5 animate-spin`}),_e(`column.undoInProgress`)]})}),G&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-top-fade`,className:`pointer-events-none absolute inset-x-0 top-0 h-6 rounded-t-xl bg-gradient-to-b from-card to-transparent`}),Se&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-bottom-fade`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 rounded-b-xl bg-gradient-to-t from-card to-transparent`})]})]})},rG=({ticketCount:e,isDeleting:t,onCancel:n,onConfirm:r})=>{let{t:i}=X(`common`);return(0,Z.jsxs)(du,{onClose:t?()=>{}:n,overlayClassName:`bg-black/60`,panelClassName:`max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:i(`boardConfirmEmptyDoneModal.heading`)}),(0,Z.jsx)(`p`,{className:`mb-2 text-sm text-foreground`,children:i(`boardConfirmEmptyDoneModal.deletePrompt`,{count:e})}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:i(`boardConfirmEmptyDoneModal.description`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:t,onClick:n,children:i(`boardConfirmEmptyDoneModal.cancel`)}),(0,Z.jsx)(K,{type:`button`,variant:`destructive`,disabled:t,onClick:r,children:i(t?`boardConfirmEmptyDoneModal.deleting`:`boardConfirmEmptyDoneModal.confirm`)})]})]})},iG=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,legacyThinkingTicketId:a=null,previousThinkingLog:o=null,previousThinkingMessageId:s=null,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d=!1,canShowComposer:f,composerControls:p,composerTheme:m=`default`,layoutKey:h,scrollLayoutKey:g,followUpPrompt:_,followUpPlaceholder:v=`Follow up on this bundle`,isSendingFollowUp:y,followUpDisabledReason:b,onFollowUpPromptChange:x,onFollowUpKeyDown:S,onFollowUpSubmit:C})=>(0,Z.jsx)(MN,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,currentThinkingMessageId:i,legacyThinkingTicketId:a,previousThinkingLog:o,previousThinkingMessageId:s,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d,autoScrollBehavior:`sticky`,canShowComposer:f,composerInlineControls:p,composerTheme:m,composerSize:`compact-on-laptop`,layoutKey:h,scrollLayoutKey:g,followUpPrompt:_,followUpPlaceholder:v,emptyStateText:`No bundle messages yet.`,autoFocusComposer:!0,isSendingFollowUp:y,followUpDisabledReason:b,onFollowUpPromptChange:x,onFollowUpKeyDown:S,onFollowUpSubmit:C}),aG=({bundleId:e,actionState:t,runDisabled:n,canBuild:r,canStopBuild:i,runningBuildTicketId:a,canResumeBuild:o,resumableBuildTicketId:s,isRunning:c,canRun:l,canReview:u,reviewActionLabel:d=`Review Bundle`,onClose:f,onBuildBundle:p,onStopBuildTicket:m,onResumeBuildTicket:h,onRunBundle:g,onStopBundle:_,onReviewBundle:v})=>{let y=t.review||t.followUp;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),c?(0,Z.jsxs)(K,{type:`button`,variant:`destructive`,disabled:t.stop,onClick:()=>void _(e),children:[(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(Nc,{className:`w-3.5 h-3.5`}),t.stop?`Stopping...`:`Stop Run`]}):l?(0,Z.jsxs)(K,{type:`button`,variant:`secondary`,disabled:t.run||n,title:n?`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{n||g(e)},className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,Z.jsx)(jc,{className:`w-3.5 h-3.5`}),t.run?`Starting Run...`:`Run`]}):null,r&&(0,Z.jsxs)(K,{type:`button`,disabled:t.build,onClick:()=>void p(e),children:[(0,Z.jsx)(jc,{className:`w-3.5 h-3.5`}),t.build?`Building Bundle...`:`Build Bundle`]}),i&&a&&(0,Z.jsxs)(K,{type:`button`,variant:`warning`,disabled:t.stopBuild,title:`Pause the build session. You can resume it later.`,"aria-label":`Pause Build`,onClick:()=>void m(a),children:[(0,Z.jsx)(Nc,{className:`w-3.5 h-3.5`}),t.stopBuild?`Pausing...`:`Pause Build`]}),o&&s&&(0,Z.jsxs)(K,{type:`button`,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,disabled:t.resumeBuild,onClick:()=>void h(s),children:[(0,Z.jsx)(jc,{className:`w-3.5 h-3.5`}),t.resumeBuild?`Resuming...`:`Resume`]}),u&&(0,Z.jsxs)(K,{type:`button`,disabled:y,onClick:()=>void v(e),children:[(0,Z.jsx)(yw,{className:`w-3.5 h-3.5`}),y?`Reviewing Bundle...`:d]})]})]})},oG=e=>e.agent_status===`running`?`bg-amber-400`:e.agent_status===`error`?`bg-rose-400`:e.agent_status===`stopped`?`bg-amber-300`:e.agent_status===`done`?`bg-emerald-400`:`bg-border`,sG=({tickets:e,onOpenTicketDetails:t,highlightedTicketId:n=null,pendingMemorySuggestionCounts:r={}})=>{let i=e.filter(e=>e.agent_status===`running`).length,a=e.filter(e=>e.agent_status===`error`).length;return(0,Z.jsxs)(`section`,{"aria-label":`Bundle tickets`,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Tickets`}),(0,Z.jsx)(U,{variant:`outline`,children:e.length}),i>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[i,` active`]}),a>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-rose-300`,children:[a,` error`,a===1?``:`s`]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-col gap-1 overflow-y-auto pr-1`,children:e.map(e=>{let i=r[e.id]??0,a=e.id===n;return(0,Z.jsxs)(`button`,{type:`button`,"data-follow-up-target":a?`true`:`false`,"aria-current":a?`true`:void 0,className:G(`flex cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2.5 text-left text-foreground transition-colors`,a?`border border-sky-500/35 bg-sky-500/10 shadow-[inset_0_0_0_1px_rgba(56,189,248,0.12)] hover:bg-sky-500/15`:`bg-background/20 hover:bg-accent/45`),onClick:()=>t(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:G(`h-2 w-2 shrink-0 rounded-full`,oG(e))}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.title}),(0,Z.jsx)(TT,{tool:e.tool,className:`shrink-0 text-[10px]`})]}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e.state})]}),a&&(0,Z.jsx)(U,{variant:`info`,className:`shrink-0 px-1.5 text-[10px]`,"aria-label":`Follow-up target`,children:`Follow-up`}),i>0&&(0,Z.jsx)(U,{variant:`warning`,className:`h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[10px]`,"aria-label":`${i} pending memory suggestion${i===1?``:`s`}`,title:`${i} pending memory suggestion${i===1?``:`s`}`,children:i})]},e.id)})})]})},cG=e=>e.kind===`description`?e.bundle_visible_at??e.created_at:e.created_at,lG=(e,t)=>e?t.get(e)??e:null,uG=(e,t)=>lG(e,t)??`Agent`,dG=e=>e.kind===`planning_follow_up`||e.kind===`planning_response`?0:e.kind===`description`?1:2,fG=(e,t)=>{let n={};for(let r of e){let e=lG(r.model,t);e&&(n[r.id]=e)}return n},pG=(e,t=[])=>{let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>{let r=n.get(e.id)??e.bundle_execution_position??2**53-1,i=n.get(t.id)??t.bundle_execution_position??2**53-1;if(r!==i)return r-i;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let a=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return a===0?e.id.localeCompare(t.id):a})},mG=(e,t,n,r=[])=>{let i=pG(e,r),a=new Map(i.map((e,t)=>[e.id,t]));return i.flatMap(e=>{let r=e.messages??[],i=e.agent_status!==null||e.session_id!==null||r.some(e=>e.kind!==`description`&&MT(e)),o=r.filter(e=>MT(e)&&(i||e.kind!==`description`)),s=n[e.id]??uG(e.model,t);return o.map(t=>t.role===`assistant`?{...t,displayTitle:s,ticketOrder:a.get(e.id)??2**53-1}:t.kind===`follow_up`?{...t,displayTitle:`You`,ticketOrder:a.get(e.id)??2**53-1}:{...t,displayTitle:e.title,ticketOrder:a.get(e.id)??2**53-1})}).sort((e,t)=>{if(e.ticket_id===t.ticket_id){let n=dG(e)-dG(t);if(n!==0)return n}let n=cG(e),r=cG(t);if(n!==r)return n.localeCompare(r);if(e.ticket_id!==t.ticket_id&&e.ticketOrder!==t.ticketOrder)return e.ticketOrder-t.ticketOrder;let i=dG(e)-dG(t);return i===0?e.id.localeCompare(t.id):i}).map(e=>{let{ticketOrder:t,...n}=e;return n})},hG=e=>yl(e.tickets,{targetTicketId:e.target_ticket_id,reviewOwnerTicketId:e.review_owner_ticket_id,latestSessionTicketId:e.latest_session_ticket_id}),gG=(0,Y.lazy)(()=>WW(()=>Promise.resolve().then(()=>nJ).then(e=>({default:e.TicketChangesModal})),void 0)),_G=e=>e.replace(/\r\n/g,`
|
|
144
|
-
`).trim(),vG=(e,t)=>e.ticket_id===t.ticket_id&&e.role===`user`&&t.role===`user`&&e.kind===`follow_up`&&t.kind===`follow_up`&&_G(e.content)===_G(t.content),yG=(e,t)=>{if(t.length===0)return e;let n=new Set,r=new Set,i=new Map,a=[];for(let a of t){let t=[...e].reverse().find(e=>!r.has(e.id)&&!n.has(a.id)&&vG(a,e));t&&(r.add(t.id),n.add(a.id),i.set(t.id,a))}for(let t of e){let e=i.get(t.id);if(e){a.push(e);continue}a.push(t)}for(let e of t)n.has(e.id)||a.push(e);return a},bG=e=>e?e.startsWith(`ses_`)?`opencode --session ${e}`:`claude --resume ${e}`:null,xG=(e,t)=>e.latest_session_id?bG(e.latest_session_id):bG(t?.session_id??null),SG=(e,t)=>t?.diff_stats?t.diff_stats:e.find(e=>e.diff_stats)?.diff_stats??null,CG=({details:e,activeColumn:t=null,isLoading:n=!1,actionState:r,canOpenIde:i,projectMemoryEnabled:a=!1,memorySuggestionsRefreshKey:o=0,runDisabled:s=!1,showModelSelector:c=!1,availableModels:l=[],availableSkills:u=[],onClose:d,onOpenTicketDetails:f,onOpenIde:p,onOpenTests:m,onRefresh:h,onUpdateTicket:g,onBuildBundle:_,onStopBuildTicket:v,onResumeBuildTicket:y,onReviewBundle:b,onRunBundle:x,onStopBundle:S,onFollowUpBundle:C})=>{let{t:w}=X(`common`),[T,E]=(0,Y.useState)(!1),[D,k]=(0,Y.useState)(``),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)(!1),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(``),[R,z]=(0,Y.useState)(``),[B,ee]=(0,Y.useState)([]),[te,ne]=(0,Y.useState)(null),[V,re]=(0,Y.useState)(!1),[H,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)({}),[se,ce]=(0,Y.useState)([]),le=(0,Y.useMemo)(()=>hG(e),[e]),ue=(0,Y.useMemo)(()=>new Map(l.map(e=>[e.id,e.label])),[l]),[de,fe]=(0,Y.useState)(()=>fG(e.tickets,ue)),pe=(0,Y.useMemo)(()=>pG(e.tickets,e.execution_order_ticket_ids),[e.execution_order_ticket_ids,e.tickets]),me=t??le?.state??null,he=me===`plan`,ge=(0,Y.useMemo)(()=>yG(mG(e.tickets,ue,de,e.execution_order_ticket_ids),se),[ue,e.execution_order_ticket_ids,e.tickets,se,de]),W=(0,Y.useMemo)(()=>lT(e.tickets,me),[me,e.tickets]),_e=(0,Y.useMemo)(()=>(0,Z.jsx)(iT,{status:W}),[W]),ve=(0,Y.useMemo)(()=>xG(e,le),[e,le]),ye=(0,Y.useMemo)(()=>SG(e.tickets,le),[e.tickets,le]),G=!he&&!!(le?.project_id&&le&&vl(le)),xe=!!(m&&le?.project_id&&le&&vl(le)),Se=!he&&!!(le?.project_id&&le),Ce=Se&&!A,we=Se&&P&&le!==null,Te=me===`plan`&&e.tickets.some(e=>e.state===`plan`),Ee=pe.find(e=>Tw(e)&&e.agent_status===`running`&&!!e.session_id)??null,De=pe.find(e=>Tw(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,Oe=Ee!==null,ke=!Oe&&De!==null,Ae=me===`build`&&e.tickets.some(e=>e.state===`build`)&&e.tickets.filter(e=>e.state===`build`).every(e=>e.agent_status===`done`),je=r.review||r.followUp,Me=me===`review`&&e.can_re_review===!0&&!e.tickets.some(e=>e.agent_status===`running`)&&!je,Ne=Ae||Me,Pe=Me?`Re-run review`:`Review Bundle`,Fe=e.tickets.some(e=>e.has_run_config&&Kw(e)),Ie=e.tickets.some(e=>e.is_running),Le=e.tickets.find(e=>e.agent_status===`running`)??le,Re=Le?.streaming_response??null,ze=Le?.agent_log??null,Be=Le?.agent_message_id??le?.agent_message_id??null,Ve=Le?.previous_agent_log??le?.previous_agent_log??null,He=Le?.previous_agent_message_id??le?.previous_agent_message_id??null,Ue=l.find(e=>e.id===I)??null,We=le?.project_id??e.tickets.find(e=>e.project_id)?.project_id??null,Ge=(0,Y.useMemo)(()=>e.tickets.map(e=>e.id).sort().join(`|`),[e.tickets]),Ke=(0,Y.useMemo)(()=>new Set(Ge.length>0?Ge.split(`|`):[]),[Ge]),qe=(0,Y.useMemo)(()=>e.tickets.map(e=>`${e.id}:${e.build_completed_at??``}`).sort().join(`|`),[e.tickets]),Je=Le??le??e.tickets[0]??null,Ye=Je??le,Xe=Ye?.id??null,Ze=Le?de[Le.id]??Le.model??`Agent`:`Agent`,Qe=Le?.agent_status===`running`?Ze:null,$e=!he&&!!(le&&vl(le)),et=Cw(t??le?.state??null),q=$e&&c&&Ye?.tool===`opencode`,J=r.followUp||H,tt=e.tickets.some(e=>e.agent_status===`running`),nt=tt?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,rt=Je?`Follow up on: ${Je.title}`:`Follow up on this bundle`,it=[{label:e.bundle.kind===`project_root`?`Project root branch`:`Worktree`,value:e.bundle.branch},{label:`Session`,value:ve??``}],at=!he,ot=A&&!M,st=e.bundle.id,ct=A?M?`expanded`:`split`:`closed`,lt=ot?`flex h-[92vh] w-[98vw] max-w-[110rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,ut=ot?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)_minmax(30rem,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)_minmax(30rem,1fr)]`:at?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)]`:`flex min-h-0 flex-1 flex-col`,dt=M?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`fixed inset-4 z-[70] flex items-stretch justify-end bg-black/30 backdrop-blur-sm 2xl:hidden sm:inset-6 lg:inset-8`;(0,Y.useEffect)(()=>{if(!a||he||!We||Ge.length===0){oe({});return}let e=new AbortController;return be(We,null,e.signal).then(t=>{e.signal.aborted||oe(t.suggestions.reduce((e,t)=>(!t.ticket_id||!Ke.has(t.ticket_id)||(e[t.ticket_id]=(e[t.ticket_id]??0)+1),e),{}))}).catch(t=>{if(!e.signal.aborted){if(t instanceof O&&(t.status===404||t.status===409)){oe({});return}oe({})}}),()=>{e.abort()}},[qe,We,Ke,Ge,he,o,a]),(0,Y.useEffect)(()=>{fe(t=>{let n={...t},r=!1,i=new Set(e.tickets.map(e=>e.id));for(let t of e.tickets){let e=t.model?ue.get(t.model)??t.model:null;!e||n[t.id]===e||(n[t.id]=e,r=!0)}for(let e of Object.keys(n))i.has(e)||(delete n[e],r=!0);return r?n:t})},[ue,e.tickets]),(0,Y.useEffect)(()=>{if(Xe!==null&&te?.ticketId===Xe)if((Ye?.model??``)===te.model&&(Ye?.variant??``)===te.variant&&(Ye?.skills.length??0)===te.skills.length&&(Ye?.skills??[]).every((e,t)=>e===te.skills[t]))ne(null);else return;L(Ye?.model??``),z(Ye?.variant??``),ee(Ye?.skills??[])},[Ye?.model,Ye?.skills,Ye?.variant,Xe,te]);let ft=async(e,t,n)=>{if(Ye){ne({ticketId:Ye.id,model:e,variant:t,skills:n}),re(!0);try{let r=await Yt(Ye.id,Ye.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});g?.(r)}catch(e){ne(null),L(Ye.model??``),z(Ye.variant??``),ee(Ye.skills),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{re(!1)}}},pt=async()=>{let t=D.trim();if(!t||J||tt)return;let n=Je?{id:`optimistic-follow-up-${Date.now()}`,ticket_id:Je.id,role:`user`,kind:`follow_up`,content:t,created_at:new Date().toISOString(),displayTitle:`You`}:null;ie(!0),k(``),n&&ce(e=>[...e,n]);try{await C(e.bundle.id,t)}catch{n&&ce(e=>e.filter(e=>e.id!==n.id)),k(t)}finally{ie(!1)}},mt=q?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:q&&(0,Z.jsx)(fP,{model:I,variant:R,skills:B,showModelSelector:!0,showSkillsSelector:!0,availableModels:l,availableSkills:u,selectedModel:Ue,onModelChange:e=>{let t=(l.find(t=>t.id===e)??null)?.variants.includes(R)?R:``;L(e),z(t),ft(e,t,B)},onVariantChange:e=>{z(e),ft(I,e,B)},onSkillsChange:e=>{ee(e),ft(I,R,e)},modelSelectId:`bundle-follow-up-model`,variantSelectId:`bundle-follow-up-variant`,skillsSelectId:`bundle-follow-up-skills`,disabled:V})}):void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(du,{onClose:d,overlayClassName:`bg-black/60 !z-40`,panelClassName:lt,renderContent:({closeButton:t})=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`div`,{"data-testid":`bundle-modal-layout`,"data-terminal-mode":ct,className:`min-h-0 flex flex-1 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:Tl(e.bundle)}),_e,e.bundle.pull_request&&(0,Z.jsx)(_w,{pullRequest:e.bundle.pull_request,asLink:!0}),(0,Z.jsxs)(U,{variant:`outline`,children:[e.tickets.length,` tickets`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!he&&ye&&(0,Z.jsx)(Dc,{stats:ye,showFiles:!0,className:`text-xs`}),G&&(0,Z.jsxs)(K,{type:`button`,"aria-label":w(`workspaceControls.changes`),onClick:()=>E(!0),variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(kc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.changes`)})]}),xe&&(0,Z.jsxs)(K,{type:`button`,"aria-label":w(`workspaceControls.tests`),onClick:m,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Oc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.tests`)})]}),!he&&i&&(0,Z.jsxs)(K,{type:`button`,"aria-label":w(`workspaceControls.openIde`),onClick:p,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ac,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.openIde`)})]}),Ce&&(0,Z.jsxs)(K,{type:`button`,"aria-label":w(`workspaceControls.openTerminalAriaLabel`),onClick:()=>{F(!0),j(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Pc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.terminal`)})]}),t]})]}),(0,Z.jsxs)(`div`,{className:ut,children:[at&&(0,Z.jsxs)(`aside`,{"data-testid":`bundle-modal-sidebar`,className:`flex min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(kT,{ariaLabel:w(`workspaceControls.ticketMetadataAriaLabel`),items:it,className:`flex-col items-stretch gap-3`}),(0,Z.jsx)(sG,{tickets:e.tickets,onOpenTicketDetails:f,highlightedTicketId:Je?.id??null,pendingMemorySuggestionCounts:ae})]}),(0,Z.jsxs)(`div`,{"data-testid":`bundle-modal-main`,className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[!he&&(0,Z.jsx)(iG,{projectId:le?.project_id??null,followUpTicketId:e.target_ticket_id,messages:ge,internalLog:ze,currentThinkingMessageId:Be,legacyThinkingTicketId:Le?.id??le?.id??null,previousThinkingLog:Ve,previousThinkingMessageId:He,pendingAgentTitle:Qe,streamingResponse:Re,isRunning:Le?.agent_status===`running`,isLoading:n,canShowComposer:$e,layoutKey:st,scrollLayoutKey:ct,composerControls:mt,composerTheme:et,followUpPrompt:D,followUpPlaceholder:rt,isSendingFollowUp:J,followUpDisabledReason:nt,onFollowUpPromptChange:k,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||tt||J||(e.preventDefault(),pt())},onFollowUpSubmit:()=>{pt()}}),he&&(0,Z.jsx)(sG,{tickets:e.tickets,onOpenTicketDetails:f,pendingMemorySuggestionCounts:ae}),(0,Z.jsx)(aG,{bundleId:e.bundle.id,actionState:r,runDisabled:s,canBuild:Te,canStopBuild:Oe,runningBuildTicketId:Ee?.id??null,canResumeBuild:ke,resumableBuildTicketId:De?.id??null,isRunning:Ie,canRun:Fe,canReview:Ne,reviewActionLabel:Pe,onClose:d,onBuildBundle:_,onStopBuildTicket:v,onResumeBuildTicket:y,onRunBundle:x,onStopBundle:S,onReviewBundle:b})]}),we&&le&&(0,Z.jsx)(`div`,{className:A?ot?`min-h-0 flex flex-col overflow-hidden`:dt:`hidden`,children:(0,Z.jsx)(FW,{createSession:()=>bT(le.id,le.project_id),isExpanded:M,isVisible:A,ariaLabel:w(`bundleDetailsModal.bundleTerminalAriaLabel`),title:w(`workspaceControls.terminalTitle`),className:ot||M?`h-full w-full max-w-none rounded-2xl shadow-2xl`:`h-full w-full max-w-5xl rounded-2xl shadow-2xl`,onClose:()=>{j(!1),N(!1),F(!1),h(e.bundle.id)},onToggleExpanded:()=>{N(e=>!e)}})})]})]})})}),T&&le&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(gG,{ticketId:le.id,projectId:le.project_id,reviewCommentsBundleId:e.bundle.id,title:Tl(e.bundle),onSubmitReviewPrompt:t=>C(e.bundle.id,t),canSubmitReviewPrompt:!tt,reviewSubmitDisabledReason:nt,canAddReviewComments:!tt,canModifyChanges:!tt,changesDisabledReason:nt,onClose:()=>{E(!1),h(e.bundle.id)}})})]})},wG=H(`group/toggle inline-flex cursor-pointer items-center justify-center gap-1 rounded-3xl text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-9 min-w-9 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5`,sm:`h-8 min-w-8 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,lg:`h-10 min-w-10 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3`}},defaultVariants:{variant:`default`,size:`default`}}),TG=Y.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function EG({className:e,variant:t,size:n,spacing:r=0,orientation:i=`horizontal`,children:a,...o}){return(0,Z.jsx)(oa,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:G(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-3xl data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,Z.jsx)(TG.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function DG({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=Y.useContext(TG);return(0,Z.jsx)(sa,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:G(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-3 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-2.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-2.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-3xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-3xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-3xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-3xl data-[state=on]:bg-muted group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,wG({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}var OG=({content:e,className:t})=>(0,Z.jsx)(`div`,{className:G(`prose prose-invert prose-sm mt-2 max-w-none break-words text-xs text-foreground [overflow-wrap:anywhere] [&_code]:rounded [&_code]:bg-background/70 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.95em] [&_p]:mb-3 [&_p:last-child]:mb-0 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-border/70 [&_pre]:bg-background/70 [&_pre]:p-3 [&_pre]:text-xs [&_pre]:leading-5 [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-inherit`,t),children:(0,Z.jsx)(gM,{remarkPlugins:[OM],children:e})}),kG=`border-sky-400/30 bg-sky-400/10 text-sky-100`,AG=(e,t)=>Ne.t(`common:pendingFixesPopover.${e}`,t),jG=e=>e.old_line_number!==null&&e.new_line_number!==null?AG(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?AG(`lineReference.unavailable`):AG(`lineReference.oldOnly`,{oldLine:e.old_line_number}):AG(`lineReference.newOnly`,{newLine:e.new_line_number}),MG=e=>e.old_line_number!==null&&e.new_line_number!==null?AG(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?AG(`lineReference.unavailable`):AG(`lineReference.oldOnly`,{oldLine:e.old_line_number}):AG(`lineReference.newOnly`,{newLine:e.new_line_number}),NG=e=>e.subject_type===`file`,PG=({reviewComments:e,reviewFindings:t=[],githubComments:n=[],pendingFixCount:r,triggerMode:i=`full`,canSendReview:a,isSubmittingReview:o,reviewSubmitDisabledReason:s,onClearPendingFixes:c,onSubmitReview:l})=>(0,Z.jsxs)(Zs,{children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,variant:`default`,size:`sm`,className:i===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":AG(`triggerLabel`),disabled:r===0,children:[i===`compact`?(0,Z.jsx)(em,{className:`h-4 w-4`}):(0,Z.jsx)(`span`,{children:AG(`triggerLabel`)}),(0,Z.jsx)(U,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:r}),(0,Z.jsx)(Oe,{className:`h-4 w-4`})]})}),(0,Z.jsxs)($s,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsxs)(ec,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(tc,{children:AG(`title`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:AG(`description`)})]}),(0,Z.jsx)(U,{variant:`outline`,children:r})]}),r===0?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:AG(`empty`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:[e.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 px-3 py-3 shadow-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(em,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-sky-200`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:AG(`manualCommentTitle`)}),(0,Z.jsx)(U,{variant:`outline`,className:kG,children:AG(`manualBadge`)})]}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-sky-100/70`,children:[ob(e.scope),` · `,e.filePath,` · `,ab(e)]}),(0,Z.jsx)(`div`,{className:`mt-2 rounded-lg border border-sky-500/15 bg-background/60 px-3 py-2`,children:(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-xs text-foreground`,children:e.comment})})]})]})},`${e.filePath}:${e.changeKey}`)),t.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Wd,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:AG(`findingTitle`,{ordinal:e.ordinal})}),(0,Z.jsx)(U,{variant:`outline`,className:`capitalize`,children:e.severity})]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,jG(e)].filter(Boolean).join(` · `)}),(0,Z.jsx)(`div`,{className:`mt-2 text-xs font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]})]})},e.id)),n.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Mc,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.kind===`review`?AG(`githubReviewSummary`):AG(`githubReviewComment`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,e.kind===`inline`&&!NG(e)?MG(e):e.author].filter(Boolean).join(` · `)}),(0,Z.jsx)(OG,{content:e.body})]})]})},e.id))]}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-2 pt-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,disabled:r===0||o,onClick:c,children:AG(`clear`)}),(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`default`,disabled:!a,title:s,onClick:l,className:`gap-2`,children:[(0,Z.jsx)(yw,{className:`h-4 w-4`}),o?AG(`sending`):AG(`sendFixes`,{count:r})]})]})]})]})]}),FG=({commitMessage:e,onCommitMessageChange:t,commitMessageRef:n,selectedFileCount:r,changesDisabledReason:i,canEditCommitMessage:a=!0,canGenerateCommitMessage:o,canCommit:s,isGeneratingCommitMessage:c,isCommitting:l,onGenerateCommitMessage:u,onCommit:d})=>{let{t:f}=X(`common`),p=e.trim()===``,m=!a||c;return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border bg-background/40 px-4 py-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 xl:flex-row xl:items-center xl:gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 xl:w-56`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:f(`ticketChangesCommitPanel.title`)}),(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 text-xs text-muted-foreground`,children:(0,Z.jsx)(U,{variant:`outline`,children:f(`ticketChangesCommitPanel.selectedFiles`,{count:r})})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(Rs,{"data-disabled":!a,className:`flex-1`,children:[(0,Z.jsx)(Us,{"aria-label":f(`ticketChangesCommitPanel.commitMessageAriaLabel`),id:`ticket-changes-commit-message`,ref:n,value:e,onChange:e=>{t(e.target.value)},placeholder:f(`ticketChangesCommitPanel.commitMessagePlaceholder`),disabled:m,title:i}),p&&(0,Z.jsx)(Bs,{align:`inline-end`,children:(0,Z.jsx)(Hs,{"aria-label":f(`ticketChangesCommitPanel.generateCommitMessageAriaLabel`),disabled:!o,onClick:u,title:i,children:f(c?`ticketChangesCommitPanel.generating`:`ticketChangesCommitPanel.generate`)})})]}),(0,Z.jsxs)(K,{type:`button`,onClick:d,disabled:!s,title:i,className:`w-full gap-2 sm:w-auto sm:min-w-32`,children:[(0,Z.jsx)(kc,{className:`h-4 w-4`}),f(l?`ticketChangesCommitPanel.committing`:`ticketChangesCommitPanel.commit`)]})]})]})})},IG=({isCommitsLoading:e,commitsError:t,unpushedCommits:n,canUndoLatestCommit:r,isUndoing:i,aheadCount:a,onUndoLatestCommit:o})=>{let{t:s}=X(`common`);if(!e&&n.length===0&&!t)return null;let c=n.length||a;return(0,Z.jsxs)(Zs,{children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:s(`ticketChangesCommitsPanel.triggerLabel`)}),(0,Z.jsx)(U,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:c}),(0,Z.jsx)(Oe,{className:`h-4 w-4`})]})}),(0,Z.jsxs)($s,{align:`end`,className:`z-[90] w-[28rem] p-4`,children:[(0,Z.jsxs)(ec,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(tc,{children:s(`ticketChangesCommitsPanel.triggerLabel`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:s(`ticketChangesCommitsPanel.description`)})]}),!e&&!t&&(0,Z.jsx)(U,{variant:`outline`,children:n.length})]}),e?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:s(`ticketChangesCommitsPanel.loading`)}):t?(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,onClick:o,disabled:!r,children:[(0,Z.jsx)(Df,{className:`h-3.5 w-3.5`}),s(i?`ticketChangesCommitsPanel.undoing`:`ticketChangesCommitsPanel.undoLatestCommit`)]})}),(0,Z.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto`,children:n.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.subject}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(U,{variant:`outline`,className:`font-mono`,children:e.short_hash}),(0,Z.jsx)(`span`,{children:new Date(e.committed_at).toLocaleString()})]})]},e.hash))})]})]})]})};function LG(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
138
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),lB&&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]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&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=MB(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=qz(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,-NB),NB),t/=NB,t/Math.abs(t)+Math.round(t*(PB-1)))}shouldForceSelection(e){return aB?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(),FB)}_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&&!(aB&&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]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>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]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<IB&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=vB(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(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(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(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?!1: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=MB(n,this._bufferService.cols)}};RB=OP([kP(3,nF),kP(4,iF),kP(5,gF),kP(6,cF),kP(7,_F),kP(8,hF)],RB);var zB=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={}}},BB=class{constructor(){this._color=new zB,this._css=new zB}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()}},VB=Object.freeze((()=>{let e=[hz.toColor(`#2e3436`),hz.toColor(`#cc0000`),hz.toColor(`#4e9a06`),hz.toColor(`#c4a000`),hz.toColor(`#3465a4`),hz.toColor(`#75507b`),hz.toColor(`#06989a`),hz.toColor(`#d3d7cf`),hz.toColor(`#555753`),hz.toColor(`#ef2929`),hz.toColor(`#8ae234`),hz.toColor(`#fce94f`),hz.toColor(`#729fcf`),hz.toColor(`#ad7fa8`),hz.toColor(`#34e2e2`),hz.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:pz.toCss(r,i,a),rgba:pz.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:pz.toCss(n,n,n),rgba:pz.toRgba(n,n,n)})}return e})()),HB=hz.toColor(`#ffffff`),UB=hz.toColor(`#000000`),WB=hz.toColor(`#ffffff`),GB=UB,KB={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},qB=HB,JB=class extends tI{constructor(e){super(),this._optionsService=e,this._contrastCache=new BB,this._halfContrastCache=new BB,this._onChangeColors=this._register(new EI),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:HB,background:UB,cursor:WB,cursorAccent:GB,selectionForeground:void 0,selectionBackgroundTransparent:KB,selectionBackgroundOpaque:mz.blend(UB,KB),selectionInactiveBackgroundTransparent:KB,selectionInactiveBackgroundOpaque:mz.blend(UB,KB),scrollbarSliderBackground:mz.opacity(HB,.2),scrollbarSliderHoverBackground:mz.opacity(HB,.4),scrollbarSliderActiveBackground:mz.opacity(HB,.5),overviewRulerBorder:HB,ansi:VB.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=YB(e.foreground,HB),t.background=YB(e.background,UB),t.cursor=mz.blend(t.background,YB(e.cursor,WB)),t.cursorAccent=mz.blend(t.background,YB(e.cursorAccent,GB)),t.selectionBackgroundTransparent=YB(e.selectionBackground,KB),t.selectionBackgroundOpaque=mz.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=YB(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=mz.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?YB(e.selectionForeground,fz):void 0,t.selectionForeground===fz&&(t.selectionForeground=void 0),mz.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=mz.opacity(t.selectionBackgroundTransparent,.3)),mz.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=mz.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=YB(e.scrollbarSliderBackground,mz.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=YB(e.scrollbarSliderHoverBackground,mz.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=YB(e.scrollbarSliderActiveBackground,mz.opacity(t.foreground,.5)),t.overviewRulerBorder=YB(e.overviewRulerBorder,qB),t.ansi=VB.slice(),t.ansi[0]=YB(e.black,VB[0]),t.ansi[1]=YB(e.red,VB[1]),t.ansi[2]=YB(e.green,VB[2]),t.ansi[3]=YB(e.yellow,VB[3]),t.ansi[4]=YB(e.blue,VB[4]),t.ansi[5]=YB(e.magenta,VB[5]),t.ansi[6]=YB(e.cyan,VB[6]),t.ansi[7]=YB(e.white,VB[7]),t.ansi[8]=YB(e.brightBlack,VB[8]),t.ansi[9]=YB(e.brightRed,VB[9]),t.ansi[10]=YB(e.brightGreen,VB[10]),t.ansi[11]=YB(e.brightYellow,VB[11]),t.ansi[12]=YB(e.brightBlue,VB[12]),t.ansi[13]=YB(e.brightMagenta,VB[13]),t.ansi[14]=YB(e.brightCyan,VB[14]),t.ansi[15]=YB(e.brightWhite,VB[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=YB(e.extendedAnsi[r],VB[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};JB=OP([kP(0,cF)],JB);function YB(e,t){if(e!==void 0)try{return hz.toColor(e)}catch{}return t}var XB=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},ZB=class{constructor(){this._services=new XB,this._services.set(oF,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=$P(e).sort((e,t)=>e.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)}},QB={trace:0,debug:1,info:2,warn:3,error:4,off:5},$B=`xterm.js: `,eV=class extends tI{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),tV=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=QB[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:$B)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};eV=OP([kP(0,cF)],eV);var tV,nV=class extends tI{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new EI),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new EI),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new EI),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._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<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},rV=3,iV=Object.freeze(new qP),aV=0,oV=2,sV=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*rV);let r=t||YP.fromCharData([0,GP,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*rV+0],n=t&2097151;return[this._data[e*rV+1],t&2097152?this._combined[e]:n?VP(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*rV+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*rV+0]=e|2097152|t[2]<<22):this._data[e*rV+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*rV+0]>>22}hasWidth(e){return this._data[e*rV+0]&12582912}getFg(e){return this._data[e*rV+1]}getBg(e){return this._data[e*rV+2]}hasContent(e){return this._data[e*rV+0]&4194303}getCodePoint(e){let t=this._data[e*rV+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*rV+0]&2097152}getString(e){let t=this._data[e*rV+0];return t&2097152?this._combined[e]:t&2097151?VP(t&2097151):``}isProtected(e){return this._data[e*rV+2]&536870912}loadCell(e,t){return aV=e*rV,t.content=this._data[aV+0],t.fg=this._data[aV+1],t.bg=this._data[aV+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*rV+0]=t.content,this._data[e*rV+1]=t.fg,this._data[e*rV+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*rV+0]=t|n<<22,this._data[e*rV+1]=r.fg,this._data[e*rV+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*rV+0];r&2097152?this._combined[e]+=VP(t):r&2097151?(this._combined[e]=VP(r&2097151)+VP(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*rV+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new YP;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new YP;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*oV<this._data.buffer.byteLength;let n=e*rV;if(e>this.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;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*oV<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*oV<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*rV+0]&4194303)return e+(this._data[e*rV+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*rV+0]&4194303||this._data[e*rV+2]&50331648)return e+(this._data[e*rV+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<rV;e++)this._data[(n+i)*rV+e]=a[(t+i)*rV+e];a[(t+i)*rV+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<rV;e++)this._data[(n+i)*rV+e]=a[(t+i)*rV+e];a[(t+i)*rV+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=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<n;){let e=this._data[t*rV+0],n=e&2097151,a=e&2097152?this._combined[t]:n?VP(n):KP;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function cV(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=fV(u,d,t),p=1,m=0;for(;p<u.length;){let e=fV(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(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 lV(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function uV(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function dV(e,t,n){let r=[],i=e.map((n,r)=>fV(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=fV(e,o,t);a>c&&(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 fV(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 pV=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new EI),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),XF(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};pV._nextId=1;var mV=pV,hV={},gV=hV.B;hV[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},hV.A={"#":`£`},hV.B=void 0,hV[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},hV.C=hV[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},hV.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},hV.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},hV.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},hV.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},hV.E=hV[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},hV.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},hV.H=hV[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},hV[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var _V=4294967295,vV=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=iV.clone(),this.savedCharset=gV,this.markers=[],this._nullCell=YP.fromCharData([0,GP,1,0]),this._whitespaceCell=YP.fromCharData([0,KP,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new mB,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new nV(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 JP),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 JP),this._whitespaceCell}getBlankLine(e,t){return new sV(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&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>_V?_V:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=iV);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 nV(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(iV),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new sV(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new sV(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(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(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<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.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._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)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=cV(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(iV),n);if(r.length>0){let n=lV(this.lines,r);uV(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(iV),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new sV(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(iV),i=[],a=0;for(let o=this.lines.length-1;o>=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&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=dV(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(iV,!0);p.push(e)}p.length>0&&(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--,_=fV(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=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+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new mV(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{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.line<e.index+e.amount&&t.dispose(),t.line>e.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)}},yV=class extends tI{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new EI),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 vV(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new vV(!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)}},bV=2,xV=1,SV=class extends tI{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new EI),this.onResize=this._onResize.event,this._onScroll=this._register(new EI),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,bV),this.rows=Math.max(e.rawOptions.rows||0,xV),this.buffers=this._register(new yV(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))}};SV=OP([kP(0,cF)],SV);var CV={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:aB,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},wV=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],TV=class extends tI{constructor(e){super(),this._onOptionChange=this._register(new EI),this.onOptionChange=this._onOptionChange.event;let t={...CV};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(QF(()=>{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 CV))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in CV))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||=CV[e],!EV(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=CV[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=wV.includes(t)?t:CV[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??={};break}return t}};function EV(e){return e===`block`||e===`underline`||e===`bar`}function DV(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]&&DV(e[r],t-1);return n}var OV=Object.freeze({insertMode:!1}),kV=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),AV=class extends tI{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 EI),this.onData=this._onData.event,this._onUserInput=this._register(new EI),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new EI),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new EI),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=DV(OV),this.decPrivateModes=DV(kV)}reset(){this.modes=DV(OV),this.decPrivateModes=DV(kV)}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))}};AV=OP([kP(0,nF),kP(1,sF),kP(2,cF)],AV);var jV={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 MV(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 NV=String.fromCharCode,PV={DEFAULT:e=>{let t=[MV(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${NV(t[0])}${NV(t[1])}${NV(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${MV(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${MV(e,!0)};${e.x};${e.y}${t}`}},FV=class extends tI{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 EI),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(jV))this.addProtocol(e,jV[e]);for(let e of Object.keys(PV))this.addEncoding(e,PV[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)}};FV=OP([kP(0,nF),kP(1,iF),kP(2,cF)],FV);var IV=[[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]],LV=[[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]],RV;function zV(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var BV=class{constructor(){if(this.version=`6`,!RV){RV=new Uint8Array(65536),RV.fill(1),RV[0]=0,RV.fill(0,1,32),RV.fill(0,127,160),RV.fill(2,4352,4448),RV[9001]=2,RV[9002]=2,RV.fill(2,11904,42192),RV[12351]=1,RV.fill(2,44032,55204),RV.fill(2,63744,64256),RV.fill(2,65040,65050),RV.fill(2,65072,65136),RV.fill(2,65280,65377),RV.fill(2,65504,65511);for(let e=0;e<IV.length;++e)RV.fill(0,IV[e][0],IV[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?RV[e]:zV(e,LV)?0: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=VV.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return VV.createPropertyValue(0,n,r)}},VV=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new EI,this.onChange=this._onChange.event;let e=new BV;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}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;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++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)}},HV=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 UV(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 WV=2147483647,GV=256,KV=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>GV)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<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>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>WV?WV: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>WV?WV: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<this.length;++t){let n=this._subParamsIdx[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,WV):e}},qV=[],JV=class{constructor(){this._state=0,this._active=qV,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=qV}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=qV,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||qV,!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`,HP(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(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&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=qV,this._id=-1,this._state=0}}},YV=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+=HP(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}},XV=[],ZV=class{constructor(){this._handlers=Object.create(null),this._active=XV,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=XV}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=XV,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||XV,!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`,HP(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=XV,this._ident=0}},QV=new KV;QV.addParam(0);var $V=class{constructor(e){this._handler=e,this._data=``,this._params=QV,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():QV,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=HP(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=QV,this._data=``,this._hitLimit=!1,e));return this._params=QV,this._data=``,this._hitLimit=!1,t}},eH=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;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},tH=160,nH=function(){let e=new eH(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),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(tH,0,2,0),e.add(tH,8,5,8),e.add(tH,6,0,6),e.add(tH,11,0,11),e.add(tH,13,13,13),e}(),rH=class extends tI{constructor(e=nH){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 KV,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(QF(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new JV),this._dcsParser=this._register(new ZV),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;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||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;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:tH)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<tH){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<tH){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<tH){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<tH){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=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(++n<t&&(r=e[n])>47&&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<tH){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<tH){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},iH=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,aH=/^[\da-f]+$/;function oH(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=iH.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),aH.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function sH(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 cH(e,t=16){let[n,r,i]=e;return`rgb:${sH(n,t)}/${sH(r,t)}/${sH(i,t)}`}var lH={"(":0,")":1,"*":2,"+":3,"-":1,".":2},uH=131072,dH=10;function fH(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 pH=5e3,mH=0,hH=class extends tI{constructor(e,t,n,r,i,a,o,s,c=new rH){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 UP,this._utf8Decoder=new WP,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=iV.clone(),this._eraseAttrDataInternal=iV.clone(),this._onRequestBell=this._register(new EI),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new EI),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new EI),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new EI),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new EI),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new EI),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new EI),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new EI),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new EI),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new EI),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new EI),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new EI),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new EI),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 gH(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($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(az.IND,()=>this.index()),this._parser.setExecuteHandler(az.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(az.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new YV(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new YV(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new YV(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new YV(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new YV(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new YV(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new YV(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new YV(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new YV(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new YV(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new YV(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new YV(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 hV)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 $V((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`),pH))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${pH} 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>uH&&(a=this._parseStack.position+uH)}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.length<e.length&&this._parseBuffer.length<uH&&(this._parseBuffer=new Uint32Array(Math.min(e.length,uH))),o||this._dirtyRowTracker.clearRange(),e.length>uH)for(let t=a;t<e.length;t+=uH){let a=t+uH<e.length?t+uH:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&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;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=VV.extractWidth(t);let n=VV.extractShouldJoin(t),m=n?VV.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(VP(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){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 sV&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=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.x<s&&n-t>0&&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=>fH(e.params[0],this._optionsService.rawOptions.windowOptions)?t(e):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new $V(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new YV(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.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=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));break}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);break}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.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(iV));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=VV.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,gV),this._charsetService.setgCharset(1,gV),this._charsetService.setgCharset(2,gV),this._charsetService.setgCharset(3,gV);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(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(`${$.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|=qP.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<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=iV.fg,e.bg=iV.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<t;i++)n=e.params[i],n>=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|=iV.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=iV.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|=iV.fg&16777215,r.bg&=-67108864,r.bg|=iV.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}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=iV.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`;break}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(!fH(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(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>dH&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>dH&&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());break}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(_H(n))if(r===`?`)t.push({type:0,index:n});else{let e=oH(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()?!1: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<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=oH(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<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);_H(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,gV),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(lH[e[0]],hV[e[1]]||gV),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),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._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=iV.clone(),this._eraseAttrDataInternal=iV.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 YP;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.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)}},gH=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(mH=e,e=t,t=mH),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};gH=OP([kP(0,nF)],gH);function _H(e){return 0<=e&&e<256}var vH=5e7,yH=12,bH=50,xH=class extends tI{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 EI),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>vH)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>=yH?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>=yH)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>bH&&(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()}},SH=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)))}};SH=OP([kP(0,nF)],SH);var CH=!1,wH=class extends tI{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new nI),this._onBinary=this._register(new EI),this.onBinary=this._onBinary.event,this._onData=this._register(new EI),this.onData=this._onData.event,this._onLineFeed=this._register(new EI),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new EI),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new EI),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new EI),this._instantiationService=new ZB,this.optionsService=this._register(new TV(e)),this._instantiationService.setService(cF,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(SV)),this._instantiationService.setService(nF,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(eV)),this._instantiationService.setService(sF,this._logService),this.coreService=this._register(this._instantiationService.createInstance(AV)),this._instantiationService.setService(iF,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(FV)),this._instantiationService.setService(rF,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(VV)),this._instantiationService.setService(uF,this.unicodeService),this._charsetService=this._instantiationService.createInstance(HV),this._instantiationService.setService(aF,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(SH),this._instantiationService.setService(lF,this._oscLinkService),this._inputHandler=this._register(new hH(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(fI.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(fI.forward(this._bufferService.onResize,this._onResize)),this._register(fI.forward(this.coreService.onData,this._onData)),this._register(fI.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 xH((e,t)=>this._inputHandler.parse(e,t))),this._register(fI.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new EI),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&&!CH&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),CH=!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,bV),t=Math.max(t,xV),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(UV.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(UV(this._bufferService),!1))),this._windowsWrappingHeuristics.value=QF(()=>{for(let t of e)t.dispose()})}}},TH={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 EH(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`?t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`D`:t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`C`:t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`A`:t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`B`:t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:a?i.key=$.ESC+`[3;`+(a+1)+`~`:i.key=$.ESC+`[3~`;break;case 36:a?i.key=$.ESC+`[1;`+(a+1)+`H`:t?i.key=$.ESC+`OH`:i.key=$.ESC+`[H`;break;case 35:a?i.key=$.ESC+`[1;`+(a+1)+`F`:t?i.key=$.ESC+`OF`:i.key=$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=$.ESC+`[5;`+(a+1)+`~`:i.key=$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=$.ESC+`[6;`+(a+1)+`~`:i.key=$.ESC+`[6~`;break;case 112:a?i.key=$.ESC+`[1;`+(a+1)+`P`:i.key=$.ESC+`OP`;break;case 113:a?i.key=$.ESC+`[1;`+(a+1)+`Q`:i.key=$.ESC+`OQ`;break;case 114:a?i.key=$.ESC+`[1;`+(a+1)+`R`:i.key=$.ESC+`OR`;break;case 115:a?i.key=$.ESC+`[1;`+(a+1)+`S`:i.key=$.ESC+`OS`;break;case 116:a?i.key=$.ESC+`[15;`+(a+1)+`~`:i.key=$.ESC+`[15~`;break;case 117:a?i.key=$.ESC+`[17;`+(a+1)+`~`:i.key=$.ESC+`[17~`;break;case 118:a?i.key=$.ESC+`[18;`+(a+1)+`~`:i.key=$.ESC+`[18~`;break;case 119:a?i.key=$.ESC+`[19;`+(a+1)+`~`:i.key=$.ESC+`[19~`;break;case 120:a?i.key=$.ESC+`[20;`+(a+1)+`~`:i.key=$.ESC+`[20~`;break;case 121:a?i.key=$.ESC+`[21;`+(a+1)+`~`:i.key=$.ESC+`[21~`;break;case 122:a?i.key=$.ESC+`[23;`+(a+1)+`~`:i.key=$.ESC+`[23~`;break;case 123:a?i.key=$.ESC+`[24;`+(a+1)+`~`:i.key=$.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=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=TH[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.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=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.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=$.US),e.key===`@`&&(i.key=$.NUL));break}return i}var DH=0,OH=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new mB,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new mB,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<r.length;i++)n>=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||(DH=this._search(t),DH===-1)||this._getKey(this._array[DH])!==t)return!1;do if(this._array[DH]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(DH),!0;while(++DH<this._array.length&&this._getKey(this._array[DH])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(DH=this._search(e),!(DH<0||DH>=this._array.length)&&this._getKey(this._array[DH])===e))do yield this._array[DH];while(++DH<this._array.length&&this._getKey(this._array[DH])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(DH=this._search(e),!(DH<0||DH>=this._array.length)&&this._getKey(this._array[DH])===e))do t(this._array[DH]);while(++DH<this._array.length&&this._getKey(this._array[DH])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},kH=0,AH=0,jH=class extends tI{constructor(){super(),this._decorations=new OH(e=>e?.marker.line),this._onDecorationRegistered=this._register(new EI),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new EI),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(QF(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new MH(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<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{kH=t.options.x??0,AH=kH+(t.options.width??1),e>=kH&&e<AH&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},MH=class extends eI{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new EI),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new EI),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=hz.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=hz.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},NH=1e3,PH=class{constructor(e,t=NH){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}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);let r=performance.now();if(r-this._lastRefreshMs>=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)}},FH=20,IH=!1,LH=class extends tI{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;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._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 PH(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);IH?(this._accessibilityContainer.classList.add(`debug`),this._rowContainer.classList.add(`debug`),this._debugRootContainer=i.createElement(`div`),this._debugRootContainer.classList.add(`xterm`),this._debugRootContainer.appendChild(i.createTextNode(`------start a11y------`)),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode(`------end a11y------`)),this._terminal.element.insertAdjacentElement(`afterend`,this._debugRootContainer)):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(`
|
|
139
|
+
`))),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(aR(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(QF(()=>{IH?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<FH+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
140
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===FH+1&&(this._liveRegion.textContent+=NP.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<i.length?i[t]:i.slice(-1)[0]+1;return a>=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;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)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<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};LH=OP([kP(1,oF),kP(2,hF),kP(3,_F)],LH);var RH=class extends tI{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new EI),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new EI),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(QF(()=>{XF(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(aR(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(aR(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(aR(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(aR(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<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(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;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?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;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._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&&zH(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,XF(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?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!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}}};RH=OP([kP(1,gF),kP(2,_F),kP(3,nF),kP(4,xF)],RH);function zH(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 BH=class extends wH{constructor(e={}){super(e),this._linkifier=this._register(new nI),this.browser=Zz,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new nI),this._onCursorMove=this._register(new EI),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new EI),this.onKey=this._onKey.event,this._onRender=this._register(new EI),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new EI),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new EI),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new EI),this.onBell=this._onBell.event,this._onFocus=this._register(new EI),this._onBlur=this._register(new EI),this._onA11yCharEmitter=this._register(new EI),this._onA11yTabEmitter=this._register(new EI),this._onWillOpen=this._register(new EI),this._setup(),this._decorationService=this._instantiationService.createInstance(jH),this._instantiationService.setService(dF,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Kz),this._instantiationService.setService(xF,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(fF)),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(fI.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(fI.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(fI.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(fI.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(QF(()=>{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=mz.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${cH(r)}${oz.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=pz.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=pz.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_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(LH,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.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($.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(aR(this.element,`copy`,e=>{this.hasSelection()&&IP(e,this._selectionService)}));let e=e=>LP(e,this.textarea,this.coreService,this.optionsService);this._register(aR(this.textarea,`paste`,e)),this._register(aR(this.element,`paste`,e)),tB?this._register(aR(this.element,`mousedown`,e=>{e.button===2&&BP(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(aR(this.element,`contextmenu`,e=>{BP(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),lB&&this._register(aR(this.element,`auxclick`,e=>{e.button===1&&zP(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(aR(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(aR(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(aR(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(aR(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(aR(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(aR(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(aR(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(aR(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`,jP.get()),uB||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(Wz,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(hF,this._coreBrowserService),this._register(aR(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(aR(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Bz,this._document,this._helperContainer),this._instantiationService.setService(mF,this._charSizeService),this._themeService=this._instantiationService.createInstance(JB),this._instantiationService.setService(bF,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(xz),this._instantiationService.setService(yF,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(gB,this.rows,this.screenElement)),this._instantiationService.setService(_F,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(sz,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Yz),this._instantiationService.setService(gF,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(RH,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(QR,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(RB,this.element,this.screenElement,r)),this._instantiationService.setService(vF,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(fI.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance($R,this.screenElement)),this._register(aR(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(LH,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(iz,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(iz,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zz,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(aR(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(aR(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=$.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){RP(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=EH(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===$.ETX||n.key===$.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)&&(VH(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<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(iV));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function VH(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var HH=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-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._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},UH=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new YP)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},WH=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 UH(t)}getNullCell(){return new YP}},GH=class extends tI{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new EI),this.onBufferChange=this._onBufferChange.event,this._normal=new WH(this._core.buffers.normal,`normal`),this._alternate=new WH(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)}},KH=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)}},qH=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}},JH=[`cols`,`rows`],YH=0,XH=class extends tI{constructor(e){super(),this._core=this._register(new BH(e)),this._addonManager=this._register(new HH),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(JH.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 KH(this._core),this._parser}get unicode(){return this._checkProposedApi(),new qH(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 GH(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`;break}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
|
|
141
|
+
`,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 jP.get()},set promptLabel(e){jP.set(e)},get tooMuchOutput(){return NP.get()},set tooMuchOutput(e){NP.set(e)}}}_verifyIntegers(...e){for(YH of e)if(YH===1/0||isNaN(YH)||YH%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(YH of e)if(YH&&(YH===1/0||isNaN(YH)||YH%1!=0||YH<0))throw Error(`This API only accepts positive integers`)}},ZH=Object.create(null);ZH.open=`0`,ZH.close=`1`,ZH.ping=`2`,ZH.pong=`3`,ZH.message=`4`,ZH.upgrade=`5`,ZH.noop=`6`;var QH=Object.create(null);Object.keys(ZH).forEach(e=>{QH[ZH[e]]=e});var $H={type:`error`,data:`parser error`},eU=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,tU=typeof ArrayBuffer==`function`,nU=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,rU=({type:e,data:t},n,r)=>eU&&t instanceof Blob?n?r(t):iU(t,r):tU&&(t instanceof ArrayBuffer||nU(t))?n?r(t):iU(new Blob([t]),r):r(ZH[e]+(t||``)),iU=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function aU(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var oU;function sU(e,t){if(eU&&e.data instanceof Blob)return e.data.arrayBuffer().then(aU).then(t);if(tU&&(e.data instanceof ArrayBuffer||nU(e.data)))return t(aU(e.data));rU(e,!1,e=>{oU||=new TextEncoder,t(oU.encode(e))})}var cU=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,lU=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)lU[cU.charCodeAt(e)]=e;var uU=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=lU[e.charCodeAt(r)],o=lU[e.charCodeAt(r+1)],s=lU[e.charCodeAt(r+2)],c=lU[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},dU=typeof ArrayBuffer==`function`,fU=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:mU(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:pU(e.substring(1),t)}:QH[n]?e.length>1?{type:QH[n],data:e.substring(1)}:{type:QH[n]}:$H},pU=(e,t)=>dU?mU(uU(e),t):{base64:!0,data:e},mU=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},hU=``,gU=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{rU(e,!1,e=>{r[a]=e,++i===n&&t(r.join(hU))})})},_U=(e,t)=>{let n=e.split(hU),r=[];for(let e=0;e<n.length;e++){let i=fU(n[e],t);if(r.push(i),i.type===`error`)break}return r};function vU(){return new TransformStream({transform(e,t){sU(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var yU;function bU(e){return e.reduce((e,t)=>e+t.length,0)}function xU(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function SU(e,t){yU||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(bU(n)<1)break;let e=xU(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(bU(n)<2)break;let e=xU(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(bU(n)<8)break;let e=xU(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue($H);break}i=a*2**32+t.getUint32(4),r=3}else{if(bU(n)<i)break;let e=xU(n,i);s.enqueue(fU(a?e:yU.decode(e),t)),r=0}if(i===0||i>e){s.enqueue($H);break}}}})}function CU(e){if(e)return wU(e)}function wU(e){for(var t in CU.prototype)e[t]=CU.prototype[t];return e}CU.prototype.on=CU.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},CU.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},CU.prototype.off=CU.prototype.removeListener=CU.prototype.removeAllListeners=CU.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},CU.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},CU.prototype.emitReserved=CU.prototype.emit,CU.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},CU.prototype.hasListeners=function(e){return!!this.listeners(e).length};var TU=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),EU=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),DU=`arraybuffer`;function OU(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var kU=EU.setTimeout,AU=EU.clearTimeout;function jU(e,t){t.useNativeTimers?(e.setTimeoutFn=kU.bind(EU),e.clearTimeoutFn=AU.bind(EU)):(e.setTimeoutFn=EU.setTimeout.bind(EU),e.clearTimeoutFn=EU.clearTimeout.bind(EU))}var MU=1.33;function NU(e){return typeof e==`string`?PU(e):Math.ceil((e.byteLength||e.size)*MU)}function PU(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function FU(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function IU(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function LU(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var RU=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},zU=class extends CU{constructor(e){super(),this.writable=!1,jU(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new RU(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=fU(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=IU(e);return t.length?`?`+t:``}},BU=class extends zU{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){_U(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,gU(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=FU()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},VU=!1;try{VU=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var HU=VU;function UU(){}var WU=class extends BU{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},GU=class e extends CU{constructor(e,t,n){super(),this.createRequest=e,jU(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=OU(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=UU,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(GU.requestsCount=0,GU.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,KU);else if(typeof addEventListener==`function`){let e=`onpagehide`in EU?`pagehide`:`unload`;addEventListener(e,KU,!1)}}function KU(){for(let e in GU.requests)GU.requests.hasOwnProperty(e)&&GU.requests[e].abort()}var qU=(function(){let e=YU({xdomain:!1});return e&&e.responseType!==null})(),JU=class extends WU{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=qU&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new GU(YU,this.uri(),e)}};function YU(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||HU))return new XMLHttpRequest}catch{}if(!t)try{return new EU[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var XU=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,ZU=class extends zU{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=XU?{}:OU(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;rU(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&TU(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=FU()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},QU=EU.WebSocket||EU.MozWebSocket,$U={websocket:class extends ZU{createSocket(e,t,n){return XU?new QU(e,t,n):t?new QU(e,t):new QU(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends zU{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=SU(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=vU();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&TU(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:JU},eW=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,tW=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function nW(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=eW.exec(e||``),a={},o=14;for(;o--;)a[tW[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=rW(a,a.path),a.queryKey=iW(a,a.query),a}function rW(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function iW(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var aW=typeof addEventListener==`function`&&typeof removeEventListener==`function`,oW=[];aW&&addEventListener(`offline`,()=>{oW.forEach(e=>e())},!1);var sW=class e extends CU{constructor(e,t){if(super(),this.binaryType=DU,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=nW(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=nW(t.host).host);jU(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=LU(this.opts.query)),aW&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},oW.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=NU(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,TU(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),aW&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=oW.indexOf(this._offlineEventListener);e!==-1&&oW.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};sW.protocol=4;var cW=class extends sW{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;sW.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;sW.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},lW=class extends cW{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>$U[e]).filter(e=>!!e)),super(e,n)}};lW.protocol;function uW(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=nW(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var dW=typeof ArrayBuffer==`function`,fW=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,pW=Object.prototype.toString,mW=typeof Blob==`function`||typeof Blob<`u`&&pW.call(Blob)===`[object BlobConstructor]`,hW=typeof File==`function`||typeof File<`u`&&pW.call(File)===`[object FileConstructor]`;function gW(e){return dW&&(e instanceof ArrayBuffer||fW(e))||mW&&e instanceof Blob||hW&&e instanceof File}function _W(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(_W(e[t]))return!0;return!1}if(gW(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return _W(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&_W(e[t]))return!0;return!1}function vW(e){let t=[],n=e.data,r=e;return r.data=yW(n,t),r.attachments=t.length,{packet:r,buffers:t}}function yW(e,t){if(!e)return e;if(gW(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=yW(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=yW(e[r],t));return n}return e}function bW(e,t){return e.data=xW(e.data,t),delete e.attachments,e}function xW(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=xW(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=xW(e[n],t));return e}var SW=r({Decoder:()=>EW,Encoder:()=>TW,PacketType:()=>wW,isPacketValid:()=>NW,protocol:()=>5}),CW=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],wW;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(wW||={});var TW=class{constructor(e){this.replacer=e}encode(e){return(e.type===wW.EVENT||e.type===wW.ACK)&&_W(e)?this.encodeAsBinary({type:e.type===wW.EVENT?wW.BINARY_EVENT:wW.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===wW.BINARY_EVENT||e.type===wW.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=vW(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},EW=class e extends CU{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===wW.BINARY_EVENT;n||t.type===wW.BINARY_ACK?(t.type=n?wW.EVENT:wW.ACK,this.reconstructor=new DW(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(gW(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(wW[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===wW.BINARY_EVENT||r.type===wW.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!kW(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case wW.CONNECT:return jW(t);case wW.DISCONNECT:return t===void 0;case wW.CONNECT_ERROR:return typeof t==`string`||jW(t);case wW.EVENT:case wW.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&CW.indexOf(t[0])===-1);case wW.ACK:case wW.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},DW=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=bW(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function OW(e){return typeof e==`string`}var kW=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function AW(e){return e===void 0||kW(e)}function jW(e){return Object.prototype.toString.call(e)===`[object Object]`}function MW(e,t){switch(e){case wW.CONNECT:return t===void 0||jW(t);case wW.DISCONNECT:return t===void 0;case wW.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&CW.indexOf(t[0])===-1);case wW.ACK:return Array.isArray(t);case wW.CONNECT_ERROR:return typeof t==`string`||jW(t);default:return!1}}function NW(e){return OW(e.nsp)&&AW(e.id)&&MW(e.type,e.data)}function PW(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var FW=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),IW=class extends CU{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[PW(e,`open`,this.onopen.bind(this)),PW(e,`packet`,this.onpacket.bind(this)),PW(e,`error`,this.onerror.bind(this)),PW(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(FW.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:wW.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:wW.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case wW.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case wW.EVENT:case wW.BINARY_EVENT:this.onevent(e);break;case wW.ACK:case wW.BINARY_ACK:this.onack(e);break;case wW.DISCONNECT:this.ondisconnect();break;case wW.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:wW.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:wW.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function LW(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}LW.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},LW.prototype.reset=function(){this.attempts=0},LW.prototype.setMin=function(e){this.ms=e},LW.prototype.setMax=function(e){this.max=e},LW.prototype.setJitter=function(e){this.jitter=e};var RW=class extends CU{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,jU(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new LW({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||SW;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new lW(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=PW(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=PW(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(PW(e,`ping`,this.onping.bind(this)),PW(e,`data`,this.ondata.bind(this)),PW(e,`error`,this.onerror.bind(this)),PW(e,`close`,this.onclose.bind(this)),PW(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){TU(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new IW(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},zW={};function BW(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=uW(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=zW[i]&&a in zW[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new RW(r,t):(zW[i]||(zW[i]=new RW(r,t)),c=zW[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(BW,{Manager:RW,Socket:IW,io:BW,connect:BW});var VW=((e=Te)=>BW(e))(),HW=({label:e,onClick:t,children:n})=>(0,Z.jsx)(K,{type:`button`,"aria-label":e,onClick:t,variant:`outline`,size:`icon-sm`,className:`bg-secondary/60`,children:n}),UW=({exitCode:e,signal:t})=>t>0?`[archon] Shell exited with signal ${t}`:`[archon] Shell exited with code ${e}`,WW=({createSession:e,isExpanded:t,isVisible:n,onClose:r,onToggleExpanded:i,className:a=``,ariaLabel:o=`Terminal`,title:s=`Terminal`,closeLabel:c=`Close terminal`,headerMeta:l})=>{let u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=(0,Y.useRef)(e),h=(0,Y.useRef)(!1),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!0);return(0,Y.useEffect)(()=>{m.current=e},[e]),(0,Y.useEffect)(()=>{if(!u.current)return;let e=new XH({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,fontSize:13,theme:{background:`#0b0d14`,foreground:`#d8deef`,cursor:`#c4b5fd`}}),t=new wP,n=null,r=!1;e.loadAddon(t),e.open(u.current),d.current=e,f.current=t;let i=()=>{let e=p.current;!e||h.current||(h.current=!0,ST(e))};window.addEventListener(`pagehide`,i),window.addEventListener(`beforeunload`,i);let a=()=>{p.current&&VW.emit(`terminal:resize`,{sessionId:p.current,cols:e.cols,rows:e.rows})},o=()=>{!u.current||r||(t.fit(),a())},s=t=>{t.sessionId===p.current&&(y(!1),window.setTimeout(()=>{o(),e.focus()},0))},c=t=>{t.sessionId===p.current&&(y(!1),e.write(t.data))},l=t=>{t.sessionId===p.current&&(e.writeln(``),e.writeln(UW(t)))},g=t=>{t.sessionId&&t.sessionId!==p.current||(y(!1),_(t.message),e.writeln(``),e.writeln(`[archon] ${t.message}`))};VW.on(`terminal:ready`,s),VW.on(`terminal:data`,c),VW.on(`terminal:exit`,l),VW.on(`terminal:error`,g);let v=e.onData(e=>{p.current&&VW.emit(`terminal:input`,{sessionId:p.current,input:e})});return typeof ResizeObserver==`function`&&(n=new ResizeObserver(()=>{o()}),n.observe(u.current)),window.setTimeout(()=>{o()},0),m.current().then(e=>{r||(p.current=e.session_id,VW.emit(`terminal:join`,{sessionId:e.session_id}))}).catch(t=>{if(r)return;y(!1);let n=t instanceof Error?t.message:`Unable to open the terminal right now.`;_(n),e.writeln(``),e.writeln(`[archon] ${n}`)}),()=>{r=!0,window.removeEventListener(`pagehide`,i),window.removeEventListener(`beforeunload`,i),p.current&&(h.current||VW.emit(`terminal:destroy`,{sessionId:p.current})),n?.disconnect(),v.dispose(),VW.off(`terminal:ready`,s),VW.off(`terminal:data`,c),VW.off(`terminal:exit`,l),VW.off(`terminal:error`,g),e.dispose(),d.current=null,f.current=null,p.current=null}},[]),(0,Y.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{f.current?.fit(),d.current&&p.current&&(VW.emit(`terminal:resize`,{sessionId:p.current,cols:d.current.cols,rows:d.current.rows}),d.current.focus())},0);return()=>{window.clearTimeout(e)}},[t,n]),(0,Z.jsxs)(mu,{"aria-label":o,"data-terminal-pane":`true`,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden rounded-xl border-border bg-[#0c1119] ${a}`.trim(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border bg-card/80 px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,Z.jsx)(Pc,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),l&&(0,Z.jsx)(`div`,{className:`mt-1 min-w-0 text-xs text-muted-foreground`,children:l})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v&&!g&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Opening terminal...`}),g&&(0,Z.jsx)(`span`,{className:`max-w-56 truncate text-xs text-red-300`,children:g}),(0,Z.jsx)(HW,{label:t?`Collapse terminal`:`Expand terminal`,onClick:i,children:t?(0,Z.jsx)(gf,{className:`h-4 w-4`}):(0,Z.jsx)(_f,{className:`h-4 w-4`})}),(0,Z.jsx)(HW,{label:c,onClick:r,children:(0,Z.jsx)(Be,{className:`h-4 w-4`})})]})]}),(0,Z.jsx)(`div`,{ref:u,"data-testid":`terminal-viewport`,onClick:()=>d.current?.focus(),className:`min-h-0 flex-1 overflow-hidden bg-[#0b0d14] pb-4`})]})},GW=({actions:e,activeAction:t=null,disableWhenActive:n=!1,className:r,heading:i,headingClassName:a,actionsClassName:o,showDisabledReason:s=!1,disabledReasonClassName:c,error:l,errorClassName:u,leadingContent:d,renderAction:f})=>{if(e.length===0&&!d)return null;let p=e.find(e=>e.disabled&&e.disabledReason)?.disabledReason??null;return(0,Z.jsxs)(`div`,{className:r,children:[i&&(0,Z.jsx)(`div`,{className:a,children:i}),(0,Z.jsxs)(`div`,{className:o,children:[d,e.map(e=>{let r=t===e.id,i=e.disabled||n&&t!==null;return f({action:e,label:r?e.pendingLabel:e.label,disabled:i,title:e.disabledReason??e.title,ariaLabel:e.ariaLabel})})]}),s&&p&&(0,Z.jsx)(`p`,{className:c,children:p}),l&&(0,Z.jsx)(`p`,{className:u,children:l})]})},KW=({id:e,label:t,pendingLabel:n,ariaLabel:r=t,title:i,disabled:a=!1,disabledReason:o=null})=>({id:e,label:t,pendingLabel:n,ariaLabel:r,title:i,disabled:a,disabledReason:o}),qW=(e,t={})=>{let{isEditing:n=!1,includePlanAdvance:r=!0,hideAdvanceWhenBlocked:i=!1,hasOpenBlockers:a=!1,canRun:o=!0,canStopRun:s=!0,canPauseBuild:c=!0,canResumeBuild:l=!0,runDisabled:u=!1,runDisabledReason:d,buildLabel:f=`Build`,reviewLabel:p=`Review`}=t,m=Sw(e.state),h=m?Nw(e,m):!1,g=Pw(e),_=e.bundle?.branch??e.branch,v=e.has_worktree??!!_,y=e.worktree_bundle_id!==null,b=e.state===`plan`&&e.agent_status===`running`,x=d??(e.has_run_config===!1?`No run config is available for this project.`:null),S=[];return r&&e.state===`plan`&&!e.parked_at&&S.push(KW({id:`build`,label:f,pendingLabel:`Building...`,ariaLabel:f,disabled:!h,disabledReason:g})),e.state===`build`&&!e.parked_at&&!(i&&a)&&S.push(KW({id:`review`,label:p,pendingLabel:`Starting review...`,ariaLabel:p,disabled:!h,disabledReason:g})),_&&v&&!b&&!n&&!y&&e.is_running!==!0&&o&&S.push(KW({id:`run`,label:`Run`,pendingLabel:`Starting run...`,ariaLabel:`Run`,disabled:u||!!x,disabledReason:x,title:u?x??`Stop the currently running ticket before starting another run.`:void 0})),_&&!n&&!y&&e.is_running===!0&&s&&S.push(KW({id:`stop-run`,label:`Stop Run`,pendingLabel:`Stopping run...`,ariaLabel:`Stop Run`,title:`Stop the currently running ticket.`,disabled:!1,disabledReason:null})),!n&&Tw(e)&&e.agent_status===`running`&&e.session_id&&c&&S.push(KW({id:`pause-build`,label:`Pause Build`,pendingLabel:`Pausing build...`,ariaLabel:`Pause Build`,title:`Pause the build session. You can resume it later.`,disabled:!1,disabledReason:null})),!n&&Tw(e)&&e.agent_status===`stopped`&&e.session_id&&l&&S.push(KW({id:`resume-build`,label:`Resume`,pendingLabel:`Resuming build...`,ariaLabel:`Resume`,disabled:!1,disabledReason:null})),S},JW=(e,t={})=>{let n=e.state===`plan`,r=e.bundle?.branch??e.branch,i=e.has_worktree??!!r;return{isPlan:n,hasWorktree:i,disabledReason:e.agent_status===`running`?n?`Wait for planning to finish before sending another message.`:`Wait for the current build to finish before sending a follow-up prompt.`:t.requireWorktree===!0&&!n&&!i?`Worktree not ready yet.`:null,heading:n?`Planning follow-up`:`Ticket follow-up`,description:n?`Ask the agent to refine this plan.`:`Send a follow-up prompt for this ticket.`,placeholder:n?`Ask the agent to refine this plan...`:`Send a follow-up for this ticket...`}},YW=(e,t,n={})=>{let r=e.tool===`opencode`||n.persistPlanSettings===!0,i=r&&t.model?t.model:null,a=r&&t.model&&t.variant?t.variant:null,o=r?t.skills:[],s=e.skills??[],c=o.length!==s.length||o.some((e,t)=>e!==s[t]);return{model:i,variant:a,skills:o,shouldPersist:r&&(i!==e.model||a!==e.variant||c)}},XW=`modulepreload`,ZW=function(e){return`/`+e},QW={},$W=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ZW(t,n),t in QW)return;QW[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:XW,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},eG=(0,Y.lazy)(()=>$W(()=>Promise.resolve().then(()=>uJ).then(e=>({default:e.TicketChangesModal})),void 0)),tG=(0,Y.lazy)(()=>$W(()=>import(`./TestsDialog-uqH8RzXV.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),nG=`(min-width: 1280px)`,rG=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches,iG=e=>{let[t,n]=(0,Y.useState)(()=>rG(e));return(0,Y.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>{n(t.matches)};return r(),t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}},[e]),t},aG=({onClose:e})=>{let{t}=X(`common`);return(0,Z.jsx)(du,{onClose:e,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-full w-full max-w-none items-center justify-center rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:t(`ticketModal.loadingDiff`)})})},oG=({ariaLabel:e,title:t,closeAriaLabel:n,className:r,showTopSpacer:i=!0,description:a,onClose:o,...s})=>(0,Z.jsxs)(`aside`,{className:`min-h-0 flex flex-col gap-3 overflow-hidden${r?` ${r}`:``}`,"aria-label":e,children:[i?(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`h-9 shrink-0`}):null,(0,Z.jsx)(HN,{...s,header:({showThinkingControl:e})=>(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:t}),e]}),a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:a}):null]}),(0,Z.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n,onClick:o,children:(0,Z.jsx)(Be,{className:`h-4 w-4`})})]})})]}),sG=(e,t)=>e?t.find(t=>t.id===e)?.label??e:null,cG=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectTestCommands:i=[],showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],projectBranchState:c=null,projectMemoryEnabled:l=!1,runDisabled:u=!1,runDisabledReason:d,onClose:f,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onUpdate:g,onDeleteDependency:_,onAdvance:v,onBuildChain:y,onRun:b,onOpenIde:x,onStop:S,onStopBuild:C,onStopBuildChain:w,onResumeBuild:T,onFollowUp:E,onRequestTicketRefresh:D,onProjectMemorySuggestionsChanged:O})=>{let{t:k}=X(`common`),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)(!1),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,ee]=(0,Y.useState)(!1),[te,ne]=(0,Y.useState)(!1),[V,re]=(0,Y.useState)(``),[H,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(0),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(!1),[he,ge]=(0,Y.useState)(null),W=A??e,[_e,ve]=(0,Y.useState)(W.model??``),[ye,be]=(0,Y.useState)(W.variant??``),[G,xe]=(0,Y.useState)(W.skills??[]),[Se,Ce]=(0,Y.useState)(()=>sG(W.model,o)??`Agent`),we=(0,Y.useRef)(W.id),Te=(0,Y.useRef)(null),Ee=(0,Y.useRef)(null),De=(0,Y.useRef)(!1),Oe=(0,Y.useRef)(W.id),ke=(0,Y.useRef)(W.build_completed_at),Ae=iG(nG),[je,Me]=(0,Y.useState)(!1),[Ne,Pe]=(0,Y.useState)({model:W.model,variant:W.variant,skills:W.skills??[]}),Fe=W.state===`plan`,Ie=Cw(W.state),Le=W.worktree_bundle_id!==null,Re=Fe&&W.agent_status===`running`,ze=Fe&&W.agent_status===`error`,Be=Fe&&!Re||M,Ve=async e=>{let t=await Yt(W.id,W.project_id,e);return j(t),g?.(t),h&&await h(),t},He=async e=>{try{await Ve(e),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Ue=async e=>{try{if(await Ve(e),!v){f();return}await v(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},We=async()=>{!v||it?.disabled||(await v(),f())},Ge=e=>{if(e===`review`){We();return}if(e===`run`){b?.();return}if(e===`stop-run`){S?.();return}if(e===`pause-build`){C?.();return}e===`resume-build`&&T?.()},Ke=async e=>{try{if(await Ve(e),!y){f();return}await y(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},qe=Fe?W.planning_session_id:W.session_id,Je=qe?qe.startsWith(`ses_`)?`opencode --session ${qe}`:`claude --resume ${qe}`:null,Ye=W.bundle?.branch??W.branch,Xe=W.has_worktree??!!Ye,Ze=`Stop Build Chain`,Qe=new Map(t.map(e=>[e.id,e])),$e=n.filter(e=>e.blocker_ticket_id===W.id),et=n.filter(e=>e.dependent_ticket_id===W.id),q=Qw(W,Qe,n),J=q.pendingBuildChainOrder.length>0?`Will build in order: ${q.pendingBuildChainOrder.map(e=>e.title).join(` -> `)}`:`All tickets in this chain have already finished build.`,tt=q.skippedBuildChainCount>0?`Skips ${q.skippedBuildChainCount} ticket${q.skippedBuildChainCount===1?``:`s`} that already finished build.`:null,nt=q.hasOpenBlockers,rt=qW(W,{isEditing:Be,includePlanAdvance:!1,hideAdvanceWhenBlocked:!0,hasOpenBlockers:nt,canRun:!!b,canStopRun:!!S,canPauseBuild:!!C,canResumeBuild:!!T,runDisabled:u,runDisabledReason:d,reviewLabel:`Review Bundle`}),it=rt.find(e=>e.id===`review`)??null,at=Ow(W),ot=W.build_chain?.active_ticket_id?`Currently building ${Qe.get(W.build_chain.active_ticket_id)?.title??`Unknown ticket`}.`:`Build chain is active.`,st=W.build_chain&&W.build_chain.queued_ticket_ids.length>0?`Queued next: ${W.build_chain.queued_ticket_ids.map(e=>Qe.get(e)?.title??`Unknown ticket`).join(` -> `)}`:`No additional tickets are queued after the current build.`,ct=Fe&&!!v&&!q.hasOpenBlockers,lt=Fe&&!!y&&q.canStartBuildChain,ut=!!W.project_id&&!Fe&&!Le,dt=Fe,ft=Le&&!Fe,pt=!!W.project_id&&!!Ye&&Xe&&!Be&&!Re&&!Le,mt=!!W.project_id&&Xe&&!Be&&!Re&&!!x&&!Le,ht=!!W.project_id&&i.length>0&&Xe,gt=ut&&!R,_t=k(`workspaceControls.openTerminalAriaLabel`),vt=ut&&te,yt=V.trim(),bt=!Be&&!Re&&W.state!==`plan`&&Xe&&!!E,xt=dt&&ae,St=ft&&se,Ct=(W.planning_context?.open_questions.length??0)>0,wt=bt&&a&&W.tool===`opencode`,Tt=k(`ticketModal.discardUnsavedDescription`),Et=o.find(e=>e.id===_e)??null,Dt=W.agent_status===`running`,Ot=cT(W,{allTickets:t,preferBundleReviewStatus:!0}),kt=W.skills??[],At=JW(W),jt=Dt?At.disabledReason??void 0:void 0,Mt=Re?At.disabledReason??void 0:void 0,Nt=[...Re?[]:[{label:`Worktree`,value:Ye??``}],{label:`Session`,value:Je??``},...Re?[{label:W.bundle?.kind===`project_root`?`Project root branch`:`Bundle`,value:(W.bundle?.kind,W.bundle?Tl(W.bundle):``)}]:Fe?[{label:`Bundle`,value:W.bundle?Tl(W.bundle):``},{label:`Model`,value:W.model??``},{label:`Variant`,value:W.variant??``},{label:`Skills`,value:kt.length>0?`${kt.length} skill${kt.length===1?``:`s`}`:``},{label:`Initiative`,value:W.planning_context?.initiative_prompt??``}]:[]],Pt=Re?{model:W.model??``,variant:W.variant??``,skills:kt}:null,Ft=dt&&ae,It=ft&&se,Lt=(Ft||It)&&!Ae,Rt=Ft&&!Lt,zt=Rt||It&&!Lt,Bt=Fe&&(Ft||!Ae),Vt=R?`flex h-[92vh] w-[96vw] max-w-7xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:zt?`flex h-[92vh] w-[98vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Lt?`flex h-[92vh] w-[98vw] max-w-6xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-6xl flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,Ht=R&&!B?`grid min-h-0 flex-1 grid-cols-1 gap-3 lg:grid-cols-2`:zt?`grid min-h-0 flex-1 grid-cols-1 gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(30rem,1fr)]`:`flex min-h-0 flex-1 flex-col`,Ut=()=>{ne(!0),z(e=>(e&&ee(!1),!e))},Wt=()=>{z(!1),ee(!1),ne(!1),D?.(W.id)},Gt=()=>{me(!1),ge(null)},Kt=()=>{me(!1),he===`cancel_edit`&&!Fe?N(!1):f(),ge(null)},qt=()=>{if(!Be){f();return}if(!de){f();return}ge(`close_modal`),me(!0)},Jt=()=>{if(Fe){qt();return}if(!de){N(!1);return}ge(`cancel_edit`),me(!0)};(0,Y.useEffect)(()=>{j(t=>!t||t.id!==e.id||e.updated_at>=t.updated_at?null:t)},[e]),(0,Y.useEffect)(()=>{if(Oe.current!==W.id){Oe.current=W.id,ke.current=W.build_completed_at;return}if(ke.current===W.build_completed_at)return;let e=ke.current;ke.current=W.build_completed_at,W.build_completed_at&&W.build_completed_at!==e&&ue(e=>e+1)},[W.build_completed_at,W.id]),(0,Y.useEffect)(()=>{ve(W.model??``),be(W.variant??``),xe(W.skills??[])},[W.model,W.skills,W.variant]),(0,Y.useEffect)(()=>{we.current!==W.id&&(we.current=W.id,Ce(sG(W.model,o)??`Agent`))},[o,W.id,W.model]),(0,Y.useEffect)(()=>{let e=sG(W.model,o);e&&Ce(e)},[o,W.model]),(0,Y.useEffect)(()=>{Pe({model:W.model,variant:W.variant,skills:W.skills??[]})},[W.id,W.model,W.skills,W.variant]),(0,Y.useEffect)(()=>{Be||(fe(!1),me(!1),ge(null))},[Be]),(0,Y.useEffect)(()=>{de||(me(!1),ge(null))},[de]),(0,Y.useEffect)(()=>{if(!Fe){Te.current=null,De.current=!1;return}let e=Te.current!==W.id,t=!De.current&&Ct;(e&&Ct||t)&&oe(!0),Te.current=W.id,De.current=Ct},[Ct,Fe,W.id]),(0,Y.useEffect)(()=>{if(!ft){Ee.current=null;return}Ee.current!==W.id&&ce(!1),Ee.current=W.id},[ft,W.id]);let Xt=async(e,t,n)=>{Me(!0);try{let r=await Yt(W.id,W.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});j(r),g?.(r)}catch(e){ve(W.model??``),be(W.variant??``),xe(W.skills??[]),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{Me(!1)}},Zt=e=>{let t=(o.find(t=>t.id===e)??null)?.variants.includes(ye)?ye:``;ve(e),be(t),Xt(e,t,G)},Qt=e=>{be(e),Xt(_e,e,G)},$t=e=>{xe(e),Xt(_e,ye,e)},en=async()=>{if(!(!E||H||Dt||!yt)){ie(!0);try{await E(yt),re(``)}finally{ie(!1)}}},tn=async()=>{if(!(H||Re||!yt||!xt)){ie(!0);try{let e=YW(W,Ne,{persistPlanSettings:!0});if(e.shouldPersist){let t=await Yt(W.id,W.project_id,{model:e.model,variant:e.variant,skills:e.skills});j(t),g?.(t)}let t=await bn(W.id,W.project_id,yt);j(t),g?.(t),re(``)}finally{ie(!1)}}},nn=(W.messages??[]).filter(MT).map(e=>e.role===`assistant`?{...e,displayTitle:Se}:e.kind===`follow_up`?{...e,displayTitle:k(`chatView.user.you`)}:e),rn=(W.messages??[]).filter(e=>(e.kind===`planning_follow_up`||e.kind===`planning_response`)&&MT(e)).map(e=>e.role===`assistant`?{...e,displayTitle:Se}:e.kind===`planning_follow_up`?{...e,displayTitle:k(`chatView.user.you`)}:e),an=Ft?(0,Z.jsx)(oG,{ariaLabel:k(`ticketModal.planningChatAriaLabel`),title:k(`ticketModal.planningChatTitle`),closeAriaLabel:k(`ticketModal.closePlanningChatAriaLabel`),className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,description:Ct?(0,Z.jsx)(`p`,{children:k(`ticketModal.planningOpenQuestions`,{count:W.planning_context?.open_questions.length??0})}):void 0,projectId:W.project_id,followUpTicketId:null,messages:rn,internalLog:W.agent_log??null,currentThinkingMessageId:W.agent_message_id??null,previousThinkingLog:W.previous_agent_log??null,previousThinkingMessageId:W.previous_agent_message_id??null,streamingResponse:W.streaming_response??null,isRunning:W.agent_status===`running`,canShowComposer:xt,pendingAgentTitle:Se,composerTheme:Ie,followUpPlaceholder:k(`ticketModal.planningFollowUpPlaceholder`),emptyStateText:null,autoFocusComposer:ae,followUpPrompt:V,isSendingFollowUp:H,followUpDisabledReason:Mt,onFollowUpPromptChange:re,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Re||H||(e.preventDefault(),tn())},onFollowUpSubmit:()=>{tn()},onClose:()=>{oe(!1)}}):It?(0,Z.jsx)(oG,{ariaLabel:k(`ticketModal.ticketChatAriaLabel`),title:k(`ticketModal.ticketChatTitle`),closeAriaLabel:k(`ticketModal.closeTicketChatAriaLabel`),className:Lt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Lt,projectId:W.project_id,followUpTicketId:W.id,messages:nn,internalLog:W.agent_log??null,currentThinkingMessageId:W.agent_message_id??null,previousThinkingLog:W.previous_agent_log??null,previousThinkingMessageId:W.previous_agent_message_id??null,streamingResponse:W.streaming_response??null,isRunning:W.agent_status===`running`,canShowComposer:St,pendingAgentTitle:Se,composerTheme:Ie,autoFocusComposer:se,followUpPrompt:V,isSendingFollowUp:H,followUpDisabledReason:jt,followUpComposerControls:wt?(0,Z.jsx)(xP,{model:_e,variant:ye,skills:G,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Et,onModelChange:Zt,onVariantChange:Qt,onSkillsChange:$t,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:je}):void 0,onFollowUpPromptChange:re,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Dt||H||(e.preventDefault(),en())},onFollowUpSubmit:()=>{en()},onClose:()=>{ce(!1)}}):null;return(0,Z.jsx)(du,{onClose:qt,overlayClassName:`bg-black/60`,panelClassName:Vt,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:[pt&&W.diff_stats&&(0,Z.jsx)(Dc,{stats:W.diff_stats,showFiles:!0,className:`text-xs`}),pt&&(0,Z.jsxs)(K,{type:`button`,"aria-label":k(`workspaceControls.changes`),onClick:()=>{D?.(W.id),F(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(kc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.changes`)})]}),ht&&(0,Z.jsxs)(K,{type:`button`,"aria-label":k(`workspaceControls.tests`),onClick:()=>{L(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Oc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.tests`)})]}),mt&&(0,Z.jsxs)(K,{type:`button`,"aria-label":k(`workspaceControls.openIde`),onClick:()=>{x?.()},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ac,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.openIde`)})]}),gt&&(0,Z.jsxs)(K,{type:`button`,"aria-label":_t,"aria-pressed":R,onClick:Ut,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Pc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.terminal`)})]}),(dt||ft)&&(0,Z.jsxs)(K,{type:`button`,"aria-label":k(`workspaceControls.chat`),"aria-pressed":Fe?ae:se,onClick:()=>{if(Fe){oe(e=>!e);return}ce(e=>!e)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(em,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k(`workspaceControls.chat`)})]}),e]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-modal-layout`,"data-terminal-mode":R?B?`expanded`:`split`:`closed`,"data-side-chat-mode":zt?`inline`:Lt?`overlay`:`closed`,className:Ht,children:[(0,Z.jsxs)(`div`,{className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[Be?(0,Z.jsxs)(Z.Fragment,{children:[ze&&W.agent_log&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-red-500/40 bg-destructive/15 px-3 py-2 text-xs text-red-300`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:k(`ticketModal.planningFailedPrefix`)}),W.agent_log]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(TT,{tool:W.tool,className:`text-[11px]`})}),(0,Z.jsx)(ET,{externalSource:W.external_source}),(0,Z.jsx)(rP,{heading:`Edit Ticket`,bundles:r,initialTitle:W.title,initialDescription:W.description??``,initialModel:W.model??``,initialVariant:W.variant??``,initialSkills:W.skills??[],initialWorktreeBundleId:W.worktree_bundle_id,projectBranchState:c,projectId:W.project_id,stackConfigurationSections:Rt&&!Bt,preferWideBundleSelector:Rt&&Bt,agentSettingsPresentation:Bt?`popover`:`panel`,showModelSelector:a,availableModels:o,availableSkills:s,onAgentSettingsChange:Pe,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onCancel:Jt,onDirtyChange:fe,titleInputId:`edit-title`,descriptionInputId:`edit-description`,bundleSelectId:`edit-ticket-bundle`,modelSelectId:`edit-model`,variantSelectId:`edit-variant`,skillsSelectId:`edit-skills`,showEmptyBundleOption:!1,planAction:{label:`Plan`,onClick:async({title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a})=>{let o=await Yt(W.id,W.project_id,{title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a});g?.(o),f(),await xn(W.id,W.project_id)}},primaryAction:{label:`Save`,variant:ct?`subtle`:`brand`,onClick:He},secondaryAction:ct?{label:`Save & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:Ue}:void 0,tertiaryAction:lt?{label:`Save & Build Chain`,variant:`brand`,showAdvanceIcon:!0,onClick:Ke}:void 0,beforeActionsContent:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(mP,{projectId:W.project_id,ticketId:W.id,memoryEnabled:l,refreshKey:le,onSuggestionsChanged:O}),q.hasDependents&&(0,Z.jsx)(NT,{summary:J,detail:tt}),(0,Z.jsx)(GN,{blocks:$e,blockedBy:et,resolveTicket:e=>Qe.get(e),onDeleteDependency:_})]}),footerLeadingContent:de?(0,Z.jsx)(U,{variant:`outline`,className:`border-amber-500/35 bg-amber-500/10 text-amber-200`,children:`Unsaved changes`}):null},`${W.id}:${W.updated_at}:${W.title}:${W.description}`)]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`sticky top-0 -my-1 bg-card py-1 pr-12 sm:pr-24`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:W.title}),(0,Z.jsx)(TT,{tool:W.tool,className:`text-[11px]`}),(Ot===`building`||Ot===`done`)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[W.is_running&&(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(iT,{status:Ot,showBuildGlyph:!0})]}),Ot!==null&&Ot!==`building`&&Ot!==`done`&&(0,Z.jsx)(iT,{status:Ot,showBuildGlyph:!0}),Ct&&(0,Z.jsx)(U,{variant:`warning`,children:k(`ticketModal.openQuestionsBadge`)}),at&&(0,Z.jsx)(U,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]})}),Le?(0,Z.jsx)(`div`,{className:`mt-3 min-h-0 flex flex-1 flex-col`,children:(0,Z.jsx)(hP,{content:W.description,externalSource:W.external_source})}):(0,Z.jsx)(Z.Fragment,{children:Fe?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 flex flex-col${Re?` mt-3`:``}`,children:(0,Z.jsx)(hP,{content:W.description,externalSource:W.external_source})}):(0,Z.jsx)(HN,{projectId:W.project_id,followUpTicketId:W.id,messages:nn,internalLog:W.agent_log??null,currentThinkingMessageId:W.agent_message_id??null,previousThinkingLog:W.previous_agent_log??null,previousThinkingMessageId:W.previous_agent_message_id??null,streamingResponse:W.streaming_response??null,isRunning:W.agent_status===`running`,canShowComposer:bt,pendingAgentTitle:Se,composerTheme:Ie,followUpComposerControls:wt?(0,Z.jsx)(xP,{model:_e,variant:ye,skills:G,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Et,onModelChange:Zt,onVariantChange:Qt,onSkillsChange:$t,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:je}):void 0,followUpPrompt:V,isSendingFollowUp:H,followUpDisabledReason:jt,onFollowUpPromptChange:re,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Dt||H||(e.preventDefault(),en())},onFollowUpSubmit:()=>{en()}})}),Re&&(0,Z.jsxs)(`section`,{"aria-label":k(`workspaceControls.ticketMetadataAriaLabel`),className:`flex flex-wrap items-center gap-2`,children:[Nt.filter(e=>e.value.trim().length>0).map(e=>(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,Z.jsx)(OT,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`)),(0,Z.jsx)(`div`,{className:`min-w-0 sm:flex-none`,children:(0,Z.jsx)(CT,{model:Pt.model,variant:Pt.variant,skills:Pt.skills})})]}),!Re&&!zt&&(0,Z.jsx)(kT,{ariaLabel:k(`workspaceControls.ticketMetadataAriaLabel`),items:Nt}),(0,Z.jsx)(mP,{projectId:W.project_id,ticketId:W.id,memoryEnabled:l,refreshKey:le,onSuggestionsChanged:O}),(0,Z.jsx)(GN,{blocks:$e,blockedBy:et,resolveTicket:e=>Qe.get(e),onDeleteDependency:_}),W.build_chain&&(0,Z.jsx)(NT,{summary:ot,detail:st})]}),!Be&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,onClick:f,variant:`ghost`,children:k(`workspaceControls.close`)}),W.build_chain&&w&&(0,Z.jsxs)(K,{type:`button`,onClick:()=>{w()},title:`Stop scheduling the remaining tickets in this build chain.`,"aria-label":Ze,variant:`destructive`,children:[(0,Z.jsx)(Nc,{className:`w-3.5 h-3.5`}),Ze]}),(0,Z.jsx)(GW,{actions:rt,actionsClassName:`contents`,renderAction:({action:e,label:t,disabled:n,title:r,ariaLabel:i})=>{let a=e.id===`review`?(0,Z.jsx)(yw,{className:`w-3.5 h-3.5`}):e.id===`run`||e.id===`resume-build`?(0,Z.jsx)(jc,{className:`w-3.5 h-3.5`}):(0,Z.jsx)(Nc,{className:`w-3.5 h-3.5`});return(0,Z.jsxs)(K,{type:`button`,disabled:n,title:r,"aria-label":i,variant:e.id===`stop-run`?`destructive`:e.id===`pause-build`||e.id===`resume-build`?`warning`:e.id===`run`?`secondary`:`default`,className:e.id===`run`?`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`:e.id===`resume-build`?`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`:void 0,onClick:()=>Ge(e.id),children:[e.id===`review`?t:a,e.id===`review`?a:t]},e.id)}})]})]})]}),zt&&an,vt&&(0,Z.jsx)(`div`,{className:R?B?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`mt-12 min-h-0 flex flex-1 flex-col overflow-hidden`:`hidden`,children:(0,Z.jsx)(WW,{createSession:()=>bT(W.id,W.project_id),isExpanded:B,isVisible:R,ariaLabel:k(`ticketModal.ticketTerminalAriaLabel`),className:B?`h-full w-full max-w-none rounded-2xl shadow-2xl`:void 0,onClose:Wt,onToggleExpanded:()=>{ee(e=>!e)}})})]}),Lt&&an,P&&(0,Z.jsx)(Y.Suspense,{fallback:(0,Z.jsx)(aG,{onClose:()=>{F(!1),D?.(W.id)}}),children:(0,Z.jsx)(eG,{ticketId:W.id,projectId:W.project_id,title:W.title,onTicketUpdate:g,onRequestTicketRefresh:D,onSubmitReviewPrompt:E,canSubmitReviewPrompt:!Dt,reviewSubmitDisabledReason:jt,onClose:()=>{F(!1),D?.(W.id)}})}),I&&ht&&W.project_id&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(tG,{scope:`ticket`,ticketId:W.id,projectId:W.project_id,testCommands:i,onClose:()=>{L(!1)}})}),pe&&(0,Z.jsx)(fu,{title:k(`ticketModal.discardUnsavedTitle`),description:Tt,confirmLabel:k(`ticketModal.discardUnsavedConfirm`),cancelLabel:k(`ticketModal.discardUnsavedCancel`),confirmVariant:`destructive`,onConfirm:Kt,onCancel:Gt})]})})},lG=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectMemoryEnabled:i=!1,overlay:a=!1,showModelSelector:o,availableModels:s,runDisabled:c=!1,runDisabledReason:l,dependencyTargetState:u=`idle`,onDependencyStart:d,onDeleteDependency:f,onRegisterNode:p,onRegisterOverlayNode:m,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onDelete:y,onUndo:b,onRetry:x,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:E,onOpenTests:D,onOpenChanges:O,onOpenIde:k,onAddTicketToBundle:A,onStop:j,onStopBuild:M,onStopBuildChain:N,onResumeBuild:P,onFollowUp:F,onOpenBundleDetails:I,onOpenTicketDetails:L,preferBundleDetailsOnClick:R=!1,hideBundleScopedControls:z=!1,hideStatusBadge:B=!1,onRequestTicketRefresh:ee,undoInProgress:te=!1})=>{let{t:ne}=X(`common`),[V,re]=(0,Y.useState)(!1),[H,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(!1),he=e.agent_status===`running`||te,ge=z,W=e.bundle?.branch??e.branch,_e=e.has_worktree??(e.state===`plan`?!1:!!W),ve=!z&&_e,ye=Qw(e,new Map(t.map(e=>[e.id,e])),n),be=Sw(e.state),G=e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`,xe=e.worktree_bundle_id!==null,Se=Ew(e),Ce=Dw(e),we=Ow(e),Te=!z&&Ce!==`plan`&&e.diff_stats===void 0,Ee=(we||Se)&&!a,De=be?ne(be===`review`?`card.advance.reviewBundle`:`card.columnLabels.${be}`):G?ne(`card.advance.rerunReview`):null,Oe=Nw(e,`trash`),ke=e.undo,Ae=!!b&&ke?.stage!==null,je=G||(be?Nw(e,be):!1),Me=!Se&&!!S&&!!De&&!ye.hasOpenBlockers,Ne=!!C&&jw(e),Pe=Se&&typeof e.state==`string`?ne(`card.returnTo`,{state:ne(`card.columnLabels.${e.state}`)}):null,Fe=!!w&&Pe!==null&&e.state!==`plan`,Ie=!Se&&!!T&&ye.canStartBuildChain,Le=Tw(e)&&e.agent_status===`running`&&!!e.session_id&&!!M,Re=Tw(e)&&e.agent_status===`stopped`&&!!e.session_id&&!!P,ze=ve&&!!O,Be=ve&&!!e.project_id&&!!D,Ve=ve&&!!k,He=!Se&&!z&&xe&&!!A,Ue=!ge&&_e&&!!W&&!e.is_running&&!!E,We=!ge&&_e&&!!W&&!!e.is_running&&!!j,Ge=!!e.build_chain&&!!N,Ke=!!y||Ae||Me||Ne||Fe||Ie||Le||Re||He||Ue||We||Be||ze||Ve||Ge,qe=Se&&!e.is_running?`opacity-0 pointer-events-none transition-opacity group-hover/card:opacity-100 group-hover/card:pointer-events-auto group-focus-within/card:opacity-100 group-focus-within/card:pointer-events-auto`:``,Je=async()=>{if(!(!E||c||de)){fe(!0);try{await E()}finally{fe(!1)}}},Ye=async()=>{if(!(!j||pe)){me(!0);try{await j()}finally{me(!1)}}},Xe=!ge&&_e&&W&&e.is_running&&j&&!te?(0,Z.jsx)(oT,{isRunning:!0,isStopPending:pe,onStop:Ye}):!ge&&_e&&W&&!e.is_running&&E?(0,Z.jsx)(oT,{isRunning:!1,isRunPending:de,runDisabled:c,runDisabledReason:l,onRun:Je,className:qe}):null;(0,Y.useEffect)(()=>{if(!se)return;let e=()=>{ce(!1)};return window.addEventListener(`click`,e,{once:!0}),()=>{window.removeEventListener(`click`,e)}},[se]);let Ze=()=>{if(a||se||te){ce(!1);return}if(R&&I){I();return}if(L){L();return}ee?.(e.id),oe(!0)},{attributes:Qe,listeners:$e,setNodeRef:et,isDragging:q}=XC({id:e.id,disabled:a||he}),J=(0,Y.useRef)(et);(0,Y.useEffect)(()=>{J.current=et},[et]);let tt=(0,Y.useCallback)(t=>{if(a){m?.(t);return}J.current(t),p?.(e.id,t)},[p,m,a,e.id]),nt=u===`valid`?`border-emerald-400 shadow-[0_0_0_1px_rgba(52,211,153,0.35)]`:u===`invalid`?`border-red-400 shadow-[0_0_0_1px_rgba(248,113,113,0.35)]`:a?`border-violet-400`:ye.isVisibleStartPoint?`border-violet-500/35 shadow-[0_0_0_1px_rgba(168,85,247,0.18)] hover:border-violet-400/55`:`border-border hover:border-primary/40`,rt=a||te?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,it=q?`opacity-30`:Ee?`opacity-90`:`opacity-100`,at=Ee?`bg-card/60`:`bg-secondary/30`,ot=Ee?`p-3 text-foreground/70`:`p-3`,st=Ee?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,ct=Ee?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,lt=Ee?`whitespace-pre-line text-xs leading-relaxed text-foreground/55 wrap-anywhere`:`whitespace-pre-line text-xs leading-relaxed text-muted-foreground wrap-anywhere`,ut=e.model??``,dt=!!e.bundle&&!z,ft=!!e.bundle?.pull_request&&!z,pt=dt||ft,mt=pt||ut.length>0,ht=le===e.id,gt=(0,Y.useMemo)(()=>{let t=e.description??``;return t?QM(t):{text:``,truncated:!1}},[e.description]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(mu,{"data-testid":`ticket-card-${e.id}`,className:`group/card shrink-0 select-none transition-colors ${nt} ${rt} ${it} ${at} gap-0 rounded-xl border shadow-none`,ref:tt,onClick:Ze,...$e,...Qe,children:[te&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(U,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Df,{className:`h-3.5 w-3.5 animate-spin`}),ne(`card.undoInProgress`)]})}),(0,Z.jsxs)(yu,{className:ot,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`div`,{className:st,children:e.title})}),(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,Z.jsx)(`div`,{className:`mr-1`,children:Xe}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:d&&(0,Z.jsx)(yc,{content:ne(`card.drawDependency`),children:(0,Z.jsx)(K,{type:`button`,"aria-label":ne(`card.createDependencyAriaLabel`,{title:e.title}),variant:`ghost`,size:`icon-xs`,className:`cursor-crosshair opacity-0 transition-all group-hover/card:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.stopPropagation(),ce(!0),d(e.id,t)},children:(0,Z.jsx)(Kd,{className:`h-4 w-4`})})})}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:Ke&&(0,Z.jsx)(gT,{title:e.title,canDelete:Oe,undo:ke,undoInProgress:te,runDisabled:c,isRunPending:de,isStopPending:pe,showTestsAction:Be,showOpenChangesAction:ze,showOpenIdeAction:Ve,showAddTicketToBundleAction:He,showRunAction:Ue,showStopRunAction:We,showAdvanceAction:Me,advanceLabel:De,canAdvance:je,showParkAction:Ne,showReturnAction:Fe,returnLabel:Pe,showBuildChainAction:Ie,showPauseBuildAction:Le,showResumeBuildAction:Re,showStopBuildChainAction:Ge,onDelete:y,onConfirmDelete:()=>re(!0),onConfirmUndo:()=>ie(!0),onOpenTests:D,onOpenChanges:O,onOpenIde:k,onAddTicketToBundle:He?()=>A?.(e.worktree_bundle_id):void 0,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:Je,onStop:Ye,onStopBuild:M,onResumeBuild:P,onStopBuildChain:N})})]})]}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(yT,{ticket:e,hideStatusBadge:B,hideBundleScopedControls:z,isStale:we,runControl:null,onRetry:x,undoInProgress:te,isChainStart:ye.isVisibleStartPoint})}),mt&&(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[pt&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${ct}`,children:[dt&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:Tl(e.bundle)}),ft&&e.bundle?.pull_request&&(0,Z.jsx)(_w,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})]}),ut.length>0&&(0,Z.jsx)(`div`,{className:ct,children:(0,Z.jsx)(`span`,{className:`truncate`,children:ut})})]}),e.description&&(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(vT,{description:e.description,descriptionClass:lt,isExpanded:ht,collapsedState:gt,useStaleLikeStyling:Ee,onExpand:()=>ue(e.id),onCollapse:()=>ue(null)})}),!z&&(Aw(Ce,e.diff_stats)||Te)&&(0,Z.jsx)(Dc,{stats:e.diff_stats,isLoading:Te,showFiles:!0,className:`mt-2`})]})]}),ae&&(0,Z.jsx)(cG,{ticket:e,allTickets:t,dependencies:n,bundles:r,projectMemoryEnabled:i,onClose:()=>{oe(!1),ee?.(e.id)},showModelSelector:o,availableModels:s,runDisabled:c,runDisabledReason:l,onDeleteDependency:f,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onAdvance:S,onBuildChain:T,onRun:E,onOpenIde:k,onStop:j,onStopBuild:M,onStopBuildChain:N,onResumeBuild:P,onFollowUp:F}),V&&(0,Z.jsx)(_T,{title:e.title,bundleName:e.bundle?Tl(e.bundle):void 0,onConfirm:()=>{re(!1),y?.()},onCancel:()=>re(!1)}),H&&ke?.stage&&(0,Z.jsx)(aT,{title:e.title,stage:ke.stage,onConfirm:()=>{ie(!1),b?.()},onCancel:()=>ie(!1)})]})},uG=({index:e})=>{let{t}=X(`common`);return(0,Z.jsx)(mu,{"aria-hidden":`true`,"data-testid":`ticket-card-skeleton`,className:`group shrink-0 select-none gap-0 rounded-xl border border-border/70 bg-secondary/20 shadow-none`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(Ec,{className:`h-3.5 w-3/5 rounded-full`}),(0,Z.jsx)(Ec,{className:`h-5 w-11 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Ec,{className:`h-3 w-full rounded-full`}),(0,Z.jsx)(Ec,{className:`h-3 w-11/12 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ec,{className:`h-4 w-14 rounded-full`}),(0,Z.jsx)(Ec,{className:`h-4 w-10 rounded-full`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:t(`column.loadingCard`,{index:e+1})})]})})},dG=({id:e,title:t,items:n,ticketCount:r,pinnedContent:i=null,allTickets:a,dependencies:o,showModelSelector:s,availableModels:c,activeRunContextKey:l,isProjectRootRunActive:u=!1,isBundleRunDisabled:d,bundles:f,getDependencyTargetState:p,onDependencyStart:m,onDeleteDependency:h,onRegisterTicketNode:g,onAddTicket:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdateTicket:x,onDeleteTicket:S,onUndoTicket:C,undoingColumn:w=null,onRetryTicket:T,onAdvanceTicket:E,onParkTicket:D,onUnparkTicket:O,onBuildChainTicket:k,onRunTicket:A,onOpenTestsTicket:j,canOpenChangesForTicket:M,onOpenChangesTicket:N,canOpenIdeForTicket:P,onOpenIdeTicket:F,onStopTicket:I,onStopBuildTicket:L,onStopBuildChainTicket:R,onResumeBuildTicket:z,onFollowUpTicket:B,onBuildBundle:ee,onReviewBundle:te,onUndoBundleReview:ne,onRunBundle:V,onStopBundle:re,onParkBundleWrapper:H,onUnparkBundleWrapper:ie,bundleActionState:ae,onOpenTicketDetails:oe,onOpenBundleDetails:se,onOpenBundleChanges:ce,onOpenBundleTests:le,onOpenBundleIde:ue,onDeleteBundleWrapper:de,onAddTicketToBundle:fe,onRequestBundleRefresh:pe,onRequestTicketRefresh:me,className:he=``,headerAccessory:ge=null,loadingSkeletonCount:W=0})=>{let{t:_e}=X(`common`),{setNodeRef:ve,isOver:ye}=ew({id:e}),be=(0,Y.useRef)(null),[G,xe]=(0,Y.useState)(!1),[Se,Ce]=(0,Y.useState)(!1),we=e=>e.has_worktree??!!(e.bundle?.branch??e.branch),Te=ye?`border-primary`:`border-border`,Ee=w===e&&(e===`build`||e===`review`),De=(0,Y.useCallback)(()=>{let e=be.current;if(!e){xe(!1),Ce(!1);return}if(!(e.scrollHeight>e.clientHeight+1)){xe(!1),Ce(!1);return}let t=e.scrollHeight-e.clientHeight;xe(e.scrollTop>1),Ce(e.scrollTop<t-1)},[]);(0,Y.useEffect)(()=>{let e=window.requestAnimationFrame(De),t=be.current;if(!t){window.cancelAnimationFrame(e);return}return t.addEventListener(`scroll`,De),window.addEventListener(`resize`,De),()=>{window.cancelAnimationFrame(e),t.removeEventListener(`scroll`,De),window.removeEventListener(`resize`,De)}},[n.length,W,De]);let Oe=(0,Y.useCallback)((t,n)=>{let r=t.worktree_bundle_id!==null,i=n?.nestedInBundle??!1,d=n?.hideStatusBadge??!1,_=r&&e!==`plan`,w=qw(t),ee=u||l!==null&&l!==ww(t)?_e(`column.runDisabledReason`):w;return(0,Z.jsx)(lG,{ticket:t,allTickets:a,dependencies:o,bundles:f,showModelSelector:s,availableModels:c,runDisabled:ee!==void 0,runDisabledReason:ee,dependencyTargetState:p?.(t.id)??`idle`,onDependencyStart:m,onDeleteDependency:h,onRegisterNode:g,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdate:x,onDelete:()=>S(t.id),onUndo:C?()=>C(t.id):void 0,undoInProgress:!1,onRetry:()=>T(t.id),onAdvance:E?()=>E(t.id):void 0,onPark:D?()=>D(t.id):void 0,onUnpark:O?()=>O(t.id):void 0,onBuildChain:k?()=>k(t.id):void 0,onRun:we(t)&&t.has_run_config&&A?()=>A(t.id):void 0,onOpenTests:j&&t.project_id&&we(t)?()=>j(t.id):void 0,onOpenChanges:M?.(t)&&N?()=>N(t.id):void 0,onOpenIde:P?.(t)&&F?()=>F(t.id):void 0,onStop:I?()=>I(t.id):void 0,onStopBuild:L?()=>L(t.id):void 0,onStopBuildChain:R?()=>R(t.id):void 0,onResumeBuild:z?()=>z(t.id):void 0,onFollowUp:B?e=>B(t.id,e):void 0,onAddTicketToBundle:fe,onOpenBundleDetails:_&&se?()=>se(t.worktree_bundle_id,e):void 0,onOpenTicketDetails:()=>oe(t),preferBundleDetailsOnClick:_,hideBundleScopedControls:i,hideStatusBadge:d,onRequestTicketRefresh:me})},[l,a,c,f,M,P,o,p,e,u,fe,E,k,v,y,h,S,m,B,se,N,F,j,oe,D,b,g,me,z,T,A,R,L,I,C,O,x,s,_e]);return(0,Z.jsxs)(mu,{className:`flex min-h-0 min-w-[280px] flex-1 flex-col rounded-2xl bg-card/80 p-4 transition-colors ${he} ${Te}`,ref:ve,children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex min-h-7 items-center justify-between`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:t}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ge,(0,Z.jsx)(U,{variant:`outline`,children:r}),_&&(0,Z.jsxs)(K,{type:`button`,onClick:_,size:`xs`,variant:`success`,className:`gap-2 shadow-[0_8px_20px_rgba(16,185,129,0.22)]`,children:[(0,Z.jsx)(`span`,{children:_e(`column.newTicket`)}),(0,Z.jsx)(U,{"aria-hidden":`true`,variant:`hotkeyDark`,className:`rounded-md px-1.5 py-0.5 text-[10px] leading-none`,children:`N`})]})]})]}),(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{ref:be,className:`flex min-h-0 h-full flex-col gap-2.5 overflow-y-auto pr-1`,children:[i,n.map(e=>{if(e.kind===`bundle`)return(0,Z.jsx)(mT,{group:e.group,renderTicket:t=>Oe(t,{nestedInBundle:!0,hideStatusBadge:e.group.column===`review`}),runDisabled:d?.(e.group.bundle.id)??!1,onBuildBundle:ee,onReviewBundle:te,onUndoBundleReview:ne,onRunBundle:V,onStopBundle:re,onParkBundleWrapper:H,onUnparkBundleWrapper:ie,bundleActionState:ae,onStopBuildTicket:L,onResumeBuildTicket:z,onOpenBundleDetails:se,onOpenBundleChanges:ce,onOpenBundleTests:le,onOpenBundleIde:ue,onDeleteBundleWrapper:de,onAddTicketToBundle:fe,onRequestBundleRefresh:pe},e.group.id);let t=e.ticket;return(0,Z.jsx)(Y.Fragment,{children:Oe(t)},t.id)}),Array.from({length:W},(t,n)=>(0,Z.jsx)(uG,{index:n},`loading-card-${e}-${n}`))]}),Ee&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-undo-overlay-${e}`,className:`absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(U,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Df,{className:`h-3.5 w-3.5 animate-spin`}),_e(`column.undoInProgress`)]})}),G&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-top-fade`,className:`pointer-events-none absolute inset-x-0 top-0 h-6 rounded-t-xl bg-gradient-to-b from-card to-transparent`}),Se&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-bottom-fade`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 rounded-b-xl bg-gradient-to-t from-card to-transparent`})]})]})},fG=({ticketCount:e,isDeleting:t,onCancel:n,onConfirm:r})=>{let{t:i}=X(`common`);return(0,Z.jsxs)(du,{onClose:t?()=>{}:n,overlayClassName:`bg-black/60`,panelClassName:`max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:i(`boardConfirmEmptyDoneModal.heading`)}),(0,Z.jsx)(`p`,{className:`mb-2 text-sm text-foreground`,children:i(`boardConfirmEmptyDoneModal.deletePrompt`,{count:e})}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:i(`boardConfirmEmptyDoneModal.description`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:t,onClick:n,children:i(`boardConfirmEmptyDoneModal.cancel`)}),(0,Z.jsx)(K,{type:`button`,variant:`destructive`,disabled:t,onClick:r,children:i(t?`boardConfirmEmptyDoneModal.deleting`:`boardConfirmEmptyDoneModal.confirm`)})]})]})},pG=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,currentThinkingMessageId:i=null,legacyThinkingTicketId:a=null,previousThinkingLog:o=null,previousThinkingMessageId:s=null,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d=!1,canShowComposer:f,composerControls:p,composerTheme:m=`default`,layoutKey:h,scrollLayoutKey:g,followUpPrompt:_,followUpPlaceholder:v=`Follow up on this bundle`,isSendingFollowUp:y,followUpDisabledReason:b,onFollowUpPromptChange:x,onFollowUpKeyDown:S,onFollowUpSubmit:C})=>(0,Z.jsx)(VN,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,currentThinkingMessageId:i,legacyThinkingTicketId:a,previousThinkingLog:o,previousThinkingMessageId:s,pendingAgentTitle:c,streamingResponse:l,isRunning:u,isLoading:d,autoScrollBehavior:`sticky`,canShowComposer:f,composerInlineControls:p,composerTheme:m,composerSize:`compact-on-laptop`,layoutKey:h,scrollLayoutKey:g,followUpPrompt:_,followUpPlaceholder:v,emptyStateText:`No bundle messages yet.`,autoFocusComposer:!0,isSendingFollowUp:y,followUpDisabledReason:b,onFollowUpPromptChange:x,onFollowUpKeyDown:S,onFollowUpSubmit:C}),mG=({bundleId:e,actionState:t,runDisabled:n,canBuild:r,canStopBuild:i,runningBuildTicketId:a,canResumeBuild:o,resumableBuildTicketId:s,isRunning:c,canRun:l,canReview:u,reviewActionLabel:d=`Review Bundle`,onClose:f,onBuildBundle:p,onStopBuildTicket:m,onResumeBuildTicket:h,onRunBundle:g,onStopBundle:_,onReviewBundle:v})=>{let y=t.review||t.followUp;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),c?(0,Z.jsxs)(K,{type:`button`,variant:`destructive`,disabled:t.stop,onClick:()=>void _(e),children:[(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(Nc,{className:`w-3.5 h-3.5`}),t.stop?`Stopping...`:`Stop Run`]}):l?(0,Z.jsxs)(K,{type:`button`,variant:`secondary`,disabled:t.run||n,title:n?`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{n||g(e)},className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,Z.jsx)(jc,{className:`w-3.5 h-3.5`}),t.run?`Starting Run...`:`Run`]}):null,r&&(0,Z.jsxs)(K,{type:`button`,disabled:t.build,onClick:()=>void p(e),children:[(0,Z.jsx)(jc,{className:`w-3.5 h-3.5`}),t.build?`Building Bundle...`:`Build Bundle`]}),i&&a&&(0,Z.jsxs)(K,{type:`button`,variant:`warning`,disabled:t.stopBuild,title:`Pause the build session. You can resume it later.`,"aria-label":`Pause Build`,onClick:()=>void m(a),children:[(0,Z.jsx)(Nc,{className:`w-3.5 h-3.5`}),t.stopBuild?`Pausing...`:`Pause Build`]}),o&&s&&(0,Z.jsxs)(K,{type:`button`,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,disabled:t.resumeBuild,onClick:()=>void h(s),children:[(0,Z.jsx)(jc,{className:`w-3.5 h-3.5`}),t.resumeBuild?`Resuming...`:`Resume`]}),u&&(0,Z.jsxs)(K,{type:`button`,disabled:y,onClick:()=>void v(e),children:[(0,Z.jsx)(yw,{className:`w-3.5 h-3.5`}),y?`Reviewing Bundle...`:d]})]})]})},hG=e=>e.agent_status===`running`?`bg-amber-400`:e.agent_status===`error`?`bg-rose-400`:e.agent_status===`stopped`?`bg-amber-300`:e.agent_status===`done`?`bg-emerald-400`:`bg-border`,gG=({tickets:e,onOpenTicketDetails:t,highlightedTicketId:n=null,pendingMemorySuggestionCounts:r={}})=>{let i=e.filter(e=>e.agent_status===`running`).length,a=e.filter(e=>e.agent_status===`error`).length;return(0,Z.jsxs)(`section`,{"aria-label":`Bundle tickets`,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Tickets`}),(0,Z.jsx)(U,{variant:`outline`,children:e.length}),i>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[i,` active`]}),a>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-rose-300`,children:[a,` error`,a===1?``:`s`]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-col gap-1 overflow-y-auto pr-1`,children:e.map(e=>{let i=r[e.id]??0,a=e.id===n;return(0,Z.jsxs)(`button`,{type:`button`,"data-follow-up-target":a?`true`:`false`,"aria-current":a?`true`:void 0,className:G(`flex cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2.5 text-left text-foreground transition-colors`,a?`border border-sky-500/35 bg-sky-500/10 shadow-[inset_0_0_0_1px_rgba(56,189,248,0.12)] hover:bg-sky-500/15`:`bg-background/20 hover:bg-accent/45`),onClick:()=>t(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:G(`h-2 w-2 shrink-0 rounded-full`,hG(e))}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.title}),(0,Z.jsx)(TT,{tool:e.tool,className:`shrink-0 text-[10px]`})]}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e.state})]}),a&&(0,Z.jsx)(U,{variant:`info`,className:`shrink-0 px-1.5 text-[10px]`,"aria-label":`Follow-up target`,children:`Follow-up`}),i>0&&(0,Z.jsx)(U,{variant:`warning`,className:`h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[10px]`,"aria-label":`${i} pending memory suggestion${i===1?``:`s`}`,title:`${i} pending memory suggestion${i===1?``:`s`}`,children:i})]},e.id)})})]})},_G=e=>e.kind===`description`?e.bundle_visible_at??e.created_at:e.created_at,vG=(e,t)=>e?t.get(e)??e:null,yG=(e,t)=>vG(e,t)??`Agent`,bG=e=>e.kind===`planning_follow_up`||e.kind===`planning_response`?0:e.kind===`description`?1:2,xG=(e,t)=>{let n={};for(let r of e){let e=vG(r.model,t);e&&(n[r.id]=e)}return n},SG=(e,t=[])=>{let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>{let r=n.get(e.id)??e.bundle_execution_position??2**53-1,i=n.get(t.id)??t.bundle_execution_position??2**53-1;if(r!==i)return r-i;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let a=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return a===0?e.id.localeCompare(t.id):a})},CG=(e,t,n,r=[])=>{let i=SG(e,r),a=new Map(i.map((e,t)=>[e.id,t]));return i.flatMap(e=>{let r=e.messages??[],i=e.agent_status!==null||e.session_id!==null||r.some(e=>e.kind!==`description`&&MT(e)),o=r.filter(e=>MT(e)&&(i||e.kind!==`description`)),s=n[e.id]??yG(e.model,t);return o.map(t=>t.role===`assistant`?{...t,displayTitle:s,ticketOrder:a.get(e.id)??2**53-1}:t.kind===`follow_up`?{...t,displayTitle:`You`,ticketOrder:a.get(e.id)??2**53-1}:{...t,displayTitle:e.title,ticketOrder:a.get(e.id)??2**53-1})}).sort((e,t)=>{if(e.ticket_id===t.ticket_id){let n=bG(e)-bG(t);if(n!==0)return n}let n=_G(e),r=_G(t);if(n!==r)return n.localeCompare(r);if(e.ticket_id!==t.ticket_id&&e.ticketOrder!==t.ticketOrder)return e.ticketOrder-t.ticketOrder;let i=bG(e)-bG(t);return i===0?e.id.localeCompare(t.id):i}).map(e=>{let{ticketOrder:t,...n}=e;return n})},wG=e=>yl(e.tickets,{targetTicketId:e.target_ticket_id,reviewOwnerTicketId:e.review_owner_ticket_id,latestSessionTicketId:e.latest_session_ticket_id}),TG=(0,Y.lazy)(()=>$W(()=>Promise.resolve().then(()=>uJ).then(e=>({default:e.TicketChangesModal})),void 0)),EG=e=>e.replace(/\r\n/g,`
|
|
142
|
+
`).trim(),DG=(e,t)=>e.ticket_id===t.ticket_id&&e.role===`user`&&t.role===`user`&&e.kind===`follow_up`&&t.kind===`follow_up`&&EG(e.content)===EG(t.content),OG=(e,t)=>{if(t.length===0)return e;let n=new Set,r=new Set,i=new Map,a=[];for(let a of t){let t=[...e].reverse().find(e=>!r.has(e.id)&&!n.has(a.id)&&DG(a,e));t&&(r.add(t.id),n.add(a.id),i.set(t.id,a))}for(let t of e){let e=i.get(t.id);if(e){a.push(e);continue}a.push(t)}for(let e of t)n.has(e.id)||a.push(e);return a},kG=e=>e?e.startsWith(`ses_`)?`opencode --session ${e}`:`claude --resume ${e}`:null,AG=(e,t)=>e.latest_session_id?kG(e.latest_session_id):kG(t?.session_id??null),jG=(e,t)=>t?.diff_stats?t.diff_stats:e.find(e=>e.diff_stats)?.diff_stats??null,MG=({details:e,activeColumn:t=null,isLoading:n=!1,actionState:r,canOpenIde:i,projectMemoryEnabled:a=!1,memorySuggestionsRefreshKey:o=0,runDisabled:s=!1,showModelSelector:c=!1,availableModels:l=[],availableSkills:u=[],onClose:d,onOpenTicketDetails:f,onOpenIde:p,onOpenTests:m,onRefresh:h,onUpdateTicket:g,onBuildBundle:_,onStopBuildTicket:v,onResumeBuildTicket:y,onReviewBundle:b,onRunBundle:x,onStopBundle:S,onFollowUpBundle:C})=>{let{t:w}=X(`common`),[T,E]=(0,Y.useState)(!1),[D,k]=(0,Y.useState)(``),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)(!1),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(``),[R,z]=(0,Y.useState)(``),[B,ee]=(0,Y.useState)([]),[te,ne]=(0,Y.useState)(null),[V,re]=(0,Y.useState)(!1),[H,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)({}),[se,ce]=(0,Y.useState)([]),le=(0,Y.useMemo)(()=>wG(e),[e]),ue=(0,Y.useMemo)(()=>new Map(l.map(e=>[e.id,e.label])),[l]),[de,fe]=(0,Y.useState)(()=>xG(e.tickets,ue)),pe=(0,Y.useMemo)(()=>SG(e.tickets,e.execution_order_ticket_ids),[e.execution_order_ticket_ids,e.tickets]),me=t??le?.state??null,he=me===`plan`,ge=(0,Y.useMemo)(()=>OG(CG(e.tickets,ue,de,e.execution_order_ticket_ids),se),[ue,e.execution_order_ticket_ids,e.tickets,se,de]),W=(0,Y.useMemo)(()=>lT(e.tickets,me),[me,e.tickets]),_e=(0,Y.useMemo)(()=>(0,Z.jsx)(iT,{status:W}),[W]),ve=(0,Y.useMemo)(()=>AG(e,le),[e,le]),ye=(0,Y.useMemo)(()=>jG(e.tickets,le),[e.tickets,le]),G=!he&&!!(le?.project_id&&le&&vl(le)),xe=!!(m&&le?.project_id&&le&&vl(le)),Se=!he&&!!(le?.project_id&&le),Ce=Se&&!A,we=Se&&P&&le!==null,Te=me===`plan`&&e.tickets.some(e=>e.state===`plan`),Ee=pe.find(e=>Tw(e)&&e.agent_status===`running`&&!!e.session_id)??null,De=pe.find(e=>Tw(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,Oe=Ee!==null,ke=!Oe&&De!==null,Ae=me===`build`&&e.tickets.some(e=>e.state===`build`)&&e.tickets.filter(e=>e.state===`build`).every(e=>e.agent_status===`done`),je=r.review||r.followUp,Me=me===`review`&&e.can_re_review===!0&&!e.tickets.some(e=>e.agent_status===`running`)&&!je,Ne=Ae||Me,Pe=Me?`Re-run review`:`Review Bundle`,Fe=e.tickets.some(e=>e.has_run_config&&Kw(e)),Ie=e.tickets.some(e=>e.is_running),Le=e.tickets.find(e=>e.agent_status===`running`)??le,Re=Le?.streaming_response??null,ze=Le?.agent_log??null,Be=Le?.agent_message_id??le?.agent_message_id??null,Ve=Le?.previous_agent_log??le?.previous_agent_log??null,He=Le?.previous_agent_message_id??le?.previous_agent_message_id??null,Ue=l.find(e=>e.id===I)??null,We=le?.project_id??e.tickets.find(e=>e.project_id)?.project_id??null,Ge=(0,Y.useMemo)(()=>e.tickets.map(e=>e.id).sort().join(`|`),[e.tickets]),Ke=(0,Y.useMemo)(()=>new Set(Ge.length>0?Ge.split(`|`):[]),[Ge]),qe=(0,Y.useMemo)(()=>e.tickets.map(e=>`${e.id}:${e.build_completed_at??``}`).sort().join(`|`),[e.tickets]),Je=Le??le??e.tickets[0]??null,Ye=Je??le,Xe=Ye?.id??null,Ze=Le?de[Le.id]??Le.model??`Agent`:`Agent`,Qe=Le?.agent_status===`running`?Ze:null,$e=!he&&!!(le&&vl(le)),et=Cw(t??le?.state??null),q=$e&&c&&Ye?.tool===`opencode`,J=r.followUp||H,tt=e.tickets.some(e=>e.agent_status===`running`),nt=tt?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,rt=Je?`Follow up on: ${Je.title}`:`Follow up on this bundle`,it=[{label:e.bundle.kind===`project_root`?`Project root branch`:`Worktree`,value:e.bundle.branch},{label:`Session`,value:ve??``}],at=!he,ot=A&&!M,st=e.bundle.id,ct=A?M?`expanded`:`split`:`closed`,lt=ot?`flex h-[92vh] w-[98vw] max-w-[110rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,ut=ot?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)_minmax(30rem,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)_minmax(30rem,1fr)]`:at?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)]`:`flex min-h-0 flex-1 flex-col`,dt=M?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`fixed inset-4 z-[70] flex items-stretch justify-end bg-black/30 backdrop-blur-sm 2xl:hidden sm:inset-6 lg:inset-8`;(0,Y.useEffect)(()=>{if(!a||he||!We||Ge.length===0){oe({});return}let e=new AbortController;return be(We,null,e.signal).then(t=>{e.signal.aborted||oe(t.suggestions.reduce((e,t)=>(!t.ticket_id||!Ke.has(t.ticket_id)||(e[t.ticket_id]=(e[t.ticket_id]??0)+1),e),{}))}).catch(t=>{if(!e.signal.aborted){if(t instanceof O&&(t.status===404||t.status===409)){oe({});return}oe({})}}),()=>{e.abort()}},[qe,We,Ke,Ge,he,o,a]),(0,Y.useEffect)(()=>{fe(t=>{let n={...t},r=!1,i=new Set(e.tickets.map(e=>e.id));for(let t of e.tickets){let e=t.model?ue.get(t.model)??t.model:null;!e||n[t.id]===e||(n[t.id]=e,r=!0)}for(let e of Object.keys(n))i.has(e)||(delete n[e],r=!0);return r?n:t})},[ue,e.tickets]),(0,Y.useEffect)(()=>{if(Xe!==null&&te?.ticketId===Xe)if((Ye?.model??``)===te.model&&(Ye?.variant??``)===te.variant&&(Ye?.skills.length??0)===te.skills.length&&(Ye?.skills??[]).every((e,t)=>e===te.skills[t]))ne(null);else return;L(Ye?.model??``),z(Ye?.variant??``),ee(Ye?.skills??[])},[Ye?.model,Ye?.skills,Ye?.variant,Xe,te]);let ft=async(e,t,n)=>{if(Ye){ne({ticketId:Ye.id,model:e,variant:t,skills:n}),re(!0);try{let r=await Yt(Ye.id,Ye.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});g?.(r)}catch(e){ne(null),L(Ye.model??``),z(Ye.variant??``),ee(Ye.skills),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{re(!1)}}},pt=async()=>{let t=D.trim();if(!t||J||tt)return;let n=Je?{id:`optimistic-follow-up-${Date.now()}`,ticket_id:Je.id,role:`user`,kind:`follow_up`,content:t,created_at:new Date().toISOString(),displayTitle:`You`}:null;ie(!0),k(``),n&&ce(e=>[...e,n]);try{await C(e.bundle.id,t)}catch{n&&ce(e=>e.filter(e=>e.id!==n.id)),k(t)}finally{ie(!1)}},mt=q?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:q&&(0,Z.jsx)(xP,{model:I,variant:R,skills:B,showModelSelector:!0,showSkillsSelector:!0,availableModels:l,availableSkills:u,selectedModel:Ue,onModelChange:e=>{let t=(l.find(t=>t.id===e)??null)?.variants.includes(R)?R:``;L(e),z(t),ft(e,t,B)},onVariantChange:e=>{z(e),ft(I,e,B)},onSkillsChange:e=>{ee(e),ft(I,R,e)},modelSelectId:`bundle-follow-up-model`,variantSelectId:`bundle-follow-up-variant`,skillsSelectId:`bundle-follow-up-skills`,disabled:V})}):void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(du,{onClose:d,overlayClassName:`bg-black/60 !z-40`,panelClassName:lt,renderContent:({closeButton:t})=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`div`,{"data-testid":`bundle-modal-layout`,"data-terminal-mode":ct,className:`min-h-0 flex flex-1 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:Tl(e.bundle)}),_e,e.bundle.pull_request&&(0,Z.jsx)(_w,{pullRequest:e.bundle.pull_request,asLink:!0}),(0,Z.jsxs)(U,{variant:`outline`,children:[e.tickets.length,` tickets`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!he&&ye&&(0,Z.jsx)(Dc,{stats:ye,showFiles:!0,className:`text-xs`}),G&&(0,Z.jsxs)(K,{type:`button`,"aria-label":w(`workspaceControls.changes`),onClick:()=>E(!0),variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(kc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.changes`)})]}),xe&&(0,Z.jsxs)(K,{type:`button`,"aria-label":w(`workspaceControls.tests`),onClick:m,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Oc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.tests`)})]}),!he&&i&&(0,Z.jsxs)(K,{type:`button`,"aria-label":w(`workspaceControls.openIde`),onClick:p,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Ac,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.openIde`)})]}),Ce&&(0,Z.jsxs)(K,{type:`button`,"aria-label":w(`workspaceControls.openTerminalAriaLabel`),onClick:()=>{F(!0),j(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Pc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:w(`workspaceControls.terminal`)})]}),t]})]}),(0,Z.jsxs)(`div`,{className:ut,children:[at&&(0,Z.jsxs)(`aside`,{"data-testid":`bundle-modal-sidebar`,className:`flex min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(kT,{ariaLabel:w(`workspaceControls.ticketMetadataAriaLabel`),items:it,className:`flex-col items-stretch gap-3`}),(0,Z.jsx)(gG,{tickets:e.tickets,onOpenTicketDetails:f,highlightedTicketId:Je?.id??null,pendingMemorySuggestionCounts:ae})]}),(0,Z.jsxs)(`div`,{"data-testid":`bundle-modal-main`,className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[!he&&(0,Z.jsx)(pG,{projectId:le?.project_id??null,followUpTicketId:e.target_ticket_id,messages:ge,internalLog:ze,currentThinkingMessageId:Be,legacyThinkingTicketId:Le?.id??le?.id??null,previousThinkingLog:Ve,previousThinkingMessageId:He,pendingAgentTitle:Qe,streamingResponse:Re,isRunning:Le?.agent_status===`running`,isLoading:n,canShowComposer:$e,layoutKey:st,scrollLayoutKey:ct,composerControls:mt,composerTheme:et,followUpPrompt:D,followUpPlaceholder:rt,isSendingFollowUp:J,followUpDisabledReason:nt,onFollowUpPromptChange:k,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||tt||J||(e.preventDefault(),pt())},onFollowUpSubmit:()=>{pt()}}),he&&(0,Z.jsx)(gG,{tickets:e.tickets,onOpenTicketDetails:f,pendingMemorySuggestionCounts:ae}),(0,Z.jsx)(mG,{bundleId:e.bundle.id,actionState:r,runDisabled:s,canBuild:Te,canStopBuild:Oe,runningBuildTicketId:Ee?.id??null,canResumeBuild:ke,resumableBuildTicketId:De?.id??null,isRunning:Ie,canRun:Fe,canReview:Ne,reviewActionLabel:Pe,onClose:d,onBuildBundle:_,onStopBuildTicket:v,onResumeBuildTicket:y,onRunBundle:x,onStopBundle:S,onReviewBundle:b})]}),we&&le&&(0,Z.jsx)(`div`,{className:A?ot?`min-h-0 flex flex-col overflow-hidden`:dt:`hidden`,children:(0,Z.jsx)(WW,{createSession:()=>bT(le.id,le.project_id),isExpanded:M,isVisible:A,ariaLabel:w(`bundleDetailsModal.bundleTerminalAriaLabel`),title:w(`workspaceControls.terminalTitle`),className:ot||M?`h-full w-full max-w-none rounded-2xl shadow-2xl`:`h-full w-full max-w-5xl rounded-2xl shadow-2xl`,onClose:()=>{j(!1),N(!1),F(!1),h(e.bundle.id)},onToggleExpanded:()=>{N(e=>!e)}})})]})]})})}),T&&le&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(TG,{ticketId:le.id,projectId:le.project_id,reviewCommentsBundleId:e.bundle.id,title:Tl(e.bundle),onSubmitReviewPrompt:t=>C(e.bundle.id,t),canSubmitReviewPrompt:!tt,reviewSubmitDisabledReason:nt,canAddReviewComments:!tt,canModifyChanges:!tt,changesDisabledReason:nt,onClose:()=>{E(!1),h(e.bundle.id)}})})]})},NG=H(`group/toggle inline-flex cursor-pointer items-center justify-center gap-1 rounded-3xl text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-9 min-w-9 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5`,sm:`h-8 min-w-8 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,lg:`h-10 min-w-10 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3`}},defaultVariants:{variant:`default`,size:`default`}}),PG=Y.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function FG({className:e,variant:t,size:n,spacing:r=0,orientation:i=`horizontal`,children:a,...o}){return(0,Z.jsx)(oa,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:G(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-3xl data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,Z.jsx)(PG.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function IG({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=Y.useContext(PG);return(0,Z.jsx)(sa,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:G(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-3 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-2.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-2.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-3xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-3xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-3xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-3xl data-[state=on]:bg-muted group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,NG({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}var LG=`border-sky-400/30 bg-sky-400/10 text-sky-100`,RG=(e,t)=>Ne.t(`common:pendingFixesPopover.${e}`,t),zG=e=>e.old_line_number!==null&&e.new_line_number!==null?RG(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?RG(`lineReference.unavailable`):RG(`lineReference.oldOnly`,{oldLine:e.old_line_number}):RG(`lineReference.newOnly`,{newLine:e.new_line_number}),BG=e=>e.old_line_number!==null&&e.new_line_number!==null?RG(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?RG(`lineReference.unavailable`):RG(`lineReference.oldOnly`,{oldLine:e.old_line_number}):RG(`lineReference.newOnly`,{newLine:e.new_line_number}),VG=e=>e.subject_type===`file`,HG=({reviewComments:e,reviewFindings:t=[],githubComments:n=[],pendingFixCount:r,triggerMode:i=`full`,canSendReview:a,isSubmittingReview:o,reviewSubmitDisabledReason:s,onClearPendingFixes:c,onSubmitReview:l})=>(0,Z.jsxs)(Zs,{children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,variant:`default`,size:`sm`,className:i===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":RG(`triggerLabel`),disabled:r===0,children:[i===`compact`?(0,Z.jsx)(em,{className:`h-4 w-4`}):(0,Z.jsx)(`span`,{children:RG(`triggerLabel`)}),(0,Z.jsx)(U,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:r}),(0,Z.jsx)(Oe,{className:`h-4 w-4`})]})}),(0,Z.jsxs)($s,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsxs)(ec,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(tc,{children:RG(`title`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:RG(`description`)})]}),(0,Z.jsx)(U,{variant:`outline`,children:r})]}),r===0?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:RG(`empty`)}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:[e.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 px-3 py-3 shadow-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(em,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-sky-200`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:RG(`manualCommentTitle`)}),(0,Z.jsx)(U,{variant:`outline`,className:LG,children:RG(`manualBadge`)})]}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-sky-100/70`,children:[ob(e.scope),` · `,e.filePath,` · `,ab(e)]}),(0,Z.jsx)(`div`,{className:`mt-2 rounded-lg border border-sky-500/15 bg-background/60 px-3 py-2`,children:(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-xs text-foreground`,children:e.comment})})]})]})},`${e.filePath}:${e.changeKey}`)),t.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Wd,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:RG(`findingTitle`,{ordinal:e.ordinal})}),(0,Z.jsx)(U,{variant:`outline`,className:`capitalize`,children:e.severity})]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,zG(e)].filter(Boolean).join(` · `)}),(0,Z.jsx)(`div`,{className:`mt-2 text-xs font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]})]})},e.id)),n.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Mc,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.kind===`review`?RG(`githubReviewSummary`):RG(`githubReviewComment`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,e.kind===`inline`&&!VG(e)?BG(e):e.author].filter(Boolean).join(` · `)}),(0,Z.jsx)(GM,{content:e.body})]})]})},e.id))]}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-2 pt-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,disabled:r===0||o,onClick:c,children:RG(`clear`)}),(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`default`,disabled:!a,title:s,onClick:l,className:`gap-2`,children:[(0,Z.jsx)(yw,{className:`h-4 w-4`}),o?RG(`sending`):RG(`sendFixes`,{count:r})]})]})]})]})]}),UG=({commitMessage:e,onCommitMessageChange:t,commitMessageRef:n,selectedFileCount:r,changesDisabledReason:i,canEditCommitMessage:a=!0,canGenerateCommitMessage:o,canCommit:s,isGeneratingCommitMessage:c,isCommitting:l,onGenerateCommitMessage:u,onCommit:d})=>{let{t:f}=X(`common`),p=e.trim()===``,m=!a||c;return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border bg-background/40 px-4 py-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 xl:flex-row xl:items-center xl:gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 xl:w-56`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:f(`ticketChangesCommitPanel.title`)}),(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 text-xs text-muted-foreground`,children:(0,Z.jsx)(U,{variant:`outline`,children:f(`ticketChangesCommitPanel.selectedFiles`,{count:r})})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(Rs,{"data-disabled":!a,className:`flex-1`,children:[(0,Z.jsx)(Us,{"aria-label":f(`ticketChangesCommitPanel.commitMessageAriaLabel`),id:`ticket-changes-commit-message`,ref:n,value:e,onChange:e=>{t(e.target.value)},placeholder:f(`ticketChangesCommitPanel.commitMessagePlaceholder`),disabled:m,title:i}),p&&(0,Z.jsx)(Bs,{align:`inline-end`,children:(0,Z.jsx)(Hs,{"aria-label":f(`ticketChangesCommitPanel.generateCommitMessageAriaLabel`),disabled:!o,onClick:u,title:i,children:f(c?`ticketChangesCommitPanel.generating`:`ticketChangesCommitPanel.generate`)})})]}),(0,Z.jsxs)(K,{type:`button`,onClick:d,disabled:!s,title:i,className:`w-full gap-2 sm:w-auto sm:min-w-32`,children:[(0,Z.jsx)(kc,{className:`h-4 w-4`}),f(l?`ticketChangesCommitPanel.committing`:`ticketChangesCommitPanel.commit`)]})]})]})})},WG=({isCommitsLoading:e,commitsError:t,unpushedCommits:n,canUndoLatestCommit:r,isUndoing:i,aheadCount:a,onUndoLatestCommit:o})=>{let{t:s}=X(`common`);if(!e&&n.length===0&&!t)return null;let c=n.length||a;return(0,Z.jsxs)(Zs,{children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:s(`ticketChangesCommitsPanel.triggerLabel`)}),(0,Z.jsx)(U,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:c}),(0,Z.jsx)(Oe,{className:`h-4 w-4`})]})}),(0,Z.jsxs)($s,{align:`end`,className:`z-[90] w-[28rem] p-4`,children:[(0,Z.jsxs)(ec,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(tc,{children:s(`ticketChangesCommitsPanel.triggerLabel`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:s(`ticketChangesCommitsPanel.description`)})]}),!e&&!t&&(0,Z.jsx)(U,{variant:`outline`,children:n.length})]}),e?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:s(`ticketChangesCommitsPanel.loading`)}):t?(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,onClick:o,disabled:!r,children:[(0,Z.jsx)(Df,{className:`h-3.5 w-3.5`}),s(i?`ticketChangesCommitsPanel.undoing`:`ticketChangesCommitsPanel.undoLatestCommit`)]})}),(0,Z.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto`,children:n.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.subject}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(U,{variant:`outline`,className:`font-mono`,children:e.short_hash}),(0,Z.jsx)(`span`,{children:new Date(e.committed_at).toLocaleString()})]})]},e.hash))})]})]})]})};function GG(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
145
143
|
font-size: .6rem;
|
|
146
144
|
font-weight: bold;
|
|
147
|
-
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function RG(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var zG=(e,t)=>Math.abs(e-t)<1.01,BG=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},VG=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},HG=e=>e,UG=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},WG=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(VG(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(VG(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},GG={passive:!0},KG=typeof window>`u`?!0:`onscrollend`in window,qG=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&KG?()=>void 0:BG(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,GG);let l=e.options.useScrollendEvent&&KG;return l&&n.addEventListener(`scrollend`,c,GG),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},JG=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},YG=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},XG=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:HG,rangeExtractor:UG,onChange:()=>{},measureElement:JG,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=LG(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=LG(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=LG(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=LG(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?QG({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=LG(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=LG(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return RG(t[ZG(0,t.length-1,e=>RG(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&zG(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},ZG=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function QG({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=ZG(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var $G=typeof document<`u`?Y.useLayoutEffect:Y.useEffect;function eK({useFlushSync:e=!0,...t}){let n=Y.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Fc.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=Y.useState(()=>new XG(r));return i.setOptions(r),$G(()=>i._didMount(),[]),$G(()=>i._willUpdate()),i}function tK(e){return eK({observeElementRect:WG,observeElementOffset:qG,scrollToFn:YG,...e})}var nK=8,rK=520,iK=2,aK=(e,t)=>Ne.t(`common:ticketChangesDiffPanel.${e}`,t),oK=()=>(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-resize-placeholder`,className:`space-y-4 px-3 py-3`,children:[{gutter:`w-8`,code:`w-[68%]`},{gutter:`w-10`,code:`w-[54%]`},{gutter:`w-8`,code:`w-[74%]`},{gutter:`w-6`,code:`w-[38%]`},{gutter:`w-10`,code:`w-[82%]`},{gutter:`w-7`,code:`w-[61%]`},{gutter:`w-9`,code:`w-[48%]`},{gutter:`w-8`,code:`w-[71%]`},{gutter:`w-11`,code:`w-[57%]`},{gutter:`w-7`,code:`w-[66%]`},{gutter:`w-9`,code:`w-[43%]`},{gutter:`w-8`,code:`w-[76%]`}].map((e,t)=>(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-resize-placeholder-row`,className:`flex items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:G(`h-4 rounded bg-muted/80`,e.gutter)}),(0,Z.jsx)(`div`,{className:G(`h-4 rounded bg-muted/60`,e.code)})]},`${e.gutter}-${e.code}-${t}`))}),sK=({additions:e,deletions:t,fileCount:n})=>n===null?[{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}]:[{key:`files`,content:aK(`stats.fileCount`,{count:n}),className:`text-muted-foreground`},{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}],cK=({control:e,mode:t})=>typeof e==`function`?e(t):e??null,lK=e=>e.reduce((e,t)=>e+t.hunks.reduce((e,t)=>e+t.changes.length,0),0),uK=e=>Yy(e),dK=(e,t)=>{let n=`oldPath`in e&&typeof e.oldPath==`string`?t(e.oldPath):``,r=`newPath`in e&&typeof e.newPath==`string`?t(e.newPath):``;return[...new Set([r,n].filter(e=>e&&e!==`/dev/null`))]},fK=e=>e.subject_type===`file`,pK=e=>e.subject_type===`line`,mK=`border-sky-400/30 bg-sky-400/10 text-sky-100`,hK=({context:e,comment:t,reviewDraftInput:n,canEdit:r,autoFocus:i,isReadOnly:a,hasSavedComment:o,onReviewDraftInputChange:s,onCancelReviewDraft:c,onEditReviewDraft:l,onRemoveReviewDraft:u,onSaveReviewDraft:d})=>{let f=(0,Y.useRef)(null),[p,m]=(0,Y.useState)(()=>n),h=uK(e.change);return(0,Y.useEffect)(()=>{!i||a||f.current?.focus({preventScroll:!0})},[i,a]),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(U,{variant:`outline`,className:mK,children:aK(`reviewComment.manualBadge`)}),(0,Z.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-sky-100/80`,children:aK(o?`reviewComment.commentOnLine`:`reviewComment.addCommentToLine`,{lineNumber:h})})]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[a?(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap rounded-xl border border-sky-500/15 bg-background/70 px-3 py-2.5 text-xs text-foreground`,children:t}):(0,Z.jsx)(Ls,{ref:f,"aria-label":aK(`reviewComment.ariaLabel`,{filePath:e.filePath}),value:p,onChange:e=>{m(e.target.value),s(e.target.value)},disabled:!r,className:`min-h-20 text-xs`,placeholder:aK(`reviewComment.placeholder`)}),(0,Z.jsx)(`div`,{className:`flex gap-2`,children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(K,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{l(e.commentKey)},disabled:!r,children:[(0,Z.jsx)(wf,{className:`h-3.5 w-3.5`}),aK(`reviewComment.edit`)]}),(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{u(e.commentKey)},disabled:!r,children:aK(`reviewComment.remove`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{type:`button`,size:`xs`,onClick:()=>{d(e,p)},disabled:!r||!p.trim(),children:aK(`reviewComment.add`)}),(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`ghost`,onClick:c,children:aK(`reviewComment.cancel`)})]})})]})]})},gK=e=>e===`high`?`destructive`:e===`medium`?`warning`:`outline`,_K=e=>e.old_line_number!==null&&e.new_line_number!==null?aK(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?aK(`lineReference.unavailable`):aK(`lineReference.oldOnly`,{oldLine:e.old_line_number}):aK(`lineReference.newOnly`,{newLine:e.new_line_number}),vK=({finding:e,isSelected:t,onToggle:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,Z.jsxs)(`div`,{className:`rounded-xl border border-slate-400/30 bg-slate-400/10 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(Wd,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,Z.jsx)(`div`,{children:aK(`reviewFinding.title`,{ordinal:e.ordinal})}),(0,Z.jsx)(U,{variant:gK(e.severity),className:`normal-case`,children:e.severity})]}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]}),(0,Z.jsxs)(K,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,Z.jsx)(Ll,{className:`h-3.5 w-3.5`}),aK(t?`reviewFinding.selected`:`reviewFinding.fix`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:_K(e)}),e.file_path&&(0,Z.jsx)(`span`,{children:e.file_path})]}),(e.why_text||e.fix_text)&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{i(e=>!e)},children:aK(r?`reviewFinding.hideDetails`:`reviewFinding.details`)}),r&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-xl border border-border bg-background/60 p-3 text-xs text-foreground`,children:[e.why_text&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:aK(`reviewFinding.whyItMatters`)}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.why_text})]}),e.fix_text&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:aK(`reviewFinding.requestedFix`)}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.fix_text})]})]})]})]})},yK=e=>e.old_line_number!==null&&e.new_line_number!==null?aK(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?aK(`lineReference.unavailable`):aK(`lineReference.oldOnly`,{oldLine:e.old_line_number}):aK(`lineReference.newOnly`,{newLine:e.new_line_number}),bK=e=>e.old_line_number!==null||e.new_line_number!==null,xK=e=>e.kind===`review`?aK(`githubComment.reviewSummary`):fK(e)?aK(`githubComment.fileComment`):bK(e)||pK(e)?aK(`githubComment.inlineComment`):aK(`githubComment.fileComment`),SK=({comment:e,isSelected:t,onToggle:n})=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-violet-400/30 bg-violet-400/10 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(U,{variant:`outline`,className:`border-violet-400/40 bg-violet-400/10 text-violet-100`,children:aK(`githubComment.badge`)}),(0,Z.jsx)(`span`,{children:xK(e)}),e.is_outdated&&(0,Z.jsx)(U,{variant:`warning`,className:`normal-case`,children:aK(`githubComment.outdated`)})]}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.author}),(0,Z.jsx)(OG,{content:e.body})]}),(0,Z.jsxs)(K,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,Z.jsx)(Ll,{className:`h-3.5 w-3.5`}),aK(t?`reviewFinding.selected`:`reviewFinding.fix`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[e.file_path&&(0,Z.jsx)(`span`,{children:e.file_path}),e.kind===`inline`&&!fK(e)&&bK(e)&&(0,Z.jsx)(`span`,{children:yK(e)}),(0,Z.jsx)(`span`,{children:new Date(e.updated_at).toLocaleString()}),(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-violet-200 underline underline-offset-2 transition-colors hover:text-violet-100`,children:aK(`githubComment.openOnGitHub`)})]})]}),CK=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,reviewFindings:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of dK(t,n))s.has(e)||s.set(e,t);for(let e of r){let n=e.file_path,r=n?s.get(n):null;if(!r||!n){o.push(e);continue}let c=t(r),l=null;for(let t of r.hunks){for(let n of t.changes)if(Zy(e,n)){l=sv(n);break}if(l)break}if(l){let t=i.get(c)??new Map,n=t.get(l)??[];t.set(l,[...n,e]),i.set(c,t);continue}a.set(c,[...a.get(c)??[],e])}return{inlineByFilePath:i,fileLevelByFilePath:a,globalFindings:o}},wK=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,githubComments:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of dK(t,n))s.has(e)||s.set(e,t);for(let e of r){if(e.kind===`review`||!e.file_path){o.push(e);continue}let n=s.get(e.file_path);if(!n){o.push(e);continue}let r=t(n);if(fK(e)||!e.subject_type&&!bK(e)){a.set(r,[...a.get(r)??[],e]);continue}let c=null;for(let t of n.hunks){for(let n of t.changes)if(Xy(e,n)){c=sv(n);break}if(c)break}if(!c){o.push(e);continue}let l=i.get(r)??new Map,u=l.get(c)??[];l.set(c,[...u,e]),i.set(r,l)}return{inlineByFilePath:i,fileLevelByFilePath:a,fallbackComments:o}},TK=({filePath:e,hunks:t,activeReviewTarget:n,editingReviewCommentKey:r,reviewDraftInstanceKey:i,reviewDraftInput:a,reviewComments:o,reviewFindingsByChangeKey:s,githubCommentsByChangeKey:c,selectedReviewFindingIds:l,selectedGitHubCommentIds:u,canEditActiveReviewDraft:d,onToggleReviewFindingSelection:f,onToggleGitHubCommentSelection:p,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v})=>{let y=new Map(o.map(e=>[sb(e.filePath,e.changeKey),e]));return t.reduce((t,o)=>{for(let b of o.changes){let x=sv(b),S=sb(e,x),C=n?.commentKey===S,w=y.get(S),T=r===S,E=s.get(x)??[],D=c.get(x)??[];if(!C&&!w&&E.length===0&&D.length===0)continue;let O={filePath:e,changeKey:x,commentKey:S,hunk:o,change:b},k=!!w&&!T&&!C,A=k?w?.comment??``:a;t[x]=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[E.map(e=>(0,Z.jsx)(vK,{finding:e,isSelected:l.includes(e.id),onToggle:()=>{f(e.id)}},e.id)),D.map(e=>(0,Z.jsx)(SK,{comment:e,isSelected:u.includes(e.id),onToggle:()=>{p(e.id)}},e.id)),(C||w)&&(0,Z.jsx)(hK,{context:O,comment:w?.comment??``,reviewDraftInput:A,canEdit:d,autoFocus:C||T,isReadOnly:k,hasSavedComment:!!w,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v},`${i??O.commentKey}:${k?`readonly`:`editable`}`)]})}return t},{})},EK=e=>e.reduce((e,t)=>{for(let n of t.changes)e.set(sv(n),{hunk:t,change:n});return e},new Map),DK=(0,Y.memo)(({selectedDiffPath:e,sidebarFiles:t,diffResponse:n,isDiffLoading:r,diffError:i,allDiffFiles:a,renderedFiles:o,viewType:s,onViewTypeChange:c,onRetry:l,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindings:h,githubComments:g,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canSelectReviewTarget:y,canEditActiveReviewDraft:b,reviewFindingsError:x,gitHubCommentsError:S,hasStaleReviewFindings:C,onSelectReviewTarget:w,onToggleReviewFindingSelection:T,onToggleGitHubCommentSelection:E,onReviewDraftInputChange:D,onCancelReviewDraft:O,onEditReviewDraft:k,onRemoveReviewDraft:A,onSaveReviewDraft:j,diffThemeClassName:M,resolveFilePath:N,normalizeDiffPath:P,emptyStateTitle:F=aK(`states.emptyTitle`),emptyStateDescription:I=null,filePickerControl:L,reviewSummaryControl:R,extraHeaderControl:z,headerLayout:B=`stacked`,surfaceVariant:ee=`default`,showViewTypeToggle:te=!0,gutterVariant:ne=`default`,isResizing:V=!1,resizePlaceholderLineThreshold:re=1/0,onVisibleFilePathsChange:H})=>{let ie=(0,Y.useRef)(null),{mode:ae,ref:oe}=Rp({compactAt:ee===`flat`?460:620,tightAt:ee===`flat`?360:500}),se=!!n?.diff?.trim()||o.length>0||(n?.files.length??0)>0,ce=(0,Y.useMemo)(()=>lK(o),[o]),le=e===`all`&&o.length>=nK,ue=V&&ce>re,de=(0,Y.useMemo)(()=>o.map(e=>N(e)).join(`
|
|
148
|
-
`),[o,N]),fe=tK({count:le?o.length:0,getScrollElement:()=>ie.current,estimateSize:()=>rK,overscan:iK,getItemKey:e=>{let t=o[e];return t?`${N(t)}:${t.type??`modify`}`:e},initialRect:{width:0,height:900}}),pe=(0,Y.useMemo)(()=>new Map(n?.files.map(e=>[e.path,e])??[]),[n?.files]),me=(0,Y.useMemo)(()=>CK({allDiffFiles:a,resolveFilePath:N,normalizeDiffPath:P,reviewFindings:C?[]:h}),[a,C,P,N,h]),he=(0,Y.useMemo)(()=>wK({allDiffFiles:a,resolveFilePath:N,normalizeDiffPath:P,githubComments:g}),[a,g,P,N]);(0,Y.useEffect)(()=>{let e=ie.current;e&&(e.scrollTop=0)},[e]),(0,Y.useEffect)(()=>{let e=ie.current;return()=>{window.getSelection()?.removeAllRanges(),e&&(e.scrollTop=0)}},[de]);let ge=fe.getVirtualItems(),W=(0,Y.useMemo)(()=>le?ge.map(e=>N(o[e.index])):o.map(e=>N(e)),[o,N,le,ge]);(0,Y.useEffect)(()=>{H?.(W)},[H,W]);let _e=le&&ge.length>0?ge[0]?.start??0:0,ve=le&&ge.length>0?Math.max(0,fe.getTotalSize()-(ge[ge.length-1]?.end??0)):0,ye=le?ge.map(e=>({file:o[e.index],virtualItem:e})):o.map(e=>({file:e,virtualItem:null})),be=e===`all`?null:t.find(t=>t.path===e)??null,xe=e===`all`?sK({additions:n?.stats?.additions??0,deletions:n?.stats?.deletions??0,fileCount:n?.stats?.files_changed??null}):be?sK({additions:be.additions,deletions:be.deletions,fileCount:null}):[],Se=(0,Y.useMemo)(()=>te?(0,Z.jsxs)(EG,{type:`single`,size:`sm`,variant:`outline`,value:s,onValueChange:e=>{(e===`split`||e===`unified`)&&c(e)},children:[(0,Z.jsx)(DG,{value:`unified`,children:aK(`viewType.unified`)}),(0,Z.jsx)(DG,{value:`split`,children:aK(`viewType.split`)})]}):null,[c,te,s]),Ce=(0,Y.useMemo)(()=>[cK({control:L,mode:ae}),cK({control:R,mode:ae})].filter(Boolean),[L,ae,R]),we=Se||Ce.length>0||z;return(0,Z.jsxs)(`section`,{className:G(`flex min-h-0 flex-1 flex-col overflow-hidden`,ee===`default`?`rounded-2xl border border-border bg-background/30`:`bg-transparent`),children:[(0,Z.jsx)(`div`,{ref:oe,"data-responsive-mode":ae,"data-testid":`ticket-diff-header`,className:G(`grid min-w-0 items-start gap-x-3 gap-y-2 border-b px-4 py-3`,ee===`default`?`border-border`:`border-border/70 px-3`,B===`stacked`?z?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`:we?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:B===`stacked`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-left`,className:`grid min-w-0 gap-2`,children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?aK(`header.allChanges`):e}),xe.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:xe.map(e=>(0,Z.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),Se||Ce.length>0?(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-controls`,className:`flex min-w-0 flex-wrap items-center gap-2 justify-start`,children:[Se?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:Se}):null,Ce.length>0?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 items-center gap-2 justify-start`,children:Ce.map((e,t)=>(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null]}):null]}),z?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:z}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?aK(`header.allChanges`):e}),xe.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:xe.map(e=>(0,Z.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),we?(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-inline-controls`,className:`flex min-w-0 flex-wrap items-start justify-end gap-2`,children:[Se?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:Se}):null,Ce.length>0?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:Ce.map((e,t)=>(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null,z?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:z}):null]}):null]})}),(0,Z.jsx)(`div`,{ref:ie,"data-testid":`ticket-diff-scroll-region`,className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsxs)(`div`,{className:G(`min-h-full pb-4 pt-4`,ee===`default`?`px-4`:`px-0`),children:[r&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:aK(`states.loading`)}),!r&&i&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-4 text-center`,children:[(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-rose-300`,children:i}),(0,Z.jsx)(K,{type:`button`,variant:`outline`,onClick:l,children:aK(`states.retry`)})]}),!r&&!i&&n&&!se&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-foreground`,children:F}),I&&(0,Z.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:I})]}),!r&&!i&&n&&se&&e!==`all`&&o.length===0&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-foreground`,children:aK(`states.noRenderableFileTitle`)}),(0,Z.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:e})]}),!r&&!i&&n&&se&&o.length>0&&ue&&(0,Z.jsx)(oK,{}),!r&&!i&&n&&se&&o.length>0&&!ue&&(0,Z.jsxs)(`div`,{className:G(`archon-diff-viewer`,ne===`compact`&&`archon-diff-viewer--compact-gutter`,e===`all`&&ee===`default`&&`space-y-6`,e===`all`&&ee===`flat`&&`space-y-0`,M),children:[x&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:x}),S&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:S}),me.globalFindings.length>0&&(0,Z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:aK(`reviewFinding.sectionTitle`)}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:me.globalFindings.map(e=>(0,Z.jsx)(vK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))})]}),e===`all`&&he.fallbackComments.length>0&&(0,Z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:aK(`githubComment.sectionTitle`)}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:he.fallbackComments.map(e=>(0,Z.jsx)(SK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))})]}),_e>0&&(0,Z.jsx)(`div`,{style:{height:_e}}),ye.map(({file:t,virtualItem:n})=>{let r=N(t),i=pe.get(r),a=EK(t.hunks),o=me.inlineByFilePath.get(r)??new Map,c=he.inlineByFilePath.get(r)??new Map,l=me.fileLevelByFilePath.get(r)??[],h=he.fileLevelByFilePath.get(r)??[],g=d?m.find(e=>sb(e.filePath,e.changeKey)===d)??null:null,x=[...m.filter(e=>e.filePath===r).map(e=>e.changeKey),...u?.filePath===r?[u.changeKey]:[],...g?.filePath===r?[g.changeKey]:[]],S=TK({filePath:r,hunks:t.hunks,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindingsByChangeKey:o,githubCommentsByChangeKey:c,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canEditActiveReviewDraft:b,onToggleReviewFindingSelection:T,onToggleGitHubCommentSelection:E,onReviewDraftInputChange:D,onCancelReviewDraft:O,onEditReviewDraft:k,onRemoveReviewDraft:A,onSaveReviewDraft:j}),C=(0,Z.jsx)(qv,{diffType:t.type,hunks:t.hunks,tokens:t.tokens,viewType:s,selectedChanges:[...new Set(x)],widgets:S,renderGutter:({change:e,side:t,renderDefault:n,wrapInAnchor:r,inHoverState:i})=>{if(!e)return r(n());let a=sv(e),o=t===`new`,c=y&&t===`new`,l=s===`unified`&&e.type===`normal`&&t===`new`?null:r(n());return(0,Z.jsxs)(`div`,{className:G(`flex items-center justify-end pr-1`,ne===`compact`?`gap-1 pr-0.5`:`gap-2`),children:[l,o&&(0,Z.jsx)(`span`,{"data-diff-gutter-action-slot":`true`,className:[ne===`compact`?`flex size-5 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`:`flex size-6 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`,c&&i?`border-emerald-200 bg-emerald-300 opacity-100`:`opacity-0`,!c&&`pointer-events-none`].join(` `),"aria-hidden":`true`,children:(0,Z.jsx)(Ll,{className:ne===`compact`?`h-3 w-3`:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:a})]})},gutterEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(sv(e));t&&w({filePath:r,changeKey:sv(e),commentKey:sb(r,sv(e)),hunk:t.hunk,change:t.change})}},codeEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(sv(e));t&&w({filePath:r,changeKey:sv(e),commentKey:sb(r,sv(e)),hunk:t.hunk,change:t.change})}},children:e=>e.map(e=>(0,Z.jsx)(Hv,{hunk:e},`${r}-${e.content}`))});return e===`all`?(0,Z.jsx)(`div`,{"data-index":n?.index,ref:n?fe.measureElement:void 0,children:(0,Z.jsxs)(`section`,{className:G(ee===`default`?`rounded-xl border border-border bg-card/70`:`border-t border-border/70 bg-transparent first:border-t-0`),children:[(0,Z.jsxs)(`div`,{className:G(`sticky top-0 z-20 border-b text-xs font-medium text-foreground`,ee===`default`?`rounded-t-xl border-border bg-card px-4 py-3`:`border-border/70 bg-background/95 px-3 py-2.5 backdrop-blur-sm`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[`oldPath`in t&&typeof t.oldPath==`string`&&P(t.oldPath)===`/dev/null`&&(0,Z.jsx)(U,{variant:`success`,className:`shrink-0`,children:aK(`fileBadge.newFile`)}),(0,Z.jsx)(`span`,{children:r})]}),i&&(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-emerald-400`,children:[`+`,i.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono text-rose-400`,children:[`-`,i.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:G(`overflow-x-auto`,ee===`default`?`p-3`:`px-0 py-3`),children:[l.length>0&&(0,Z.jsx)(`div`,{className:G(`mb-3 space-y-3`,ee===`flat`&&`px-3`),children:l.map(e=>(0,Z.jsx)(vK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))}),h.length>0&&(0,Z.jsx)(`div`,{className:G(`mb-3 space-y-3`,ee===`flat`&&`px-3`),children:h.map(e=>(0,Z.jsx)(SK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),C]})]})},`${r}-${t.type??`modify`}`):(0,Z.jsxs)(`div`,{"data-index":n?.index,ref:n?fe.measureElement:void 0,children:[l.length>0&&(0,Z.jsx)(`div`,{className:`mb-3 space-y-3`,children:l.map(e=>(0,Z.jsx)(vK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))}),h.length>0&&(0,Z.jsx)(`div`,{className:`mb-3 space-y-3`,children:h.map(e=>(0,Z.jsx)(SK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),C]},`${r}-${t.type??`modify`}`)}),ve>0&&(0,Z.jsx)(`div`,{style:{height:ve}})]})]})})]})});DK.displayName=`TicketChangesDiffPanel`;var OK=e=>G(`group`,e?`border-sky-700 bg-card/95 shadow-sm`:`border-border/50 bg-transparent text-muted-foreground hover:border-border/80 hover:bg-accent/60 hover:text-accent-foreground hover:shadow-sm`),kK={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},AK={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},jK=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},MK=({selectionWarning:e,gitError:t,sidebarFiles:n,commentCountByPath:r,commentCountTone:i,isGitStatusLoading:a,selectedPaths:o,selectedDiffPath:s,allFilesSelected:c,diffStats:l,title:u=`Changed files`,allChangesDescription:d=`Review the full workspace diff.`,enableSelection:f=!0,onToggleSelectAll:p,onSelectDiffPath:m,onTogglePath:h})=>{let g=i===`bundle_diff`?`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`;return(0,Z.jsxs)(`aside`,{className:`flex min-h-0 h-full flex-col between overflow-hidden rounded-2xl border border-border bg-background/40`,children:[(e||t)&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-border p-4`,children:[e&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:e}),t&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:u}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.length,` file`,n.length===1?``:`s`,` changed`]})]}),f&&(0,Z.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:n.length===0,children:c?`Unselect all`:`Select all`})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[a&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading file list...`}),!a&&n.length===0&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`No changes to review.`}),!a&&n.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{m(`all`)},className:G(`flex w-full cursor-pointer items-start justify-between gap-3 rounded-xl border px-2.5 py-2 text-left transition-colors`,OK(s===`all`)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`All changes`}),l&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[l.files_changed,` file`,l.files_changed===1?``:`s`]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,l.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,l.deletions]})]})]}),(0,Z.jsx)(`div`,{className:`mt-1 flex w-full flex-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:d})]})}),n.map(e=>{let t=f&&o.has(e.path),n=s===e.path,i=r.get(e.path)??0;return(0,Z.jsxs)(`div`,{className:G(`relative flex cursor-pointer items-start gap-2.5 rounded-xl border px-2.5 py-2 transition-colors`,OK(n)),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Open diff for ${e.path}`,onClick:()=>{m(e.path)},className:`absolute inset-0 cursor-pointer rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`}),f&&(0,Z.jsx)(`input`,{type:`checkbox`,"aria-label":e.path,checked:t,onChange:()=>{h(e.path)},className:`relative z-10 mt-0.5 h-4 w-4 rounded border-border bg-background text-primary`}),(0,Z.jsxs)(`div`,{className:`relative z-10 min-w-0 flex-1 cursor-pointer text-left pointer-events-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-1 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:jK(e.path)}),i>0&&(0,Z.jsx)(`span`,{"aria-label":`${i} comment${i===1?``:`s`} in ${e.path}`,className:g,children:i})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,e.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,e.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[e.status&&(0,Z.jsx)(U,{variant:`outline`,className:kK[e.status],children:AK[e.status]}),e.staged&&(0,Z.jsx)(U,{variant:`outline`,children:`Staged`}),e.unstaged&&(0,Z.jsx)(U,{variant:`outline`,children:`Unstaged`}),e.conflicted&&(0,Z.jsx)(U,{variant:`destructive`,children:`Conflicted`}),e.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:e.status===`renamed`?`from ${e.originalPath}`:e.originalPath})]})]})]},`${e.path}:${e.originalPath??``}`)})]})]})]})},NK=[`[--diff-background-color:transparent]`,`[--diff-text-color:rgb(226_232_240)]`,`[--diff-selection-background-color:rgba(148,163,184,0.2)]`,`[--diff-gutter-insert-background-color:rgba(34,197,94,0.16)]`,`[--diff-gutter-delete-background-color:rgba(244,63,94,0.16)]`,`[--diff-gutter-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-code-insert-background-color:rgba(34,197,94,0.08)]`,`[--diff-code-delete-background-color:rgba(244,63,94,0.08)]`,`[--diff-code-insert-edit-background-color:rgba(34,197,94,0.22)]`,`[--diff-code-delete-edit-background-color:rgba(244,63,94,0.22)]`,`[--diff-code-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-font-family:var(--font-mono)]`,`[&_.diff]:w-full`,`[&_.diff]:border-collapse`,`[&_.diff]:font-mono`,`[&_.diff-code]:whitespace-pre-wrap`,`[&_.diff-code]:break-words`,`[&_.diff-gutter]:select-none`].join(` `),PK=25e4,FK=2e3,IK=new Map,LK=e=>e?e.split(`
|
|
149
|
-
`).length:0,RK=e=>{let t=e.diff??``;return t?t.length<=PK&&LK(t)<=FK:!0},zK=({scope:e,projectId:t,ticketId:n})=>e===`project_root`?t?`project_root:${t}`:null:n?`ticket:${t??`none`}:${n}`:null,BK=e=>e?IK.get(e)??null:null,VK=({cacheKey:e,diffResponse:t,gitStatus:n})=>{let r=n.workspace_signature?.trim();if(!(!e||!r)){if(!RK(t)){IK.delete(e);return}IK.set(e,{diffResponse:t,gitStatus:n,workspaceSignature:r})}},HK=e=>{e&&IK.delete(e)},UK={css:`css`,html:`markup`,htm:`markup`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,markdown:`markdown`,sh:`bash`,ts:`typescript`,tsx:`tsx`,yaml:`yaml`,yml:`yaml`},WK=e=>{if(!e)return null;let t=e.split(` -> `),n=t[t.length-1]??e,r=n.split(`/`),i=r[r.length-1]??n,a=``;if(i.includes(`.`)){let e=i.split(`.`);a=e[e.length-1]?.toLowerCase()??``}return UK[a]??null},GK=new Set,KK=e=>{e&&GK.forEach(t=>t(e))},qK=e=>(GK.add(e),()=>{GK.delete(e)}),JK=300,YK=(e,t={})=>{let n=t.dedupeMs??JK,r=0,i=()=>{if(document.visibilityState!==`visible`)return;let t=Date.now();t-r<n||(r=t,e())};return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,i)}},XK=i(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),ZK=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.normal={},n.property={};function r(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}})),QK=i(((e,t)=>{var n=XK(),r=ZK();t.exports=i;function i(e){for(var t=e.length,i=[],a=[],o=-1,s,c;++o<t;)s=e[o],i.push(s.property),a.push(s.normal),c=s.space;return new r(n.apply(null,i),n.apply(null,a),c)}})),$K=i(((e,t)=>{t.exports=n;function n(e){return e.toLowerCase()}})),eq=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.attribute=null,n.property=null,n.boolean=!1,n.booleanish=!1,n.overloadedBoolean=!1,n.number=!1,n.commaSeparated=!1,n.spaceSeparated=!1,n.commaOrSpaceSeparated=!1,n.mustUseProperty=!1,n.defined=!1;function r(e,t){this.property=e,this.attribute=t}})),tq=i((e=>{var t=0;e.boolean=n(),e.booleanish=n(),e.overloadedBoolean=n(),e.number=n(),e.spaceSeparated=n(),e.commaSeparated=n(),e.commaOrSpaceSeparated=n();function n(){return 2**++t}})),nq=i(((e,t)=>{var n=eq(),r=tq();t.exports=o,o.prototype=new n,o.prototype.defined=!0;var i=[`boolean`,`booleanish`,`overloadedBoolean`,`number`,`commaSeparated`,`spaceSeparated`,`commaOrSpaceSeparated`],a=i.length;function o(e,t,o,c){var l=-1,u;for(s(this,`space`,c),n.call(this,e,t);++l<a;)u=i[l],s(this,u,(o&r[u])===r[u])}function s(e,t,n){n&&(e[t]=n)}})),rq=i(((e,t)=>{var n=$K(),r=ZK(),i=nq();t.exports=a;function a(e){var t=e.space,a=e.mustUseProperty||[],o=e.attributes||{},s=e.properties,c=e.transform,l={},u={},d,f;for(d in s)f=new i(d,c(o,d),s[d],t),a.indexOf(d)!==-1&&(f.mustUseProperty=!0),l[d]=f,u[n(d)]=d,u[n(f.attribute)]=d;return new r(l,u,t)}})),iq=i(((e,t)=>{t.exports=rq()({space:`xlink`,transform:n,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function n(e,t){return`xlink:`+t.slice(5).toLowerCase()}})),aq=i(((e,t)=>{t.exports=rq()({space:`xml`,transform:n,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function n(e,t){return`xml:`+t.slice(3).toLowerCase()}})),oq=i(((e,t)=>{t.exports=n;function n(e,t){return t in e?e[t]:t}})),sq=i(((e,t)=>{var n=oq();t.exports=r;function r(e,t){return n(e,t.toLowerCase())}})),cq=i(((e,t)=>{t.exports=rq()({space:`xmlns`,attributes:{xmlnsxlink:`xmlns:xlink`},transform:sq(),properties:{xmlns:null,xmlnsXLink:null}})})),lq=i(((e,t)=>{var n=tq(),r=rq(),i=n.booleanish,a=n.number,o=n.spaceSeparated;t.exports=r({transform:s,properties:{ariaActiveDescendant:null,ariaAtomic:i,ariaAutoComplete:null,ariaBusy:i,ariaChecked:i,ariaColCount:a,ariaColIndex:a,ariaColSpan:a,ariaControls:o,ariaCurrent:null,ariaDescribedBy:o,ariaDetails:null,ariaDisabled:i,ariaDropEffect:o,ariaErrorMessage:null,ariaExpanded:i,ariaFlowTo:o,ariaGrabbed:i,ariaHasPopup:null,ariaHidden:i,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:o,ariaLevel:a,ariaLive:null,ariaModal:i,ariaMultiLine:i,ariaMultiSelectable:i,ariaOrientation:null,ariaOwns:o,ariaPlaceholder:null,ariaPosInSet:a,ariaPressed:i,ariaReadOnly:i,ariaRelevant:null,ariaRequired:i,ariaRoleDescription:o,ariaRowCount:a,ariaRowIndex:a,ariaRowSpan:a,ariaSelected:i,ariaSetSize:a,ariaSort:null,ariaValueMax:a,ariaValueMin:a,ariaValueNow:a,ariaValueText:null,role:null}});function s(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}})),uq=i(((e,t)=>{var n=tq(),r=rq(),i=sq(),a=n.boolean,o=n.overloadedBoolean,s=n.booleanish,c=n.number,l=n.spaceSeparated,u=n.commaSeparated;t.exports=r({space:`html`,attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},transform:i,mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:u,acceptCharset:l,accessKey:l,action:null,allow:null,allowFullScreen:a,allowPaymentRequest:a,allowUserMedia:a,alt:null,as:null,async:a,autoCapitalize:null,autoComplete:l,autoFocus:a,autoPlay:a,capture:a,charSet:null,checked:a,cite:null,className:l,cols:c,colSpan:null,content:null,contentEditable:s,controls:a,controlsList:l,coords:c|u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:a,defer:a,dir:null,dirName:null,disabled:a,download:o,draggable:s,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:a,formTarget:null,headers:l,height:c,hidden:a,high:c,href:null,hrefLang:null,htmlFor:l,httpEquiv:l,id:null,imageSizes:null,imageSrcSet:u,inputMode:null,integrity:null,is:null,isMap:a,itemId:null,itemProp:l,itemRef:l,itemScope:a,itemType:l,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:a,low:c,manifest:null,max:null,maxLength:c,media:null,method:null,min:null,minLength:c,multiple:a,muted:a,name:null,nonce:null,noModule:a,noValidate:a,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:a,optimum:c,pattern:null,ping:l,placeholder:null,playsInline:a,poster:null,preload:null,readOnly:a,referrerPolicy:null,rel:l,required:a,reversed:a,rows:c,rowSpan:c,sandbox:l,scope:null,scoped:a,seamless:a,selected:a,shape:null,size:c,sizes:null,slot:null,span:c,spellCheck:s,src:null,srcDoc:null,srcLang:null,srcSet:u,start:c,step:null,style:null,tabIndex:c,target:null,title:null,translate:null,type:null,typeMustMatch:a,useMap:null,value:s,width:c,wrap:null,align:null,aLink:null,archive:l,axis:null,background:null,bgColor:null,border:c,borderColor:null,bottomMargin:c,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:a,declare:a,event:null,face:null,frame:null,frameBorder:null,hSpace:c,leftMargin:c,link:null,longDesc:null,lowSrc:null,marginHeight:c,marginWidth:c,noResize:a,noHref:a,noShade:a,noWrap:a,object:null,profile:null,prompt:null,rev:null,rightMargin:c,rules:null,scheme:null,scrolling:s,standby:null,summary:null,text:null,topMargin:c,valueType:null,version:null,vAlign:null,vLink:null,vSpace:c,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:a,disableRemotePlayback:a,prefix:null,property:null,results:c,security:null,unselectable:null}})})),dq=i(((e,t)=>{var n=QK(),r=iq();t.exports=n([aq(),r,cq(),lq(),uq()])})),fq=i(((e,t)=>{var n=$K(),r=nq(),i=eq(),a=`data`;t.exports=l;var o=/^data[-\w.:]+$/i,s=/-[a-z]/g,c=/[A-Z]/g;function l(e,t){var s=n(t),c=t,l=i;return s in e.normal?e.property[e.normal[s]]:(s.length>4&&s.slice(0,4)===a&&o.test(t)&&(t.charAt(4)===`-`?c=u(t):t=d(t),l=r),new l(c,t))}function u(e){var t=e.slice(5).replace(s,p);return a+t.charAt(0).toUpperCase()+t.slice(1)}function d(e){var t=e.slice(4);return s.test(t)?e:(t=t.replace(c,f),t.charAt(0)!==`-`&&(t=`-`+t),a+t)}function f(e){return`-`+e.toLowerCase()}function p(e){return e.charAt(1).toUpperCase()}})),pq=i(((e,t)=>{t.exports=r;var n=/[#.]/g;function r(e,t){for(var r=e||``,i=t||`div`,a={},o=0,s,c,l;o<r.length;)n.lastIndex=o,l=n.exec(r),s=r.slice(o,l?l.index:r.length),s&&(c?c===`#`?a.id=s:a.className?a.className.push(s):a.className=[s]:i=s,o+=s.length),l&&(c=l[0],o++);return{type:`element`,tagName:i,properties:a,children:[]}}})),mq=i((e=>{e.parse=i,e.stringify=a;var t=``,n=` `,r=/[ \t\n\r\f]+/g;function i(e){var n=String(e||t).trim();return n===t?[]:n.split(r)}function a(e){return e.join(n).trim()}})),hq=i((e=>{e.parse=i,e.stringify=a;var t=`,`,n=` `,r=``;function i(e){for(var n=[],i=String(e||r),a=i.indexOf(t),o=0,s=!1,c;!s;)a===-1&&(a=i.length,s=!0),c=i.slice(o,a).trim(),(c||!s)&&n.push(c),o=a+1,a=i.indexOf(t,o);return n}function a(e,i){var a=i||{},o=a.padLeft===!1?r:n,s=a.padRight?n:r;return e[e.length-1]===r&&(e=e.concat(r)),e.join(s+t+o).trim()}})),gq=i(((e,t)=>{var n=fq(),r=$K(),i=pq(),a=mq().parse,o=hq().parse;t.exports=c;var s={}.hasOwnProperty;function c(e,t,r){var c=r?h(r):null;return u;function u(e,n){var r=i(e,t),a=Array.prototype.slice.call(arguments,2),o=r.tagName.toLowerCase(),u;if(r.tagName=c&&s.call(c,o)?c[o]:o,n&&l(n,r)&&(a.unshift(n),n=null),n)for(u in n)p(r.properties,u,n[u]);return d(r.children,a),r.tagName===`template`&&(r.content={type:`root`,children:r.children},r.children=[]),r}function p(t,r,i){var s,c,l;i==null||i!==i||(s=n(e,r),c=s.property,l=i,typeof l==`string`&&(s.spaceSeparated?l=a(l):s.commaSeparated?l=o(l):s.commaOrSpaceSeparated&&(l=a(o(l).join(` `)))),c===`style`&&typeof i!=`string`&&(l=m(l)),c===`className`&&t.className&&(l=t.className.concat(l)),t[c]=f(s,c,l))}}function l(e,t){return typeof e==`string`||`length`in e||u(t.tagName,e)}function u(e,t){var n=t.type;return e===`input`||!n||typeof n!=`string`?!1:typeof t.children==`object`&&`length`in t.children?!0:(n=n.toLowerCase(),e===`button`?n!==`menu`&&n!==`submit`&&n!==`reset`&&n!==`button`:`value`in t)}function d(e,t){var n,r;if(typeof t==`string`||typeof t==`number`){e.push({type:`text`,value:String(t)});return}if(typeof t==`object`&&`length`in t){for(n=-1,r=t.length;++n<r;)d(e,t[n]);return}if(typeof t!=`object`||!(`type`in t))throw Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function f(e,t,n){var r,i,a;if(typeof n!=`object`||!(`length`in n))return p(e,t,n);for(i=n.length,r=-1,a=[];++r<i;)a[r]=p(e,t,n[r]);return a}function p(e,t,n){var i=n;return e.number||e.positiveNumber?!isNaN(i)&&i!==``&&(i=Number(i)):(e.boolean||e.overloadedBoolean)&&typeof i==`string`&&(i===``||r(n)===r(t))&&(i=!0),i}function m(e){var t=[],n;for(n in e)t.push([n,e[n]].join(`: `));return t.join(`; `)}function h(e){for(var t=e.length,n=-1,r={},i;++n<t;)i=e[n],r[i.toLowerCase()]=i;return r}})),_q=i(((e,t)=>{var n=dq(),r=gq()(n,`div`);r.displayName=`html`,t.exports=r})),vq=i(((e,t)=>{t.exports=_q()})),yq=r({AElig:()=>`Æ`,AMP:()=>`&`,Aacute:()=>`Á`,Acirc:()=>`Â`,Agrave:()=>`À`,Aring:()=>`Å`,Atilde:()=>`Ã`,Auml:()=>`Ä`,COPY:()=>`©`,Ccedil:()=>`Ç`,ETH:()=>`Ð`,Eacute:()=>`É`,Ecirc:()=>`Ê`,Egrave:()=>`È`,Euml:()=>`Ë`,GT:()=>`>`,Iacute:()=>`Í`,Icirc:()=>`Î`,Igrave:()=>`Ì`,Iuml:()=>`Ï`,LT:()=>`<`,Ntilde:()=>`Ñ`,Oacute:()=>`Ó`,Ocirc:()=>`Ô`,Ograve:()=>`Ò`,Oslash:()=>`Ø`,Otilde:()=>`Õ`,Ouml:()=>`Ö`,QUOT:()=>`"`,REG:()=>`®`,THORN:()=>`Þ`,Uacute:()=>`Ú`,Ucirc:()=>`Û`,Ugrave:()=>`Ù`,Uuml:()=>`Ü`,Yacute:()=>`Ý`,aacute:()=>`á`,acirc:()=>`â`,acute:()=>`´`,aelig:()=>`æ`,agrave:()=>`à`,amp:()=>`&`,aring:()=>`å`,atilde:()=>`ã`,auml:()=>`ä`,brvbar:()=>`¦`,ccedil:()=>`ç`,cedil:()=>`¸`,cent:()=>`¢`,copy:()=>`©`,curren:()=>`¤`,default:()=>bq,deg:()=>`°`,divide:()=>`÷`,eacute:()=>`é`,ecirc:()=>`ê`,egrave:()=>`è`,eth:()=>`ð`,euml:()=>`ë`,frac12:()=>`½`,frac14:()=>`¼`,frac34:()=>`¾`,gt:()=>`>`,iacute:()=>`í`,icirc:()=>`î`,iexcl:()=>`¡`,igrave:()=>`ì`,iquest:()=>`¿`,iuml:()=>`ï`,laquo:()=>`«`,lt:()=>`<`,macr:()=>`¯`,micro:()=>`µ`,middot:()=>`·`,nbsp:()=>`\xA0`,not:()=>`¬`,ntilde:()=>`ñ`,oacute:()=>`ó`,ocirc:()=>`ô`,ograve:()=>`ò`,ordf:()=>`ª`,ordm:()=>`º`,oslash:()=>`ø`,otilde:()=>`õ`,ouml:()=>`ö`,para:()=>`¶`,plusmn:()=>`±`,pound:()=>`£`,quot:()=>`"`,raquo:()=>`»`,reg:()=>`®`,sect:()=>`§`,shy:()=>``,sup1:()=>`¹`,sup2:()=>`²`,sup3:()=>`³`,szlig:()=>`ß`,thorn:()=>`þ`,times:()=>`×`,uacute:()=>`ú`,ucirc:()=>`û`,ugrave:()=>`ù`,uml:()=>`¨`,uuml:()=>`ü`,yacute:()=>`ý`,yen:()=>`¥`,yuml:()=>`ÿ`}),bq,xq=n((()=>{bq={AElig:`Æ`,AMP:`&`,Aacute:`Á`,Acirc:`Â`,Agrave:`À`,Aring:`Å`,Atilde:`Ã`,Auml:`Ä`,COPY:`©`,Ccedil:`Ç`,ETH:`Ð`,Eacute:`É`,Ecirc:`Ê`,Egrave:`È`,Euml:`Ë`,GT:`>`,Iacute:`Í`,Icirc:`Î`,Igrave:`Ì`,Iuml:`Ï`,LT:`<`,Ntilde:`Ñ`,Oacute:`Ó`,Ocirc:`Ô`,Ograve:`Ò`,Oslash:`Ø`,Otilde:`Õ`,Ouml:`Ö`,QUOT:`"`,REG:`®`,THORN:`Þ`,Uacute:`Ú`,Ucirc:`Û`,Ugrave:`Ù`,Uuml:`Ü`,Yacute:`Ý`,aacute:`á`,acirc:`â`,acute:`´`,aelig:`æ`,agrave:`à`,amp:`&`,aring:`å`,atilde:`ã`,auml:`ä`,brvbar:`¦`,ccedil:`ç`,cedil:`¸`,cent:`¢`,copy:`©`,curren:`¤`,deg:`°`,divide:`÷`,eacute:`é`,ecirc:`ê`,egrave:`è`,eth:`ð`,euml:`ë`,frac12:`½`,frac14:`¼`,frac34:`¾`,gt:`>`,iacute:`í`,icirc:`î`,iexcl:`¡`,igrave:`ì`,iquest:`¿`,iuml:`ï`,laquo:`«`,lt:`<`,macr:`¯`,micro:`µ`,middot:`·`,nbsp:`\xA0`,not:`¬`,ntilde:`ñ`,oacute:`ó`,ocirc:`ô`,ograve:`ò`,ordf:`ª`,ordm:`º`,oslash:`ø`,otilde:`õ`,ouml:`ö`,para:`¶`,plusmn:`±`,pound:`£`,quot:`"`,raquo:`»`,reg:`®`,sect:`§`,shy:``,sup1:`¹`,sup2:`²`,sup3:`³`,szlig:`ß`,thorn:`þ`,times:`×`,uacute:`ú`,ucirc:`û`,ugrave:`ù`,uml:`¨`,uuml:`ü`,yacute:`ý`,yen:`¥`,yuml:`ÿ`}})),Sq=r({default:()=>Cq}),Cq,wq=n((()=>{Cq={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`}})),Tq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}})),Eq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}})),Dq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}})),Oq=i(((e,t)=>{var n=Dq(),r=Tq();t.exports=i;function i(e){return n(e)||r(e)}})),kq=i(((e,t)=>{var n,r=59;t.exports=i;function i(e){var t=`&`+e+`;`,i;return n||=document.createElement(`i`),n.innerHTML=t,i=n.textContent,i.charCodeAt(i.length-1)===r&&e!==`semi`||i===t?!1:i}})),Aq=i(((e,n)=>{var r=(xq(),t(yq).default),i=(wq(),t(Sq).default),a=Tq(),o=Eq(),s=Oq(),c=kq();n.exports=R;var l={}.hasOwnProperty,u=String.fromCharCode,d=Function.prototype,f={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},p=9,m=10,h=12,g=32,_=38,v=59,y=60,b=61,x=35,S=88,C=120,w=65533,T=`named`,E=`hexadecimal`,D=`decimal`,O={};O[E]=16,O[D]=10;var k={};k[T]=s,k[D]=a,k[E]=o;var A=1,j=2,M=3,N=4,P=5,F=6,I=7,L={};L[A]=`Named character references must be terminated by a semicolon`,L[j]=`Numeric character references must be terminated by a semicolon`,L[M]=`Named character references cannot be empty`,L[N]=`Numeric character references cannot be empty`,L[P]=`Named character references must be known`,L[F]=`Numeric character references cannot be disallowed`,L[I]=`Numeric character references cannot be outside the permissible Unicode range`;function R(e,t){var n={},r,i;for(i in t||={},f)r=t[i],n[i]=r??f[i];return(n.position.indent||n.position.start)&&(n.indent=n.position.indent||[],n.position=n.position.start),z(e,n)}function z(e,t){var n=t.additional,a=t.nonTerminated,o=t.text,f=t.reference,R=t.warning,z=t.textContext,te=t.referenceContext,ne=t.warningContext,V=t.position,re=t.indent||[],H=e.length,ie=0,ae=-1,oe=V.column||1,se=V.line||1,ce=``,le=[],U,ue,de,fe,pe,me,he,ge,W,_e,ve,ye,be,G,xe,Se,Ce,we,Te;for(typeof n==`string`&&(n=n.charCodeAt(0)),Se=Ee(),ge=R?De:d,ie--,H++;++ie<H;)if(pe===m&&(oe=re[ae]||1),pe=e.charCodeAt(ie),pe===_){if(he=e.charCodeAt(ie+1),he===p||he===m||he===h||he===g||he===_||he===y||he!==he||n&&he===n){ce+=u(pe),oe++;continue}for(be=ie+1,ye=be,Te=be,he===x?(Te=++ye,he=e.charCodeAt(Te),he===S||he===C?(G=E,Te=++ye):G=D):G=T,U=``,ve=``,fe=``,xe=k[G],Te--;++Te<H&&(he=e.charCodeAt(Te),xe(he));)fe+=u(he),G===T&&l.call(r,fe)&&(U=fe,ve=r[fe]);de=e.charCodeAt(Te)===v,de&&(Te++,ue=G===T?c(fe):!1,ue&&(U=fe,ve=ue)),we=1+Te-be,!de&&!a||(fe?G===T?(de&&!ve?ge(P,1):(U!==fe&&(Te=ye+U.length,we=1+Te-ye,de=!1),de||(W=U?A:M,t.attribute?(he=e.charCodeAt(Te),he===b?(ge(W,we),ve=null):s(he)?ve=null:ge(W,we)):ge(W,we))),me=ve):(de||ge(j,we),me=parseInt(fe,O[G]),B(me)?(ge(I,we),me=u(w)):me in i?(ge(F,we),me=i[me]):(_e=``,ee(me)&&ge(F,we),me>65535&&(me-=65536,_e+=u(me>>>10|55296),me=56320|me&1023),me=_e+u(me))):G!==T&&ge(N,we)),me?(Oe(),Se=Ee(),ie=Te-1,oe+=Te-be+1,le.push(me),Ce=Ee(),Ce.offset++,f&&f.call(te,me,{start:Se,end:Ce},e.slice(be-1,Te)),Se=Ce):(fe=e.slice(be-1,Te),ce+=fe,oe+=fe.length,ie=Te-1)}else pe===10&&(se++,ae++,oe=0),pe===pe?(ce+=u(pe),oe++):Oe();return le.join(``);function Ee(){return{line:se,column:oe,offset:ie+(V.offset||0)}}function De(e,t){var n=Ee();n.column+=t,n.offset+=t,R.call(ne,L[e],n,e)}function Oe(){ce&&=(le.push(ce),o&&o.call(z,ce,{start:Se,end:Ee()}),``)}}function B(e){return e>=55296&&e<=57343||e>1114111}function ee(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}})),jq=i(((e,t)=>{var n=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,r={},i={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof a?new a(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,`&`).replace(/</g,`<`).replace(/\u00a0/g,` `)},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,`__id`,{value:++n}),e.__id},clone:function e(t,n){n||={};var r,a;switch(i.util.type(t)){case`Object`:if(a=i.util.objId(t),n[a])return n[a];for(var o in r={},n[a]=r,t)t.hasOwnProperty(o)&&(r[o]=e(t[o],n));return r;case`Array`:return a=i.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return`none`},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,`gi`),``),e.classList.add(`language-`+n)},currentScript:function(){if(typeof document>`u`)return null;if(`currentScript`in document)return document.currentScript;try{throw Error()}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var t=document.getElementsByTagName(`script`);for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var r=`no-`+t;e;){var i=e.classList;if(i.contains(t))return!0;if(i.contains(r))return!1;e=e.parentElement}return!!n}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,t){var n=i.util.clone(i.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=i.languages;var a=r[e],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==t)for(var c in n)n.hasOwnProperty(c)&&(o[c]=n[c]);n.hasOwnProperty(s)||(o[s]=a[s])}var l=r[e];return r[e]=o,i.languages.DFS(i.languages,function(t,n){n===l&&t!=e&&(this[t]=o)}),o},DFS:function e(t,n,r,a){a||={};var o=i.util.objId;for(var s in t)if(t.hasOwnProperty(s)){n.call(t,s,t[s],r||s);var c=t[s],l=i.util.type(c);l===`Object`&&!a[o(c)]?(a[o(c)]=!0,e(c,n,null,a)):l===`Array`&&!a[o(c)]&&(a[o(c)]=!0,e(c,n,s,a))}}},plugins:{},highlightAll:function(e,t){i.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var r={callback:n,container:e,selector:`code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code`};i.hooks.run(`before-highlightall`,r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),i.hooks.run(`before-all-elements-highlight`,r);for(var a=0,o;o=r.elements[a++];)i.highlightElement(o,t===!0,r.callback)},highlightElement:function(t,n,r){var a=i.util.getLanguage(t),o=i.languages[a];i.util.setLanguage(t,a);var s=t.parentElement;s&&s.nodeName.toLowerCase()===`pre`&&i.util.setLanguage(s,a);var c={element:t,language:a,grammar:o,code:t.textContent};function l(e){c.highlightedCode=e,i.hooks.run(`before-insert`,c),c.element.innerHTML=c.highlightedCode,i.hooks.run(`after-highlight`,c),i.hooks.run(`complete`,c),r&&r.call(c.element)}if(i.hooks.run(`before-sanity-check`,c),s=c.element.parentElement,s&&s.nodeName.toLowerCase()===`pre`&&!s.hasAttribute(`tabindex`)&&s.setAttribute(`tabindex`,`0`),!c.code){i.hooks.run(`complete`,c),r&&r.call(c.element);return}if(i.hooks.run(`before-highlight`,c),!c.grammar){l(i.util.encode(c.code));return}if(n&&e.Worker){var u=new Worker(i.filename);u.onmessage=function(e){l(e.data)},u.postMessage(JSON.stringify({language:c.language,code:c.code,immediateClose:!0}))}else l(i.highlight(c.code,c.grammar,c.language))},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(i.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=i.tokenize(r.code,r.grammar),i.hooks.run(`after-tokenize`,r),a.stringify(i.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new c;return l(i,i.head,e),s(e,i,t,i.head,0),d(i)},hooks:{all:{},add:function(e,t){var n=i.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=i.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:a};e.Prism=i;function a(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}a.stringify=function e(t,n){if(typeof t==`string`)return t;if(Array.isArray(t)){var r=``;return t.forEach(function(t){r+=e(t,n)}),r}var a={type:t.type,content:e(t.content,n),tag:`span`,classes:[`token`,t.type],attributes:{},language:n},o=t.alias;o&&(Array.isArray(o)?Array.prototype.push.apply(a.classes,o):a.classes.push(o)),i.hooks.run(`wrap`,a);var s=``;for(var c in a.attributes)s+=` `+c+`="`+(a.attributes[c]||``).replace(/"/g,`"`)+`"`;return`<`+a.tag+` class="`+a.classes.join(` `)+`"`+s+`>`+a.content+`</`+a.tag+`>`};function o(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function s(e,t,n,r,c,d){for(var f in n)if(!(!n.hasOwnProperty(f)||!n[f])){var p=n[f];p=Array.isArray(p)?p:[p];for(var m=0;m<p.length;++m){if(d&&d.cause==f+`,`+m)return;var h=p[m],g=h.inside,_=!!h.lookbehind,v=!!h.greedy,y=h.alias;if(v&&!h.pattern.global){var b=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,b+`g`)}for(var x=h.pattern||h,S=r.next,C=c;S!==t.tail&&!(d&&C>=d.reach);C+=S.value.length,S=S.next){var w=S.value;if(t.length>e.length)return;if(!(w instanceof a)){var T=1,E;if(v){if(E=o(x,C,e,_),!E||E.index>=e.length)break;var D=E.index,O=E.index+E[0].length,k=C;for(k+=S.value.length;D>=k;)S=S.next,k+=S.value.length;if(k-=S.value.length,C=k,S.value instanceof a)continue;for(var A=S;A!==t.tail&&(k<O||typeof A.value==`string`);A=A.next)T++,k+=A.value.length;T--,w=e.slice(C,k),E.index-=C}else if(E=o(x,0,w,_),!E)continue;var D=E.index,j=E[0],M=w.slice(0,D),N=w.slice(D+j.length),P=C+w.length;d&&P>d.reach&&(d.reach=P);var F=S.prev;M&&(F=l(t,F,M),C+=M.length),u(t,F,T);var I=new a(f,g?i.tokenize(j,g):j,y,j);if(S=l(t,F,I),N&&l(t,S,N),T>1){var L={cause:f+`,`+m,reach:P};s(e,t,n,S.prev,C,L),d&&L.reach>d.reach&&(d.reach=L.reach)}}}}}}function c(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function l(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function u(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function d(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}if(!e.document)return e.addEventListener&&(i.disableWorkerMessageHandler||e.addEventListener(`message`,function(t){var n=JSON.parse(t.data),r=n.language,a=n.code,o=n.immediateClose;e.postMessage(i.highlight(a,i.languages[r],r)),o&&e.close()},!1)),i;var f=i.util.currentScript();f&&(i.filename=f.src,f.hasAttribute(`data-manual`)&&(i.manual=!0));function p(){i.manual||i.highlightAll()}if(!i.manual){var m=document.readyState;m===`loading`||m===`interactive`&&f&&f.defer?document.addEventListener(`DOMContentLoaded`,p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return i}(typeof window<`u`?window:typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope?self:{});t!==void 0&&t.exports&&(t.exports=n),typeof global<`u`&&(global.Prism=n)})),Mq=i(((e,t)=>{t.exports=n,n.displayName=`markup`,n.aliases=[`html`,`mathml`,`svg`,`xml`,`ssml`,`atom`,`rss`];function n(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&/,`&`))}),Object.defineProperty(e.languages.markup.tag,`addInlined`,{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,`addAttribute`,{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}})),Nq=i(((e,t)=>{t.exports=n,n.displayName=`css`,n.aliases=[];function n(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}})),Pq=i(((e,t)=>{t.exports=n,n.displayName=`clike`,n.aliases=[];function n(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}})),Fq=i(((e,t)=>{t.exports=n,n.displayName=`javascript`,n.aliases=[`js`];function n(e){e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}})),Iq=i(((e,t)=>{var n=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},r=C();n.Prism={manual:!0,disableWorkerMessageHandler:!0};var i=vq(),a=Aq(),o=jq(),s=Mq(),c=Nq(),l=Pq(),u=Fq();r();var d={}.hasOwnProperty;function f(){}f.prototype=o;var p=new f;t.exports=p,p.highlight=g,p.register=m,p.alias=h,p.registered=_,p.listLanguages=v,m(s),m(c),m(l),m(u),p.util.encode=x,p.Token.stringify=y;function m(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `grammar`, got `"+e+"`");p.languages[e.displayName]===void 0&&e(p)}function h(e,t){var n=p.languages,r=e,i,a,o,s;for(i in t&&(r={},r[e]=t),r)for(a=r[i],a=typeof a==`string`?[a]:a,o=a.length,s=-1;++s<o;)n[a[s]]=n[i]}function g(e,t){var n=o.highlight,r;if(typeof e!=`string`)throw Error("Expected `string` for `value`, got `"+e+"`");if(p.util.type(t)===`Object`)r=t,t=null;else{if(typeof t!=`string`)throw Error("Expected `string` for `name`, got `"+t+"`");if(d.call(p.languages,t))r=p.languages[t];else throw Error("Unknown language: `"+t+"` is not registered")}return n.call(this,e,r,t)}function _(e){if(typeof e!=`string`)throw Error("Expected `string` for `language`, got `"+e+"`");return d.call(p.languages,e)}function v(){var e=p.languages,t=[],n;for(n in e)d.call(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function y(e,t,n){var r;return typeof e==`string`?{type:`text`,value:e}:p.util.type(e)===`Array`?b(e,t):(r={type:e.type,content:p.Token.stringify(e.content,t,n),tag:`span`,classes:[`token`,e.type],attributes:{},language:t,parent:n},e.alias&&(r.classes=r.classes.concat(e.alias)),p.hooks.run(`wrap`,r),i(r.tag+`.`+r.classes.join(`.`),S(r.attributes),r.content))}function b(e,t){for(var n=[],r=e.length,i=-1,a;++i<r;)a=e[i],a!==``&&a!=null&&n.push(a);for(i=-1,r=n.length;++i<r;)a=n[i],n[i]=p.Token.stringify(a,t,n);return n}function x(e){return e}function S(e){for(var t in e)e[t]=a(e[t]);return e}function C(){var e=`Prism`in n,t=e?n.Prism:void 0;return r;function r(){e?n.Prism=t:delete n.Prism,e=void 0,t=void 0}}})),Lq=i(((e,t)=>{t.exports=n,n.displayName=`bash`,n.aliases=[`shell`];function n(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.shell=e.languages.bash})(e)}})),Rq=i(((e,t)=>{t.exports=n,n.displayName=`json`,n.aliases=[`webmanifest`];function n(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}})),zq=i(((e,t)=>{t.exports=n,n.displayName=`jsx`,n.aliases=[];function n(e){(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){e.language!==`jsx`&&e.language!==`tsx`||s(e.tokens)})})(e)}})),Bq=i(((e,t)=>{t.exports=n,n.displayName=`markdown`,n.aliases=[`md`];function n(e){(function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(l(t.content.value),s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}});var o=RegExp(e.languages.markup.tag.pattern.source,`gi`),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;function l(e){var t=e.replace(o,``);return t=t.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){return t=t.toLowerCase(),t[0]===`#`?c(t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1))):s[t]||e}),t}e.languages.md=e.languages.markdown})(e)}})),Vq=i(((e,t)=>{t.exports=n,n.displayName=`typescript`,n.aliases=[`ts`];function n(e){(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}})),Hq=i(((e,t)=>{var n=zq(),r=Vq();t.exports=i,i.displayName=`tsx`,i.aliases=[];function i(e){e.register(n),e.register(r),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}})),Uq=i(((e,t)=>{t.exports=n,n.displayName=`yaml`,n.aliases=[`yml`];function n(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}})),Wq=e(Iq(),1),Gq=e(Lq(),1),Kq=e(Nq(),1),qq=e(Fq(),1),Jq=e(Rq(),1),Yq=e(zq(),1),Xq=e(Bq(),1),Zq=e(Mq(),1),Qq=e(Hq(),1),$q=e(Vq(),1),eJ=e(Uq(),1),tJ=e=>{let t=e.displayName;!t||Wq.default.registered(t)||Wq.default.register(e)};tJ(Zq.default),tJ(Kq.default),tJ(qq.default),tJ($q.default),tJ(Qq.default),tJ(Jq.default),tJ(Yq.default),tJ(Xq.default),tJ(eJ.default),tJ(Gq.default);var nJ=r({TicketChangesModal:()=>MJ}),rJ=(e,t)=>Ne.t(`common:ticketChangesModal.${e}`,t),iJ=4,aJ=1500,oJ=`archon.ticket-changes.review-comments`,sJ=[],cJ=[],lJ=[],uJ=e=>new Set(e.map(e=>e.path)),dJ=(e,t)=>{if(!e)return null;if(e.blocked_reason)return e.blocked_reason;let n=e.files.find(e=>!t.has(e.path)&&e.staged);return n?`"${n.path}" already has staged changes. Finish that commit in the terminal first.`:null},fJ=e=>e.replace(/^[ab]\//,``),pJ=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?fJ(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?fJ(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},mJ=e=>{let[t,n]=pJ(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},hJ=e=>{let[t,n]=pJ(e);return t??n??null},gJ=e=>e.hunks.reduce((e,t)=>e+t.changes.length,0),_J=e=>{if(gJ(e)>aJ)return null;let t=WK(hJ(e));if(!t)return null;try{return qy(e.hunks,{highlight:!0,refractor:Wq.default,language:t,enhancers:[Gy(e.hunks)]})}catch{return null}},vJ=(e,t)=>e instanceof Error?e.message:t,yJ=(e,t)=>`${oJ}:${e}:${t}`,bJ=()=>({activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map,signature:null}),xJ=()=>({uncommitted:bJ(),bundle_diff:bJ()}),SJ=e=>({uncommitted:e(),bundle_diff:e()}),CJ=()=>SJ(()=>new Map),wJ=e=>{let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^e.charCodeAt(n);return`${e.length}:${t>>>0}`},TJ=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return(t.scope===void 0||t.scope===`uncommitted`||t.scope===`bundle_diff`)&&typeof t.filePath==`string`&&typeof t.changeKey==`string`&&typeof t.changeType==`string`&&(typeof t.oldLineNumber==`number`||t.oldLineNumber===null)&&(typeof t.newLineNumber==`number`||t.newLineNumber===null)&&typeof t.hunkHeader==`string`&&typeof t.lineContent==`string`&&typeof t.diffSnippet==`string`&&typeof t.comment==`string`},EJ=e=>{try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.diffSignature!=`string`||!Array.isArray(n.comments))return null;let r=n.comments.filter(TJ).map(e=>({scope:e.scope??`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.changeType,oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber,hunkHeader:e.hunkHeader,lineContent:e.lineContent,diffSnippet:e.diffSnippet,comment:e.comment}));return r.length===n.comments.length?{diffSignature:n.diffSignature,comments:r}:null}catch{return null}},DJ=e=>new Map(e.map(e=>[sb(e.filePath,e.changeKey),e])),OJ=(e,t)=>{e.set(t,(e.get(t)??0)+1)},kJ=e=>e.find(e=>e.trim())||``,AJ=({pullRequest:e,isLoading:t,isOpen:n,canCreate:r,disabledReason:i,isCreating:a,isSyncing:o,isGeneratingDescription:s,title:c,body:l,baseBranch:u,onOpenChange:d,onTitleChange:f,onBodyChange:p,onBaseBranchChange:m,showGenerateDescription:h,onGenerateDescription:g,onCreate:_})=>t?(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:`Loading PR...`}):o?(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:[(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}),`Checking PR...`]}):e?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border/80 bg-background/50 px-3 py-2`,children:[(0,Z.jsx)(_w,{pullRequest:e}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-xs font-medium text-sky-300 underline underline-offset-2 hover:text-sky-200`,children:[`PR #`,e.number]})]}):(0,Z.jsxs)(Zs,{open:n,onOpenChange:d,children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`default`,disabled:!r,title:i,className:`gap-2`,children:[a?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Mc,{className:`h-4 w-4`}),a?`Creating PR...`:`Create PR`]})}),(0,Z.jsxs)($s,{align:`end`,className:`z-[90] w-[36rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsx)(ec,{children:(0,Z.jsx)(tc,{children:`Create pull request`})}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(xu,{label:`Title`,htmlFor:`bundle-pr-title`,children:(0,Z.jsx)(We,{id:`bundle-pr-title`,value:c,onChange:e=>f(e.target.value),placeholder:`Bundle title`,disabled:a})}),(0,Z.jsx)(xu,{label:`Base branch`,htmlFor:`bundle-pr-base-branch`,description:`Optional. Leave blank to use the repository default branch.`,children:(0,Z.jsx)(We,{id:`bundle-pr-base-branch`,value:u,onChange:e=>m(e.target.value),placeholder:`main`,disabled:a})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,htmlFor:`bundle-pr-body`,children:`Description`}),h&&(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a||s,onClick:g,children:[s?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):null,s?`Generating...`:`Generate`]})]}),(0,Z.jsx)(Ls,{id:`bundle-pr-body`,value:l,onChange:e=>p(e.target.value),placeholder:`Summarize the bundle changes for reviewers.`,className:`min-h-40`,disabled:a})]}),(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(K,{type:`button`,size:`sm`,disabled:!c.trim()||a,onClick:_,children:a?`Creating...`:`Create PR`})})]})]})]}),jJ=(e,t,n)=>{if(n)return uJ(t);let r=new Set(t.map(e=>e.path));return new Set([...e].filter(e=>r.has(e)))},MJ=e=>{let{projectId:t,reviewCommentsBundleId:n=null,title:r,onClose:i,onSubmitReviewPrompt:a,canSubmitReviewPrompt:o=!1,reviewSubmitDisabledReason:s,canAddReviewComments:c=!0,canModifyChanges:l=!0,changesDisabledReason:u}=e,d=e.scope??`ticket`,{isGitHubConnected:f}=ff(t),p=e.scope===`project_root`?null:e.ticketId,m=e.scope===`project_root`?void 0:e.onTicketUpdate,h=e.scope===`project_root`?void 0:e.onRequestTicketRefresh,[g,_]=(0,Y.useState)(`uncommitted`),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)([]),[E,D]=(0,Y.useState)(new Set),[O,k]=(0,Y.useState)(`all`),[A,j]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(null),[R,z]=(0,Y.useState)(null),[B,te]=(0,Y.useState)(!0),[ne,V]=(0,Y.useState)(!1),[re,H]=(0,Y.useState)(!0),[ie,ae]=(0,Y.useState)(!1),[oe,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(!1),[de,he]=(0,Y.useState)(null),[ge,W]=(0,Y.useState)(!1),[_e,ve]=(0,Y.useState)(`unified`),[ye,be]=(0,Y.useState)(new Map),[G,xe]=(0,Y.useState)(lJ),[we,Te]=(0,Y.useState)(xJ),[Ee,De]=(0,Y.useState)(null),[Ae,Me]=(0,Y.useState)([]),[Ne,Pe]=(0,Y.useState)(null),[Fe,Ie]=(0,Y.useState)(null),[Le,ze]=(0,Y.useState)(new Set),[Be,Ue]=(0,Y.useState)(new Set),[We,Ge]=(0,Y.useState)(!1),[Ke,qe]=(0,Y.useState)(null),[Je,Ye]=(0,Y.useState)(!1),[Xe,Ze]=(0,Y.useState)(!1),[Qe,$e]=(0,Y.useState)(``),[et,q]=(0,Y.useState)(``),[J,tt]=(0,Y.useState)(``),[nt,rt]=(0,Y.useState)([]),[it,at]=(0,Y.useState)(!1),[ot,st]=(0,Y.useState)(!1),[ct,lt]=(0,Y.useState)(!1),ut=(0,Y.useRef)(null),dt=(0,Y.useRef)(!1),ft=(0,Y.useRef)(null),pt=(0,Y.useRef)(null),mt=(0,Y.useRef)(0),ht=(0,Y.useRef)(0),gt=(0,Y.useRef)(!1),_t=(0,Y.useRef)(SJ(()=>null)),vt=(0,Y.useRef)(CJ()),X=(0,Y.useMemo)(()=>zK({scope:d,projectId:t,ticketId:p}),[t,d,p]),yt=(0,Y.useCallback)(()=>{if(!p)throw Error(`Ticket changes require a ticket id.`);return p},[p]),bt=(0,Y.useCallback)(e=>{ft.current=e,y(e),N(null)},[]),xt=(0,Y.useCallback)((e,t)=>{VK({cacheKey:X,diffResponse:e,gitStatus:t})},[X]),St=(0,Y.useCallback)(e=>{ft.current&&VK({cacheKey:X,diffResponse:ft.current,gitStatus:e})},[X]),Ct=(0,Y.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ve(t)}return await Zt(yt(),t)},[t,yt,d]),wt=(0,Y.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await ke(t)}return await Qt(yt(),t,{refreshRemote:!1})},[t,yt,d]),Et=(0,Y.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await me(t)}return await nn(yt(),t)},[t,yt,d]),At=(0,Y.useCallback)(async e=>d===`project_root`||!n||!t?null:await Pt(t,n,e),[t,n,d]),jt=(0,Y.useCallback)(async e=>d===`project_root`||!n||!t?null:await Tt(t,n,e),[t,n,d]),Mt=(0,Y.useCallback)(async e=>d===`project_root`||!n||!t?null:await Ft(t,n,e),[t,n,d]),Nt=(0,Y.useCallback)(async e=>d===`project_root`||!n||!t?null:await It(t,n,e),[t,n,d]),Lt=(0,Y.useCallback)((e,t)=>{Te(n=>({...n,[e]:t(n[e])}))},[]),Rt=(0,Y.useCallback)(async e=>{if(d===`project_root`||!n||!t)throw Error(`Pull request description generation requires a bundle context.`);return await Ot(t,n,e)},[t,n,d]),zt=(0,Y.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await se(t,e)}return await $t(yt(),t,e)},[t,yt,d]),Bt=(0,Y.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ce(t,e)}return await en(yt(),t,e)},[t,yt,d]),Vt=(0,Y.useCallback)(async(e={})=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await fe(t,e)}return await tn(yt(),t,e)},[t,yt,d]),Ht=(0,Y.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await ee(t)}return await rn(yt(),t)},[t,yt,d]),Ut=(0,Y.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=mt.current+1;mt.current=r,ae(!0),n||z(null);try{let t=await Et();if(!e()||mt.current!==r)return;T(t.commits),z(null)}catch(t){if(!e()||mt.current!==r)return;z(vJ(t,`Unable to load local commits right now.`)),n||T([])}finally{e()&&mt.current===r&&ae(!1)}},[Et]),Wt=(0,Y.useCallback)(()=>{mt.current+=1,T([]),z(null),ae(!1)},[]),Gt=(0,Y.useCallback)((e,t={})=>{let n=t.resetSelection??!1;pt.current=e,C(e),L(null),D(t=>{let r=jJ(t,e.files,n||!dt.current);return dt.current=!0,r})},[]),Kt=(0,Y.useCallback)(async(e={})=>{let t=e.preserveContent??!1,n=e.gitStatusForCache??null;t||N(null),te(!0);try{let e=await Ct();bt(e),n&&xt(e,n)}catch(e){n&&HK(X),(!t||!ft.current)&&N(vJ(e,`Unable to load the diff right now.`))}finally{te(!1)}},[bt,X,Ct,xt]),qt=(0,Y.useCallback)(async(e={})=>{let r=e.preserveContent??!1;if(d===`project_root`||!n||!t){x(null),F(null),V(!1);return}r||F(null),V(!0);try{x(await Mt()),F(null)}catch(e){(!r||!b)&&F(vJ(e,`Unable to load the branch diff right now.`))}finally{V(!1)}},[b,t,Mt,n,d]),Jt=(0,Y.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=t.resetSelection??!1,i=t.allowCache??!0?BK(X):null;if(n||(N(null),L(null)),H(!0),i){bt(i.diffResponse),Gt(i.gitStatus,{resetSelection:r}),te(!1);try{let t=await wt();if(!e())return;Gt(t,{resetSelection:r}),H(!1),(t.ahead??0)>0?Ut(e,{preserveContent:!0}):Wt();let n=t.workspace_signature??null;if(n&&n===i.workspaceSignature){xt(i.diffResponse,t);return}HK(X),await Kt({preserveContent:!0,gitStatusForCache:t});return}catch(t){if(!e())return;L(vJ(t,`Unable to load git status right now.`)),C(null),H(!1),Wt();return}}te(!0),Ct().then(t=>{e()&&(bt(t),pt.current&&xt(t,pt.current))}).catch(t=>{e()&&(!n||!ft.current)&&N(vJ(t,`Unable to load the diff right now.`))}).finally(()=>{e()&&te(!1)});try{let t=await wt();if(!e())return;Gt(t,{resetSelection:r}),H(!1),ft.current&&xt(ft.current,t),(t.ahead??0)>0?Ut(e,{preserveContent:n}):Wt()}catch(t){if(!e())return;L(vJ(t,`Unable to load git status right now.`)),n||C(null),H(!1),Wt()}},[bt,Gt,X,Wt,Ut,Kt,Ct,wt,xt]),Yt=(0,Y.useCallback)(async()=>{if(!t)return;let e=ht.current+1;ht.current=e,H(!0);try{let t=await wt();if(ht.current!==e)return;let n=pt.current?.workspace_signature??null,r=t.workspace_signature??null,i=!ft.current||n!==r;if(Gt(t),(t.ahead??0)>0?Ut(()=>ht.current===e,{preserveContent:!0}):Wt(),!i){St(t);return}await Kt({preserveContent:!0,gitStatusForCache:t})}catch{return}finally{ht.current===e&&H(!1)}},[Gt,Wt,Ut,Kt,t,wt,St]);(0,Y.useEffect)(()=>{ft.current=v},[v]),(0,Y.useEffect)(()=>{pt.current=S},[S]),(0,Y.useEffect)(()=>{let e=!0;return Jt(()=>e,{resetSelection:!0}),()=>{e=!1}},[Jt]),(0,Y.useEffect)(()=>{if(t)return qK(e=>{if(e===t){if(gt.current){gt.current=!1;return}Yt()}})},[t,Yt]),(0,Y.useEffect)(()=>{if(!t)return;let e=YK(()=>{document.visibilityState===`visible`&&Yt()});return()=>{e()}},[t,Yt]),(0,Y.useEffect)(()=>{if(d===`project_root`){De(null),Pe(null),ze(new Set);return}if(!v?.diff?.trim()){De(null),Pe(null),ze(new Set);return}let e=new AbortController,t=!0;return Pe(null),At(e.signal).then(e=>{t&&(De(e),ze(t=>{let n=new Set((e?.findings??[]).map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(n=>{!t||e.signal.aborted||(Pe(vJ(n,`Unable to load review findings right now.`)),De(null),ze(new Set))}),()=>{t=!1,e.abort()}},[v?.diff,At,d]),(0,Y.useEffect)(()=>{_(`uncommitted`),_t.current=SJ(()=>null),vt.current=CJ(),Te(xJ()),x(null),F(null),V(!1),Me([]),Ie(null),Ue(new Set),qe(null),Ye(!1),Ze(!1),$e(``),q(``),tt(``),rt([]),at(!1),st(!1),lt(!1)},[n]),(0,Y.useEffect)(()=>{if(d===`project_root`||!n||!t){qe(null),Ye(!1);return}if(v===null&&!M){Ye(!1);return}let e=new AbortController,i=!0;return Ye(!0),jt(e.signal).then(e=>{i&&(qe(e),$e(t=>t.trim()?t:e?.bundle?Tl(e.bundle):r),q(t=>t.trim()?t:kJ(e?.recent_commit_subjects??nt)),tt(t=>t.trim()?t:e?.bundle.pull_request?.base_branch??``))}).catch(()=>{!i||e.signal.aborted||qe(null)}).finally(()=>{i&&Ye(!1)}),()=>{i=!1,e.abort()}},[M,v,nt,t,jt,n,d,r]),(0,Y.useEffect)(()=>{if(d===`project_root`||!n||!t){x(null),F(null),V(!1);return}if(g!==`bundle_diff`){V(!1);return}let e=new AbortController,r=!0;return V(!0),F(null),Mt(e.signal).then(e=>{r&&(x(e),F(null))}).catch(t=>{!r||e.signal.aborted||(F(vJ(t,`Unable to load the branch diff right now.`)),x(null))}).finally(()=>{r&&V(!1)}),()=>{r=!1,e.abort()}},[g,t,Mt,n,d]),(0,Y.useEffect)(()=>{let e=Ke?.bundle.pull_request??null;if(d===`project_root`||!n||!t||!e){Me([]),Ie(null),Ue(new Set);return}if(!f){Me([]),Ie(null),Ue(new Set);return}if(g!==`bundle_diff`)return;let r=new AbortController,i=!0;return Ie(null),Nt(r.signal).then(e=>{!i||!e||(Me(e.comments),Ie(e.error),Ue(t=>{let n=new Set(e.comments.map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(e=>{!i||r.signal.aborted||(Me([]),Ie(vJ(e,`Unable to load GitHub review comments right now.`)),Ue(new Set))}),()=>{i=!1,r.abort()}},[g,Ke?.bundle.pull_request,f,t,Nt,n,d]),(0,Y.useEffect)(()=>{re&&S===null||ut.current?.focus()},[S,re]);let Xt=(0,Y.useMemo)(()=>{let e=typeof v?.diff==`string`?v.diff:``;return e.trim()?Rm(e).map(e=>({...e,pathCandidates:pJ(e)})):[]},[v]),an=(0,Y.useMemo)(()=>{let e=typeof b?.diff==`string`?b.diff:``;return e.trim()?Rm(e).map(e=>({...e,pathCandidates:pJ(e)})):[]},[b]),on=(0,Y.useMemo)(()=>{let e=v?.diff??``;return e?wJ(e):null},[v?.diff]),sn=(0,Y.useMemo)(()=>{let e=b?.diff??``;return e?wJ(e):null},[b?.diff]),cn=g===`bundle_diff`?b:v,ln=g===`bundle_diff`?an:Xt,un=(0,Y.useMemo)(()=>n?{uncommitted:yJ(n,`uncommitted`),bundle_diff:yJ(n,`bundle_diff`)}:{uncommitted:null,bundle_diff:null},[n]),dn=(0,Y.useMemo)(()=>({uncommitted:on,bundle_diff:sn}),[sn,on]),fn=(0,Y.useMemo)(()=>{let e=new Map;for(let t of cn?.files??[])e.set(t.path,t);return e},[cn]),pn=(0,Y.useMemo)(()=>{let e=new Map;for(let t of ln)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[ln]),mn=(0,Y.useCallback)(e=>{xe(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),hn=(0,Y.useMemo)(()=>g===`bundle_diff`?(b?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})):S?(S.files??[]).map(e=>{let t=fn.get(e.path)??(e.original_path?fn.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(v?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})),[g,b?.files,fn,v?.files,S]);(0,Y.useEffect)(()=>{O!==`all`&&(hn.some(e=>e.path===O)||k(`all`))},[O,hn]);let gn=g===`bundle_diff`?0:E.size,_n=de!==null,vn=de===`force`,yn=g===`bundle_diff`?hn.length:S?.files?.length??hn.length,bn=yn>0&&gn===yn,xn=(0,Y.useMemo)(()=>g===`bundle_diff`?null:dJ(S,E),[g,S,E]),Sn=g===`uncommitted`&&!re&&!oe&&l&&!!S&&gn>0&&A.trim().length>0&&xn===null,Cn=g===`uncommitted`&&!re&&!B&&!le&&!oe&&!_n&&l&&!We&&!!S&&gn>0,wn=!re&&(_n||!!S?.can_push&&(S?.ahead??0)>0),Tn=wn&&!!S?.can_force_push_with_lease,En=wn&&l&&!_n&&!oe,Dn=Tn&&l&&!_n&&!oe,On=l&&!ie&&!ge&&!oe&&!_n&&(w?.length??0)>0,kn=(S?.ahead??0)>0?`${S?.ahead??0} to push`:`Up to date`,An=(S?.behind??0)>0?`${S?.behind??0} behind`:`In sync`,jn=S?.branch??null,Mn=O===`all`?null:pn.get(O)??null,Nn=(0,Y.useMemo)(()=>O===`all`?ln:Mn?[Mn]:[],[ln,O,Mn]);(0,Y.useEffect)(()=>{be(new Map),xe(lJ)},[g,ln]),(0,Y.useEffect)(()=>{let e={uncommitted:un.uncommitted&&dn.uncommitted?`${un.uncommitted}:${dn.uncommitted}`:null,bundle_diff:un.bundle_diff&&dn.bundle_diff?`${un.bundle_diff}:${dn.bundle_diff}`:null},t=_t.current;t.uncommitted===e.uncommitted&&t.bundle_diff===e.bundle_diff||(_t.current=e,Te(n=>{let r={...n};return[`uncommitted`,`bundle_diff`].forEach(i=>{if(t[i]===e[i])return;let a=dn[i],o=un[i],s=n[i];if(t[i]===null&&a&&(s.activeTarget||s.editingCommentKey||s.draftInput.trim()||s.comments.size>0)){r[i]={...s,signature:a};return}if(!a){vt.current[i]=new Map,r[i]=bJ();return}let c=new Map;if(o){let e=window.localStorage.getItem(o),t=e?EJ(e):null;t?.diffSignature===a?c=DJ(t.comments.map(e=>({...e,scope:i}))):e!==null&&window.localStorage.removeItem(o)}vt.current[i]=new Map,r[i]={activeTarget:null,editingCommentKey:null,draftInput:``,comments:c,signature:a}}),r}))},[dn,un]),(0,Y.useEffect)(()=>{[`uncommitted`,`bundle_diff`].forEach(e=>{let t=un[e],n=dn[e],r=we[e];if(!t||!n||r.signature!==n)return;if(r.comments.size===0){window.localStorage.removeItem(t);return}let i={diffSignature:n,comments:[...r.comments.values()]};window.localStorage.setItem(t,JSON.stringify(i))})},[dn,un,we]),(0,Y.useEffect)(()=>{if(ln.length===0)return;let e=!1,t=null,n=(()=>{if(!Mn){let e=[],t=new Set;for(let n of G){let r=pn.get(n);if(!r)continue;let i=mJ(r);t.has(i)||(t.add(i),e.push(r))}return e.length>0?e:ln.slice(0,iJ)}return[Mn]})(),r=0,i=()=>{if(e)return;let a=n.slice(r,r+iJ);a.length!==0&&(be(e=>{let t=new Map(e);for(let e of a){let n=mJ(e);t.has(n)||t.set(n,_J(e))}return t}),r+=iJ,r<n.length&&(t=window.setTimeout(i,0)))};return n.length<=iJ?i():t=window.setTimeout(i,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[ln,pn,Mn,G]);let Pn=(0,Y.useMemo)(()=>Nn.map(e=>({...e,tokens:ye.get(mJ(e))??null})),[ye,Nn]),Fn=(0,Y.useMemo)(()=>ln.map(e=>({...e,tokens:null})),[ln]),In=(0,Y.useMemo)(()=>{let e=new Map;for(let t of ln){let n=mJ(t);e.set(n,n);for(let r of pJ(t))e.set(r,n)}return e},[ln]),Ln=(0,Y.useMemo)(()=>[...we.uncommitted.comments.values()],[we.uncommitted.comments]),Rn=(0,Y.useMemo)(()=>[...we.bundle_diff.comments.values()],[we.bundle_diff.comments]),zn=we[g],Bn=zn.activeTarget,Vn=zn.editingCommentKey,Hn=Bn?.commentKey??Vn,Un=Hn?`${g}:${Hn}`:g,Wn=Hn?vt.current[g].get(Hn)??zn.draftInput:zn.draftInput,Gn=g===`bundle_diff`?Rn:Ln,Kn=(0,Y.useMemo)(()=>[...Ln,...Rn],[Rn,Ln]),qn=(0,Y.useMemo)(()=>Ee?.findings??[],[Ee]),Jn=(0,Y.useMemo)(()=>Ee?.is_current_diff?qn.filter(e=>Le.has(e.id)):[],[qn,Ee?.is_current_diff,Le]),Yn=(0,Y.useMemo)(()=>[...Le],[Le]),Xn=(0,Y.useMemo)(()=>Ae.filter(e=>Be.has(e.id)),[Ae,Be]),Zn=(0,Y.useMemo)(()=>[...Be],[Be]),Qn=Kn.length+Jn.length+Xn.length,$n=!!(Ee?.review_run&&qn.length>0&&!Ee.is_current_diff),er=Ke?.bundle.pull_request??null,tr=(0,Y.useMemo)(()=>nt.length>0?nt:Ke?.recent_commit_subjects??[],[Ke?.recent_commit_subjects,nt]),nr=Ke?.has_helper_model===!0,rr=d!==`project_root`&&!!n&&!!t,ir=g===`bundle_diff`?P:M,ar=B&&v===null,or=ne&&b===null,sr=re&&S===null,cr=Je&&Ke===null,lr=g===`bundle_diff`?or:ar,ur=g===`uncommitted`?qn:sJ,dr=g===`uncommitted`?Yn:lJ,fr=g===`bundle_diff`?Ae:cJ,pr=g===`bundle_diff`?Zn:lJ,mr=g===`bundle_diff`?`bundle_diff`:`uncommitted`,hr=(0,Y.useMemo)(()=>{let e=new Map,t=e=>e?In.get(e)??e:null;for(let n of Gn){let r=t(n.filePath);r&&OJ(e,r)}if(g===`uncommitted`){if($n)return e;for(let n of qn){let r=t(n.file_path);r&&OJ(e,r)}return e}for(let n of Ae){let r=t(n.file_path);r&&OJ(e,r)}return e},[g,In,Gn,Ae,$n,qn]),gr=($n?0:qn.length)+Ln.length,_r=Ae.length+Rn.length,vr=g===`bundle_diff`?`No branch diff to show.`:`No uncommitted changes to show.`,yr=g===`uncommitted`&&rr?`Switch to Branch diff to review the full branch diff.`:null,br=rr&&!cr&&!!Ke&&Ke?.bundle.kind!==`project_root`&&S?.has_upstream===!0&&f,xr=br&&!er&&!it&&!ot&&!ct&&!We&&!_n&&!oe&&!ge&&(S?.ahead??0)===0&&!!S?.branch,Sr=(0,Y.useCallback)(e=>{if(!e){Ze(!1);return}if(!t||!n||!br||er||ot){Ze(e);return}st(!0),kt(t,n).then(e=>{qe(e),tt(t=>t.trim()?t:e.bundle.pull_request?.base_branch??``),Ze(!e.bundle.pull_request)}).catch(e=>{Q.error(vJ(e,`Unable to check for an existing pull request right now.`),{id:`ticket-changes-sync-pr-error`}),Ze(!0)}).finally(()=>{st(!1)})},[er,ot,t,n,br]),Cr=(0,Y.useMemo)(()=>{if(br)return(S?.ahead??0)>0?`Push the branch before creating a pull request.`:S?.branch?u:`Bundle branch information is not available right now.`},[u,S?.ahead,S?.branch,br]),wr=c&&!lr&&(g===`bundle_diff`||!sr)&&!oe&&!_n&&!ge,Tr=Bn?wr||zn.comments.has(Bn.commentKey):wr,Er=!!a&&o&&Qn>0&&!We,Dr=(0,Y.useCallback)(e=>{ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Or=(0,Y.useCallback)(e=>{Ue(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),kr=(0,Y.useCallback)(()=>{vt.current=CJ(),Te(e=>({uncommitted:{...e.uncommitted,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map},bundle_diff:{...e.bundle_diff,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map}}))},[]),Ar=(0,Y.useCallback)(()=>{kr(),ze(new Set),Ue(new Set)},[kr]),jr=(0,Y.useCallback)(async()=>{if(!(!t||!n||!xr)){at(!0);try{let e=await Dt(t,n,{title:Qe.trim(),body:et.trim(),base_branch:J.trim()||null});qe(e),tt(e.bundle.pull_request?.base_branch??J.trim()),Ze(!1),Q.success(`Pull request created.`,{id:`ticket-changes-create-pr-success`})}catch(e){Q.error(vJ(e,`Unable to create the pull request right now.`),{id:`ticket-changes-create-pr-error`})}finally{at(!1)}}},[xr,t,J,et,Qe,n]),Mr=(0,Y.useCallback)(async()=>{if(!(!t||!n||!br||ct)){lt(!0);try{q((await Rt({title:Qe.trim(),commit_subjects:tr})).description)}catch(e){Q.error(vJ(e,`Unable to generate the pull request description right now.`),{id:`ticket-changes-generate-pr-description-error`})}finally{lt(!1)}}},[ct,t,tr,Qe,Rt,n,br]),Nr=(0,Y.useCallback)(({filePath:e,changeKey:t,commentKey:n})=>{let r=zn.comments.get(n),i=vt.current[g].get(n)??r?.comment??``;if(r){k(r.filePath),Lt(g,e=>({...e,activeTarget:null,editingCommentKey:n,draftInput:i}));return}wr&&Lt(g,r=>({...r,activeTarget:{filePath:e,changeKey:t,commentKey:n},editingCommentKey:null,draftInput:i}))},[g,zn.comments,wr,Lt]),Pr=(0,Y.useCallback)(()=>{Hn&&vt.current[g].delete(Hn),Lt(g,e=>({...e,activeTarget:null,editingCommentKey:null,draftInput:``}))},[g,Hn,Lt]),Fr=(0,Y.useCallback)(e=>{Hn&&vt.current[g].set(Hn,e)},[g,Hn]),Ir=(0,Y.useCallback)((e,t)=>{let n=zn.comments.has(e.commentKey);if(!wr&&!n)return;let r=t.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;Lt(g,t=>{let n=new Map(t.comments);return n.set(e.commentKey,{scope:g,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:cb(e.hunk,e.change),comment:r}),{...t,activeTarget:null,editingCommentKey:null,draftInput:``,comments:n}}),vt.current[g].delete(e.commentKey)},[g,zn.comments,wr,Lt]),Lr=(0,Y.useCallback)(e=>{let t=zn.comments.get(e);if(!t)return;k(t.filePath);let n=vt.current[g].get(e)??t.comment;Lt(g,t=>({...t,activeTarget:null,editingCommentKey:e,draftInput:n}))},[g,zn.comments,Lt]),Rr=(0,Y.useCallback)(e=>{vt.current[g].delete(e),Lt(g,t=>{let n=new Map(t.comments);return n.delete(e),{...t,activeTarget:t.activeTarget?.commentKey===e?null:t.activeTarget,editingCommentKey:t.editingCommentKey===e?null:t.editingCommentKey,draftInput:t.activeTarget?.commentKey===e||t.editingCommentKey===e?``:t.draftInput,comments:n}})},[g,Lt]),zr=(0,Y.useCallback)(async()=>{if(!a||!Er)return;Ge(!0);let e=_b({drafts:Kn,findings:Jn,githubComments:Xn,uncommittedFiles:Xt,bundleFiles:an});try{await a(e),kr(),ze(new Set),Ue(new Set),De(e=>e&&{...e,findings:[],is_current_diff:!1}),Q.success(`Fixes submitted.`,{id:`ticket-diff-review-submit-success`}),i()}catch(e){Q.error(vJ(e,`Unable to submit the review right now.`),{id:`ticket-diff-review-submit-error`})}finally{Ge(!1)}},[Kn,an,Er,kr,i,a,Xn,Jn,Xt]),Br=(0,Y.useCallback)(()=>{if(g===`bundle_diff`){qt();return}Jt(()=>!0,{allowCache:!1,resetSelection:!dt.current})},[g,qt,Jt]),Vr=(0,Y.useMemo)(()=>a?(0,Z.jsx)(PG,{reviewComments:Kn,reviewFindings:Jn,githubComments:Xn,pendingFixCount:Qn,canSendReview:Er,isSubmittingReview:We,reviewSubmitDisabledReason:s,onClearPendingFixes:Ar,onSubmitReview:()=>{zr()}}):null,[Kn,Er,Ar,zr,We,a,Qn,s,Xn,Jn]),Hr=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ur=()=>{S&&D(bn?new Set:uJ(S.files))},Wr=async()=>{if(Sn){ce(!0);try{let e=await zt({message:A.trim(),selected_paths:[...E]});e.ticket&&m?.(e.ticket),Gt(e.git_status,{resetSelection:!0}),j(``),t&&(gt.current=!0,KK(t)),p&&h?.(p),await Kt({preserveContent:!0,gitStatusForCache:e.git_status}),await qt({preserveContent:!0}),(e.git_status.ahead??0)>0?await Ut(()=>!0):Wt(),Q.success(`Commit created.`,{id:`ticket-git-commit-success`})}catch(e){Q.error(vJ(e,`Unable to create the commit right now.`),{id:`ticket-git-commit-error`})}finally{ce(!1)}}},Gr=async()=>{if(Cn){ue(!0);try{j((await Bt({selected_paths:[...E]})).message),ut.current?.focus()}catch(e){Q.error(vJ(e,`Unable to generate a commit message right now.`),{id:`ticket-git-commit-message-error`})}finally{ue(!1)}}},Kr=async(e=`normal`)=>{if(!(e===`force`?!Dn:!En)){he(e);try{let r=w.map(e=>e.subject.trim()).filter(Boolean),a=await Vt({forceWithLease:e===`force`});if(a.ticket&&m?.(a.ticket),Gt(a.git_status,{resetSelection:!0}),St(a.git_status),rt(r),Wt(),t&&(gt.current=!0,KK(t)),p&&h?.(p),Q.success(e===`force`?a.git_status.ahead===0?rJ(`branchForcePushed`):rJ(`forcePushCompleted`):a.git_status.ahead===0?rJ(`branchPushed`):rJ(`pushCompleted`),{id:`ticket-git-push-success`}),a.git_status.ahead===0)if(d!==`project_root`&&t&&n)try{let e=await Tt(t,n);qe(e),$e(t=>t.trim()?t:Tl(e.bundle)),q(e=>e.trim()?e:kJ(r)),tt(t=>t.trim()?t:e.bundle.pull_request?.base_branch??``)}catch{}else i()}catch(t){Q.error(vJ(t,rJ(e===`force`?`forcePushFallbackError`:`pushFallbackError`)),{id:`ticket-git-push-error`})}finally{he(null)}}},qr=async()=>{if(On){W(!0);try{let e=await Ht();e.ticket&&m?.(e.ticket),Gt(e.git_status,{resetSelection:!0}),T(e.commits),z(null),ae(!1),t&&(gt.current=!0,KK(t)),p&&h?.(p),await Kt({preserveContent:!0,gitStatusForCache:e.git_status}),await qt({preserveContent:!0}),Q.success(`Latest local commit undone.`,{id:`ticket-git-undo-success`})}catch(e){Q.error(vJ(e,`Unable to undo the latest local commit right now.`),{id:`ticket-git-undo-error`})}finally{W(!1)}}};return(0,Z.jsx)(du,{onClose:i,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-[92vh] w-full max-w-none flex-col overflow-hidden rounded-2xl border border-border bg-card p-6 shadow-2xl`,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[_n&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-2xl bg-black/45 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-border bg-card/95 px-4 py-3 text-sm text-foreground shadow-xl`,children:[(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{children:`Pushing branch...`})]})}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Changes`}),jn?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`h2`,{className:`max-w-full truncate font-mono text-lg font-semibold text-foreground`,children:jn}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(U,{variant:(S?.ahead??0)>0?`info`:`outline`,children:kn}),(0,Z.jsx)(U,{variant:(S?.behind??0)>0?`warning`:`outline`,children:An}),(0,Z.jsx)(U,{variant:S?.is_dirty?`warning`:`success`,children:S?.is_dirty?`Dirty`:`Clean`})]})]}):(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-7 w-56 animate-pulse rounded-md bg-muted/70`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-6 w-32 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 text-xs text-muted-foreground`,children:[(er||br)&&(0,Z.jsx)(AJ,{pullRequest:er,isLoading:cr,isOpen:Xe,canCreate:xr,disabledReason:Cr,isCreating:it,isSyncing:ot,isGeneratingDescription:ct,title:Qe,body:et,baseBranch:J,onOpenChange:Sr,onTitleChange:$e,onBodyChange:q,onBaseBranchChange:tt,showGenerateDescription:nr,onGenerateDescription:()=>{Mr()},onCreate:()=>{jr()}}),(0,Z.jsx)(IG,{isCommitsLoading:ie,commitsError:R,unpushedCommits:w,canUndoLatestCommit:On,isUndoing:ge,aheadCount:S?.ahead??0,onUndoLatestCommit:()=>{qr()}}),wn&&(Tn?(0,Z.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Kr()},disabled:!En,title:u,className:`gap-2 rounded-r-none`,children:[_n?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Mc,{className:`h-4 w-4`}),rJ(vn?`forcePushing`:_n?`pushing`:`pushBranch`)]}),(0,Z.jsxs)(He,{children:[(0,Z.jsx)(Se,{asChild:!0,children:(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`default`,disabled:!Dn,"aria-label":rJ(`morePushActions`),className:`rounded-l-none border-l border-primary-foreground/20 px-2`,children:(0,Z.jsx)(Oe,{className:`h-4 w-4`})})}),(0,Z.jsx)(je,{align:`end`,className:`w-56`,children:(0,Z.jsx)(Re,{disabled:!Dn,onSelect:()=>{Kr(`force`)},children:rJ(`forcePushWithLease`)})})]})]}):(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Kr()},disabled:!En,title:u,className:`gap-2`,children:[_n?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Mc,{className:`h-4 w-4`}),rJ(_n?`pushing`:`pushBranch`)]})),e]})]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-changes-layout`,className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)] xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`flex min-h-0 flex-col`,children:[rr&&(0,Z.jsxs)(EG,{type:`single`,size:`sm`,variant:`outline`,value:g,onValueChange:e=>{(e===`uncommitted`||e===`bundle_diff`)&&_(e)},className:`mb-3 self-start`,children:[(0,Z.jsxs)(DG,{value:`uncommitted`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Uncommitted`}),gr>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`,children:gr})]}),(0,Z.jsxs)(DG,{value:`bundle_diff`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Branch diff`}),_r>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`,children:_r})]})]}),(0,Z.jsx)(MK,{selectionWarning:g===`uncommitted`?xn:null,gitError:g===`uncommitted`?I:P,sidebarFiles:hn,commentCountByPath:hr,commentCountTone:mr,isGitStatusLoading:g===`bundle_diff`?or:sr&&hn.length===0,selectedPaths:E,selectedDiffPath:O,allFilesSelected:bn,diffStats:cn?.stats??null,title:g===`bundle_diff`?`Branch diff files`:`Changed files`,allChangesDescription:g===`bundle_diff`?`Review the full branch diff against the review base.`:`Review the full workspace diff.`,enableSelection:g===`uncommitted`&&!sr,onToggleSelectAll:Ur,onSelectDiffPath:k,onTogglePath:Hr})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,Z.jsx)(DK,{selectedDiffPath:O,sidebarFiles:hn,diffResponse:cn,isDiffLoading:lr,diffError:ir,allDiffFiles:Fn,renderedFiles:Pn,viewType:_e,onViewTypeChange:ve,onRetry:Br,activeReviewTarget:Bn,editingReviewCommentKey:Vn,reviewDraftInstanceKey:Un,reviewDraftInput:Wn,reviewComments:Gn,reviewFindings:ur,githubComments:fr,selectedReviewFindingIds:dr,selectedGitHubCommentIds:pr,canSelectReviewTarget:wr,canEditActiveReviewDraft:Tr,reviewFindingsError:g===`uncommitted`?Ne:null,gitHubCommentsError:g===`bundle_diff`?Fe:null,hasStaleReviewFindings:g===`uncommitted`?$n:!1,onSelectReviewTarget:Nr,onToggleReviewFindingSelection:Dr,onToggleGitHubCommentSelection:Or,onReviewDraftInputChange:Fr,onCancelReviewDraft:Pr,onEditReviewDraft:Lr,onRemoveReviewDraft:Rr,onSaveReviewDraft:Ir,diffThemeClassName:NK,resolveFilePath:mJ,normalizeDiffPath:fJ,onVisibleFilePathsChange:mn,emptyStateTitle:vr,emptyStateDescription:yr,reviewSummaryControl:Vr,headerLayout:`inline-controls`}),g===`uncommitted`&&(0,Z.jsx)(`div`,{className:`mt-auto shrink-0`,children:(0,Z.jsx)(FG,{commitMessage:A,onCommitMessageChange:j,commitMessageRef:ut,selectedFileCount:gn,changesDisabledReason:u,canEditCommitMessage:l&&!We,canGenerateCommitMessage:Cn,canCommit:Sn,isGeneratingCommitMessage:le,isCommitting:oe,onGenerateCommitMessage:()=>{Gr()},onCommit:()=>{Wr()}})})]})]})]})]})})},NJ={blocked:{className:`stroke-red-400/80`,markerId:`dependency-arrowhead-blocked`},ready:{className:`stroke-emerald-400/80`,markerId:`dependency-arrowhead-ready`},preview:{className:`stroke-amber-300/80`,markerId:`dependency-arrowhead-preview`}},PJ=e=>Gw(e)?`ready`:`blocked`,FJ=180,IJ=560,LJ=88,RJ=12,zJ=18,BJ=(e,t,n)=>Math.min(Math.max(e,t),n),VJ=(e,t,n)=>n&&n.width>0&&n.height>0?n:Object.values(e).reduce((e,t)=>({width:Math.max(e.width,t.left+t.width),height:Math.max(e.height,t.top+t.height)}),{width:t.x,height:t.y}),HJ=(e,t)=>{let n=BJ(Math.round(e.length*7.2)+24,FJ,IJ),r=Math.max(FJ,t-RJ*2);return Math.min(n,r)},UJ=(e,t,n,r,i)=>{let a=n.get(e.blockerTicketId);if(!a)return null;let o=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?r[e.hoveredTicketId]:null,s=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?n.get(e.hoveredTicketId):null,c=s?`${a.title} is blocking ${s.title}`:`${a.title} is blocking...`,{start:l,end:u}=$w(t,o??{left:e.pointer.x,top:e.pointer.y,width:0,height:0}),d=VJ(r,e.pointer,i),f=o&&s?{x:l.x+(u.x-l.x)*.6,y:l.y+(u.y-l.y)*.6-28}:{x:u.x,y:u.y-28},p=HJ(c,d.width);return{text:c,x:o&&s?BJ(f.x-p/2,RJ,Math.max(RJ,d.width-p-RJ)):(()=>{let e=f.x+zJ,t=f.x-zJ-p;return e+p<=d.width-RJ?e:t>=RJ?t:BJ(e,RJ,Math.max(RJ,d.width-p-RJ))})(),y:BJ(f.y,RJ,Math.max(RJ,d.height-LJ-RJ)),width:p}},WJ=({blockerRect:e,dependentRect:t,className:n,testId:r,markerEnd:i})=>{let{start:a,end:o}=$w(e,t),{path:s}=eT(a,o);return(0,Z.jsx)(`g`,{"data-testid":r,children:(0,Z.jsx)(`path`,{d:s,className:n,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,markerEnd:i})})},GJ=({preview:e,cardRects:t,ticketsById:n,overlaySize:r})=>{if(!e)return null;let i=t[e.blockerTicketId];if(!i)return null;let a=(e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId&&t[e.hoveredTicketId]?t[e.hoveredTicketId]:null)??{left:e.pointer.x,top:e.pointer.y,width:0,height:0},o=UJ(e,i,n,t,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(WJ,{blockerRect:i,dependentRect:a,className:NJ.preview.className,testId:`dependency-preview`,markerEnd:`url(#${NJ.preview.markerId})`}),(e=>o?(0,Z.jsx)(`foreignObject`,{x:o.x,y:o.y,width:o.width,height:LJ,"data-testid":`dependency-preview-label`,children:e}):null)((0,Z.jsx)(`div`,{className:`pointer-events-none flex h-full w-full items-start`,children:(0,Z.jsx)(`div`,{className:`max-w-full rounded-md border border-amber-300/60 bg-stone-950/85 px-3 py-1.5 text-xs font-medium leading-5 text-amber-100 shadow-lg shadow-stone-950/20 whitespace-normal break-words`,children:o?.text})}))]})},KJ=({dependencies:e,cardRects:t,preview:n,ticketsById:r,overlaySize:i})=>(0,Z.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 z-10 h-full w-full overflow-visible`,children:[(0,Z.jsx)(`defs`,{children:Object.values(NJ).map(e=>(0,Z.jsx)(`marker`,{id:e.markerId,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,markerUnits:`userSpaceOnUse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8`,className:e.className,fill:`none`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})},e.markerId))}),e.map(e=>{let n=r.get(e.blocker_ticket_id),i=r.get(e.dependent_ticket_id),a=t[e.blocker_ticket_id],o=t[e.dependent_ticket_id];if(n?.parked_at||i?.parked_at)return null;let s=NJ[PJ(n)];return!a||!o?null:(0,Z.jsx)(WJ,{blockerRect:a,dependentRect:o,className:s.className,testId:`dependency-edge-${e.blocker_ticket_id}-${e.dependent_ticket_id}`,markerEnd:`url(#${s.markerId})`},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`)}),(0,Z.jsx)(GJ,{preview:n,cardRects:t,ticketsById:r,overlaySize:i})]}),qJ=({onSubmit:e,bundles:t,projectId:n=null,projectBranchState:r=null,tool:i,showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialModel:c=``,initialVariant:l=``,initialSkills:u=[],initialWorktreeBundleId:d=null,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,onClose:h})=>{let{t:g}=X(`common`),{jiraImportState:_,importFromJira:v}=hf(n);return(0,Z.jsx)(du,{onClose:h,overlayClassName:`bg-black/60`,panelClassName:`h-[92vh] w-[96vw] max-w-6xl overflow-y-auto rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,renderContent:({closeButton:y})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:y}),(0,Z.jsx)(JN,{heading:g(`newTicketModal.heading`),bundles:t,showModelSelector:a,availableModels:o,availableSkills:s,projectId:n,initialModel:c,initialVariant:l,initialSkills:u,initialWorktreeBundleId:d,projectBranchState:r,jiraImportState:_,onImportFromJira:v,onCancel:h,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,titleInputId:`title`,descriptionInputId:`description`,bundleSelectId:`new-ticket-bundle`,modelSelectId:`new-model`,variantSelectId:`new-variant`,skillsSelectId:`new-skills`,showEmptyBundleOption:!0,planAction:i?{label:g(`newTicketModal.actions.plan`),onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`plan`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}}:void 0,primaryAction:{label:g(`newTicketModal.actions.createTicket`),variant:`subtle`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`create`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}},secondaryAction:{label:g(`newTicketModal.actions.createAndBuild`),variant:`brand`,showAdvanceIcon:!0,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`build`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}}})]})})},JJ=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},YJ=e=>e.status===`error`?`border-red-500/35 bg-red-500/10`:e.status===`done`?e.boardState===`fading`?`border-emerald-500/25 bg-emerald-500/10 opacity-0 transition-opacity duration-700`:`border-emerald-500/35 bg-emerald-500/10`:`border-violet-500/30 bg-card/60`,XJ=({run:e})=>(0,Z.jsxs)(mu,{"data-testid":`planning-run-card-${e.id}`,className:`relative overflow-hidden rounded-xl border shadow-none ${YJ(e)}`,children:[e.status===`running`&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-0 h-1 animate-pulse bg-gradient-to-r from-violet-500/0 via-violet-300/80 to-violet-500/0`}),(0,Z.jsxs)(yu,{className:`space-y-3 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[e.status===`running`?(0,Z.jsx)(rT,{label:`Planning...`}):e.status===`done`?(0,Z.jsx)(rT,{label:`Done`,className:`bg-emerald-500/85 text-emerald-50`}):(0,Z.jsx)(rT,{label:`Planning failed`,className:`bg-red-500/85 text-red-50`}),(0,Z.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.16em] text-muted-foreground`,children:JJ(e.submittedAt)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),e.status===`done`&&e.summary&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Created `,e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]}),e.status===`error`&&e.error&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-200`,children:e.error})]})]})]}),ZJ={idle:`bg-secondary`,running:`bg-sky-400`,done:`bg-emerald-400`,error:`bg-red-400`},QJ=e=>e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`done`)?`done`:`idle`,$J=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},eY=({status:e})=>{let{t}=X(`common`);return e===`running`?(0,Z.jsx)(rT,{label:t(`planningAgentSidebar.runStatus.planning`),className:`px-2.5 py-0.5 text-[11px]`}):e===`done`?(0,Z.jsx)(U,{className:`bg-emerald-500/85 px-2.5 py-0.5 text-[11px] text-emerald-50`,children:t(`planningAgentSidebar.runStatus.done`)}):(0,Z.jsx)(U,{className:`bg-red-500/85 px-2.5 py-0.5 text-[11px] text-red-50`,children:t(`planningAgentSidebar.runStatus.failed`)})},tY=({heading:e,runs:t})=>{let{t:n}=X(`common`);return t.length===0?null:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:t.map(e=>(0,Z.jsx)(mu,{className:`rounded-2xl border-border bg-card/70 shadow-none`,children:(0,Z.jsxs)(yu,{className:`space-y-2 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),(0,Z.jsx)(eY,{status:e.status})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:$J(e.submittedAt)}),e.summary&&(0,Z.jsxs)(`span`,{children:[n(`planningAgentSidebar.runSummary.tickets`,{count:e.summary.ticketCount}),`, `,n(`planningAgentSidebar.runSummary.dependencies`,{count:e.summary.dependencyCount}),e.summary.ticketsWithOpenQuestions>0?`, ${n(`planningAgentSidebar.runSummary.openQuestions`,{count:e.summary.ticketsWithOpenQuestions})}`:``]})]}),e.error&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-destructive/15 px-3 py-2 text-xs text-red-200`,children:e.error})]})},e.id))})]})},nY=({projectId:e=null,state:t,bundles:n,showModelSelector:r,availableModels:i,availableSkills:a,onManageBundles:o,onToggle:s,onDescriptionChange:c,onModelChange:l,onVariantChange:u,onSkillsChange:d,onBundleChange:f,onGenerate:p})=>{let{t:m}=X(`common`),h=i.find(e=>e.id===t.composer.model)??null,{jiraImportState:g,importFromJira:_}=hf(t.isOpen?e:null),v=(0,Y.useRef)(null),y=(0,Y.useRef)(t.isOpen),b=(0,Y.useRef)(t.isOpen),x=QJ(t.runs),S=t.runs.filter(e=>e.status===`running`),C=t.runs.filter(e=>e.status!==`running`),w=t.composer.description.trim().length>0,T=m(`planningAgentSidebar.actions.planTickets`);(0,Y.useEffect)(()=>{if(t.isOpen&&!y.current&&(b.current=!0),t.isOpen||(b.current=!1),y.current=t.isOpen,!t.isOpen||!b.current)return;let e=window.requestAnimationFrame(()=>{let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`[data-testid="planning-agent-rail"]`)!==null;if(e instanceof HTMLElement&&e!==document.body&&e!==v.current&&!t){b.current=!1;return}v.current?.focus({preventScroll:!0}),b.current=!1});return()=>{window.cancelAnimationFrame(e)}},[t.isOpen]),(0,Y.useEffect)(()=>{if(!t.isOpen)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),s())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[s,t.isOpen]);let E=(0,Z.jsxs)(K,{type:`button`,"aria-label":t.isOpen?m(`planningAgentSidebar.actions.closeAriaLabel`):m(`planningAgentSidebar.actions.openAriaLabel`),"aria-pressed":t.isOpen,onClick:s,variant:`outline`,className:`relative flex h-14 w-11 flex-col items-center justify-center gap-1 p-0`,children:[(0,Z.jsx)(Wd,{className:`size-5`}),(0,Z.jsx)(pw,{"aria-hidden":`true`,children:`A`}),(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-2.5 w-2.5 rounded-full ring-2 ring-card ${ZJ[x]}`})]});return(0,Z.jsxs)(`aside`,{"aria-label":m(`planningAgentSidebar.ariaLabel`),className:`relative z-20 h-full w-16 shrink-0 overflow-visible border-r border-border bg-background`,children:[(0,Z.jsx)(`div`,{"data-testid":`planning-agent-rail`,className:`relative z-40 flex h-full w-16 shrink-0 flex-col items-center border-r border-border bg-background py-4`,children:t.isOpen?E:(0,Z.jsx)(yc,{content:m(`planningAgentSidebar.tooltip`),children:E})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-drawer`,"aria-hidden":!t.isOpen,inert:!t.isOpen||void 0,className:G(`absolute inset-y-0 left-16 z-30 w-[min(36rem,calc(100vw-5rem))] overflow-hidden transition-transform duration-200 ease-out motion-reduce:transition-none`,t.isOpen?`pointer-events-auto translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,Z.jsxs)(`div`,{className:`flex h-full w-[min(36rem,calc(100vw-5rem))] flex-col border-r border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-border px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:m(`planningAgentSidebar.title`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:m(`planningAgentSidebar.description`)})]}),(0,Z.jsx)(K,{type:`button`,"aria-label":m(`planningAgentSidebar.actions.closePanelAriaLabel`),onClick:s,variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Be,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-scroll-body`,className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`space-y-5 px-6 py-5`,children:[(0,Z.jsx)(WN,{jiraImportState:g,onImportFromJira:_,onImported:e=>{c(e.description)},inputId:`planning-agent-jira-import`}),(0,Z.jsx)(xu,{label:m(`planningAgentSidebar.descriptionLabel`),htmlFor:`planning-agent-description`,className:`gap-2`,children:(0,Z.jsx)(`div`,{className:`relative`,children:(0,Z.jsx)(Zp,{ref:v,projectId:e,suggestionAnchor:`caret`,id:`planning-agent-description`,"aria-label":m(`planningAgentSidebar.descriptionAriaLabel`),value:t.composer.description,onValueChange:c,rows:14,className:`min-h-[18rem] resize-y text-sm leading-6`,placeholder:m(`planningAgentSidebar.descriptionPlaceholder`)})})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(GN,{bundles:n,value:t.composer.worktreeBundleId,onChange:f,selectId:`planning-agent-bundle`,emptyLabel:m(`planningAgentSidebar.autoCreateBundle`),hideProjectRootBundles:!0,label:``})}),o&&(0,Z.jsx)(K,{type:`button`,onClick:o,variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`,children:m(`planningAgentSidebar.actions.manageBundles`)})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:(0,Z.jsx)(VN,{model:t.composer.model,variant:t.composer.variant,skills:t.composer.skills,showModelSelector:r,showSkillsSelector:r,availableModels:i,availableSkills:a,selectedModel:h,onModelChange:l,onVariantChange:u,onSkillsChange:d,modelSelectId:`planning-agent-model`,variantSelectId:`planning-agent-variant`,skillsSelectId:`planning-agent-skills`,layout:`stacked`})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-runs`,className:`border-t border-border/80 px-0 pt-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(tY,{heading:m(`planningAgentSidebar.activeRuns`),runs:S}),(0,Z.jsx)(tY,{heading:m(`planningAgentSidebar.recentRuns`),runs:C})]})})]})}),(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border px-6 py-4`,children:(0,Z.jsx)(K,{type:`button`,onClick:p,disabled:!w,className:`w-full`,children:T})})]})})]})},rY=({className:e=``})=>{let{setNodeRef:t,isOver:n}=ew({id:`trash`});return(0,Z.jsxs)(`div`,{ref:t,"data-testid":`delete-drop-zone`,className:`${e} flex min-w-[13rem] select-none items-center justify-between gap-4 rounded-2xl border px-4 py-3 backdrop-blur-sm transition-all duration-150 ${n?`scale-[1.02] border-red-400/70 bg-destructive/35 text-red-100 shadow-lg shadow-red-950/30`:`border-red-500/30 bg-background/82 text-red-200/85`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(U,{variant:`destructive`,className:`text-[11px] uppercase tracking-[0.28em]`,children:`Delete`}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:n?`Release to delete`:`Drop here to delete`})]}),(0,Z.jsx)(`div`,{className:`rounded-xl border p-2 transition-colors ${n?`border-red-400/60 bg-red-500/20`:`border-red-500/20 bg-background/60`}`,children:(0,Z.jsx)(Su,{className:`h-5 w-5 transition-colors ${n?`text-red-100`:`text-red-300/70`}`})})]})},iY=(e,t)=>q(E(`/ticket-dependencies`,e),{signal:t}),aY=(e,t)=>q(E(`/ticket-dependencies`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create the dependency right now.`}),oY=(e,t,n)=>L(E(`/ticket-dependencies/${t}/${n}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to remove the dependency right now.`}),sY=(e,t)=>{let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.left!==i.left||n.top!==i.top||n.width!==i.width||n.height!==i.height)return!1}return!0},cY=(e,t)=>e===t?!0:!e||!t?!1:e.projectId===t.projectId&&e.blockerTicketId===t.blockerTicketId&&e.hoveredTicketId===t.hoveredTicketId&&e.pointer.x===t.pointer.x&&e.pointer.y===t.pointer.y,lY=({activeProjectId:e,tickets:t,dependencies:n,setDependencies:r,activeTicket:i,activeOverlayNode:a,dragOffset:o})=>{let[s,c]=(0,Y.useState)({}),[l,u]=(0,Y.useState)({width:0,height:0}),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(new Map),y=(0,Y.useRef)({}),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useRef)(null),T=(0,Y.useRef)(null),E=(0,Y.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);(0,Y.useEffect)(()=>{C.current=p},[p]),(0,Y.useLayoutEffect)(()=>{if(!i||!a||!g.current)return;let e=window.requestAnimationFrame(()=>{let e=g.current?.getBoundingClientRect(),t=a.getBoundingClientRect();e&&f({ticketId:i.id,rect:{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}})});return()=>{window.cancelAnimationFrame(e)}},[a,i,o.x,o.y]);let D=(0,Y.useCallback)(()=>{b.current===null&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=g.current;if(!e){_.current=null,y.current={},c({}),u({width:0,height:0});return}let t=e.getBoundingClientRect(),n={};_.current={left:t.left,top:t.top},u(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height});for(let[e,r]of v.current){let i=r.getBoundingClientRect();n[e]={left:i.left-t.left,top:i.top-t.top,width:i.width,height:i.height}}y.current=n,c(e=>sY(e,n)?e:n)}))},[]);(0,Y.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{D()};return e.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[D]),(0,Y.useEffect)(()=>{if(typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(()=>{D()});x.current=e;for(let t of v.current.values())e.observe(t);return()=>{e.disconnect(),x.current===e&&(x.current=null)}},[D]),(0,Y.useEffect)(()=>{let e=h.current,t=g.current;if(!e&&!t)return;let n=new ResizeObserver(()=>{D()});return e&&n.observe(e),t&&t!==e&&n.observe(t),()=>{n.disconnect()}},[D]),(0,Y.useEffect)(()=>(D(),()=>{b.current!==null&&(window.cancelAnimationFrame(b.current),b.current=null)}),[n,D,t]);let k=(0,Y.useCallback)((e,t)=>{let n=v.current.get(e);if(t){if(n===t)return;v.current.set(e,t),x.current?.observe(t)}else{if(!n)return;v.current.delete(e),x.current?.unobserve(n)}D()},[D]),A=(0,Y.useCallback)(e=>{cY(C.current,e)||(C.current=e,m(e))},[]),j=(0,Y.useCallback)(()=>{w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),T.current=null},[]),M=(0,Y.useCallback)(e=>{T.current=e,w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null;let e=T.current;T.current=null,A(e)}))},[A]),N=(0,Y.useCallback)((e,t)=>{let n=_.current;if(!n&&g.current){let e=g.current.getBoundingClientRect();n={left:e.left,top:e.top},_.current=n}return n?{x:e-n.left,y:t-n.top}:{x:e,y:t}},[]),P=(0,Y.useCallback)((e,t,n)=>{for(let[r,i]of Object.entries(y.current))if(r!==n&&e>=i.left&&e<=i.left+i.width&&t>=i.top&&t<=i.top+i.height)return r;return null},[]),F=(0,Y.useCallback)(async t=>{if(e)try{await oY(e,t.blocker_ticket_id,t.dependent_ticket_id),r(e=>Vw(e,t.blocker_ticket_id,t.dependent_ticket_id))}catch(e){Q.error(e instanceof O?e.message:`Unable to remove the dependency right now.`,{id:`board-dependency-error`})}},[e,r]),I=(0,Y.useCallback)((t,i)=>{if(!e)return;i.preventDefault(),S.current?.();let a=(n,r,i=!1)=>{let a=N(n,r),o={projectId:e,blockerTicketId:t,hoveredTicketId:P(a.x,a.y,t),pointer:a};if(i){j(),A(o);return}M(o)};a(i.clientX,i.clientY,!0);let o=e=>{a(e.clientX,e.clientY)},s=async i=>{let a=N(i.clientX,i.clientY),o=P(a.x,a.y,t),s=o?Uw(n,t,o):null;if(S.current?.(),S.current=null,A(null),!(!o||!s)){if(!s.valid){Q.error(Ww(s.reason),{id:`board-dependency-error`});return}try{let n=await aY(e,{blocker_ticket_id:t,dependent_ticket_id:o});r(e=>Bw(e,n))}catch(e){Q.error(e instanceof O?e.message:`Unable to create the dependency right now.`,{id:`board-dependency-error`})}}};S.current=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),j()},window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0})},[e,j,n,P,N,M,r,A]);(0,Y.useEffect)(()=>{S.current?.(),S.current=null,j(),C.current=null},[e,j]),(0,Y.useEffect)(()=>()=>{S.current?.(),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]);let L=(0,Y.useMemo)(()=>{let r=p?.blockerTicketId;if(!r||p.projectId!==e||!E.has(r))return null;let i=new Map;for(let e of t){if(e.id===r){i.set(e.id,`source`);continue}let t=Uw(n,r,e.id);i.set(e.id,t.valid?`valid`:`idle`)}return i},[e,n,p,E,t]),R=(0,Y.useCallback)(e=>{if(!L||!p)return`idle`;let t=L.get(e)??`idle`;return e===p.hoveredTicketId&&t===`idle`?`invalid`:t},[L,p]),z=(0,Y.useMemo)(()=>!p||p.projectId!==e||!E.has(p.blockerTicketId)?null:{blockerTicketId:p.blockerTicketId,hoveredTicketId:p.hoveredTicketId,pointer:p.pointer},[e,p,E]);return{boardViewportRef:h,boardContentRef:g,registerTicketNode:k,measuredCardRects:(0,Y.useMemo)(()=>{if(!i)return s;let e=s[i.id];return e?d?.ticketId===i.id?{...s,[i.id]:d.rect}:{...s,[i.id]:{...e,left:e.left+o.x,top:e.top+o.y}}:s},[d,i,s,o.x,o.y]),overlayPreview:z,overlaySize:l,getDependencyTargetState:R,handleDependencyStart:I,handleDeleteDependency:F}},uY=e=>{if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.id==`string`?t.id:``,r=typeof t.name==`string`?t.name:``,i=typeof t.command==`string`?t.command:``,a=typeof t.cwd==`string`?t.cwd:``,o=t.runner===`vitest`||t.runner===`jest`||t.runner===`unknown`?t.runner:`auto`;return n.trim()===``||r.trim()===``&&i.trim()===``&&a.trim()===``?[]:[{id:n,name:r,command:i,cwd:a,runner:o}]}):[]}catch{return[]}},dY=`[data-terminal-pane="true"]`,fY=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||e.isContentEditable},pY=e=>e instanceof HTMLElement?e.closest(dY)!==null:!1,mY=e=>fY(e)||pY(e),hY=(e,t={})=>{let{isBlocked:n}=t;(0,Y.useEffect)(()=>{let t=t=>{if(t.defaultPrevented||t.repeat)return;let r=e.find(e=>!e.disabled&&e.key.toLowerCase()===t.key.toLowerCase()&&(e.ctrlKey??!1)===t.ctrlKey&&(e.altKey??!1)===t.altKey&&(e.metaKey??!1)===t.metaKey&&(e.shiftKey===void 0||e.shiftKey===t.shiftKey));r&&(n?.(document.activeElement)||(t.preventDefault(),r.onKeyDown()))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,n])},gY=e=>({...e,messages:void 0,agent_log:void 0,streaming_response:void 0}),_Y=(e,t)=>e?e.state!==t.state||e.parked_at!==t.parked_at||e.worktree_bundle_id!==t.worktree_bundle_id:!0,vY=(e,t)=>{if(!e)return t;let n=t.worktree_bundle_id!==null&&e.worktree_bundle_id===t.worktree_bundle_id,r=t.bundle??(n&&e.bundle?.id===t.worktree_bundle_id?e.bundle:null),i=t.bundle_execution_position??(n?e.bundle_execution_position??null:null);return{...e,...t,bundle:r,bundle_execution_position:i}},yY=(e,t)=>{let n=e=>Ew(t)?Ew(e):e.state===t.state&&!Ew(e),r=e.findIndex(e=>n(e));if(r===-1)return[...e,t];let i=[...e];return i.splice(r,0,t),i},bY=(e,t)=>{let n=e.find(e=>e.id===t.id);return[n&&n.pull_request!==void 0&&t.pull_request===void 0?{...n,...t,pull_request:n.pull_request}:t,...e.filter(e=>e.id!==t.id)]},xY=(e,t)=>{let n=e.find(e=>e.id===t.id);if(!n)return[...e,t];let r=vY(n,t);return e.map(e=>e.id===t.id?r:e)},SY=(e,t)=>{let n=vY(e.find(e=>e.id===t.id),t);return yY(wY(e,t.id),n)},CY=(e,t)=>{if(e.length===0)return[...t];let n=[...e];for(let e of t)n=_Y(n.find(t=>t.id===e.id),e)?SY(n,e):xY(n,e);let r=new Set(t.map(e=>e.id));return n.filter(e=>r.has(e.id))},wY=(e,t)=>e.filter(e=>e.id!==t),TY=(e,t,n,r={},i={})=>{let a=e.findIndex(e=>e.id===t);if(a===-1)return e;let o={...e[a],state:n,...r},s=wY(e,t);if(i.preferredIndex!==void 0){let e=Math.max(0,Math.min(i.preferredIndex,s.length));return s.splice(e,0,o),s}return yY(s,o)},EY=async(e,t)=>{`Notification`in window&&Notification.permission!==`denied`&&(Notification.permission===`default`&&await Notification.requestPermission(),Notification.permission===`granted`&&new Notification(e,{body:t}))},DY=(0,Y.createContext)(MW),OY=()=>(0,Y.useContext)(DY),kY=(0,Y.createContext)(null),AY=15*1e3,jY=1e3,MY=async e=>EY(`Ticket done`,e),NY=e=>gY(e),PY=(e,t)=>t===`running`&&e.agent_status===`done`?`Finished ${e.state} for "${e.title}"`:t===`running`&&e.agent_status===`error`?`Failed ${e.state} for "${e.title}"`:t!==`running`&&e.agent_status===`running`?`Running ${e.state} for "${e.title}"`:null,FY=({activeProjectId:e,refreshKey:t=0,onLoadedProjectIdChange:n,onProjectUsageChange:r,onBundlesChange:i,onBundlesLoadingChange:a,children:o})=>{let s=OY(),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)([]),[f,p]=(0,Y.useState)([]),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(null),[C,w]=(0,Y.useState)(null),T=(0,Y.useRef)(0),E=(0,Y.useRef)(0),D=(0,Y.useRef)(new Map),O=(0,Y.useRef)(new Map),k=(0,Y.useRef)(e),A=(0,Y.useRef)(new Map),j=(0,Y.useRef)(new Map),M=(0,Y.useRef)(new Map),N=(0,Y.useCallback)((e,t)=>{let n=j.current.get(t.id);return!n||!e||t.state===n?t:e},[]),P=(0,Y.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(j.current);for(let r of e)n.set(r,t);j.current=n},[]),F=(0,Y.useCallback)(e=>{if(e.length===0||j.current.size===0)return;let t=new Map(j.current);for(let n of e)t.delete(n);j.current=t},[]),I=(0,Y.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(M.current);for(let r of e)n.set(r,t);M.current=n},[]),L=(0,Y.useCallback)(e=>{if(e.length===0||M.current.size===0)return;let t=new Map(M.current);for(let n of e)t.delete(n);M.current=t},[]),R=(0,Y.useCallback)((e,t)=>{if(A.current.has(t.id))return null;let n=N(e,t);return M.current.has(t.id)?{...n,parked_at:M.current.get(t.id)??null}:n},[N]),z=(0,Y.useCallback)((e,t)=>{if(A.current.size===0&&j.current.size===0&&M.current.size===0)return t;let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=R(n.get(e.id),e);return t?[t]:[]})},[R]),B=(0,Y.useCallback)(async(e,t)=>{let n=await Wt(e,t,{detail:`board`});return Array.isArray(n)?(!t?.aborted&&k.current===e&&l(e=>CY(e,z(e,n).map(NY))),n):null},[z]),ee=(0,Y.useCallback)(async(e,t)=>{await B(e,t)},[B]),te=(0,Y.useCallback)(async(e,t)=>{let n=++E.current,r=await Gt(e,t);if(!Array.isArray(r)||t?.aborted||k.current!==e||E.current!==n)return;let i=new Map(r.map(e=>[e.id,e]));l(e=>e.map(e=>{let t=i.get(e.id);return t?{...e,diff_stats:t.diff_stats??null,is_stale:t.is_stale}:e}))},[]),ne=(0,Y.useCallback)(e=>e.some(e=>e.is_stale===void 0),[]),V=(0,Y.useCallback)(async e=>{let t=k.current;if(!t)return null;try{let n=await Kt(e,t);if(k.current!==t)return null;let r=O.current.get(n.id),i=R(r,n);if(!i)return null;let a=NY(i),o=_Y(r,a);return l(e=>o?SY(e,a):xY(e,a)),n}catch{return null}},[R]),re=(0,Y.useCallback)(async t=>{if(!e){p([]);return}p(await Ct(e,t))},[e]),H=(0,Y.useMemo)(()=>new Map(c.map(e=>[e.id,e])),[c]),ie=(0,Y.useMemo)(()=>{let e=c.filter(e=>e.agent_status===`running`),t=new Set(e.map(e=>e.worktree_bundle_id).filter(e=>typeof e==`string`&&e.trim().length>0));return{total_running:e.length,running_plan_count:e.filter(e=>e.state===`plan`).length,running_build_count:e.filter(e=>e.state===`build`).length,running_review_count:e.filter(e=>e.state===`review`).length,active_bundle_count:t.size,latest_message:C}},[C,c]);(0,Y.useEffect)(()=>{O.current=H},[H]),(0,Y.useEffect)(()=>{k.current=e,A.current.clear(),j.current.clear(),M.current.clear(),w(null),h(null),D.current.clear()},[e]),(0,Y.useEffect)(()=>{n?.(v?null:g)},[g,v,n]),(0,Y.useEffect)(()=>{if(i){if(!e){i(null,[]);return}if(g!==e){i(e,[]);return}i(e,f)}},[e,f,g,i]),(0,Y.useEffect)(()=>{if(a){if(!e){a(null,!1);return}a(e,b===e)}},[e,b,a]),(0,Y.useEffect)(()=>{let t=new AbortController,n=++T.current,r=null,i=async()=>{try{if(!e){l([]),d([]),p([]),_(null),y(null);return}l([]),d([]),p([]),_(null),y(e),x(e);let[n,i,a]=await Promise.allSettled([B(e,t.signal),iY(e,t.signal),Ct(e,t.signal)]);if(t.signal.aborted)return;n.status!==`fulfilled`&&!S(n.reason)&&l([]),i.status===`fulfilled`?d(i.value):S(i.reason)||d([]),a.status===`fulfilled`?p(a.value):S(a.reason)||p([]),_(n.status===`fulfilled`&&i.status===`fulfilled`&&a.status===`fulfilled`?e:null),n.status===`fulfilled`&&n.value!==null&&ne(n.value)&&(r=window.setTimeout(()=>{t.signal.aborted||te(e,t.signal)},jY))}finally{!t.signal.aborted&&T.current===n&&(y(null),x(null))}},a=t=>{t.project_id===e&&(h(t),!A.current.has(t.id)&&(t.bundle&&p(e=>bY(e,t.bundle)),l(e=>SY(e,NY(t)))))},o=t=>{if(t.project_id===e&&h(t),l(n=>{if(t.project_id!==e)return wY(n,t.id);let r=n.find(e=>e.id===t.id),i=R(r,t);if(!i)return n;let a=NY(i);return _Y(r,a)?SY(n,a):xY(n,a)}),t.project_id!==e){d(e=>zw(e,t.id));return}t.bundle&&p(e=>bY(e,t.bundle))},c=({id:e})=>{A.current.delete(e),M.current.delete(e),j.current.delete(e),l(t=>wY(t,e)),d(t=>zw(t,e))},u=e=>{if(!e)return;let t=O.current.get(e.blocker_ticket_id),n=O.current.get(e.dependent_ticket_id);!t||!n||t.project_id!==k.current||n.project_id!==k.current||d(t=>Bw(t,e))},f=e=>{d(t=>Vw(t,e.blocker_ticket_id,e.dependent_ticket_id))};return i(),s.on(`ticket:created`,a),s.on(`ticket:updated`,o),s.on(`ticket:deleted`,c),s.on(`ticket-dependency:created`,u),s.on(`ticket-dependency:deleted`,f),()=>{t.abort(),r!==null&&window.clearTimeout(r),s.off(`ticket:created`,a),s.off(`ticket:updated`,o),s.off(`ticket:deleted`,c),s.off(`ticket-dependency:created`,u),s.off(`ticket-dependency:deleted`,f)}},[e,te,t,ne,B,R,s]),(0,Y.useEffect)(()=>{if(!e)return;let t=new AbortController,n=()=>{document.visibilityState===`visible`&&Promise.allSettled([B(e,t.signal),re(t.signal)]).then(n=>{n[0]?.status===`fulfilled`&&n[0].value!==null&&ne(n[0].value)&&te(e,t.signal)}).catch(()=>{})},r=window.setInterval(n,AY),i=YK(n);return()=>{t.abort(),window.clearInterval(r),i()}},[e,re,te,ne,B]),(0,Y.useEffect)(()=>{if(!e||!r||g!==e)return;let t=c.filter(e=>{let t=e.bundle?.branch??e.branch;return typeof t==`string`&&t.trim()!==``}).length;r({projectId:e,ticketCount:c.length,worktreeCount:t,repoPathLocked:c.length>0||t>0||f.length>0})},[e,f.length,g,r,c]),(0,Y.useEffect)(()=>{for(let e of c){let t=D.current.get(e.id),n=PY(e,t);n&&w(n),t!==void 0&&t===`running`&&e.agent_status===`done`&&(e.state===`plan`||e.state===`build`||e.state===`review`)&&MY(e.title),D.current.set(e.id,e.agent_status)}},[c]);let ae=(0,Y.useCallback)(()=>{h(null)},[]),oe=(0,Y.useMemo)(()=>({tickets:c,setTickets:l,dependencies:u,setDependencies:d,bundles:f,setBundles:p,latestDetailedTicketUpdate:m,clearLatestDetailedTicketUpdate:ae,loadedProjectId:g,loadingProjectId:v,activeProjectIdRef:k,pendingDeletedTicketsRef:A,pendingOptimisticMovesRef:j,pendingParkedTicketsRef:M,refreshTickets:ee,requestSingleTicketRefresh:V,refreshBundles:re,resolvePendingTicket:R,resolvePendingTickets:z,markPendingOptimisticMoves:P,clearPendingOptimisticMoves:F,markPendingParkedTickets:I,clearPendingParkedTickets:L,liveActivity:ie}),[f,ae,F,L,u,ie,g,m,v,P,I,re,ee,V,R,z,c]);return(0,Z.jsx)(kY.Provider,{value:oe,children:o})},IY=()=>{let e=(0,Y.useContext)(kY);if(!e)throw Error(`useProjectWorkspace must be used inside ProjectWorkspaceProvider`);return e},LY=(0,Y.lazy)(()=>WW(()=>import(`./TestsDialog-BtSHirWO.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),RY=`archon.last-model-selection`,zY=`archon.last-variant-selection`,BY=`archon.last-skills-selection`,VY=()=>{try{let e=window.localStorage.getItem(BY),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},HY=e=>[e.title,e.description,e.bundle?.name??``,e.bundle?.branch??``,e.branch??``].map(e=>e.toLowerCase()),UY=(e,t)=>{let n=e.bundle_execution_position??2**53-1,r=t.bundle_execution_position??2**53-1;if(n!==r)return n-r;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let i=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return i===0?e.id.localeCompare(t.id):i},WY=(e,t)=>t?{...e,...t,messages:t.messages===void 0?e.messages:t.messages,agent_log:t.agent_log===void 0?e.agent_log:t.agent_log,streaming_response:t.streaming_response===void 0?e.streaming_response:t.streaming_response}:e,GY=(e,t)=>{let n=e.toLowerCase().trim().split(/\s+/).filter(Boolean);if(n.length===0)return!0;let r=HY(t);return n.every(e=>r.some(t=>t.includes(e)))},KY=[`plan`,`build`,`review`],qY=`done`,JY=()=>({build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1,bundleRefresh:!1}),YY=({bundleId:e,activeRunContextKey:t,isProjectRootRunActive:n})=>n?!0:t!==null&&t!==e,XY=(e,t)=>{if(!e)return null;let n=t.find(t=>t.id===e.ticket_id);return n?ww(n):e.ticket_id},ZY=()=>({description:``,model:window.localStorage.getItem(RY)??``,variant:window.localStorage.getItem(zY)??``,skills:VY(),worktreeBundleId:``}),QY=()=>({isOpen:!1,composer:ZY(),runs:[]}),$Y=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`planning-run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,eX=e=>({ticketCount:e.tickets.length,dependencyCount:e.dependencies.length,ticketsWithOpenQuestions:e.tickets.filter(e=>(e.planning_context?.open_questions.length??0)>0).length,ticketTitles:e.tickets.map(e=>e.title),ticketIds:e.tickets.map(e=>e.id)}),tX=(e,t,n)=>e.map(e=>e.id===t?n(e):e),nX=(e,t,n)=>{e?window.localStorage.setItem(RY,e):window.localStorage.removeItem(RY),t?window.localStorage.setItem(zY,t):window.localStorage.removeItem(zY),n.length>0?window.localStorage.setItem(BY,JSON.stringify(n)):window.localStorage.removeItem(BY)},rX=(e,t={})=>yl(e,t),iX=()=>({model:window.localStorage.getItem(RY)??``,variant:window.localStorage.getItem(zY)??``,skills:VY()}),aX=(e,t)=>{let n=wY(e,t.ticket.id),r=Math.max(0,Math.min(t.index,n.length));return n.splice(r,0,t.ticket),n},oX=e=>e.tickets.length>0&&e.tickets.every(e=>Nw(e,`trash`)),sX=e=>e.tickets.length>0&&e.tickets.every(e=>Nw(e,qY)),cX=e=>e.column===qY&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),lX=(e,t,n,r)=>n||t!==null&&t!==ww(e)?r:qw(e),uX=(e,t)=>t===`build`?{agent_status:null,agent_log:null,streaming_response:null,build_completed_at:null,planning_context:e.planning_context?{...e.planning_context,open_questions:[]}:null}:t===`review`?{agent_status:null,agent_log:null,streaming_response:null}:{},dX=(e,t)=>e===`plan`&&t===`build`?`build`:e===`build`&&t===`review`?`review`:e===`review`&&t===`build`?`undoReview`:null,fX=(e,t,n)=>t===`review`&&n===`build`?{}:uX(e,n),pX=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:a,onRunStopped:o,onRunStatusChange:s,refreshKey:c=0})=>{let{t:l}=X(`common`),u=qx(Kx(YS,{activationConstraint:{distance:5}})),{tickets:d,setTickets:f,dependencies:p,setDependencies:m,bundles:h,setBundles:g,latestDetailedTicketUpdate:_,clearLatestDetailedTicketUpdate:v,loadedProjectId:y,loadingProjectId:b,activeProjectIdRef:x,pendingDeletedTicketsRef:C,requestSingleTicketRefresh:w,refreshBundles:T,resolvePendingTicket:E,markPendingOptimisticMoves:D,clearPendingOptimisticMoves:k,markPendingParkedTickets:A,clearPendingParkedTickets:j}=IY(),[M,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(null),[R,z]=(0,Y.useState)({x:0,y:0}),[B,ee]=(0,Y.useState)(null),[te,ne]=(0,Y.useState)(!1),[V,re]=(0,Y.useState)([]),[H,ie]=(0,Y.useState)([]),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)({}),[le,U]=(0,Y.useState)(!1),[ue,de]=(0,Y.useState)(!1),[fe,pe]=(0,Y.useState)(null),[me,he]=(0,Y.useState)(null),[ge,W]=(0,Y.useState)(null),[_e,ve]=(0,Y.useState)(null),[ye,be]=(0,Y.useState)(null),[xe,Se]=(0,Y.useState)(null),[Ce,we]=(0,Y.useState)(null),[Te,Ee]=(0,Y.useState)(null),[De,Oe]=(0,Y.useState)(null),[ke,Ae]=(0,Y.useState)(null),[je,Me]=(0,Y.useState)(!1),[Ne,Pe]=(0,Y.useState)(JY()),[Fe,Ie]=(0,Y.useState)(0),[Le,Re]=(0,Y.useState)(``),[ze,Ve]=(0,Y.useState)(!1),He=i===`opencode`||ge?.tool===`opencode`||!!xe?.tickets.some(e=>e.tool===`opencode`),Ue=i===`opencode`&&V.length>0,Ge=ge?.tool===`opencode`&&V.length>0,Ke=!!xe?.tickets.some(e=>e.tool===`opencode`)&&V.length>0,qe=(0,Y.useRef)(e),Je=(0,Y.useRef)(null),Ye=(0,Y.useRef)(null),[Xe,Ze]=(0,Y.useState)(null),Qe=d.find(e=>e.is_running)??null,$e=Qe?ww(Qe):null,et=r?.context_key??null,q=r?.kind===`ticket`?XY(r,d)??$e:$e,J=r?.kind===`project`,tt=q??Xe,nt=(0,Y.useCallback)(e=>YY({bundleId:e,activeRunContextKey:tt,isProjectRootRunActive:J}),[tt,J]),rt=M!==null&&Nw(M,`trash`)||P!==null&&oX(P),it=b===e,at=(0,Y.useMemo)(()=>uY(t?.test_commands??null),[t?.test_commands]),ot=(0,Y.useCallback)(async e=>EY(l(`board.notifications.planningDoneTitle`),l(`board.notifications.planningDoneBody`,{count:e})),[l]),st=at.length>0,ct=(0,Y.useMemo)(()=>new Map(d.map(e=>[e.id,e])),[d]);(0,Y.useEffect)(()=>{Ze(null)},[e]),(0,Y.useEffect)(()=>{Xe!==null&&(J||q!==null)&&Ze(null)},[q,J,Xe]),(0,Y.useEffect)(()=>{if(!me){W(null);return}let e=ct.get(me)??null;e&&W(t=>!t||t.id!==me?e:WY(t,e))},[me,ct]),(0,Y.useEffect)(()=>{_&&(W(e=>!e||e.id!==_.id?e:WY(e,_)),Se(e=>{if(!e)return e;let t=_.worktree_bundle_id;if(!t||e.bundle.id!==t)return e;let n=e.tickets.some(e=>e.id===_.id)?e.tickets.map(e=>e.id===_.id?WY(e,_):e):[...e.tickets,_];return{...e,tickets:n}}))},[_]),(0,Y.useEffect)(()=>{_===null||me!==null||_e!==null||v()},[v,_,_e,me]);let lt=(0,Y.useCallback)(async e=>{let t=await w(e);if(!t)return null;let n=ct.get(e),r=n?WY(t,n):t;return W(t=>t&&t.id!==e||me&&me!==e?t:r),r},[w,me,ct]),ut=(0,Y.useCallback)(e=>{W(e),he(e.id),lt(e.id)},[lt]),dt=(0,Y.useMemo)(()=>new Map(h.map(e=>[e.id,e])),[h]),ft=(0,Y.useMemo)(()=>{if(!xe)return null;let e=xe.bundle.id,t=_?.worktree_bundle_id===e?_:null,n=d.filter(t=>t.worktree_bundle_id===e),r=new Map(n.map(e=>[e.id,e])),i=xe.tickets.filter(e=>!C.current.has(e.id)).map(e=>t&&e.id===t.id?WY(e,t):e);t&&!i.some(e=>e.id===t.id)&&!C.current.has(t.id)&&i.push(t);let a=i.map(e=>WY(e,r.get(e.id)));for(let e of n)a.some(t=>t.id===e.id)||a.push(e);a.sort(UY);let o=xe.execution_order_ticket_ids??[],s=a.map(e=>e.id),c=[...o,...s].filter((e,t,n)=>s.includes(e)&&n.indexOf(e)===t),l=n.some(e=>e.can_re_review!==void 0||e.has_completed_review!==void 0||e.has_follow_up_since_last_review!==void 0),u=n.some(e=>e.agent_status===`running`),f={has_completed_review:n.some(e=>e.has_completed_review===!0),has_follow_up_since_last_review:n.some(e=>e.has_follow_up_since_last_review===!0),can_re_review:!u&&n.some(e=>e.can_re_review===!0)},p=gl(a),m=a.find(e=>e.id===xe.review_owner_ticket_id&&e.state===`review`)??a.find(e=>e.state===`review`)??null,h=yl(a,{targetTicketId:xe.target_ticket_id,reviewOwnerTicketId:m?.id??xe.review_owner_ticket_id,latestSessionTicketId:p?.id??xe.latest_session_ticket_id});return{...xe,bundle:dt.get(e)??xe.bundle,tickets:a,execution_order_ticket_ids:c,latest_session_ticket_id:p?.id??null,latest_session_id:p?.session_id??null,review_owner_ticket_id:m?.id??null,target_ticket_id:h?.id??null,has_completed_review:l?f.has_completed_review:xe.has_completed_review,has_follow_up_since_last_review:l?f.has_follow_up_since_last_review:xe.has_follow_up_since_last_review,can_re_review:l?f.can_re_review:xe.can_re_review}},[dt,_,C,xe,d]),pt=(0,Y.useMemo)(()=>d.filter(e=>ze&&Ow(e)?!1:GY(Le,e)),[ze,Le,d]),mt=(0,Y.useMemo)(()=>pt.filter(e=>Ew(e)),[pt]),ht=(0,Y.useMemo)(()=>bl(mt,h,qY),[h,mt]),{boardViewportRef:gt,boardContentRef:_t,registerTicketNode:vt,measuredCardRects:yt,overlayPreview:bt,overlaySize:xt,getDependencyTargetState:St,handleDependencyStart:Ct,handleDeleteDependency:Dt}=lY({activeProjectId:e,tickets:d,dependencies:p,setDependencies:m,activeTicket:M,activeOverlayNode:I,dragOffset:R}),Ot=e?se[e]??QY():QY(),kt=Ot.composer.worktreeBundleId&&h.some(e=>e.id===Ot.composer.worktreeBundleId)?Ot.composer.worktreeBundleId:``,Pt=kt===Ot.composer.worktreeBundleId?Ot:{...Ot,composer:{...Ot.composer,worktreeBundleId:kt}},Ft=iX(),It=!!t?.run_ide?.trim(),Bt=Pt.runs.filter(e=>e.boardVisible),Vt=(0,Y.useCallback)((e,t,n=d)=>{let r=bl(n,h,t).find(t=>t.kind===`bundle`&&t.group.bundle.id===e);return r?.kind===`bundle`?r.group:null},[h,d]),Ht=(0,Y.useCallback)(e=>(0,Z.jsx)(eG,{ticket:e,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:e.tool===`opencode`&&V.length>0,availableModels:V,runDisabled:!0,hideBundleScopedControls:!0}),[t?.memory_enabled,V,h,p,d]),Ut=Bt.length>0?(0,Z.jsx)(`div`,{className:`mb-0.5 flex flex-col gap-2.5`,children:Bt.map(e=>(0,Z.jsx)(XJ,{run:e},e.id))}):null,Wt=(0,Y.useCallback)(t=>vl(t)?t.project_id===e?It:!!t.has_run_ide:!1,[It,e]),Gt=(0,Y.useCallback)(e=>!!e.project_id&&!!(e.bundle?.branch??e.branch)&&vl(e),[]),Kt=(0,Y.useCallback)(e=>{let t=e?.tickets.find(t=>t.id===e.target_ticket_id)??e?.tickets.find(e=>e.has_worktree)??null;return t?Wt(t):!1},[Wt]),Yt=(0,Y.useCallback)(e=>{let t=d.filter(t=>t.worktree_bundle_id===e).sort(UY);return xe?.bundle.id===e?rX(xe.tickets.map(e=>t.find(t=>t.id===e.id)??e).sort(UY),{targetTicketId:xe.target_ticket_id,reviewOwnerTicketId:xe.review_owner_ticket_id,latestSessionTicketId:xe.latest_session_ticket_id}):rX(t)},[xe,d]),Zt=(0,Y.useCallback)((e,t)=>{ce(n=>({...n,[e]:t(n[e]??QY())}))},[]);(0,Y.useEffect)(()=>{U(!1),de(!1),we(null),Ae(null),qe.current!==e&&(Je.current=e),e||(Je.current=null,Re(``)),qe.current=e},[e,c]),(0,Y.useLayoutEffect)(()=>{!e||y!==e||Je.current===e&&(Je.current=null,Re(``))},[e,y]),(0,Y.useEffect)(()=>{if(!He){ie([]);return}let t=new AbortController;return(async()=>{try{re(await Sn(`opencode`,t.signal))}catch(e){S(e)||re(e=>e)}})(),(async()=>{try{ie(await mw(`opencode`,t.signal,e))}catch(e){S(e)||ie([])}})(),()=>{t.abort()}},[e,He]);let Qt=({active:e})=>{oe(!1),L(null),z({x:0,y:0});let t=Sl(String(e.id));if(t){F(Vt(t.bundleId,t.column)),N(null);return}F(null),N(d.find(t=>t.id===e.id)??null)},$t=()=>{oe(!1),L(null),z({x:0,y:0}),N(null),F(null)},en=(0,Y.useCallback)(e=>{f(t=>e.reduce((e,t)=>SY(e,t),t))},[f]),tn=(0,Y.useCallback)((e,t)=>{if(e.length===0)return;let n=e[0]?.state;n&&f(r=>e.reduce((e,r)=>TY(e,r.id,t,fX(r,n,t)),r))},[f]),nn=(0,Y.useCallback)((e,t=d)=>!e.worktree_bundle_id||!e.project_id||e.state!==`build`?[]:t.filter(t=>t.project_id===e.project_id&&t.worktree_bundle_id===e.worktree_bundle_id&&t.state===`build`&&t.parked_at===null).sort(UY),[d]),rn=async({active:e,over:t})=>{let n=Sl(String(e.id)),r=d.find(t=>t.id===e.id),i=n?Vt(n.bundleId,n.column):null,a=t?.id===`trash`&&(r!==void 0&&Nw(r,`trash`)||i!==null&&oX(i)),o=t?.id&&KY.includes(t.id)?t.id:null;if(oe(a),L(null),z({x:0,y:0}),N(null),F(null),t){if(n){if(t.id===`trash`){if(!i||!oX(i))return;await Pn(i);return}if(t.id===qY){if(!i||!sX(i))return;await jn(i);return}if(o){if(n.column===qY){if(!i||!cX(i))return;await Mn(i);return}await lr(n.bundleId,n.column,o)}return}if(t.id===`trash`){if(!r||!Nw(r,`trash`))return;Ln(e.id);return}if(t.id===qY){if(!r||!Nw(r,qY))return;await kn(e.id);return}if(o){if(r&&Mw(r,o)){await An(e.id);return}if(!(!r||!Nw(r,o)))try{await Dn(r,o,{optimistic:!0})}catch(e){Q.error(e instanceof O?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`})}}}},Cn=async(t,n,r,a,o,s,c)=>{let u=await qt({title:t,description:n,tool:i,model:a,variant:o,skills:s,project_id:e,...c});if(nX(a,o,s),f(e=>SY(e,gY(u))),u.bundle&&g(e=>bY(e,u.bundle)),r===`build`)try{await Dn(u,`build`)}catch(e){Q.error(e instanceof O?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`})}r===`plan`&&xn(u.id,u.project_id)},wn=async t=>{if(!e)throw Error(l(`board.errors.createBundleWithoutProject`));let n=await wt(e,{name:t,prepare:!0});return g(e=>bY(e,n)),n},Tn=e=>{f(t=>[...e.tickets].reverse().reduce((e,t)=>SY(e,gY(t)),t)),m(t=>e.dependencies.reduce((e,t)=>Bw(e,t),t));for(let t of e.tickets)t.bundle&&g(e=>bY(e,t.bundle))},En=(0,Y.useCallback)((e,t={})=>{let n=gY(e);f(e=>t.reorderInState?SY(e,n):xY(e,n)),W(t=>!t||t.id!==e.id?t:WY(e,n)),e.bundle&&g(t=>bY(t,e.bundle))},[g,f]),Dn=async(e,t,n={})=>{let r=d.findIndex(t=>t.id===e.id),i=t===`review`?nn(e):[],a=t===`review`&&i.length>1,o=n.optimistic?a?i.map(e=>e.id):[e.id]:[];n.optimistic&&(D(o,t),a?tn(i,t):f(n=>TY(n,e.id,t,uX(e,t))));try{if(a&&e.project_id&&e.worktree_bundle_id){let t=await jt(e.project_id,e.worktree_bundle_id);Qn(t);let n=t.tickets.find(t=>t.id===e.id);if(!n)throw Error(l(`board.errors.missingBundleReviewTicket`));return k(o),n}let n=await Xt(e.id,e.project_id,t);return f(r=>{let i=r.find(t=>t.id===e.id);return i?.state===t&&n.state===t&&i.agent_status!==n.agent_status&&n.agent_status===e.agent_status?r:_Y(i,n)?SY(r,n):xY(r,n)}),n.bundle&&g(e=>bY(e,n.bundle)),k(o),n}catch(t){throw n.optimistic&&(a?en(i):f(t=>TY(t,e.id,e.state,{agent_status:e.agent_status,agent_log:e.agent_log,build_completed_at:e.build_completed_at},{preferredIndex:r})),k(o)),t}},On=(e,t)=>{f(n=>n.map(n=>n.id===e?{...n,...t}:n))},kn=async t=>{let n=d.find(e=>e.id===t);if(n)try{let r=new Date().toISOString();A([t],r),On(t,{parked_at:r}),En(await ln(t,n.project_id??e),{reorderInState:!0}),j([t])}catch(e){j([t]),On(t,{parked_at:n.parked_at}),Q.error(e instanceof O?e.message:l(`board.errors.parkTicket`),{id:`board-park-error`})}},An=async t=>{let n=d.find(e=>e.id===t);if(n)try{A([t],null),On(t,{parked_at:null}),En(await un(t,n.project_id??e),{reorderInState:!0}),j([t])}catch(e){j([t]),On(t,{parked_at:n.parked_at}),Q.error(e instanceof O?e.message:l(`board.errors.returnTicket`),{id:`board-unpark-error`})}},jn=(0,Y.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at})),r=new Date().toISOString();A(e.tickets.map(e=>e.id),r),f(e=>e.map(e=>t.has(e.id)?{...e,parked_at:r}:e));let i=await Promise.allSettled(e.tickets.map(e=>ln(e.id,e.project_id??x.current))),a=new Set;if(i.forEach((t,n)=>{if(t.status===`fulfilled`){j([t.value.id]),En(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&a.add(r.id)}),a.size===0)return;j([...a]),f(e=>e.map(e=>{if(!a.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let o=i.find(e=>e.status===`rejected`),s=a.size===e.tickets.length?o?.reason instanceof O?o.reason.message:l(`board.errors.moveBundleToDone`):l(`board.toasts.movedBundleToDonePartial`,{movedCount:e.tickets.length-a.size,totalCount:e.tickets.length});Q.error(s,{id:`board-bundle-park-error`})},[x,En,j,A,f,l]),Mn=(0,Y.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at}));A(e.tickets.map(e=>e.id),null),f(e=>e.map(e=>t.has(e.id)?{...e,parked_at:null}:e));let r=await Promise.allSettled(e.tickets.map(e=>un(e.id,e.project_id??x.current))),i=new Set;if(r.forEach((t,n)=>{if(t.status===`fulfilled`){j([t.value.id]),En(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&i.add(r.id)}),i.size===0)return;j([...i]),f(e=>e.map(e=>{if(!i.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let a=r.find(e=>e.status===`rejected`),o=i.size===e.tickets.length?a?.reason instanceof O?a.reason.message:l(`board.errors.restoreBundle`):l(`board.toasts.restoredBundlePartial`,{restoredCount:e.tickets.length-i.size,totalCount:e.tickets.length});Q.error(o,{id:`board-bundle-unpark-error`})},[x,En,j,A,f,l]),Nn=async t=>{e&&(await zt(e,t),g(e=>e.filter(e=>e.id!==t)))},Pn=(0,Y.useCallback)(async t=>{let n=t.tickets.map(e=>({ticket:e,index:d.findIndex(t=>t.id===e.id)})).filter(e=>e.index!==-1);if(n.length===0)return;for(let e of n)C.current.set(e.ticket.id,e);let r=new Set(n.map(e=>e.ticket.id));f(e=>e.filter(e=>!r.has(e.id))),m(e=>e.filter(e=>!r.has(e.blocker_ticket_id)&&!r.has(e.dependent_ticket_id)));let i=await Promise.allSettled(n.map(async t=>(await sn(t.ticket.id,t.ticket.project_id??e),C.current.delete(t.ticket.id),t.ticket.id)));t.tickets.some(e=>e.project_id===x.current)&&T().catch(()=>{});let a=n.filter((e,t)=>i[t]?.status===`rejected`);if(a.length===0)return;for(let e of a)C.current.delete(e.ticket.id);a.some(e=>e.ticket.project_id===x.current)&&f(e=>[...a].sort((e,t)=>e.index-t.index).reduce((e,t)=>aX(e,t),e));let o=i.find(e=>e.status===`rejected`),s=a.length===n.length?o?.reason instanceof O?o.reason.message:l(`board.errors.deleteBundleTickets`):l(`board.toasts.deletedBundleTicketsPartial`,{deletedCount:n.length-a.length,totalCount:n.length});Q.error(s,{id:`board-delete-bundle-wrapper-error`})},[e,x,C,T,m,f,d,l]),Fn=e=>{let t=ct.get(e.id);En(e,{reorderInState:t?t.state!==e.state||t.parked_at!==e.parked_at||t.worktree_bundle_id!==e.worktree_bundle_id:!1}),t?.worktree_bundle_id&&t.worktree_bundle_id!==e.worktree_bundle_id&&t.bundle?.ticket_count===1&&g(e=>e.filter(e=>e.id!==t.worktree_bundle_id)),(t?.worktree_bundle_id!==e.worktree_bundle_id||t?.bundle?.ticket_count!==e.bundle?.ticket_count)&&e.project_id===x.current&&T().catch(()=>{})},In=async()=>{if(!e)return;let t=e,n=Ot.composer.description.trim();if(!n)return;let r=$Y(),a=Ue?Ot.composer.model.trim():``,o=Ue&&a?Ot.composer.variant.trim():``,s=Ue?Ot.composer.skills:[],c=Date.now();Zt(t,e=>({...e,isOpen:!1,composer:{...e.composer,description:``,worktreeBundleId:``},runs:[{id:r,description:n,model:a,variant:o,skills:s,worktreeBundleId:kt,status:`running`,error:null,submittedAt:c,completedAt:null,boardVisible:!0,boardState:`visible`,summary:null},...e.runs]}));try{let e=await Jt({description:n,tool:i,model:a||null,variant:a&&o||null,skills:s,project_id:t,worktree_bundle_id:kt||null});nX(a||null,a&&o||null,s);let c=eX(e);Zt(t,e=>({...e,runs:tX(e.runs,r,e=>({...e,status:`done`,error:null,completedAt:Date.now(),summary:c,boardVisible:!1}))})),Q.success(l(`board.toasts.planningAgentCardsCreated`,{count:c.ticketCount}),{id:`planning-agent-success-${r}`}),ot(e.tickets.length),x.current===t&&Tn(e)}catch(e){let n=e instanceof O?e.message:l(`board.errors.generateTickets`);Zt(t,e=>({...e,runs:tX(e.runs,r,e=>({...e,status:`error`,error:n,completedAt:Date.now()}))})),Q.error(n,{id:`planning-agent-error`})}},Ln=async t=>{let n=d.find(e=>e.id===t),r=d.findIndex(e=>e.id===t);if(!(!n||r===-1)){C.current.set(t,{ticket:n,index:r}),f(e=>wY(e,t)),m(e=>zw(e,t));try{await sn(t,n.project_id??e),n.project_id===x.current&&T().catch(()=>{}),C.current.delete(t)}catch(e){let n=C.current.get(t);C.current.delete(t),n&&n.ticket.project_id===x.current&&(f(e=>aX(e,n)),Q.error(e instanceof O?e.message:l(`board.errors.deleteTicket`),{id:`board-delete-error`}))}}},Rn=async t=>{let n=d.find(e=>e.id===t);if(!n)return;let r=n.state===`review`?`review`:`build`;try{if(pe(r),n.project_id&&n.worktree_bundle_id&&n.state===`review`){Qn(await Mt(n.project_id,n.worktree_bundle_id));return}En(await cn(t,n.project_id??e),{reorderInState:!0})}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.undoTicket`),{id:`board-undo-error`}),e}finally{pe(e=>e===r?null:e)}},zn=t=>{fn(t,d.find(e=>e.id===t)?.project_id??e)},Bn=async t=>{let n=d.find(e=>e.id===t),r=n?ww(n):t;try{Ze(r),await pn(t,n?.project_id??e),s?.()}catch(e){Ze(e=>e===r?null:e),Q.error(e instanceof O?e.message:l(`board.errors.startRun`),{id:`board-run-error`})}},Vn=(0,Y.useCallback)(async t=>{let n=d.find(e=>e.id===t);try{await mn(t,n?.project_id??e)}catch(e){Q.error(e instanceof O?e.message:l(`board.errors.openIde`),{id:`board-open-ide-error`})}},[e,l,d]),Hn=async t=>{let n=d.find(e=>e.id===t),i=r?.kind===`ticket`&&n&&q===ww(n)?et:null;try{await hn(t,n?.project_id??e),o?.(i),s?.()}catch{}},Un=t=>{gn(t,d.find(e=>e.id===t)?.project_id??e).then(()=>{f(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e))})},Wn=t=>{_n(t,d.find(e=>e.id===t)?.project_id??e).then(()=>{f(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e))})},Gn=(0,Y.useCallback)(e=>{let t=Yt(e);!t||!Wt(t)||Vn(t.id)},[Wt,Yt,Vn]),Kn=(0,Y.useCallback)(e=>{let t=Yt(e);t&&Oe({bundleId:e,ticketId:t.id,projectId:t.project_id,title:t.bundle?Tl(t.bundle):t.title})},[Yt]),qn=(0,Y.useCallback)(e=>{if(!st)return;let t=Yt(e);!t?.project_id||!vl(t)||Ae(e)},[Yt,st]),Jn=(0,Y.useCallback)(e=>{let t=d.find(t=>t.id===e);!t||!Gt(t)||Ee({ticketId:t.id,projectId:t.project_id,title:t.title})},[Gt,d]),Yn=(0,Y.useCallback)(e=>{if(!st)return;let t=d.find(t=>t.id===e);!t?.project_id||!vl(t)||we({ticketId:t.id,projectId:t.project_id})},[st,d]),Xn=(0,Y.useCallback)(async(t,n)=>{let r=d.find(e=>e.id===t);if(r)try{En(r.state===`plan`?await bn(t,r.project_id??e,n):await vn(t,r.project_id??e,n))}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.sendFollowUp`),{id:`board-follow-up-error`}),e}},[e,En,l,d]),Zn=(0,Y.useCallback)(e=>{f(t=>e.reduce((e,t)=>{let n=e.find(e=>e.id===t.id),r=E(n,t);if(!r)return e;let i=gY(n&&n.state===r.state&&n.agent_status===`running`&&r.agent_status===null?{...r,agent_status:n.agent_status,session_id:n.session_id,is_running:n.is_running}:r);return _Y(n,i)?SY(e,i):xY(e,i)},t))},[E,f]),Qn=(0,Y.useCallback)(e=>{Se(e),g(t=>bY(t,e.bundle)),Zn(e.tickets)},[Zn,g]),$n=(0,Y.useCallback)((e,t)=>{Array.isArray(t.tickets)&&Se(n=>!n||n.bundle.id!==e?n:{...n,tickets:t.tickets,execution_order_ticket_ids:t.execution_order_ticket_ids,latest_session_ticket_id:t.latest_session_ticket_id,latest_session_id:t.latest_session_id,review_owner_ticket_id:t.review_owner_ticket_id,target_ticket_id:t.target_ticket_id})},[]),er=(0,Y.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await Tt(t,e);return x.current===t?(Qn(n),n):null},[x,Qn]),tr=(0,Y.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await Et(t,e);return x.current===t?($n(e,n),n):null},[x,$n]),nr=(0,Y.useCallback)(async(e,t=null)=>{let n=x.current;if(!n)return;he(null),W(null),ve(e),be(t),Pe(JY());let r=dt.get(e)??null,i=d.filter(t=>t.worktree_bundle_id===e);if(r&&i.length>0){let e=gl(i),t=yl(i,{reviewOwnerTicketId:i.find(e=>e.state===`review`)?.id??null,latestSessionTicketId:e?.id??null});Se({bundle:r,tickets:i,latest_session_ticket_id:e?.id??null,latest_session_id:e?.session_id??null,review_owner_ticket_id:i.find(e=>e.state===`review`)?.id??null,target_ticket_id:t?.id??null})}else Se(null);Me(!0);try{await tr(e)}catch{}finally{x.current===n&&Me(!1)}},[x,dt,tr,d]),rr=(0,Y.useCallback)(async(e,t)=>{Pe(t=>({...t,[e]:!0}));try{return await t()}finally{Pe(t=>({...t,[e]:!1}))}},[]),ir=(0,Y.useCallback)(async t=>{await rr(`stopBuild`,async()=>{let n=d.find(e=>e.id===t);await gn(t,n?.project_id??e),f(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e)),n?.worktree_bundle_id&&await er(n.worktree_bundle_id)})},[e,er,rr,f,d]),ar=(0,Y.useCallback)(async t=>{await rr(`resumeBuild`,async()=>{let n=d.find(e=>e.id===t);await _n(t,n?.project_id??e),f(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e)),n?.worktree_bundle_id&&await er(n.worktree_bundle_id)})},[e,er,rr,f,d]),or=(0,Y.useCallback)(async t=>{if(e)try{Qn(await rr(`build`,()=>At(e,t))),_e===t&&be(`build`),s?.()}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.buildBundle`),{id:`board-bundle-build-error`}),e}},[e,Qn,s,rr,_e,l]),sr=(0,Y.useCallback)(async t=>{if(e)try{Qn(await rr(`review`,()=>jt(e,t))),_e===t&&be(`review`)}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.reviewBundle`),{id:`board-bundle-review-error`}),e}},[e,Qn,rr,_e,l]),cr=(0,Y.useCallback)(async t=>{if(e)try{pe(`review`),Qn(await rr(`undoReview`,()=>Mt(e,t))),_e===t&&be(`build`)}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.undoBundleReview`),{id:`board-bundle-undo-review-error`}),e}finally{pe(e=>e===`review`?null:e)}},[e,Qn,rr,_e,l]),lr=(0,Y.useCallback)(async(e,t,n)=>{if(t===qY||n===qY)return;let r=dX(t,n);if(!r)return;let i=d.filter(n=>n.worktree_bundle_id===e&&n.state===t&&n.parked_at===null);if(i.length===0)return;let a=i.map(e=>e.id);D(a,n),tn(i,n);try{if(r===`build`){await or(e),k(a);return}if(r===`review`){await sr(e),k(a);return}await cr(e),k(a)}catch(e){en(i),k(a),Q.error(e instanceof O?e.message:l(`board.errors.moveBundle`),{id:`board-bundle-move-error`})}},[k,or,sr,cr,D,tn,en,d,l]),ur=async t=>{e&&(Qn(await rr(`run`,()=>Lt(e,t))),s?.())},dr=async t=>{if(!e)return;let n=r?.kind===`ticket`&&q===t?et:null,i=await rr(`stop`,()=>Rt(e,t));o?.(n),Qn(i),s?.()},fr=(0,Y.useCallback)(async(t,n)=>{e&&Qn(await rr(`followUp`,()=>Nt(e,t,n)))},[e,Qn,rr]);(0,Y.useEffect)(()=>()=>{a?.(null)},[a]),(0,Y.useEffect)(()=>{if(!a)return;if(!r){a(null);return}if(r.kind===`project`){a({target:null,canSelect:!1,disabledReason:l(`board.preview.disabledProjectRoot`),submitPrompt:null});return}let e=d.find(e=>e.id===r.ticket_id);if(!e){a({target:null,canSelect:!1,disabledReason:l(`board.preview.disabledBuildCapable`),submitPrompt:null});return}if(e.state===`plan`){a({target:{kind:`ticket`,id:e.id},canSelect:!1,disabledReason:l(`board.preview.disabledPlanMode`),submitPrompt:null});return}if(e.worktree_bundle_id){a({target:{kind:`bundle`,id:e.worktree_bundle_id,ticket_id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:l(`board.preview.followUpBundlePlaceholder`),submitPrompt:t=>fr(e.worktree_bundle_id,t)});return}a({target:{kind:`ticket`,id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:l(`board.preview.followUpTicketPlaceholder`),submitPrompt:t=>Xn(e.id,t)})},[r,Xn,fr,a,l,d]);let pr=async t=>{let n=d.find(e=>e.id===t),r=n?Sw(n.state):null;if(n)try{if(n.state===`review`&&n.can_re_review&&n.agent_status!==`running`){let t=await yn(n.id,n.project_id??e);En(t),t.worktree_bundle_id&&await er(t.worktree_bundle_id);return}if(!r)return;if(n.worktree_bundle_id&&r===`review`){await sr(n.worktree_bundle_id);return}await Dn(n,r)}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`}),e}},mr=async t=>{let n=d.find(e=>e.id===t);try{En(await an(t,n?.project_id??e))}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.startBuildChain`),{id:`board-build-chain-error`}),e}},hr=async t=>{let n=d.find(e=>e.id===t);try{await on(t,n?.project_id??e)}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.stopBuildChain`),{id:`board-stop-build-chain-error`}),e}},gr=async()=>{if(!(!e||ue)){de(!0);try{let t=await dn(e);f(e=>e.filter(e=>!t.deleted_ticket_ids.includes(e.id))),m(e=>t.deleted_ticket_ids.reduce(zw,e)),await T(),U(!1),t.failed_count>0?Q.error(l(`board.toasts.deleteDonePartial`,{count:t.deleted_count,deletedCount:t.deleted_count,failedCount:t.failed_count}),{id:`board-delete-parked-error`}):Q.success(l(`board.toasts.deleteDoneSuccess`,{count:t.deleted_count}),{id:`board-delete-parked-success`})}catch(e){Q.error(e instanceof O?e.message:l(`board.errors.emptyDone`),{id:`board-delete-parked-error`})}finally{de(!1)}}},_r=({delta:e})=>{z(e)},vr=(0,Y.useCallback)((t=null)=>{e&&ee({initialWorktreeBundleId:t})},[e]),yr=(0,Y.useCallback)(()=>{e&&Zt(e,e=>e.isOpen?e:{...e,isOpen:!0})},[e,Zt]),br=(0,Y.useCallback)(()=>{Ye.current?.focus({preventScroll:!0})},[]);return hY([{key:`n`,onKeyDown:vr,disabled:!e},{key:`a`,onKeyDown:yr,disabled:!e},{key:`k`,ctrlKey:!0,onKeyDown:br}],{isBlocked:mY}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(KC,{sensors:u,collisionDetection:iS,onDragStart:Qt,onDragMove:_r,onDragCancel:$t,onDragEnd:rn,children:[(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(nY,{projectId:e,state:Pt,bundles:h,projectBranchState:n,showModelSelector:Ue,availableModels:V,availableSkills:H,onManageBundles:e?()=>{(async()=>{try{await T()}catch{}ne(!0)})()}:void 0,onToggle:()=>{e&&Zt(e,e=>({...e,isOpen:!e.isOpen}))},onDescriptionChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,description:t}}))},onModelChange:t=>{if(!e)return;let n=V.find(e=>e.id===t)??null;Zt(e,e=>({...e,composer:{...e.composer,model:t,variant:n?.variants.includes(e.composer.variant)?e.composer.variant:``}}))},onSkillsChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,skills:t}}))},onVariantChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,variant:t}}))},onBundleChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t}}))},onGenerate:()=>{In()}}),(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:G(`absolute inset-y-0 left-16 right-0 z-10 bg-black/60 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Pt.isOpen?`opacity-100`:`pointer-events-none opacity-0`)}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 overflow-hidden p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,Z.jsx)(We,{id:`board-ticket-search`,ref:Ye,type:`search`,value:Le,onChange:e=>Re(e.target.value),placeholder:l(`board.search.placeholder`),"aria-label":l(`board.search.ariaLabel`),className:`pr-32`}),Le.length>0?(0,Z.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":l(`board.search.clearAriaLabel`),className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{Re(``),Ye.current?.focus()},children:(0,Z.jsx)(Be,{className:`size-4`})}):(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(pw,{children:`CTRL`}),(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(pw,{children:`K`})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ud,{id:`board-hide-stale-tickets`,checked:ze,onCheckedChange:Ve,"aria-label":l(`board.search.hideStaleAriaLabel`)}),(0,Z.jsx)(Xs,{htmlFor:`board-hide-stale-tickets`,className:`text-sm text-muted-foreground`,children:l(`board.search.hideStaleLabel`)})]})]}),(0,Z.jsx)(`div`,{ref:gt,className:`flex min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,Z.jsxs)(`div`,{ref:_t,className:`relative flex min-h-0 w-max min-w-full gap-4`,children:[(0,Z.jsx)(KJ,{dependencies:p,cardRects:yt,preview:bt,ticketsById:ct,overlaySize:xt}),KY.map(t=>{let n=d.filter(e=>e.state===t&&!Ew(e)),r=pt.filter(e=>e.state===t&&!Ew(e)),i=bl(r,h,t),a=it&&n.length===0?t===`plan`?1:t===`build`?2:0:0;return(0,Z.jsx)(nG,{id:t,title:l(`card.columnLabels.${t}`),pinnedContent:t===`plan`?Ut:null,items:i,ticketCount:r.length,allTickets:d,dependencies:p,showModelSelector:Ue,availableModels:V,bundles:h,activeRunContextKey:tt,isProjectRootRunActive:J,isBundleRunDisabled:nt,getDependencyTargetState:St,onDependencyStart:Ct,onDeleteDependency:Dt,onRegisterTicketNode:vt,onAddTicket:t===`plan`&&e?vr:void 0,onCreateBundle:t===`plan`&&e?wn:void 0,onDeleteBundle:t===`plan`&&e?Nn:void 0,onDeleteBundleWrapper:Pn,onRefreshBundles:t===`plan`&&e?T:void 0,onUpdateTicket:Fn,onDeleteTicket:Ln,onUndoTicket:Rn,undoingColumn:fe,onRetryTicket:zn,onAdvanceTicket:pr,onParkTicket:kn,onUnparkTicket:An,onBuildChainTicket:mr,onRunTicket:Bn,onOpenTestsTicket:st?Yn:void 0,canOpenChangesForTicket:Gt,onOpenChangesTicket:Jn,canOpenIdeForTicket:Wt,onOpenIdeTicket:Vn,onStopTicket:Hn,onStopBuildTicket:Un,onStopBuildChainTicket:hr,onResumeBuildTicket:Wn,onOpenBundleChanges:Kn,onOpenBundleTests:st?qn:void 0,onOpenBundleIde:Gn,onAddTicketToBundle:vr,onFollowUpTicket:Xn,bundleActionState:Ne,onBuildBundle:or,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onParkBundleWrapper:jn,onUnparkBundleWrapper:Mn,onOpenTicketDetails:ut,onOpenBundleDetails:(e,t)=>{nr(e,t)},onRequestBundleRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onRequestTicketRefresh:w,loadingSkeletonCount:a},t)}),(0,Z.jsx)(nG,{id:qY,title:l(`card.columnLabels.done`),items:ht,ticketCount:mt.length,allTickets:d,dependencies:p,showModelSelector:Ue,availableModels:V,bundles:h,activeRunContextKey:tt,isProjectRootRunActive:J,isBundleRunDisabled:nt,getDependencyTargetState:St,onDependencyStart:Ct,onDeleteDependency:Dt,onRegisterTicketNode:vt,onUpdateTicket:Fn,onDeleteTicket:Ln,onUndoTicket:Rn,undoingColumn:fe,onRetryTicket:zn,onAdvanceTicket:pr,onParkTicket:kn,onUnparkTicket:An,onBuildChainTicket:mr,onRunTicket:Bn,onOpenTestsTicket:st?Yn:void 0,canOpenChangesForTicket:Gt,onOpenChangesTicket:Jn,canOpenIdeForTicket:Wt,onOpenIdeTicket:Vn,onStopTicket:Hn,onStopBuildTicket:Un,onStopBuildChainTicket:hr,onResumeBuildTicket:Wn,onOpenBundleChanges:Kn,onOpenBundleTests:st?qn:void 0,onOpenBundleIde:Gn,onAddTicketToBundle:vr,onFollowUpTicket:Xn,bundleActionState:Ne,onBuildBundle:or,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onParkBundleWrapper:jn,onUnparkBundleWrapper:Mn,onOpenTicketDetails:ut,onOpenBundleDetails:(e,t)=>{nr(e,t)},onRequestBundleRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onRequestTicketRefresh:w,className:`min-w-[272px] max-w-[272px] flex-[0.98] bg-card/65`,headerAccessory:(0,Z.jsxs)(K,{type:`button`,variant:`destructive`,size:`xs`,className:`gap-1.5`,disabled:mt.length===0||ue,onClick:()=>U(!0),children:[(0,Z.jsx)(Su,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:l(`board.doneColumn.emptyAction`)})]})})]})})]})]}),(0,Z.jsxs)(fw,{zIndex:5,dropAnimation:ae?null:void 0,children:[M&&(0,Z.jsx)(eG,{ticket:M,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:M.tool===`opencode`&&V.length>0,availableModels:V,runDisabled:lX(M,tt,J,l(`board.errors.runBlockedByActive`))!==void 0,runDisabledReason:lX(M,tt,J,l(`board.errors.runBlockedByActive`)),onDependencyStart:Ct,onDeleteDependency:Dt,onRegisterOverlayNode:L,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:T,onUpdate:Fn,onDelete:()=>Ln(M.id),onUndo:()=>Rn(M.id),undoInProgress:fe===M.state&&(M.state===`build`||M.state===`review`),onRetry:()=>zn(M.id),onAdvance:()=>pr(M.id),onPark:()=>kn(M.id),onUnpark:()=>An(M.id),onBuildChain:()=>mr(M.id),onRun:M.worktree_bundle_id===null&&vl(M)&&M.has_run_config?()=>Bn(M.id):void 0,onOpenIde:M.worktree_bundle_id===null&&Wt(M)?()=>Vn(M.id):void 0,onStop:M.worktree_bundle_id===null?()=>Hn(M.id):void 0,onStopBuild:()=>Un(M.id),onStopBuildChain:()=>hr(M.id),onResumeBuild:()=>Wn(M.id),onFollowUp:e=>Xn(M.id,e),onRequestTicketRefresh:w}),!M&&P&&(0,Z.jsx)(mT,{group:P,overlay:!0,renderTicket:Ht})]}),rt&&(0,Z.jsx)(rY,{className:`pointer-events-auto fixed left-1/2 top-4 z-20 w-[min(14rem,calc(100vw-2rem))] -translate-x-1/2`})]}),B&&(0,Z.jsx)(qJ,{onSubmit:Cn,bundles:h,projectId:e,projectBranchState:n,tool:i,showModelSelector:Ue,availableModels:V,availableSkills:H,initialModel:Ue?Ft.model:``,initialVariant:Ue&&Ft.model?Ft.variant:``,initialSkills:Ue?Ft.skills:[],initialWorktreeBundleId:B.initialWorktreeBundleId,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:T,onClose:()=>ee(null)}),te&&e&&(0,Z.jsx)(wu,{bundles:h,selectedBundleId:Pt.composer.worktreeBundleId||null,onSelectBundle:t=>{Zt(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t??``}}))},onCreateBundle:wn,onDeleteBundle:Nn,onClose:()=>ne(!1)}),le&&(0,Z.jsx)(rG,{ticketCount:mt.length,isDeleting:ue,onCancel:()=>U(!1),onConfirm:()=>{gr()}}),ge&&(0,Z.jsx)($W,{ticket:ge,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,projectBranchState:n,onClose:()=>{let e=ge.id;he(null),W(null),f(t=>t.map(t=>t.id===e?gY(t):t))},showModelSelector:Ge,availableModels:V,availableSkills:H,runDisabled:lX(ge,tt,J,l(`board.errors.runBlockedByActive`))!==void 0,runDisabledReason:lX(ge,tt,J,l(`board.errors.runBlockedByActive`)),onDeleteDependency:Dt,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:T,onUpdate:Fn,onAdvance:()=>pr(ge.id),onBuildChain:()=>mr(ge.id),onRun:vl(ge)&&ge.has_run_config?()=>Bn(ge.id):void 0,onOpenIde:Wt(ge)?()=>Vn(ge.id):void 0,onStop:()=>Hn(ge.id),onStopBuild:()=>Un(ge.id),onStopBuildChain:()=>hr(ge.id),onResumeBuild:()=>Wn(ge.id),onFollowUp:e=>Xn(ge.id,e),onProjectMemorySuggestionsChanged:()=>{Ie(e=>e+1)},onRequestTicketRefresh:e=>{lt(e)}}),Ce&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(LY,{scope:`ticket`,ticketId:Ce.ticketId,projectId:Ce.projectId,testCommands:at,onClose:()=>we(null)})}),De&&(0,Z.jsx)(MJ,{ticketId:De.ticketId,projectId:De.projectId,reviewCommentsBundleId:De.bundleId,title:De.title,onSubmitReviewPrompt:e=>fr(De.bundleId,e),canSubmitReviewPrompt:!d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`),reviewSubmitDisabledReason:d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`)?l(`board.changes.reviewPromptDisabledReason`):void 0,canAddReviewComments:!d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`),canModifyChanges:!d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`),changesDisabledReason:d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`)?l(`board.changes.modifyChangesDisabledReason`):void 0,onClose:()=>{let{bundleId:e}=De;Oe(null),er(e)},onTicketUpdate:Fn,onRequestTicketRefresh:w}),Te&&(0,Z.jsx)(MJ,{ticketId:Te.ticketId,projectId:Te.projectId,title:Te.title,onClose:()=>{let{ticketId:e}=Te;Ee(null),lt(e)},onTicketUpdate:Fn,onRequestTicketRefresh:e=>{lt(e)}}),ke&&e&&t&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(LY,{scope:`project`,projectId:e,targetKind:`bundle`,targetBundleId:ke,testCommands:at,onClose:()=>Ae(null)})}),_e&&ft&&(0,Z.jsx)(CG,{details:ft,activeColumn:ye,isLoading:je||Ne.bundleRefresh,actionState:Ne,canOpenIde:Kt(ft),projectMemoryEnabled:!!t?.memory_enabled,memorySuggestionsRefreshKey:Fe,runDisabled:nt(ft.bundle.id),showModelSelector:Ke,availableModels:V,availableSkills:H,onClose:()=>{let e=ft.bundle.id;ve(null),be(null),Se(null),Me(!1),Pe(JY()),f(t=>t.map(t=>t.worktree_bundle_id===e&&t.id!==me?gY(t):t))},onOpenTicketDetails:ut,onUpdateTicket:Fn,onOpenIde:()=>{let e=ft.tickets.find(e=>e.id===ft.target_ticket_id)??ft.tickets.find(e=>e.has_worktree);e&&Vn(e.id)},onOpenTests:st?()=>{qn(ft.bundle.id)}:void 0,onRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onBuildBundle:or,onStopBuildTicket:ir,onResumeBuildTicket:ar,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onFollowUpBundle:fr})]})},mX=({className:e})=>(0,Z.jsx)(ko,{"aria-hidden":`true`,className:e}),hX=({className:e})=>(0,Z.jsx)(bo,{"aria-hidden":`true`,className:e}),gX=({className:e})=>(0,Z.jsx)(xo,{"aria-hidden":`true`,className:e}),_X=4,vX=5e3,yX=(e,t)=>Ne.t(`common:chatChangesPanel.${e}`,t),bX=e=>e.replace(/^[ab]\//,``),xX=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?bX(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?bX(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},SX=e=>{let[t,n]=xX(e);return!t&&!n?yX(`unknownFile`):t&&n&&t!==n?`${n} -> ${t}`:t??n??yX(`unknownFile`)},CX=e=>{let t=WK((()=>{let[t,n]=xX(e);return t??n??null})());if(!t)return null;try{return qy(e.hunks,{highlight:!0,refractor:Wq.default,language:t,enhancers:[Gy(e.hunks)]})}catch{return null}},wX=(e,t)=>e instanceof Error?e.message:t,TX=(e,t)=>{if(!t)return e;let n=SX(t);return[t,...e.filter(e=>SX(e)!==n)]},EX=e=>[...e].sort((e,t)=>{if(e.filePath!==t.filePath)return e.filePath.localeCompare(t.filePath);let n=e.newLineNumber??e.oldLineNumber??2**53-1,r=t.newLineNumber??t.oldLineNumber??2**53-1;return n===r?e.changeKey.localeCompare(t.changeKey):n-r}),DX=({diffResponse:e,gitStatus:t})=>{let n=new Map;for(let t of e?.files??[])n.set(t.path,t);return t?t.files.map(e=>{let t=n.get(e.path)??(e.original_path?n.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(e?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions}))},OX=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},kX={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},AX=e=>yX(`fileStatus.${e}`),jX=({selectedDiffPath:e,sidebarFiles:t,diffStats:n,triggerMode:r=`full`,onSelectDiffPath:i})=>{let[a,o]=(0,Y.useState)(!1),s=t.find(t=>t.path===e)??null,c=r===`compact`?e===`all`?yX(`picker.diff`):s?OX(s.path):yX(`picker.file`):e===`all`?yX(`picker.allChanges`):s?OX(s.path):e;return(0,Z.jsxs)(Zs,{open:a,onOpenChange:o,children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:G(`max-w-full gap-2`,r===`full`?`min-w-0 max-w-[18rem]`:`min-w-0 px-2.5`),"aria-label":yX(`picker.openChangedFilesAriaLabel`),title:e===`all`?void 0:s?.path??e,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:c}),r===`full`&&(0,Z.jsx)(U,{variant:`outline`,className:`shrink-0 text-[10px] uppercase tracking-wide`,children:yX(`picker.fileCount`,{count:t.length})}),(0,Z.jsx)(Oe,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Z.jsxs)($s,{align:`start`,className:`z-[90] w-[28rem] max-w-[calc(100vw-2rem)] p-0`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:yX(`picker.title`)})}),(0,Z.jsx)(`div`,{className:`max-h-[min(28rem,calc(100vh-10rem))] overflow-y-auto p-3`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{i(`all`),o(!1)},className:G(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,OK(e===`all`),`justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:yX(`picker.allChanges`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:yX(`picker.allChangesDescription`)})]}),n&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:yX(`picker.fileCount`,{count:n.files_changed})}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,n.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,n.deletions]})]})]}),t.map(t=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{i(t.path),o(!1)},className:G(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,OK(e===t.path)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:OX(t.path)}),(0,Z.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.path})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,t.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,t.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[t.status&&(0,Z.jsx)(U,{variant:`outline`,className:kX[t.status],children:AX(t.status)}),t.staged&&(0,Z.jsx)(U,{variant:`outline`,children:yX(`fileStatus.staged`)}),t.unstaged&&(0,Z.jsx)(U,{variant:`outline`,children:yX(`fileStatus.unstaged`)}),t.conflicted&&(0,Z.jsx)(U,{variant:`destructive`,children:yX(`fileStatus.conflicted`)}),t.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.status===`renamed`?yX(`fileStatus.renamedFrom`,{path:t.originalPath}):t.originalPath})]})]})},`${t.path}:${t.originalPath??``}`))]})})]})]})},MX=(0,Y.memo)(({projectId:e,chatSessionId:t=null,canSubmitReviewPrompt:n,reviewSubmitDisabledReason:r,onSubmitReviewPrompt:i,state:a,onStateChange:o,isResizing:s=!1,onClose:c,desktopWidth:l,panelElementRef:u})=>{let[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),[,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(new Map),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(0),T=(0,Y.useRef)(0),E=(0,Y.useRef)(null),D=(0,Y.useRef)(null),O=a.selectedDiffPath,k=a.activeReviewTarget,A=a.editingReviewCommentKey,j=k?.commentKey??A??`chat`,M=a.reviewDraftInput,N=(0,Y.useMemo)(()=>new Map(a.reviewComments.map(e=>[sb(e.filePath,e.changeKey),e])),[a.reviewComments]),P=(0,Y.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await ix(e,t):await Ve(e)},[t,e]),F=(0,Y.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await ax(e,t):await ke(e)},[t,e]);(0,Y.useEffect)(()=>{E.current=d},[d]),(0,Y.useEffect)(()=>{D.current=p},[p]);let I=(0,Y.useCallback)(async()=>{if(!e){T.current+=1,f(null),m(null),g(null),v(!1),y(!1);return}let t=w.current+1,n=T.current+1;w.current=t,T.current=n,v(!0),y(!0);let[r,i]=await Promise.allSettled([P(),F()]);w.current===t&&(r.status===`fulfilled`?(E.current=r.value,f(r.value),g(null)):g(wX(r.reason,yX(`errors.loadDiff`))),i.status===`fulfilled`&&(D.current=i.value,m(i.value)),T.current===n&&v(!1),y(!1))},[P,F,e]),L=(0,Y.useCallback)(async(t={})=>{if(!e)return;let{broadcastOnSignatureChange:n=!1}=t,r=w.current+1;w.current=r,y(!0);try{let t=await F();if(w.current!==r)return;let i=D.current?.workspace_signature??null,a=t.workspace_signature??null,o=!E.current||i!==a;if(D.current=t,m(t),!o){T.current+=1,v(!1);return}let s=!E.current,c=T.current+1;T.current=c,s&&v(!0);try{let t=await P();if(w.current!==r)return;E.current=t,f(t),g(null),n&&i!==a&&KK(e)}catch(e){if(w.current!==r)return;E.current||g(wX(e,yX(`errors.loadDiff`)))}finally{s&&T.current===c&&v(!1)}}catch{E.current||(T.current+=1,v(!1));return}finally{w.current===r&&y(!1)}},[P,F,e]);(0,Y.useEffect)(()=>{I()},[I]),(0,Y.useEffect)(()=>{if(e)return qK(t=>{t===e&&L()})},[e,L]),(0,Y.useEffect)(()=>{if(!e)return;let t=YK(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})});return()=>{t()}},[e,L]),(0,Y.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})},vX);return()=>{window.clearInterval(t)}},[e,L]);let R=(0,Y.useMemo)(()=>{let e=typeof d?.diff==`string`?d.diff:``;return e.trim()?Rm(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:xX(e)})):[]},[d]),z=(0,Y.useMemo)(()=>{let e=new Map;for(let t of R)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[R]),B=(0,Y.useMemo)(()=>DX({diffResponse:d,gitStatus:p}),[d,p]);(0,Y.useEffect)(()=>{if(O!==`all`&&!(!d&&!p)){if(B.length===0){o(e=>({...e,selectedDiffPath:`all`}));return}B.some(e=>e.path===O)||o(e=>({...e,selectedDiffPath:`all`}))}},[d,p,o,O,B]);let ee=O===`all`?null:z.get(O)??null,te=(0,Y.useMemo)(()=>TX(R,ee),[R,ee]),ne=(0,Y.useMemo)(()=>O===`all`?R:ee?[ee]:[],[R,O,ee]);(0,Y.useEffect)(()=>{x(new Map)},[R]),(0,Y.useEffect)(()=>{if(te.length===0)return;let e=!1,t=null,n=0,r=()=>{if(e)return;let i=te.slice(n,n+_X);i.length!==0&&(x(e=>{let t=new Map(e);for(let e of i){let n=SX(e);t.has(n)||t.set(n,CX(e))}return t}),n+=_X,n<te.length&&(t=window.setTimeout(r,0)))};return t=window.setTimeout(r,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[te]);let V=(0,Y.useMemo)(()=>{let e=new Map;for(let t of te.slice(0,_X))e.set(SX(t),CX(t));return e},[te]),re=(0,Y.useMemo)(()=>ne.map(e=>({...e,tokens:b.get(SX(e))??V.get(SX(e))??null})),[V,b,ne]),H=(0,Y.useMemo)(()=>R.map(e=>({...e,tokens:null})),[R]),ie=(0,Y.useMemo)(()=>EX(a.reviewComments),[a.reviewComments]),ae=ie.length,oe=n&&!S&&ae>0,se=(0,Y.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}))},[o]),ce=(0,Y.useCallback)(({filePath:e,changeKey:t,commentKey:r})=>{let i=N.get(r);if(i){o(e=>({...e,selectedDiffPath:i.filePath,activeReviewTarget:null,editingReviewCommentKey:r,reviewDraftInput:i.comment}));return}n&&o(n=>({...n,activeReviewTarget:{filePath:e,changeKey:t,commentKey:r},editingReviewCommentKey:null,reviewDraftInput:``}))},[n,o,N]),le=(0,Y.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``}))},[o]),U=(0,Y.useCallback)(e=>{let t=N.has(e.commentKey);if(!n&&!t)return;let r=M.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;o(t=>{let n=new Map(t.reviewComments.map(e=>[sb(e.filePath,e.changeKey),e]));return n.set(e.commentKey,{scope:`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:cb(e.hunk,e.change),comment:r}),{...t,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[...n.values()]}})},[n,o,N,M]),ue=(0,Y.useCallback)(e=>{let t=N.get(e);t&&o(n=>({...n,selectedDiffPath:t.filePath,activeReviewTarget:null,editingReviewCommentKey:e,reviewDraftInput:t.comment}))},[o,N]),de=(0,Y.useCallback)(e=>{o(t=>({...t,activeReviewTarget:t.activeReviewTarget?.commentKey===e?null:t.activeReviewTarget,editingReviewCommentKey:t.editingReviewCommentKey===e?null:t.editingReviewCommentKey,reviewDraftInput:t.activeReviewTarget?.commentKey===e||t.editingReviewCommentKey===e?``:t.reviewDraftInput,reviewComments:t.reviewComments.filter(t=>sb(t.filePath,t.changeKey)!==e)}))},[o]),fe=(0,Y.useCallback)(async()=>{if(!oe)return;C(!0);let e=_b({drafts:ie,findings:[],githubComments:[],uncommittedFiles:R});try{await i(e),se(),Q.success(yX(`toasts.sendChangesSuccess`),{id:`chat-diff-review-submit-success`})}catch(e){Q.error(wX(e,yX(`errors.sendChanges`)),{id:`chat-diff-review-submit-error`})}finally{C(!1)}},[oe,se,i,R,ie]),pe=(0,Y.useCallback)(e=>(0,Z.jsx)(PG,{reviewComments:ie,pendingFixCount:ae,triggerMode:e===`wide`?`full`:`compact`,canSendReview:oe,isSubmittingReview:S,reviewSubmitDisabledReason:r??void 0,onClearPendingFixes:se,onSubmitReview:()=>{fe()}}),[oe,se,fe,S,ae,ie,r]),me=c?(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":yX(`closeAriaLabel`),className:`text-muted-foreground hover:text-foreground`,onClick:c,children:(0,Z.jsx)(Be,{className:`h-4 w-4`})}):null,he=l?{"--chat-changes-panel-width":`${l}px`}:void 0;return(0,Z.jsx)(`aside`,{"data-testid":`chat-changes-panel`,"data-desktop-width":l?String(l):void 0,ref:u,style:he,className:G(`flex h-[26rem] min-h-0 w-full shrink-0 flex-col overflow-hidden border-t border-border/70 bg-background/20 xl:h-full xl:border-l xl:border-t-0`,l?`xl:w-[var(--chat-changes-panel-width)]`:`xl:w-[32rem]`),children:(0,Z.jsx)(DK,{selectedDiffPath:O,sidebarFiles:B,diffResponse:d,isDiffLoading:_,diffError:h,allDiffFiles:H,renderedFiles:re,viewType:`unified`,onViewTypeChange:()=>{},onRetry:()=>{I()},activeReviewTarget:k,editingReviewCommentKey:A,reviewDraftInstanceKey:j,reviewDraftInput:M,reviewComments:ie,reviewFindings:[],githubComments:[],selectedReviewFindingIds:[],selectedGitHubCommentIds:[],canSelectReviewTarget:n,canEditActiveReviewDraft:n,reviewFindingsError:null,gitHubCommentsError:null,hasStaleReviewFindings:!1,onSelectReviewTarget:ce,onToggleReviewFindingSelection:()=>{},onToggleGitHubCommentSelection:()=>{},onReviewDraftInputChange:e=>{o(t=>({...t,reviewDraftInput:e}))},onCancelReviewDraft:le,onEditReviewDraft:ue,onRemoveReviewDraft:de,onSaveReviewDraft:U,diffThemeClassName:NK,resolveFilePath:SX,normalizeDiffPath:bX,emptyStateTitle:yX(`emptyStateTitle`),emptyStateDescription:yX(`emptyStateDescription`),filePickerControl:e=>(0,Z.jsx)(jX,{selectedDiffPath:O,sidebarFiles:B,diffStats:d?.stats??null,triggerMode:e===`wide`?`full`:`compact`,onSelectDiffPath:e=>{o(t=>({...t,selectedDiffPath:e}))}}),reviewSummaryControl:pe,extraHeaderControl:me,surfaceVariant:`flat`,showViewTypeToggle:!1,gutterVariant:`compact`,isResizing:s,resizePlaceholderLineThreshold:200})})});MX.displayName=`ChatChangesPanel`;var NX=({projectId:e,messages:t,internalLog:n,currentThinkingMessageId:r=null,previousThinkingLog:i=null,previousThinkingMessageId:a=null,pendingAgentTitle:o,streamingResponse:s,isRunning:c,isLoading:l=!1,canShowComposer:u,cardClassName:d,isExternallyResizing:f=!1,pendingAgentRevealKey:p=null,pendingAgentRevealDelayMs:m=0,composerFocusNonce:h=0,blurComposerOnSendStart:g=!1,hidePendingAgentTitle:_=!1,forceScrollToBottomKey:v,header:y,composerControls:b,composerInlineControls:x,composerTheme:S=`default`,layoutKey:C,scrollLayoutKey:w,followUpPrompt:T,draftAttachments:E=[],followUpPlaceholder:D,emptyStateText:O=null,renderMessageFooter:k,isSendingFollowUp:A,isUploadingAttachments:j=!1,canAttachImages:M=!1,followUpDisabledReason:N,onFollowUpPromptChange:P,onFollowUpKeyDown:F,onFollowUpPaste:I,onUploadAttachments:L,onRemoveAttachment:R,onFollowUpSubmit:z})=>(0,Z.jsx)(MN,{projectId:e,messages:t,internalLog:n,currentThinkingMessageId:r,previousThinkingLog:i,previousThinkingMessageId:a,pendingAgentTitle:o,streamingResponse:s,isRunning:c,isLoading:l,autoScrollBehavior:`sticky`,surfaceVariant:`chat`,canShowComposer:u,cardClassName:d,header:y,composerControls:b,composerInlineControls:x,composerTheme:S,composerSize:`compact-on-laptop`,showThinkingPlacement:`header`,pinComposerToBottom:!0,isExternallyResizing:f,pendingAgentRevealKey:p,pendingAgentRevealDelayMs:m,composerFocusNonce:h,blurComposerOnSendStart:g,forceScrollToBottomKey:v,layoutKey:C,scrollLayoutKey:w,followUpPrompt:T,draftAttachments:E,followUpPlaceholder:D,emptyStateText:O,autoFocusComposer:!0,renderMessageFooter:k,isSendingFollowUp:A,isUploadingAttachments:j,canAttachImages:M,followUpDisabledReason:N,hidePendingAgentTitle:_,onFollowUpPromptChange:P,onFollowUpKeyDown:F,onFollowUpPaste:I,onUploadAttachments:L,onRemoveAttachment:R,onFollowUpSubmit:z}),PX=({value:e,disabled:t=!1,onChange:n,planInactiveTooltip:r,buildInactiveTooltip:i})=>(0,Z.jsx)(bc,{value:e,items:[{value:`plan`,label:`Plan`,activeVariant:`ghost`,activeClassName:`border-transparent bg-sky-300 text-[#07111a] shadow-[0_10px_30px_rgba(125,211,252,0.24)] hover:bg-sky-200 hover:text-[#07111a]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:r},{value:`build`,label:`Build`,activeVariant:`ghost`,activeClassName:`border-transparent bg-emerald-400 text-[#07130d] shadow-[0_10px_30px_rgba(16,185,129,0.28)] hover:bg-emerald-300 hover:text-[#07130d]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:i}],disabled:t,onChange:n}),FX={default:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,muted:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`},IX=({tone:e=`default`,className:t,children:n,...r})=>(0,Z.jsx)(U,{variant:`outline`,className:G(FX[e],t),...r,children:n}),LX=(e,t)=>Ne.t(`projects:memory.${e}`,t),RX=e=>LX(`stageLabels.${e}`),zX=e=>LX(`priorityLabels.${e}`),BX=()=>({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),VX=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
|
|
145
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function KG(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var qG=(e,t)=>Math.abs(e-t)<1.01,JG=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},YG=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},XG=e=>e,ZG=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},QG=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(YG(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(YG(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},$G={passive:!0},eK=typeof window>`u`?!0:`onscrollend`in window,tK=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&eK?()=>void 0:JG(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,$G);let l=e.options.useScrollendEvent&&eK;return l&&n.addEventListener(`scrollend`,c,$G),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},nK=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},rK=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},iK=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:XG,rangeExtractor:ZG,onChange:()=>{},measureElement:nK,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=GG(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=GG(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=GG(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=GG(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?oK({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=GG(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=GG(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return KG(t[aK(0,t.length-1,e=>KG(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&qG(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},aK=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function oK({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=aK(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var sK=typeof document<`u`?Y.useLayoutEffect:Y.useEffect;function cK({useFlushSync:e=!0,...t}){let n=Y.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Fc.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=Y.useState(()=>new iK(r));return i.setOptions(r),sK(()=>i._didMount(),[]),sK(()=>i._willUpdate()),i}function lK(e){return cK({observeElementRect:QG,observeElementOffset:tK,scrollToFn:rK,...e})}var uK=8,dK=520,fK=2,pK=(e,t)=>Ne.t(`common:ticketChangesDiffPanel.${e}`,t),mK=()=>(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-resize-placeholder`,className:`space-y-4 px-3 py-3`,children:[{gutter:`w-8`,code:`w-[68%]`},{gutter:`w-10`,code:`w-[54%]`},{gutter:`w-8`,code:`w-[74%]`},{gutter:`w-6`,code:`w-[38%]`},{gutter:`w-10`,code:`w-[82%]`},{gutter:`w-7`,code:`w-[61%]`},{gutter:`w-9`,code:`w-[48%]`},{gutter:`w-8`,code:`w-[71%]`},{gutter:`w-11`,code:`w-[57%]`},{gutter:`w-7`,code:`w-[66%]`},{gutter:`w-9`,code:`w-[43%]`},{gutter:`w-8`,code:`w-[76%]`}].map((e,t)=>(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-resize-placeholder-row`,className:`flex items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:G(`h-4 rounded bg-muted/80`,e.gutter)}),(0,Z.jsx)(`div`,{className:G(`h-4 rounded bg-muted/60`,e.code)})]},`${e.gutter}-${e.code}-${t}`))}),hK=({additions:e,deletions:t,fileCount:n})=>n===null?[{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}]:[{key:`files`,content:pK(`stats.fileCount`,{count:n}),className:`text-muted-foreground`},{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}],gK=({control:e,mode:t})=>typeof e==`function`?e(t):e??null,_K=e=>e.reduce((e,t)=>e+t.hunks.reduce((e,t)=>e+t.changes.length,0),0),vK=e=>Yy(e),yK=(e,t)=>{let n=`oldPath`in e&&typeof e.oldPath==`string`?t(e.oldPath):``,r=`newPath`in e&&typeof e.newPath==`string`?t(e.newPath):``;return[...new Set([r,n].filter(e=>e&&e!==`/dev/null`))]},bK=e=>e.subject_type===`file`,xK=e=>e.subject_type===`line`,SK=`border-sky-400/30 bg-sky-400/10 text-sky-100`,CK=({context:e,comment:t,reviewDraftInput:n,canEdit:r,autoFocus:i,isReadOnly:a,hasSavedComment:o,onReviewDraftInputChange:s,onCancelReviewDraft:c,onEditReviewDraft:l,onRemoveReviewDraft:u,onSaveReviewDraft:d})=>{let f=(0,Y.useRef)(null),[p,m]=(0,Y.useState)(()=>n),h=vK(e.change);return(0,Y.useEffect)(()=>{!i||a||f.current?.focus({preventScroll:!0})},[i,a]),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(U,{variant:`outline`,className:SK,children:pK(`reviewComment.manualBadge`)}),(0,Z.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-sky-100/80`,children:pK(o?`reviewComment.commentOnLine`:`reviewComment.addCommentToLine`,{lineNumber:h})})]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[a?(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap rounded-xl border border-sky-500/15 bg-background/70 px-3 py-2.5 text-xs text-foreground`,children:t}):(0,Z.jsx)(Ls,{ref:f,"aria-label":pK(`reviewComment.ariaLabel`,{filePath:e.filePath}),value:p,onChange:e=>{m(e.target.value),s(e.target.value)},disabled:!r,className:`min-h-20 text-xs`,placeholder:pK(`reviewComment.placeholder`)}),(0,Z.jsx)(`div`,{className:`flex gap-2`,children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(K,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{l(e.commentKey)},disabled:!r,children:[(0,Z.jsx)(wf,{className:`h-3.5 w-3.5`}),pK(`reviewComment.edit`)]}),(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{u(e.commentKey)},disabled:!r,children:pK(`reviewComment.remove`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{type:`button`,size:`xs`,onClick:()=>{d(e,p)},disabled:!r||!p.trim(),children:pK(`reviewComment.add`)}),(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`ghost`,onClick:c,children:pK(`reviewComment.cancel`)})]})})]})]})},wK=e=>e===`high`?`destructive`:e===`medium`?`warning`:`outline`,TK=e=>e.old_line_number!==null&&e.new_line_number!==null?pK(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?pK(`lineReference.unavailable`):pK(`lineReference.oldOnly`,{oldLine:e.old_line_number}):pK(`lineReference.newOnly`,{newLine:e.new_line_number}),EK=({finding:e,isSelected:t,onToggle:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,Z.jsxs)(`div`,{className:`rounded-xl border border-slate-400/30 bg-slate-400/10 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(Wd,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,Z.jsx)(`div`,{children:pK(`reviewFinding.title`,{ordinal:e.ordinal})}),(0,Z.jsx)(U,{variant:wK(e.severity),className:`normal-case`,children:e.severity})]}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]}),(0,Z.jsxs)(K,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,Z.jsx)(Ll,{className:`h-3.5 w-3.5`}),pK(t?`reviewFinding.selected`:`reviewFinding.fix`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:TK(e)}),e.file_path&&(0,Z.jsx)(`span`,{children:e.file_path})]}),(e.why_text||e.fix_text)&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{i(e=>!e)},children:pK(r?`reviewFinding.hideDetails`:`reviewFinding.details`)}),r&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-xl border border-border bg-background/60 p-3 text-xs text-foreground`,children:[e.why_text&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:pK(`reviewFinding.whyItMatters`)}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.why_text})]}),e.fix_text&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:pK(`reviewFinding.requestedFix`)}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.fix_text})]})]})]})]})},DK=e=>e.old_line_number!==null&&e.new_line_number!==null?pK(`lineReference.oldAndNew`,{oldLine:e.old_line_number,newLine:e.new_line_number}):e.new_line_number===null?e.old_line_number===null?pK(`lineReference.unavailable`):pK(`lineReference.oldOnly`,{oldLine:e.old_line_number}):pK(`lineReference.newOnly`,{newLine:e.new_line_number}),OK=e=>e.old_line_number!==null||e.new_line_number!==null,kK=e=>e.kind===`review`?pK(`githubComment.reviewSummary`):bK(e)?pK(`githubComment.fileComment`):OK(e)||xK(e)?pK(`githubComment.inlineComment`):pK(`githubComment.fileComment`),AK=({comment:e,isSelected:t,onToggle:n})=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-violet-400/30 bg-violet-400/10 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(U,{variant:`outline`,className:`border-violet-400/40 bg-violet-400/10 text-violet-100`,children:pK(`githubComment.badge`)}),(0,Z.jsx)(`span`,{children:kK(e)}),e.is_outdated&&(0,Z.jsx)(U,{variant:`warning`,className:`normal-case`,children:pK(`githubComment.outdated`)})]}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.author}),(0,Z.jsx)(GM,{content:e.body})]}),(0,Z.jsxs)(K,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,Z.jsx)(Ll,{className:`h-3.5 w-3.5`}),pK(t?`reviewFinding.selected`:`reviewFinding.fix`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[e.file_path&&(0,Z.jsx)(`span`,{children:e.file_path}),e.kind===`inline`&&!bK(e)&&OK(e)&&(0,Z.jsx)(`span`,{children:DK(e)}),(0,Z.jsx)(`span`,{children:new Date(e.updated_at).toLocaleString()}),(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-violet-200 underline underline-offset-2 transition-colors hover:text-violet-100`,children:pK(`githubComment.openOnGitHub`)})]})]}),jK=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,reviewFindings:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of yK(t,n))s.has(e)||s.set(e,t);for(let e of r){let n=e.file_path,r=n?s.get(n):null;if(!r||!n){o.push(e);continue}let c=t(r),l=null;for(let t of r.hunks){for(let n of t.changes)if(Zy(e,n)){l=sv(n);break}if(l)break}if(l){let t=i.get(c)??new Map,n=t.get(l)??[];t.set(l,[...n,e]),i.set(c,t);continue}a.set(c,[...a.get(c)??[],e])}return{inlineByFilePath:i,fileLevelByFilePath:a,globalFindings:o}},MK=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,githubComments:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of yK(t,n))s.has(e)||s.set(e,t);for(let e of r){if(e.kind===`review`||!e.file_path){o.push(e);continue}let n=s.get(e.file_path);if(!n){o.push(e);continue}let r=t(n);if(bK(e)||!e.subject_type&&!OK(e)){a.set(r,[...a.get(r)??[],e]);continue}let c=null;for(let t of n.hunks){for(let n of t.changes)if(Xy(e,n)){c=sv(n);break}if(c)break}if(!c){o.push(e);continue}let l=i.get(r)??new Map,u=l.get(c)??[];l.set(c,[...u,e]),i.set(r,l)}return{inlineByFilePath:i,fileLevelByFilePath:a,fallbackComments:o}},NK=({filePath:e,hunks:t,activeReviewTarget:n,editingReviewCommentKey:r,reviewDraftInstanceKey:i,reviewDraftInput:a,reviewComments:o,reviewFindingsByChangeKey:s,githubCommentsByChangeKey:c,selectedReviewFindingIds:l,selectedGitHubCommentIds:u,canEditActiveReviewDraft:d,onToggleReviewFindingSelection:f,onToggleGitHubCommentSelection:p,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v})=>{let y=new Map(o.map(e=>[sb(e.filePath,e.changeKey),e]));return t.reduce((t,o)=>{for(let b of o.changes){let x=sv(b),S=sb(e,x),C=n?.commentKey===S,w=y.get(S),T=r===S,E=s.get(x)??[],D=c.get(x)??[];if(!C&&!w&&E.length===0&&D.length===0)continue;let O={filePath:e,changeKey:x,commentKey:S,hunk:o,change:b},k=!!w&&!T&&!C,A=k?w?.comment??``:a;t[x]=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[E.map(e=>(0,Z.jsx)(EK,{finding:e,isSelected:l.includes(e.id),onToggle:()=>{f(e.id)}},e.id)),D.map(e=>(0,Z.jsx)(AK,{comment:e,isSelected:u.includes(e.id),onToggle:()=>{p(e.id)}},e.id)),(C||w)&&(0,Z.jsx)(CK,{context:O,comment:w?.comment??``,reviewDraftInput:A,canEdit:d,autoFocus:C||T,isReadOnly:k,hasSavedComment:!!w,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v},`${i??O.commentKey}:${k?`readonly`:`editable`}`)]})}return t},{})},PK=e=>e.reduce((e,t)=>{for(let n of t.changes)e.set(sv(n),{hunk:t,change:n});return e},new Map),FK=(0,Y.memo)(({selectedDiffPath:e,sidebarFiles:t,diffResponse:n,isDiffLoading:r,diffError:i,allDiffFiles:a,renderedFiles:o,viewType:s,onViewTypeChange:c,onRetry:l,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindings:h,githubComments:g,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canSelectReviewTarget:y,canEditActiveReviewDraft:b,reviewFindingsError:x,gitHubCommentsError:S,hasStaleReviewFindings:C,onSelectReviewTarget:w,onToggleReviewFindingSelection:T,onToggleGitHubCommentSelection:E,onReviewDraftInputChange:D,onCancelReviewDraft:O,onEditReviewDraft:k,onRemoveReviewDraft:A,onSaveReviewDraft:j,diffThemeClassName:M,resolveFilePath:N,normalizeDiffPath:P,emptyStateTitle:F=pK(`states.emptyTitle`),emptyStateDescription:I=null,filePickerControl:L,reviewSummaryControl:R,extraHeaderControl:z,headerLayout:B=`stacked`,surfaceVariant:ee=`default`,showViewTypeToggle:te=!0,gutterVariant:ne=`default`,isResizing:V=!1,resizePlaceholderLineThreshold:re=1/0,onVisibleFilePathsChange:H})=>{let ie=(0,Y.useRef)(null),{mode:ae,ref:oe}=Rp({compactAt:ee===`flat`?460:620,tightAt:ee===`flat`?360:500}),se=!!n?.diff?.trim()||o.length>0||(n?.files.length??0)>0,ce=(0,Y.useMemo)(()=>_K(o),[o]),le=e===`all`&&o.length>=uK,ue=V&&ce>re,de=(0,Y.useMemo)(()=>o.map(e=>N(e)).join(`
|
|
146
|
+
`),[o,N]),fe=lK({count:le?o.length:0,getScrollElement:()=>ie.current,estimateSize:()=>dK,overscan:fK,getItemKey:e=>{let t=o[e];return t?`${N(t)}:${t.type??`modify`}`:e},initialRect:{width:0,height:900}}),pe=(0,Y.useMemo)(()=>new Map(n?.files.map(e=>[e.path,e])??[]),[n?.files]),me=(0,Y.useMemo)(()=>jK({allDiffFiles:a,resolveFilePath:N,normalizeDiffPath:P,reviewFindings:C?[]:h}),[a,C,P,N,h]),he=(0,Y.useMemo)(()=>MK({allDiffFiles:a,resolveFilePath:N,normalizeDiffPath:P,githubComments:g}),[a,g,P,N]);(0,Y.useEffect)(()=>{let e=ie.current;e&&(e.scrollTop=0)},[e]),(0,Y.useEffect)(()=>{let e=ie.current;return()=>{window.getSelection()?.removeAllRanges(),e&&(e.scrollTop=0)}},[de]);let ge=fe.getVirtualItems(),W=(0,Y.useMemo)(()=>le?ge.map(e=>N(o[e.index])):o.map(e=>N(e)),[o,N,le,ge]);(0,Y.useEffect)(()=>{H?.(W)},[H,W]);let _e=le&&ge.length>0?ge[0]?.start??0:0,ve=le&&ge.length>0?Math.max(0,fe.getTotalSize()-(ge[ge.length-1]?.end??0)):0,ye=le?ge.map(e=>({file:o[e.index],virtualItem:e})):o.map(e=>({file:e,virtualItem:null})),be=e===`all`?null:t.find(t=>t.path===e)??null,xe=e===`all`?hK({additions:n?.stats?.additions??0,deletions:n?.stats?.deletions??0,fileCount:n?.stats?.files_changed??null}):be?hK({additions:be.additions,deletions:be.deletions,fileCount:null}):[],Se=(0,Y.useMemo)(()=>te?(0,Z.jsxs)(FG,{type:`single`,size:`sm`,variant:`outline`,value:s,onValueChange:e=>{(e===`split`||e===`unified`)&&c(e)},children:[(0,Z.jsx)(IG,{value:`unified`,children:pK(`viewType.unified`)}),(0,Z.jsx)(IG,{value:`split`,children:pK(`viewType.split`)})]}):null,[c,te,s]),Ce=(0,Y.useMemo)(()=>[gK({control:L,mode:ae}),gK({control:R,mode:ae})].filter(Boolean),[L,ae,R]),we=Se||Ce.length>0||z;return(0,Z.jsxs)(`section`,{className:G(`flex min-h-0 flex-1 flex-col overflow-hidden`,ee===`default`?`rounded-2xl border border-border bg-background/30`:`bg-transparent`),children:[(0,Z.jsx)(`div`,{ref:oe,"data-responsive-mode":ae,"data-testid":`ticket-diff-header`,className:G(`grid min-w-0 items-start gap-x-3 gap-y-2 border-b px-4 py-3`,ee===`default`?`border-border`:`border-border/70 px-3`,B===`stacked`?z?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`:we?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:B===`stacked`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-left`,className:`grid min-w-0 gap-2`,children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?pK(`header.allChanges`):e}),xe.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:xe.map(e=>(0,Z.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),Se||Ce.length>0?(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-controls`,className:`flex min-w-0 flex-wrap items-center gap-2 justify-start`,children:[Se?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:Se}):null,Ce.length>0?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 items-center gap-2 justify-start`,children:Ce.map((e,t)=>(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null]}):null]}),z?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:z}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?pK(`header.allChanges`):e}),xe.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:xe.map(e=>(0,Z.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),we?(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-inline-controls`,className:`flex min-w-0 flex-wrap items-start justify-end gap-2`,children:[Se?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:Se}):null,Ce.length>0?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:Ce.map((e,t)=>(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null,z?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:z}):null]}):null]})}),(0,Z.jsx)(`div`,{ref:ie,"data-testid":`ticket-diff-scroll-region`,className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsxs)(`div`,{className:G(`min-h-full pb-4 pt-4`,ee===`default`?`px-4`:`px-0`),children:[r&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:pK(`states.loading`)}),!r&&i&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-4 text-center`,children:[(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-rose-300`,children:i}),(0,Z.jsx)(K,{type:`button`,variant:`outline`,onClick:l,children:pK(`states.retry`)})]}),!r&&!i&&n&&!se&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-foreground`,children:F}),I&&(0,Z.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:I})]}),!r&&!i&&n&&se&&e!==`all`&&o.length===0&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-foreground`,children:pK(`states.noRenderableFileTitle`)}),(0,Z.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:e})]}),!r&&!i&&n&&se&&o.length>0&&ue&&(0,Z.jsx)(mK,{}),!r&&!i&&n&&se&&o.length>0&&!ue&&(0,Z.jsxs)(`div`,{className:G(`archon-diff-viewer`,ne===`compact`&&`archon-diff-viewer--compact-gutter`,e===`all`&&ee===`default`&&`space-y-6`,e===`all`&&ee===`flat`&&`space-y-0`,M),children:[x&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:x}),S&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:S}),me.globalFindings.length>0&&(0,Z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:pK(`reviewFinding.sectionTitle`)}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:me.globalFindings.map(e=>(0,Z.jsx)(EK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))})]}),e===`all`&&he.fallbackComments.length>0&&(0,Z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:pK(`githubComment.sectionTitle`)}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:he.fallbackComments.map(e=>(0,Z.jsx)(AK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))})]}),_e>0&&(0,Z.jsx)(`div`,{style:{height:_e}}),ye.map(({file:t,virtualItem:n})=>{let r=N(t),i=pe.get(r),a=PK(t.hunks),o=me.inlineByFilePath.get(r)??new Map,c=he.inlineByFilePath.get(r)??new Map,l=me.fileLevelByFilePath.get(r)??[],h=he.fileLevelByFilePath.get(r)??[],g=d?m.find(e=>sb(e.filePath,e.changeKey)===d)??null:null,x=[...m.filter(e=>e.filePath===r).map(e=>e.changeKey),...u?.filePath===r?[u.changeKey]:[],...g?.filePath===r?[g.changeKey]:[]],S=NK({filePath:r,hunks:t.hunks,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindingsByChangeKey:o,githubCommentsByChangeKey:c,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canEditActiveReviewDraft:b,onToggleReviewFindingSelection:T,onToggleGitHubCommentSelection:E,onReviewDraftInputChange:D,onCancelReviewDraft:O,onEditReviewDraft:k,onRemoveReviewDraft:A,onSaveReviewDraft:j}),C=(0,Z.jsx)(qv,{diffType:t.type,hunks:t.hunks,tokens:t.tokens,viewType:s,selectedChanges:[...new Set(x)],widgets:S,renderGutter:({change:e,side:t,renderDefault:n,wrapInAnchor:r,inHoverState:i})=>{if(!e)return r(n());let a=sv(e),o=t===`new`,c=y&&t===`new`,l=s===`unified`&&e.type===`normal`&&t===`new`?null:r(n());return(0,Z.jsxs)(`div`,{className:G(`flex items-center justify-end pr-1`,ne===`compact`?`gap-1 pr-0.5`:`gap-2`),children:[l,o&&(0,Z.jsx)(`span`,{"data-diff-gutter-action-slot":`true`,className:[ne===`compact`?`flex size-5 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`:`flex size-6 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`,c&&i?`border-emerald-200 bg-emerald-300 opacity-100`:`opacity-0`,!c&&`pointer-events-none`].join(` `),"aria-hidden":`true`,children:(0,Z.jsx)(Ll,{className:ne===`compact`?`h-3 w-3`:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:a})]})},gutterEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(sv(e));t&&w({filePath:r,changeKey:sv(e),commentKey:sb(r,sv(e)),hunk:t.hunk,change:t.change})}},codeEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(sv(e));t&&w({filePath:r,changeKey:sv(e),commentKey:sb(r,sv(e)),hunk:t.hunk,change:t.change})}},children:e=>e.map(e=>(0,Z.jsx)(Hv,{hunk:e},`${r}-${e.content}`))});return e===`all`?(0,Z.jsx)(`div`,{"data-index":n?.index,ref:n?fe.measureElement:void 0,children:(0,Z.jsxs)(`section`,{className:G(ee===`default`?`rounded-xl border border-border bg-card/70`:`border-t border-border/70 bg-transparent first:border-t-0`),children:[(0,Z.jsxs)(`div`,{className:G(`sticky top-0 z-20 border-b text-xs font-medium text-foreground`,ee===`default`?`rounded-t-xl border-border bg-card px-4 py-3`:`border-border/70 bg-background/95 px-3 py-2.5 backdrop-blur-sm`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[`oldPath`in t&&typeof t.oldPath==`string`&&P(t.oldPath)===`/dev/null`&&(0,Z.jsx)(U,{variant:`success`,className:`shrink-0`,children:pK(`fileBadge.newFile`)}),(0,Z.jsx)(`span`,{children:r})]}),i&&(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-emerald-400`,children:[`+`,i.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono text-rose-400`,children:[`-`,i.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:G(`overflow-x-auto`,ee===`default`?`p-3`:`px-0 py-3`),children:[l.length>0&&(0,Z.jsx)(`div`,{className:G(`mb-3 space-y-3`,ee===`flat`&&`px-3`),children:l.map(e=>(0,Z.jsx)(EK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))}),h.length>0&&(0,Z.jsx)(`div`,{className:G(`mb-3 space-y-3`,ee===`flat`&&`px-3`),children:h.map(e=>(0,Z.jsx)(AK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),C]})]})},`${r}-${t.type??`modify`}`):(0,Z.jsxs)(`div`,{"data-index":n?.index,ref:n?fe.measureElement:void 0,children:[l.length>0&&(0,Z.jsx)(`div`,{className:`mb-3 space-y-3`,children:l.map(e=>(0,Z.jsx)(EK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))}),h.length>0&&(0,Z.jsx)(`div`,{className:`mb-3 space-y-3`,children:h.map(e=>(0,Z.jsx)(AK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),C]},`${r}-${t.type??`modify`}`)}),ve>0&&(0,Z.jsx)(`div`,{style:{height:ve}})]})]})})]})});FK.displayName=`TicketChangesDiffPanel`;var IK=e=>G(`group`,e?`border-sky-700 bg-card/95 shadow-sm`:`border-border/50 bg-transparent text-muted-foreground hover:border-border/80 hover:bg-accent/60 hover:text-accent-foreground hover:shadow-sm`),LK={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},RK={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},zK=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},BK=({selectionWarning:e,gitError:t,sidebarFiles:n,commentCountByPath:r,commentCountTone:i,isGitStatusLoading:a,selectedPaths:o,selectedDiffPath:s,allFilesSelected:c,diffStats:l,title:u=`Changed files`,allChangesDescription:d=`Review the full workspace diff.`,enableSelection:f=!0,onToggleSelectAll:p,onSelectDiffPath:m,onTogglePath:h})=>{let g=i===`bundle_diff`?`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`;return(0,Z.jsxs)(`aside`,{className:`flex min-h-0 h-full flex-col between overflow-hidden rounded-2xl border border-border bg-background/40`,children:[(e||t)&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-border p-4`,children:[e&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:e}),t&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:u}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.length,` file`,n.length===1?``:`s`,` changed`]})]}),f&&(0,Z.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:n.length===0,children:c?`Unselect all`:`Select all`})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[a&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading file list...`}),!a&&n.length===0&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`No changes to review.`}),!a&&n.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{m(`all`)},className:G(`flex w-full cursor-pointer items-start justify-between gap-3 rounded-xl border px-2.5 py-2 text-left transition-colors`,IK(s===`all`)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`All changes`}),l&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[l.files_changed,` file`,l.files_changed===1?``:`s`]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,l.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,l.deletions]})]})]}),(0,Z.jsx)(`div`,{className:`mt-1 flex w-full flex-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:d})]})}),n.map(e=>{let t=f&&o.has(e.path),n=s===e.path,i=r.get(e.path)??0;return(0,Z.jsxs)(`div`,{className:G(`relative flex cursor-pointer items-start gap-2.5 rounded-xl border px-2.5 py-2 transition-colors`,IK(n)),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Open diff for ${e.path}`,onClick:()=>{m(e.path)},className:`absolute inset-0 cursor-pointer rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`}),f&&(0,Z.jsx)(`input`,{type:`checkbox`,"aria-label":e.path,checked:t,onChange:()=>{h(e.path)},className:`relative z-10 mt-0.5 h-4 w-4 rounded border-border bg-background text-primary`}),(0,Z.jsxs)(`div`,{className:`relative z-10 min-w-0 flex-1 cursor-pointer text-left pointer-events-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-1 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:zK(e.path)}),i>0&&(0,Z.jsx)(`span`,{"aria-label":`${i} comment${i===1?``:`s`} in ${e.path}`,className:g,children:i})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,e.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,e.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[e.status&&(0,Z.jsx)(U,{variant:`outline`,className:LK[e.status],children:RK[e.status]}),e.staged&&(0,Z.jsx)(U,{variant:`outline`,children:`Staged`}),e.unstaged&&(0,Z.jsx)(U,{variant:`outline`,children:`Unstaged`}),e.conflicted&&(0,Z.jsx)(U,{variant:`destructive`,children:`Conflicted`}),e.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:e.status===`renamed`?`from ${e.originalPath}`:e.originalPath})]})]})]},`${e.path}:${e.originalPath??``}`)})]})]})]})},VK=[`[--diff-background-color:transparent]`,`[--diff-text-color:rgb(226_232_240)]`,`[--diff-selection-background-color:rgba(148,163,184,0.2)]`,`[--diff-gutter-insert-background-color:rgba(34,197,94,0.16)]`,`[--diff-gutter-delete-background-color:rgba(244,63,94,0.16)]`,`[--diff-gutter-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-code-insert-background-color:rgba(34,197,94,0.08)]`,`[--diff-code-delete-background-color:rgba(244,63,94,0.08)]`,`[--diff-code-insert-edit-background-color:rgba(34,197,94,0.22)]`,`[--diff-code-delete-edit-background-color:rgba(244,63,94,0.22)]`,`[--diff-code-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-font-family:var(--font-mono)]`,`[&_.diff]:w-full`,`[&_.diff]:border-collapse`,`[&_.diff]:font-mono`,`[&_.diff-code]:whitespace-pre-wrap`,`[&_.diff-code]:break-words`,`[&_.diff-gutter]:select-none`].join(` `),HK=25e4,UK=2e3,WK=new Map,GK=e=>e?e.split(`
|
|
147
|
+
`).length:0,KK=e=>{let t=e.diff??``;return t?t.length<=HK&&GK(t)<=UK:!0},qK=({scope:e,projectId:t,ticketId:n})=>e===`project_root`?t?`project_root:${t}`:null:n?`ticket:${t??`none`}:${n}`:null,JK=e=>e?WK.get(e)??null:null,YK=({cacheKey:e,diffResponse:t,gitStatus:n})=>{let r=n.workspace_signature?.trim();if(!(!e||!r)){if(!KK(t)){WK.delete(e);return}WK.set(e,{diffResponse:t,gitStatus:n,workspaceSignature:r})}},XK=e=>{e&&WK.delete(e)},ZK={css:`css`,html:`markup`,htm:`markup`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,markdown:`markdown`,sh:`bash`,ts:`typescript`,tsx:`tsx`,yaml:`yaml`,yml:`yaml`},QK=e=>{if(!e)return null;let t=e.split(` -> `),n=t[t.length-1]??e,r=n.split(`/`),i=r[r.length-1]??n,a=``;if(i.includes(`.`)){let e=i.split(`.`);a=e[e.length-1]?.toLowerCase()??``}return ZK[a]??null},$K=new Set,eq=e=>{e&&$K.forEach(t=>t(e))},tq=e=>($K.add(e),()=>{$K.delete(e)}),nq=300,rq=(e,t={})=>{let n=t.dedupeMs??nq,r=0,i=()=>{if(document.visibilityState!==`visible`)return;let t=Date.now();t-r<n||(r=t,e())};return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,i)}},iq=i(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),aq=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.normal={},n.property={};function r(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}})),oq=i(((e,t)=>{var n=iq(),r=aq();t.exports=i;function i(e){for(var t=e.length,i=[],a=[],o=-1,s,c;++o<t;)s=e[o],i.push(s.property),a.push(s.normal),c=s.space;return new r(n.apply(null,i),n.apply(null,a),c)}})),sq=i(((e,t)=>{t.exports=n;function n(e){return e.toLowerCase()}})),cq=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.attribute=null,n.property=null,n.boolean=!1,n.booleanish=!1,n.overloadedBoolean=!1,n.number=!1,n.commaSeparated=!1,n.spaceSeparated=!1,n.commaOrSpaceSeparated=!1,n.mustUseProperty=!1,n.defined=!1;function r(e,t){this.property=e,this.attribute=t}})),lq=i((e=>{var t=0;e.boolean=n(),e.booleanish=n(),e.overloadedBoolean=n(),e.number=n(),e.spaceSeparated=n(),e.commaSeparated=n(),e.commaOrSpaceSeparated=n();function n(){return 2**++t}})),uq=i(((e,t)=>{var n=cq(),r=lq();t.exports=o,o.prototype=new n,o.prototype.defined=!0;var i=[`boolean`,`booleanish`,`overloadedBoolean`,`number`,`commaSeparated`,`spaceSeparated`,`commaOrSpaceSeparated`],a=i.length;function o(e,t,o,c){var l=-1,u;for(s(this,`space`,c),n.call(this,e,t);++l<a;)u=i[l],s(this,u,(o&r[u])===r[u])}function s(e,t,n){n&&(e[t]=n)}})),dq=i(((e,t)=>{var n=sq(),r=aq(),i=uq();t.exports=a;function a(e){var t=e.space,a=e.mustUseProperty||[],o=e.attributes||{},s=e.properties,c=e.transform,l={},u={},d,f;for(d in s)f=new i(d,c(o,d),s[d],t),a.indexOf(d)!==-1&&(f.mustUseProperty=!0),l[d]=f,u[n(d)]=d,u[n(f.attribute)]=d;return new r(l,u,t)}})),fq=i(((e,t)=>{t.exports=dq()({space:`xlink`,transform:n,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function n(e,t){return`xlink:`+t.slice(5).toLowerCase()}})),pq=i(((e,t)=>{t.exports=dq()({space:`xml`,transform:n,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function n(e,t){return`xml:`+t.slice(3).toLowerCase()}})),mq=i(((e,t)=>{t.exports=n;function n(e,t){return t in e?e[t]:t}})),hq=i(((e,t)=>{var n=mq();t.exports=r;function r(e,t){return n(e,t.toLowerCase())}})),gq=i(((e,t)=>{t.exports=dq()({space:`xmlns`,attributes:{xmlnsxlink:`xmlns:xlink`},transform:hq(),properties:{xmlns:null,xmlnsXLink:null}})})),_q=i(((e,t)=>{var n=lq(),r=dq(),i=n.booleanish,a=n.number,o=n.spaceSeparated;t.exports=r({transform:s,properties:{ariaActiveDescendant:null,ariaAtomic:i,ariaAutoComplete:null,ariaBusy:i,ariaChecked:i,ariaColCount:a,ariaColIndex:a,ariaColSpan:a,ariaControls:o,ariaCurrent:null,ariaDescribedBy:o,ariaDetails:null,ariaDisabled:i,ariaDropEffect:o,ariaErrorMessage:null,ariaExpanded:i,ariaFlowTo:o,ariaGrabbed:i,ariaHasPopup:null,ariaHidden:i,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:o,ariaLevel:a,ariaLive:null,ariaModal:i,ariaMultiLine:i,ariaMultiSelectable:i,ariaOrientation:null,ariaOwns:o,ariaPlaceholder:null,ariaPosInSet:a,ariaPressed:i,ariaReadOnly:i,ariaRelevant:null,ariaRequired:i,ariaRoleDescription:o,ariaRowCount:a,ariaRowIndex:a,ariaRowSpan:a,ariaSelected:i,ariaSetSize:a,ariaSort:null,ariaValueMax:a,ariaValueMin:a,ariaValueNow:a,ariaValueText:null,role:null}});function s(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}})),vq=i(((e,t)=>{var n=lq(),r=dq(),i=hq(),a=n.boolean,o=n.overloadedBoolean,s=n.booleanish,c=n.number,l=n.spaceSeparated,u=n.commaSeparated;t.exports=r({space:`html`,attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},transform:i,mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:u,acceptCharset:l,accessKey:l,action:null,allow:null,allowFullScreen:a,allowPaymentRequest:a,allowUserMedia:a,alt:null,as:null,async:a,autoCapitalize:null,autoComplete:l,autoFocus:a,autoPlay:a,capture:a,charSet:null,checked:a,cite:null,className:l,cols:c,colSpan:null,content:null,contentEditable:s,controls:a,controlsList:l,coords:c|u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:a,defer:a,dir:null,dirName:null,disabled:a,download:o,draggable:s,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:a,formTarget:null,headers:l,height:c,hidden:a,high:c,href:null,hrefLang:null,htmlFor:l,httpEquiv:l,id:null,imageSizes:null,imageSrcSet:u,inputMode:null,integrity:null,is:null,isMap:a,itemId:null,itemProp:l,itemRef:l,itemScope:a,itemType:l,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:a,low:c,manifest:null,max:null,maxLength:c,media:null,method:null,min:null,minLength:c,multiple:a,muted:a,name:null,nonce:null,noModule:a,noValidate:a,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:a,optimum:c,pattern:null,ping:l,placeholder:null,playsInline:a,poster:null,preload:null,readOnly:a,referrerPolicy:null,rel:l,required:a,reversed:a,rows:c,rowSpan:c,sandbox:l,scope:null,scoped:a,seamless:a,selected:a,shape:null,size:c,sizes:null,slot:null,span:c,spellCheck:s,src:null,srcDoc:null,srcLang:null,srcSet:u,start:c,step:null,style:null,tabIndex:c,target:null,title:null,translate:null,type:null,typeMustMatch:a,useMap:null,value:s,width:c,wrap:null,align:null,aLink:null,archive:l,axis:null,background:null,bgColor:null,border:c,borderColor:null,bottomMargin:c,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:a,declare:a,event:null,face:null,frame:null,frameBorder:null,hSpace:c,leftMargin:c,link:null,longDesc:null,lowSrc:null,marginHeight:c,marginWidth:c,noResize:a,noHref:a,noShade:a,noWrap:a,object:null,profile:null,prompt:null,rev:null,rightMargin:c,rules:null,scheme:null,scrolling:s,standby:null,summary:null,text:null,topMargin:c,valueType:null,version:null,vAlign:null,vLink:null,vSpace:c,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:a,disableRemotePlayback:a,prefix:null,property:null,results:c,security:null,unselectable:null}})})),yq=i(((e,t)=>{var n=oq(),r=fq();t.exports=n([pq(),r,gq(),_q(),vq()])})),bq=i(((e,t)=>{var n=sq(),r=uq(),i=cq(),a=`data`;t.exports=l;var o=/^data[-\w.:]+$/i,s=/-[a-z]/g,c=/[A-Z]/g;function l(e,t){var s=n(t),c=t,l=i;return s in e.normal?e.property[e.normal[s]]:(s.length>4&&s.slice(0,4)===a&&o.test(t)&&(t.charAt(4)===`-`?c=u(t):t=d(t),l=r),new l(c,t))}function u(e){var t=e.slice(5).replace(s,p);return a+t.charAt(0).toUpperCase()+t.slice(1)}function d(e){var t=e.slice(4);return s.test(t)?e:(t=t.replace(c,f),t.charAt(0)!==`-`&&(t=`-`+t),a+t)}function f(e){return`-`+e.toLowerCase()}function p(e){return e.charAt(1).toUpperCase()}})),xq=i(((e,t)=>{t.exports=r;var n=/[#.]/g;function r(e,t){for(var r=e||``,i=t||`div`,a={},o=0,s,c,l;o<r.length;)n.lastIndex=o,l=n.exec(r),s=r.slice(o,l?l.index:r.length),s&&(c?c===`#`?a.id=s:a.className?a.className.push(s):a.className=[s]:i=s,o+=s.length),l&&(c=l[0],o++);return{type:`element`,tagName:i,properties:a,children:[]}}})),Sq=i((e=>{e.parse=i,e.stringify=a;var t=``,n=` `,r=/[ \t\n\r\f]+/g;function i(e){var n=String(e||t).trim();return n===t?[]:n.split(r)}function a(e){return e.join(n).trim()}})),Cq=i((e=>{e.parse=i,e.stringify=a;var t=`,`,n=` `,r=``;function i(e){for(var n=[],i=String(e||r),a=i.indexOf(t),o=0,s=!1,c;!s;)a===-1&&(a=i.length,s=!0),c=i.slice(o,a).trim(),(c||!s)&&n.push(c),o=a+1,a=i.indexOf(t,o);return n}function a(e,i){var a=i||{},o=a.padLeft===!1?r:n,s=a.padRight?n:r;return e[e.length-1]===r&&(e=e.concat(r)),e.join(s+t+o).trim()}})),wq=i(((e,t)=>{var n=bq(),r=sq(),i=xq(),a=Sq().parse,o=Cq().parse;t.exports=c;var s={}.hasOwnProperty;function c(e,t,r){var c=r?h(r):null;return u;function u(e,n){var r=i(e,t),a=Array.prototype.slice.call(arguments,2),o=r.tagName.toLowerCase(),u;if(r.tagName=c&&s.call(c,o)?c[o]:o,n&&l(n,r)&&(a.unshift(n),n=null),n)for(u in n)p(r.properties,u,n[u]);return d(r.children,a),r.tagName===`template`&&(r.content={type:`root`,children:r.children},r.children=[]),r}function p(t,r,i){var s,c,l;i==null||i!==i||(s=n(e,r),c=s.property,l=i,typeof l==`string`&&(s.spaceSeparated?l=a(l):s.commaSeparated?l=o(l):s.commaOrSpaceSeparated&&(l=a(o(l).join(` `)))),c===`style`&&typeof i!=`string`&&(l=m(l)),c===`className`&&t.className&&(l=t.className.concat(l)),t[c]=f(s,c,l))}}function l(e,t){return typeof e==`string`||`length`in e||u(t.tagName,e)}function u(e,t){var n=t.type;return e===`input`||!n||typeof n!=`string`?!1:typeof t.children==`object`&&`length`in t.children?!0:(n=n.toLowerCase(),e===`button`?n!==`menu`&&n!==`submit`&&n!==`reset`&&n!==`button`:`value`in t)}function d(e,t){var n,r;if(typeof t==`string`||typeof t==`number`){e.push({type:`text`,value:String(t)});return}if(typeof t==`object`&&`length`in t){for(n=-1,r=t.length;++n<r;)d(e,t[n]);return}if(typeof t!=`object`||!(`type`in t))throw Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function f(e,t,n){var r,i,a;if(typeof n!=`object`||!(`length`in n))return p(e,t,n);for(i=n.length,r=-1,a=[];++r<i;)a[r]=p(e,t,n[r]);return a}function p(e,t,n){var i=n;return e.number||e.positiveNumber?!isNaN(i)&&i!==``&&(i=Number(i)):(e.boolean||e.overloadedBoolean)&&typeof i==`string`&&(i===``||r(n)===r(t))&&(i=!0),i}function m(e){var t=[],n;for(n in e)t.push([n,e[n]].join(`: `));return t.join(`; `)}function h(e){for(var t=e.length,n=-1,r={},i;++n<t;)i=e[n],r[i.toLowerCase()]=i;return r}})),Tq=i(((e,t)=>{var n=yq(),r=wq()(n,`div`);r.displayName=`html`,t.exports=r})),Eq=i(((e,t)=>{t.exports=Tq()})),Dq=r({AElig:()=>`Æ`,AMP:()=>`&`,Aacute:()=>`Á`,Acirc:()=>`Â`,Agrave:()=>`À`,Aring:()=>`Å`,Atilde:()=>`Ã`,Auml:()=>`Ä`,COPY:()=>`©`,Ccedil:()=>`Ç`,ETH:()=>`Ð`,Eacute:()=>`É`,Ecirc:()=>`Ê`,Egrave:()=>`È`,Euml:()=>`Ë`,GT:()=>`>`,Iacute:()=>`Í`,Icirc:()=>`Î`,Igrave:()=>`Ì`,Iuml:()=>`Ï`,LT:()=>`<`,Ntilde:()=>`Ñ`,Oacute:()=>`Ó`,Ocirc:()=>`Ô`,Ograve:()=>`Ò`,Oslash:()=>`Ø`,Otilde:()=>`Õ`,Ouml:()=>`Ö`,QUOT:()=>`"`,REG:()=>`®`,THORN:()=>`Þ`,Uacute:()=>`Ú`,Ucirc:()=>`Û`,Ugrave:()=>`Ù`,Uuml:()=>`Ü`,Yacute:()=>`Ý`,aacute:()=>`á`,acirc:()=>`â`,acute:()=>`´`,aelig:()=>`æ`,agrave:()=>`à`,amp:()=>`&`,aring:()=>`å`,atilde:()=>`ã`,auml:()=>`ä`,brvbar:()=>`¦`,ccedil:()=>`ç`,cedil:()=>`¸`,cent:()=>`¢`,copy:()=>`©`,curren:()=>`¤`,default:()=>Oq,deg:()=>`°`,divide:()=>`÷`,eacute:()=>`é`,ecirc:()=>`ê`,egrave:()=>`è`,eth:()=>`ð`,euml:()=>`ë`,frac12:()=>`½`,frac14:()=>`¼`,frac34:()=>`¾`,gt:()=>`>`,iacute:()=>`í`,icirc:()=>`î`,iexcl:()=>`¡`,igrave:()=>`ì`,iquest:()=>`¿`,iuml:()=>`ï`,laquo:()=>`«`,lt:()=>`<`,macr:()=>`¯`,micro:()=>`µ`,middot:()=>`·`,nbsp:()=>`\xA0`,not:()=>`¬`,ntilde:()=>`ñ`,oacute:()=>`ó`,ocirc:()=>`ô`,ograve:()=>`ò`,ordf:()=>`ª`,ordm:()=>`º`,oslash:()=>`ø`,otilde:()=>`õ`,ouml:()=>`ö`,para:()=>`¶`,plusmn:()=>`±`,pound:()=>`£`,quot:()=>`"`,raquo:()=>`»`,reg:()=>`®`,sect:()=>`§`,shy:()=>``,sup1:()=>`¹`,sup2:()=>`²`,sup3:()=>`³`,szlig:()=>`ß`,thorn:()=>`þ`,times:()=>`×`,uacute:()=>`ú`,ucirc:()=>`û`,ugrave:()=>`ù`,uml:()=>`¨`,uuml:()=>`ü`,yacute:()=>`ý`,yen:()=>`¥`,yuml:()=>`ÿ`}),Oq,kq=n((()=>{Oq={AElig:`Æ`,AMP:`&`,Aacute:`Á`,Acirc:`Â`,Agrave:`À`,Aring:`Å`,Atilde:`Ã`,Auml:`Ä`,COPY:`©`,Ccedil:`Ç`,ETH:`Ð`,Eacute:`É`,Ecirc:`Ê`,Egrave:`È`,Euml:`Ë`,GT:`>`,Iacute:`Í`,Icirc:`Î`,Igrave:`Ì`,Iuml:`Ï`,LT:`<`,Ntilde:`Ñ`,Oacute:`Ó`,Ocirc:`Ô`,Ograve:`Ò`,Oslash:`Ø`,Otilde:`Õ`,Ouml:`Ö`,QUOT:`"`,REG:`®`,THORN:`Þ`,Uacute:`Ú`,Ucirc:`Û`,Ugrave:`Ù`,Uuml:`Ü`,Yacute:`Ý`,aacute:`á`,acirc:`â`,acute:`´`,aelig:`æ`,agrave:`à`,amp:`&`,aring:`å`,atilde:`ã`,auml:`ä`,brvbar:`¦`,ccedil:`ç`,cedil:`¸`,cent:`¢`,copy:`©`,curren:`¤`,deg:`°`,divide:`÷`,eacute:`é`,ecirc:`ê`,egrave:`è`,eth:`ð`,euml:`ë`,frac12:`½`,frac14:`¼`,frac34:`¾`,gt:`>`,iacute:`í`,icirc:`î`,iexcl:`¡`,igrave:`ì`,iquest:`¿`,iuml:`ï`,laquo:`«`,lt:`<`,macr:`¯`,micro:`µ`,middot:`·`,nbsp:`\xA0`,not:`¬`,ntilde:`ñ`,oacute:`ó`,ocirc:`ô`,ograve:`ò`,ordf:`ª`,ordm:`º`,oslash:`ø`,otilde:`õ`,ouml:`ö`,para:`¶`,plusmn:`±`,pound:`£`,quot:`"`,raquo:`»`,reg:`®`,sect:`§`,shy:``,sup1:`¹`,sup2:`²`,sup3:`³`,szlig:`ß`,thorn:`þ`,times:`×`,uacute:`ú`,ucirc:`û`,ugrave:`ù`,uml:`¨`,uuml:`ü`,yacute:`ý`,yen:`¥`,yuml:`ÿ`}})),Aq=r({default:()=>jq}),jq,Mq=n((()=>{jq={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`}})),Nq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}})),Pq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}})),Fq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}})),Iq=i(((e,t)=>{var n=Fq(),r=Nq();t.exports=i;function i(e){return n(e)||r(e)}})),Lq=i(((e,t)=>{var n,r=59;t.exports=i;function i(e){var t=`&`+e+`;`,i;return n||=document.createElement(`i`),n.innerHTML=t,i=n.textContent,i.charCodeAt(i.length-1)===r&&e!==`semi`||i===t?!1:i}})),Rq=i(((e,n)=>{var r=(kq(),t(Dq).default),i=(Mq(),t(Aq).default),a=Nq(),o=Pq(),s=Iq(),c=Lq();n.exports=R;var l={}.hasOwnProperty,u=String.fromCharCode,d=Function.prototype,f={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},p=9,m=10,h=12,g=32,_=38,v=59,y=60,b=61,x=35,S=88,C=120,w=65533,T=`named`,E=`hexadecimal`,D=`decimal`,O={};O[E]=16,O[D]=10;var k={};k[T]=s,k[D]=a,k[E]=o;var A=1,j=2,M=3,N=4,P=5,F=6,I=7,L={};L[A]=`Named character references must be terminated by a semicolon`,L[j]=`Numeric character references must be terminated by a semicolon`,L[M]=`Named character references cannot be empty`,L[N]=`Numeric character references cannot be empty`,L[P]=`Named character references must be known`,L[F]=`Numeric character references cannot be disallowed`,L[I]=`Numeric character references cannot be outside the permissible Unicode range`;function R(e,t){var n={},r,i;for(i in t||={},f)r=t[i],n[i]=r??f[i];return(n.position.indent||n.position.start)&&(n.indent=n.position.indent||[],n.position=n.position.start),z(e,n)}function z(e,t){var n=t.additional,a=t.nonTerminated,o=t.text,f=t.reference,R=t.warning,z=t.textContext,te=t.referenceContext,ne=t.warningContext,V=t.position,re=t.indent||[],H=e.length,ie=0,ae=-1,oe=V.column||1,se=V.line||1,ce=``,le=[],U,ue,de,fe,pe,me,he,ge,W,_e,ve,ye,be,G,xe,Se,Ce,we,Te;for(typeof n==`string`&&(n=n.charCodeAt(0)),Se=Ee(),ge=R?De:d,ie--,H++;++ie<H;)if(pe===m&&(oe=re[ae]||1),pe=e.charCodeAt(ie),pe===_){if(he=e.charCodeAt(ie+1),he===p||he===m||he===h||he===g||he===_||he===y||he!==he||n&&he===n){ce+=u(pe),oe++;continue}for(be=ie+1,ye=be,Te=be,he===x?(Te=++ye,he=e.charCodeAt(Te),he===S||he===C?(G=E,Te=++ye):G=D):G=T,U=``,ve=``,fe=``,xe=k[G],Te--;++Te<H&&(he=e.charCodeAt(Te),xe(he));)fe+=u(he),G===T&&l.call(r,fe)&&(U=fe,ve=r[fe]);de=e.charCodeAt(Te)===v,de&&(Te++,ue=G===T?c(fe):!1,ue&&(U=fe,ve=ue)),we=1+Te-be,!de&&!a||(fe?G===T?(de&&!ve?ge(P,1):(U!==fe&&(Te=ye+U.length,we=1+Te-ye,de=!1),de||(W=U?A:M,t.attribute?(he=e.charCodeAt(Te),he===b?(ge(W,we),ve=null):s(he)?ve=null:ge(W,we)):ge(W,we))),me=ve):(de||ge(j,we),me=parseInt(fe,O[G]),B(me)?(ge(I,we),me=u(w)):me in i?(ge(F,we),me=i[me]):(_e=``,ee(me)&&ge(F,we),me>65535&&(me-=65536,_e+=u(me>>>10|55296),me=56320|me&1023),me=_e+u(me))):G!==T&&ge(N,we)),me?(Oe(),Se=Ee(),ie=Te-1,oe+=Te-be+1,le.push(me),Ce=Ee(),Ce.offset++,f&&f.call(te,me,{start:Se,end:Ce},e.slice(be-1,Te)),Se=Ce):(fe=e.slice(be-1,Te),ce+=fe,oe+=fe.length,ie=Te-1)}else pe===10&&(se++,ae++,oe=0),pe===pe?(ce+=u(pe),oe++):Oe();return le.join(``);function Ee(){return{line:se,column:oe,offset:ie+(V.offset||0)}}function De(e,t){var n=Ee();n.column+=t,n.offset+=t,R.call(ne,L[e],n,e)}function Oe(){ce&&=(le.push(ce),o&&o.call(z,ce,{start:Se,end:Ee()}),``)}}function B(e){return e>=55296&&e<=57343||e>1114111}function ee(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}})),zq=i(((e,t)=>{var n=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,r={},i={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof a?new a(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,`&`).replace(/</g,`<`).replace(/\u00a0/g,` `)},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,`__id`,{value:++n}),e.__id},clone:function e(t,n){n||={};var r,a;switch(i.util.type(t)){case`Object`:if(a=i.util.objId(t),n[a])return n[a];for(var o in r={},n[a]=r,t)t.hasOwnProperty(o)&&(r[o]=e(t[o],n));return r;case`Array`:return a=i.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return`none`},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,`gi`),``),e.classList.add(`language-`+n)},currentScript:function(){if(typeof document>`u`)return null;if(`currentScript`in document)return document.currentScript;try{throw Error()}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var t=document.getElementsByTagName(`script`);for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var r=`no-`+t;e;){var i=e.classList;if(i.contains(t))return!0;if(i.contains(r))return!1;e=e.parentElement}return!!n}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,t){var n=i.util.clone(i.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=i.languages;var a=r[e],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==t)for(var c in n)n.hasOwnProperty(c)&&(o[c]=n[c]);n.hasOwnProperty(s)||(o[s]=a[s])}var l=r[e];return r[e]=o,i.languages.DFS(i.languages,function(t,n){n===l&&t!=e&&(this[t]=o)}),o},DFS:function e(t,n,r,a){a||={};var o=i.util.objId;for(var s in t)if(t.hasOwnProperty(s)){n.call(t,s,t[s],r||s);var c=t[s],l=i.util.type(c);l===`Object`&&!a[o(c)]?(a[o(c)]=!0,e(c,n,null,a)):l===`Array`&&!a[o(c)]&&(a[o(c)]=!0,e(c,n,s,a))}}},plugins:{},highlightAll:function(e,t){i.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var r={callback:n,container:e,selector:`code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code`};i.hooks.run(`before-highlightall`,r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),i.hooks.run(`before-all-elements-highlight`,r);for(var a=0,o;o=r.elements[a++];)i.highlightElement(o,t===!0,r.callback)},highlightElement:function(t,n,r){var a=i.util.getLanguage(t),o=i.languages[a];i.util.setLanguage(t,a);var s=t.parentElement;s&&s.nodeName.toLowerCase()===`pre`&&i.util.setLanguage(s,a);var c={element:t,language:a,grammar:o,code:t.textContent};function l(e){c.highlightedCode=e,i.hooks.run(`before-insert`,c),c.element.innerHTML=c.highlightedCode,i.hooks.run(`after-highlight`,c),i.hooks.run(`complete`,c),r&&r.call(c.element)}if(i.hooks.run(`before-sanity-check`,c),s=c.element.parentElement,s&&s.nodeName.toLowerCase()===`pre`&&!s.hasAttribute(`tabindex`)&&s.setAttribute(`tabindex`,`0`),!c.code){i.hooks.run(`complete`,c),r&&r.call(c.element);return}if(i.hooks.run(`before-highlight`,c),!c.grammar){l(i.util.encode(c.code));return}if(n&&e.Worker){var u=new Worker(i.filename);u.onmessage=function(e){l(e.data)},u.postMessage(JSON.stringify({language:c.language,code:c.code,immediateClose:!0}))}else l(i.highlight(c.code,c.grammar,c.language))},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(i.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=i.tokenize(r.code,r.grammar),i.hooks.run(`after-tokenize`,r),a.stringify(i.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new c;return l(i,i.head,e),s(e,i,t,i.head,0),d(i)},hooks:{all:{},add:function(e,t){var n=i.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=i.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:a};e.Prism=i;function a(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}a.stringify=function e(t,n){if(typeof t==`string`)return t;if(Array.isArray(t)){var r=``;return t.forEach(function(t){r+=e(t,n)}),r}var a={type:t.type,content:e(t.content,n),tag:`span`,classes:[`token`,t.type],attributes:{},language:n},o=t.alias;o&&(Array.isArray(o)?Array.prototype.push.apply(a.classes,o):a.classes.push(o)),i.hooks.run(`wrap`,a);var s=``;for(var c in a.attributes)s+=` `+c+`="`+(a.attributes[c]||``).replace(/"/g,`"`)+`"`;return`<`+a.tag+` class="`+a.classes.join(` `)+`"`+s+`>`+a.content+`</`+a.tag+`>`};function o(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function s(e,t,n,r,c,d){for(var f in n)if(!(!n.hasOwnProperty(f)||!n[f])){var p=n[f];p=Array.isArray(p)?p:[p];for(var m=0;m<p.length;++m){if(d&&d.cause==f+`,`+m)return;var h=p[m],g=h.inside,_=!!h.lookbehind,v=!!h.greedy,y=h.alias;if(v&&!h.pattern.global){var b=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,b+`g`)}for(var x=h.pattern||h,S=r.next,C=c;S!==t.tail&&!(d&&C>=d.reach);C+=S.value.length,S=S.next){var w=S.value;if(t.length>e.length)return;if(!(w instanceof a)){var T=1,E;if(v){if(E=o(x,C,e,_),!E||E.index>=e.length)break;var D=E.index,O=E.index+E[0].length,k=C;for(k+=S.value.length;D>=k;)S=S.next,k+=S.value.length;if(k-=S.value.length,C=k,S.value instanceof a)continue;for(var A=S;A!==t.tail&&(k<O||typeof A.value==`string`);A=A.next)T++,k+=A.value.length;T--,w=e.slice(C,k),E.index-=C}else if(E=o(x,0,w,_),!E)continue;var D=E.index,j=E[0],M=w.slice(0,D),N=w.slice(D+j.length),P=C+w.length;d&&P>d.reach&&(d.reach=P);var F=S.prev;M&&(F=l(t,F,M),C+=M.length),u(t,F,T);var I=new a(f,g?i.tokenize(j,g):j,y,j);if(S=l(t,F,I),N&&l(t,S,N),T>1){var L={cause:f+`,`+m,reach:P};s(e,t,n,S.prev,C,L),d&&L.reach>d.reach&&(d.reach=L.reach)}}}}}}function c(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function l(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function u(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function d(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}if(!e.document)return e.addEventListener&&(i.disableWorkerMessageHandler||e.addEventListener(`message`,function(t){var n=JSON.parse(t.data),r=n.language,a=n.code,o=n.immediateClose;e.postMessage(i.highlight(a,i.languages[r],r)),o&&e.close()},!1)),i;var f=i.util.currentScript();f&&(i.filename=f.src,f.hasAttribute(`data-manual`)&&(i.manual=!0));function p(){i.manual||i.highlightAll()}if(!i.manual){var m=document.readyState;m===`loading`||m===`interactive`&&f&&f.defer?document.addEventListener(`DOMContentLoaded`,p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return i}(typeof window<`u`?window:typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope?self:{});t!==void 0&&t.exports&&(t.exports=n),typeof global<`u`&&(global.Prism=n)})),Bq=i(((e,t)=>{t.exports=n,n.displayName=`markup`,n.aliases=[`html`,`mathml`,`svg`,`xml`,`ssml`,`atom`,`rss`];function n(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&/,`&`))}),Object.defineProperty(e.languages.markup.tag,`addInlined`,{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,`addAttribute`,{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}})),Vq=i(((e,t)=>{t.exports=n,n.displayName=`css`,n.aliases=[];function n(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}})),Hq=i(((e,t)=>{t.exports=n,n.displayName=`clike`,n.aliases=[];function n(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}})),Uq=i(((e,t)=>{t.exports=n,n.displayName=`javascript`,n.aliases=[`js`];function n(e){e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}})),Wq=i(((e,t)=>{var n=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},r=C();n.Prism={manual:!0,disableWorkerMessageHandler:!0};var i=Eq(),a=Rq(),o=zq(),s=Bq(),c=Vq(),l=Hq(),u=Uq();r();var d={}.hasOwnProperty;function f(){}f.prototype=o;var p=new f;t.exports=p,p.highlight=g,p.register=m,p.alias=h,p.registered=_,p.listLanguages=v,m(s),m(c),m(l),m(u),p.util.encode=x,p.Token.stringify=y;function m(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `grammar`, got `"+e+"`");p.languages[e.displayName]===void 0&&e(p)}function h(e,t){var n=p.languages,r=e,i,a,o,s;for(i in t&&(r={},r[e]=t),r)for(a=r[i],a=typeof a==`string`?[a]:a,o=a.length,s=-1;++s<o;)n[a[s]]=n[i]}function g(e,t){var n=o.highlight,r;if(typeof e!=`string`)throw Error("Expected `string` for `value`, got `"+e+"`");if(p.util.type(t)===`Object`)r=t,t=null;else{if(typeof t!=`string`)throw Error("Expected `string` for `name`, got `"+t+"`");if(d.call(p.languages,t))r=p.languages[t];else throw Error("Unknown language: `"+t+"` is not registered")}return n.call(this,e,r,t)}function _(e){if(typeof e!=`string`)throw Error("Expected `string` for `language`, got `"+e+"`");return d.call(p.languages,e)}function v(){var e=p.languages,t=[],n;for(n in e)d.call(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function y(e,t,n){var r;return typeof e==`string`?{type:`text`,value:e}:p.util.type(e)===`Array`?b(e,t):(r={type:e.type,content:p.Token.stringify(e.content,t,n),tag:`span`,classes:[`token`,e.type],attributes:{},language:t,parent:n},e.alias&&(r.classes=r.classes.concat(e.alias)),p.hooks.run(`wrap`,r),i(r.tag+`.`+r.classes.join(`.`),S(r.attributes),r.content))}function b(e,t){for(var n=[],r=e.length,i=-1,a;++i<r;)a=e[i],a!==``&&a!=null&&n.push(a);for(i=-1,r=n.length;++i<r;)a=n[i],n[i]=p.Token.stringify(a,t,n);return n}function x(e){return e}function S(e){for(var t in e)e[t]=a(e[t]);return e}function C(){var e=`Prism`in n,t=e?n.Prism:void 0;return r;function r(){e?n.Prism=t:delete n.Prism,e=void 0,t=void 0}}})),Gq=i(((e,t)=>{t.exports=n,n.displayName=`bash`,n.aliases=[`shell`];function n(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.shell=e.languages.bash})(e)}})),Kq=i(((e,t)=>{t.exports=n,n.displayName=`json`,n.aliases=[`webmanifest`];function n(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}})),qq=i(((e,t)=>{t.exports=n,n.displayName=`jsx`,n.aliases=[];function n(e){(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){e.language!==`jsx`&&e.language!==`tsx`||s(e.tokens)})})(e)}})),Jq=i(((e,t)=>{t.exports=n,n.displayName=`markdown`,n.aliases=[`md`];function n(e){(function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(l(t.content.value),s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}});var o=RegExp(e.languages.markup.tag.pattern.source,`gi`),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;function l(e){var t=e.replace(o,``);return t=t.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){return t=t.toLowerCase(),t[0]===`#`?c(t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1))):s[t]||e}),t}e.languages.md=e.languages.markdown})(e)}})),Yq=i(((e,t)=>{t.exports=n,n.displayName=`typescript`,n.aliases=[`ts`];function n(e){(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}})),Xq=i(((e,t)=>{var n=qq(),r=Yq();t.exports=i,i.displayName=`tsx`,i.aliases=[];function i(e){e.register(n),e.register(r),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}})),Zq=i(((e,t)=>{t.exports=n,n.displayName=`yaml`,n.aliases=[`yml`];function n(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}})),Qq=e(Wq(),1),$q=e(Gq(),1),eJ=e(Vq(),1),tJ=e(Uq(),1),nJ=e(Kq(),1),rJ=e(qq(),1),iJ=e(Jq(),1),aJ=e(Bq(),1),oJ=e(Xq(),1),sJ=e(Yq(),1),cJ=e(Zq(),1),lJ=e=>{let t=e.displayName;!t||Qq.default.registered(t)||Qq.default.register(e)};lJ(aJ.default),lJ(eJ.default),lJ(tJ.default),lJ(sJ.default),lJ(oJ.default),lJ(nJ.default),lJ(rJ.default),lJ(iJ.default),lJ(cJ.default),lJ($q.default);var uJ=r({TicketChangesModal:()=>BJ}),dJ=(e,t)=>Ne.t(`common:ticketChangesModal.${e}`,t),fJ=4,pJ=1500,mJ=`archon.ticket-changes.review-comments`,hJ=[],gJ=[],_J=[],vJ=e=>new Set(e.map(e=>e.path)),yJ=(e,t)=>{if(!e)return null;if(e.blocked_reason)return e.blocked_reason;let n=e.files.find(e=>!t.has(e.path)&&e.staged);return n?`"${n.path}" already has staged changes. Finish that commit in the terminal first.`:null},bJ=e=>e.replace(/^[ab]\//,``),xJ=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?bJ(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?bJ(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},SJ=e=>{let[t,n]=xJ(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},CJ=e=>{let[t,n]=xJ(e);return t??n??null},wJ=e=>e.hunks.reduce((e,t)=>e+t.changes.length,0),TJ=e=>{if(wJ(e)>pJ)return null;let t=QK(CJ(e));if(!t)return null;try{return qy(e.hunks,{highlight:!0,refractor:Qq.default,language:t,enhancers:[Gy(e.hunks)]})}catch{return null}},EJ=(e,t)=>e instanceof Error?e.message:t,DJ=(e,t)=>`${mJ}:${e}:${t}`,OJ=()=>({activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map,signature:null}),kJ=()=>({uncommitted:OJ(),bundle_diff:OJ()}),AJ=e=>({uncommitted:e(),bundle_diff:e()}),jJ=()=>AJ(()=>new Map),MJ=e=>{let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^e.charCodeAt(n);return`${e.length}:${t>>>0}`},NJ=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return(t.scope===void 0||t.scope===`uncommitted`||t.scope===`bundle_diff`)&&typeof t.filePath==`string`&&typeof t.changeKey==`string`&&typeof t.changeType==`string`&&(typeof t.oldLineNumber==`number`||t.oldLineNumber===null)&&(typeof t.newLineNumber==`number`||t.newLineNumber===null)&&typeof t.hunkHeader==`string`&&typeof t.lineContent==`string`&&typeof t.diffSnippet==`string`&&typeof t.comment==`string`},PJ=e=>{try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.diffSignature!=`string`||!Array.isArray(n.comments))return null;let r=n.comments.filter(NJ).map(e=>({scope:e.scope??`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.changeType,oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber,hunkHeader:e.hunkHeader,lineContent:e.lineContent,diffSnippet:e.diffSnippet,comment:e.comment}));return r.length===n.comments.length?{diffSignature:n.diffSignature,comments:r}:null}catch{return null}},FJ=e=>new Map(e.map(e=>[sb(e.filePath,e.changeKey),e])),IJ=(e,t)=>{e.set(t,(e.get(t)??0)+1)},LJ=e=>e.find(e=>e.trim())||``,RJ=({pullRequest:e,isLoading:t,isOpen:n,canCreate:r,disabledReason:i,isCreating:a,isSyncing:o,isGeneratingDescription:s,title:c,body:l,baseBranch:u,onOpenChange:d,onTitleChange:f,onBodyChange:p,onBaseBranchChange:m,showGenerateDescription:h,onGenerateDescription:g,onCreate:_})=>t?(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:`Loading PR...`}):o?(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:[(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}),`Checking PR...`]}):e?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border/80 bg-background/50 px-3 py-2`,children:[(0,Z.jsx)(_w,{pullRequest:e}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-xs font-medium text-sky-300 underline underline-offset-2 hover:text-sky-200`,children:[`PR #`,e.number]})]}):(0,Z.jsxs)(Zs,{open:n,onOpenChange:d,children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`default`,disabled:!r,title:i,className:`gap-2`,children:[a?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Mc,{className:`h-4 w-4`}),a?`Creating PR...`:`Create PR`]})}),(0,Z.jsxs)($s,{align:`end`,className:`z-[90] w-[36rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsx)(ec,{children:(0,Z.jsx)(tc,{children:`Create pull request`})}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(xu,{label:`Title`,htmlFor:`bundle-pr-title`,children:(0,Z.jsx)(We,{id:`bundle-pr-title`,value:c,onChange:e=>f(e.target.value),placeholder:`Bundle title`,disabled:a})}),(0,Z.jsx)(xu,{label:`Base branch`,htmlFor:`bundle-pr-base-branch`,description:`Optional. Leave blank to use the repository default branch.`,children:(0,Z.jsx)(We,{id:`bundle-pr-base-branch`,value:u,onChange:e=>m(e.target.value),placeholder:`main`,disabled:a})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,htmlFor:`bundle-pr-body`,children:`Description`}),h&&(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a||s,onClick:g,children:[s?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):null,s?`Generating...`:`Generate`]})]}),(0,Z.jsx)(Ls,{id:`bundle-pr-body`,value:l,onChange:e=>p(e.target.value),placeholder:`Summarize the bundle changes for reviewers.`,className:`min-h-40`,disabled:a})]}),(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(K,{type:`button`,size:`sm`,disabled:!c.trim()||a,onClick:_,children:a?`Creating...`:`Create PR`})})]})]})]}),zJ=(e,t,n)=>{if(n)return vJ(t);let r=new Set(t.map(e=>e.path));return new Set([...e].filter(e=>r.has(e)))},BJ=e=>{let{projectId:t,reviewCommentsBundleId:n=null,title:r,onClose:i,onSubmitReviewPrompt:a,canSubmitReviewPrompt:o=!1,reviewSubmitDisabledReason:s,canAddReviewComments:c=!0,canModifyChanges:l=!0,changesDisabledReason:u}=e,d=e.scope??`ticket`,{isGitHubConnected:f}=ff(t),p=e.scope===`project_root`?null:e.ticketId,m=e.scope===`project_root`?void 0:e.onTicketUpdate,h=e.scope===`project_root`?void 0:e.onRequestTicketRefresh,[g,_]=(0,Y.useState)(`uncommitted`),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)([]),[E,D]=(0,Y.useState)(new Set),[O,k]=(0,Y.useState)(`all`),[A,j]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(null),[R,z]=(0,Y.useState)(null),[B,te]=(0,Y.useState)(!0),[ne,V]=(0,Y.useState)(!1),[re,H]=(0,Y.useState)(!0),[ie,ae]=(0,Y.useState)(!1),[oe,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(!1),[de,he]=(0,Y.useState)(null),[ge,W]=(0,Y.useState)(!1),[_e,ve]=(0,Y.useState)(`unified`),[ye,be]=(0,Y.useState)(new Map),[G,xe]=(0,Y.useState)(_J),[we,Te]=(0,Y.useState)(kJ),[Ee,De]=(0,Y.useState)(null),[Ae,Me]=(0,Y.useState)([]),[Ne,Pe]=(0,Y.useState)(null),[Fe,Ie]=(0,Y.useState)(null),[Le,ze]=(0,Y.useState)(new Set),[Be,Ue]=(0,Y.useState)(new Set),[We,Ge]=(0,Y.useState)(!1),[Ke,qe]=(0,Y.useState)(null),[Je,Ye]=(0,Y.useState)(!1),[Xe,Ze]=(0,Y.useState)(!1),[Qe,$e]=(0,Y.useState)(``),[et,q]=(0,Y.useState)(``),[J,tt]=(0,Y.useState)(``),[nt,rt]=(0,Y.useState)([]),[it,at]=(0,Y.useState)(!1),[ot,st]=(0,Y.useState)(!1),[ct,lt]=(0,Y.useState)(!1),ut=(0,Y.useRef)(null),dt=(0,Y.useRef)(!1),ft=(0,Y.useRef)(null),pt=(0,Y.useRef)(null),mt=(0,Y.useRef)(0),ht=(0,Y.useRef)(0),gt=(0,Y.useRef)(!1),_t=(0,Y.useRef)(AJ(()=>null)),vt=(0,Y.useRef)(jJ()),X=(0,Y.useRef)(`idle`),yt=(0,Y.useRef)(0),bt=(0,Y.useRef)(null),xt=(0,Y.useMemo)(()=>qK({scope:d,projectId:t,ticketId:p}),[t,d,p]),St=(0,Y.useCallback)(()=>{if(!p)throw Error(`Ticket changes require a ticket id.`);return p},[p]),Ct=(0,Y.useCallback)(e=>{ft.current=e,y(e),N(null)},[]),wt=(0,Y.useCallback)((e,t)=>{YK({cacheKey:xt,diffResponse:e,gitStatus:t})},[xt]),Et=(0,Y.useCallback)(e=>{ft.current&&YK({cacheKey:xt,diffResponse:ft.current,gitStatus:e})},[xt]),At=(0,Y.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ve(t)}return await Zt(St(),t)},[t,St,d]),jt=(0,Y.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await ke(t)}return await Qt(St(),t,{refreshRemote:!1})},[t,St,d]),Mt=(0,Y.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await me(t)}return await nn(St(),t)},[t,St,d]),Nt=(0,Y.useCallback)(async e=>d===`project_root`||!n||!t?null:await Pt(t,n,e),[t,n,d]),Lt=(0,Y.useCallback)(async e=>d===`project_root`||!n||!t?null:await Tt(t,n,e),[t,n,d]),Rt=(0,Y.useCallback)(async e=>d===`project_root`||!n||!t?null:await Ft(t,n,e),[t,n,d]),zt=(0,Y.useCallback)(async e=>d===`project_root`||!n||!t?null:await It(t,n,e),[t,n,d]),Bt=(0,Y.useCallback)(function e({silent:r}){if(d===`project_root`||!n||!t||!Ke?.bundle.pull_request||!f||X.current===`loaded`)return Promise.resolve();if(X.current===`loading`){let t=bt.current;return t?t.then(()=>{if(!r&&X.current===`idle`)return e({silent:!1})}):Promise.resolve()}r||Ie(null),X.current=`loading`;let i=yt.current,a=zt().then(e=>{if(i===yt.current){if(!e){X.current=`idle`;return}if(e.error){r||(Me(e.comments),Ie(e.error),Ue(t=>{let n=new Set(e.comments.map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))})),X.current=`idle`;return}Me(e.comments),Ie(null),Ue(t=>{let n=new Set(e.comments.map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}),X.current=`loaded`}}).catch(e=>{i===yt.current&&(X.current=`idle`,!r&&(Me([]),Ie(EJ(e,`Unable to load GitHub review comments right now.`)),Ue(new Set)))}).finally(()=>{i===yt.current&&bt.current===a&&(bt.current=null)});return bt.current=a,a},[Ke?.bundle.pull_request,f,t,zt,n,d]),Vt=(0,Y.useCallback)((e,t)=>{Te(n=>({...n,[e]:t(n[e])}))},[]),Ht=(0,Y.useCallback)(async e=>{if(d===`project_root`||!n||!t)throw Error(`Pull request description generation requires a bundle context.`);return await Ot(t,n,e)},[t,n,d]),Ut=(0,Y.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await se(t,e)}return await $t(St(),t,e)},[t,St,d]),Wt=(0,Y.useCallback)(async e=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ce(t,e)}return await en(St(),t,e)},[t,St,d]),Gt=(0,Y.useCallback)(async(e={})=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await fe(t,e)}return await tn(St(),t,e)},[t,St,d]),Kt=(0,Y.useCallback)(async()=>{if(d===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await ee(t)}return await rn(St(),t)},[t,St,d]),qt=(0,Y.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=mt.current+1;mt.current=r,ae(!0),n||z(null);try{let t=await Mt();if(!e()||mt.current!==r)return;T(t.commits),z(null)}catch(t){if(!e()||mt.current!==r)return;z(EJ(t,`Unable to load local commits right now.`)),n||T([])}finally{e()&&mt.current===r&&ae(!1)}},[Mt]),Jt=(0,Y.useCallback)(()=>{mt.current+=1,T([]),z(null),ae(!1)},[]),Yt=(0,Y.useCallback)((e,t={})=>{let n=t.resetSelection??!1;pt.current=e,C(e),L(null),D(t=>{let r=zJ(t,e.files,n||!dt.current);return dt.current=!0,r})},[]),Xt=(0,Y.useCallback)(async(e={})=>{let t=e.preserveContent??!1,n=e.gitStatusForCache??null;t||N(null),te(!0);try{let e=await At();Ct(e),n&&wt(e,n)}catch(e){n&&XK(xt),(!t||!ft.current)&&N(EJ(e,`Unable to load the diff right now.`))}finally{te(!1)}},[Ct,xt,At,wt]),an=(0,Y.useCallback)(async(e={})=>{let r=e.preserveContent??!1;if(d===`project_root`||!n||!t){x(null),F(null),V(!1);return}r||F(null),V(!0);try{x(await Rt()),F(null)}catch(e){(!r||!b)&&F(EJ(e,`Unable to load the branch diff right now.`))}finally{V(!1)}},[b,t,Rt,n,d]),on=(0,Y.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=t.resetSelection??!1,i=t.allowCache??!0?JK(xt):null;if(n||(N(null),L(null)),H(!0),i){Ct(i.diffResponse),Yt(i.gitStatus,{resetSelection:r}),te(!1);try{let t=await jt();if(!e())return;Yt(t,{resetSelection:r}),H(!1),(t.ahead??0)>0?qt(e,{preserveContent:!0}):Jt();let n=t.workspace_signature??null;if(n&&n===i.workspaceSignature){wt(i.diffResponse,t);return}XK(xt),await Xt({preserveContent:!0,gitStatusForCache:t});return}catch(t){if(!e())return;L(EJ(t,`Unable to load git status right now.`)),C(null),H(!1),Jt();return}}te(!0),At().then(t=>{e()&&(Ct(t),pt.current&&wt(t,pt.current))}).catch(t=>{e()&&(!n||!ft.current)&&N(EJ(t,`Unable to load the diff right now.`))}).finally(()=>{e()&&te(!1)});try{let t=await jt();if(!e())return;Yt(t,{resetSelection:r}),H(!1),ft.current&&wt(ft.current,t),(t.ahead??0)>0?qt(e,{preserveContent:n}):Jt()}catch(t){if(!e())return;L(EJ(t,`Unable to load git status right now.`)),n||C(null),H(!1),Jt()}},[Ct,Yt,xt,Jt,qt,Xt,At,jt,wt]),sn=(0,Y.useCallback)(async()=>{if(!t)return;let e=ht.current+1;ht.current=e,H(!0);try{let t=await jt();if(ht.current!==e)return;let n=pt.current?.workspace_signature??null,r=t.workspace_signature??null,i=!ft.current||n!==r;if(Yt(t),(t.ahead??0)>0?qt(()=>ht.current===e,{preserveContent:!0}):Jt(),!i){Et(t);return}await Xt({preserveContent:!0,gitStatusForCache:t})}catch{return}finally{ht.current===e&&H(!1)}},[Yt,Jt,qt,Xt,t,jt,Et]);(0,Y.useEffect)(()=>{ft.current=v},[v]),(0,Y.useEffect)(()=>{pt.current=S},[S]),(0,Y.useEffect)(()=>{let e=!0;return on(()=>e,{resetSelection:!0}),()=>{e=!1}},[on]),(0,Y.useEffect)(()=>{if(t)return tq(e=>{if(e===t){if(gt.current){gt.current=!1;return}sn()}})},[t,sn]),(0,Y.useEffect)(()=>{if(!t)return;let e=rq(()=>{document.visibilityState===`visible`&&sn()});return()=>{e()}},[t,sn]),(0,Y.useEffect)(()=>{if(d===`project_root`){De(null),Pe(null),ze(new Set);return}if(!v?.diff?.trim()){De(null),Pe(null),ze(new Set);return}let e=new AbortController,t=!0;return Pe(null),Nt(e.signal).then(e=>{t&&(De(e),ze(t=>{let n=new Set((e?.findings??[]).map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(n=>{!t||e.signal.aborted||(Pe(EJ(n,`Unable to load review findings right now.`)),De(null),ze(new Set))}),()=>{t=!1,e.abort()}},[v?.diff,Nt,d]),(0,Y.useEffect)(()=>{_(`uncommitted`),_t.current=AJ(()=>null),vt.current=jJ(),Te(kJ()),x(null),F(null),V(!1),yt.current+=1,X.current=`idle`,bt.current=null,Me([]),Ie(null),Ue(new Set),qe(null),Ye(!1),Ze(!1),$e(``),q(``),tt(``),rt([]),at(!1),st(!1),lt(!1)},[n]),(0,Y.useEffect)(()=>{if(d===`project_root`||!n||!t){qe(null),Ye(!1);return}if(v===null&&!M){Ye(!1);return}let e=new AbortController,i=!0;return Ye(!0),Lt(e.signal).then(e=>{i&&(qe(e),$e(t=>t.trim()?t:e?.bundle?Tl(e.bundle):r),q(t=>t.trim()?t:LJ(e?.recent_commit_subjects??nt)),tt(t=>t.trim()?t:e?.bundle.pull_request?.base_branch??``))}).catch(()=>{!i||e.signal.aborted||qe(null)}).finally(()=>{i&&Ye(!1)}),()=>{i=!1,e.abort()}},[M,v,nt,t,Lt,n,d,r]),(0,Y.useEffect)(()=>{if(d===`project_root`||!n||!t){x(null),F(null),V(!1);return}if(g!==`bundle_diff`){V(!1);return}let e=new AbortController,r=!0;return V(!0),F(null),Rt(e.signal).then(e=>{r&&(x(e),F(null))}).catch(t=>{!r||e.signal.aborted||(F(EJ(t,`Unable to load the branch diff right now.`)),x(null))}).finally(()=>{r&&V(!1)}),()=>{r=!1,e.abort()}},[g,t,Rt,n,d]),(0,Y.useEffect)(()=>{let e=Ke?.bundle.pull_request??null;if(d===`project_root`||!n||!t||!e){yt.current+=1,X.current=`idle`,bt.current=null,Me([]),Ie(null),Ue(new Set);return}if(!f){yt.current+=1,X.current=`idle`,bt.current=null,Me([]),Ie(null),Ue(new Set);return}Bt({silent:!0})},[Ke?.bundle.pull_request,Bt,f,t,n,d]),(0,Y.useEffect)(()=>{g===`bundle_diff`&&Bt({silent:!1})},[g,Ke?.bundle.pull_request,Bt,f,t,n,d]),(0,Y.useEffect)(()=>{re&&S===null||ut.current?.focus()},[S,re]);let cn=(0,Y.useMemo)(()=>{let e=typeof v?.diff==`string`?v.diff:``;return e.trim()?Rm(e).map(e=>({...e,pathCandidates:xJ(e)})):[]},[v]),ln=(0,Y.useMemo)(()=>{let e=typeof b?.diff==`string`?b.diff:``;return e.trim()?Rm(e).map(e=>({...e,pathCandidates:xJ(e)})):[]},[b]),un=(0,Y.useMemo)(()=>{let e=v?.diff??``;return e?MJ(e):null},[v?.diff]),dn=(0,Y.useMemo)(()=>{let e=b?.diff??``;return e?MJ(e):null},[b?.diff]),fn=g===`bundle_diff`?b:v,pn=g===`bundle_diff`?ln:cn,mn=(0,Y.useMemo)(()=>n?{uncommitted:DJ(n,`uncommitted`),bundle_diff:DJ(n,`bundle_diff`)}:{uncommitted:null,bundle_diff:null},[n]),hn=(0,Y.useMemo)(()=>({uncommitted:un,bundle_diff:dn}),[dn,un]),gn=(0,Y.useMemo)(()=>{let e=new Map;for(let t of fn?.files??[])e.set(t.path,t);return e},[fn]),_n=(0,Y.useMemo)(()=>{let e=new Map;for(let t of pn)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[pn]),vn=(0,Y.useCallback)(e=>{xe(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),yn=(0,Y.useMemo)(()=>g===`bundle_diff`?(b?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})):S?(S.files??[]).map(e=>{let t=gn.get(e.path)??(e.original_path?gn.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(v?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})),[g,b?.files,gn,v?.files,S]);(0,Y.useEffect)(()=>{O!==`all`&&(yn.some(e=>e.path===O)||k(`all`))},[O,yn]);let bn=g===`bundle_diff`?0:E.size,xn=de!==null,Sn=de===`force`,Cn=g===`bundle_diff`?yn.length:S?.files?.length??yn.length,wn=Cn>0&&bn===Cn,Tn=(0,Y.useMemo)(()=>g===`bundle_diff`?null:yJ(S,E),[g,S,E]),En=g===`uncommitted`&&!re&&!oe&&l&&!!S&&bn>0&&A.trim().length>0&&Tn===null,Dn=g===`uncommitted`&&!re&&!B&&!le&&!oe&&!xn&&l&&!We&&!!S&&bn>0,On=!re&&(xn||!!S?.can_push&&(S?.ahead??0)>0),kn=On&&!!S?.can_force_push_with_lease,An=On&&l&&!xn&&!oe,jn=kn&&l&&!xn&&!oe,Mn=l&&!ie&&!ge&&!oe&&!xn&&(w?.length??0)>0,Nn=(S?.ahead??0)>0?`${S?.ahead??0} to push`:`Up to date`,Pn=(S?.behind??0)>0?`${S?.behind??0} behind`:`In sync`,Fn=S?.branch??null,In=O===`all`?null:_n.get(O)??null,Ln=(0,Y.useMemo)(()=>O===`all`?pn:In?[In]:[],[pn,O,In]);(0,Y.useEffect)(()=>{be(new Map),xe(_J)},[g,pn]),(0,Y.useEffect)(()=>{let e={uncommitted:mn.uncommitted&&hn.uncommitted?`${mn.uncommitted}:${hn.uncommitted}`:null,bundle_diff:mn.bundle_diff&&hn.bundle_diff?`${mn.bundle_diff}:${hn.bundle_diff}`:null},t=_t.current;t.uncommitted===e.uncommitted&&t.bundle_diff===e.bundle_diff||(_t.current=e,Te(n=>{let r={...n};return[`uncommitted`,`bundle_diff`].forEach(i=>{if(t[i]===e[i])return;let a=hn[i],o=mn[i],s=n[i];if(t[i]===null&&a&&(s.activeTarget||s.editingCommentKey||s.draftInput.trim()||s.comments.size>0)){r[i]={...s,signature:a};return}if(!a){vt.current[i]=new Map,r[i]=OJ();return}let c=new Map;if(o){let e=window.localStorage.getItem(o),t=e?PJ(e):null;t?.diffSignature===a?c=FJ(t.comments.map(e=>({...e,scope:i}))):e!==null&&window.localStorage.removeItem(o)}vt.current[i]=new Map,r[i]={activeTarget:null,editingCommentKey:null,draftInput:``,comments:c,signature:a}}),r}))},[hn,mn]),(0,Y.useEffect)(()=>{[`uncommitted`,`bundle_diff`].forEach(e=>{let t=mn[e],n=hn[e],r=we[e];if(!t||!n||r.signature!==n)return;if(r.comments.size===0){window.localStorage.removeItem(t);return}let i={diffSignature:n,comments:[...r.comments.values()]};window.localStorage.setItem(t,JSON.stringify(i))})},[hn,mn,we]),(0,Y.useEffect)(()=>{if(pn.length===0)return;let e=!1,t=null,n=(()=>{if(!In){let e=[],t=new Set;for(let n of G){let r=_n.get(n);if(!r)continue;let i=SJ(r);t.has(i)||(t.add(i),e.push(r))}return e.length>0?e:pn.slice(0,fJ)}return[In]})(),r=0,i=()=>{if(e)return;let a=n.slice(r,r+fJ);a.length!==0&&(be(e=>{let t=new Map(e);for(let e of a){let n=SJ(e);t.has(n)||t.set(n,TJ(e))}return t}),r+=fJ,r<n.length&&(t=window.setTimeout(i,0)))};return n.length<=fJ?i():t=window.setTimeout(i,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[pn,_n,In,G]);let Rn=(0,Y.useMemo)(()=>Ln.map(e=>({...e,tokens:ye.get(SJ(e))??null})),[ye,Ln]),zn=(0,Y.useMemo)(()=>pn.map(e=>({...e,tokens:null})),[pn]),Bn=(0,Y.useMemo)(()=>{let e=new Map;for(let t of pn){let n=SJ(t);e.set(n,n);for(let r of xJ(t))e.set(r,n)}return e},[pn]),Vn=(0,Y.useMemo)(()=>[...we.uncommitted.comments.values()],[we.uncommitted.comments]),Hn=(0,Y.useMemo)(()=>[...we.bundle_diff.comments.values()],[we.bundle_diff.comments]),Un=we[g],Wn=Un.activeTarget,Gn=Un.editingCommentKey,Kn=Wn?.commentKey??Gn,qn=Kn?`${g}:${Kn}`:g,Jn=Kn?vt.current[g].get(Kn)??Un.draftInput:Un.draftInput,Yn=g===`bundle_diff`?Hn:Vn,Xn=(0,Y.useMemo)(()=>[...Vn,...Hn],[Hn,Vn]),Zn=(0,Y.useMemo)(()=>Ee?.findings??[],[Ee]),Qn=(0,Y.useMemo)(()=>Ee?.is_current_diff?Zn.filter(e=>Le.has(e.id)):[],[Zn,Ee?.is_current_diff,Le]),$n=(0,Y.useMemo)(()=>[...Le],[Le]),er=(0,Y.useMemo)(()=>Ae.filter(e=>Be.has(e.id)),[Ae,Be]),tr=(0,Y.useMemo)(()=>[...Be],[Be]),nr=Xn.length+Qn.length+er.length,rr=!!(Ee?.review_run&&Zn.length>0&&!Ee.is_current_diff),ir=Ke?.bundle.pull_request??null,ar=(0,Y.useMemo)(()=>nt.length>0?nt:Ke?.recent_commit_subjects??[],[Ke?.recent_commit_subjects,nt]),or=Ke?.has_helper_model===!0,sr=d!==`project_root`&&!!n&&!!t,cr=g===`bundle_diff`?P:M,lr=B&&v===null,ur=ne&&b===null,dr=re&&S===null,fr=Je&&Ke===null,pr=g===`bundle_diff`?ur:lr,mr=g===`uncommitted`?Zn:hJ,hr=g===`uncommitted`?$n:_J,gr=g===`bundle_diff`?Ae:gJ,_r=g===`bundle_diff`?tr:_J,vr=g===`bundle_diff`?`bundle_diff`:`uncommitted`,yr=(0,Y.useMemo)(()=>{let e=new Map,t=e=>e?Bn.get(e)??e:null;for(let n of Yn){let r=t(n.filePath);r&&IJ(e,r)}if(g===`uncommitted`){if(rr)return e;for(let n of Zn){let r=t(n.file_path);r&&IJ(e,r)}return e}for(let n of Ae){let r=t(n.file_path);r&&IJ(e,r)}return e},[g,Bn,Yn,Ae,rr,Zn]),br=(rr?0:Zn.length)+Vn.length,xr=Ae.length+Hn.length,Sr=g===`bundle_diff`?`No branch diff to show.`:`No uncommitted changes to show.`,Cr=g===`uncommitted`&&sr?`Switch to Branch diff to review the full branch diff.`:null,wr=sr&&!fr&&!!Ke&&Ke?.bundle.kind!==`project_root`&&S?.has_upstream===!0&&f,Tr=wr&&!ir&&!it&&!ot&&!ct&&!We&&!xn&&!oe&&!ge&&(S?.ahead??0)===0&&!!S?.branch,Er=(0,Y.useCallback)(e=>{if(!e){Ze(!1);return}if(!t||!n||!wr||ir||ot){Ze(e);return}st(!0),kt(t,n).then(e=>{qe(e),tt(t=>t.trim()?t:e.bundle.pull_request?.base_branch??``),Ze(!e.bundle.pull_request)}).catch(e=>{Q.error(EJ(e,`Unable to check for an existing pull request right now.`),{id:`ticket-changes-sync-pr-error`}),Ze(!0)}).finally(()=>{st(!1)})},[ir,ot,t,n,wr]),Dr=(0,Y.useMemo)(()=>{if(wr)return(S?.ahead??0)>0?`Push the branch before creating a pull request.`:S?.branch?u:`Bundle branch information is not available right now.`},[u,S?.ahead,S?.branch,wr]),Or=c&&!pr&&(g===`bundle_diff`||!dr)&&!oe&&!xn&&!ge,kr=Wn?Or||Un.comments.has(Wn.commentKey):Or,Ar=!!a&&o&&nr>0&&!We,jr=(0,Y.useCallback)(e=>{ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Mr=(0,Y.useCallback)(e=>{Ue(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Nr=(0,Y.useCallback)(()=>{vt.current=jJ(),Te(e=>({uncommitted:{...e.uncommitted,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map},bundle_diff:{...e.bundle_diff,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map}}))},[]),Pr=(0,Y.useCallback)(()=>{Nr(),ze(new Set),Ue(new Set)},[Nr]),Fr=(0,Y.useCallback)(async()=>{if(!(!t||!n||!Tr)){at(!0);try{let e=await Dt(t,n,{title:Qe.trim(),body:et.trim(),base_branch:J.trim()||null});qe(e),tt(e.bundle.pull_request?.base_branch??J.trim()),Ze(!1),Q.success(`Pull request created.`,{id:`ticket-changes-create-pr-success`})}catch(e){Q.error(EJ(e,`Unable to create the pull request right now.`),{id:`ticket-changes-create-pr-error`})}finally{at(!1)}}},[Tr,t,J,et,Qe,n]),Ir=(0,Y.useCallback)(async()=>{if(!(!t||!n||!wr||ct)){lt(!0);try{q((await Ht({title:Qe.trim(),commit_subjects:ar})).description)}catch(e){Q.error(EJ(e,`Unable to generate the pull request description right now.`),{id:`ticket-changes-generate-pr-description-error`})}finally{lt(!1)}}},[ct,t,ar,Qe,Ht,n,wr]),Lr=(0,Y.useCallback)(({filePath:e,changeKey:t,commentKey:n})=>{let r=Un.comments.get(n),i=vt.current[g].get(n)??r?.comment??``;if(r){k(r.filePath),Vt(g,e=>({...e,activeTarget:null,editingCommentKey:n,draftInput:i}));return}Or&&Vt(g,r=>({...r,activeTarget:{filePath:e,changeKey:t,commentKey:n},editingCommentKey:null,draftInput:i}))},[g,Un.comments,Or,Vt]),Rr=(0,Y.useCallback)(()=>{Kn&&vt.current[g].delete(Kn),Vt(g,e=>({...e,activeTarget:null,editingCommentKey:null,draftInput:``}))},[g,Kn,Vt]),zr=(0,Y.useCallback)(e=>{Kn&&vt.current[g].set(Kn,e)},[g,Kn]),Br=(0,Y.useCallback)((e,t)=>{let n=Un.comments.has(e.commentKey);if(!Or&&!n)return;let r=t.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;Vt(g,t=>{let n=new Map(t.comments);return n.set(e.commentKey,{scope:g,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:cb(e.hunk,e.change),comment:r}),{...t,activeTarget:null,editingCommentKey:null,draftInput:``,comments:n}}),vt.current[g].delete(e.commentKey)},[g,Un.comments,Or,Vt]),Vr=(0,Y.useCallback)(e=>{let t=Un.comments.get(e);if(!t)return;k(t.filePath);let n=vt.current[g].get(e)??t.comment;Vt(g,t=>({...t,activeTarget:null,editingCommentKey:e,draftInput:n}))},[g,Un.comments,Vt]),Hr=(0,Y.useCallback)(e=>{vt.current[g].delete(e),Vt(g,t=>{let n=new Map(t.comments);return n.delete(e),{...t,activeTarget:t.activeTarget?.commentKey===e?null:t.activeTarget,editingCommentKey:t.editingCommentKey===e?null:t.editingCommentKey,draftInput:t.activeTarget?.commentKey===e||t.editingCommentKey===e?``:t.draftInput,comments:n}})},[g,Vt]),Ur=(0,Y.useCallback)(async()=>{if(!a||!Ar)return;Ge(!0);let e=_b({drafts:Xn,findings:Qn,githubComments:er,uncommittedFiles:cn,bundleFiles:ln});try{await a(e),Nr(),ze(new Set),Ue(new Set),De(e=>e&&{...e,findings:[],is_current_diff:!1}),Q.success(`Fixes submitted.`,{id:`ticket-diff-review-submit-success`}),i()}catch(e){Q.error(EJ(e,`Unable to submit the review right now.`),{id:`ticket-diff-review-submit-error`})}finally{Ge(!1)}},[Xn,ln,Ar,Nr,i,a,er,Qn,cn]),Wr=(0,Y.useCallback)(()=>{if(g===`bundle_diff`){an();return}on(()=>!0,{allowCache:!1,resetSelection:!dt.current})},[g,an,on]),Gr=(0,Y.useMemo)(()=>a?(0,Z.jsx)(HG,{reviewComments:Xn,reviewFindings:Qn,githubComments:er,pendingFixCount:nr,canSendReview:Ar,isSubmittingReview:We,reviewSubmitDisabledReason:s,onClearPendingFixes:Pr,onSubmitReview:()=>{Ur()}}):null,[Xn,Ar,Pr,Ur,We,a,nr,s,er,Qn]),Kr=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},qr=()=>{S&&D(wn?new Set:vJ(S.files))},Jr=async()=>{if(En){ce(!0);try{let e=await Ut({message:A.trim(),selected_paths:[...E]});e.ticket&&m?.(e.ticket),Yt(e.git_status,{resetSelection:!0}),j(``),t&&(gt.current=!0,eq(t)),p&&h?.(p),await Xt({preserveContent:!0,gitStatusForCache:e.git_status}),await an({preserveContent:!0}),(e.git_status.ahead??0)>0?await qt(()=>!0):Jt(),Q.success(`Commit created.`,{id:`ticket-git-commit-success`})}catch(e){Q.error(EJ(e,`Unable to create the commit right now.`),{id:`ticket-git-commit-error`})}finally{ce(!1)}}},Yr=async()=>{if(Dn){ue(!0);try{j((await Wt({selected_paths:[...E]})).message),ut.current?.focus()}catch(e){Q.error(EJ(e,`Unable to generate a commit message right now.`),{id:`ticket-git-commit-message-error`})}finally{ue(!1)}}},Xr=async(e=`normal`)=>{if(!(e===`force`?!jn:!An)){he(e);try{let r=w.map(e=>e.subject.trim()).filter(Boolean),a=await Gt({forceWithLease:e===`force`});if(a.ticket&&m?.(a.ticket),Yt(a.git_status,{resetSelection:!0}),Et(a.git_status),rt(r),Jt(),t&&(gt.current=!0,eq(t)),p&&h?.(p),Q.success(e===`force`?a.git_status.ahead===0?dJ(`branchForcePushed`):dJ(`forcePushCompleted`):a.git_status.ahead===0?dJ(`branchPushed`):dJ(`pushCompleted`),{id:`ticket-git-push-success`}),a.git_status.ahead===0)if(d!==`project_root`&&t&&n)try{let e=await Tt(t,n);qe(e),$e(t=>t.trim()?t:Tl(e.bundle)),q(e=>e.trim()?e:LJ(r)),tt(t=>t.trim()?t:e.bundle.pull_request?.base_branch??``)}catch{}else i()}catch(t){Q.error(EJ(t,dJ(e===`force`?`forcePushFallbackError`:`pushFallbackError`)),{id:`ticket-git-push-error`})}finally{he(null)}}},Zr=async()=>{if(Mn){W(!0);try{let e=await Kt();e.ticket&&m?.(e.ticket),Yt(e.git_status,{resetSelection:!0}),T(e.commits),z(null),ae(!1),t&&(gt.current=!0,eq(t)),p&&h?.(p),await Xt({preserveContent:!0,gitStatusForCache:e.git_status}),await an({preserveContent:!0}),Q.success(`Latest local commit undone.`,{id:`ticket-git-undo-success`})}catch(e){Q.error(EJ(e,`Unable to undo the latest local commit right now.`),{id:`ticket-git-undo-error`})}finally{W(!1)}}};return(0,Z.jsx)(du,{onClose:i,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-[92vh] w-full max-w-none flex-col overflow-hidden rounded-2xl border border-border bg-card p-6 shadow-2xl`,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[xn&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-2xl bg-black/45 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-border bg-card/95 px-4 py-3 text-sm text-foreground shadow-xl`,children:[(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{children:`Pushing branch...`})]})}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Changes`}),Fn?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`h2`,{className:`max-w-full truncate font-mono text-lg font-semibold text-foreground`,children:Fn}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(U,{variant:(S?.ahead??0)>0?`info`:`outline`,children:Nn}),(0,Z.jsx)(U,{variant:(S?.behind??0)>0?`warning`:`outline`,children:Pn}),(0,Z.jsx)(U,{variant:S?.is_dirty?`warning`:`success`,children:S?.is_dirty?`Dirty`:`Clean`})]})]}):(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-7 w-56 animate-pulse rounded-md bg-muted/70`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-6 w-32 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 text-xs text-muted-foreground`,children:[(ir||wr)&&(0,Z.jsx)(RJ,{pullRequest:ir,isLoading:fr,isOpen:Xe,canCreate:Tr,disabledReason:Dr,isCreating:it,isSyncing:ot,isGeneratingDescription:ct,title:Qe,body:et,baseBranch:J,onOpenChange:Er,onTitleChange:$e,onBodyChange:q,onBaseBranchChange:tt,showGenerateDescription:or,onGenerateDescription:()=>{Ir()},onCreate:()=>{Fr()}}),(0,Z.jsx)(WG,{isCommitsLoading:ie,commitsError:R,unpushedCommits:w,canUndoLatestCommit:Mn,isUndoing:ge,aheadCount:S?.ahead??0,onUndoLatestCommit:()=>{Zr()}}),On&&(kn?(0,Z.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Xr()},disabled:!An,title:u,className:`gap-2 rounded-r-none`,children:[xn?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Mc,{className:`h-4 w-4`}),dJ(Sn?`forcePushing`:xn?`pushing`:`pushBranch`)]}),(0,Z.jsxs)(He,{children:[(0,Z.jsx)(Se,{asChild:!0,children:(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`default`,disabled:!jn,"aria-label":dJ(`morePushActions`),className:`rounded-l-none border-l border-primary-foreground/20 px-2`,children:(0,Z.jsx)(Oe,{className:`h-4 w-4`})})}),(0,Z.jsx)(je,{align:`end`,className:`w-56`,children:(0,Z.jsx)(Re,{disabled:!jn,onSelect:()=>{Xr(`force`)},children:dJ(`forcePushWithLease`)})})]})]}):(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Xr()},disabled:!An,title:u,className:`gap-2`,children:[xn?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Mc,{className:`h-4 w-4`}),dJ(xn?`pushing`:`pushBranch`)]})),e]})]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-changes-layout`,className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)] xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`flex min-h-0 flex-col`,children:[sr&&(0,Z.jsxs)(FG,{type:`single`,size:`sm`,variant:`outline`,value:g,onValueChange:e=>{(e===`uncommitted`||e===`bundle_diff`)&&_(e)},className:`mb-3 self-start`,children:[(0,Z.jsxs)(IG,{value:`uncommitted`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Uncommitted`}),br>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`,children:br})]}),(0,Z.jsxs)(IG,{value:`bundle_diff`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Branch diff`}),xr>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`,children:xr})]})]}),(0,Z.jsx)(BK,{selectionWarning:g===`uncommitted`?Tn:null,gitError:g===`uncommitted`?I:P,sidebarFiles:yn,commentCountByPath:yr,commentCountTone:vr,isGitStatusLoading:g===`bundle_diff`?ur:dr&&yn.length===0,selectedPaths:E,selectedDiffPath:O,allFilesSelected:wn,diffStats:fn?.stats??null,title:g===`bundle_diff`?`Branch diff files`:`Changed files`,allChangesDescription:g===`bundle_diff`?`Review the full branch diff against the review base.`:`Review the full workspace diff.`,enableSelection:g===`uncommitted`&&!dr,onToggleSelectAll:qr,onSelectDiffPath:k,onTogglePath:Kr})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,Z.jsx)(FK,{selectedDiffPath:O,sidebarFiles:yn,diffResponse:fn,isDiffLoading:pr,diffError:cr,allDiffFiles:zn,renderedFiles:Rn,viewType:_e,onViewTypeChange:ve,onRetry:Wr,activeReviewTarget:Wn,editingReviewCommentKey:Gn,reviewDraftInstanceKey:qn,reviewDraftInput:Jn,reviewComments:Yn,reviewFindings:mr,githubComments:gr,selectedReviewFindingIds:hr,selectedGitHubCommentIds:_r,canSelectReviewTarget:Or,canEditActiveReviewDraft:kr,reviewFindingsError:g===`uncommitted`?Ne:null,gitHubCommentsError:g===`bundle_diff`?Fe:null,hasStaleReviewFindings:g===`uncommitted`?rr:!1,onSelectReviewTarget:Lr,onToggleReviewFindingSelection:jr,onToggleGitHubCommentSelection:Mr,onReviewDraftInputChange:zr,onCancelReviewDraft:Rr,onEditReviewDraft:Vr,onRemoveReviewDraft:Hr,onSaveReviewDraft:Br,diffThemeClassName:VK,resolveFilePath:SJ,normalizeDiffPath:bJ,onVisibleFilePathsChange:vn,emptyStateTitle:Sr,emptyStateDescription:Cr,reviewSummaryControl:Gr,headerLayout:`inline-controls`}),g===`uncommitted`&&(0,Z.jsx)(`div`,{className:`mt-auto shrink-0`,children:(0,Z.jsx)(UG,{commitMessage:A,onCommitMessageChange:j,commitMessageRef:ut,selectedFileCount:bn,changesDisabledReason:u,canEditCommitMessage:l&&!We,canGenerateCommitMessage:Dn,canCommit:En,isGeneratingCommitMessage:le,isCommitting:oe,onGenerateCommitMessage:()=>{Yr()},onCommit:()=>{Jr()}})})]})]})]})]})})},VJ={blocked:{className:`stroke-red-400/80`,markerId:`dependency-arrowhead-blocked`},ready:{className:`stroke-emerald-400/80`,markerId:`dependency-arrowhead-ready`},preview:{className:`stroke-amber-300/80`,markerId:`dependency-arrowhead-preview`}},HJ=e=>Gw(e)?`ready`:`blocked`,UJ=180,WJ=560,GJ=88,KJ=12,qJ=18,JJ=(e,t,n)=>Math.min(Math.max(e,t),n),YJ=(e,t,n)=>n&&n.width>0&&n.height>0?n:Object.values(e).reduce((e,t)=>({width:Math.max(e.width,t.left+t.width),height:Math.max(e.height,t.top+t.height)}),{width:t.x,height:t.y}),XJ=(e,t)=>{let n=JJ(Math.round(e.length*7.2)+24,UJ,WJ),r=Math.max(UJ,t-KJ*2);return Math.min(n,r)},ZJ=(e,t,n,r,i)=>{let a=n.get(e.blockerTicketId);if(!a)return null;let o=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?r[e.hoveredTicketId]:null,s=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?n.get(e.hoveredTicketId):null,c=s?`${a.title} is blocking ${s.title}`:`${a.title} is blocking...`,{start:l,end:u}=$w(t,o??{left:e.pointer.x,top:e.pointer.y,width:0,height:0}),d=YJ(r,e.pointer,i),f=o&&s?{x:l.x+(u.x-l.x)*.6,y:l.y+(u.y-l.y)*.6-28}:{x:u.x,y:u.y-28},p=XJ(c,d.width);return{text:c,x:o&&s?JJ(f.x-p/2,KJ,Math.max(KJ,d.width-p-KJ)):(()=>{let e=f.x+qJ,t=f.x-qJ-p;return e+p<=d.width-KJ?e:t>=KJ?t:JJ(e,KJ,Math.max(KJ,d.width-p-KJ))})(),y:JJ(f.y,KJ,Math.max(KJ,d.height-GJ-KJ)),width:p}},QJ=({blockerRect:e,dependentRect:t,className:n,testId:r,markerEnd:i})=>{let{start:a,end:o}=$w(e,t),{path:s}=eT(a,o);return(0,Z.jsx)(`g`,{"data-testid":r,children:(0,Z.jsx)(`path`,{d:s,className:n,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,markerEnd:i})})},$J=({preview:e,cardRects:t,ticketsById:n,overlaySize:r})=>{if(!e)return null;let i=t[e.blockerTicketId];if(!i)return null;let a=(e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId&&t[e.hoveredTicketId]?t[e.hoveredTicketId]:null)??{left:e.pointer.x,top:e.pointer.y,width:0,height:0},o=ZJ(e,i,n,t,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(QJ,{blockerRect:i,dependentRect:a,className:VJ.preview.className,testId:`dependency-preview`,markerEnd:`url(#${VJ.preview.markerId})`}),(e=>o?(0,Z.jsx)(`foreignObject`,{x:o.x,y:o.y,width:o.width,height:GJ,"data-testid":`dependency-preview-label`,children:e}):null)((0,Z.jsx)(`div`,{className:`pointer-events-none flex h-full w-full items-start`,children:(0,Z.jsx)(`div`,{className:`max-w-full rounded-md border border-amber-300/60 bg-stone-950/85 px-3 py-1.5 text-xs font-medium leading-5 text-amber-100 shadow-lg shadow-stone-950/20 whitespace-normal break-words`,children:o?.text})}))]})},eY=({dependencies:e,cardRects:t,preview:n,ticketsById:r,overlaySize:i})=>(0,Z.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 z-10 h-full w-full overflow-visible`,children:[(0,Z.jsx)(`defs`,{children:Object.values(VJ).map(e=>(0,Z.jsx)(`marker`,{id:e.markerId,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,markerUnits:`userSpaceOnUse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8`,className:e.className,fill:`none`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})},e.markerId))}),e.map(e=>{let n=r.get(e.blocker_ticket_id),i=r.get(e.dependent_ticket_id),a=t[e.blocker_ticket_id],o=t[e.dependent_ticket_id];if(n?.parked_at||i?.parked_at)return null;let s=VJ[HJ(n)];return!a||!o?null:(0,Z.jsx)(QJ,{blockerRect:a,dependentRect:o,className:s.className,testId:`dependency-edge-${e.blocker_ticket_id}-${e.dependent_ticket_id}`,markerEnd:`url(#${s.markerId})`},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`)}),(0,Z.jsx)($J,{preview:n,cardRects:t,ticketsById:r,overlaySize:i})]}),tY=({onSubmit:e,bundles:t,projectId:n=null,projectBranchState:r=null,tool:i,showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialModel:c=``,initialVariant:l=``,initialSkills:u=[],initialWorktreeBundleId:d=null,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,onClose:h})=>{let{t:g}=X(`common`),{jiraImportState:_,importFromJira:v}=hf(n);return(0,Z.jsx)(du,{onClose:h,overlayClassName:`bg-black/60`,panelClassName:`h-[92vh] w-[96vw] max-w-6xl overflow-y-auto rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,renderContent:({closeButton:y})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:y}),(0,Z.jsx)(rP,{heading:g(`newTicketModal.heading`),bundles:t,showModelSelector:a,availableModels:o,availableSkills:s,projectId:n,initialModel:c,initialVariant:l,initialSkills:u,initialWorktreeBundleId:d,projectBranchState:r,jiraImportState:_,onImportFromJira:v,onCancel:h,onCreateBundle:f,onDeleteBundle:p,onRefreshBundles:m,titleInputId:`title`,descriptionInputId:`description`,bundleSelectId:`new-ticket-bundle`,modelSelectId:`new-model`,variantSelectId:`new-variant`,skillsSelectId:`new-skills`,showEmptyBundleOption:!0,planAction:i?{label:g(`newTicketModal.actions.plan`),onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`plan`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}}:void 0,primaryAction:{label:g(`newTicketModal.actions.createTicket`),variant:`subtle`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`create`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}},secondaryAction:{label:g(`newTicketModal.actions.createAndBuild`),variant:`brand`,showAdvanceIcon:!0,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`build`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),h()}}})]})})},nY=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},rY=e=>e.status===`error`?`border-red-500/35 bg-red-500/10`:e.status===`done`?e.boardState===`fading`?`border-emerald-500/25 bg-emerald-500/10 opacity-0 transition-opacity duration-700`:`border-emerald-500/35 bg-emerald-500/10`:`border-violet-500/30 bg-card/60`,iY=({run:e})=>(0,Z.jsxs)(mu,{"data-testid":`planning-run-card-${e.id}`,className:`relative overflow-hidden rounded-xl border shadow-none ${rY(e)}`,children:[e.status===`running`&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-0 h-1 animate-pulse bg-gradient-to-r from-violet-500/0 via-violet-300/80 to-violet-500/0`}),(0,Z.jsxs)(yu,{className:`space-y-3 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[e.status===`running`?(0,Z.jsx)(rT,{label:`Planning...`}):e.status===`done`?(0,Z.jsx)(rT,{label:`Done`,className:`bg-emerald-500/85 text-emerald-50`}):(0,Z.jsx)(rT,{label:`Planning failed`,className:`bg-red-500/85 text-red-50`}),(0,Z.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.16em] text-muted-foreground`,children:nY(e.submittedAt)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),e.status===`done`&&e.summary&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Created `,e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]}),e.status===`error`&&e.error&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-200`,children:e.error})]})]})]}),aY={idle:`bg-secondary`,running:`bg-sky-400`,done:`bg-emerald-400`,error:`bg-red-400`},oY=e=>e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`done`)?`done`:`idle`,sY=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},cY=({status:e})=>{let{t}=X(`common`);return e===`running`?(0,Z.jsx)(rT,{label:t(`planningAgentSidebar.runStatus.planning`),className:`px-2.5 py-0.5 text-[11px]`}):e===`done`?(0,Z.jsx)(U,{className:`bg-emerald-500/85 px-2.5 py-0.5 text-[11px] text-emerald-50`,children:t(`planningAgentSidebar.runStatus.done`)}):(0,Z.jsx)(U,{className:`bg-red-500/85 px-2.5 py-0.5 text-[11px] text-red-50`,children:t(`planningAgentSidebar.runStatus.failed`)})},lY=({heading:e,runs:t})=>{let{t:n}=X(`common`);return t.length===0?null:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:t.map(e=>(0,Z.jsx)(mu,{className:`rounded-2xl border-border bg-card/70 shadow-none`,children:(0,Z.jsxs)(yu,{className:`space-y-2 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),(0,Z.jsx)(cY,{status:e.status})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:sY(e.submittedAt)}),e.summary&&(0,Z.jsxs)(`span`,{children:[n(`planningAgentSidebar.runSummary.tickets`,{count:e.summary.ticketCount}),`, `,n(`planningAgentSidebar.runSummary.dependencies`,{count:e.summary.dependencyCount}),e.summary.ticketsWithOpenQuestions>0?`, ${n(`planningAgentSidebar.runSummary.openQuestions`,{count:e.summary.ticketsWithOpenQuestions})}`:``]})]}),e.error&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-destructive/15 px-3 py-2 text-xs text-red-200`,children:e.error})]})},e.id))})]})},uY=({projectId:e=null,state:t,bundles:n,showModelSelector:r,availableModels:i,availableSkills:a,onManageBundles:o,onToggle:s,onDescriptionChange:c,onModelChange:l,onVariantChange:u,onSkillsChange:d,onBundleChange:f,onGenerate:p})=>{let{t:m}=X(`common`),h=i.find(e=>e.id===t.composer.model)??null,{jiraImportState:g,importFromJira:_}=hf(t.isOpen?e:null),v=(0,Y.useRef)(null),y=(0,Y.useRef)(t.isOpen),b=(0,Y.useRef)(t.isOpen),x=oY(t.runs),S=t.runs.filter(e=>e.status===`running`),C=t.runs.filter(e=>e.status!==`running`),w=t.composer.description.trim().length>0,T=m(`planningAgentSidebar.actions.planTickets`);(0,Y.useEffect)(()=>{if(t.isOpen&&!y.current&&(b.current=!0),t.isOpen||(b.current=!1),y.current=t.isOpen,!t.isOpen||!b.current)return;let e=window.requestAnimationFrame(()=>{let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`[data-testid="planning-agent-rail"]`)!==null;if(e instanceof HTMLElement&&e!==document.body&&e!==v.current&&!t){b.current=!1;return}v.current?.focus({preventScroll:!0}),b.current=!1});return()=>{window.cancelAnimationFrame(e)}},[t.isOpen]),(0,Y.useEffect)(()=>{if(!t.isOpen)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),s())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[s,t.isOpen]);let E=(0,Z.jsxs)(K,{type:`button`,"aria-label":t.isOpen?m(`planningAgentSidebar.actions.closeAriaLabel`):m(`planningAgentSidebar.actions.openAriaLabel`),"aria-pressed":t.isOpen,onClick:s,variant:`outline`,className:`relative flex h-14 w-11 flex-col items-center justify-center gap-1 p-0`,children:[(0,Z.jsx)(Wd,{className:`size-5`}),(0,Z.jsx)(pw,{"aria-hidden":`true`,children:`A`}),(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-2.5 w-2.5 rounded-full ring-2 ring-card ${aY[x]}`})]});return(0,Z.jsxs)(`aside`,{"aria-label":m(`planningAgentSidebar.ariaLabel`),className:`relative z-20 h-full w-16 shrink-0 overflow-visible border-r border-border bg-background`,children:[(0,Z.jsx)(`div`,{"data-testid":`planning-agent-rail`,className:`relative z-40 flex h-full w-16 shrink-0 flex-col items-center border-r border-border bg-background py-4`,children:t.isOpen?E:(0,Z.jsx)(yc,{content:m(`planningAgentSidebar.tooltip`),children:E})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-drawer`,"aria-hidden":!t.isOpen,inert:!t.isOpen||void 0,className:G(`absolute inset-y-0 left-16 z-30 w-[min(36rem,calc(100vw-5rem))] overflow-hidden transition-transform duration-200 ease-out motion-reduce:transition-none`,t.isOpen?`pointer-events-auto translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,Z.jsxs)(`div`,{className:`flex h-full w-[min(36rem,calc(100vw-5rem))] flex-col border-r border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-border px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:m(`planningAgentSidebar.title`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:m(`planningAgentSidebar.description`)})]}),(0,Z.jsx)(K,{type:`button`,"aria-label":m(`planningAgentSidebar.actions.closePanelAriaLabel`),onClick:s,variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(Be,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-scroll-body`,className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`space-y-5 px-6 py-5`,children:[(0,Z.jsx)($N,{jiraImportState:g,onImportFromJira:_,onImported:e=>{c(e.description)},inputId:`planning-agent-jira-import`}),(0,Z.jsx)(xu,{label:m(`planningAgentSidebar.descriptionLabel`),htmlFor:`planning-agent-description`,className:`gap-2`,children:(0,Z.jsx)(`div`,{className:`relative`,children:(0,Z.jsx)(Zp,{ref:v,projectId:e,suggestionAnchor:`caret`,id:`planning-agent-description`,"aria-label":m(`planningAgentSidebar.descriptionAriaLabel`),value:t.composer.description,onValueChange:c,rows:14,className:`min-h-[18rem] resize-y text-sm leading-6`,placeholder:m(`planningAgentSidebar.descriptionPlaceholder`)})})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(eP,{bundles:n,value:t.composer.worktreeBundleId,onChange:f,selectId:`planning-agent-bundle`,emptyLabel:m(`planningAgentSidebar.autoCreateBundle`),hideProjectRootBundles:!0,label:``})}),o&&(0,Z.jsx)(K,{type:`button`,onClick:o,variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`,children:m(`planningAgentSidebar.actions.manageBundles`)})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:(0,Z.jsx)(XN,{model:t.composer.model,variant:t.composer.variant,skills:t.composer.skills,showModelSelector:r,showSkillsSelector:r,availableModels:i,availableSkills:a,selectedModel:h,onModelChange:l,onVariantChange:u,onSkillsChange:d,modelSelectId:`planning-agent-model`,variantSelectId:`planning-agent-variant`,skillsSelectId:`planning-agent-skills`,layout:`stacked`})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-runs`,className:`border-t border-border/80 px-0 pt-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(lY,{heading:m(`planningAgentSidebar.activeRuns`),runs:S}),(0,Z.jsx)(lY,{heading:m(`planningAgentSidebar.recentRuns`),runs:C})]})})]})}),(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border px-6 py-4`,children:(0,Z.jsx)(K,{type:`button`,onClick:p,disabled:!w,className:`w-full`,children:T})})]})})]})},dY=({className:e=``})=>{let{setNodeRef:t,isOver:n}=ew({id:`trash`});return(0,Z.jsxs)(`div`,{ref:t,"data-testid":`delete-drop-zone`,className:`${e} flex min-w-[13rem] select-none items-center justify-between gap-4 rounded-2xl border px-4 py-3 backdrop-blur-sm transition-all duration-150 ${n?`scale-[1.02] border-red-400/70 bg-destructive/35 text-red-100 shadow-lg shadow-red-950/30`:`border-red-500/30 bg-background/82 text-red-200/85`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(U,{variant:`destructive`,className:`text-[11px] uppercase tracking-[0.28em]`,children:`Delete`}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:n?`Release to delete`:`Drop here to delete`})]}),(0,Z.jsx)(`div`,{className:`rounded-xl border p-2 transition-colors ${n?`border-red-400/60 bg-red-500/20`:`border-red-500/20 bg-background/60`}`,children:(0,Z.jsx)(Su,{className:`h-5 w-5 transition-colors ${n?`text-red-100`:`text-red-300/70`}`})})]})},fY=(e,t)=>q(E(`/ticket-dependencies`,e),{signal:t}),pY=(e,t)=>q(E(`/ticket-dependencies`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create the dependency right now.`}),mY=(e,t,n)=>L(E(`/ticket-dependencies/${t}/${n}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to remove the dependency right now.`}),hY=(e,t)=>{let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.left!==i.left||n.top!==i.top||n.width!==i.width||n.height!==i.height)return!1}return!0},gY=(e,t)=>e===t?!0:!e||!t?!1:e.projectId===t.projectId&&e.blockerTicketId===t.blockerTicketId&&e.hoveredTicketId===t.hoveredTicketId&&e.pointer.x===t.pointer.x&&e.pointer.y===t.pointer.y,_Y=({activeProjectId:e,tickets:t,dependencies:n,setDependencies:r,activeTicket:i,activeOverlayNode:a,dragOffset:o})=>{let[s,c]=(0,Y.useState)({}),[l,u]=(0,Y.useState)({width:0,height:0}),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(new Map),y=(0,Y.useRef)({}),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useRef)(null),T=(0,Y.useRef)(null),E=(0,Y.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);(0,Y.useEffect)(()=>{C.current=p},[p]),(0,Y.useLayoutEffect)(()=>{if(!i||!a||!g.current)return;let e=window.requestAnimationFrame(()=>{let e=g.current?.getBoundingClientRect(),t=a.getBoundingClientRect();e&&f({ticketId:i.id,rect:{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}})});return()=>{window.cancelAnimationFrame(e)}},[a,i,o.x,o.y]);let D=(0,Y.useCallback)(()=>{b.current===null&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=g.current;if(!e){_.current=null,y.current={},c({}),u({width:0,height:0});return}let t=e.getBoundingClientRect(),n={};_.current={left:t.left,top:t.top},u(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height});for(let[e,r]of v.current){let i=r.getBoundingClientRect();n[e]={left:i.left-t.left,top:i.top-t.top,width:i.width,height:i.height}}y.current=n,c(e=>hY(e,n)?e:n)}))},[]);(0,Y.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{D()};return e.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[D]),(0,Y.useEffect)(()=>{if(typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(()=>{D()});x.current=e;for(let t of v.current.values())e.observe(t);return()=>{e.disconnect(),x.current===e&&(x.current=null)}},[D]),(0,Y.useEffect)(()=>{let e=h.current,t=g.current;if(!e&&!t)return;let n=new ResizeObserver(()=>{D()});return e&&n.observe(e),t&&t!==e&&n.observe(t),()=>{n.disconnect()}},[D]),(0,Y.useEffect)(()=>(D(),()=>{b.current!==null&&(window.cancelAnimationFrame(b.current),b.current=null)}),[n,D,t]);let k=(0,Y.useCallback)((e,t)=>{let n=v.current.get(e);if(t){if(n===t)return;v.current.set(e,t),x.current?.observe(t)}else{if(!n)return;v.current.delete(e),x.current?.unobserve(n)}D()},[D]),A=(0,Y.useCallback)(e=>{gY(C.current,e)||(C.current=e,m(e))},[]),j=(0,Y.useCallback)(()=>{w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),T.current=null},[]),M=(0,Y.useCallback)(e=>{T.current=e,w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null;let e=T.current;T.current=null,A(e)}))},[A]),N=(0,Y.useCallback)((e,t)=>{let n=_.current;if(!n&&g.current){let e=g.current.getBoundingClientRect();n={left:e.left,top:e.top},_.current=n}return n?{x:e-n.left,y:t-n.top}:{x:e,y:t}},[]),P=(0,Y.useCallback)((e,t,n)=>{for(let[r,i]of Object.entries(y.current))if(r!==n&&e>=i.left&&e<=i.left+i.width&&t>=i.top&&t<=i.top+i.height)return r;return null},[]),F=(0,Y.useCallback)(async t=>{if(e)try{await mY(e,t.blocker_ticket_id,t.dependent_ticket_id),r(e=>Vw(e,t.blocker_ticket_id,t.dependent_ticket_id))}catch(e){Q.error(e instanceof O?e.message:`Unable to remove the dependency right now.`,{id:`board-dependency-error`})}},[e,r]),I=(0,Y.useCallback)((t,i)=>{if(!e)return;i.preventDefault(),S.current?.();let a=(n,r,i=!1)=>{let a=N(n,r),o={projectId:e,blockerTicketId:t,hoveredTicketId:P(a.x,a.y,t),pointer:a};if(i){j(),A(o);return}M(o)};a(i.clientX,i.clientY,!0);let o=e=>{a(e.clientX,e.clientY)},s=async i=>{let a=N(i.clientX,i.clientY),o=P(a.x,a.y,t),s=o?Uw(n,t,o):null;if(S.current?.(),S.current=null,A(null),!(!o||!s)){if(!s.valid){Q.error(Ww(s.reason),{id:`board-dependency-error`});return}try{let n=await pY(e,{blocker_ticket_id:t,dependent_ticket_id:o});r(e=>Bw(e,n))}catch(e){Q.error(e instanceof O?e.message:`Unable to create the dependency right now.`,{id:`board-dependency-error`})}}};S.current=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),j()},window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0})},[e,j,n,P,N,M,r,A]);(0,Y.useEffect)(()=>{S.current?.(),S.current=null,j(),C.current=null},[e,j]),(0,Y.useEffect)(()=>()=>{S.current?.(),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]);let L=(0,Y.useMemo)(()=>{let r=p?.blockerTicketId;if(!r||p.projectId!==e||!E.has(r))return null;let i=new Map;for(let e of t){if(e.id===r){i.set(e.id,`source`);continue}let t=Uw(n,r,e.id);i.set(e.id,t.valid?`valid`:`idle`)}return i},[e,n,p,E,t]),R=(0,Y.useCallback)(e=>{if(!L||!p)return`idle`;let t=L.get(e)??`idle`;return e===p.hoveredTicketId&&t===`idle`?`invalid`:t},[L,p]),z=(0,Y.useMemo)(()=>!p||p.projectId!==e||!E.has(p.blockerTicketId)?null:{blockerTicketId:p.blockerTicketId,hoveredTicketId:p.hoveredTicketId,pointer:p.pointer},[e,p,E]);return{boardViewportRef:h,boardContentRef:g,registerTicketNode:k,measuredCardRects:(0,Y.useMemo)(()=>{if(!i)return s;let e=s[i.id];return e?d?.ticketId===i.id?{...s,[i.id]:d.rect}:{...s,[i.id]:{...e,left:e.left+o.x,top:e.top+o.y}}:s},[d,i,s,o.x,o.y]),overlayPreview:z,overlaySize:l,getDependencyTargetState:R,handleDependencyStart:I,handleDeleteDependency:F}},vY=e=>{if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.id==`string`?t.id:``,r=typeof t.name==`string`?t.name:``,i=typeof t.command==`string`?t.command:``,a=typeof t.cwd==`string`?t.cwd:``,o=t.runner===`vitest`||t.runner===`jest`||t.runner===`unknown`?t.runner:`auto`;return n.trim()===``||r.trim()===``&&i.trim()===``&&a.trim()===``?[]:[{id:n,name:r,command:i,cwd:a,runner:o}]}):[]}catch{return[]}},yY=`[data-terminal-pane="true"]`,bY=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||e.isContentEditable},xY=e=>e instanceof HTMLElement?e.closest(yY)!==null:!1,SY=e=>bY(e)||xY(e),CY=(e,t={})=>{let{isBlocked:n}=t;(0,Y.useEffect)(()=>{let t=t=>{if(t.defaultPrevented||t.repeat)return;let r=e.find(e=>!e.disabled&&e.key.toLowerCase()===t.key.toLowerCase()&&(e.ctrlKey??!1)===t.ctrlKey&&(e.altKey??!1)===t.altKey&&(e.metaKey??!1)===t.metaKey&&(e.shiftKey===void 0||e.shiftKey===t.shiftKey));r&&(n?.(document.activeElement)||(t.preventDefault(),r.onKeyDown()))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,n])},wY=e=>({...e,messages:void 0,agent_log:void 0,streaming_response:void 0}),TY=(e,t)=>e?e.state!==t.state||e.parked_at!==t.parked_at||e.worktree_bundle_id!==t.worktree_bundle_id:!0,EY=(e,t)=>{if(!e)return t;let n=t.worktree_bundle_id!==null&&e.worktree_bundle_id===t.worktree_bundle_id,r=t.bundle??(n&&e.bundle?.id===t.worktree_bundle_id?e.bundle:null),i=t.bundle_execution_position??(n?e.bundle_execution_position??null:null);return{...e,...t,bundle:r,bundle_execution_position:i}},DY=(e,t)=>{let n=e=>Ew(t)?Ew(e):e.state===t.state&&!Ew(e),r=e.findIndex(e=>n(e));if(r===-1)return[...e,t];let i=[...e];return i.splice(r,0,t),i},OY=(e,t)=>{let n=e.find(e=>e.id===t.id);return[n&&n.pull_request!==void 0&&t.pull_request===void 0?{...n,...t,pull_request:n.pull_request}:t,...e.filter(e=>e.id!==t.id)]},kY=(e,t)=>{let n=e.find(e=>e.id===t.id);if(!n)return[...e,t];let r=EY(n,t);return e.map(e=>e.id===t.id?r:e)},AY=(e,t)=>{let n=EY(e.find(e=>e.id===t.id),t);return DY(MY(e,t.id),n)},jY=(e,t)=>{if(e.length===0)return[...t];let n=[...e];for(let e of t)n=TY(n.find(t=>t.id===e.id),e)?AY(n,e):kY(n,e);let r=new Set(t.map(e=>e.id));return n.filter(e=>r.has(e.id))},MY=(e,t)=>e.filter(e=>e.id!==t),NY=(e,t,n,r={},i={})=>{let a=e.findIndex(e=>e.id===t);if(a===-1)return e;let o={...e[a],state:n,...r},s=MY(e,t);if(i.preferredIndex!==void 0){let e=Math.max(0,Math.min(i.preferredIndex,s.length));return s.splice(e,0,o),s}return DY(s,o)},PY=async(e,t)=>{`Notification`in window&&Notification.permission!==`denied`&&(Notification.permission===`default`&&await Notification.requestPermission(),Notification.permission===`granted`&&new Notification(e,{body:t}))},FY=(0,Y.createContext)(VW),IY=()=>(0,Y.useContext)(FY),LY=(0,Y.createContext)(null),RY=15*1e3,zY=1e3,BY=async e=>PY(`Ticket done`,e),VY=e=>wY(e),HY=(e,t)=>t===`running`&&e.agent_status===`done`?`Finished ${e.state} for "${e.title}"`:t===`running`&&e.agent_status===`error`?`Failed ${e.state} for "${e.title}"`:t!==`running`&&e.agent_status===`running`?`Running ${e.state} for "${e.title}"`:null,UY=({activeProjectId:e,refreshKey:t=0,onLoadedProjectIdChange:n,onProjectUsageChange:r,onBundlesChange:i,onBundlesLoadingChange:a,children:o})=>{let s=IY(),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)([]),[f,p]=(0,Y.useState)([]),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(null),[C,w]=(0,Y.useState)(null),T=(0,Y.useRef)(0),E=(0,Y.useRef)(0),D=(0,Y.useRef)(new Map),O=(0,Y.useRef)(new Map),k=(0,Y.useRef)(e),A=(0,Y.useRef)(new Map),j=(0,Y.useRef)(new Map),M=(0,Y.useRef)(new Map),N=(0,Y.useCallback)((e,t)=>{let n=j.current.get(t.id);return!n||!e||t.state===n?t:e},[]),P=(0,Y.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(j.current);for(let r of e)n.set(r,t);j.current=n},[]),F=(0,Y.useCallback)(e=>{if(e.length===0||j.current.size===0)return;let t=new Map(j.current);for(let n of e)t.delete(n);j.current=t},[]),I=(0,Y.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(M.current);for(let r of e)n.set(r,t);M.current=n},[]),L=(0,Y.useCallback)(e=>{if(e.length===0||M.current.size===0)return;let t=new Map(M.current);for(let n of e)t.delete(n);M.current=t},[]),R=(0,Y.useCallback)((e,t)=>{if(A.current.has(t.id))return null;let n=N(e,t);return M.current.has(t.id)?{...n,parked_at:M.current.get(t.id)??null}:n},[N]),z=(0,Y.useCallback)((e,t)=>{if(A.current.size===0&&j.current.size===0&&M.current.size===0)return t;let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=R(n.get(e.id),e);return t?[t]:[]})},[R]),B=(0,Y.useCallback)(async(e,t)=>{let n=await Wt(e,t,{detail:`board`});return Array.isArray(n)?(!t?.aborted&&k.current===e&&l(e=>jY(e,z(e,n).map(VY))),n):null},[z]),ee=(0,Y.useCallback)(async(e,t)=>{await B(e,t)},[B]),te=(0,Y.useCallback)(async(e,t)=>{let n=++E.current,r=await Gt(e,t);if(!Array.isArray(r)||t?.aborted||k.current!==e||E.current!==n)return;let i=new Map(r.map(e=>[e.id,e]));l(e=>e.map(e=>{let t=i.get(e.id);return t?{...e,diff_stats:t.diff_stats??null,is_stale:t.is_stale}:e}))},[]),ne=(0,Y.useCallback)(e=>e.some(e=>e.is_stale===void 0),[]),V=(0,Y.useCallback)(async e=>{let t=k.current;if(!t)return null;try{let n=await Kt(e,t);if(k.current!==t)return null;let r=O.current.get(n.id),i=R(r,n);if(!i)return null;let a=VY(i),o=TY(r,a);return l(e=>o?AY(e,a):kY(e,a)),n}catch{return null}},[R]),re=(0,Y.useCallback)(async t=>{if(!e){p([]);return}p(await Ct(e,t))},[e]),H=(0,Y.useMemo)(()=>new Map(c.map(e=>[e.id,e])),[c]),ie=(0,Y.useMemo)(()=>{let e=c.filter(e=>e.agent_status===`running`),t=new Set(e.map(e=>e.worktree_bundle_id).filter(e=>typeof e==`string`&&e.trim().length>0));return{total_running:e.length,running_plan_count:e.filter(e=>e.state===`plan`).length,running_build_count:e.filter(e=>e.state===`build`).length,running_review_count:e.filter(e=>e.state===`review`).length,active_bundle_count:t.size,latest_message:C}},[C,c]);(0,Y.useEffect)(()=>{O.current=H},[H]),(0,Y.useEffect)(()=>{k.current=e,A.current.clear(),j.current.clear(),M.current.clear(),w(null),h(null),D.current.clear()},[e]),(0,Y.useEffect)(()=>{n?.(v?null:g)},[g,v,n]),(0,Y.useEffect)(()=>{if(i){if(!e){i(null,[]);return}if(g!==e){i(e,[]);return}i(e,f)}},[e,f,g,i]),(0,Y.useEffect)(()=>{if(a){if(!e){a(null,!1);return}a(e,b===e)}},[e,b,a]),(0,Y.useEffect)(()=>{let t=new AbortController,n=++T.current,r=null,i=async()=>{try{if(!e){l([]),d([]),p([]),_(null),y(null);return}l([]),d([]),p([]),_(null),y(e),x(e);let[n,i,a]=await Promise.allSettled([B(e,t.signal),fY(e,t.signal),Ct(e,t.signal)]);if(t.signal.aborted)return;n.status!==`fulfilled`&&!S(n.reason)&&l([]),i.status===`fulfilled`?d(i.value):S(i.reason)||d([]),a.status===`fulfilled`?p(a.value):S(a.reason)||p([]),_(n.status===`fulfilled`&&i.status===`fulfilled`&&a.status===`fulfilled`?e:null),n.status===`fulfilled`&&n.value!==null&&ne(n.value)&&(r=window.setTimeout(()=>{t.signal.aborted||te(e,t.signal)},zY))}finally{!t.signal.aborted&&T.current===n&&(y(null),x(null))}},a=t=>{t.project_id===e&&(h(t),!A.current.has(t.id)&&(t.bundle&&p(e=>OY(e,t.bundle)),l(e=>AY(e,VY(t)))))},o=t=>{if(t.project_id===e&&h(t),l(n=>{if(t.project_id!==e)return MY(n,t.id);let r=n.find(e=>e.id===t.id),i=R(r,t);if(!i)return n;let a=VY(i);return TY(r,a)?AY(n,a):kY(n,a)}),t.project_id!==e){d(e=>zw(e,t.id));return}t.bundle&&p(e=>OY(e,t.bundle))},c=({id:e})=>{A.current.delete(e),M.current.delete(e),j.current.delete(e),l(t=>MY(t,e)),d(t=>zw(t,e))},u=e=>{if(!e)return;let t=O.current.get(e.blocker_ticket_id),n=O.current.get(e.dependent_ticket_id);!t||!n||t.project_id!==k.current||n.project_id!==k.current||d(t=>Bw(t,e))},f=e=>{d(t=>Vw(t,e.blocker_ticket_id,e.dependent_ticket_id))};return i(),s.on(`ticket:created`,a),s.on(`ticket:updated`,o),s.on(`ticket:deleted`,c),s.on(`ticket-dependency:created`,u),s.on(`ticket-dependency:deleted`,f),()=>{t.abort(),r!==null&&window.clearTimeout(r),s.off(`ticket:created`,a),s.off(`ticket:updated`,o),s.off(`ticket:deleted`,c),s.off(`ticket-dependency:created`,u),s.off(`ticket-dependency:deleted`,f)}},[e,te,t,ne,B,R,s]),(0,Y.useEffect)(()=>{if(!e)return;let t=new AbortController,n=()=>{document.visibilityState===`visible`&&Promise.allSettled([B(e,t.signal),re(t.signal)]).then(n=>{n[0]?.status===`fulfilled`&&n[0].value!==null&&ne(n[0].value)&&te(e,t.signal)}).catch(()=>{})},r=window.setInterval(n,RY),i=rq(n);return()=>{t.abort(),window.clearInterval(r),i()}},[e,re,te,ne,B]),(0,Y.useEffect)(()=>{if(!e||!r||g!==e)return;let t=c.filter(e=>{let t=e.bundle?.branch??e.branch;return typeof t==`string`&&t.trim()!==``}).length;r({projectId:e,ticketCount:c.length,worktreeCount:t,repoPathLocked:c.length>0||t>0||f.length>0})},[e,f.length,g,r,c]),(0,Y.useEffect)(()=>{for(let e of c){let t=D.current.get(e.id),n=HY(e,t);n&&w(n),t!==void 0&&t===`running`&&e.agent_status===`done`&&(e.state===`plan`||e.state===`build`||e.state===`review`)&&BY(e.title),D.current.set(e.id,e.agent_status)}},[c]);let ae=(0,Y.useCallback)(()=>{h(null)},[]),oe=(0,Y.useMemo)(()=>({tickets:c,setTickets:l,dependencies:u,setDependencies:d,bundles:f,setBundles:p,latestDetailedTicketUpdate:m,clearLatestDetailedTicketUpdate:ae,loadedProjectId:g,loadingProjectId:v,activeProjectIdRef:k,pendingDeletedTicketsRef:A,pendingOptimisticMovesRef:j,pendingParkedTicketsRef:M,refreshTickets:ee,requestSingleTicketRefresh:V,refreshBundles:re,resolvePendingTicket:R,resolvePendingTickets:z,markPendingOptimisticMoves:P,clearPendingOptimisticMoves:F,markPendingParkedTickets:I,clearPendingParkedTickets:L,liveActivity:ie}),[f,ae,F,L,u,ie,g,m,v,P,I,re,ee,V,R,z,c]);return(0,Z.jsx)(LY.Provider,{value:oe,children:o})},WY=()=>{let e=(0,Y.useContext)(LY);if(!e)throw Error(`useProjectWorkspace must be used inside ProjectWorkspaceProvider`);return e},GY=(0,Y.lazy)(()=>$W(()=>import(`./TestsDialog-uqH8RzXV.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),KY=`archon.last-model-selection`,qY=`archon.last-variant-selection`,JY=`archon.last-skills-selection`,YY=()=>{try{let e=window.localStorage.getItem(JY),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},XY=e=>[e.title,e.description,e.bundle?.name??``,e.bundle?.branch??``,e.branch??``].map(e=>e.toLowerCase()),ZY=(e,t)=>{let n=e.bundle_execution_position??2**53-1,r=t.bundle_execution_position??2**53-1;if(n!==r)return n-r;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let i=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return i===0?e.id.localeCompare(t.id):i},QY=(e,t)=>t?{...e,...t,messages:t.messages===void 0?e.messages:t.messages,agent_log:t.agent_log===void 0?e.agent_log:t.agent_log,streaming_response:t.streaming_response===void 0?e.streaming_response:t.streaming_response}:e,$Y=(e,t)=>{let n=e.toLowerCase().trim().split(/\s+/).filter(Boolean);if(n.length===0)return!0;let r=XY(t);return n.every(e=>r.some(t=>t.includes(e)))},eX=[`plan`,`build`,`review`],tX=`done`,nX=()=>({build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1,bundleRefresh:!1}),rX=({bundleId:e,activeRunContextKey:t,isProjectRootRunActive:n})=>n?!0:t!==null&&t!==e,iX=(e,t)=>{if(!e)return null;let n=t.find(t=>t.id===e.ticket_id);return n?ww(n):e.ticket_id},aX=()=>({description:``,model:window.localStorage.getItem(KY)??``,variant:window.localStorage.getItem(qY)??``,skills:YY(),worktreeBundleId:``}),oX=()=>({isOpen:!1,composer:aX(),runs:[]}),sX=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`planning-run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,cX=e=>({ticketCount:e.tickets.length,dependencyCount:e.dependencies.length,ticketsWithOpenQuestions:e.tickets.filter(e=>(e.planning_context?.open_questions.length??0)>0).length,ticketTitles:e.tickets.map(e=>e.title),ticketIds:e.tickets.map(e=>e.id)}),lX=(e,t,n)=>e.map(e=>e.id===t?n(e):e),uX=(e,t,n)=>{e?window.localStorage.setItem(KY,e):window.localStorage.removeItem(KY),t?window.localStorage.setItem(qY,t):window.localStorage.removeItem(qY),n.length>0?window.localStorage.setItem(JY,JSON.stringify(n)):window.localStorage.removeItem(JY)},dX=(e,t={})=>yl(e,t),fX=()=>({model:window.localStorage.getItem(KY)??``,variant:window.localStorage.getItem(qY)??``,skills:YY()}),pX=(e,t)=>{let n=MY(e,t.ticket.id),r=Math.max(0,Math.min(t.index,n.length));return n.splice(r,0,t.ticket),n},mX=e=>e.tickets.length>0&&e.tickets.every(e=>Nw(e,`trash`)),hX=e=>e.tickets.length>0&&e.tickets.every(e=>Nw(e,tX)),gX=e=>e.column===tX&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),_X=(e,t,n,r)=>n||t!==null&&t!==ww(e)?r:qw(e),vX=(e,t)=>t===`build`?{agent_status:null,agent_log:null,streaming_response:null,build_completed_at:null,planning_context:e.planning_context?{...e.planning_context,open_questions:[]}:null}:t===`review`?{agent_status:null,agent_log:null,streaming_response:null}:{},yX=(e,t)=>e===`plan`&&t===`build`?`build`:e===`build`&&t===`review`?`review`:e===`review`&&t===`build`?`undoReview`:null,bX=(e,t,n)=>t===`review`&&n===`build`?{}:vX(e,n),xX=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:a,onRunStopped:o,onRunStatusChange:s,refreshKey:c=0})=>{let{t:l}=X(`common`),u=qx(Kx(YS,{activationConstraint:{distance:5}})),{tickets:d,setTickets:f,dependencies:p,setDependencies:m,bundles:h,setBundles:g,latestDetailedTicketUpdate:_,clearLatestDetailedTicketUpdate:v,loadedProjectId:y,loadingProjectId:b,activeProjectIdRef:x,pendingDeletedTicketsRef:C,requestSingleTicketRefresh:w,refreshBundles:T,resolvePendingTicket:E,markPendingOptimisticMoves:D,clearPendingOptimisticMoves:k,markPendingParkedTickets:A,clearPendingParkedTickets:j}=WY(),[M,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(null),[R,z]=(0,Y.useState)({x:0,y:0}),[B,ee]=(0,Y.useState)(null),[te,ne]=(0,Y.useState)(!1),[V,re]=(0,Y.useState)([]),[H,ie]=(0,Y.useState)([]),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)({}),[le,U]=(0,Y.useState)(!1),[ue,de]=(0,Y.useState)(!1),[fe,pe]=(0,Y.useState)(null),[me,he]=(0,Y.useState)(null),[ge,W]=(0,Y.useState)(null),[_e,ve]=(0,Y.useState)(null),[ye,be]=(0,Y.useState)(null),[xe,Se]=(0,Y.useState)(null),[Ce,we]=(0,Y.useState)(null),[Te,Ee]=(0,Y.useState)(null),[De,Oe]=(0,Y.useState)(null),[ke,Ae]=(0,Y.useState)(null),[je,Me]=(0,Y.useState)(!1),[Ne,Pe]=(0,Y.useState)(nX()),[Fe,Ie]=(0,Y.useState)(0),[Le,Re]=(0,Y.useState)(``),[ze,Ve]=(0,Y.useState)(!1),He=i===`opencode`||ge?.tool===`opencode`||!!xe?.tickets.some(e=>e.tool===`opencode`),Ue=i===`opencode`&&V.length>0,Ge=ge?.tool===`opencode`&&V.length>0,Ke=!!xe?.tickets.some(e=>e.tool===`opencode`)&&V.length>0,qe=(0,Y.useRef)(e),Je=(0,Y.useRef)(null),Ye=(0,Y.useRef)(null),[Xe,Ze]=(0,Y.useState)(null),Qe=d.find(e=>e.is_running)??null,$e=Qe?ww(Qe):null,et=r?.context_key??null,q=r?.kind===`ticket`?iX(r,d)??$e:$e,J=r?.kind===`project`,tt=q??Xe,nt=(0,Y.useCallback)(e=>rX({bundleId:e,activeRunContextKey:tt,isProjectRootRunActive:J}),[tt,J]),rt=M!==null&&Nw(M,`trash`)||P!==null&&mX(P),it=b===e,at=(0,Y.useMemo)(()=>vY(t?.test_commands??null),[t?.test_commands]),ot=(0,Y.useCallback)(async e=>PY(l(`board.notifications.planningDoneTitle`),l(`board.notifications.planningDoneBody`,{count:e})),[l]),st=at.length>0,ct=(0,Y.useMemo)(()=>new Map(d.map(e=>[e.id,e])),[d]);(0,Y.useEffect)(()=>{Ze(null)},[e]),(0,Y.useEffect)(()=>{Xe!==null&&(J||q!==null)&&Ze(null)},[q,J,Xe]),(0,Y.useEffect)(()=>{if(!me){W(null);return}let e=ct.get(me)??null;e&&W(t=>!t||t.id!==me?e:QY(t,e))},[me,ct]),(0,Y.useEffect)(()=>{_&&(W(e=>!e||e.id!==_.id?e:QY(e,_)),Se(e=>{if(!e)return e;let t=_.worktree_bundle_id;if(!t||e.bundle.id!==t)return e;let n=e.tickets.some(e=>e.id===_.id)?e.tickets.map(e=>e.id===_.id?QY(e,_):e):[...e.tickets,_];return{...e,tickets:n}}))},[_]),(0,Y.useEffect)(()=>{_===null||me!==null||_e!==null||v()},[v,_,_e,me]);let lt=(0,Y.useCallback)(async e=>{let t=await w(e);if(!t)return null;let n=ct.get(e),r=n?QY(t,n):t;return W(t=>t&&t.id!==e||me&&me!==e?t:r),r},[w,me,ct]),ut=(0,Y.useCallback)(e=>{W(e),he(e.id),lt(e.id)},[lt]),dt=(0,Y.useMemo)(()=>new Map(h.map(e=>[e.id,e])),[h]),ft=(0,Y.useMemo)(()=>{if(!xe)return null;let e=xe.bundle.id,t=_?.worktree_bundle_id===e?_:null,n=d.filter(t=>t.worktree_bundle_id===e),r=new Map(n.map(e=>[e.id,e])),i=xe.tickets.filter(e=>!C.current.has(e.id)).map(e=>t&&e.id===t.id?QY(e,t):e);t&&!i.some(e=>e.id===t.id)&&!C.current.has(t.id)&&i.push(t);let a=i.map(e=>QY(e,r.get(e.id)));for(let e of n)a.some(t=>t.id===e.id)||a.push(e);a.sort(ZY);let o=xe.execution_order_ticket_ids??[],s=a.map(e=>e.id),c=[...o,...s].filter((e,t,n)=>s.includes(e)&&n.indexOf(e)===t),l=n.some(e=>e.can_re_review!==void 0||e.has_completed_review!==void 0||e.has_follow_up_since_last_review!==void 0),u=n.some(e=>e.agent_status===`running`),f={has_completed_review:n.some(e=>e.has_completed_review===!0),has_follow_up_since_last_review:n.some(e=>e.has_follow_up_since_last_review===!0),can_re_review:!u&&n.some(e=>e.can_re_review===!0)},p=gl(a),m=a.find(e=>e.id===xe.review_owner_ticket_id&&e.state===`review`)??a.find(e=>e.state===`review`)??null,h=yl(a,{targetTicketId:xe.target_ticket_id,reviewOwnerTicketId:m?.id??xe.review_owner_ticket_id,latestSessionTicketId:p?.id??xe.latest_session_ticket_id});return{...xe,bundle:dt.get(e)??xe.bundle,tickets:a,execution_order_ticket_ids:c,latest_session_ticket_id:p?.id??null,latest_session_id:p?.session_id??null,review_owner_ticket_id:m?.id??null,target_ticket_id:h?.id??null,has_completed_review:l?f.has_completed_review:xe.has_completed_review,has_follow_up_since_last_review:l?f.has_follow_up_since_last_review:xe.has_follow_up_since_last_review,can_re_review:l?f.can_re_review:xe.can_re_review}},[dt,_,C,xe,d]),pt=(0,Y.useMemo)(()=>d.filter(e=>ze&&Ow(e)?!1:$Y(Le,e)),[ze,Le,d]),mt=(0,Y.useMemo)(()=>pt.filter(e=>Ew(e)),[pt]),ht=(0,Y.useMemo)(()=>bl(mt,h,tX),[h,mt]),{boardViewportRef:gt,boardContentRef:_t,registerTicketNode:vt,measuredCardRects:yt,overlayPreview:bt,overlaySize:xt,getDependencyTargetState:St,handleDependencyStart:Ct,handleDeleteDependency:Dt}=_Y({activeProjectId:e,tickets:d,dependencies:p,setDependencies:m,activeTicket:M,activeOverlayNode:I,dragOffset:R}),Ot=e?se[e]??oX():oX(),kt=Ot.composer.worktreeBundleId&&h.some(e=>e.id===Ot.composer.worktreeBundleId)?Ot.composer.worktreeBundleId:``,Pt=kt===Ot.composer.worktreeBundleId?Ot:{...Ot,composer:{...Ot.composer,worktreeBundleId:kt}},Ft=fX(),It=!!t?.run_ide?.trim(),Bt=Pt.runs.filter(e=>e.boardVisible),Vt=(0,Y.useCallback)((e,t,n=d)=>{let r=bl(n,h,t).find(t=>t.kind===`bundle`&&t.group.bundle.id===e);return r?.kind===`bundle`?r.group:null},[h,d]),Ht=(0,Y.useCallback)(e=>(0,Z.jsx)(lG,{ticket:e,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:e.tool===`opencode`&&V.length>0,availableModels:V,runDisabled:!0,hideBundleScopedControls:!0}),[t?.memory_enabled,V,h,p,d]),Ut=Bt.length>0?(0,Z.jsx)(`div`,{className:`mb-0.5 flex flex-col gap-2.5`,children:Bt.map(e=>(0,Z.jsx)(iY,{run:e},e.id))}):null,Wt=(0,Y.useCallback)(t=>vl(t)?t.project_id===e?It:!!t.has_run_ide:!1,[It,e]),Gt=(0,Y.useCallback)(e=>!!e.project_id&&!!(e.bundle?.branch??e.branch)&&vl(e),[]),Kt=(0,Y.useCallback)(e=>{let t=e?.tickets.find(t=>t.id===e.target_ticket_id)??e?.tickets.find(e=>e.has_worktree)??null;return t?Wt(t):!1},[Wt]),Yt=(0,Y.useCallback)(e=>{let t=d.filter(t=>t.worktree_bundle_id===e).sort(ZY);return xe?.bundle.id===e?dX(xe.tickets.map(e=>t.find(t=>t.id===e.id)??e).sort(ZY),{targetTicketId:xe.target_ticket_id,reviewOwnerTicketId:xe.review_owner_ticket_id,latestSessionTicketId:xe.latest_session_ticket_id}):dX(t)},[xe,d]),Zt=(0,Y.useCallback)((e,t)=>{ce(n=>({...n,[e]:t(n[e]??oX())}))},[]);(0,Y.useEffect)(()=>{U(!1),de(!1),we(null),Ae(null),qe.current!==e&&(Je.current=e),e||(Je.current=null,Re(``)),qe.current=e},[e,c]),(0,Y.useLayoutEffect)(()=>{!e||y!==e||Je.current===e&&(Je.current=null,Re(``))},[e,y]),(0,Y.useEffect)(()=>{if(!He){ie([]);return}let t=new AbortController;return(async()=>{try{re(await Sn(`opencode`,t.signal))}catch(e){S(e)||re(e=>e)}})(),(async()=>{try{ie(await mw(`opencode`,t.signal,e))}catch(e){S(e)||ie([])}})(),()=>{t.abort()}},[e,He]);let Qt=({active:e})=>{oe(!1),L(null),z({x:0,y:0});let t=Sl(String(e.id));if(t){F(Vt(t.bundleId,t.column)),N(null);return}F(null),N(d.find(t=>t.id===e.id)??null)},$t=()=>{oe(!1),L(null),z({x:0,y:0}),N(null),F(null)},en=(0,Y.useCallback)(e=>{f(t=>e.reduce((e,t)=>AY(e,t),t))},[f]),tn=(0,Y.useCallback)((e,t)=>{if(e.length===0)return;let n=e[0]?.state;n&&f(r=>e.reduce((e,r)=>NY(e,r.id,t,bX(r,n,t)),r))},[f]),nn=(0,Y.useCallback)((e,t=d)=>!e.worktree_bundle_id||!e.project_id||e.state!==`build`?[]:t.filter(t=>t.project_id===e.project_id&&t.worktree_bundle_id===e.worktree_bundle_id&&t.state===`build`&&t.parked_at===null).sort(ZY),[d]),rn=async({active:e,over:t})=>{let n=Sl(String(e.id)),r=d.find(t=>t.id===e.id),i=n?Vt(n.bundleId,n.column):null,a=t?.id===`trash`&&(r!==void 0&&Nw(r,`trash`)||i!==null&&mX(i)),o=t?.id&&eX.includes(t.id)?t.id:null;if(oe(a),L(null),z({x:0,y:0}),N(null),F(null),t){if(n){if(t.id===`trash`){if(!i||!mX(i))return;await Pn(i);return}if(t.id===tX){if(!i||!hX(i))return;await jn(i);return}if(o){if(n.column===tX){if(!i||!gX(i))return;await Mn(i);return}await lr(n.bundleId,n.column,o)}return}if(t.id===`trash`){if(!r||!Nw(r,`trash`))return;Ln(e.id);return}if(t.id===tX){if(!r||!Nw(r,tX))return;await kn(e.id);return}if(o){if(r&&Mw(r,o)){await An(e.id);return}if(!(!r||!Nw(r,o)))try{await Dn(r,o,{optimistic:!0})}catch(e){Q.error(e instanceof O?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`})}}}},Cn=async(t,n,r,a,o,s,c)=>{let u=await qt({title:t,description:n,tool:i,model:a,variant:o,skills:s,project_id:e,...c});if(uX(a,o,s),f(e=>AY(e,wY(u))),u.bundle&&g(e=>OY(e,u.bundle)),r===`build`)try{await Dn(u,`build`)}catch(e){Q.error(e instanceof O?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`})}r===`plan`&&xn(u.id,u.project_id)},wn=async t=>{if(!e)throw Error(l(`board.errors.createBundleWithoutProject`));let n=await wt(e,{name:t,prepare:!0});return g(e=>OY(e,n)),n},Tn=e=>{f(t=>[...e.tickets].reverse().reduce((e,t)=>AY(e,wY(t)),t)),m(t=>e.dependencies.reduce((e,t)=>Bw(e,t),t));for(let t of e.tickets)t.bundle&&g(e=>OY(e,t.bundle))},En=(0,Y.useCallback)((e,t={})=>{let n=wY(e);f(e=>t.reorderInState?AY(e,n):kY(e,n)),W(t=>!t||t.id!==e.id?t:QY(e,n)),e.bundle&&g(t=>OY(t,e.bundle))},[g,f]),Dn=async(e,t,n={})=>{let r=d.findIndex(t=>t.id===e.id),i=t===`review`?nn(e):[],a=t===`review`&&i.length>1,o=n.optimistic?a?i.map(e=>e.id):[e.id]:[];n.optimistic&&(D(o,t),a?tn(i,t):f(n=>NY(n,e.id,t,vX(e,t))));try{if(a&&e.project_id&&e.worktree_bundle_id){let t=await jt(e.project_id,e.worktree_bundle_id);Qn(t);let n=t.tickets.find(t=>t.id===e.id);if(!n)throw Error(l(`board.errors.missingBundleReviewTicket`));return k(o),n}let n=await Xt(e.id,e.project_id,t);return f(r=>{let i=r.find(t=>t.id===e.id);return i?.state===t&&n.state===t&&i.agent_status!==n.agent_status&&n.agent_status===e.agent_status?r:TY(i,n)?AY(r,n):kY(r,n)}),n.bundle&&g(e=>OY(e,n.bundle)),k(o),n}catch(t){throw n.optimistic&&(a?en(i):f(t=>NY(t,e.id,e.state,{agent_status:e.agent_status,agent_log:e.agent_log,build_completed_at:e.build_completed_at},{preferredIndex:r})),k(o)),t}},On=(e,t)=>{f(n=>n.map(n=>n.id===e?{...n,...t}:n))},kn=async t=>{let n=d.find(e=>e.id===t);if(n)try{let r=new Date().toISOString();A([t],r),On(t,{parked_at:r}),En(await ln(t,n.project_id??e),{reorderInState:!0}),j([t])}catch(e){j([t]),On(t,{parked_at:n.parked_at}),Q.error(e instanceof O?e.message:l(`board.errors.parkTicket`),{id:`board-park-error`})}},An=async t=>{let n=d.find(e=>e.id===t);if(n)try{A([t],null),On(t,{parked_at:null}),En(await un(t,n.project_id??e),{reorderInState:!0}),j([t])}catch(e){j([t]),On(t,{parked_at:n.parked_at}),Q.error(e instanceof O?e.message:l(`board.errors.returnTicket`),{id:`board-unpark-error`})}},jn=(0,Y.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at})),r=new Date().toISOString();A(e.tickets.map(e=>e.id),r),f(e=>e.map(e=>t.has(e.id)?{...e,parked_at:r}:e));let i=await Promise.allSettled(e.tickets.map(e=>ln(e.id,e.project_id??x.current))),a=new Set;if(i.forEach((t,n)=>{if(t.status===`fulfilled`){j([t.value.id]),En(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&a.add(r.id)}),a.size===0)return;j([...a]),f(e=>e.map(e=>{if(!a.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let o=i.find(e=>e.status===`rejected`),s=a.size===e.tickets.length?o?.reason instanceof O?o.reason.message:l(`board.errors.moveBundleToDone`):l(`board.toasts.movedBundleToDonePartial`,{movedCount:e.tickets.length-a.size,totalCount:e.tickets.length});Q.error(s,{id:`board-bundle-park-error`})},[x,En,j,A,f,l]),Mn=(0,Y.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at}));A(e.tickets.map(e=>e.id),null),f(e=>e.map(e=>t.has(e.id)?{...e,parked_at:null}:e));let r=await Promise.allSettled(e.tickets.map(e=>un(e.id,e.project_id??x.current))),i=new Set;if(r.forEach((t,n)=>{if(t.status===`fulfilled`){j([t.value.id]),En(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&i.add(r.id)}),i.size===0)return;j([...i]),f(e=>e.map(e=>{if(!i.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let a=r.find(e=>e.status===`rejected`),o=i.size===e.tickets.length?a?.reason instanceof O?a.reason.message:l(`board.errors.restoreBundle`):l(`board.toasts.restoredBundlePartial`,{restoredCount:e.tickets.length-i.size,totalCount:e.tickets.length});Q.error(o,{id:`board-bundle-unpark-error`})},[x,En,j,A,f,l]),Nn=async t=>{e&&(await zt(e,t),g(e=>e.filter(e=>e.id!==t)))},Pn=(0,Y.useCallback)(async t=>{let n=t.tickets.map(e=>({ticket:e,index:d.findIndex(t=>t.id===e.id)})).filter(e=>e.index!==-1);if(n.length===0)return;for(let e of n)C.current.set(e.ticket.id,e);let r=new Set(n.map(e=>e.ticket.id));f(e=>e.filter(e=>!r.has(e.id))),m(e=>e.filter(e=>!r.has(e.blocker_ticket_id)&&!r.has(e.dependent_ticket_id)));let i=await Promise.allSettled(n.map(async t=>(await sn(t.ticket.id,t.ticket.project_id??e),C.current.delete(t.ticket.id),t.ticket.id)));t.tickets.some(e=>e.project_id===x.current)&&T().catch(()=>{});let a=n.filter((e,t)=>i[t]?.status===`rejected`);if(a.length===0)return;for(let e of a)C.current.delete(e.ticket.id);a.some(e=>e.ticket.project_id===x.current)&&f(e=>[...a].sort((e,t)=>e.index-t.index).reduce((e,t)=>pX(e,t),e));let o=i.find(e=>e.status===`rejected`),s=a.length===n.length?o?.reason instanceof O?o.reason.message:l(`board.errors.deleteBundleTickets`):l(`board.toasts.deletedBundleTicketsPartial`,{deletedCount:n.length-a.length,totalCount:n.length});Q.error(s,{id:`board-delete-bundle-wrapper-error`})},[e,x,C,T,m,f,d,l]),Fn=e=>{let t=ct.get(e.id);En(e,{reorderInState:t?t.state!==e.state||t.parked_at!==e.parked_at||t.worktree_bundle_id!==e.worktree_bundle_id:!1}),t?.worktree_bundle_id&&t.worktree_bundle_id!==e.worktree_bundle_id&&t.bundle?.ticket_count===1&&g(e=>e.filter(e=>e.id!==t.worktree_bundle_id)),(t?.worktree_bundle_id!==e.worktree_bundle_id||t?.bundle?.ticket_count!==e.bundle?.ticket_count)&&e.project_id===x.current&&T().catch(()=>{})},In=async()=>{if(!e)return;let t=e,n=Ot.composer.description.trim();if(!n)return;let r=sX(),a=Ue?Ot.composer.model.trim():``,o=Ue&&a?Ot.composer.variant.trim():``,s=Ue?Ot.composer.skills:[],c=Date.now();Zt(t,e=>({...e,isOpen:!1,composer:{...e.composer,description:``,worktreeBundleId:``},runs:[{id:r,description:n,model:a,variant:o,skills:s,worktreeBundleId:kt,status:`running`,error:null,submittedAt:c,completedAt:null,boardVisible:!0,boardState:`visible`,summary:null},...e.runs]}));try{let e=await Jt({description:n,tool:i,model:a||null,variant:a&&o||null,skills:s,project_id:t,worktree_bundle_id:kt||null});uX(a||null,a&&o||null,s);let c=cX(e);Zt(t,e=>({...e,runs:lX(e.runs,r,e=>({...e,status:`done`,error:null,completedAt:Date.now(),summary:c,boardVisible:!1}))})),Q.success(l(`board.toasts.planningAgentCardsCreated`,{count:c.ticketCount}),{id:`planning-agent-success-${r}`}),ot(e.tickets.length),x.current===t&&Tn(e)}catch(e){let n=e instanceof O?e.message:l(`board.errors.generateTickets`);Zt(t,e=>({...e,runs:lX(e.runs,r,e=>({...e,status:`error`,error:n,completedAt:Date.now()}))})),Q.error(n,{id:`planning-agent-error`})}},Ln=async t=>{let n=d.find(e=>e.id===t),r=d.findIndex(e=>e.id===t);if(!(!n||r===-1)){C.current.set(t,{ticket:n,index:r}),f(e=>MY(e,t)),m(e=>zw(e,t));try{await sn(t,n.project_id??e),n.project_id===x.current&&T().catch(()=>{}),C.current.delete(t)}catch(e){let n=C.current.get(t);C.current.delete(t),n&&n.ticket.project_id===x.current&&(f(e=>pX(e,n)),Q.error(e instanceof O?e.message:l(`board.errors.deleteTicket`),{id:`board-delete-error`}))}}},Rn=async t=>{let n=d.find(e=>e.id===t);if(!n)return;let r=n.state===`review`?`review`:`build`;try{if(pe(r),n.project_id&&n.worktree_bundle_id&&n.state===`review`){Qn(await Mt(n.project_id,n.worktree_bundle_id));return}En(await cn(t,n.project_id??e),{reorderInState:!0})}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.undoTicket`),{id:`board-undo-error`}),e}finally{pe(e=>e===r?null:e)}},zn=t=>{fn(t,d.find(e=>e.id===t)?.project_id??e)},Bn=async t=>{let n=d.find(e=>e.id===t),r=n?ww(n):t;try{Ze(r),await pn(t,n?.project_id??e),s?.()}catch(e){Ze(e=>e===r?null:e),Q.error(e instanceof O?e.message:l(`board.errors.startRun`),{id:`board-run-error`})}},Vn=(0,Y.useCallback)(async t=>{let n=d.find(e=>e.id===t);try{await mn(t,n?.project_id??e)}catch(e){Q.error(e instanceof O?e.message:l(`board.errors.openIde`),{id:`board-open-ide-error`})}},[e,l,d]),Hn=async t=>{let n=d.find(e=>e.id===t),i=r?.kind===`ticket`&&n&&q===ww(n)?et:null;try{await hn(t,n?.project_id??e),o?.(i),s?.()}catch{}},Un=t=>{gn(t,d.find(e=>e.id===t)?.project_id??e).then(()=>{f(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e))})},Wn=t=>{_n(t,d.find(e=>e.id===t)?.project_id??e).then(()=>{f(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e))})},Gn=(0,Y.useCallback)(e=>{let t=Yt(e);!t||!Wt(t)||Vn(t.id)},[Wt,Yt,Vn]),Kn=(0,Y.useCallback)(e=>{let t=Yt(e);t&&Oe({bundleId:e,ticketId:t.id,projectId:t.project_id,title:t.bundle?Tl(t.bundle):t.title})},[Yt]),qn=(0,Y.useCallback)(e=>{if(!st)return;let t=Yt(e);!t?.project_id||!vl(t)||Ae(e)},[Yt,st]),Jn=(0,Y.useCallback)(e=>{let t=d.find(t=>t.id===e);!t||!Gt(t)||Ee({ticketId:t.id,projectId:t.project_id,title:t.title})},[Gt,d]),Yn=(0,Y.useCallback)(e=>{if(!st)return;let t=d.find(t=>t.id===e);!t?.project_id||!vl(t)||we({ticketId:t.id,projectId:t.project_id})},[st,d]),Xn=(0,Y.useCallback)(async(t,n)=>{let r=d.find(e=>e.id===t);if(r)try{En(r.state===`plan`?await bn(t,r.project_id??e,n):await vn(t,r.project_id??e,n))}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.sendFollowUp`),{id:`board-follow-up-error`}),e}},[e,En,l,d]),Zn=(0,Y.useCallback)(e=>{f(t=>e.reduce((e,t)=>{let n=e.find(e=>e.id===t.id),r=E(n,t);if(!r)return e;let i=wY(n&&n.state===r.state&&n.agent_status===`running`&&r.agent_status===null?{...r,agent_status:n.agent_status,session_id:n.session_id,is_running:n.is_running}:r);return TY(n,i)?AY(e,i):kY(e,i)},t))},[E,f]),Qn=(0,Y.useCallback)(e=>{Se(e),g(t=>OY(t,e.bundle)),Zn(e.tickets)},[Zn,g]),$n=(0,Y.useCallback)((e,t)=>{Array.isArray(t.tickets)&&Se(n=>!n||n.bundle.id!==e?n:{...n,tickets:t.tickets,execution_order_ticket_ids:t.execution_order_ticket_ids,latest_session_ticket_id:t.latest_session_ticket_id,latest_session_id:t.latest_session_id,review_owner_ticket_id:t.review_owner_ticket_id,target_ticket_id:t.target_ticket_id})},[]),er=(0,Y.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await Tt(t,e);return x.current===t?(Qn(n),n):null},[x,Qn]),tr=(0,Y.useCallback)(async e=>{let t=x.current;if(!t)return null;let n=await Et(t,e);return x.current===t?($n(e,n),n):null},[x,$n]),nr=(0,Y.useCallback)(async(e,t=null)=>{let n=x.current;if(!n)return;he(null),W(null),ve(e),be(t),Pe(nX());let r=dt.get(e)??null,i=d.filter(t=>t.worktree_bundle_id===e);if(r&&i.length>0){let e=gl(i),t=yl(i,{reviewOwnerTicketId:i.find(e=>e.state===`review`)?.id??null,latestSessionTicketId:e?.id??null});Se({bundle:r,tickets:i,latest_session_ticket_id:e?.id??null,latest_session_id:e?.session_id??null,review_owner_ticket_id:i.find(e=>e.state===`review`)?.id??null,target_ticket_id:t?.id??null})}else Se(null);Me(!0);try{await tr(e)}catch{}finally{x.current===n&&Me(!1)}},[x,dt,tr,d]),rr=(0,Y.useCallback)(async(e,t)=>{Pe(t=>({...t,[e]:!0}));try{return await t()}finally{Pe(t=>({...t,[e]:!1}))}},[]),ir=(0,Y.useCallback)(async t=>{await rr(`stopBuild`,async()=>{let n=d.find(e=>e.id===t);await gn(t,n?.project_id??e),f(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e)),n?.worktree_bundle_id&&await er(n.worktree_bundle_id)})},[e,er,rr,f,d]),ar=(0,Y.useCallback)(async t=>{await rr(`resumeBuild`,async()=>{let n=d.find(e=>e.id===t);await _n(t,n?.project_id??e),f(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e)),n?.worktree_bundle_id&&await er(n.worktree_bundle_id)})},[e,er,rr,f,d]),or=(0,Y.useCallback)(async t=>{if(e)try{Qn(await rr(`build`,()=>At(e,t))),_e===t&&be(`build`),s?.()}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.buildBundle`),{id:`board-bundle-build-error`}),e}},[e,Qn,s,rr,_e,l]),sr=(0,Y.useCallback)(async t=>{if(e)try{Qn(await rr(`review`,()=>jt(e,t))),_e===t&&be(`review`)}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.reviewBundle`),{id:`board-bundle-review-error`}),e}},[e,Qn,rr,_e,l]),cr=(0,Y.useCallback)(async t=>{if(e)try{pe(`review`),Qn(await rr(`undoReview`,()=>Mt(e,t))),_e===t&&be(`build`)}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.undoBundleReview`),{id:`board-bundle-undo-review-error`}),e}finally{pe(e=>e===`review`?null:e)}},[e,Qn,rr,_e,l]),lr=(0,Y.useCallback)(async(e,t,n)=>{if(t===tX||n===tX)return;let r=yX(t,n);if(!r)return;let i=d.filter(n=>n.worktree_bundle_id===e&&n.state===t&&n.parked_at===null);if(i.length===0)return;let a=i.map(e=>e.id);D(a,n),tn(i,n);try{if(r===`build`){await or(e),k(a);return}if(r===`review`){await sr(e),k(a);return}await cr(e),k(a)}catch(e){en(i),k(a),Q.error(e instanceof O?e.message:l(`board.errors.moveBundle`),{id:`board-bundle-move-error`})}},[k,or,sr,cr,D,tn,en,d,l]),ur=async t=>{e&&(Qn(await rr(`run`,()=>Lt(e,t))),s?.())},dr=async t=>{if(!e)return;let n=r?.kind===`ticket`&&q===t?et:null,i=await rr(`stop`,()=>Rt(e,t));o?.(n),Qn(i),s?.()},fr=(0,Y.useCallback)(async(t,n)=>{e&&Qn(await rr(`followUp`,()=>Nt(e,t,n)))},[e,Qn,rr]);(0,Y.useEffect)(()=>()=>{a?.(null)},[a]),(0,Y.useEffect)(()=>{if(!a)return;if(!r){a(null);return}if(r.kind===`project`){a({target:null,canSelect:!1,disabledReason:l(`board.preview.disabledProjectRoot`),submitPrompt:null});return}let e=d.find(e=>e.id===r.ticket_id);if(!e){a({target:null,canSelect:!1,disabledReason:l(`board.preview.disabledBuildCapable`),submitPrompt:null});return}if(e.state===`plan`){a({target:{kind:`ticket`,id:e.id},canSelect:!1,disabledReason:l(`board.preview.disabledPlanMode`),submitPrompt:null});return}if(e.worktree_bundle_id){a({target:{kind:`bundle`,id:e.worktree_bundle_id,ticket_id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:l(`board.preview.followUpBundlePlaceholder`),submitPrompt:t=>fr(e.worktree_bundle_id,t)});return}a({target:{kind:`ticket`,id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:l(`board.preview.followUpTicketPlaceholder`),submitPrompt:t=>Xn(e.id,t)})},[r,Xn,fr,a,l,d]);let pr=async t=>{let n=d.find(e=>e.id===t),r=n?Sw(n.state):null;if(n)try{if(n.state===`review`&&n.can_re_review&&n.agent_status!==`running`){let t=await yn(n.id,n.project_id??e);En(t),t.worktree_bundle_id&&await er(t.worktree_bundle_id);return}if(!r)return;if(n.worktree_bundle_id&&r===`review`){await sr(n.worktree_bundle_id);return}await Dn(n,r)}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.moveTicket`),{id:`board-move-error`}),e}},mr=async t=>{let n=d.find(e=>e.id===t);try{En(await an(t,n?.project_id??e))}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.startBuildChain`),{id:`board-build-chain-error`}),e}},hr=async t=>{let n=d.find(e=>e.id===t);try{await on(t,n?.project_id??e)}catch(e){throw Q.error(e instanceof O?e.message:l(`board.errors.stopBuildChain`),{id:`board-stop-build-chain-error`}),e}},gr=async()=>{if(!(!e||ue)){de(!0);try{let t=await dn(e);f(e=>e.filter(e=>!t.deleted_ticket_ids.includes(e.id))),m(e=>t.deleted_ticket_ids.reduce(zw,e)),await T(),U(!1),t.failed_count>0?Q.error(l(`board.toasts.deleteDonePartial`,{count:t.deleted_count,deletedCount:t.deleted_count,failedCount:t.failed_count}),{id:`board-delete-parked-error`}):Q.success(l(`board.toasts.deleteDoneSuccess`,{count:t.deleted_count}),{id:`board-delete-parked-success`})}catch(e){Q.error(e instanceof O?e.message:l(`board.errors.emptyDone`),{id:`board-delete-parked-error`})}finally{de(!1)}}},_r=({delta:e})=>{z(e)},vr=(0,Y.useCallback)((t=null)=>{e&&ee({initialWorktreeBundleId:t})},[e]),yr=(0,Y.useCallback)(()=>{e&&Zt(e,e=>e.isOpen?e:{...e,isOpen:!0})},[e,Zt]),br=(0,Y.useCallback)(()=>{Ye.current?.focus({preventScroll:!0})},[]);return CY([{key:`n`,onKeyDown:vr,disabled:!e},{key:`a`,onKeyDown:yr,disabled:!e},{key:`k`,ctrlKey:!0,onKeyDown:br}],{isBlocked:SY}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(KC,{sensors:u,collisionDetection:iS,onDragStart:Qt,onDragMove:_r,onDragCancel:$t,onDragEnd:rn,children:[(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(uY,{projectId:e,state:Pt,bundles:h,projectBranchState:n,showModelSelector:Ue,availableModels:V,availableSkills:H,onManageBundles:e?()=>{(async()=>{try{await T()}catch{}ne(!0)})()}:void 0,onToggle:()=>{e&&Zt(e,e=>({...e,isOpen:!e.isOpen}))},onDescriptionChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,description:t}}))},onModelChange:t=>{if(!e)return;let n=V.find(e=>e.id===t)??null;Zt(e,e=>({...e,composer:{...e.composer,model:t,variant:n?.variants.includes(e.composer.variant)?e.composer.variant:``}}))},onSkillsChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,skills:t}}))},onVariantChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,variant:t}}))},onBundleChange:t=>{e&&Zt(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t}}))},onGenerate:()=>{In()}}),(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:G(`absolute inset-y-0 left-16 right-0 z-10 bg-black/60 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Pt.isOpen?`opacity-100`:`pointer-events-none opacity-0`)}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 overflow-hidden p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,Z.jsx)(We,{id:`board-ticket-search`,ref:Ye,type:`search`,value:Le,onChange:e=>Re(e.target.value),placeholder:l(`board.search.placeholder`),"aria-label":l(`board.search.ariaLabel`),className:`pr-32`}),Le.length>0?(0,Z.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":l(`board.search.clearAriaLabel`),className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{Re(``),Ye.current?.focus()},children:(0,Z.jsx)(Be,{className:`size-4`})}):(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(pw,{children:`CTRL`}),(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(pw,{children:`K`})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ud,{id:`board-hide-stale-tickets`,checked:ze,onCheckedChange:Ve,"aria-label":l(`board.search.hideStaleAriaLabel`)}),(0,Z.jsx)(Xs,{htmlFor:`board-hide-stale-tickets`,className:`text-sm text-muted-foreground`,children:l(`board.search.hideStaleLabel`)})]})]}),(0,Z.jsx)(`div`,{ref:gt,className:`flex min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,Z.jsxs)(`div`,{ref:_t,className:`relative flex min-h-0 w-max min-w-full gap-4`,children:[(0,Z.jsx)(eY,{dependencies:p,cardRects:yt,preview:bt,ticketsById:ct,overlaySize:xt}),eX.map(t=>{let n=d.filter(e=>e.state===t&&!Ew(e)),r=pt.filter(e=>e.state===t&&!Ew(e)),i=bl(r,h,t),a=it&&n.length===0?t===`plan`?1:t===`build`?2:0:0;return(0,Z.jsx)(dG,{id:t,title:l(`card.columnLabels.${t}`),pinnedContent:t===`plan`?Ut:null,items:i,ticketCount:r.length,allTickets:d,dependencies:p,showModelSelector:Ue,availableModels:V,bundles:h,activeRunContextKey:tt,isProjectRootRunActive:J,isBundleRunDisabled:nt,getDependencyTargetState:St,onDependencyStart:Ct,onDeleteDependency:Dt,onRegisterTicketNode:vt,onAddTicket:t===`plan`&&e?vr:void 0,onCreateBundle:t===`plan`&&e?wn:void 0,onDeleteBundle:t===`plan`&&e?Nn:void 0,onDeleteBundleWrapper:Pn,onRefreshBundles:t===`plan`&&e?T:void 0,onUpdateTicket:Fn,onDeleteTicket:Ln,onUndoTicket:Rn,undoingColumn:fe,onRetryTicket:zn,onAdvanceTicket:pr,onParkTicket:kn,onUnparkTicket:An,onBuildChainTicket:mr,onRunTicket:Bn,onOpenTestsTicket:st?Yn:void 0,canOpenChangesForTicket:Gt,onOpenChangesTicket:Jn,canOpenIdeForTicket:Wt,onOpenIdeTicket:Vn,onStopTicket:Hn,onStopBuildTicket:Un,onStopBuildChainTicket:hr,onResumeBuildTicket:Wn,onOpenBundleChanges:Kn,onOpenBundleTests:st?qn:void 0,onOpenBundleIde:Gn,onAddTicketToBundle:vr,onFollowUpTicket:Xn,bundleActionState:Ne,onBuildBundle:or,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onParkBundleWrapper:jn,onUnparkBundleWrapper:Mn,onOpenTicketDetails:ut,onOpenBundleDetails:(e,t)=>{nr(e,t)},onRequestBundleRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onRequestTicketRefresh:w,loadingSkeletonCount:a},t)}),(0,Z.jsx)(dG,{id:tX,title:l(`card.columnLabels.done`),items:ht,ticketCount:mt.length,allTickets:d,dependencies:p,showModelSelector:Ue,availableModels:V,bundles:h,activeRunContextKey:tt,isProjectRootRunActive:J,isBundleRunDisabled:nt,getDependencyTargetState:St,onDependencyStart:Ct,onDeleteDependency:Dt,onRegisterTicketNode:vt,onUpdateTicket:Fn,onDeleteTicket:Ln,onUndoTicket:Rn,undoingColumn:fe,onRetryTicket:zn,onAdvanceTicket:pr,onParkTicket:kn,onUnparkTicket:An,onBuildChainTicket:mr,onRunTicket:Bn,onOpenTestsTicket:st?Yn:void 0,canOpenChangesForTicket:Gt,onOpenChangesTicket:Jn,canOpenIdeForTicket:Wt,onOpenIdeTicket:Vn,onStopTicket:Hn,onStopBuildTicket:Un,onStopBuildChainTicket:hr,onResumeBuildTicket:Wn,onOpenBundleChanges:Kn,onOpenBundleTests:st?qn:void 0,onOpenBundleIde:Gn,onAddTicketToBundle:vr,onFollowUpTicket:Xn,bundleActionState:Ne,onBuildBundle:or,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onParkBundleWrapper:jn,onUnparkBundleWrapper:Mn,onOpenTicketDetails:ut,onOpenBundleDetails:(e,t)=>{nr(e,t)},onRequestBundleRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onRequestTicketRefresh:w,className:`min-w-[272px] max-w-[272px] flex-[0.98] bg-card/65`,headerAccessory:(0,Z.jsxs)(K,{type:`button`,variant:`destructive`,size:`xs`,className:`gap-1.5`,disabled:mt.length===0||ue,onClick:()=>U(!0),children:[(0,Z.jsx)(Su,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:l(`board.doneColumn.emptyAction`)})]})})]})})]})]}),(0,Z.jsxs)(fw,{zIndex:5,dropAnimation:ae?null:void 0,children:[M&&(0,Z.jsx)(lG,{ticket:M,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:M.tool===`opencode`&&V.length>0,availableModels:V,runDisabled:_X(M,tt,J,l(`board.errors.runBlockedByActive`))!==void 0,runDisabledReason:_X(M,tt,J,l(`board.errors.runBlockedByActive`)),onDependencyStart:Ct,onDeleteDependency:Dt,onRegisterOverlayNode:L,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:T,onUpdate:Fn,onDelete:()=>Ln(M.id),onUndo:()=>Rn(M.id),undoInProgress:fe===M.state&&(M.state===`build`||M.state===`review`),onRetry:()=>zn(M.id),onAdvance:()=>pr(M.id),onPark:()=>kn(M.id),onUnpark:()=>An(M.id),onBuildChain:()=>mr(M.id),onRun:M.worktree_bundle_id===null&&vl(M)&&M.has_run_config?()=>Bn(M.id):void 0,onOpenIde:M.worktree_bundle_id===null&&Wt(M)?()=>Vn(M.id):void 0,onStop:M.worktree_bundle_id===null?()=>Hn(M.id):void 0,onStopBuild:()=>Un(M.id),onStopBuildChain:()=>hr(M.id),onResumeBuild:()=>Wn(M.id),onFollowUp:e=>Xn(M.id,e),onRequestTicketRefresh:w}),!M&&P&&(0,Z.jsx)(mT,{group:P,overlay:!0,renderTicket:Ht})]}),rt&&(0,Z.jsx)(dY,{className:`pointer-events-auto fixed left-1/2 top-4 z-20 w-[min(14rem,calc(100vw-2rem))] -translate-x-1/2`})]}),B&&(0,Z.jsx)(tY,{onSubmit:Cn,bundles:h,projectId:e,projectBranchState:n,tool:i,showModelSelector:Ue,availableModels:V,availableSkills:H,initialModel:Ue?Ft.model:``,initialVariant:Ue&&Ft.model?Ft.variant:``,initialSkills:Ue?Ft.skills:[],initialWorktreeBundleId:B.initialWorktreeBundleId,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:T,onClose:()=>ee(null)}),te&&e&&(0,Z.jsx)(wu,{bundles:h,selectedBundleId:Pt.composer.worktreeBundleId||null,onSelectBundle:t=>{Zt(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t??``}}))},onCreateBundle:wn,onDeleteBundle:Nn,onClose:()=>ne(!1)}),le&&(0,Z.jsx)(fG,{ticketCount:mt.length,isDeleting:ue,onCancel:()=>U(!1),onConfirm:()=>{gr()}}),ge&&(0,Z.jsx)(cG,{ticket:ge,allTickets:d,dependencies:p,bundles:h,projectMemoryEnabled:!!t?.memory_enabled,projectBranchState:n,onClose:()=>{let e=ge.id;he(null),W(null),f(t=>t.map(t=>t.id===e?wY(t):t))},showModelSelector:Ge,availableModels:V,availableSkills:H,runDisabled:_X(ge,tt,J,l(`board.errors.runBlockedByActive`))!==void 0,runDisabledReason:_X(ge,tt,J,l(`board.errors.runBlockedByActive`)),onDeleteDependency:Dt,onCreateBundle:wn,onDeleteBundle:Nn,onRefreshBundles:T,onUpdate:Fn,onAdvance:()=>pr(ge.id),onBuildChain:()=>mr(ge.id),onRun:vl(ge)&&ge.has_run_config?()=>Bn(ge.id):void 0,onOpenIde:Wt(ge)?()=>Vn(ge.id):void 0,onStop:()=>Hn(ge.id),onStopBuild:()=>Un(ge.id),onStopBuildChain:()=>hr(ge.id),onResumeBuild:()=>Wn(ge.id),onFollowUp:e=>Xn(ge.id,e),onProjectMemorySuggestionsChanged:()=>{Ie(e=>e+1)},onRequestTicketRefresh:e=>{lt(e)}}),Ce&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(GY,{scope:`ticket`,ticketId:Ce.ticketId,projectId:Ce.projectId,testCommands:at,onClose:()=>we(null)})}),De&&(0,Z.jsx)(BJ,{ticketId:De.ticketId,projectId:De.projectId,reviewCommentsBundleId:De.bundleId,title:De.title,onSubmitReviewPrompt:e=>fr(De.bundleId,e),canSubmitReviewPrompt:!d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`),reviewSubmitDisabledReason:d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`)?l(`board.changes.reviewPromptDisabledReason`):void 0,canAddReviewComments:!d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`),canModifyChanges:!d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`),changesDisabledReason:d.some(e=>e.worktree_bundle_id===De.bundleId&&e.agent_status===`running`)?l(`board.changes.modifyChangesDisabledReason`):void 0,onClose:()=>{let{bundleId:e}=De;Oe(null),er(e)},onTicketUpdate:Fn,onRequestTicketRefresh:w}),Te&&(0,Z.jsx)(BJ,{ticketId:Te.ticketId,projectId:Te.projectId,title:Te.title,onClose:()=>{let{ticketId:e}=Te;Ee(null),lt(e)},onTicketUpdate:Fn,onRequestTicketRefresh:e=>{lt(e)}}),ke&&e&&t&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(GY,{scope:`project`,projectId:e,targetKind:`bundle`,targetBundleId:ke,testCommands:at,onClose:()=>Ae(null)})}),_e&&ft&&(0,Z.jsx)(MG,{details:ft,activeColumn:ye,isLoading:je||Ne.bundleRefresh,actionState:Ne,canOpenIde:Kt(ft),projectMemoryEnabled:!!t?.memory_enabled,memorySuggestionsRefreshKey:Fe,runDisabled:nt(ft.bundle.id),showModelSelector:Ke,availableModels:V,availableSkills:H,onClose:()=>{let e=ft.bundle.id;ve(null),be(null),Se(null),Me(!1),Pe(nX()),f(t=>t.map(t=>t.worktree_bundle_id===e&&t.id!==me?wY(t):t))},onOpenTicketDetails:ut,onUpdateTicket:Fn,onOpenIde:()=>{let e=ft.tickets.find(e=>e.id===ft.target_ticket_id)??ft.tickets.find(e=>e.has_worktree);e&&Vn(e.id)},onOpenTests:st?()=>{qn(ft.bundle.id)}:void 0,onRefresh:e=>{rr(`bundleRefresh`,()=>er(e))},onBuildBundle:or,onStopBuildTicket:ir,onResumeBuildTicket:ar,onReviewBundle:sr,onUndoBundleReview:cr,onRunBundle:ur,onStopBundle:dr,onFollowUpBundle:fr})]})},SX=({className:e})=>(0,Z.jsx)(ko,{"aria-hidden":`true`,className:e}),CX=({className:e})=>(0,Z.jsx)(bo,{"aria-hidden":`true`,className:e}),wX=({className:e})=>(0,Z.jsx)(xo,{"aria-hidden":`true`,className:e}),TX=4,EX=5e3,DX=(e,t)=>Ne.t(`common:chatChangesPanel.${e}`,t),OX=e=>e.replace(/^[ab]\//,``),kX=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?OX(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?OX(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},AX=e=>{let[t,n]=kX(e);return!t&&!n?DX(`unknownFile`):t&&n&&t!==n?`${n} -> ${t}`:t??n??DX(`unknownFile`)},jX=e=>{let t=QK((()=>{let[t,n]=kX(e);return t??n??null})());if(!t)return null;try{return qy(e.hunks,{highlight:!0,refractor:Qq.default,language:t,enhancers:[Gy(e.hunks)]})}catch{return null}},MX=(e,t)=>e instanceof Error?e.message:t,NX=(e,t)=>{if(!t)return e;let n=AX(t);return[t,...e.filter(e=>AX(e)!==n)]},PX=e=>[...e].sort((e,t)=>{if(e.filePath!==t.filePath)return e.filePath.localeCompare(t.filePath);let n=e.newLineNumber??e.oldLineNumber??2**53-1,r=t.newLineNumber??t.oldLineNumber??2**53-1;return n===r?e.changeKey.localeCompare(t.changeKey):n-r}),FX=({diffResponse:e,gitStatus:t})=>{let n=new Map;for(let t of e?.files??[])n.set(t.path,t);return t?t.files.map(e=>{let t=n.get(e.path)??(e.original_path?n.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(e?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions}))},IX=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},LX={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},RX=e=>DX(`fileStatus.${e}`),zX=({selectedDiffPath:e,sidebarFiles:t,diffStats:n,triggerMode:r=`full`,onSelectDiffPath:i})=>{let[a,o]=(0,Y.useState)(!1),s=t.find(t=>t.path===e)??null,c=r===`compact`?e===`all`?DX(`picker.diff`):s?IX(s.path):DX(`picker.file`):e===`all`?DX(`picker.allChanges`):s?IX(s.path):e;return(0,Z.jsxs)(Zs,{open:a,onOpenChange:o,children:[(0,Z.jsx)(Qs,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:G(`max-w-full gap-2`,r===`full`?`min-w-0 max-w-[18rem]`:`min-w-0 px-2.5`),"aria-label":DX(`picker.openChangedFilesAriaLabel`),title:e===`all`?void 0:s?.path??e,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:c}),r===`full`&&(0,Z.jsx)(U,{variant:`outline`,className:`shrink-0 text-[10px] uppercase tracking-wide`,children:DX(`picker.fileCount`,{count:t.length})}),(0,Z.jsx)(Oe,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Z.jsxs)($s,{align:`start`,className:`z-[90] w-[28rem] max-w-[calc(100vw-2rem)] p-0`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:DX(`picker.title`)})}),(0,Z.jsx)(`div`,{className:`max-h-[min(28rem,calc(100vh-10rem))] overflow-y-auto p-3`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{i(`all`),o(!1)},className:G(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,IK(e===`all`),`justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:DX(`picker.allChanges`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:DX(`picker.allChangesDescription`)})]}),n&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:DX(`picker.fileCount`,{count:n.files_changed})}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,n.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,n.deletions]})]})]}),t.map(t=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{i(t.path),o(!1)},className:G(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,IK(e===t.path)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:IX(t.path)}),(0,Z.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.path})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,t.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,t.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[t.status&&(0,Z.jsx)(U,{variant:`outline`,className:LX[t.status],children:RX(t.status)}),t.staged&&(0,Z.jsx)(U,{variant:`outline`,children:DX(`fileStatus.staged`)}),t.unstaged&&(0,Z.jsx)(U,{variant:`outline`,children:DX(`fileStatus.unstaged`)}),t.conflicted&&(0,Z.jsx)(U,{variant:`destructive`,children:DX(`fileStatus.conflicted`)}),t.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.status===`renamed`?DX(`fileStatus.renamedFrom`,{path:t.originalPath}):t.originalPath})]})]})},`${t.path}:${t.originalPath??``}`))]})})]})]})},BX=(0,Y.memo)(({projectId:e,chatSessionId:t=null,canSubmitReviewPrompt:n,reviewSubmitDisabledReason:r,onSubmitReviewPrompt:i,state:a,onStateChange:o,isResizing:s=!1,onClose:c,desktopWidth:l,panelElementRef:u})=>{let[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),[,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(new Map),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(0),T=(0,Y.useRef)(0),E=(0,Y.useRef)(null),D=(0,Y.useRef)(null),O=a.selectedDiffPath,k=a.activeReviewTarget,A=a.editingReviewCommentKey,j=k?.commentKey??A??`chat`,M=a.reviewDraftInput,N=(0,Y.useMemo)(()=>new Map(a.reviewComments.map(e=>[sb(e.filePath,e.changeKey),e])),[a.reviewComments]),P=(0,Y.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await ix(e,t):await Ve(e)},[t,e]),F=(0,Y.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await ax(e,t):await ke(e)},[t,e]);(0,Y.useEffect)(()=>{E.current=d},[d]),(0,Y.useEffect)(()=>{D.current=p},[p]);let I=(0,Y.useCallback)(async()=>{if(!e){T.current+=1,f(null),m(null),g(null),v(!1),y(!1);return}let t=w.current+1,n=T.current+1;w.current=t,T.current=n,v(!0),y(!0);let[r,i]=await Promise.allSettled([P(),F()]);w.current===t&&(r.status===`fulfilled`?(E.current=r.value,f(r.value),g(null)):g(MX(r.reason,DX(`errors.loadDiff`))),i.status===`fulfilled`&&(D.current=i.value,m(i.value)),T.current===n&&v(!1),y(!1))},[P,F,e]),L=(0,Y.useCallback)(async(t={})=>{if(!e)return;let{broadcastOnSignatureChange:n=!1}=t,r=w.current+1;w.current=r,y(!0);try{let t=await F();if(w.current!==r)return;let i=D.current?.workspace_signature??null,a=t.workspace_signature??null,o=!E.current||i!==a;if(D.current=t,m(t),!o){T.current+=1,v(!1);return}let s=!E.current,c=T.current+1;T.current=c,s&&v(!0);try{let t=await P();if(w.current!==r)return;E.current=t,f(t),g(null),n&&i!==a&&eq(e)}catch(e){if(w.current!==r)return;E.current||g(MX(e,DX(`errors.loadDiff`)))}finally{s&&T.current===c&&v(!1)}}catch{E.current||(T.current+=1,v(!1));return}finally{w.current===r&&y(!1)}},[P,F,e]);(0,Y.useEffect)(()=>{I()},[I]),(0,Y.useEffect)(()=>{if(e)return tq(t=>{t===e&&L()})},[e,L]),(0,Y.useEffect)(()=>{if(!e)return;let t=rq(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})});return()=>{t()}},[e,L]),(0,Y.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})},EX);return()=>{window.clearInterval(t)}},[e,L]);let R=(0,Y.useMemo)(()=>{let e=typeof d?.diff==`string`?d.diff:``;return e.trim()?Rm(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:kX(e)})):[]},[d]),z=(0,Y.useMemo)(()=>{let e=new Map;for(let t of R)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[R]),B=(0,Y.useMemo)(()=>FX({diffResponse:d,gitStatus:p}),[d,p]);(0,Y.useEffect)(()=>{if(O!==`all`&&!(!d&&!p)){if(B.length===0){o(e=>({...e,selectedDiffPath:`all`}));return}B.some(e=>e.path===O)||o(e=>({...e,selectedDiffPath:`all`}))}},[d,p,o,O,B]);let ee=O===`all`?null:z.get(O)??null,te=(0,Y.useMemo)(()=>NX(R,ee),[R,ee]),ne=(0,Y.useMemo)(()=>O===`all`?R:ee?[ee]:[],[R,O,ee]);(0,Y.useEffect)(()=>{x(new Map)},[R]),(0,Y.useEffect)(()=>{if(te.length===0)return;let e=!1,t=null,n=0,r=()=>{if(e)return;let i=te.slice(n,n+TX);i.length!==0&&(x(e=>{let t=new Map(e);for(let e of i){let n=AX(e);t.has(n)||t.set(n,jX(e))}return t}),n+=TX,n<te.length&&(t=window.setTimeout(r,0)))};return t=window.setTimeout(r,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[te]);let V=(0,Y.useMemo)(()=>{let e=new Map;for(let t of te.slice(0,TX))e.set(AX(t),jX(t));return e},[te]),re=(0,Y.useMemo)(()=>ne.map(e=>({...e,tokens:b.get(AX(e))??V.get(AX(e))??null})),[V,b,ne]),H=(0,Y.useMemo)(()=>R.map(e=>({...e,tokens:null})),[R]),ie=(0,Y.useMemo)(()=>PX(a.reviewComments),[a.reviewComments]),ae=ie.length,oe=n&&!S&&ae>0,se=(0,Y.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}))},[o]),ce=(0,Y.useCallback)(({filePath:e,changeKey:t,commentKey:r})=>{let i=N.get(r);if(i){o(e=>({...e,selectedDiffPath:i.filePath,activeReviewTarget:null,editingReviewCommentKey:r,reviewDraftInput:i.comment}));return}n&&o(n=>({...n,activeReviewTarget:{filePath:e,changeKey:t,commentKey:r},editingReviewCommentKey:null,reviewDraftInput:``}))},[n,o,N]),le=(0,Y.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``}))},[o]),U=(0,Y.useCallback)(e=>{let t=N.has(e.commentKey);if(!n&&!t)return;let r=M.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;o(t=>{let n=new Map(t.reviewComments.map(e=>[sb(e.filePath,e.changeKey),e]));return n.set(e.commentKey,{scope:`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:cb(e.hunk,e.change),comment:r}),{...t,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[...n.values()]}})},[n,o,N,M]),ue=(0,Y.useCallback)(e=>{let t=N.get(e);t&&o(n=>({...n,selectedDiffPath:t.filePath,activeReviewTarget:null,editingReviewCommentKey:e,reviewDraftInput:t.comment}))},[o,N]),de=(0,Y.useCallback)(e=>{o(t=>({...t,activeReviewTarget:t.activeReviewTarget?.commentKey===e?null:t.activeReviewTarget,editingReviewCommentKey:t.editingReviewCommentKey===e?null:t.editingReviewCommentKey,reviewDraftInput:t.activeReviewTarget?.commentKey===e||t.editingReviewCommentKey===e?``:t.reviewDraftInput,reviewComments:t.reviewComments.filter(t=>sb(t.filePath,t.changeKey)!==e)}))},[o]),fe=(0,Y.useCallback)(async()=>{if(!oe)return;C(!0);let e=_b({drafts:ie,findings:[],githubComments:[],uncommittedFiles:R});try{await i(e),se(),Q.success(DX(`toasts.sendChangesSuccess`),{id:`chat-diff-review-submit-success`})}catch(e){Q.error(MX(e,DX(`errors.sendChanges`)),{id:`chat-diff-review-submit-error`})}finally{C(!1)}},[oe,se,i,R,ie]),pe=(0,Y.useCallback)(e=>(0,Z.jsx)(HG,{reviewComments:ie,pendingFixCount:ae,triggerMode:e===`wide`?`full`:`compact`,canSendReview:oe,isSubmittingReview:S,reviewSubmitDisabledReason:r??void 0,onClearPendingFixes:se,onSubmitReview:()=>{fe()}}),[oe,se,fe,S,ae,ie,r]),me=c?(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":DX(`closeAriaLabel`),className:`text-muted-foreground hover:text-foreground`,onClick:c,children:(0,Z.jsx)(Be,{className:`h-4 w-4`})}):null,he=l?{"--chat-changes-panel-width":`${l}px`}:void 0;return(0,Z.jsx)(`aside`,{"data-testid":`chat-changes-panel`,"data-desktop-width":l?String(l):void 0,ref:u,style:he,className:G(`flex h-[26rem] min-h-0 w-full shrink-0 flex-col overflow-hidden border-t border-border/70 bg-background/20 xl:h-full xl:border-l xl:border-t-0`,l?`xl:w-[var(--chat-changes-panel-width)]`:`xl:w-[32rem]`),children:(0,Z.jsx)(FK,{selectedDiffPath:O,sidebarFiles:B,diffResponse:d,isDiffLoading:_,diffError:h,allDiffFiles:H,renderedFiles:re,viewType:`unified`,onViewTypeChange:()=>{},onRetry:()=>{I()},activeReviewTarget:k,editingReviewCommentKey:A,reviewDraftInstanceKey:j,reviewDraftInput:M,reviewComments:ie,reviewFindings:[],githubComments:[],selectedReviewFindingIds:[],selectedGitHubCommentIds:[],canSelectReviewTarget:n,canEditActiveReviewDraft:n,reviewFindingsError:null,gitHubCommentsError:null,hasStaleReviewFindings:!1,onSelectReviewTarget:ce,onToggleReviewFindingSelection:()=>{},onToggleGitHubCommentSelection:()=>{},onReviewDraftInputChange:e=>{o(t=>({...t,reviewDraftInput:e}))},onCancelReviewDraft:le,onEditReviewDraft:ue,onRemoveReviewDraft:de,onSaveReviewDraft:U,diffThemeClassName:VK,resolveFilePath:AX,normalizeDiffPath:OX,emptyStateTitle:DX(`emptyStateTitle`),emptyStateDescription:DX(`emptyStateDescription`),filePickerControl:e=>(0,Z.jsx)(zX,{selectedDiffPath:O,sidebarFiles:B,diffStats:d?.stats??null,triggerMode:e===`wide`?`full`:`compact`,onSelectDiffPath:e=>{o(t=>({...t,selectedDiffPath:e}))}}),reviewSummaryControl:pe,extraHeaderControl:me,surfaceVariant:`flat`,showViewTypeToggle:!1,gutterVariant:`compact`,isResizing:s,resizePlaceholderLineThreshold:200})})});BX.displayName=`ChatChangesPanel`;var VX=({projectId:e,messages:t,internalLog:n,currentThinkingMessageId:r=null,previousThinkingLog:i=null,previousThinkingMessageId:a=null,pendingAgentTitle:o,streamingResponse:s,isRunning:c,isLoading:l=!1,canShowComposer:u,cardClassName:d,isExternallyResizing:f=!1,pendingAgentRevealKey:p=null,pendingAgentRevealDelayMs:m=0,composerFocusNonce:h=0,blurComposerOnSendStart:g=!1,hidePendingAgentTitle:_=!1,forceScrollToBottomKey:v,header:y,composerControls:b,composerInlineControls:x,composerTheme:S=`default`,layoutKey:C,scrollLayoutKey:w,followUpPrompt:T,draftAttachments:E=[],followUpPlaceholder:D,emptyStateText:O=null,renderMessageFooter:k,isSendingFollowUp:A,isUploadingAttachments:j=!1,canAttachImages:M=!1,followUpDisabledReason:N,onFollowUpPromptChange:P,onFollowUpKeyDown:F,onFollowUpPaste:I,onUploadAttachments:L,onRemoveAttachment:R,onFollowUpSubmit:z})=>(0,Z.jsx)(VN,{projectId:e,messages:t,internalLog:n,currentThinkingMessageId:r,previousThinkingLog:i,previousThinkingMessageId:a,pendingAgentTitle:o,streamingResponse:s,isRunning:c,isLoading:l,autoScrollBehavior:`sticky`,surfaceVariant:`chat`,canShowComposer:u,cardClassName:d,header:y,composerControls:b,composerInlineControls:x,composerTheme:S,composerSize:`compact-on-laptop`,showThinkingPlacement:`header`,pinComposerToBottom:!0,isExternallyResizing:f,pendingAgentRevealKey:p,pendingAgentRevealDelayMs:m,composerFocusNonce:h,blurComposerOnSendStart:g,forceScrollToBottomKey:v,layoutKey:C,scrollLayoutKey:w,followUpPrompt:T,draftAttachments:E,followUpPlaceholder:D,emptyStateText:O,autoFocusComposer:!0,renderMessageFooter:k,isSendingFollowUp:A,isUploadingAttachments:j,canAttachImages:M,followUpDisabledReason:N,hidePendingAgentTitle:_,onFollowUpPromptChange:P,onFollowUpKeyDown:F,onFollowUpPaste:I,onUploadAttachments:L,onRemoveAttachment:R,onFollowUpSubmit:z}),HX=({value:e,disabled:t=!1,onChange:n,planInactiveTooltip:r,buildInactiveTooltip:i})=>(0,Z.jsx)(bc,{value:e,items:[{value:`plan`,label:`Plan`,activeVariant:`ghost`,activeClassName:`border-transparent bg-sky-300 text-[#07111a] shadow-[0_10px_30px_rgba(125,211,252,0.24)] hover:bg-sky-200 hover:text-[#07111a]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:r},{value:`build`,label:`Build`,activeVariant:`ghost`,activeClassName:`border-transparent bg-emerald-400 text-[#07130d] shadow-[0_10px_30px_rgba(16,185,129,0.28)] hover:bg-emerald-300 hover:text-[#07130d]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:i}],disabled:t,onChange:n}),UX={default:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,muted:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`},WX=({tone:e=`default`,className:t,children:n,...r})=>(0,Z.jsx)(U,{variant:`outline`,className:G(UX[e],t),...r,children:n}),GX=(e,t)=>Ne.t(`projects:memory.${e}`,t),KX=e=>GX(`stageLabels.${e}`),qX=e=>GX(`priorityLabels.${e}`),JX=()=>({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),YX=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
|
|
150
148
|
`),priority:e.priority}:{kind:`decision`,title:e.title,scope:e.scope??``,content:e.decision,rationale:e.rationale??``,implications:e.implications.join(`
|
|
151
|
-
`),stages:``,priority:`normal`},
|
|
152
|
-
`).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),UX=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},WX=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=LX(a?`suggested.saveAsNewDecision`:`suggested.accept`),s=e.kind===`decision`?e.decision:e.instruction;return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(IX,{children:LX(`suggested.badge`,{kind:e.kind})}),a?(0,Z.jsx)(IX,{tone:`muted`,children:LX(`suggested.duplicateBadge`)}):null]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:LX(`suggested.review`)}),(0,Z.jsx)(K,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:LX(`suggested.dismiss`)})]})]})})},GX=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?LX(`suggested.saveAsNewDecision`):LX(`suggested.acceptAs`,{kind:e.kind});return(0,Z.jsx)(Os,{open:t,onOpenChange:a,children:(0,Z.jsxs)(Ms,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Ns,{children:[(0,Z.jsx)(Fs,{children:e.title}),(0,Z.jsx)(Is,{children:LX(`suggested.reviewDescription`,{kind:e.kind})})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:LX(`suggested.duplicateTitle`)}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}):null,n?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:LX(`editor.titleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":LX(`editor.titleAriaLabel`),value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:LX(`editor.scopeLabel`)}),(0,Z.jsx)(`input`,{"aria-label":LX(`editor.scopeAriaLabel`),value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:i.kind===`decision`?LX(`suggested.decision`):LX(`suggested.instruction`)}),(0,Z.jsx)(`textarea`,{"aria-label":i.kind===`decision`?LX(`suggested.decision`):LX(`suggested.instruction`),value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`min-h-32 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:LX(`editor.rationaleLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":LX(`editor.rationaleAriaLabel`),value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:LX(`suggested.implicationsMultiline`)}),(0,Z.jsx)(`textarea`,{"aria-label":LX(`editor.implicationsAriaLabel`),value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:LX(`suggested.stagesMultiline`)}),(0,Z.jsx)(`textarea`,{"aria-label":LX(`editor.stagesLabel`),value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:LX(`editor.priorityLabel`)}),(0,Z.jsxs)(`select`,{"aria-label":LX(`editor.priorityAriaLabel`),value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,Z.jsx)(`option`,{value:`low`,children:LX(`priorityLabels.low`)}),(0,Z.jsx)(`option`,{value:`normal`,children:LX(`priorityLabels.normal`)}),(0,Z.jsx)(`option`,{value:`high`,children:LX(`priorityLabels.high`)})]})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e.kind===`decision`?LX(`suggested.decision`):LX(`suggested.instruction`)}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-foreground`,children:e.kind===`decision`?e.decision:e.instruction})]}),e.rationale?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:LX(`editor.rationaleLabel`)}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-muted-foreground`,children:e.rationale})]}):null,e.kind===`decision`&&e.implications.length>0?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:LX(`editor.implicationsLabel`)}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:e.implications.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}):null,e.kind===`convention`?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:LX(`editor.stagesLabel`)}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:e.stages.map(e=>RX(e)).join(`, `)||LX(`suggested.noneSpecified`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:LX(`editor.priorityLabel`)}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:zX(e.priority)})]})]}):null]})]}),(0,Z.jsxs)(Ps,{className:`flex flex-wrap gap-2 sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:LX(`suggested.cancelEdits`)}):(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:LX(`suggested.edit`)}),(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(e),children:LX(`suggested.dismiss`)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d?(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:LX(`suggested.updateExistingDecision`)}):null,(0,Z.jsx)(K,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})]})]})})},KX=({projectId:e,suggestions:t,title:n,description:r,emptyState:i=null,onSuggestionsChanged:a})=>{let[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(BX),[f,p]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{l(e=>e&&!t.some(t=>t.id===e)?null:e),s(e=>e&&!t.some(t=>t.id===e)?null:e)},[t]);let m=o?t.find(e=>e.id===o)??null:null,h=()=>{l(null),d(BX())},g=e=>{s(e.id),l(e.id),d(VX(e))},_=e=>{c&&c!==e.id&&h(),s(e.id)},v=e=>{e||(s(null),c&&h())},y=async(t,n)=>{let r=c===t.id?u:VX(t),i=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:HX(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:UX(r.stages),priority:r.priority};p(t.id);try{if(n){if(t.kind!==`decision`)throw Error(LX(`messages.onlyDecisionSuggestionsCanUpdate`));let n=t.duplicate_match?.decision;if(!n)throw Error(LX(`messages.noExistingDecision`));await Le(e,t.id,n.id,i)}else await w(e,t.id,i);h(),s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:LX(`messages.saveSuggestionError`),{id:`project-memory-suggestion-error`})}finally{p(null)}},b=async t=>{p(t.id);try{await Me(e,t.id),c===t.id&&h(),o===t.id&&s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:LX(`messages.dismissSuggestionError`),{id:`project-memory-suggestion-error`})}finally{p(null)}};return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[n||r?(0,Z.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,Z.jsxs)(`div`,{children:[n?(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:n}):null,r?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}):null]})}):null,t.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,Z.jsx)(WX,{suggestion:e,isPending:f===e.id,onReview:_,onAccept:e=>y(e,!1),onDismiss:b},e.id))}):i?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:i}):null,(0,Z.jsx)(GX,{suggestion:m,isOpen:!!m,isEditing:c===m?.id,isPending:f===m?.id,draft:c===m?.id?u:m?VX(m):u,onOpenChange:v,onStartEdit:g,onDraftChange:d,onCancelEdit:h,onAccept:y,onDismiss:b})]})},qX=()=>({selectedDiffPath:`all`,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}),JX=[{key:`today`,label:`Today`},{key:`yesterday`,label:`Yesterday`},{key:`last_7_days`,label:`Last 7 Days`},{key:`older`,label:`Older`}],YX=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},XX=e=>e.activity_at??e.last_user_message_at??e.created_at,ZX=(e,t)=>{let n=XX(e),r=XX(t);return n===r?e.created_at===t.created_at?t.id.localeCompare(e.id):t.created_at.localeCompare(e.created_at):r.localeCompare(n)},QX=e=>[...e].sort(ZX),$X=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),eZ=(e,t=new Date)=>{let n=YX(XX(e));if(!n)return`older`;let r=$X(t),i=new Date(r);i.setDate(i.getDate()-1);let a=new Date(r);return a.setDate(a.getDate()-6),n>=r?`today`:n>=i?`yesterday`:n>=a?`last_7_days`:`older`},tZ=(e,t=new Date)=>{let n=new Map;for(let r of QX(e)){let e=eZ(r,t);n.set(e,[...n.get(e)??[],r])}return JX.flatMap(e=>{let t=n.get(e.key)??[];return t.length===0?[]:[{key:e.key,label:e.label,sessions:t}]})},nZ=e=>{let t={...e};return delete t.messages,t.agent_log=null,t.agent_message_id=null,t.previous_agent_log=null,t.previous_agent_message_id=null,t.streaming_response=null,t},rZ=(e,t)=>Ne.t(`chatView.${e}`,t),iZ=1500,aZ=`archon.chat-run-config`,oZ=`archon.chat-changes-panel-layout`,sZ=`archon.chat-session-list-layout`,cZ=`archon.chat-draft`,lZ=512,uZ=360,dZ=.6,fZ=6,pZ=`.`,mZ=`/`,hZ=`Slash`,gZ=`NumpadDivide`,_Z=600,vZ=4,yZ=`mt-1 flex min-h-5 flex-wrap items-center gap-2 text-xs text-muted-foreground`,bZ=(e,t)=>{let n=Number.isFinite(e)?Math.round(e):lZ;if(!Number.isFinite(t))return Math.max(uZ,n);let r=Math.max(uZ,Math.round(t*dZ));return Math.max(uZ,Math.min(r,n))},xZ=e=>rZ(e===`claude`?`tool.claude`:`tool.opencode`),SZ=({availableModelsById:e,model:t})=>t?e.get(t)??t:null,CZ=e=>rZ(e===`plan`?`mode.plan`:`mode.build`),wZ=e=>rZ(e===`plan`?`placeholders.plan`:`placeholders.build`),TZ=e=>rZ(`pendingMemorySuggestions`,{count:e}),EZ=e=>e===`plan`?`build`:`plan`,DZ=e=>!e.defaultPrevented&&!e.altKey&&!e.shiftKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&e.key===pZ,OZ=e=>!e.defaultPrevented&&!e.altKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&(e.key===mZ||e.code===hZ||e.code===gZ),kZ=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??navigator.userAgent;return/mac/i.test(e)},AZ=()=>kZ()?rZ(`shortcuts.modifierMac`):rZ(`shortcuts.modifierDefault`),jZ=({modifierLabel:e,keys:t,ariaHidden:n=!1})=>(0,Z.jsxs)(`span`,{"aria-hidden":n,className:`flex items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(pw,{"aria-hidden":n,children:e}),t.map(e=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(pw,{"aria-hidden":n,children:e})]},e))]}),MZ=({label:e,modifierLabel:t,keys:n})=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(jZ,{modifierLabel:t,keys:n,ariaHidden:!0})]}),NZ=({modelLabel:e,tool:t})=>e??xZ(t),PZ=()=>rZ(`user.you`),FZ=e=>{if(!Number.isFinite(e))return`0`;if(e>=1e6){let t=e/1e6,n=t<10?2:1;return`${t.toFixed(n)}M`}return e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`},IZ=({totalTokens:e,contextWindow:t})=>!Number.isFinite(e)||!Number.isFinite(t)||t<=0?null:Math.round(e/t*100),LZ=({tool:e,model:t,availableModels:n,fallbackContextWindow:r})=>e===`opencode`?(n.find(e=>e.id===t)??null)?.context_window??r:r,RZ=({projectId:e,tool:t})=>`${aZ}:${e}:${t}`,zZ=({projectId:e,tool:t,chatSessionId:n})=>n?`${cZ}:${e}:session:${n}`:`${cZ}:${e}:draft:${t}`,BZ=e=>`${oZ}:${e}`,VZ=e=>`${sZ}:${e}`,HZ=e=>{if(!e)return``;try{return window.localStorage.getItem(e)??``}catch{return``}},UZ=({storageKey:e,value:t})=>{if(e)try{if(t){window.localStorage.setItem(e,t);return}window.localStorage.removeItem(e)}catch{}},WZ=e=>{if(!e)return{isOpen:!0,width:lZ};try{let t=window.localStorage.getItem(BZ(e));if(!t)return{isOpen:!0,width:lZ};let n=JSON.parse(t),r=typeof n.width==`number`&&Number.isFinite(n.width)?Math.max(uZ,Math.round(n.width)):lZ;return{isOpen:n.isOpen!==!1,width:r}}catch{return{isOpen:!0,width:lZ}}},GZ=e=>{if(!e)return{isOpen:!0};try{let t=window.localStorage.getItem(VZ(e));return t?{isOpen:JSON.parse(t).isOpen!==!1}:{isOpen:!0}}catch{return{isOpen:!0}}},KZ=({projectId:e,isOpen:t,width:n})=>{if(e)try{window.localStorage.setItem(BZ(e),JSON.stringify({isOpen:t,width:n}))}catch{}},qZ=({projectId:e,isOpen:t})=>{if(e)try{window.localStorage.setItem(VZ(e),JSON.stringify({isOpen:t}))}catch{}},JZ=({projectId:e,tool:t})=>{if(!e||t!==`opencode`)return null;try{let n=window.localStorage.getItem(RZ({projectId:e,tool:t}));if(!n)return null;let r=JSON.parse(n),i=(typeof r.model==`string`?r.model.trim():``)||null,a=r.mode===`plan`||r.mode===`build`?r.mode:null;return!i&&!a?null:{model:i,variant:i&&typeof r.variant==`string`&&r.variant.trim()||null,mode:a}}catch{return null}},YZ=({projectId:e,tool:t,model:n,variant:r,mode:i})=>{if(!(!e||t!==`opencode`||!n&&!i))try{window.localStorage.setItem(RZ({projectId:e,tool:t}),JSON.stringify({model:n,variant:n?r:null,mode:i}))}catch{}},XZ=({projectId:e,tool:t})=>JZ({projectId:e,tool:t})?.mode??`plan`,ZZ=({activeProjectId:e,helperModel:t,helperVariant:n,activeTool:r,availableModels:i})=>{let a=JZ({projectId:e,tool:r}),o=new Set(i.map(e=>e.id)),s=e=>e?o.size===0?!0:o.has(e):!1,c=t??``,l=a?.model??``,u=s(l)?l:s(c)?c:``,d=u===l?a?.variant??null:u&&u===c?n??null:null,f=i.find(e=>e.id===u)??null;return{model:u,variant:f?f.variants.includes(d??``)?d??``:``:u?d??``:``,mode:a?.mode??`plan`}},QZ=e=>e&&e.replace(/\s+/g,` `).trim()||null,$Z=e=>{let t=QZ(e.first_user_message_preview);if(t)return t;let n=e.messages?.find(e=>e.role===`user`)?.content;return QZ(n)},eQ=({chatSessionId:e,instruction:t,attachments:n,createdAt:r})=>({id:`optimistic:${e}:${r}`,chat_session_id:e,role:`user`,kind:`prompt`,content:t,attachments:n,created_at:r}),tQ=({session:e,instruction:t,attachments:n,createdAt:r})=>({...e,messages:[...e.messages??[],eQ({chatSessionId:e.id,instruction:t,attachments:n,createdAt:r})],activity_at:r,last_user_message_at:r,updated_at:r}),nQ=e=>!!(e.first_user_message_preview||e.last_user_message_at||e.messages?.some(e=>e.role===`user`)),rQ=({activeProject:e,activeProjectBranchState:t,session:n})=>!e||n.target_available===!1?!1:n.target_kind===`bundle`?e.active_target_kind===`bundle`&&!!n.target_bundle_id&&e.active_target_bundle_id===n.target_bundle_id:e.active_target_kind===`bundle`?!1:!t||!n.target_branch_snapshot?!0:t?.status!==`ready`||!t.branch?!1:t.branch===n.target_branch_snapshot,iQ=({session:e,activeProject:t,activeProjectBranchState:n})=>e.target_kind===`bundle`?e.target_label_snapshot||rZ(`targets.bundleFallback`):!t||t.active_target_kind===`bundle`||n?.status!==`ready`||!n.branch||!e.target_branch_snapshot||n.branch===e.target_branch_snapshot?null:rZ(`targets.repoRootWithBranch`,{branch:e.target_branch_snapshot}),aQ=e=>e.target_kind===`bundle`?e.target_label_snapshot||rZ(`targets.bundleFallback`):e.target_branch_snapshot?rZ(`targets.repoRootWithBranch`,{branch:e.target_branch_snapshot}):rZ(`targets.repoRoot`),oQ=({activeProject:e,activeProjectBranchState:t})=>e?e.active_target_kind===`bundle`?rZ(`targets.selectedBundleTarget`):t?.branch?rZ(`targets.repoRootWithBranch`,{branch:t.branch}):rZ(`targets.repoRoot`):rZ(`targets.currentTarget`),sQ=e=>e.agent_status===`running`?rZ(`sidebar.deleteDisabledReason`):null,cQ=({count:e,title:t,isDeleting:n,onConfirm:r,onCancel:i})=>{let a=e>1;return(0,Z.jsxs)(du,{onClose:i,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:rZ(a?`deleteSessionModal.bulkTitle`:`deleteSessionModal.title`)}),t?(0,Z.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:t}):null,(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:a?rZ(`deleteSessionModal.bulkDescription`,{count:e}):rZ(`deleteSessionModal.description`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,variant:`ghost`,onClick:i,disabled:n,children:rZ(`deleteSessionModal.cancel`)}),(0,Z.jsx)(K,{type:`button`,variant:`destructive`,onClick:r,disabled:n,children:rZ(n?`deleteSessionModal.deleting`:`deleteSessionModal.delete`)})]})]})},lQ=({activeProject:e,activeProjectBranchState:t,activeSessionId:n,chatModeShortcutModifierLabel:r,deletingSessionIds:i,finishedBackgroundSessionIds:a,hasDeletableSessions:o,isCreatingSession:s,isSelectionMode:c,isDraftOpen:l,isLoadingSessions:u,isOpen:d,isSendingPrompt:f,selectedSessionCount:p,selectedSessionIds:m,sessionGroups:h,sessions:g,onConfirmDeleteSelectedSessions:_,onConfirmDeleteSession:v,onDraftOpen:y,onEnterSelectionMode:b,onExitSelectionMode:x,onSetSessionSelection:S,onSessionSelect:C,onToggleSessionSelection:w,onToggleOpen:T})=>{let E=(0,Y.useMemo)(()=>new Set(g.filter(e=>!sQ(e)&&!i.has(e.id)).map(e=>e.id)),[i,g]),D=(0,Y.useRef)(null),O=(0,Y.useRef)(!1),k=(0,Y.useRef)(null),A=(0,Y.useCallback)(()=>{k.current!==null&&(window.clearTimeout(k.current),k.current=null)},[]),j=(0,Y.useCallback)(()=>{A(),k.current=window.setTimeout(()=>{O.current=!1,k.current=null},0)},[A]),M=(0,Y.useCallback)(()=>{D.current&&(D.current=null,j())},[j]),N=(0,Y.useCallback)(e=>{let t=D.current;!t||t.visitedSessionIds.has(e)||!E.has(e)||(t.visitedSessionIds.add(e),S(e,t.mode===`select`))},[S,E]),P=(0,Y.useCallback)(e=>{let t=D.current;!t||e.pointerId!==t.pointerId||M()},[M]);return(0,Y.useEffect)(()=>{if(!c){M();return}return window.addEventListener(`pointerup`,P),window.addEventListener(`pointercancel`,P),()=>{window.removeEventListener(`pointerup`,P),window.removeEventListener(`pointercancel`,P),M(),A()}},[A,P,c,M]),(0,Z.jsx)(`aside`,{"data-testid":`chat-sessions-sidebar`,"data-state":d?`expanded`:`collapsed`,"aria-label":rZ(`sidebar.ariaLabel`),className:G(`relative z-20 flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background/40 transition-[width] duration-200 ease-out motion-reduce:transition-none`,d?`w-72`:`w-16`),children:d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-start gap-2 border-b border-border/70 px-4 py-3.5`,children:[(0,Z.jsxs)(K,{type:`button`,size:`sm`,className:`gap-2`,onClick:y,disabled:s||f,children:[(0,Z.jsx)(Ll,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:rZ(`sidebar.newSession`)}),(0,Z.jsx)(jZ,{modifierLabel:r,keys:[mZ],ariaHidden:!0})]}),(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":rZ(`sidebar.collapseAriaLabel`),"aria-expanded":d,className:`ml-auto`,onClick:T,children:(0,Z.jsx)(hX,{className:`h-4 w-4`})})]}),g.length>0?(0,Z.jsx)(`div`,{className:`px-4 py-2.5`,children:c?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:x,disabled:i.size>0,children:rZ(`sidebar.cancelSelection`)}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`destructive`,className:`h-7 px-2 text-xs`,onClick:_,disabled:p===0||i.size>0,children:rZ(`sidebar.deleteSelected`)})]}),(0,Z.jsx)(`div`,{className:`flex justify-end text-xs font-medium text-muted-foreground`,children:rZ(`sidebar.selectedCount`,{count:p})})]}):o?(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:b,children:[(0,Z.jsx)(mX,{className:`h-3.5 w-3.5`}),rZ(`sidebar.select`)]}):null}):null,(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:u&&g.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground`,children:rZ(`sidebar.loadingSessions`)}):g.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:rZ(`sidebar.noSessions`)}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:h.map(r=>(0,Z.jsxs)(`section`,{"aria-label":r.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`div`,{className:`px-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/80`,children:r.label}),r.sessions.map(r=>{let o=!l&&r.id===n,s=$Z(r),u=iQ({session:r,activeProject:e,activeProjectBranchState:t}),d=sQ(r),f=i.has(r.id),p=!!d||f,h=m.has(r.id),g=r.agent_status===`running`?`running`:r.agent_status===`stopped`?`interrupted`:!o&&a.has(r.id)?`finished`:null,_=g===`interrupted`?null:g;return(0,Z.jsxs)(`div`,{"data-chat-session-id":r.id,"data-chat-session-selectable":p?`false`:`true`,className:G(`group relative rounded-xl border transition-colors`,o?`border-sky-400/40 bg-sky-500/10 text-foreground ring-1 ring-sky-400/40`:`border-border/50 bg-card/35 text-muted-foreground hover:border-border/80 hover:bg-card/60 hover:text-foreground`),onPointerDownCapture:e=>{!c||p||e.pointerType&&e.pointerType!==`mouse`||typeof e.button==`number`&&e.button!==0||(e.preventDefault(),A(),O.current=!0,D.current={pointerId:e.pointerId,mode:h?`deselect`:`select`,visitedSessionIds:new Set},N(r.id))},onPointerMove:e=>{let t=D.current;!t||t.pointerId!==e.pointerId||N(r.id)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":[r.title,CZ(r.mode),xZ(r.tool),e?.memory_enabled&&r.pending_memory_suggestion_count>0?TZ(r.pending_memory_suggestion_count):null,g===`running`?rZ(`sidebar.running`):g===`interrupted`?rZ(`sidebar.interrupted`):g===`finished`?rZ(`sidebar.finished`):null].filter(Boolean).join(` `),className:`flex w-full min-w-0 cursor-pointer items-start gap-2 rounded-xl px-3 py-2 pr-11 text-left transition-colors focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,onClick:()=>{if(c){if(O.current){O.current=!1;return}if(p)return;w(r.id);return}C(r)},children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[u?(0,Z.jsx)(`div`,{className:`mb-1 truncate text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75`,children:u}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:r.title}),e?.memory_enabled&&r.pending_memory_suggestion_count>0?(0,Z.jsx)(IX,{tone:o?`default`:`muted`,className:`shrink-0`,"aria-label":TZ(r.pending_memory_suggestion_count),title:TZ(r.pending_memory_suggestion_count),children:r.pending_memory_suggestion_count}):null]}),s?(0,Z.jsx)(`div`,{className:G(`mt-0.5 line-clamp-1 text-xs leading-4`,o?`text-foreground/70`:`text-muted-foreground`),children:s}):null,r.target_available===!1?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-1 text-[11px] leading-4 text-amber-200/90`,children:r.target_unavailable_reason??rZ(`sidebar.targetUnavailable`)}):null]}),(0,Z.jsx)(Il,{state:_,className:`mt-1`})]})}),c?(0,Z.jsx)(`div`,{className:`absolute top-2 right-2 flex h-7 w-7 items-center justify-center`,title:d??rZ(`sidebar.selectSessionTitle`,{title:r.title}),children:(0,Z.jsx)(`input`,{type:`checkbox`,"aria-label":rZ(`sidebar.selectSessionAriaLabel`,{title:r.title}),checked:h,disabled:p,onClick:e=>{e.stopPropagation()},onChange:()=>{O.current||w(r.id)},className:`h-4 w-4 rounded border-border bg-background text-primary`})}):(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":rZ(`sidebar.deleteSessionAriaLabel`),className:G(`absolute top-2 right-2 h-7 w-7 shrink-0 rounded-md border border-transparent text-muted-foreground transition-all duration-150 hover:border-border/70 hover:bg-card/80 hover:text-foreground focus-visible:border-border/70 focus-visible:bg-card/80 focus-visible:text-foreground`,`opacity-100 sm:opacity-0 sm:pointer-events-none sm:group-hover:pointer-events-auto sm:group-focus-within:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,p&&`sm:disabled:opacity-0 sm:group-hover:disabled:opacity-50 sm:group-focus-within:disabled:opacity-50`,(o||f)&&`sm:pointer-events-auto sm:opacity-100 sm:disabled:opacity-50`,d&&`cursor-not-allowed text-muted-foreground/50 hover:border-transparent hover:bg-transparent hover:text-muted-foreground/50 focus-visible:border-transparent focus-visible:bg-transparent focus-visible:text-muted-foreground/50`),title:d??rZ(`sidebar.deleteSessionTitle`,{title:r.title}),disabled:p,onClick:e=>{e.stopPropagation(),v(r.id)},children:(0,Z.jsx)(Su,{className:`h-4 w-4`})})]},r.id)})]},r.key))})})]}):(0,Z.jsxs)(`div`,{"data-testid":`chat-sessions-rail`,className:`flex h-full w-full flex-col items-center gap-2 bg-background/80 py-3`,children:[(0,Z.jsx)(yc,{content:(0,Z.jsx)(MZ,{label:rZ(`shortcuts.startNewSession`),modifierLabel:r,keys:[mZ]}),side:`right`,children:(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,"aria-label":rZ(`sidebar.newSession`),className:`h-9 w-9`,onClick:y,disabled:s||f,children:(0,Z.jsx)(Ll,{className:`h-4 w-4`})})}),(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":rZ(`sidebar.openAriaLabel`),"aria-expanded":d,className:`h-9 w-9`,onClick:T,children:(0,Z.jsx)(gX,{className:`h-4 w-4`})})]})})},uQ=({proposals:e,isApplying:t,onApply:n})=>e.status===`applied`?(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:rZ(`ticketProposal.createdTitle`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:rZ(`ticketProposal.createdDescription`,{count:e.created_tickets.length})}),e.created_tickets.length>0?(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1 text-foreground`,children:e.created_tickets.map(e=>(0,Z.jsx)(`li`,{children:e.title},e.ticket_id))}):null]}):(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:rZ(`ticketProposal.proposedTitle`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:rZ(`ticketProposal.proposedDescription`)}),(0,Z.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e.tickets.map(e=>(0,Z.jsxs)(`li`,{className:`rounded border border-border/60 bg-background/80 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-muted-foreground`,children:e.description})]},e.key))}),e.dependencies.length>0?(0,Z.jsx)(`div`,{className:`mt-3 text-muted-foreground`,children:rZ(`ticketProposal.dependenciesLabel`,{value:e.dependencies.map(e=>`${e.blocker_key} -> ${e.dependent_key}`).join(`, `)})}):null,(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(K,{type:`button`,size:`sm`,onClick:n,disabled:t,children:rZ(t?`ticketProposal.creating`:`ticketProposal.create`)})})]}),dQ=({activeProjectId:e,activeProject:t,activeProjectBranchState:n=null,activeTool:r,onRestoreSessionTarget:i,onReviewCapabilityChange:a,isExternallyResizing:o=!1,showChangesPanel:s=!0})=>{let c=OY(),[l,u]=(0,Y.useState)([]),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(()=>XZ({projectId:e,tool:r})),[x,C]=(0,Y.useState)({}),[w,T]=(0,Y.useState)({}),[E,D]=(0,Y.useState)({}),[O,k]=(0,Y.useState)([]),[A,j]=(0,Y.useState)([]),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(``),[I,L]=(0,Y.useState)([]),[R,z]=(0,Y.useState)(!1),[B,ee]=(0,Y.useState)(!1),[te,ne]=(0,Y.useState)(!1),[V,re]=(0,Y.useState)(!1),[H,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)(null),[se,ce]=(0,Y.useState)([]),[le,U]=(0,Y.useState)(()=>new Set),[ue,de]=(0,Y.useState)(!1),[fe,me]=(0,Y.useState)(()=>new Set),[he,ge]=(0,Y.useState)(!1),[W,_e]=(0,Y.useState)(!1),[ve,ye]=(0,Y.useState)(null),[xe,Se]=(0,Y.useState)([]),[Ce,we]=(0,Y.useState)(!1),[Te,Ee]=(0,Y.useState)(!1),[De,Oe]=(0,Y.useState)(0),[ke,Ae]=(0,Y.useState)(qX),[je,Me]=(0,Y.useState)(()=>GZ(e).isOpen),[Ne,Pe]=(0,Y.useState)(()=>WZ(e).isOpen),[Fe,Ie]=(0,Y.useState)(!1),[Le,Re]=(0,Y.useState)(!1),[ze,Be]=(0,Y.useState)(()=>WZ(e).width),[Ve,He]=(0,Y.useState)(0),[Ue,We]=(0,Y.useState)(null),[Ge,Ke]=(0,Y.useState)(()=>new Set),qe=(0,Y.useRef)({model:``,variant:``,skills:[],showModelSelector:!1}),Je=(0,Y.useRef)(!1),Ye=(0,Y.useRef)(null),Xe=(0,Y.useRef)(0),Ze=(0,Y.useRef)(0),Qe=(0,Y.useRef)(null),$e=(0,Y.useRef)(null),et=(0,Y.useRef)(null),q=(0,Y.useRef)(null),J=(0,Y.useRef)(null),tt=(0,Y.useRef)(null),nt=(0,Y.useRef)(!1),rt=(0,Y.useRef)(!1),it=(0,Y.useRef)(0),at=(0,Y.useRef)(lZ),ot=(0,Y.useRef)(lZ),st=(0,Y.useRef)(!1),ct=(0,Y.useRef)(0),lt=(0,Y.useRef)({id:null,status:null}),ut=(0,Y.useRef)(new Map),dt=(0,Y.useRef)({}),ft=(0,Y.useRef)({}),pt=(0,Y.useRef)(new Set),mt=(0,Y.useRef)(!1),ht=e?zZ({projectId:e,tool:_?r:p?.tool??r,chatSessionId:_?null:d}):null,gt=ht?x[ht]??``:``,_t=_?r:p?.tool??r,vt=p?w[p.id]??[]:[],X=(p?E[p.id]??0:0)>0;(0,Y.useEffect)(()=>{Je.current=_},[_]),(0,Y.useEffect)(()=>{dt.current=x},[x]),(0,Y.useEffect)(()=>{ft.current=w},[w]),(0,Y.useEffect)(()=>{if(!ht||pt.current.has(ht))return;pt.current.add(ht);let e=HZ(ht);e&&C(t=>Object.prototype.hasOwnProperty.call(t,ht)?t:{...t,[ht]:e})},[ht]),(0,Y.useEffect)(()=>{!ht||!Object.prototype.hasOwnProperty.call(x,ht)||UZ({storageKey:ht,value:x[ht]??``})},[ht,x]),(0,Y.useEffect)(()=>{Ye.current=d},[d]);let yt=(0,Y.useCallback)(()=>{Ze.current+=1},[]),bt=(0,Y.useCallback)(e=>{yt(),m(e)},[yt]);(0,Y.useEffect)(()=>{if(!mt.current){mt.current=!0;return}let t=WZ(e),n=GZ(e);Je.current=!1,st.current=!1,pt.current=new Set,f(null),bt(null),v(!1),C({}),T({}),D({}),oe(null),ce([]),U(new Set),de(!1),me(new Set),We(null),Se([]),Ee(!1),ee(!1),Ae(qX()),Ke(new Set),ut.current=new Map,ot.current=t.width,Me(n.isOpen),Be(t.width),Pe(t.isOpen)},[e,bt]),(0,Y.useEffect)(()=>{Fe||(ot.current=ze,et.current&&(et.current.style.setProperty(`--chat-changes-panel-width`,`${ze}px`),et.current.setAttribute(`data-desktop-width`,String(ze))))},[ze,Fe]),(0,Y.useEffect)(()=>{if(!s||!Qe.current)return;let e=Qe.current.getBoundingClientRect().width;if(e<=0)return;let t=bZ(ze,e);t!==ze&&(ot.current=t,Be(t))},[ze,s]),(0,Y.useEffect)(()=>{qZ({projectId:e,isOpen:je})},[e,je]),(0,Y.useEffect)(()=>{s&&KZ({projectId:e,isOpen:Ne,width:ze})},[e,ze,Ne,s]),(0,Y.useEffect)(()=>{Ee(!1)},[d,_]);let xt=(0,Y.useCallback)(e=>{let t=nZ(e);u(e=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return QX([...e,t]);let r=[...e];return r[n]=t,QX(r)})},[]),St=(0,Y.useCallback)(t=>{let n=Array.from(new Set(t));if(n.length===0)return;let i=new Set(n),a=Ye.current,o=e?n.map(t=>zZ({projectId:e,tool:r,chatSessionId:t})):[];C(e=>{let t=o.filter(t=>Object.prototype.hasOwnProperty.call(e,t));if(t.length===0)return e;let n={...e};for(let e of t)delete n[e];return n}),T(e=>{let t={...e},r=!1;for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],r=!0);return r?t:e}),D(e=>{let t={...e},r=!1;for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],r=!0);return r?t:e});for(let e of o)UZ({storageKey:e,value:``});u(e=>{let t=e.filter(e=>!i.has(e.id));if(a&&i.has(a)){let e=t[0]??null;f(e?.id??null),bt(null),v(e===null),Se([]),we(!1),Ee(!1)}return t}),Ke(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e}),We(e=>e?.sessionId&&i.has(e.sessionId)?null:e),oe(e=>e&&i.has(e)?null:e),ce(e=>e.filter(e=>!i.has(e))),U(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e}),me(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e})},[e,r,bt]),Ct=(0,Y.useCallback)(e=>{St([e])},[St]),wt=(0,Y.useCallback)((e,t)=>{e&&C(n=>n[e]===t?n:{...n,[e]:t})},[]),Tt=(0,Y.useCallback)(e=>{e&&(C(t=>t[e]===``?t:{...t,[e]:``}),UZ({storageKey:e,value:``}))},[]),Et=(0,Y.useCallback)((e,t)=>{T(n=>{if(t.length===0){if(!Object.prototype.hasOwnProperty.call(n,e))return n;let t={...n};return delete t[e],t}return{...n,[e]:t}})},[]),Dt=(0,Y.useCallback)(e=>{T(t=>{if(!Object.prototype.hasOwnProperty.call(t,e))return t;let n={...t};return delete n[e],n}),D(t=>{if(!Object.prototype.hasOwnProperty.call(t,e))return t;let n={...t};return delete n[e],n})},[]),Ot=(0,Y.useCallback)((e,t)=>{D(n=>{let r=Math.max(0,(n[e]??0)+t);if(r===0){if(!Object.prototype.hasOwnProperty.call(n,e))return n;let t={...n};return delete t[e],t}return{...n,[e]:r}})},[]),kt=(0,Y.useCallback)(({fromStorageKey:e,toStorageKey:t})=>{if(!e||!t||e===t)return;let n=Object.prototype.hasOwnProperty.call(dt.current,e)?dt.current[e]??``:HZ(e);C(r=>{let i={...r,[t]:n};return delete i[e],i}),UZ({storageKey:t,value:n}),UZ({storageKey:e,value:``})},[]),At=(0,Y.useCallback)((e,t)=>{u(n=>{let r=n.findIndex(t=>t.id===e);if(r===-1)return n;let i=n[r];if(i.pending_memory_suggestion_count===t)return n;let a=[...n];return a[r]={...i,pending_memory_suggestion_count:t},a}),m(n=>!n||n.id!==e||n.pending_memory_suggestion_count===t?n:(Ze.current+=1,{...n,pending_memory_suggestion_count:t}))},[]),jt=(0,Y.useCallback)(async r=>{if(!e){u([]),f(null),bt(null),v(!1),ee(!1);return}z(!0);try{let i=await Yb(e,r);if(r?.aborted)return;let a=QX(i.map(nZ)),o=a[0]??null,s=t?.active_target_kind===`bundle`||n?.status!==`loading`;u(a),f(e=>Je.current?null:e&&a.some(t=>t.id===e)?e:e?a[0]?.id??null:st.current?null:o?s?(st.current=!0,rQ({activeProject:t,activeProjectBranchState:n,session:o})?o.id:null):null:(st.current=!0,null)),a.length===0&&v(!0)}catch(e){S(e)||Q.error(e instanceof Error?e.message:rZ(`errors.loadSessions`))}finally{r?.aborted||(z(!1),ee(!0))}},[t,n,e,bt]),Mt=(0,Y.useCallback)(async(t,n)=>{if(!e){bt(null);return}ne(!0);let r=Xe.current+1;Xe.current=r;let i=Ze.current;try{let a=await Zb(e,t,n);if(n?.aborted)return;let o=Ze.current!==i,s=Xe.current===r,c=Ye.current===t&&!Je.current;if(!s||o||!c)return;bt(a),xt(a)}catch(e){S(e)||Q.error(e instanceof Error?e.message:rZ(`errors.loadSession`))}finally{n?.aborted||ne(!1)}},[e,bt,xt]),Nt=(0,Y.useCallback)(async(n,r)=>{if(!e||!t?.memory_enabled){Se([]),we(!1);return}we(!0);try{let t=await be(e,null,r,n);if(r?.aborted)return;Se(t.suggestions),At(n,t.suggestions.length)}catch(e){S(e)||Q.error(e instanceof Error?e.message:rZ(`errors.loadMemorySuggestions`))}finally{r?.aborted||we(!1)}},[t?.memory_enabled,e,At]),Pt=(0,Y.useCallback)(()=>{Se(e=>{let t=e.length>0?e.slice(0,-1):e;return d&&At(d,t.length),t}),Oe(e=>e+1),jt(),d&&Mt(d)},[d,Mt,jt,At]);(0,Y.useEffect)(()=>{let e=new AbortController;return jt(e.signal),()=>{e.abort()}},[jt]),(0,Y.useEffect)(()=>{if(Je.current||_||d||st.current||l.length===0||t?.active_target_kind!==`bundle`&&n?.status===`loading`)return;st.current=!0;let e=l[0]??null;e&&rQ({activeProject:t,activeProjectBranchState:n,session:e})&&f(e.id)},[t,n,d,_,l]),(0,Y.useEffect)(()=>{if(_t!==`opencode`){k([]),j([]),_e(!1);return}let t=new AbortController;return(async()=>{_e(!0);try{let[n,r]=await Promise.all([Sn(_t,t.signal),mw(_t,t.signal,e)]);k(n),j(r)}catch(e){S(e)||(k(e=>e),j(e=>e))}finally{t.signal.aborted||_e(!1)}})(),()=>{t.abort()}},[e,_t]),(0,Y.useEffect)(()=>{if(_||!d){bt(null);return}if(p?.id===d)return;bt(null);let e=new AbortController;return Mt(d,e.signal),()=>{e.abort()}},[p,d,_,Mt,bt]),(0,Y.useEffect)(()=>{if(!t?.memory_enabled||_||!d){Se([]),we(!1);return}let e=new AbortController;return Nt(d,e.signal),()=>{e.abort()}},[t?.memory_enabled,d,_,Nt,De]),(0,Y.useEffect)(()=>{!Te||Ce||xe.length>0||Ee(!1)},[Ce,Te,xe.length]),(0,Y.useEffect)(()=>{if(!d||p?.agent_status!==`running`)return;let e=new AbortController,t=window.setInterval(()=>{Promise.all([jt(e.signal),Mt(d,e.signal)])},iZ);return()=>{e.abort(),window.clearInterval(t)}},[p?.agent_status,d,Mt,jt]),(0,Y.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||(t.id===d&&bt(t),nQ(t)&&xt(t))},n=t=>{!t||t.project_id!==e||Ct(t.id)};return c.on(`chat-session:created`,t),c.on(`chat-session:updated`,t),c.on(`chat-session:deleted`,n),()=>{c.off(`chat-session:created`,t),c.off(`chat-session:updated`,t),c.off(`chat-session:deleted`,n)}},[e,d,Ct,bt,c,xt]),(0,Y.useEffect)(()=>{_&&b(XZ({projectId:e,tool:r}))},[e,r,_]),(0,Y.useEffect)(()=>{if(_t!==`opencode`){N(``),F(``),L([]);return}if(_){let n=ZZ({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:_t,availableModels:O});N(n.model),F(n.variant),L([]);return}N(p?.model??t?.helper_model??``),F(p?.variant??t?.helper_variant??``),L(p?.skills??[])},[e,t?.helper_model,t?.helper_variant,p?.id,p?.model,p?.skills,p?.variant,O,_t,_]),(0,Y.useEffect)(()=>{let e=O.find(e=>e.id===M)??null;F(t=>e?e.variants.includes(t)?t:``:t)},[O,M]),(0,Y.useEffect)(()=>{if(_t!==`opencode`||!_||!M||P)return;let n=ZZ({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:_t,availableModels:O});n.model===M&&n.variant&&F(n.variant)},[e,t?.helper_model,t?.helper_variant,_t,O,_,M,P]),(0,Y.useEffect)(()=>{if(!ae)return;let e=p?.id===ae?p:l.find(e=>e.id===ae)??null;(!e||e.agent_status!==`running`)&&oe(null)},[p,ae,l]),(0,Y.useEffect)(()=>{let e=lt.current,n=p?.id??null,r=p?.agent_status??null;e.id===n&&e.status===`running`&&r===`done`&&t?.memory_enabled&&n&&Oe(e=>e+1),lt.current={id:n,status:r}},[t?.memory_enabled,e,p?.agent_status,p?.id,p?.title]),(0,Y.useEffect)(()=>{d&&Ke(e=>{if(!e.has(d))return e;let t=new Set(e);return t.delete(d),t})},[d]),(0,Y.useEffect)(()=>{Ue&&Ue.sessionId!==d&&We(null)},[d,Ue]),(0,Y.useEffect)(()=>{let e=ut.current,t=new Map,n=[];for(let r of l){let i=e.get(r.id)??null,a=r.agent_status??null;i===`running`&&a===`done`&&r.id!==d&&n.push(r),t.set(r.id,a)}ut.current=t,Ke(e=>{let t=new Set(e),r=!1,i=new Set(l.map(e=>e.id));for(let e of t)i.has(e)||(t.delete(e),r=!0);for(let e of l){let i=e.agent_status??null,a=n.some(t=>t.id===e.id);if((e.id===d||i!==`done`)&&t.delete(e.id)){r=!0;continue}a&&!t.has(e.id)&&(t.add(e.id),r=!0)}return r?t:e})},[e,d,l]);let Ft=(0,Y.useMemo)(()=>new Map(O.map(e=>[e.id,e.label])),[O]),It=(0,Y.useMemo)(()=>tZ(l),[l]),Lt=(0,Y.useMemo)(()=>se.length===0?[]:se.flatMap(e=>{let t=l.find(t=>t.id===e)??(p?.id===e?p:null);return t?[t]:[]}),[p,se,l]),Rt=Lt.length===1?Lt[0]?.title??null:null;(0,Y.useEffect)(()=>{se.length>0&&Lt.length!==se.length&&ce(Lt.map(e=>e.id))},[se,Lt]),(0,Y.useEffect)(()=>{let e=new Set(l.filter(e=>!sQ(e)&&!le.has(e.id)).map(e=>e.id));me(t=>{let n=new Set(Array.from(t).filter(t=>e.has(t)));return n.size===t.size?t:n})},[le,l]),(0,Y.useEffect)(()=>{!ue||je||(de(!1),me(new Set))},[je,ue]);let zt=(0,Y.useMemo)(()=>p?NZ({modelLabel:SZ({availableModelsById:Ft,model:p.model}),tool:p.tool}):null,[p,Ft]),Bt=(0,Y.useMemo)(()=>p?(p.messages??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,attachments:e.attachments??[],ticket_proposals:e.ticket_proposals??null,created_at:e.created_at,displayTitle:e.role===`assistant`?zt??xZ(p.tool):PZ()})):[],[p,zt]),Vt=p?.id&&p.agent_status===`running`&&Ue?.sessionId===p.id?Ue.turnKey:null,Ht=_t===`opencode`&&O.length>0,Ut=_t===`opencode`&&!Ht&&W;(0,Y.useEffect)(()=>{qe.current={model:M,variant:P,skills:I,showModelSelector:Ht}},[M,I,P,Ht]);let Wt=(0,Y.useMemo)(()=>O.find(e=>e.id===M)??null,[O,M]),Gt=_?y:p?.mode??`build`,Kt=_?rZ(`composer.newChatTitle`):p?.title??rZ(`composer.chatTitle`),qt=_?r:p?.tool??r,Jt=(0,Y.useMemo)(()=>AZ(),[]),Yt=Ht?M||null:p?.model??null,Xt=qt===`opencode`,Zt=SZ({availableModelsById:Ft,model:Yt}),Qt=(0,Y.useMemo)(()=>{let e=p?.usage_snapshot_total_tokens??null;if(e===null)return null;let t=LZ({tool:qt,model:Yt,availableModels:O,fallbackContextWindow:p?.usage_snapshot_context_window??null});if(t===null)return null;let n=IZ({totalTokens:e,contextWindow:t});return n===null?null:`${FZ(e)} (${n}%)`},[p?.usage_snapshot_context_window,p?.usage_snapshot_total_tokens,O,Yt,qt]),$t=_?`draft:${e??`none`}:${r}`:p?.id,en=(0,Y.useCallback)(()=>{Je.current=!0,v(!0),b(XZ({projectId:e,tool:r})),g(null),f(null),bt(null),oe(null),de(!1),me(new Set),We(null)},[e,r,bt]),tn=(0,Y.useCallback)((e,t=null)=>{Je.current=!1,v(!1),g(null),f(e),bt(t)},[bt]),nn=(0,Y.useCallback)(async()=>{if(!(!p||!i)){g(p.id);try{await i(p)}catch(e){Q.error(e instanceof Error?e.message:rZ(`errors.restoreTarget`))}finally{g(e=>e===p.id?null:e)}}},[p,i]),rn=!!(p&&p.target_available!==!1&&!_&&!rQ({activeProject:t,activeProjectBranchState:n,session:p})),an=rn&&p?rZ(`review.mismatchReason`,{sessionTarget:aQ(p),currentTarget:oQ({activeProject:t,activeProjectBranchState:n})}):null,on=rn&&h===null,sn=(0,Y.useCallback)(async r=>{g(r.id);let a=r;if(e)try{let t=await Zb(e,r.id);a=t,xt(t)}catch(e){Q.error(e instanceof Error?e.message:rZ(`errors.loadSession`)),g(e=>e===r.id?null:e);return}if(a.target_available===!1){tn(a.id,a);return}if(!rQ({activeProject:t,activeProjectBranchState:n,session:a})&&i)try{if(!await i(a)){g(e=>e===a.id?null:e);return}}catch(e){Q.error(e instanceof Error?e.message:rZ(`errors.restoreTarget`)),g(e=>e===a.id?null:e);return}tn(a.id,a)},[t,n,e,i,tn,xt]),cn=(0,Y.useCallback)(()=>{He(e=>e+1)},[]),ln=(0,Y.useCallback)(async t=>{if(_){let n=qe.current;b(t),YZ({projectId:e,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,mode:t}),cn();return}if(!(!e||!p||p.mode===t||he)){ge(!0);try{let n=await Qb(e,p.id,{mode:t});YZ({projectId:e,tool:n.tool,model:n.model,variant:n.variant,mode:n.mode}),bt(n),xt(n),cn()}catch(e){Q.error(e instanceof Error?e.message:rZ(`errors.updateMode`))}finally{ge(!1)}}},[e,p,r,cn,_,he,bt,xt]),un=(0,Y.useCallback)(async({instruction:t,attachments:n,targetSession:r})=>{if(!e)return null;let i=qe.current;ct.current+=1;let a={sessionId:r.id,turnKey:`${r.id}:${ct.current}`};We(a);try{let a=await $b(e,r.id,{instruction:t,...n.length>0?{attachment_ids:n.map(e=>e.id)}:{},tool:r.tool,model:i.showModelSelector&&i.model||null,variant:i.showModelSelector&&i.model&&i.variant||null,skills:i.showModelSelector?i.skills:[]});return YZ({projectId:e,tool:a.tool,model:a.model,variant:a.variant,mode:a.mode}),Je.current=!1,bt(a),f(a.id),v(!1),xt(a),a}catch(e){throw We(e=>e?.turnKey===a.turnKey?null:e),e}},[e,bt,xt]),dn=(0,Y.useCallback)(async({fromStorageKey:t})=>{if(!e)return null;let n=qe.current,i=await Xb(e,{mode:Gt,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,skills:n.showModelSelector?n.skills:[]});Je.current=!1,v(!1),f(i.id),bt(i);let a=zZ({projectId:e,tool:i.tool,chatSessionId:i.id});return kt({fromStorageKey:t,toStorageKey:a}),{session:i,storageKey:a}},[e,r,Gt,kt,bt]),fn=(0,Y.useCallback)(async t=>{if(!e||H||V||X||p?.agent_status===`running`||p?.target_available===!1||on)return!1;let n=t.trim(),r=p?ft.current[p.id]??[]:[];if(!n&&r.length===0)return!1;ie(!0);let i=null,a=p,o=e&&p?zZ({projectId:e,tool:p.tool,chatSessionId:p.id}):null,s=r;try{let t=p;if(!t){re(!0);let e=await dn({fromStorageKey:ht});i=e?.session??null,t=i,o=e?.storageKey??null,s=i?ft.current[i.id]??[]:[]}if(!t)return!1;Tt(o??ht);let r=tQ({session:t,instruction:n,attachments:s,createdAt:new Date().toISOString()});bt(r),f(r.id),xt(r);let a=await un({instruction:n,attachments:s,targetSession:t});return Tt(a&&e?zZ({projectId:e,tool:a.tool,chatSessionId:a.id}):o),a&&Dt(a.id),!0}catch(e){throw wt(o??ht,n),i?(bt(i),f(i.id),v(!1),xt(i)):a&&(bt(a),xt(a)),e}finally{re(!1),ie(!1)}},[e,p,Dt,Tt,dn,ht,V,H,X,bt,un,wt,on,xt]),pn=(0,Y.useCallback)(e=>{Je.current=!0,v(!0),b(e),g(null),f(null),bt(null),oe(null),We(null)},[bt]),mn=(0,Y.useCallback)(async t=>{if(!e||t.length===0||_t!==`opencode`)return;let n=t.slice(0,vZ);if(n.length===0)return;let r=null,i=p;try{if(i||=(re(!0),r=await dn({fromStorageKey:ht}),r?.session??null),!i)return;if((ft.current[i.id]??[]).length+n.length>vZ){Q.error(`You can attach up to 4 images per turn.`);return}Ot(i.id,1);let t=await ex(e,i.id,n),a=ft.current[i.id]??[];Et(i.id,[...a,...t.attachments])}catch(t){if(r&&!gt.trim())try{await rx(e,r.session.id),Ct(r.session.id),pn(r.session.mode)}catch{}Q.error(t instanceof Error?t.message:rZ(`errors.uploadAttachments`))}finally{i&&Ot(i.id,-1),re(!1)}},[e,p,dn,gt,ht,Ot,pn,Ct,Et,_t]),hn=(0,Y.useCallback)(async t=>{if(!e||!p)return;let n=(ft.current[p.id]??[]).filter(e=>e.id!==t);try{await tx(e,p.id,t),Et(p.id,n),n.length===0&&!gt.trim()&&(p.messages?.length??0)===0&&(await rx(e,p.id),Ct(p.id),pn(p.mode))}catch(e){Q.error(e instanceof Error?e.message:rZ(`errors.removeAttachment`))}},[e,p,gt,pn,Ct,Et]),gn=(0,Y.useCallback)(e=>{if(_t!==`opencode`)return;let t=Array.from(e.clipboardData.items).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>e!==null);t.length!==0&&(e.preventDefault(),mn(t))},[_t,mn]),_n=(0,Y.useCallback)(async e=>{await fn(e)},[fn]),vn=!!(e&&(_||p&&p.target_available!==!1&&!on)),yn=p?.agent_status===`running`,bn=p?.agent_status===`stopped`,xn=yn&&ae===p?.id,Cn=vn&&!yn&&!H&&!V&&!X,wn=vn?p?.target_available===!1?p.target_unavailable_reason??rZ(`review.unavailableTarget`):on?an??rZ(`review.restoreTargetFallback`):yn?rZ(`review.waitTurn`):X?rZ(`review.waitUpload`):V||H?rZ(`review.waitPrompt`):null:rZ(`review.missingTarget`),Tn=(0,Y.useCallback)(async()=>{if(!(!e||!p||p.agent_status!==`running`||xn)){oe(p.id);try{await nx(e,p.id)}catch(e){oe(e=>e===p.id?null:e),Q.error(e instanceof Error?e.message:rZ(`errors.interruptResponse`))}}},[e,p,xn]),En=(0,Y.useCallback)(async()=>{if(!e||se.length===0||le.size>0)return;let t=Array.from(new Set(se)),n=ue||t.length>1;U(new Set(t));let r=await Promise.allSettled(t.map(async t=>(await rx(e,t),t))),i=[],a=[];for(let[e,n]of r.entries()){if(n.status===`fulfilled`){i.push(n.value);continue}a.push({sessionId:t[e]??``,message:n.reason instanceof Error?n.reason.message:null})}if(i.length>0&&St(i),U(new Set),a.length===0){ce([]),n&&(de(!1),me(new Set),Q.success(rZ(`toasts.deleteSelectedSuccess`,{count:i.length})));return}let o=a.map(e=>e.sessionId);if(ce(o),n&&me(new Set(o)),i.length>0){Q.error(rZ(`toasts.deleteSelectedPartial`,{count:i.length,deletedCount:i.length,failedCount:a.length}));return}Q.error(a[0]?.message??rZ(`errors.deleteSession`))},[e,se,le,ue,St]),Dn=(0,Y.useMemo)(()=>l.some(e=>!sQ(e)),[l]),On=(0,Y.useCallback)((e,t)=>{me(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),kn=(0,Y.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(PX,{value:Gt,planInactiveTooltip:(0,Z.jsx)(MZ,{label:rZ(`shortcuts.switchToPlan`),modifierLabel:Jt,keys:[pZ]}),buildInactiveTooltip:(0,Z.jsx)(MZ,{label:rZ(`shortcuts.switchToBuild`),modifierLabel:Jt,keys:[pZ]}),disabled:he,onChange:e=>{ln(e)}}),yn?(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:xn,onClick:()=>{Tn()},children:[xn?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Nc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:rZ(xn?`review.interrupting`:`review.interrupt`)})]}):null]}),[Jt,Gt,Tn,ln,xn,yn,he]),An=(0,Y.useMemo)(()=>Ht?(0,Z.jsx)(fP,{model:M,variant:P,skills:I,showModelSelector:!0,showSkillsSelector:!0,availableModels:O,availableSkills:A,selectedModel:Wt,onModelChange:e=>{let t=O.find(t=>t.id===e)??null;N(e),F(e=>t&&t.variants.includes(e)?e:``)},onVariantChange:F,onSkillsChange:L,modelSelectId:`project-chat-model-selector`,variantSelectId:`project-chat-variant-selector`,skillsSelectId:`project-chat-skills-selector`,disabled:H||V||p?.agent_status===`running`}):Ut?(0,Z.jsx)(dP,{dataTestId:`chat-model-selector-skeleton`}):null,[p?.agent_status,O,A,V,H,Wt,M,I,P,Ht,Ut]);(0,Y.useEffect)(()=>{if(a)return()=>{a(null)}},[a]),(0,Y.useEffect)(()=>{if(a){if(!e||!vn){a(null);return}a({chatSessionId:p?.id??null,canSubmitReviewPrompt:Cn,reviewSubmitDisabledReason:wn,mode:Gt,onModeChange:ln,isUpdatingMode:he,promptPlaceholder:wZ(Gt),promptComposerControls:kn,promptComposerInlineControls:An,submitPrompt:_n})}},[e,p,Cn,Gt,ln,_n,vn,he,a,kn,An,wn]);let jn=async()=>{if(!(!gt.trim()&&vt.length===0||X))try{if(!await fn(gt))return}catch(e){Q.error(e instanceof Error?e.message:rZ(`errors.sendPrompt`))}},Mn=e=>{e.key!==`Enter`||e.shiftKey||p?.agent_status===`running`||V||H||X||(e.preventDefault(),jn())};(0,Y.useEffect)(()=>{let t=t=>{if(OZ(t)){if(!e||V||H)return;t.preventDefault(),en(),cn();return}DZ(t)&&(!e||!_&&!p||(t.preventDefault(),ln(EZ(Gt))))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,p,Gt,cn,en,ln,V,_,H]);let Nn=(0,Y.useCallback)(async t=>{if(!(!e||!p)){ye(t);try{let n=await ox(e,p.id,t);bt(n.chatSession),xt(n.chatSession),Q.success(rZ(`ticketProposal.createdFromChat`,{count:n.created_tickets.length}))}catch(e){Q.error(e instanceof Error?e.message:rZ(`errors.createTickets`))}finally{ye(e=>e===t?null:e)}}},[e,p,bt,xt]),Pn=(0,Y.useCallback)(e=>{if(!Qe.current)return;let t=Qe.current.getBoundingClientRect().width,n=bZ(e,t);ot.current=n,et.current&&(et.current.style.setProperty(`--chat-changes-panel-width`,`${n}px`),et.current.setAttribute(`data-desktop-width`,String(n)))},[]),Fn=(0,Y.useCallback)(()=>{tt.current?.(),tt.current=null},[]),In=(0,Y.useCallback)(e=>{let t=q.current,n=J.current,r=nt.current;if(t!==null){if(q.current=null,J.current=null,nt.current=!1,Ie(!1),Re(!1),Fn(),e!==null&&typeof $e.current?.hasPointerCapture==`function`&&$e.current.hasPointerCapture(e)&&typeof $e.current.releasePointerCapture==`function`&&$e.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;Be(ot.current),Pe(!0);return}Be(ot.current)}},[Fn]),Ln=(0,Y.useCallback)((e,t)=>{if(q.current!==e)return;let n=t-it.current,r=at.current-n;if(J.current===`collapsed`){if(!nt.current&&r<fZ)return;nt.current||(nt.current=!0,rt.current=!0,Re(!0),Ie(!0))}Pn(r)},[Pn]),Rn=(0,Y.useCallback)((e,t)=>{if(q.current===e){if(t!==null&&(J.current===`inline`||nt.current)){let e=t-it.current;Pn(at.current-e)}In(e)}},[In,Pn]),zn=(0,Y.useCallback)(e=>{if(!s)return;e.preventDefault(),q.current=e.pointerId,J.current=Ne?`inline`:`collapsed`,nt.current=!1,rt.current=!1,it.current=e.clientX,at.current=Ne?ot.current:0,Ie(Ne),Fn(),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=e=>{Ln(e.pointerId,e.clientX)},n=e=>{Rn(e.pointerId,e.clientX)},r=e=>{Rn(e.pointerId,e.clientX)};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),tt.current=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r)}},[Rn,Ln,Ne,s,Fn]),Bn=(0,Y.useCallback)(e=>{Ln(e.pointerId,e.clientX)},[Ln]),Vn=(0,Y.useCallback)(e=>{Rn(e.pointerId,e.clientX)},[Rn]),Hn=(0,Y.useCallback)(e=>{Rn(e.pointerId,e.clientX)},[Rn]),Un=(0,Y.useCallback)(e=>{q.current===e.pointerId&&In(e.pointerId)},[In]),Wn=(0,Y.useCallback)(()=>{if(rt.current){rt.current=!1;return}Pe(!0)},[]),Gn=(0,Y.useCallback)(()=>{Pe(!1)},[]),Kn=(0,Y.useCallback)(e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),Wn())},[Wn]);(0,Y.useEffect)(()=>{s||(q.current=null,J.current=null,nt.current=!1,rt.current=!1,Ie(!1),Re(!1),Fn())},[s,Fn]),(0,Y.useEffect)(()=>()=>{Fn()},[Fn]);let qn=!!d,Jn=p?.target_available===!1,Yn=Jn?p?.target_unavailable_reason??rZ(`review.unavailableTarget`):null,Xn=_||!!(p&&p.target_available!==!1&&!on),Zn=!!(t?.memory_enabled&&p&&(xe.length>0||Ce)),Qn=s&&(_||qn)&&!Jn&&!on,$n=Qn&&!Ne&&!Le,er=Qn&&(Ne||Le),tr=`${$t??`none`}:${Qn?`changes-enabled`:`changes-disabled`}:${er?`panel-visible`:`panel-hidden`}`,nr=p||_?(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(NX,{projectId:e,messages:p?Bt:[],internalLog:p?.agent_log??null,currentThinkingMessageId:p?.agent_message_id??null,previousThinkingLog:p?.previous_agent_log??null,previousThinkingMessageId:p?.previous_agent_message_id??null,pendingAgentTitle:zt,streamingResponse:p?.streaming_response??null,isRunning:p?.agent_status===`running`,isLoading:!_&&te,canShowComposer:Xn,cardClassName:`border-t-0`,isExternallyResizing:o||Fe,pendingAgentRevealKey:Vt,pendingAgentRevealDelayMs:_Z,composerFocusNonce:Ve,header:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,children:Kt}),(0,Z.jsxs)(`div`,{className:yZ,children:[_?null:(0,Z.jsx)(TT,{tool:p?.tool,className:`text-[11px]`}),Zt?(0,Z.jsx)(`p`,{children:Zt}):null,bn?(0,Z.jsx)(`div`,{className:`inline-flex items-center rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100`,children:rZ(`sidebar.interrupted`)}):null,Qt?(0,Z.jsx)(`div`,{"data-testid":`chat-context-usage-badge`,className:`inline-flex items-center rounded-full border border-border/80 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-foreground`,children:Qt}):null]})]}),Zn?(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`outline`,className:`gap-2`,onClick:()=>Ee(!0),children:Ce?rZ(`composer.loadingMemory`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:rZ(`composer.memorySuggestions`)}),(0,Z.jsx)(IX,{children:xe.length})]})}):null]}),on&&an?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{children:an}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{nn()},children:rZ(`composer.switchBack`)}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:en,children:rZ(`composer.startNewSession`)})]})]})}):null,Jn&&Yn?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:Yn}):null]}),composerControls:kn,composerInlineControls:An,composerTheme:Gt,layoutKey:$t,scrollLayoutKey:tr,followUpPrompt:gt,draftAttachments:vt,followUpPlaceholder:wZ(Gt),emptyStateText:null,renderMessageFooter:e=>e.ticket_proposals?(0,Z.jsx)(uQ,{proposals:e.ticket_proposals,isApplying:ve===e.id,onApply:()=>{Nn(e.id)}}):null,isSendingFollowUp:H||V,isUploadingAttachments:X,canAttachImages:Xt,followUpDisabledReason:Jn?Yn??void 0:p?.agent_status===`running`?rZ(`review.waitTurnShort`):X?rZ(`review.waitUpload`):void 0,onFollowUpPromptChange:e=>{wt(ht,e)},onFollowUpKeyDown:Mn,onFollowUpPaste:gn,onUploadAttachments:e=>{mn(e)},onRemoveAttachment:e=>{hn(e)},onFollowUpSubmit:()=>{jn()}})}):qn?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:rZ(`composer.loadingSession`)}):!B||R?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:rZ(`sidebar.loadingSessions`)}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6`,children:(0,Z.jsxs)(mu,{className:`w-full max-w-lg border-dashed border-border/70 bg-card/40`,children:[(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{children:rZ(`composer.noSessionSelectedTitle`)}),(0,Z.jsx)(_u,{children:rZ(`composer.noSessionSelectedDescription`)})]}),(0,Z.jsx)(yu,{children:(0,Z.jsx)(K,{type:`button`,onClick:en,disabled:!e||V||H,children:rZ(`composer.startNewSession`)})})]})}),rr=Qn?(0,Z.jsx)(`div`,{ref:$e,"aria-label":rZ($n?`composer.openDiff`:`composer.resizeDiffPanel`),"aria-orientation":$n?void 0:`vertical`,className:G($n?`group flex h-8 w-full shrink-0 touch-none select-none items-center justify-center border-t border-border/70 bg-background/90 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground xl:h-auto xl:w-7 xl:cursor-col-resize xl:border-l xl:border-t-0`:`group hidden w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 transition-colors xl:flex`,Fe&&!$n&&`bg-background`),"data-testid":$n?`collapsed-changes-rail`:void 0,onLostPointerCapture:Un,onPointerCancel:Hn,onPointerDown:zn,onPointerMove:Bn,onPointerUp:Vn,onClick:$n?Wn:void 0,onKeyDown:$n?Kn:void 0,role:$n?`button`:`separator`,tabIndex:$n?0:void 0,children:$n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`hidden h-full w-full items-center justify-center xl:flex`,children:(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(kc,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]})}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium xl:hidden`,children:[(0,Z.jsx)(kc,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:rZ(`composer.diff`)})]})]}):(0,Z.jsx)(`div`,{className:G(`h-14 w-1.5 rounded-full transition-colors`,Fe?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`)})}):null,ir=Te&&e&&t?.memory_enabled?(0,Z.jsx)(du,{onClose:()=>Ee(!1),overlayClassName:`bg-background/45 p-4 backdrop-blur-sm`,panelClassName:`w-full max-w-3xl`,renderContent:({closeButton:t})=>(0,Z.jsxs)(mu,{size:`sm`,className:`max-h-[calc(100vh-2rem)] w-full gap-0 overflow-hidden border-border/80 bg-card/95 shadow-2xl`,children:[(0,Z.jsxs)(hu,{className:`border-b border-border/80 pb-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(gu,{children:rZ(`composer.memorySuggestionsTitle`)}),(0,Z.jsx)(_u,{children:rZ(`composer.memorySuggestionsDescription`)})]}),(0,Z.jsx)(vu,{children:t})]}),(0,Z.jsx)(yu,{className:`min-h-0 flex-1 overflow-y-auto pt-4`,children:(0,Z.jsx)(KX,{projectId:e,suggestions:xe,emptyState:rZ(`composer.memorySuggestionsEmpty`),onSuggestionsChanged:Pt})})]}),closeButtonLabel:rZ(`composer.closeMemorySuggestions`)}):null,ar=Lt.length>0?(0,Z.jsx)(cQ,{count:Lt.length,title:Rt,isDeleting:le.size>0,onConfirm:()=>{En()},onCancel:()=>{le.size>0||ce([])}}):null;return(0,Z.jsxs)(`div`,{"data-testid":`chat-view-shell`,className:`relative flex min-h-0 flex-1 overflow-hidden border-t border-border/70`,children:[(0,Z.jsx)(lQ,{activeProject:t,activeProjectBranchState:n,activeSessionId:d,chatModeShortcutModifierLabel:Jt,deletingSessionIds:le,finishedBackgroundSessionIds:Ge,hasDeletableSessions:Dn,isCreatingSession:V||!e,isSelectionMode:ue,isDraftOpen:_,isLoadingSessions:R,isOpen:je,isSendingPrompt:H,selectedSessionCount:fe.size,selectedSessionIds:fe,sessionGroups:It,sessions:l,onConfirmDeleteSelectedSessions:()=>{ce(Array.from(fe))},onConfirmDeleteSession:e=>{ce([e])},onDraftOpen:en,onEnterSelectionMode:()=>{de(!0),me(new Set)},onExitSelectionMode:()=>{de(!1),me(new Set)},onSetSessionSelection:On,onSessionSelect:e=>{sn(e)},onToggleSessionSelection:e=>{me(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},onToggleOpen:()=>{Me(e=>!e)}}),(0,Z.jsxs)(`div`,{ref:Qe,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden xl:flex-row`,children:[(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:nr}),Qn?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yc,{content:rZ(`composer.openDiff`),disabled:!$n,side:`left`,children:rr}),er?(0,Z.jsx)(MX,{projectId:e,chatSessionId:_?null:d,canSubmitReviewPrompt:Cn,reviewSubmitDisabledReason:wn,onSubmitReviewPrompt:_n,state:ke,onStateChange:Ae,isResizing:Fe,onClose:Gn,desktopWidth:ze,panelElementRef:et}):null]}):null]}),ir,ar]})},fQ=({className:e})=>(0,Z.jsx)(yo,{"aria-hidden":`true`,className:e}),pQ=({activeProject:e})=>e?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/60 pb-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Memory archive`}),(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name})]})}),(0,Z.jsx)(dp,{mode:`edit`,projectId:e.id,memoryEnabled:e.memory_enabled,persistedMemoryEnabled:e.memory_enabled,onMemoryEnabledChange:()=>{},showActivationControls:!1,archiveLayout:!0})]})}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Select a project to view memory.`}),mQ=()=>({hasRunning:!1,hasFinishedUnseen:!1,hasErrorUnseen:!1}),hQ=()=>({board:mQ(),memory:mQ(),chat:mQ()}),gQ=(e,t)=>{let n=e[t];return!n.hasFinishedUnseen&&!n.hasErrorUnseen?e:{...e,[t]:{...n,hasFinishedUnseen:!1,hasErrorUnseen:!1}}},_Q=e=>({hasRunning:e.board.hasRunning||e.chat.hasRunning,hasFinishedUnseen:e.board.hasFinishedUnseen||e.chat.hasFinishedUnseen,hasErrorUnseen:e.board.hasErrorUnseen||e.chat.hasErrorUnseen}),vQ=e=>e.hasErrorUnseen?`error`:e.hasRunning?`running`:e.hasFinishedUnseen?`finished`:null,yQ=(e,t)=>t?null:vQ(e),bQ=320,xQ=.7,SQ=28,CQ=6,wQ=(e,t)=>{let n=Math.max(bQ,Math.round(t*xQ));return Math.max(bQ,Math.min(n,Math.round(e)))},TQ=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return[...e,t];let r=e.slice();return r[n]=t,r},EQ=(e,t)=>{if(t.type===`reset`)return hQ();if(t.type===`mark-workspace-visible`)return gQ(e,t.workspace);let n=e[t.workspace],r={...n,hasRunning:t.activity.hasRunning,hasFinishedUnseen:t.visibleWorkspace===t.workspace?!1:n.hasFinishedUnseen||t.activity.didFinish,hasErrorUnseen:t.visibleWorkspace===t.workspace?!1:n.hasErrorUnseen||t.activity.didError};return n.hasRunning===r.hasRunning&&n.hasFinishedUnseen===r.hasFinishedUnseen&&n.hasErrorUnseen===r.hasErrorUnseen?e:{...e,[t.workspace]:r}},DQ=({activeProjectId:e,onActivity:t})=>{let{tickets:n}=IY(),r=(0,Y.useRef)(new Map);return(0,Y.useEffect)(()=>{r.current=new Map},[e]),(0,Y.useEffect)(()=>{let e=r.current,i=new Map,a=!1,o=!1;for(let t of n){let n=e.get(t.id)??null,r=t.agent_status??null;n===`running`&&r===`done`&&(a=!0),n===`running`&&r===`error`&&(o=!0),i.set(t.id,r)}r.current=i,t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:a,didError:o})},[t,n]),null},OQ=({activeProjectId:e,onActivity:t})=>{let n=OY(),[r,i]=(0,Y.useState)([]),a=(0,Y.useRef)(new Map);return(0,Y.useEffect)(()=>{if(!e)return;let t=new AbortController;return(async()=>{try{let n=await Yb(e,t.signal);if(t.signal.aborted)return;i(n)}catch(e){S(e)}})(),()=>{t.abort()}},[e,n]),(0,Y.useEffect)(()=>{if(!e)return;let t=new AbortController,n=YK(()=>{document.visibilityState===`visible`&&Yb(e,t.signal).then(e=>{t.signal.aborted||i(e)}).catch(e=>{S(e)})});return()=>{t.abort(),n()}},[e,n]),(0,Y.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||i(e=>TQ(e,t))},r=t=>{!t||t.project_id!==e||i(e=>e.filter(e=>e.id!==t.id))};return n.on(`chat-session:created`,t),n.on(`chat-session:updated`,t),n.on(`chat-session:deleted`,r),()=>{n.off(`chat-session:created`,t),n.off(`chat-session:updated`,t),n.off(`chat-session:deleted`,r)}},[e,n]),(0,Y.useEffect)(()=>{let n=a.current,i=new Map,o=[],s=!1;for(let e of r){let t=n.get(e.id)??null,r=e.agent_status??null;t===`running`&&r===`done`&&o.push(e),t===`running`&&r===`error`&&(s=!0),i.set(e.id,r)}a.current=i;for(let e of o)e.title&&EY(`Chat response ready`,e.title);o.length>0&&e&&KK(e),t({hasRunning:r.some(e=>e.agent_status===`running`),didFinish:o.length>0,didError:s})},[e,t,r]),null},kQ=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onRestoreChatSessionTarget:a,onChatReviewCapabilityChange:o,onPreviewReviewCapabilityChange:s,previewDisplayMode:c=`hidden`,previewPane:l=null,previewPaneWidth:u=480,isPreviewButtonDisabled:d=!1,previewButtonTitle:f,visibleWorkspace:p,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,onBoardLoadedProjectIdChange:_,onPreviewToggle:v,onPreviewPaneWidthChange:y,onRunStopped:b,onRunStatusChange:x,onWorkspaceActivityChange:S,onWorkspaceActivityEvent:C,refreshKey:w=0})=>{let T=(0,Y.useRef)(null),E=(0,Y.useRef)(null),D=(0,Y.useRef)(null),O=(0,Y.useRef)(null),k=(0,Y.useRef)(!1),A=(0,Y.useRef)(!1),j=(0,Y.useRef)(0),M=(0,Y.useRef)(u),N=(0,Y.useRef)(u),P=p===`board`||p===`chat`,F=l!==null,[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,ee]=(0,Y.useState)(u),[te,ne]=(0,Y.useReducer)(EQ,void 0,hQ),V=P&&F&&c===`expanded`,re=P&&F&&c===`inline`,H=P&&F&&c===`hidden`&&!R,ie=(re||R)&&!V,ae=V||ie,oe=P&&F&&!V,se=I?B:u,ce=p!==`chat`||!ie,le=e=>{let t=D.current,n=O.current,r=k.current;if(t!==null){if(D.current=null,O.current=null,k.current=!1,L(!1),z(!1),e!==null&&E.current?.hasPointerCapture(e)&&E.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;y?.(N.current),v?.();return}y?.(N.current)}},U=e=>{if(!T.current)return;let t=T.current.getBoundingClientRect().width,n=wQ(e,t);N.current=n,ee(n)},ue=e=>{y&&(H&&d||(e.preventDefault(),D.current=e.pointerId,O.current=H?`collapsed`:`inline`,k.current=!1,A.current=!1,j.current=e.clientX,M.current=H?0:N.current,L(!H),e.currentTarget.setPointerCapture(e.pointerId)))},de=e=>{if(D.current!==e.pointerId)return;let t=e.clientX-j.current,n=M.current-t;if(O.current===`collapsed`){if(!k.current&&n<CQ)return;k.current||(k.current=!0,A.current=!0,z(!0),L(!0))}U(n)},fe=e=>{if(D.current===e.pointerId){if(O.current===`inline`||k.current){let t=e.clientX-j.current;U(M.current-t)}le(e.pointerId)}},pe=e=>{D.current===e.pointerId&&le(e.pointerId)},me=(0,Y.useCallback)((e,t)=>{C?.(e,t),ne({type:`update-workspace`,workspace:e,activity:t,visibleWorkspace:p})},[C,p]);(0,Y.useEffect)(()=>{ne({type:`reset`})},[e]),(0,Y.useEffect)(()=>{p!==`memory`&&ne({type:`mark-workspace-visible`,workspace:p})},[p]),(0,Y.useEffect)(()=>{S?.(te)},[S,te]),(0,Y.useEffect)(()=>{I||(N.current=u),!F&&(D.current=null,O.current=null,k.current=!1,A.current=!1,N.current=u)},[F,I,u]);let he=()=>{if(A.current){A.current=!1;return}d||v?.()};return(0,Z.jsx)(FY,{activeProjectId:e,refreshKey:w,onLoadedProjectIdChange:_,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,children:(0,Z.jsxs)(`div`,{ref:T,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(DQ,{activeProjectId:e,onActivity:e=>{me(`board`,e)}}),(0,Z.jsx)(OQ,{activeProjectId:e,onActivity:e=>{me(`chat`,e)}}),p===`memory`?(0,Z.jsx)(`div`,{id:`project-workspace-panel-memory`,role:`tabpanel`,"aria-labelledby":`project-workspace-tab-memory`,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(pQ,{activeProject:t})}):(0,Z.jsxs)(`div`,{id:p===`chat`?`project-workspace-panel-chat`:`project-workspace-panel-board`,role:`tabpanel`,"aria-labelledby":p===`chat`?`project-workspace-tab-chat`:`project-workspace-tab-board`,className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:p===`chat`?(0,Z.jsx)(dQ,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeTool:i,isExternallyResizing:I,onRestoreSessionTarget:a,onReviewCapabilityChange:o,showChangesPanel:ce}):(0,Z.jsx)(pX,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:s,onRunStopped:b,onRunStatusChange:x,refreshKey:w})}),[oe?(0,Z.jsx)(yc,{content:d?f??`Preview unavailable`:`Open preview`,disabled:!H,side:`left`,children:(0,Z.jsx)(`div`,{"aria-label":H?f??`Show preview`:`Resize preview pane`,"aria-orientation":H?void 0:`vertical`,className:H?`group flex shrink-0 touch-none select-none items-center justify-center border-l border-border/70 bg-background/90 transition-colors ${d?`cursor-not-allowed text-muted-foreground/60`:`cursor-col-resize text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`:`group flex w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 ${I?`bg-background`:``}`,"data-preview-divider":`true`,"data-testid":H?`collapsed-preview-rail`:void 0,onLostPointerCapture:pe,onPointerCancel:fe,onPointerDown:ue,onPointerMove:de,onPointerUp:fe,onClick:H?he:void 0,onKeyDown:H?e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),he())}:void 0,ref:E,role:H?`button`:`separator`,style:H?{width:`${SQ}px`}:void 0,tabIndex:H?d?-1:0:void 0,children:H?(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(fQ,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]}):(0,Z.jsx)(`div`,{className:`h-14 w-1.5 rounded-full transition-colors ${I?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`}`})})},`preview-divider`):null,ae?(0,Z.jsx)(`div`,{className:V?`fixed inset-0 z-50 bg-black/70 p-4 sm:p-6`:`min-h-0 shrink-0 border-l border-border/70 bg-[#11131a]`,style:V?void 0:{width:`${se}px`},children:(0,Z.jsx)(`div`,{className:`h-full w-full`,children:l})},`preview-container`):null]]})]})})},AQ=({isExpanded:e,isVisible:t,project:n,onClose:r,onToggleExpanded:i})=>(0,Z.jsx)(`div`,{className:[`fixed inset-x-4 bottom-24 z-40`,e?`top-20`:`h-[min(28rem,calc(100vh-8rem))]`,t?`block`:`hidden`].join(` `),children:(0,Z.jsx)(FW,{createSession:()=>xT(n.id),isExpanded:e,isVisible:t,ariaLabel:`Project terminal for ${n.name}`,title:n.name,closeLabel:`Close terminal`,className:e?`h-full w-full rounded-2xl shadow-2xl`:`mx-auto h-full max-w-6xl shadow-2xl`,onClose:r,onToggleExpanded:i})}),jQ=({activeWorkspace:e,activityByWorkspace:t,memoryEnabled:n=!1,onWorkspaceChange:r})=>(0,Z.jsx)(`div`,{role:`tablist`,"aria-label":`Project workspace`,className:`inline-flex items-end gap-1 border-b border-border/70`,children:(n?[`board`,`chat`,`memory`]:[`board`,`chat`]).map(n=>{let i=e===n,a=yQ(t[n],i),o=n===`board`?`border-sky-300/70 bg-sky-500/8 text-sky-200`:n===`memory`?`border-amber-300/70 bg-amber-500/8 text-amber-200`:`border-emerald-300/70 bg-emerald-500/8 text-emerald-200`;return(0,Z.jsx)(`button`,{id:`project-workspace-tab-${n}`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`project-workspace-panel-${n}`,tabIndex:i?0:-1,className:G(`cursor-pointer rounded-t-lg border-b-2 px-4 py-2.5 text-[15px] font-medium transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,i?o:`border-transparent text-muted-foreground hover:border-border hover:bg-background/35 hover:text-foreground`),onClick:()=>r(n),children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:n===`board`?`Board`:n===`memory`?`Memory`:`Chat`}),(0,Z.jsx)(Il,{state:a,className:`mt-0`})]})},n)})}),MQ=32,NQ=5.5,PQ=2,FQ=24,IQ=8,LQ=new Map,RQ={running:{fill:`#fcd34d`,stroke:`#f59e0b`},finished:{fill:`#34d399`,stroke:`#059669`},error:{fill:`#fb7185`,stroke:`#e11d48`}},zQ=e=>e.replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`),BQ=e=>{if(!e)return null;let t=e.trim().match(/^([0-9]+(?:\.[0-9]+)?)/);return t?Number(t[1]):null},VQ=e=>{let t=new DOMParser().parseFromString(e,`image/svg+xml`);if(t.querySelector(`parsererror`))return null;let n=t.documentElement;if(n.nodeName.toLowerCase()!==`svg`)return null;let r=n.getAttribute(`viewBox`)?.trim(),i=BQ(n.getAttribute(`width`)),a=BQ(n.getAttribute(`height`)),o=r??(i&&a?`0 0 ${i} ${a}`:`0 0 ${MQ} ${MQ}`);return`<svg ${[Array.from(n.attributes).filter(e=>![`width`,`height`,`viewBox`,`x`,`y`,`preserveAspectRatio`].includes(e.name)).map(e=>`${e.name}="${zQ(e.value)}"`).join(` `),`x="0"`,`y="0"`,`width="${MQ}"`,`height="${MQ}"`,`viewBox="${zQ(o)}"`,`preserveAspectRatio="xMidYMid meet"`].filter(e=>e.length>0).join(` `)}>${n.innerHTML}</svg>`},HQ=async e=>{if(!e)return null;let t=LQ.get(e);if(t)return t;let n=(async()=>{try{if(e.startsWith(`data:image/svg+xml,`))return VQ(decodeURIComponent(e.slice(19)));if(e.startsWith(`data:image/svg+xml;base64,`))return VQ(atob(e.slice(26)));let t=await fetch(e);return t.ok?VQ(await t.text()):null}catch{return null}})();return LQ.set(e,n),n},UQ=async(e,t)=>{let{fill:n,stroke:r}=RQ[e],i=await HQ(t);return i?[`<svg xmlns="http://www.w3.org/2000/svg" width="${MQ}" height="${MQ}" viewBox="0 0 ${MQ} ${MQ}">`,i,`<circle cx="${FQ}" cy="${IQ}" r="${NQ}" fill="${n}" stroke="${r}" stroke-width="${PQ}"/>`,`</svg>`].join(``):null},WQ=async(e,t)=>{if(!e)return t;let n=await UQ(e,t);return n?`data:image/svg+xml,${encodeURIComponent(n)}`:t},GQ=()=>{let e=document.querySelector(`link[rel="icon"]`);if(e)return e;let t=document.createElement(`link`);return t.rel=`icon`,document.head.appendChild(t),t},KQ=({defaultHref:e,state:t})=>{let n=GQ(),r=Number(n.dataset.browserTabActivityRequestId??`0`)+1;if(n.dataset.browserTabActivityState=t??`default`,n.dataset.browserTabActivityRequestId=String(r),!t){if(e){n.href=e;return}n.removeAttribute(`href`);return}WQ(t,e).then(e=>{if(n.dataset.browserTabActivityRequestId===String(r)){if(e){n.href=e;return}n.removeAttribute(`href`)}})},qQ=(e,t)=>Ne.t(`common:projectFooter.${e}`,t),JQ=1e3,YQ=`archon.active-project-id`,XQ=`archon.workspace-by-project`,ZQ=`archon.preview-mode-by-project`,QQ=`archon.dismissed-preview-run-context-by-project`,$Q=5e3,e$=`archon.preview-pane-width`,t$=`archon.preview-viewport-preset`,n$=`archon.preview-zoom`,r$=480,i$=`responsive`,a$=1,o$={hasMounted:!1,isOpen:!1,isExpanded:!1},s$=`hidden`,c$=(0,Y.lazy)(()=>WW(()=>Promise.resolve().then(()=>nJ).then(e=>({default:e.TicketChangesModal})),void 0)),l$=(0,Y.lazy)(()=>WW(()=>import(`./TestsDialog-BtSHirWO.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),u$=e=>{if(!e)return null;try{return JSON.parse(e)}catch{return null}},d$=e=>{let t=u$(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0):[]},f$=e=>{let t=u$(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.name==`string`?t.name:``,r=typeof t.cmd==`string`?t.cmd:``,i=typeof t.cwd==`string`?t.cwd:``;return n.trim()===``&&r.trim()===``&&i.trim()===``?[]:[{name:n,cmd:r,cwd:i}]}):[]},p$=e=>{let t=u$(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.source==`string`?t.source:``,r=typeof t.target==`string`?t.target:``,i=t.mode===`copy`||t.mode===`symlink`?t.mode:`copy`;return n.trim()===``&&r.trim()===``?[]:[{source:n,target:r,mode:i}]}):[]},m$=e=>({name:e.name,repoPath:e.repo_path,linkedProjectIds:e.linked_project_ids,runSetup:d$(e.run_setup),runServices:f$(e.run_services),testCommands:uY(e.test_commands),runIde:e.run_ide??``,previewServiceName:e.preview_service_name??``,previewPath:e.preview_path??``,previewCapabilityMode:e.preview_capability_mode??`auto`,helperModel:e.helper_model??``,helperVariant:e.helper_variant??``,commitMessageRules:e.commit_message_rules??``,autoParkStaleTickets:e.auto_park_stale_tickets,memoryEnabled:e.memory_enabled,worktreeSync:p$(e.worktree_sync)}),h$=e=>{let t=e.testCommands??[],n=e.previewServiceName?.trim()||null,r=e.previewPath?.trim()||``,i=r===``||r===`/`?null:r,a=n||i||e.previewCapabilityMode===`force_web`||e.previewCapabilityMode===`force_disabled`?e.previewCapabilityMode??`auto`:null;return{name:e.name,repo_path:e.repoPath,linked_project_ids:e.linkedProjectIds,run_setup:e.runSetup.length>0?e.runSetup:null,run_services:e.runServices.length>0?e.runServices.map(e=>({...e.name?{name:e.name}:{},cmd:e.cmd,...e.cwd?{cwd:e.cwd}:{}})):null,...t.length>0?{test_commands:t.map(e=>({id:e.id,name:e.name,command:e.command,runner:e.runner,...e.cwd?{cwd:e.cwd}:{}}))}:{},run_ide:e.runIde||null,preview_service_name:n,preview_path:i,preview_capability_mode:a,helper_model:e.helperModel||null,helper_variant:e.helperModel&&e.helperVariant||null,commit_message_rules:e.commitMessageRules||null,auto_park_stale_tickets:e.autoParkStaleTickets,memory_enabled:e.memoryEnabled,worktree_sync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source,...e.target?{target:e.target}:{},mode:e.mode})):null}},g$=e=>e?d$(e.run_setup).length>0||f$(e.run_services).length>0||(e.run_ide?.trim().length??0)>0:!1,_$=(e,t,n)=>`${e} ${e===1?t:n}`,v$=e=>{if(!e.repo_path_locked)return null;let t=[];return e.ticket_count>0&&t.push(_$(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&t.push(_$(e.worktree_count,`worktree exists`,`worktrees exist`)),t.length===0?`Repository path is locked for this project.`:`Repository path is locked because ${t.join(` and `)}.`},y$=(e,t)=>{if(t.length<=1)return`Keep at least one project in Archon.`;let n=[];e.ticket_count>0&&n.push(_$(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&n.push(_$(e.worktree_count,`worktree exists`,`worktrees exist`));let r=t.filter(t=>t.linked_project_ids.includes(e.id)).length;return r>0&&n.push(_$(r,`project links to it`,`projects link to it`)),n.length===0?null:`This project can't be deleted while ${n.join(` and `)}.`},b$=(e,t)=>e.id!==t.projectId||e.ticket_count===t.ticketCount&&e.worktree_count===t.worktreeCount&&e.repo_path_locked===t.repoPathLocked?e:{...e,ticket_count:t.ticketCount,worktree_count:t.worktreeCount,repo_path_locked:t.repoPathLocked},x$=(e,t)=>({projectId:e,branch:t.branch,status:t.status,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.has_upstream??!1,canPull:t.can_pull??!1,diffStats:t.diff_stats??null}),S$=e=>({projectId:e,branch:null,status:`loading`,ahead:0,behind:0,hasUpstream:!1,canPull:!1,diffStats:null}),C$=(e,t)=>t?e[t]??o$:o$,w$=(e,t)=>t?e[t]??s$:s$,T$=()=>{let e=window.localStorage.getItem(e$),t=Number(e);return Number.isFinite(t)&&t>=320?t:r$},E$=()=>{let e=window.localStorage.getItem(t$);return e===`phone`||e===`tablet`||e===`laptop`||e===`responsive`?e:i$},D$=()=>{let e=Number(window.localStorage.getItem(n$));return Number.isFinite(e)&&e>0?e:a$},O$=()=>{let e=u$(window.localStorage.getItem(XQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`board`||e===`chat`||e===`memory`))},k$=()=>{let e=u$(window.localStorage.getItem(ZQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`hidden`||e===`inline`||e===`expanded`))},A$=()=>{let e=u$(window.localStorage.getItem(QQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`||e===null))},j$=e=>!!e?.preview_service_name?.trim()&&e?.preview_capability_mode!==`force_disabled`,M$=({activeRun:e,project:t})=>{if(!e||e.kind!==`project`||!t)return!1;let n=t.active_target_kind??`repo_root`,r=t.active_target_bundle_id??null;return e.project_id===t.id&&(e.target_kind??`repo_root`)===n&&((e.target_kind??`repo_root`)!==`bundle`||e.target_bundle_id===r)},N$=({activeRun:e,project:t,projectId:n})=>!e||!n?null:e.kind===`ticket`?e.project_id===n?e:null:M$({activeRun:e,project:t})?e:null,P$=`Project root has uncommitted changes. Confirm branch switch to continue.`,F$=({activeProject:e,activeProjectBranchState:t,nextTarget:n})=>e?n.kind===`bundle`?e.active_target_kind!==`bundle`||e.active_target_bundle_id!==n.bundleId:e.active_target_kind===`bundle`?!0:n.branch?t?.branch!==n.branch:!1:!1,I$=()=>{let[e,t]=(0,Y.useState)(`opencode`),[n,r]=(0,Y.useState)(!1),[i,o]=(0,Y.useState)([]),[s,c]=(0,Y.useState)(()=>window.localStorage.getItem(YQ)),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[g,_]=(0,Y.useState)({}),[y,b]=(0,Y.useState)({}),[x,C]=(0,Y.useState)({}),[w,T]=(0,Y.useState)({}),[E,D]=(0,Y.useState)({}),[k,A]=(0,Y.useState)(k$),[j,N]=(0,Y.useState)(A$),[P,I]=(0,Y.useState)(T$),[L,R]=(0,Y.useState)(E$),[z,B]=(0,Y.useState)(D$),[ee,te]=(0,Y.useState)(null),[ne,V]=(0,Y.useState)([]),[re,H]=(0,Y.useState)(!1),[ie,se]=(0,Y.useState)(``),[ce,U]=(0,Y.useState)(``),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(null),[he,ge]=(0,Y.useState)(null),[W,_e]=(0,Y.useState)(null),[ye,be]=(0,Y.useState)(!1),[G,xe]=(0,Y.useState)({}),[Se,Ce]=(0,Y.useState)(O$),[we,Te]=(0,Y.useState)(()=>hQ()),[Ee,Oe]=(0,Y.useState)(()=>mQ()),[K,Ae]=(0,Y.useState)(0),[je,Me]=(0,Y.useState)(null),[Ne,Pe]=(0,Y.useState)(null),[Fe,Ie]=(0,Y.useState)({}),[Le,Re]=(0,Y.useState)({}),[ze,Be]=(0,Y.useState)({}),[Ve,He]=(0,Y.useState)({}),[We,Ge]=(0,Y.useState)(!1),[Ke,Je]=(0,Y.useState)(!1),[Ye,Xe]=(0,Y.useState)(null),Qe=(0,Y.useRef)(null),et=(0,Y.useRef)(null),q=(0,Y.useRef)(null),J=i.find(e=>e.id===s)??null,tt=!!J?.memory_enabled,nt=s?Se[s]??`board`:`board`,rt=nt===`memory`?tt?`memory`:`board`:nt,it=J!==null,at=g$(J),ot=!!J?.run_ide?.trim(),st=s!==null&&d===s,ct=s!==null&&(!at||p===s),lt=s?g[s]??S$(s):null,ut=s?y[s]??null:null,dt=s?!!x[s]:!1,ft=s?w[s]??null:null,pt=s?Fe[s]??[]:[],mt=s?!!Le[s]:!1,ht=s?ze[s]??{current_branch:null,default_branch:null,previous_branch:null}:{current_branch:null,default_branch:null,previous_branch:null},gt=s?!!Ve[s]:!1,_t=s?E[s]??null:null,vt=w$(k,s),X=vt!==`hidden`,yt=N$({activeRun:l,project:J,projectId:s}),bt=yt?.context_key??null,xt=s?j[s]??null:null,St=j$(J),Ct=bt===ee,Tt=(0,Y.useMemo)(()=>_Q(we),[we]),Et=(0,Y.useMemo)(()=>vQ({hasRunning:Tt.hasRunning,hasFinishedUnseen:Ee.hasFinishedUnseen,hasErrorUnseen:Ee.hasErrorUnseen}),[Tt.hasRunning,Ee.hasErrorUnseen,Ee.hasFinishedUnseen]);(0,Y.useEffect)(()=>{Me(null),Pe(null),et.current=null},[s]),(0,Y.useEffect)(()=>{Pe(null)},[rt]),(0,Y.useEffect)(()=>{X||(et.current=null)},[X]),(0,Y.useEffect)(()=>{let e=je?.target?.kind??null;if(e===`ticket`||e===`bundle`){et.current=je;return}(rt===`board`||!X)&&(et.current=je)},[X,je,rt]),(0,Y.useEffect)(()=>{Te(hQ())},[s]),(0,Y.useEffect)(()=>{Oe(mQ())},[s]);let Dt=(0,Y.useCallback)((e,t)=>{document.visibilityState!==`visible`&&(!t.didFinish&&!t.didError||Oe(e=>{let n={...e,hasFinishedUnseen:e.hasFinishedUnseen||t.didFinish,hasErrorUnseen:e.hasErrorUnseen||t.didError};return e.hasFinishedUnseen===n.hasFinishedUnseen&&e.hasErrorUnseen===n.hasErrorUnseen?e:n}))},[]);(0,Y.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&Oe(e=>!e.hasFinishedUnseen&&!e.hasErrorUnseen?e:{...e,hasFinishedUnseen:!1,hasErrorUnseen:!1})};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]),(0,Y.useEffect)(()=>(Qe.current===null&&(Qe.current=document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)??`/favicon.svg`),KQ({defaultHref:Qe.current,state:Et}),()=>{KQ({defaultHref:Qe.current,state:null})}),[Et]);let Ot=(0,Y.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;try{let t=await ue(e,r,{refreshRemote:n});if(r?.aborted)return;_(n=>({...n,[e]:x$(e,t)}))}catch(t){if(S(t))return;if(t instanceof O&&t.status===404){_(t=>({...t,[e]:{...S$(e),status:`unknown`}}));return}_(t=>({...t,[e]:{projectId:e,branch:t[e]?.branch??null,status:`unknown`,ahead:t[e]?.ahead??0,behind:t[e]?.behind??0,hasUpstream:t[e]?.hasUpstream??!1,canPull:t[e]?.canPull??!1,diffStats:t[e]?.diffStats??null}}))}},[]),kt=(0,Y.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r,suppressLoading:i=!1}=t;i||C(t=>({...t,[e]:!0}));try{let t=await ke(e,{refreshRemote:n,signal:r});if(r?.aborted)return;b(n=>({...n,[e]:t}))}catch(t){if(S(t))return;t instanceof O&&t.status===404&&b(t=>({...t,[e]:null}))}finally{!r?.aborted&&!i&&C(t=>({...t,[e]:!1}))}},[]),At=(0,Y.useCallback)((e,t)=>{T(n=>({...n,[e]:t}))},[]),jt=(0,Y.useCallback)(async(e,t)=>{b(n=>({...n,[e.id]:t})),e.active_target_kind!==`bundle`&&await Ot(e.id),KK(e.id)},[Ot]);(0,Y.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let{tool:n}=await Cn(e.signal);t(n)}catch(e){S(e)}finally{e.signal.aborted||r(!0)}})(),()=>{e.abort()}},[]),(0,Y.useEffect)(()=>{if(!de||i.length>0&&pe===null||re)return;let e=new AbortController;return(async()=>{try{V(await Sn(`opencode`,e.signal))}catch(e){S(e)||V(e=>e)}finally{e.signal.aborted||H(!0)}})(),()=>{e.abort()}},[re,pe,i.length,de]),(0,Y.useEffect)(()=>{let e=new AbortController,t=window.localStorage.getItem(YQ);return(async()=>{try{let n=await le(e.signal);if(e.signal.aborted)return;o(n);let r=n[0]?.id??null;c(n.some(e=>e.id===t)?t:r)}catch(e){S(e)||o([])}finally{e.signal.aborted||fe(!0)}})(),()=>{e.abort()}},[]),(0,Y.useEffect)(()=>{if(de){if(s){window.localStorage.setItem(YQ,s);return}window.localStorage.removeItem(YQ)}},[s,de]),(0,Y.useEffect)(()=>{window.localStorage.setItem(XQ,JSON.stringify(Se))},[Se]),(0,Y.useEffect)(()=>{window.localStorage.setItem(ZQ,JSON.stringify(k))},[k]),(0,Y.useEffect)(()=>{window.localStorage.setItem(QQ,JSON.stringify(j))},[j]),(0,Y.useEffect)(()=>{_(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),b(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),C(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,Y.useEffect)(()=>{xe(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,Y.useEffect)(()=>{let e=new Set(i.map(e=>e.id));Ie(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Re(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Be(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),He(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t))))},[i]),(0,Y.useEffect)(()=>{de&&(D(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),A(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),N(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}))},[i,de]),(0,Y.useEffect)(()=>{de&&Ce(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i,de]),(0,Y.useEffect)(()=>{if(!de||!s||!it)return;let e=!1,t=null,n=null;_(e=>e[s]?e:{...e,[s]:S$(s)});let r=async(r=!1)=>{let i=r?`remote`:`local`;if(t){if(n===`remote`||n===i)return;t.abort()}let a=new AbortController;t=a,n=i;try{await Promise.all([Ot(s,{refreshRemote:r,signal:a.signal}),kt(s,{refreshRemote:r,signal:a.signal})])}catch{if(e||a.signal.aborted)return}finally{t===a&&(t=null,n=null)}};r(!1);let i=YK(()=>{document.visibilityState===`visible`&&r(!1)});return()=>{e=!0,t?.abort(),i()}},[s,it,de,Ot,kt]),(0,Y.useEffect)(()=>{if(s)return qK(e=>{e===s&&(Ot(e),kt(e))})},[s,Ot,kt]),(0,Y.useEffect)(()=>{if(!s||!it)return;let e=ut?.operation_state??`idle`;if(!(ft===`rebase`||e!==`idle`))return;let t=!1,n=null,r=null,i=async()=>{r?.abort(),r=new AbortController;try{await kt(s,{signal:r.signal,suppressLoading:!0})}catch{}finally{t||(n=window.setTimeout(()=>{i()},JQ))}};return i(),()=>{t=!0,r?.abort(),n!==null&&window.clearTimeout(n)}},[ft,s,ut?.operation_state,it,kt]);let Mt=(0,Y.useCallback)(async e=>{let t=s;if(!t){u(null),m(null);return}try{let n=await Vt(t,e);e?.aborted||(u(n.active_run),m(t))}catch(e){S(e)}},[s]),Nt=(0,Y.useCallback)(async e=>{let t=s;if(t)try{let n=await Bt(t,e);e?.aborted||D(e=>({...e,[t]:n}))}catch(e){S(e)}},[s]);(0,Y.useEffect)(()=>{if(!de)return;if(!at){u(null),m(null);return}if(!st)return;let e=new AbortController;m(null),Mt(e.signal);let t=window.setInterval(()=>{Mt(e.signal)},$Q),n=YK(()=>{document.visibilityState===`visible`&&Mt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[st,at,de,Mt]),(0,Y.useEffect)(()=>{if(!de||!s||!st||!St)return;let e=new AbortController;Nt(e.signal);let t=window.setInterval(()=>{Nt(e.signal)},$Q),n=YK(()=>{document.visibilityState===`visible`&&Nt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[s,st,St,de,Nt]),(0,Y.useEffect)(()=>{window.localStorage.setItem(e$,String(P))},[P]),(0,Y.useEffect)(()=>{window.localStorage.setItem(t$,L)},[L]),(0,Y.useEffect)(()=>{window.localStorage.setItem(n$,String(z))},[z]),(0,Y.useEffect)(()=>{s&&bt&&N(e=>{let t=e[s]??null;return!t||t===bt?e:{...e,[s]:null}})},[s,bt]),(0,Y.useEffect)(()=>{!s||!yt||!j$(J)||xt!==yt.context_key&&A(e=>w$(e,s)===`hidden`?{...e,[s]:`inline`}:e)},[J,s,xt,yt]);let Pt=async e=>{try{t((await wn(e)).tool)}catch{}},Ft=(0,Y.useCallback)(e=>{o(t=>t.map(t=>t.id===e.id?e:t))},[]),It=(0,Y.useCallback)((e,t)=>{Ie(n=>{let r=[t,...(n[e]??[]).filter(e=>e.id!==t.id)];return{...n,[e]:r}})},[]),Lt=(0,Y.useCallback)(async e=>{He(t=>({...t,[e]:!0}));try{let t=await ve(e);Be(n=>({...n,[e]:t}))}catch(e){Q.error(e instanceof O?e.message:`Unable to load the project target options right now.`,{id:`project-target-selector-load-error`})}finally{He(t=>({...t,[e]:!1}))}},[]),Rt=async e=>{try{let t=await F(h$(e));return o(e=>[...e,t]),c(t.id),me(null),null}catch(e){return e instanceof O?e.message:`Unable to create the project right now.`}},Wt=async e=>{if(!J)return`Select a project before editing settings.`;try{let t=await h(J.id,h$(e));return o(e=>e.map(e=>e.id===t.id?t:e)),Ae(e=>e+1),me(null),null}catch(e){return e instanceof O?e.message:`Unable to update the project right now.`}},Gt=async()=>{if(!J)return`Select a project before deleting it.`;try{await Ue(J.id);let e=i.filter(e=>e.id!==J.id);return o(e),c(e[0]?.id??null),me(null),null}catch(e){return e instanceof O?e.message:`Unable to delete the project right now.`}},Kt=(0,Y.useCallback)(e=>{o(t=>t.map(t=>b$(t,e)))},[]),qt=(0,Y.useCallback)((e,t)=>{e&&Ie(n=>({...n,[e]:t}))},[]),Jt=(0,Y.useCallback)((e,t)=>{e&&Re(n=>({...n,[e]:t}))},[]),Yt=async(e,t,n)=>await oe({repo_path:e,helper_model:t||null,helper_variant:t&&n||null}),Xt=async()=>(await ae()).repo_path,Zt=(0,Y.useCallback)(async e=>{let t=await De({repo_path:e});return{valid:t.valid,repoRoot:t.repo_root,error:t.error,willInitialize:t.will_initialize,hasInitialCommit:t.has_initial_commit}},[]),Qt=(0,Y.useCallback)(async()=>{if(!(!J||ye)){be(!0);try{let e=await a(J.id);o(t=>t.map(t=>t.id===e.id?e:t)),Q.success(`Initial commit created.`,{id:`project-initial-commit-success`}),Ot(e.id),kt(e.id)}catch(e){Q.error(e instanceof O?e.message:`Unable to create the initial commit right now.`,{id:`project-initial-commit-error`})}finally{be(!1)}}},[J,ye,Ot,kt]),$t=(0,Y.useCallback)((e,t)=>{A(t=>({...t,[e]:`hidden`})),t&&N(n=>({...n,[e]:t}))},[]),en=(0,Y.useCallback)(()=>{s&&$t(s,bt)},[s,$t,bt]),tn=(0,Y.useCallback)(e=>{s&&(A(e=>({...e,[s]:`hidden`})),e&&u(t=>t?.context_key===e?null:t))},[s]),nn=(0,Y.useCallback)(async()=>{if(!yt||ee===yt.context_key)return;let{context_key:e}=yt;te(e);try{yt.kind===`ticket`?await hn(yt.ticket_id,yt.project_id):u((await Ut(yt.project_id)).active_run),tn(e),await Promise.all([Mt(),Nt()])}catch(e){Q.error(e instanceof O?e.message:`Unable to stop the preview run right now.`,{id:`app-preview-run-stop-error`})}finally{te(t=>t===e?null:t)}},[tn,yt,Nt,Mt,ee]),rn=(0,Y.useCallback)(e=>{!e||!s||Lt(s)},[s,Lt]),an=(0,Y.useCallback)(e=>new Promise(t=>{q.current=t,Xe(e)}),[]),on=(0,Y.useCallback)(e=>{let t=q.current;q.current=null,Xe(null),t?.(e)},[]),sn=(0,Y.useCallback)(async e=>{if(!J||!s)throw Error(`Select a project first.`);if(!F$({activeProject:J,activeProjectBranchState:lt,nextTarget:e})||!l||l.kind!==`project`||l.project_id!==J.id)return!0;if(!await an({title:`Stop current run and switch target?`,description:`Switching targets will stop the current run and close its preview.`,confirmLabel:`Stop and switch`,cancelLabel:`Keep current target`,confirmVariant:`destructive`}))return!1;try{let e=l.context_key,t=await Ut(J.id);return tn(e),u(t.active_run),await Nt(),!0}catch(e){return Q.error(e instanceof O?e.message:`Unable to stop the project run right now.`,{id:`project-target-switch-stop-run-error`}),!1}},[J,lt,s,l,tn,Nt,an]),cn=(0,Y.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);return await sn({kind:`bundle`,bundleId:e})?(Ft(await M(s,{kind:`bundle`,bundle_id:e})),b(e=>({...e,[s]:null})),await Promise.all([Ot(s),kt(s)]),!0):!1},[s,sn,Ot,kt,Ft]),ln=(0,Y.useCallback)(async(e,t={})=>{if(!s)throw Error(`Select a project first.`);if(!await sn({kind:`repo_root`,branch:e}))return!1;let n=n=>M(s,{kind:`repo_root`,...e?{branch:e}:{},...t.createBranch===!1?{create_branch:!1}:{},...n?{confirm_dirty_switch:!0}:{}}),r;try{r=await n(t.confirmDirtySwitch===!0)}catch(e){if(!t.confirmDirtySwitch&&e instanceof O&&e.status===409&&e.message===P$){if(!await an({title:`Switch repo root branch?`,description:`${P$}\n\nSwitch anyway?`,confirmLabel:`Switch anyway`,cancelLabel:`Keep current branch`}))return!1;r=await n(!0)}else throw e}return Ft(r),b(e=>({...e,[s]:null})),await Promise.all([Ot(s),kt(s),Lt(s)]),!0},[s,sn,Lt,Ot,kt,Ft,an]),un=(0,Y.useCallback)(async e=>!e.target_kind||e.target_available===!1?!0:e.target_kind===`bundle`?e.target_bundle_id?await cn(e.target_bundle_id):!1:await ln(e.target_branch_snapshot??null,{createBranch:!1}),[cn,ln]),dn=(0,Y.useCallback)(()=>{Ge(!0)},[]),fn=(0,Y.useCallback)(()=>{Ge(!1)},[]),pn=(0,Y.useCallback)(e=>{if(e){cn(e);return}ln(null)},[cn,ln]),mn=(0,Y.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);let t=await wt(s,{name:e,prepare:!0});return It(s,t),Ae(e=>e+1),t},[s,It]),gn=(0,Y.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);await zt(s,e),Ie(t=>({...t,[s]:(t[s]??[]).filter(t=>t.id!==e)})),Ae(e=>e+1)},[s]),_n=(0,Y.useCallback)(async()=>{if(!J)return;let e=J.active_target_kind??`repo_root`,t=J.active_target_bundle_id??null,n=l?.kind===`project`&&l.project_id===J.id&&(l.target_kind??`repo_root`)===e&&((l.target_kind??`repo_root`)!==`bundle`||l.target_bundle_id===t),r=n?l?.context_key??null:null,i=!n&&j$(J)&&vt===`hidden`;i&&(A(e=>({...e,[J.id]:`inline`})),N(e=>({...e,[J.id]:null})));try{let e=n?await Ut(J.id):await Ht(J.id);n&&tn(r),u(e.active_run),Nt()}catch(e){i&&A(e=>({...e,[J.id]:`hidden`})),Q.error(e instanceof O?e.message:`Unable to update the project run right now.`,{id:`app-project-run-error`})}},[vt,J,l,tn,Nt]),vn=(0,Y.useCallback)(async()=>{if(!(!J||!ot))try{await qe(J.id)}catch(e){Q.error(e instanceof Error?e.message:`Unable to open the IDE right now.`,{id:`app-project-open-ide-error`})}},[J,ot]),yn=(0,Y.useCallback)(async()=>{if(J){At(J.id,`pull`);try{let e=await $e(J.id);await jt(J,e),Q.success(e.behind===0?qQ(`branchSynced`):qQ(`branchUpdated`),{id:`app-project-pull-success`})}catch(e){Q.error(e instanceof O?e.message:qQ(`syncFallbackError`),{id:`app-project-pull-error`})}finally{At(J.id,null)}}},[J,jt,At]),bn=(0,Y.useCallback)(async()=>{if(!J)return;let e=ut?.base_branch??null;At(J.id,`rebase`);try{let t=await Ze(J.id);await jt(J,t);let n=t.base_branch??e;Q.success(n?qQ(`branchRebasedOnto`,{branch:n}):qQ(`branchRebased`),{id:`app-project-rebase-success`})}catch(e){await Promise.allSettled([Ot(J.id),kt(J.id,{suppressLoading:!0})]),Q.error(e instanceof O?e.message:qQ(`rebaseFallbackError`),{id:`app-project-rebase-error`})}finally{At(J.id,null)}},[J,ut?.base_branch,jt,Ot,kt,At]),xn=(0,Y.useCallback)(async()=>{if(J){At(J.id,`abort`);try{await jt(J,await v(J.id)),Q.success(qQ(`gitOperationAborted`),{id:`app-project-abort-success`})}catch(e){Q.error(e instanceof O?e.message:qQ(`abortFallbackError`),{id:`app-project-abort-error`})}finally{At(J.id,null)}}},[J,jt,At]),Tn=(0,Y.useCallback)(()=>{J&&ge({projectId:J.id,title:J.name})},[J]),En=(0,Y.useCallback)(()=>{if(!he)return;let{projectId:e}=he;ge(null),Ot(e),kt(e)},[Ot,kt,he]),Dn=(0,Y.useCallback)(()=>{J&&_e({projectId:J.id,targetKind:J.active_target_kind??`repo_root`,targetBundleId:J.active_target_bundle_id??null})},[J]),On=(0,Y.useCallback)(()=>{_e(null)},[]),kn=C$(G,s),An=J?uY(J.test_commands).length>0:!1,jn=rt===`chat`?Ne:null,Mn=et.current,Nn=Mn?.target?.kind??null,Pn=rt===`chat`?Nn===`ticket`||Nn===`bundle`?{target:Mn?.target??null,canSelect:!1,disabledReason:`This preview belongs to a ticket run. Return to Board to send preview comments.`,promptMode:Mn?.promptMode??null,onPromptModeChange:Mn?.onPromptModeChange??null,isUpdatingPromptMode:Mn?.isUpdatingPromptMode??!1,promptPlaceholder:Mn?.promptPlaceholder??null,promptComposerControls:Mn?.promptComposerControls,promptComposerInlineControls:Mn?.promptComposerInlineControls,submitPrompt:null}:jn?{target:{kind:`chat_session`,id:jn.chatSessionId??`draft:${s}`},canSelect:jn.canSubmitReviewPrompt,disabledReason:jn.canSubmitReviewPrompt?null:jn.reviewSubmitDisabledReason??`Wait for the current chat turn to finish before sending preview comments.`,promptMode:jn.mode,onPromptModeChange:jn.onModeChange,isUpdatingPromptMode:jn.isUpdatingMode,promptPlaceholder:jn.promptPlaceholder,promptComposerControls:jn.promptComposerControls,promptComposerInlineControls:jn.promptComposerInlineControls,submitPrompt:jn.canSubmitReviewPrompt?jn.submitPrompt:null}:{target:null,canSelect:!1,disabledReason:`Select a chat session to send preview comments.`,submitPrompt:null}:je,Fn=jn?.canSubmitReviewPrompt??!1,In=rt===`chat`?jn?jn.reviewSubmitDisabledReason:`Select a chat session to send review comments.`:void 0,Ln=(0,Y.useCallback)(()=>{s&&xe(e=>{let t=e[s]??o$;return{...e,[s]:{hasMounted:!0,isOpen:!t.isOpen,isExpanded:t.isExpanded}}})},[s]),Rn=(0,Y.useCallback)(e=>{xe(t=>{let n=t[e]??o$;return!n.hasMounted||!n.isOpen?t:{...t,[e]:o$}})},[]),zn=(0,Y.useCallback)(e=>{xe(t=>{let n=t[e]??o$;return{...t,[e]:{hasMounted:!0,isOpen:n.isOpen,isExpanded:!n.isExpanded}}})},[]),Bn=(0,Y.useCallback)(()=>{me(`create`)},[]),Vn=(0,Y.useCallback)(()=>{if(s){if(X){en();return}A(e=>({...e,[s]:`inline`})),N(e=>({...e,[s]:null}))}},[s,en,X]),Hn=(0,Y.useCallback)(()=>{s&&A(e=>{let t=w$(e,s);return{...e,[s]:t===`expanded`?`inline`:`expanded`}})},[s]),Un=J?J.preview_service_name?.trim()?J.preview_capability_mode===`force_disabled`?`Preview is disabled for this project.`:_t?.state===`unsupported`?_t.message??`Preview is unavailable for this project.`:X?`Hide preview`:`Show preview`:`Choose a named preview service in project settings first.`:`Select a project first.`,Wn=!J||!J.preview_service_name?.trim()||J.preview_capability_mode===`force_disabled`||_t?.state===`unsupported`,Gn=J&&J.preview_service_name?.trim()?(0,Z.jsx)(Jb,{project:J,mode:vt===`expanded`?`expanded`:`inline`,status:_t,viewportPreset:L,zoom:z,activeRun:yt,reviewCapability:Pn,isStoppingActiveRun:Ct,onHide:en,onStopActiveRun:()=>{nn()},onToggleExpanded:Hn,onViewportPresetChange:R,onZoomChange:B}):null;return(0,Z.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-[linear-gradient(180deg,_rgba(15,16,21,1),_rgba(9,10,14,1))] text-foreground`,children:[(0,Z.jsx)(iu,{}),i.length>0&&(0,Z.jsx)(`header`,{className:`border-b border-border bg-background/95 px-6 py-3 backdrop-blur`,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-center`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 lg:justify-self-start`,children:(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-[20rem] sm:max-w-[30rem]`,children:(0,Z.jsx)(wc,{activeProjectId:s,projects:i,onEditProject:()=>me(`edit`),onProjectChange:c})})}),s&&(0,Z.jsx)(`div`,{className:`flex justify-start lg:col-start-2 lg:row-start-1 lg:justify-center`,children:(0,Z.jsx)(jQ,{activeWorkspace:rt,activityByWorkspace:we,memoryEnabled:tt,onWorkspaceChange:e=>{s&&(Ce(t=>({...t,[s]:e})),Te(t=>gQ(t,e)))}})}),(0,Z.jsx)(`div`,{className:`w-full lg:col-start-3 lg:row-start-1 lg:w-auto lg:justify-self-end`,children:(0,Z.jsx)(ru,{activeTool:e,onCreateProject:Bn,onMobileAccessOpen:()=>Je(!0),onToolChange:Pt})})]})}),de?i.length===0?(0,Z.jsx)(Sc,{activeTool:e,availableHelperModels:ne,helperModel:ie,helperVariant:ce,isHelperModelsLoaded:re,isToolLoaded:n,onCreateProject:Bn,onHelperModelChange:e=>{se(e),U(``)},onHelperVariantChange:U,onToolChange:Pt}):(0,Z.jsxs)(Z.Fragment,{children:[J?.has_initial_commit===!1&&(0,Z.jsx)(pu,{isSubmitting:ye,onCreateInitialCommit:()=>{Qt()}}),(0,Z.jsx)(kQ,{activeProjectId:s,activeProject:J,activeProjectBranchState:lt,activeRun:l,activeTool:e,onRestoreChatSessionTarget:un,onChatReviewCapabilityChange:Pe,isPreviewButtonDisabled:Wn,onPreviewReviewCapabilityChange:Me,onPreviewToggle:Vn,onRunStopped:tn,onWorkspaceActivityChange:Te,onWorkspaceActivityEvent:Dt,previewDisplayMode:vt,previewPane:Gn,previewPaneWidth:P,previewButtonTitle:Un,visibleWorkspace:rt,refreshKey:K,onBoardLoadedProjectIdChange:f,onBundlesChange:qt,onBundlesLoadingChange:Jt,onPreviewPaneWidthChange:I,onProjectUsageChange:Kt,onRunStatusChange:()=>{Mt(),Nt()}},s??`no-project`)]}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading projects...`}),i.length>0&&(0,Z.jsx)(Fl,{activeProject:J,activeRun:l,branchState:lt,targetGitStatus:ut,isBoardLoadedForActiveProject:st,activeProjectBranchAction:ft,isProjectIdeAvailable:ot,isProjectRunAvailable:at,isRunStatusLoadedForActiveProject:ct,isTerminalOpen:kn.isOpen,targetBundles:pt,targetBranchSuggestions:ht,isTargetBundleLoading:mt,isTargetSelectorLoading:gt,isTargetGitStatusLoading:dt,hasConfiguredTests:An,onProjectIdeOpen:()=>{vn()},onProjectPull:()=>{yn()},onProjectRebase:bn,onProjectAbortGitOperation:xn,onProjectRunToggle:()=>{_n()},onProjectChangesOpen:Tn,onProjectTestsOpen:Dn,onTerminalToggle:Ln,onTargetSelectorOpenChange:rn,onSelectBundleTarget:cn,onSelectRepoRootTarget:ln,onManageBundles:dn}),(0,Z.jsx)(Md,{activeProjectId:s,open:Ke,onOpenChange:Je}),We&&J&&(0,Z.jsx)(wu,{bundles:pt,selectedBundleId:J.active_target_kind===`bundle`?J.active_target_bundle_id??null:null,activeTargetBundleId:J.active_target_kind===`bundle`?J.active_target_bundle_id??null:null,onSelectBundle:pn,onCreateBundle:mn,onDeleteBundle:gn,onClose:fn}),Ye&&(0,Z.jsx)(fu,{title:Ye.title,description:Ye.description,confirmLabel:Ye.confirmLabel,cancelLabel:Ye.cancelLabel,confirmVariant:Ye.confirmVariant,onConfirm:()=>on(!0),onCancel:()=>on(!1)}),i.map(e=>{let t=C$(G,e.id);return t.hasMounted?(0,Z.jsx)(AQ,{project:e,isExpanded:t.isExpanded,isVisible:e.id===s&&t.isOpen,onClose:()=>Rn(e.id),onToggleExpanded:()=>zn(e.id)},e.id):null}),pe&&(0,Z.jsx)(Ip,{mode:pe,projectId:pe===`edit`&&J?J.id:null,availableHelperModels:ne,isLoadingHelperModels:!re,isAutoConfigReady:n,initialValues:pe===`edit`&&J?m$(J):i.length===0?{name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],testCommands:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:ie,helperVariant:ce,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}:void 0,linkedProjectOptions:i.filter(e=>e.id!==J?.id).map(e=>({id:e.id,name:e.name})),repoPathLocked:pe===`edit`&&J?J.repo_path_locked:!1,repoPathLockedMessage:pe===`edit`&&J?v$(J):null,deleteBlockedMessage:pe===`edit`&&J?y$(J,i):null,onDelete:pe===`edit`?Gt:void 0,onAutoConfig:Yt,onBrowseRepoPath:Xt,onValidateRepoPath:Zt,onClose:()=>me(null),onSubmit:pe===`edit`?Wt:Rt}),he&&he.projectId===s&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(c$,{scope:`project_root`,projectId:he.projectId,title:he.title,onSubmitReviewPrompt:jn?.submitPrompt,canSubmitReviewPrompt:Fn,reviewSubmitDisabledReason:In??void 0,canAddReviewComments:Fn,canModifyChanges:!0,onClose:En})}),W&&W.projectId===s&&J&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(l$,{scope:`project`,projectId:W.projectId,targetKind:W.targetKind,targetBundleId:W.targetBundleId,testCommands:uY(J.test_commands),onClose:On})})]})},L$=({className:e})=>(0,Z.jsx)(fo,{"aria-hidden":`true`,className:e}),R$=({className:e})=>(0,Z.jsx)(ho,{"aria-hidden":`true`,className:e}),z$=({className:e})=>(0,Z.jsx)(Oo,{"aria-hidden":`true`,className:e}),B$=`X-Archon-Mobile-CSRF`,V$=async(e,t={})=>{let n=await fetch(e,{credentials:`include`,...t});if(!n.ok)throw new O(await _(n,`Mobile request failed.`),n.status);return n},H$=async(e,t={})=>await(await V$(e,t)).json(),U$=e=>H$(`/mobile/projects`,{signal:e}),W$=(e,t)=>H$(`/mobile/projects/${encodeURIComponent(e)}/summary`,{signal:t}),G$=(e,t)=>H$(`/mobile/projects/${encodeURIComponent(e)}/target-options`,{signal:t}),K$=(e,t)=>H$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions`,{signal:t}),q$=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}`,{signal:n}),J$=(e,t)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets`,{signal:t}),Y$=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}`,{signal:n}),X$=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}`,{signal:n}),Z$=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/build`,$$(n)),Q$=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/review`,$$(n)),$$=(e,t,n=`POST`)=>({method:n,headers:{"Content-Type":`application/json`,[B$]:e},body:t===void 0?void 0:JSON.stringify(t)}),e1=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions`,$$(t,n)),t1=(e,t,n,r)=>H$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}/messages`,$$(n,r)),n1=(e,t,n,r)=>H$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}`,$$(n,r,`PATCH`)),r1=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}/stop`,$$(n)),i1=(e,t,n,r)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/state`,$$(n,{state:r},`PATCH`)),a1=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/run`,$$(n)),o1=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/stop`,$$(n)),s1=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/stop-build`,$$(n)),c1=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/resume-build`,$$(n)),l1=(e,t,n,r)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}`,$$(n,r,`PATCH`)),u1=(e,t,n,r)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/plan-follow-up`,$$(n,{instruction:r})),d1=(e,t,n,r)=>H$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/follow-up`,$$(n,{instruction:r})),f1=(e,t,n,r)=>H$(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/follow-up`,$$(n,{instruction:r})),p1=(e,t,n)=>H$(`/mobile/projects/${encodeURIComponent(e)}/target`,$$(t,n)),m1=(e,t)=>H$(`/mobile/models?tool=${encodeURIComponent(e)}`,{signal:t}),h1=(e,t,n)=>{let r=new URLSearchParams({tool:e});return t&&r.set(`project_id`,t),H$(`/mobile/skills?${r.toString()}`,{signal:n})},g1=e=>H$(`/mobile-auth/status`,{signal:e}),_1=(e,t)=>H$(`/mobile-auth/pair/preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t}),v1=e=>H$(`/mobile-auth/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),y1=e=>H$(`/mobile-auth/logout`,{method:`POST`,headers:{[B$]:e}}),b1=()=>jW(window.location.origin,{withCredentials:!0}),x1=e=>Ne.t(`common:mobileApp.${e}`),S1={key:`overview`,label:x1(`navigation.overview`),Icon:L$},C1={key:`tickets`,label:x1(`navigation.tickets`),Icon:z$,ctaAriaLabel:x1(`overviewActions.ticketsAriaLabel`)},w1={key:`chats`,label:x1(`navigation.chats`),Icon:em,ctaAriaLabel:x1(`overviewActions.chatsAriaLabel`)},T1=[S1,C1,w1],E1=`Project root has uncommitted changes. Confirm branch switch to continue.`,D1=e=>e?`Repo root (${e})`:`Repo root`,O1=e=>{if(!e)return`Repo root`;if(e.length<=20)return e;let t=e.split(`/`).filter(Boolean),n=t[t.length-1]??e;return n.length<=17?`.../${n}`:`${n.slice(0,16)}...`},k1=(e,t)=>{if(!e)return`Target`;if(e.active_target_kind===`bundle`&&e.active_target_bundle_id){let n=t?.bundles.find(t=>t.id===e.active_target_bundle_id)??null;return n?Tl(n):`Selected bundle`}return O1(t?.current_branch??null)},A1=({children:e})=>(0,Z.jsx)(`main`,{className:`min-h-screen bg-background text-foreground`,children:(0,Z.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-lg items-center px-4 py-8`,children:(0,Z.jsx)(`div`,{className:`w-full`,children:e})})}),j1=({title:e,description:t,children:n})=>(0,Z.jsx)(A1,{children:(0,Z.jsxs)(mu,{className:`w-full border-border/80 bg-card/90 shadow-2xl shadow-black/20`,children:[(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{children:e}),(0,Z.jsx)(_u,{children:t})]}),n?(0,Z.jsx)(yu,{className:`space-y-4`,children:n}):null]})}),M1=e=>e===`connected`?{label:`Connected`,variant:`success`,indicatorState:`finished`}:e===`reconnecting`?{label:`Reconnecting`,variant:`warning`,indicatorState:`running`}:e===`unavailable`?{label:`Offline`,variant:`destructive`,indicatorState:`error`}:{label:`Connecting`,variant:`outline`,indicatorState:`running`},N1=({status:e})=>{let t=M1(e);return(0,Z.jsxs)(U,{variant:t.variant,className:`gap-1.5 px-2.5 py-1 text-[11px] uppercase tracking-[0.14em]`,children:[(0,Z.jsx)(Il,{state:t.indicatorState,className:`mt-0`}),t.label]})},P1=()=>{let[e,t]=(0,Y.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(min-width: 1024px)`).matches);return(0,Y.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(min-width: 1024px)`),n=n=>{t(n?.matches??e.matches)};return n(),typeof e.addEventListener==`function`?(e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)):(e.addListener(n),()=>e.removeListener(n))},[]),e},F1=({status:e,onRetry:t})=>e===`connected`?null:e===`unavailable`?(0,Z.jsx)(mu,{className:`border-red-500/25 bg-destructive/10 shadow-none`,children:(0,Z.jsxs)(yu,{className:`flex flex-col gap-3 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-red-100`,children:`Desktop Archon is currently unreachable.`}),(0,Z.jsx)(`p`,{className:`text-sm text-red-200/85`,children:`Mobile access may have been disabled, the backend may have restarted, or this phone lost network access.`})]}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(K,{variant:`warning`,onClick:t,children:`Retry connection`})})]})}):(0,Z.jsx)(mu,{className:`border-amber-500/25 bg-amber-500/10 shadow-none`,children:(0,Z.jsx)(yu,{className:`pt-5 text-sm text-amber-100`,children:e===`connecting`?`Connecting to live updates from desktop Archon...`:`Reconnecting to desktop Archon. Existing content stays visible while this phone reconnects.`})}),I1=({title:e,description:t,children:n})=>(0,Z.jsxs)(`div`,{className:`flex max-h-[80vh] flex-col overflow-hidden`,children:[(0,Z.jsxs)(Ns,{className:`border-b border-border/70 px-4 py-4`,children:[(0,Z.jsx)(Fs,{children:e}),t?(0,Z.jsx)(Is,{children:t}):null]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:n})]}),L1=({projects:e,selectedProjectId:t,error:n,onSelectProject:r,onRetry:i})=>n?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:n}),(0,Z.jsx)(K,{variant:`warning`,onClick:i,children:`Retry projects`})]}):e?e.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No projects are available on the desktop instance yet.`}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{let n=e.id===t;return(0,Z.jsxs)(`button`,{type:`button`,className:G(`w-full rounded-2xl border px-4 py-3 text-left transition-colors`,n?`border-primary/50 bg-primary/10`:`border-border/80 bg-card/60 hover:border-primary/30 hover:bg-accent/60`),onClick:()=>r(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.repo_path})]}),n&&(0,Z.jsx)(U,{variant:`info`,children:`Current`})]}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:(0,Z.jsxs)(`span`,{children:[e.ticket_count,` tickets`]})})]},e.id)})}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading projects...`}),R1=({open:e,projects:t,selectedProjectId:n,error:r,onOpenChange:i,onSelectProject:a,onRetry:o})=>(0,Z.jsx)(Os,{open:e,onOpenChange:i,children:(0,Z.jsx)(Ms,{showCloseButton:!1,"aria-describedby":void 0,className:`top-auto right-0 bottom-0 left-0 max-w-none translate-x-0 translate-y-0 overflow-hidden rounded-t-3xl rounded-b-none border-x-0 border-b-0 p-0 sm:top-1/2 sm:right-auto sm:bottom-auto sm:left-1/2 sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl sm:border sm:p-0`,children:(0,Z.jsx)(I1,{title:`Projects`,children:(0,Z.jsx)(L1,{projects:t,selectedProjectId:n,error:r,onSelectProject:e=>{a(e),i(!1)},onRetry:o})})})}),z1=({open:e,project:t,targetOptions:n,error:r,isLoading:i,isSubmitting:a,onOpenChange:o,onRetry:s,onSelectBundle:c,onSelectRepoRoot:l})=>{let[u,d]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{e&&d(n?.current_branch??``)},[e,n?.current_branch]);let f=t?.active_target_kind!==`bundle`,p=hl(n?.bundles??[]),m=[{key:`default`,label:`Default branch`,branch:n?.default_branch??null},{key:`previous`,label:`Previous branch`,branch:n?.previous_branch??null}].filter(e=>e.branch&&e.branch!==n?.current_branch).filter((e,t,n)=>n.findIndex(t=>t.branch===e.branch)===t),h=t?r?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:r}),(0,Z.jsx)(K,{variant:`warning`,onClick:s,children:`Retry target options`})]}):n?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`Project target`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Choose the repo root or a prepared bundle for new chats and desktop work launched from this phone.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Xs,{className:`text-xs font-medium text-muted-foreground`,children:`Target`}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/70 bg-background/40 p-2`,children:[(0,Z.jsx)(K,{type:`button`,variant:f?`secondary`:`ghost`,className:`w-full justify-start`,disabled:a,onClick:()=>l(null),children:D1(n.current_branch)}),(0,Z.jsxs)(`div`,{className:`relative min-h-10`,"data-testid":`mobile-target-options`,children:[i&&(0,Z.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-10 text-muted-foreground`,"data-testid":`mobile-target-options-spinner`,children:(0,Z.jsx)(pe,{className:`h-3.5 w-3.5 animate-spin`})}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto pr-7`,children:p.length===0&&!i?(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:`No prepared bundles are available yet.`}):p.map(e=>(0,Z.jsx)(K,{type:`button`,variant:t.active_target_kind===`bundle`&&t.active_target_bundle_id===e.id?`secondary`:`ghost`,className:`w-full justify-start`,disabled:a,onClick:()=>c(e.id),children:(0,Z.jsx)(`span`,{className:`truncate`,children:Tl(e)})},e.id))})]})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Xs,{className:`text-xs font-medium text-muted-foreground`,children:`Repo root branch`}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/70 bg-background/40 p-3`,children:[(0,Z.jsx)(`div`,{className:`space-y-2`,children:m.length>0?m.map(({key:e,label:t,branch:n})=>(0,Z.jsxs)(K,{type:`button`,variant:`outline`,className:`w-full justify-between gap-3`,disabled:!f||a||!n,onClick:()=>l(n),children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n})]},e)):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i?`Loading branch suggestions...`:`No suggested branches available.`})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsx)(Xs,{htmlFor:`mobile-project-target-branch-input`,className:`text-xs text-muted-foreground`,children:`Switch or create branch`}),(0,Z.jsx)(We,{id:`mobile-project-target-branch-input`,value:u,disabled:!f||a,onChange:e=>d(e.target.value),placeholder:`feature/quick-fix`})]}),(0,Z.jsx)(K,{type:`button`,disabled:!f||!u.trim()||a,onClick:()=>l(u.trim()),children:`Switch`})]}),f?null:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Switch to repo root to choose a branch.`})]})]})]}):(0,Z.jsx)(W1,{text:`Loading target options...`}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a project before choosing a target.`});return(0,Z.jsx)(Os,{open:e,onOpenChange:o,children:(0,Z.jsx)(Ms,{showCloseButton:!1,"aria-describedby":void 0,className:`top-auto right-0 bottom-0 left-0 max-w-none translate-x-0 translate-y-0 overflow-hidden rounded-t-3xl rounded-b-none border-x-0 border-b-0 p-0 sm:top-1/2 sm:right-auto sm:bottom-auto sm:left-1/2 sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl sm:border sm:p-0`,children:(0,Z.jsx)(I1,{title:`Target`,description:t?k1(t,n):void 0,children:h})})})},B1=({selectedProject:e,targetLabel:t,isTargetLoading:n,isTargetDisabled:r,connectionState:i,onOpenProjects:a,onOpenTargetSelector:o})=>(0,Z.jsx)(`header`,{className:`sticky top-0 z-20 border-b border-border/70 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between gap-3 px-3 pb-3 pt-4 sm:px-4`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`Choose project`,className:`min-w-0 flex-1 text-left`,onClick:a,children:[(0,Z.jsx)(`div`,{className:`truncate text-base font-medium text-foreground`,children:e?.name??`Choose a project`}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e?.repo_path??`Select a desktop project to continue`})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(N1,{status:i}),(0,Z.jsxs)(K,{variant:`outline`,size:`sm`,"aria-label":`Choose target`,"data-testid":`mobile-target-trigger`,className:`h-8 max-w-32 gap-2 px-2.5 sm:max-w-40`,disabled:r,onClick:o,children:[(0,Z.jsx)(Dl,{className:`h-3.5 w-3.5 shrink-0`}),n?(0,Z.jsx)(Ec,{className:`h-3.5 w-16`}):(0,Z.jsx)(`span`,{className:`truncate text-xs sm:text-sm`,children:t})]}),(0,Z.jsx)(K,{variant:`outline`,size:`icon-sm`,"aria-label":`Choose project`,onClick:a,children:(0,Z.jsx)(of,{className:`h-4 w-4`})})]})]})}),V1=({activeSection:e,onChange:t})=>(0,Z.jsx)(`nav`,{className:`fixed inset-x-0 bottom-0 z-20 border-t border-border/70 bg-background/95 px-3 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] pt-2 backdrop-blur supports-[backdrop-filter]:bg-background/85 sm:px-4 lg:hidden`,children:(0,Z.jsx)(`div`,{className:`mx-auto flex max-w-6xl gap-2`,children:T1.map(n=>{let r=n.key===e,i=n.Icon;return(0,Z.jsxs)(K,{type:`button`,variant:r?`secondary`:`ghost`,className:`h-11 flex-1 gap-2`,"aria-current":r?`page`:void 0,onClick:()=>t(n.key),children:[(0,Z.jsx)(i,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:n.label})]},n.key)})})}),H1=({title:e,description:t,action:n})=>(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{children:e}),(0,Z.jsx)(_u,{children:t})]}),n?(0,Z.jsx)(yu,{children:n}):null]}),U1=({label:e,value:t,accentClassName:n})=>(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:G(`text-xl font-semibold text-foreground`,n),children:t}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs uppercase tracking-[0.14em] text-muted-foreground`,children:e})]}),W1=({text:e})=>(0,Z.jsxs)(`div`,{"aria-live":`polite`,className:`flex items-center gap-2 px-1 py-3 text-sm text-muted-foreground`,role:`status`,children:[(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{children:e})]}),G1=()=>(0,Z.jsxs)(`div`,{className:`space-y-3`,"data-testid":`mobile-overview-skeleton`,children:[(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(hu,{className:`border-b border-border/70 pb-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(Ec,{className:`h-6 w-28`}),(0,Z.jsx)(Ec,{className:`h-6 w-28 rounded-full`})]})}),(0,Z.jsxs)(yu,{className:`space-y-4 pt-5`,children:[(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:Array.from({length:6},(e,t)=>(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(Ec,{className:`h-6 w-10`}),(0,Z.jsx)(Ec,{className:`mt-2 h-3 w-16`})]},t))}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,Z.jsx)(Ec,{className:`h-10 w-full rounded-xl`}),(0,Z.jsx)(Ec,{className:`h-10 w-full rounded-xl`})]})]})]}),(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(hu,{children:(0,Z.jsx)(Ec,{className:`h-6 w-20`})}),(0,Z.jsx)(yu,{children:(0,Z.jsx)(Ec,{className:`h-10 w-40 rounded-xl`})})]})]}),K1=({isLoggingOut:e,onLogout:t})=>(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(hu,{children:(0,Z.jsx)(gu,{children:`Session`})}),(0,Z.jsx)(yu,{children:(0,Z.jsxs)(K,{variant:`destructive`,className:`gap-2`,disabled:e,onClick:t,children:[(0,Z.jsx)(R$,{className:`h-4 w-4`}),e?`Logging out...`:`Log out this phone`]})})]}),q1=({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r})=>{let i=r?.agent_status===`running`||!!n?.some(e=>e.agent_status===`running`);if(e?.kind===`ticket`)return{label:`Ticket run active`,variant:`success`};if(i)return{label:`Chat active`,variant:`success`};if(e)return{label:`Project run active`,variant:`success`};let a=t?.filter(e=>e.agent_status===`running`&&e.parked_at===null)??[];return a.some(e=>e.state===`review`)?{label:`Reviewing`,variant:`warning`}:a.some(e=>e.state===`build`)?{label:`Building`,variant:`success`}:a.some(e=>e.state===`plan`)?{label:`Planning`,variant:`info`}:{label:`Idle`,variant:`outline`}},J1=({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r})=>{let i=q1({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r});return(0,Z.jsx)(U,{variant:i.variant,children:i.label})},Y1=({selectedProjectId:e,summary:t,tickets:n,error:r,chatSessions:i,chatSessionDetail:a,onRetry:o,onOpenTickets:s,onOpenChats:c})=>{let l=C1.Icon,u=w1.Icon;return r?(0,Z.jsx)(H1,{title:`Project summary unavailable`,description:r,action:(0,Z.jsx)(K,{variant:`warning`,onClick:o,children:`Retry summary`})}):e?!t||t.project.id!==e?(0,Z.jsx)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:(0,Z.jsx)(yu,{className:`pt-5 text-sm text-muted-foreground`,children:`Loading project summary...`})}):(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsxs)(hu,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(gu,{children:`Overview`}),(0,Z.jsx)(vu,{children:(0,Z.jsx)(J1,{activeRun:t.active_run,tickets:n,chatSessions:i,chatSessionDetail:a})})]}),(0,Z.jsxs)(yu,{className:`space-y-4 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:[(0,Z.jsx)(U1,{label:`Tickets`,value:t.tickets.total}),(0,Z.jsx)(U1,{label:`Plan`,value:t.tickets.plan,accentClassName:`text-sky-200`}),(0,Z.jsx)(U1,{label:`Build`,value:t.tickets.build,accentClassName:`text-emerald-200`}),(0,Z.jsx)(U1,{label:`Review`,value:t.tickets.review,accentClassName:`text-amber-200`}),(0,Z.jsx)(U1,{label:`Done`,value:t.tickets.parked}),(0,Z.jsx)(U1,{label:`Bundles`,value:t.project.bundle_count??0})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,Z.jsxs)(K,{variant:`outline`,className:`gap-2`,"aria-label":C1.ctaAriaLabel,onClick:s,children:[(0,Z.jsx)(l,{className:`h-4 w-4`}),C1.label]}),(0,Z.jsxs)(K,{variant:`outline`,className:`gap-2`,"aria-label":w1.ctaAriaLabel,onClick:c,children:[(0,Z.jsx)(u,{className:`h-4 w-4`}),w1.label]})]})]})]}):(0,Z.jsx)(H1,{title:`Choose a project`,description:`Select a desktop project before opening tickets or chats from this phone.`})},X1=e=>e.parked_at?`parked`:e.state,Z1=e=>{let t=X1(e);return t===`parked`?`Done`:`${t.slice(0,1).toUpperCase()}${t.slice(1)}`},Q1=e=>e===`plan`?`info`:e===`build`?`success`:e===`review`?`warning`:`outline`,$1=({ticket:e,isSelected:t,onSelectTicket:n,className:r})=>(0,Z.jsxs)(`button`,{type:`button`,className:G(`w-full rounded-2xl border px-4 py-3 text-left transition-colors`,t?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`,r),onClick:()=>n(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.title})}),(0,Z.jsx)(U,{variant:Q1(X1(e)),children:Z1(e)})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:[e.agent_status?(0,Z.jsx)(`span`,{children:e.agent_status}):null,e.branch?(0,Z.jsx)(`span`,{children:e.branch}):null,e.bundle?.name?(0,Z.jsx)(`span`,{children:e.bundle.name}):null]})]}),e0=({group:e,selectedBundleId:t,selectedTicketId:n,onSelectBundle:r,onSelectTicket:i})=>{let a=e.bundle.id===t,o=e.tickets.some(e=>e.id===n),[s,c]=(0,Y.useState)(o),l=Tl(e.bundle)||e.bundle.branch||e.bundle.name||`Bundle`,u=e.tickets.filter(e=>e.agent_status===`running`).length,d=a||o;return(0,Y.useEffect)(()=>{o&&c(!0)},[o]),(0,Z.jsxs)($u,{open:s,onOpenChange:c,children:[(0,Z.jsxs)(`div`,{className:G(`flex items-start gap-2 rounded-2xl border px-4 py-3 transition-colors`,d?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`),children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,"aria-label":`Open bundle ${l}`,onClick:()=>r(e.bundle.id),children:(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(U,{variant:`outline`,children:`Bundle`}),(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:l})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[e.tickets.length,` ticket`,e.tickets.length===1?``:`s`]}),u>0?(0,Z.jsxs)(`span`,{children:[u,` running`]}):null,e.bundle.branch?(0,Z.jsx)(`span`,{children:e.bundle.branch}):null]})]})})}),(0,Z.jsx)(ed,{asChild:!0,children:(0,Z.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mt-0.5 shrink-0`,"aria-label":`Toggle bundle tickets for ${l}`,children:(0,Z.jsx)(Oe,{className:G(`h-4 w-4 transition-transform`,s&&`rotate-180`)})})})]}),(0,Z.jsx)(td,{className:`pt-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2 pl-3`,children:e.tickets.map(t=>(0,Z.jsx)($1,{ticket:t,isSelected:t.id===n,onSelectTicket:t=>i(t,e.bundle.id),className:`rounded-xl`},t.id))})})]})},t0=(e,t)=>bl(e,[],t),n0=e=>[{key:`plan`,label:`Plan`,tickets:e.filter(e=>!e.parked_at&&e.state===`plan`),items:t0(e.filter(e=>!e.parked_at&&e.state===`plan`),`plan`)},{key:`build`,label:`Build`,tickets:e.filter(e=>!e.parked_at&&e.state===`build`),items:t0(e.filter(e=>!e.parked_at&&e.state===`build`),`build`)},{key:`review`,label:`Review`,tickets:e.filter(e=>!e.parked_at&&e.state===`review`),items:t0(e.filter(e=>!e.parked_at&&e.state===`review`),`review`)},{key:`parked`,label:`Done`,tickets:e.filter(e=>e.parked_at),items:t0(e.filter(e=>e.parked_at),`done`)}].filter(e=>e.tickets.length>0),r0=(e,t)=>{if(!e)return e;let n=new Map(t.tickets.map(e=>[e.id,e]));return e.map(e=>n.get(e.id)??e)},i0=({selectedProjectId:e,tickets:t,selectedBundleId:n,selectedTicketId:r,error:i,onRetry:a,onSelectBundle:o,onSelectTicket:s})=>{if(!e)return(0,Z.jsx)(H1,{title:`Choose a project`,description:`Select a project before browsing tickets from this phone.`});if(i)return(0,Z.jsx)(H1,{title:`Tickets unavailable`,description:i,action:(0,Z.jsx)(K,{variant:`warning`,onClick:a,children:`Retry tickets`})});if(!t)return(0,Z.jsx)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:(0,Z.jsx)(yu,{className:`pt-5 text-sm text-muted-foreground`,children:`Loading tickets...`})});if(t.length===0)return(0,Z.jsx)(H1,{title:`No tickets`,description:`This project does not have any tickets yet.`});let c=n0(t);return(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none lg:flex lg:min-h-0 lg:flex-col`,children:[(0,Z.jsxs)(hu,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(gu,{children:`Tickets`}),(0,Z.jsxs)(_u,{children:[t.length,` total`]})]}),(0,Z.jsx)(yu,{className:`space-y-4 pt-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto`,children:c.map(e=>(0,Z.jsxs)(`section`,{className:`space-y-2`,"aria-label":`${e.label} tickets`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`span`,{children:e.tickets.length})]}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.items.map(e=>e.kind===`bundle`?(0,Z.jsx)(e0,{group:e.group,selectedBundleId:n,selectedTicketId:r,onSelectBundle:o,onSelectTicket:s},e.group.id):(0,Z.jsx)($1,{ticket:e.ticket,isSelected:e.ticket.id===r,onSelectTicket:e=>s(e,null)},e.ticket.id))})]},e.key))})]})},a0=({selectedProjectId:e,chatSessions:t,selectedChatSessionId:n,error:r,onRetry:i,onOpenNewChat:a,onSelectChat:o})=>e?r?(0,Z.jsx)(H1,{title:`Chats unavailable`,description:r,action:(0,Z.jsx)(K,{variant:`warning`,onClick:i,children:`Retry chats`})}):(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none lg:flex lg:min-h-0 lg:flex-col`,children:[(0,Z.jsxs)(hu,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(gu,{children:`Chats`}),(0,Z.jsx)(_u,{children:t?`${t.length} recent`:`Loading chats...`}),(0,Z.jsx)(vu,{children:(0,Z.jsx)(K,{variant:`outline`,size:`sm`,onClick:a,children:`New chat`})})]}),(0,Z.jsx)(yu,{className:`space-y-2 pt-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto`,children:t?t.length===0?(0,Z.jsx)(H1,{title:`No chats`,description:`Start a new chat to plan or build from this project.`,action:(0,Z.jsx)(K,{onClick:a,children:`Start a chat`})}):t.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:G(`w-full rounded-xl border px-3 py-2.5 text-left transition-colors`,e.id===n?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`),onClick:()=>o(e.id),children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 pr-2 text-sm font-medium text-foreground line-clamp-2 break-words`,children:e.title}),(0,Z.jsx)(U,{variant:e.agent_status===`running`?`warning`:e.mode===`plan`?`info`:`success`,children:e.agent_status??e.mode})]})},e.id)):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading chats...`})})]}):(0,Z.jsx)(H1,{title:`Choose a project`,description:`Select a project before browsing chats from this phone.`}),o0=({label:e,disabled:t,onClick:n})=>(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:t,onClick:n,children:e}),s0=e=>{let t=e.tickets.filter(e=>!e.parked_at),n=t.filter(e=>e.state===`plan`),r=t.filter(e=>e.state===`build`),i=t.filter(e=>e.state===`review`),a=t.some(e=>e.agent_status===`running`),o=t.find(e=>Tw(e)&&e.agent_status===`running`&&!!e.session_id)??null,s=t.find(e=>Tw(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,c=[];n.length>0&&c.push({id:`build`,label:`Build Bundle`,pendingLabel:`Building Bundle...`,ariaLabel:`Build Bundle`,disabled:!1,disabledReason:null});let l=r.length>0&&r.every(e=>e.agent_status===`done`),u=r.length===0&&i.length>0&&e.can_re_review===!0&&!a;return(l||u)&&c.push({id:`review`,label:u?`Re-run review`:`Review Bundle`,pendingLabel:`Reviewing Bundle...`,ariaLabel:u?`Re-run review`:`Review Bundle`,disabled:!1,disabledReason:null}),o&&c.push({id:`pause-build`,label:`Pause Build`,pendingLabel:`Pausing Build...`,ariaLabel:`Pause Build`,title:`Pause the build session. You can resume it later.`,disabled:!1,disabledReason:null}),!o&&s&&c.push({id:`resume-build`,label:`Resume`,pendingLabel:`Resuming...`,ariaLabel:`Resume`,disabled:!1,disabledReason:null}),{actions:c,runningBuildTicketId:o?.id??null,resumableBuildTicketId:s?.id??null}},c0=({ticket:e,actionState:t,actionError:n,onAction:r})=>{let i=RW(e,{reviewLabel:e.worktree_bundle_id===null?`Review`:`Review Bundle`}),a=e.worktree_bundle_id===null&&e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`&&!e.parked_at?[{id:`review`,label:`Re-run review`,pendingLabel:`Re-running review...`,ariaLabel:`Re-run review`,disabled:!1,disabledReason:null},...i]:i;return a.length===0?null:(0,Z.jsx)(IW,{actions:a,activeAction:t,disableWhenActive:!0,className:`space-y-3`,heading:`Actions`,headingClassName:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,actionsClassName:`flex flex-wrap gap-2`,showDisabledReason:!0,disabledReasonClassName:`text-sm text-amber-200`,error:n,errorClassName:`text-sm text-red-200`,renderAction:({action:e,label:t,disabled:n})=>(0,Z.jsx)(o0,{label:t,disabled:n,onClick:()=>r(e.id)},e.id)})},l0=({bundleDetail:e,actionState:t,actionError:n,onAction:r})=>{let{actions:i}=s0(e);return i.length===0?null:(0,Z.jsx)(IW,{actions:i,activeAction:t,disableWhenActive:!0,className:`space-y-3`,heading:`Actions`,headingClassName:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,actionsClassName:`flex flex-wrap gap-2`,error:n,errorClassName:`text-sm text-red-200`,renderAction:({action:e,label:t,disabled:n})=>(0,Z.jsx)(o0,{label:t,disabled:n,onClick:()=>r(e.id)},e.id)})},u0=(e,t)=>(e??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,created_at:e.created_at,ticket_id:t??null,ticket_proposals:`ticket_proposals`in e?e.ticket_proposals??null:null})),d0=({title:e,subtitle:t,badges:n,backLabel:r,onBack:i,action:a})=>(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[i?(0,Z.jsxs)(K,{variant:`ghost`,size:`sm`,className:`h-8 px-2.5 lg:hidden`,"aria-label":r,onClick:i,children:[(0,Z.jsx)(nT,{className:`h-4 w-4`}),`Back`]}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e}),t?(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t}):null]})]}),a?(0,Z.jsx)(`div`,{className:`shrink-0`,children:a}):null]}),n?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n}):null]}),f0=({title:e,backLabel:t,onBack:n,action:r})=>(0,Z.jsxs)(`div`,{className:`-mx-3 flex shrink-0 items-center justify-between gap-3 border-b border-border/80 bg-background/95 px-3 py-2.5 backdrop-blur supports-[backdrop-filter]:bg-background/85 sm:-mx-4 sm:px-4 lg:hidden`,children:[(0,Z.jsxs)(K,{variant:`ghost`,size:`sm`,className:`h-8 px-2.5`,"aria-label":t,onClick:n,children:[(0,Z.jsx)(nT,{className:`h-4 w-4`}),`Back`]}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:r})]}),p0=({title:e,backLabel:t,onBack:n,action:r,subheader:i,children:a})=>(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(f0,{title:e,backLabel:t,onBack:n,action:r}),i?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-border/70 py-2 lg:hidden`,children:i}):null,(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:a})]}),m0=({value:e,onTranscript:t,onDetails:n})=>(0,Z.jsxs)(`div`,{className:`flex gap-2 px-3 sm:px-0`,children:[(0,Z.jsx)(K,{type:`button`,variant:e===`transcript`?`secondary`:`ghost`,className:`h-9 flex-1`,"aria-pressed":e===`transcript`,onClick:t,children:`Transcript`}),(0,Z.jsx)(K,{type:`button`,variant:e===`details`?`secondary`:`ghost`,className:`h-9 flex-1`,"aria-pressed":e===`details`,onClick:n,children:`Details`})]}),h0=({controls:e})=>{let[t,n]=(0,Y.useState)(!1);return(0,Z.jsxs)($u,{open:t,onOpenChange:n,children:[(0,Z.jsx)(`div`,{className:`px-1 pb-1`,children:(0,Z.jsx)(ed,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 gap-1.5 px-2 text-xs text-muted-foreground`,children:[`Options`,(0,Z.jsx)(Oe,{className:G(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]})})}),(0,Z.jsx)(td,{className:`px-1 pb-1`,children:(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-background/35 p-2`,children:e})})]})},g0=({ticket:e})=>{let t=[{label:`State`,value:Z1(e)},{label:`Tool`,value:e.tool},{label:`Agent`,value:e.agent_status},{label:`Branch`,value:e.branch},{label:`Bundle`,value:e.bundle?.name??null},{label:`Model`,value:e.model},{label:`Variant`,value:e.variant}].filter(e=>!!e.value);return t.length===0?null:(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-xl border border-border/70 bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Details`}),(0,Z.jsx)(`dl`,{className:`grid gap-2 text-sm sm:grid-cols-2`,children:t.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-lg border border-border/60 bg-background/50 px-3 py-2`,children:[(0,Z.jsx)(`dt`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,Z.jsx)(`dd`,{className:`break-words text-foreground`,children:e.value})]},e.label))})]})},_0=({ticket:e,badges:t,actionState:n,actionError:r,onAction:i,className:a})=>(0,Z.jsxs)(mu,{className:G(`flex min-h-0 min-w-0 flex-col border-border/80 bg-card/70 shadow-none`,a),children:[(0,Z.jsx)(hu,{className:`min-w-0 pb-3`,children:(0,Z.jsx)(d0,{title:e.title,badges:t})}),(0,Z.jsxs)(yu,{className:`min-h-0 min-w-0 flex-1 space-y-3 overflow-y-auto pt-0`,children:[(0,Z.jsx)(c0,{ticket:e,actionState:n,actionError:r,onAction:i}),e.description?(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-xl border border-border/70 bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Description`}),(0,Z.jsx)(HM,{content:e.description,className:`min-w-0 text-foreground`})]}):null,(0,Z.jsx)(g0,{ticket:e})]})]}),v0=({bundleDetail:e,title:t,subtitle:n,badges:r,actionState:i,actionError:a,onAction:o,orderedTickets:s,highlightedTicketId:c,isTicketListOpen:l,onTicketListOpenChange:u,onSelectTicket:d,className:f})=>(0,Z.jsxs)(mu,{className:G(`flex min-h-0 min-w-0 flex-col border-border/80 bg-card/70 shadow-none`,f),children:[(0,Z.jsx)(hu,{className:`min-w-0 pb-3`,children:(0,Z.jsx)(d0,{title:t,subtitle:n,badges:r})}),(0,Z.jsxs)(yu,{className:`min-h-0 min-w-0 flex-1 space-y-3 overflow-y-auto pt-0`,children:[(0,Z.jsx)(l0,{bundleDetail:e,actionState:i,actionError:a,onAction:o}),(0,Z.jsxs)($u,{open:l,onOpenChange:u,children:[(0,Z.jsx)(ed,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs text-muted-foreground`,children:[`Tickets`,(0,Z.jsx)(Oe,{className:G(`h-3.5 w-3.5 transition-transform`,l&&`rotate-180`)})]})}),(0,Z.jsx)(td,{className:`pt-2`,children:(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-background/35 p-3`,children:(0,Z.jsx)(sG,{tickets:s,highlightedTicketId:c,onOpenTicketDetails:e=>d(e.id,e.worktree_bundle_id)})})})]})]})]}),y0=({selectedProjectId:e,bundleId:t,bundleDetail:n,openNonce:r,mobileDetailView:i,error:a,actionState:o,actionError:s,followUpPrompt:c,isSendingFollowUp:l,followUpError:u,availableModels:d,onBack:f,onRetry:p,onAction:m,onDetailViewChange:h,onSelectTicket:g,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y,isLargeScreen:b})=>{let[x,S]=(0,Y.useState)(!0);if((0,Y.useEffect)(()=>{S(!0)},[t,r]),!e)return(0,Z.jsx)(H1,{title:`Choose a project`,description:`Select a project before opening bundle details from this phone.`});if(!t)return(0,Z.jsx)(H1,{title:`Choose a bundle`,description:`Open a bundle to review its transcript and grouped ticket progress.`});if(a)return(0,Z.jsx)(p0,{title:`Bundle unavailable`,backLabel:`Back to tickets`,onBack:f,children:(0,Z.jsx)(H1,{title:`Bundle unavailable`,description:a,action:(0,Z.jsx)(K,{variant:`warning`,onClick:p,children:`Retry bundle`})})});if(!n||n.bundle.id!==t)return(0,Z.jsx)(p0,{title:`Loading bundle`,backLabel:`Back to tickets`,onBack:f,children:(0,Z.jsx)(W1,{text:`Loading bundle details...`})});let C=Tl(n.bundle)||n.bundle.branch||n.bundle.name||`Bundle`,w=new Map(d.map(e=>[e.id,e.label])),T=fG(n.tickets,w),E=hG(n),D=pG(n.tickets,n.execution_order_ticket_ids),O=mG(n.tickets,w,T,n.execution_order_ticket_ids),k=lT(n.tickets,E?.state??null),A=n.tickets.find(e=>e.agent_status===`running`)??E,j=A??E??n.tickets[0]??null,M=A?.agent_status===`running`?T[A.id]??A.model??`Agent`:null,N=!!(E&&E.state!==`plan`&&vl(E)),P=n.tickets.some(e=>e.agent_status===`running`)?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,F=`mobile-bundle:${n.bundle.id}:${r}`,I=`${n.tickets.length} ticket${n.tickets.length===1?``:`s`}`,L=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(iT,{status:k}),(0,Z.jsx)(U,{variant:`outline`,children:I}),j?(0,Z.jsxs)(U,{variant:`outline`,children:[`Target: `,j.title]}):null]});return(0,Z.jsx)(p0,{title:C,backLabel:`Back to tickets`,onBack:f,subheader:b?void 0:(0,Z.jsx)(m0,{value:i,onTranscript:()=>h(`transcript`),onDetails:()=>h(`details`)}),children:b?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden pt-3`,children:[(0,Z.jsx)(v0,{bundleDetail:n,title:C,subtitle:n.bundle.branch,badges:L,actionState:o,actionError:s,onAction:m,orderedTickets:D,highlightedTicketId:n.target_ticket_id,isTicketListOpen:x,onTicketListOpenChange:S,onSelectTicket:g,className:`shrink-0`}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(iG,{projectId:e,followUpTicketId:n.target_ticket_id,messages:O,internalLog:A?.agent_log??null,currentThinkingMessageId:A?.agent_message_id??E?.agent_message_id??null,legacyThinkingTicketId:A?.id??E?.id??null,previousThinkingLog:A?.previous_agent_log??E?.previous_agent_log??null,previousThinkingMessageId:A?.previous_agent_message_id??E?.previous_agent_message_id??null,pendingAgentTitle:M,streamingResponse:A?.streaming_response??null,isRunning:n.tickets.some(e=>e.agent_status===`running`),canShowComposer:N,composerTheme:Cw(E?.state??null),layoutKey:F,scrollLayoutKey:F,followUpPrompt:c,followUpPlaceholder:j?`Follow up on: ${j.title}`:`Follow up on this bundle`,isSendingFollowUp:l,followUpDisabledReason:P,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y},F)}),u?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-red-200`,children:u}):null]}):i===`details`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(v0,{bundleDetail:n,title:C,subtitle:n.bundle.branch,badges:L,actionState:o,actionError:s,onAction:m,orderedTickets:D,highlightedTicketId:n.target_ticket_id,isTicketListOpen:x,onTicketListOpenChange:S,onSelectTicket:g,className:`h-full`})}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(iG,{projectId:e,followUpTicketId:n.target_ticket_id,messages:O,internalLog:A?.agent_log??null,currentThinkingMessageId:A?.agent_message_id??E?.agent_message_id??null,legacyThinkingTicketId:A?.id??E?.id??null,previousThinkingLog:A?.previous_agent_log??E?.previous_agent_log??null,previousThinkingMessageId:A?.previous_agent_message_id??E?.previous_agent_message_id??null,pendingAgentTitle:M,streamingResponse:A?.streaming_response??null,isRunning:n.tickets.some(e=>e.agent_status===`running`),canShowComposer:N,composerTheme:Cw(E?.state??null),layoutKey:F,scrollLayoutKey:F,followUpPrompt:c,followUpPlaceholder:j?`Follow up on: ${j.title}`:`Follow up on this bundle`,isSendingFollowUp:l,followUpDisabledReason:P,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y},F),u?(0,Z.jsx)(`p`,{className:`shrink-0 px-1 pt-2 text-sm text-red-200`,children:u}):null]})})},b0=({selectedProjectId:e,chatSession:t,chatSessionId:n,openNonce:r,error:i,isStopping:a,composerMode:o,composerTool:s,prompt:c,selectedModel:l,selectedVariant:u,selectedSkills:d,availableModels:f,availableSkills:p,isLoadingAgentSettings:m,isSending:h,isUpdatingMode:g,composerDisabledReason:_,onBack:v,onRetry:y,onStop:b,onModeChange:x,onPromptChange:S,onModelChange:C,onVariantChange:w,onSkillsChange:T,onPromptKeyDown:E,onSubmit:D,isLargeScreen:O})=>{if(!e)return(0,Z.jsx)(H1,{title:`Choose a project`,description:`Select a project before opening the chat workspace.`});if(n&&i)return(0,Z.jsx)(H1,{title:`Chat unavailable`,description:i,action:(0,Z.jsx)(K,{variant:`warning`,onClick:y,children:`Retry chat`})});if(n&&(!t||t.id!==n))return(0,Z.jsx)(p0,{title:`Loading chat`,backLabel:`Back to chats`,onBack:v,children:(0,Z.jsx)(W1,{text:`Loading chat transcript...`})});let k=t?.mode??o,A=s===`opencode`&&f.length>0,j=f.find(e=>e.id===l)??null,M=u0(t?.messages),N=t?.agent_status===`running`?(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a,onClick:b,children:[a?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Nc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:a?`Interrupting...`:`Interrupt`})]}):null,P=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{variant:k===`plan`?`info`:`success`,children:k}),(0,Z.jsx)(U,{variant:`outline`,children:t?.tool??s}),t?.agent_status?(0,Z.jsx)(U,{variant:`outline`,children:t.agent_status}):null]}),F=A?(0,Z.jsx)(fP,{model:l,variant:u,skills:d,showModelSelector:!0,showSkillsSelector:!0,availableModels:f,availableSkills:p,selectedModel:j,onModelChange:C,onVariantChange:w,onSkillsChange:T,modelSelectId:`mobile-chat-model-selector`,variantSelectId:`mobile-chat-variant-selector`,skillsSelectId:`mobile-chat-skills-selector`,disabled:!!_||h}):s===`opencode`&&m?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading model controls...`}):null,I=!O&&F?(0,Z.jsx)(h0,{controls:F}):F,L=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,Z.jsx)(PX,{value:k,disabled:!!_||h||g,onChange:x})}),R=O?void 0:({showThinkingControl:e})=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-1`,children:[L,(0,Z.jsx)(`div`,{className:`ml-auto`,children:e})]}),z=`mobile-chat:${n??`new`}:${r}`;return(0,Z.jsx)(p0,{title:t?.title??`New chat`,backLabel:`Back to chats`,onBack:v,action:N,children:(0,Z.jsx)(NX,{projectId:e,messages:M,internalLog:t?.agent_log??null,currentThinkingMessageId:t?.agent_message_id??null,previousThinkingLog:t?.previous_agent_log??null,previousThinkingMessageId:t?.previous_agent_message_id??null,pendingAgentTitle:t?.title??`Archon`,streamingResponse:t?.streaming_response??null,isRunning:t?.agent_status===`running`,canShowComposer:!0,header:O?(0,Z.jsx)(d0,{title:t?.title??`New chat`,subtitle:t?.target_label_snapshot??`Project root`,badges:P}):R,composerControls:O?L:void 0,composerInlineControls:I,composerTheme:k,forceScrollToBottomKey:z,layoutKey:z,scrollLayoutKey:z,composerFocusNonce:r,blurComposerOnSendStart:!O,followUpPrompt:c,followUpPlaceholder:n?`Continue this chat`:k===`plan`?`Ask Archon to scope or reason through project work`:`Ask Archon to build or verify something in this project`,emptyStateText:n?`No messages yet.`:`Start a new project chat from this phone.`,isSendingFollowUp:h,followUpDisabledReason:_??void 0,hidePendingAgentTitle:!O,onFollowUpPromptChange:S,onFollowUpKeyDown:E,onFollowUpSubmit:D},z)})},x0=({selectedProjectId:e,ticketId:t,ticket:n,openNonce:r,error:i,actionState:a,actionError:o,followUpPrompt:s,followUpSelectedModel:c,followUpSelectedVariant:l,followUpSelectedSkills:u,availableModels:d,availableSkills:f,isLoadingAgentSettings:p,isSendingFollowUp:m,followUpError:h,onBack:g,onRetry:_,onAction:v,onFollowUpPromptChange:y,onFollowUpModelChange:b,onFollowUpVariantChange:x,onFollowUpSkillsChange:S,onFollowUpKeyDown:C,onFollowUpSubmit:w,isLargeScreen:T})=>{let[E,D]=(0,Y.useState)(`transcript`);if((0,Y.useEffect)(()=>{D(`transcript`)},[r,t]),!e)return(0,Z.jsx)(H1,{title:`Choose a project`,description:`Select a project before opening ticket details from this phone.`});if(!t)return(0,Z.jsx)(H1,{title:`Choose a ticket`,description:`Open a ticket to review its transcript and continue the workflow.`});if(i)return(0,Z.jsx)(H1,{title:`Ticket unavailable`,description:i,action:(0,Z.jsx)(K,{variant:`warning`,onClick:_,children:`Retry ticket`})});if(!n||n.id!==t)return(0,Z.jsx)(p0,{title:`Loading ticket`,backLabel:`Back to tickets`,onBack:g,children:(0,Z.jsx)(W1,{text:`Loading ticket details...`})});let O=zW(n,{requireWorktree:!0}),k=u0(n.messages,n.id),A=d.find(e=>e.id===c)??null,j=n.tool===`opencode`&&d.length>0?(0,Z.jsx)(fP,{model:c,variant:l,skills:u,showModelSelector:!0,showSkillsSelector:!0,availableModels:d,availableSkills:f,selectedModel:A,onModelChange:b,onVariantChange:x,onSkillsChange:S,modelSelectId:`mobile-ticket-follow-up-model-selector`,variantSelectId:`mobile-ticket-follow-up-variant-selector`,skillsSelectId:`mobile-ticket-follow-up-skills-selector`,disabled:!!O.disabledReason||m}):n.tool===`opencode`&&p?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading model controls...`}):null,M=!T&&j?(0,Z.jsx)(h0,{controls:j}):j,N=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{variant:Q1(X1(n)),children:Z1(n)}),n.tool?(0,Z.jsx)(U,{variant:`outline`,children:n.tool}):null,n.agent_status?(0,Z.jsx)(U,{variant:`outline`,children:n.agent_status}):null,n.branch?(0,Z.jsx)(U,{variant:`outline`,children:n.branch}):null,n.bundle?.name?(0,Z.jsx)(U,{variant:`outline`,children:n.bundle.name}):null]}),P=`mobile-ticket:${n.id}:${r}`,F=(0,Z.jsx)(m0,{value:E,onTranscript:()=>D(`transcript`),onDetails:()=>D(`details`)});return(0,Z.jsx)(p0,{title:n.title,backLabel:`Back to tickets`,onBack:g,subheader:T?void 0:F,children:T?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden pt-3`,children:[(0,Z.jsx)(_0,{ticket:n,badges:N,actionState:a,actionError:o,onAction:v,className:`shrink-0`}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(NN,{projectId:e,followUpTicketId:n.id,messages:k,internalLog:n.agent_log??null,currentThinkingMessageId:n.agent_message_id??null,previousThinkingLog:n.previous_agent_log??null,previousThinkingMessageId:n.previous_agent_message_id??null,pendingAgentTitle:n.title,streamingResponse:n.streaming_response??null,isRunning:n.agent_status===`running`,canShowComposer:!0,followUpComposerControls:j,composerTheme:n.state,forceScrollToBottomKey:P,layoutKey:P,scrollLayoutKey:P,followUpPrompt:s,followUpPlaceholder:O.placeholder,emptyStateText:`No follow-up messages yet.`,isSendingFollowUp:m,followUpDisabledReason:O.disabledReason??void 0,onFollowUpPromptChange:y,onFollowUpKeyDown:C,onFollowUpSubmit:w},P)}),h?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-red-200`,children:h}):null]}):E===`details`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(_0,{ticket:n,badges:N,actionState:a,actionError:o,onAction:v,className:`h-full`})}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(NN,{projectId:e,followUpTicketId:n.id,messages:k,internalLog:n.agent_log??null,currentThinkingMessageId:n.agent_message_id??null,previousThinkingLog:n.previous_agent_log??null,previousThinkingMessageId:n.previous_agent_message_id??null,pendingAgentTitle:n.title,streamingResponse:n.streaming_response??null,isRunning:n.agent_status===`running`,canShowComposer:!0,followUpComposerControls:M,composerTheme:n.state,surfaceVariant:`chat`,composerSize:`compact-on-laptop`,forceScrollToBottomKey:P,layoutKey:P,scrollLayoutKey:P,followUpPrompt:s,followUpPlaceholder:O.placeholder,emptyStateText:`No follow-up messages yet.`,isSendingFollowUp:m,followUpDisabledReason:O.disabledReason??void 0,onFollowUpPromptChange:y,onFollowUpKeyDown:C,onFollowUpSubmit:w},P),h?(0,Z.jsx)(`p`,{className:`shrink-0 px-1 pt-2 text-sm text-red-200`,children:h}):null]})})},S0=()=>{let e=new URLSearchParams(window.location.search),t=new URLSearchParams(window.location.hash.slice(1)),n=e.get(`mobileAccessId`)??``,r=e.get(`pairingId`)??``,i=t.get(`pairingSecret`)??``;return!n||!r||!i?null:{mobileAccessId:n,pairingId:r,pairingSecret:i}},C0=()=>{window.history.replaceState({},``,`/mobile`)},w0=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},T0=(e,t)=>e instanceof O&&e.message?e.message:t,E0=e=>({status:`authenticated`,csrfToken:e,projects:null,selectedProjectId:null,projectError:null,projectSummary:null,projectSummaryError:null,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),D0=(e=`pairing_required`)=>({status:`unauthenticated`,reason:e}),O0=e=>e instanceof O&&(e.status===401||e.status===403),k0=()=>{let[e,t]=(0,Y.useState)({status:`checking`}),[n,r]=(0,Y.useState)(`connecting`),[i,a]=(0,Y.useState)(`overview`),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(`build`),[C,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(``),[D,k]=(0,Y.useState)([]),[A,j]=(0,Y.useState)([]),[M,N]=(0,Y.useState)([]),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,ee]=(0,Y.useState)(null),[te,ne]=(0,Y.useState)(null),[V,re]=(0,Y.useState)(null),[H,ie]=(0,Y.useState)(null),[ae,oe]=(0,Y.useState)(null),[se,ce]=(0,Y.useState)(null),[le,U]=(0,Y.useState)(``),[ue,de]=(0,Y.useState)(``),[fe,pe]=(0,Y.useState)(``),[me,he]=(0,Y.useState)([]),[ge,W]=(0,Y.useState)(!1),[_e,ve]=(0,Y.useState)(null),[ye,be]=(0,Y.useState)(``),[xe,Se]=(0,Y.useState)(!1),[Ce,we]=(0,Y.useState)(null),[Te,Ee]=(0,Y.useState)(0),[De,Oe]=(0,Y.useState)(0),[ke,Ae]=(0,Y.useState)(0),[je,Me]=(0,Y.useState)(`transcript`),[Ne,Pe]=(0,Y.useState)(null),[Fe,Ie]=(0,Y.useState)(null),[Le,Re]=(0,Y.useState)(!1),[ze,Be]=(0,Y.useState)(!1),[Ve,He]=(0,Y.useState)(!1),[Ue,We]=(0,Y.useState)(null),[Ge,Ke]=(0,Y.useState)(null),qe=(0,Y.useRef)(null),Je=(0,Y.useRef)(null),Ye=(0,Y.useRef)(null),Xe=(0,Y.useRef)(null),Ze=(0,Y.useCallback)(e=>O0(e)?(t(D0(`session_revoked`)),r(`unavailable`),s(!1),l(!1),d(!1),p(!1),!0):!1,[]),Qe=(0,Y.useCallback)(async(e,n,r,i)=>{try{let a=await Y$(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedTicketId!==r?t:{...t,ticketDetail:a,ticketDetailError:null})}catch(i){if(!S(i)){if(Ze(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedTicketId!==r?t:{...t,ticketDetail:null,ticketDetailError:T0(i,`Unable to load ticket details.`)})}}},[Ze]),$e=(0,Y.useCallback)(async(e,n,r,i)=>{try{let a=await X$(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedBundleId!==r?t:{...t,bundleDetail:a,bundleDetailError:null,tickets:r0(t.tickets,a)})}catch(i){if(!S(i)){if(Ze(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedBundleId!==r?t:{...t,bundleDetail:null,bundleDetailError:T0(i,`Unable to load bundle details.`)})}}},[Ze]),et=(0,Y.useCallback)(async(e,n,r)=>{try{let i=await J$(n,r);t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n)return t;let r=t.selectedTicketId&&i.some(e=>e.id===t.selectedTicketId)?t.selectedTicketId:null,a=t.selectedBundleId&&i.some(e=>e.worktree_bundle_id===t.selectedBundleId)?t.selectedBundleId:null;return{...t,tickets:i,ticketsError:null,selectedBundleId:a,bundleDetail:a?t.bundleDetail:null,bundleDetailError:a?t.bundleDetailError:null,selectedTicketId:r,ticketDetail:r?t.ticketDetail:null,ticketDetailError:r?t.ticketDetailError:null}})}catch(r){if(!S(r)){if(Ze(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,tickets:null,ticketsError:T0(r,`Unable to load project tickets.`),selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null})}}},[Ze]),q=(0,Y.useCallback)(async(e,n,r,i)=>{try{let a=await q$(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedChatSessionId!==r?t:{...t,chatSessionDetail:a,chatSessionDetailError:null})}catch(i){if(!S(i)){if(Ze(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedChatSessionId!==r?t:{...t,chatSessionDetail:null,chatSessionDetailError:T0(i,`Unable to load chat transcript.`)})}}},[Ze]),J=(0,Y.useCallback)(async(e,n,r)=>{try{let i=await K$(n,r);t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n)return t;let r=t.selectedChatSessionId&&i.some(e=>e.id===t.selectedChatSessionId)?t.selectedChatSessionId:null;return{...t,chatSessions:i,chatSessionsError:null,selectedChatSessionId:r,chatSessionDetail:r?t.chatSessionDetail:null,chatSessionDetailError:r?t.chatSessionDetailError:null}})}catch(r){if(!S(r)){if(Ze(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,chatSessions:null,chatSessionsError:T0(r,`Unable to load project chats.`),selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null})}}},[Ze]),tt=(0,Y.useCallback)(async(e,n,r)=>{try{let i=await W$(n,r);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,projectSummary:i,projectSummaryError:null})}catch(r){if(!S(r)){if(Ze(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,projectSummary:null,projectSummaryError:T0(r,`Unable to load the project summary.`)})}}},[Ze]),nt=(0,Y.useCallback)(async(e,t,n)=>{Be(!0);try{let e=await G$(t,n),r=qe.current;if(r&&r!==t)return;Pe(e),Ie(null),We(null)}catch(e){if(!S(e)){if(Ze(e))return;let n=qe.current;if(n&&n!==t)return;Pe(null),Ie(T0(e,`Unable to load project target options.`))}}finally{n?.aborted||Be(!1)}},[Ze]),rt=(0,Y.useCallback)(e=>{t(t=>t.status===`authenticated`?{...t,projects:t.projects?.map(t=>t.id===e.id?e:t)??t.projects,projectSummary:t.projectSummary?.project.id===e.id?{...t.projectSummary,project:e}:t.projectSummary}:t)},[]),it=(0,Y.useCallback)(async(e,n,r)=>{try{let i=await U$(n),a=r&&i.some(e=>e.id===r)?r:i[0]?.id??null;t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e)return t;let n=!!(t.selectedProjectId&&a&&t.selectedProjectId===a);return{...t,projects:i,selectedProjectId:a,projectError:null,projectSummary:n?t.projectSummary:null,projectSummaryError:n?t.projectSummaryError:null,chatSessions:n?t.chatSessions:null,chatSessionsError:n?t.chatSessionsError:null,selectedChatSessionId:n?t.selectedChatSessionId:null,chatSessionDetail:n?t.chatSessionDetail:null,chatSessionDetailError:n?t.chatSessionDetailError:null,tickets:n?t.tickets:null,ticketsError:n?t.ticketsError:null,selectedBundleId:n?t.selectedBundleId:null,bundleDetail:n?t.bundleDetail:null,bundleDetailError:n?t.bundleDetailError:null,selectedTicketId:n?t.selectedTicketId:null,ticketDetail:n?t.ticketDetail:null,ticketDetailError:n?t.ticketDetailError:null}});let o=a?i.find(e=>e.id===a)??null:null;a&&(tt(e,a,n),o?.active_target_kind===`bundle`&&nt(e,a,n),J(e,a,n),et(e,a,n))}catch(n){if(!S(n)){if(Ze(n))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e?t:{...t,projects:t.projects??[],projectError:T0(n,`Unable to load projects from desktop Archon.`)})}}},[Ze,J,tt,nt,et]),at=(0,Y.useCallback)(async e=>{t({status:`checking`}),r(`connecting`);try{let n=await g1(e);if(n.authenticated&&n.csrf_token){r(`connecting`),t(E0(n.csrf_token)),it(n.csrf_token,e,n.preferred_project_id);return}t(D0())}catch(e){S(e)||t({status:`error`,message:T0(e,`Mobile access is unavailable. Make sure it is still enabled on desktop Archon.`)})}},[it]),ot=(0,Y.useCallback)((e,n,i)=>{r(`connecting`),t(E0(e)),it(e,i,n)},[it]);(0,Y.useEffect)(()=>{let e=new AbortController;if(window.location.pathname===`/mobile/pair`){let n=S0();return C0(),n?(t({status:`pairing`}),_1(n,e.signal).then(e=>{t({status:`pairing_confirmation`,payload:n,displayCode:e.display_code,expiresAt:e.expires_at,error:null})}).catch(e=>{t({status:`error`,message:T0(e,`Pairing failed. Regenerate the pairing link from desktop Archon and try again.`)})}),()=>e.abort()):(t({status:`error`,message:`Pairing link is missing required pairing details.`}),()=>e.abort())}return at(e.signal),()=>e.abort()},[ot,at]);let st=e.status===`authenticated`?e.csrfToken:null,ct=e.status===`authenticated`?e.selectedProjectId:null,lt=e.status===`authenticated`?e.selectedChatSessionId:null,ut=e.status===`authenticated`?e.selectedBundleId:null,dt=e.status===`authenticated`?e.selectedTicketId:null,ft=e.status===`authenticated`?e.projects?.find(t=>t.id===e.selectedProjectId)??null:null,pt=e.status===`authenticated`?e.chatSessionDetail:null,mt=e.status===`authenticated`?e.bundleDetail:null,ht=e.status===`authenticated`?e.ticketDetail:null,gt=k1(ft,Ne),_t=ze&&(!ft||ft.active_target_kind===`bundle`),vt=P1(),X=pt?.tool??`opencode`,yt=e.status!==`authenticated`||!e.selectedProjectId?`Choose a project before sending a prompt.`:R?`Wait for the chat mode change before sending another prompt.`:pt?.agent_status===`running`?`Stop or wait for the current response before sending another prompt.`:null,bt=!vt&&(i===`tickets`&&(u&&!!dt||c&&!!ut)||i===`chats`&&f);(0,Y.useEffect)(()=>{qe.current=ct},[ct]),(0,Y.useEffect)(()=>{ct||(Pe(null),Ie(null),We(null),Re(!1),Be(!1),He(!1))},[ct]),(0,Y.useEffect)(()=>{Je.current=lt},[lt]),(0,Y.useEffect)(()=>{Ye.current=ut},[ut]),(0,Y.useEffect)(()=>{Xe.current=dt},[dt]),(0,Y.useEffect)(()=>{if(!st||!ct){j([]),N([]),F(!1);return}if(!(X===`opencode`||ht?.tool===`opencode`)){j([]),N([]),F(!1);return}let e=new AbortController;return F(!0),Promise.all([m1(`opencode`,e.signal),h1(`opencode`,ct,e.signal)]).then(([e,t])=>{j(e),N(t)}).catch(e=>{Ze(e)||S(e)||(j([]),N([]))}).finally(()=>{e.signal.aborted||F(!1)}),()=>e.abort()},[st,X,Ze,ct,ht?.tool]),(0,Y.useEffect)(()=>{if(X!==`opencode`){w(``),E(``),k([]);return}w(pt?.model??ft?.helper_model??``),E(pt?.variant??ft?.helper_variant??``),k(pt?.skills??[])},[X,pt?.id,pt?.model,pt?.skills,pt?.variant,ft?.helper_model,ft?.helper_variant]),(0,Y.useEffect)(()=>{pt?.mode&&x(pt.mode)},[pt?.id,pt?.mode]),(0,Y.useEffect)(()=>{let e=A.find(e=>e.id===C)??null;E(t=>e?e.variants.includes(t)?t:``:t)},[A,C]),(0,Y.useEffect)(()=>{U(``),ve(null),de(ht?.model??``),pe(ht?.variant??``),he(ht?.skills??[])},[ht?.id,ht?.model,ht?.skills,ht?.variant]),(0,Y.useEffect)(()=>{be(``),we(null)},[mt?.bundle.id]),(0,Y.useEffect)(()=>{let e=A.find(e=>e.id===ue)??null;pe(t=>e?e.variants.includes(t)?t:``:t)},[A,ue]),(0,Y.useEffect)(()=>{if(!st)return;let e=b1();r(`connecting`);let t=()=>{let e=qe.current,t=Je.current,n=Ye.current,r=Xe.current;it(st,void 0,e),e&&(tt(st,e),J(st,e),et(st,e)),e&&t&&q(st,e,t),e&&n&&$e(st,e,n),e&&r&&Qe(st,e,r)},n=()=>{r(`connected`),t()},i=()=>{r(`reconnecting`)},a=()=>{r(`unavailable`)},o=()=>{it(st,void 0,qe.current)},s=(e=null)=>{let t=qe.current;t&&(e?.project_id&&e.project_id!==t||tt(st,t))},c=(e=null)=>{let t=qe.current;t&&(e?.project_id&&e.project_id!==t||J(st,t))},l=(e=null)=>{let t=qe.current;t&&(e?.project_id&&e.project_id!==t||et(st,t))},u=(e=null)=>{let t=qe.current,n=Je.current;!t||!n||e?.project_id&&e.project_id!==t||e?.id&&e.id!==n||q(st,t,n)},d=(e=null)=>{let t=qe.current,n=Xe.current;!t||!n||e?.project_id&&e.project_id!==t||e?.id&&e.id!==n||Qe(st,t,n)},f=(e=null)=>{let t=qe.current,n=Ye.current;!t||!n||e?.project_id&&e.project_id!==t||$e(st,t,n)};return e.on(`connect`,n),e.on(`disconnect`,i),e.on(`connect_error`,a),e.on(`ticket:created`,s),e.on(`ticket:created`,l),e.on(`ticket:updated`,s),e.on(`ticket:updated`,l),e.on(`ticket:updated`,f),e.on(`ticket:updated`,d),e.on(`ticket:deleted`,o),e.on(`ticket:deleted`,l),e.on(`ticket:deleted`,f),e.on(`ticket-dependency:created`,s),e.on(`ticket-dependency:deleted`,s),e.on(`chat-session:created`,c),e.on(`chat-session:updated`,c),e.on(`chat-session:updated`,u),e.on(`chat-session:deleted`,c),()=>{e.off(`connect`,n),e.off(`disconnect`,i),e.off(`connect_error`,a),e.off(`ticket:created`,s),e.off(`ticket:created`,l),e.off(`ticket:updated`,s),e.off(`ticket:updated`,l),e.off(`ticket:updated`,f),e.off(`ticket:updated`,d),e.off(`ticket:deleted`,o),e.off(`ticket:deleted`,l),e.off(`ticket:deleted`,f),e.off(`ticket-dependency:created`,s),e.off(`ticket-dependency:deleted`,s),e.off(`chat-session:created`,c),e.off(`chat-session:updated`,c),e.off(`chat-session:updated`,u),e.off(`chat-session:deleted`,c),e.disconnect()}},[st,$e,q,J,tt,it,Qe,et]),(0,Y.useEffect)(()=>{ut||l(!1)},[ut]),(0,Y.useEffect)(()=>{dt||d(!1)},[dt]);let xt=()=>{at()},St=e=>{a(e),l(!1),d(!1),p(!1),Ke(null)},Ct=()=>{s(!0)},wt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(We(null),Re(!0),!Ne&&!ze&&nt(e.csrfToken,e.selectedProjectId))},Tt=()=>{e.status===`authenticated`&&(h(!0),y1(e.csrfToken).then(()=>t(D0())).catch(e=>{Ze(e)||t({status:`error`,message:T0(e,`Logout failed. Mobile access may have already been revoked from desktop Archon.`)})}).finally(()=>h(!1)))},Et=()=>{if(e.status!==`pairing_confirmation`||g)return;let n=e.payload;_(!0),t({...e,error:null}),v1(n).then(e=>{if(e.authenticated&&e.csrf_token){window.history.replaceState({},``,`/mobile`),ot(e.csrf_token,e.preferred_project_id);return}t(D0())}).catch(e=>{t(t=>t.status===`pairing_confirmation`?{...t,error:T0(e,`Pairing failed. Regenerate the pairing link from desktop Archon and try again.`)}:t)}).finally(()=>_(!1))},Dt=()=>{window.history.replaceState({},``,`/mobile`),t(D0())},Ot=()=>{e.status===`authenticated`&&(t({...e,projects:null,projectError:null}),it(e.csrfToken))},kt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,projectSummary:null,projectSummaryError:null}),tt(e.csrfToken,e.selectedProjectId))},At=()=>{e.status!==`authenticated`||!e.selectedProjectId||(Pe(null),Ie(null),We(null),nt(e.csrfToken,e.selectedProjectId))},jt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null}),J(e.csrfToken,e.selectedProjectId))},Mt=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedChatSessionId||(t({...e,chatSessionDetail:null,chatSessionDetailError:null}),q(e.csrfToken,e.selectedProjectId,e.selectedChatSessionId))},Nt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),et(e.csrfToken,e.selectedProjectId))},Pt=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||(t({...e,ticketDetail:null,ticketDetailError:null}),Qe(e.csrfToken,e.selectedProjectId,e.selectedTicketId))},Ft=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||(t({...e,bundleDetail:null,bundleDetailError:null}),$e(e.csrfToken,e.selectedProjectId,e.selectedBundleId))},It=n=>{if(e.status!==`authenticated`)return;let r=e.projects?.find(e=>e.id===n)??null;qe.current=n,t({...e,selectedProjectId:n,projectSummary:null,projectSummaryError:null,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),re(null),ie(null),oe(null),ce(null),ne(null),ce(null),setStopRunError(null),we(null),Pe(null),Ie(null),We(null),s(!1),Re(!1),l(!1),d(!1),p(!1),Me(`transcript`),Ke(null),a(`overview`),tt(e.csrfToken,n),r?.active_target_kind===`bundle`&&nt(e.csrfToken,n),J(e.csrfToken,n),et(e.csrfToken,n)},Lt=async t=>{if(!(e.status!==`authenticated`||!e.selectedProjectId)){He(!0),We(null);try{rt(await p1(e.selectedProjectId,e.csrfToken,{kind:`bundle`,bundle_id:t})),Re(!1),tt(e.csrfToken,e.selectedProjectId),nt(e.csrfToken,e.selectedProjectId)}catch(e){if(Ze(e))return;We(T0(e,`Unable to update the project target right now.`))}finally{He(!1)}}},Rt=async(t,n={})=>{if(e.status!==`authenticated`||!e.selectedProjectId)return;He(!0),We(null);let r=r=>p1(e.selectedProjectId??``,e.csrfToken,{kind:`repo_root`,...t?{branch:t}:{},...n.createBranch===!1?{create_branch:!1}:{},...r?{confirm_dirty_switch:!0}:{}});try{let t;try{t=await r(n.confirmDirtySwitch===!0)}catch(e){if(!n.confirmDirtySwitch&&e instanceof O&&e.status===409&&e.message===E1){if(!window.confirm(`${E1}\n\nSwitch anyway?`))return;t=await r(!0)}else throw e}rt(t),Re(!1),tt(e.csrfToken,e.selectedProjectId),nt(e.csrfToken,e.selectedProjectId)}catch(e){if(Ze(e))return;We(T0(e,`Unable to update the project target right now.`))}finally{He(!1)}},zt=n=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedChatSessionId:n,chatSessionDetail:null,chatSessionDetailError:null}),ne(null),Ee(e=>e+1),p(!0),a(`chats`),q(e.csrfToken,e.selectedProjectId,n))},Bt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null}),ne(null),y(``),Ee(e=>e+1),p(!0),a(`chats`))},Vt=n=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedBundleId:n,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),re(null),ie(null),ce(null),we(null),Ke(null),Me(`transcript`),Oe(e=>e+1),l(!0),d(!1),a(`tickets`),$e(e.csrfToken,e.selectedProjectId,n))},Ht=(n,r)=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedTicketId:n,ticketDetail:null,ticketDetailError:null}),Ke(r),Ae(e=>e+1),l(r!==null),d(!0),a(`tickets`),Qe(e.csrfToken,e.selectedProjectId,n))},Ut=()=>{p(!1)},Wt=n=>{if(e.status!==`authenticated`||!e.selectedProjectId)return;if(!e.chatSessionDetail||!e.selectedChatSessionId){x(n);return}if(e.chatSessionDetail.mode===n||R)return;let r=e.selectedProjectId,i=e.selectedChatSessionId,a=e.csrfToken;z(!0),ne(null),n1(r,i,a,{mode:n}).then(e=>{x(e.mode),t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedChatSessionId!==i)return t;let n=t.chatSessions?.map(t=>t.id===e.id?e:t)??t.chatSessions;return{...t,chatSessions:n,chatSessionDetail:e,chatSessionDetailError:null}})}).catch(e=>{Ze(e)||ne(T0(e,`Unable to update the chat mode right now.`))}).finally(()=>z(!1))},Gt=()=>{if(e.status===`authenticated`&&Ge&&e.selectedBundleId===Ge){t({...e,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),d(!1),l(!0),Ke(null);return}Ke(null),d(!1)},Kt=()=>{l(!1)},qt=e=>{let t=A.find(t=>t.id===e)??null;w(e),E(e=>t&&t.variants.includes(e)?e:``)},Jt=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Yt())},Yt=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||I||yt)return;let n=v.trim();if(!n)return;let r=e.selectedProjectId,i=e.csrfToken,a=X===`opencode`&&C?C:null,o=X===`opencode`&&C&&T?T:null,s=X===`opencode`?D:[];ne(null),L(!0);let c=e=>t1(r,e.id,i,{instruction:n,tool:e.tool,model:a,variant:o,skills:s});(e.chatSessionDetail?c(e.chatSessionDetail):e1(r,i,{mode:b,tool:X,model:a,variant:o,skills:s}).then(c)).then(e=>{y(``),p(!0),t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r)return t;let n=t.chatSessions??[],i=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];return{...t,chatSessions:i,selectedChatSessionId:e.id,chatSessionDetail:e,chatSessionDetailError:null}}),J(i,r)}).catch(e=>{Ze(e)||ne(T0(e,`Unable to send the chat prompt.`))}).finally(()=>L(!1))},Xt=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedChatSessionId||B)return;let t=e.selectedProjectId,n=e.selectedChatSessionId;ne(null),ee(n),r1(t,n,e.csrfToken).then(()=>q(e.csrfToken,t,n)).catch(e=>{Ze(e)||ne(T0(e,`Unable to stop the chat response.`))}).finally(()=>ee(null))},Zt=n=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||ae||(n===`stop-run`||n===`pause-build`)&&!window.confirm(`Stop this ticket action on the desktop machine?`))return;let r=e.selectedProjectId,i=e.selectedTicketId,a=e.csrfToken,o=n===`build`?i1(r,i,a,`build`):n===`review`?i1(r,i,a,`review`):n===`run`?a1(r,i,a):n===`stop-run`?o1(r,i,a):n===`pause-build`?s1(r,i,a):c1(r,i,a);oe(n),ce(null),o.then(e=>{t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedTicketId!==i)return t;let n=t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets;return{...t,tickets:n,ticketDetail:e,ticketDetailError:null}}),tt(a,r),et(a,r),Qe(a,r,i)}).catch(e=>{Ze(e)||ce(T0(e,`Unable to update this ticket from mobile.`))}).finally(()=>oe(null))},Qt=n=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||!e.bundleDetail||V)return;let r=e.selectedProjectId,i=e.selectedBundleId,a=e.csrfToken,o=e.bundleDetail,{runningBuildTicketId:s,resumableBuildTicketId:c}=s0(o);if(n===`pause-build`&&!window.confirm(`Pause this bundle build on the desktop machine?`))return;let l=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:r0(t.tickets,e),bundleDetail:e,bundleDetailError:null})},u=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets,bundleDetail:t.bundleDetail?{...t.bundleDetail,tickets:t.bundleDetail.tickets.map(t=>t.id===e.id?e:t)}:t.bundleDetail,bundleDetailError:null})},d=n===`build`?Z$(r,i,a):n===`review`?Q$(r,i,a):n===`pause-build`?s?s1(r,s,a):null:c?c1(r,c,a):null;d&&(re(n),ie(null),d.then(e=>{`tickets`in e?l(e):u(e),tt(a,r),et(a,r),$e(a,r,i)}).catch(e=>{Ze(e)||ie(T0(e,`Unable to update this bundle from mobile.`))}).finally(()=>re(null)))},$t=e=>{let t=A.find(t=>t.id===e)??null;de(e),pe(e=>t&&t.variants.includes(e)?e:``)},en=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),tn())},tn=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||!e.ticketDetail||ge)return;let n=le.trim();if(!n)return;let r=e.selectedProjectId,i=e.ticketDetail,a=e.csrfToken,o=BW(i,{model:ue||null,variant:fe||null,skills:me}),s=()=>i.state===`plan`?u1(r,i.id,a,n):d1(r,i.id,a,n),c=e=>{t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedTicketId!==i.id)return t;let n=t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets;return{...t,tickets:n,ticketDetail:e,ticketDetailError:null}})};W(!0),ve(null),(async()=>{o.shouldPersist&&c(await l1(r,i.id,a,{model:o.model,variant:o.variant,skills:o.skills})),c(await s()),U(``),et(a,r),Qe(a,r,i.id)})().catch(e=>{Ze(e)||ve(T0(e,`Unable to send the ticket follow-up.`))}).finally(()=>W(!1))},nn=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),rn())},rn=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||!e.bundleDetail||xe)return;let n=ye.trim();if(!n)return;let r=e.selectedProjectId,i=e.selectedBundleId,a=e.csrfToken,o=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:r0(t.tickets,e),bundleDetail:e,bundleDetailError:null})};Se(!0),we(null),f1(r,i,a,n).then(e=>{o(e),be(``),et(a,r),$e(a,r,i)}).catch(e=>{Ze(e)||we(T0(e,`Unable to send the bundle follow-up.`))}).finally(()=>Se(!1))};return e.status===`checking`?(0,Z.jsx)(j1,{title:`Checking mobile session`,description:`Archon is validating this browser before showing project controls.`}):e.status===`pairing`?(0,Z.jsx)(j1,{title:`Checking pairing link`,description:`Keep this page open while Archon verifies the one-time pairing link.`}):e.status===`pairing_confirmation`?(0,Z.jsxs)(j1,{title:`Compare pairing code`,description:`Confirm this code matches the desktop dialog before pairing this phone.`,children:[(0,Z.jsx)(mu,{className:`border-primary/25 bg-primary/10 shadow-none`,children:(0,Z.jsxs)(yu,{className:`space-y-2 pt-5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-foreground`,children:`Verification code`}),(0,Z.jsx)(`div`,{className:`font-mono text-3xl font-semibold tracking-[0.18em] text-foreground`,children:e.displayCode}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Expires at `,w0(e.expiresAt)]})]})}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`If this code does not match the desktop dialog, cancel and regenerate the pairing link from desktop Archon.`}),e.error?(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:e.error}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(K,{size:`lg`,disabled:g,onClick:Et,children:g?`Pairing...`:`Pair this phone`}),(0,Z.jsx)(K,{variant:`outline`,size:`lg`,disabled:g,onClick:Dt,children:`Cancel`})]})]}):e.status===`unauthenticated`?(0,Z.jsx)(j1,{title:e.reason===`session_revoked`?`Mobile session revoked`:`Pairing required`,description:e.reason===`session_revoked`?`This mobile session is no longer valid. Scan the QR code or open the pairing link from desktop Archon to continue.`:`This browser is not paired. Scan the QR code or open the pairing link from desktop Archon.`,children:(0,Z.jsx)(K,{onClick:xt,children:`Retry`})}):e.status===`error`?(0,Z.jsx)(j1,{title:`Mobile access unavailable`,description:e.message,children:(0,Z.jsx)(K,{onClick:xt,children:`Retry`})}):(0,Z.jsxs)(`main`,{className:G(`bg-background text-foreground`,bt?`flex h-[100dvh] flex-col overflow-hidden`:`min-h-screen`),children:[(0,Z.jsx)(R1,{open:o,projects:e.projects,selectedProjectId:e.selectedProjectId,error:e.projectError,onOpenChange:s,onSelectProject:It,onRetry:Ot}),(0,Z.jsx)(z1,{open:Le,project:ft,targetOptions:Ne,error:Ue??Fe,isLoading:ze,isSubmitting:Ve,onOpenChange:Re,onRetry:At,onSelectBundle:e=>{Lt(e)},onSelectRepoRoot:(e,t)=>{Rt(e,t)}}),(0,Z.jsx)(B1,{selectedProject:ft,targetLabel:gt,isTargetLoading:_t,isTargetDisabled:!ct,connectionState:n,onOpenProjects:Ct,onOpenTargetSelector:wt}),bt?(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-6xl flex-1 flex-col overflow-hidden px-3 py-3 sm:px-4`,children:[i===`tickets`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:u&&e.selectedTicketId?(0,Z.jsx)(x0,{selectedProjectId:e.selectedProjectId,ticketId:e.selectedTicketId,ticket:e.ticketDetail,openNonce:ke,error:e.ticketDetailError,actionState:ae,actionError:se,followUpPrompt:le,followUpSelectedModel:ue,followUpSelectedVariant:fe,followUpSelectedSkills:me,availableModels:A,availableSkills:M,isLoadingAgentSettings:P,isSendingFollowUp:ge,followUpError:_e,onBack:Gt,onRetry:Pt,onAction:Zt,onFollowUpPromptChange:U,onFollowUpModelChange:$t,onFollowUpVariantChange:pe,onFollowUpSkillsChange:he,onFollowUpKeyDown:en,onFollowUpSubmit:tn,isLargeScreen:!1}):(0,Z.jsx)(y0,{selectedProjectId:e.selectedProjectId,bundleId:e.selectedBundleId,bundleDetail:e.bundleDetail,openNonce:De,mobileDetailView:je,error:e.bundleDetailError,actionState:V,actionError:H,followUpPrompt:ye,isSendingFollowUp:xe,followUpError:Ce,availableModels:A,onBack:Kt,onRetry:Ft,onAction:Qt,onDetailViewChange:Me,onSelectTicket:Ht,onFollowUpPromptChange:be,onFollowUpKeyDown:nn,onFollowUpSubmit:rn,isLargeScreen:!1})}):null,i===`chats`?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(b0,{selectedProjectId:e.selectedProjectId,chatSession:e.chatSessionDetail,chatSessionId:e.selectedChatSessionId,openNonce:Te,error:e.chatSessionDetailError,isStopping:B===e.selectedChatSessionId,composerMode:e.chatSessionDetail?.mode??b,composerTool:X,prompt:v,selectedModel:C,selectedVariant:T,selectedSkills:D,availableModels:A,availableSkills:M,isLoadingAgentSettings:P,isSending:I,isUpdatingMode:R,composerDisabledReason:yt,onBack:Ut,onRetry:Mt,onStop:Xt,onModeChange:Wt,onPromptChange:y,onModelChange:qt,onVariantChange:E,onSkillsChange:k,onPromptKeyDown:Jt,onSubmit:Yt,isLargeScreen:!1}),te?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-200`,children:te}):null]}):null]}):(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-3 py-3 pb-[calc(env(safe-area-inset-bottom)+5rem)] sm:px-4 lg:flex lg:min-h-[calc(100dvh-4.5rem)] lg:flex-col lg:overflow-hidden lg:pb-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-3 lg:flex lg:min-h-0 lg:flex-1 lg:flex-col`,children:[(0,Z.jsx)(F1,{status:n,onRetry:xt}),i===`overview`?(0,Z.jsx)(`div`,{className:`space-y-3 lg:flex lg:min-h-0 lg:flex-1 lg:flex-col`,children:e.projectError?(0,Z.jsx)(H1,{title:`Projects unavailable`,description:e.projectError,action:(0,Z.jsx)(K,{variant:`warning`,onClick:Ot,children:`Retry projects`})}):e.selectedProjectId&&!e.projectSummary&&!e.projectSummaryError?(0,Z.jsx)(G1,{}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y1,{selectedProjectId:e.selectedProjectId,summary:e.projectSummary,tickets:e.tickets,error:e.projectSummaryError,chatSessions:e.chatSessions,chatSessionDetail:e.chatSessionDetail,onRetry:kt,onOpenTickets:()=>St(`tickets`),onOpenChats:()=>St(`chats`)}),(0,Z.jsx)(K1,{isLoggingOut:m,onLogout:Tt})]})}):null,i===`tickets`?vt?(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden lg:grid-cols-[minmax(15rem,18rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`min-h-0`,children:(0,Z.jsx)(i0,{selectedProjectId:e.selectedProjectId,tickets:e.tickets,selectedBundleId:e.selectedBundleId,selectedTicketId:e.selectedTicketId,error:e.ticketsError,onRetry:Nt,onSelectBundle:Vt,onSelectTicket:Ht})}),(0,Z.jsx)(`div`,{className:`hidden min-h-0 lg:flex lg:flex-col lg:overflow-hidden`,children:u&&e.selectedTicketId?(0,Z.jsx)(x0,{selectedProjectId:e.selectedProjectId,ticketId:e.selectedTicketId,ticket:e.ticketDetail,openNonce:ke,error:e.ticketDetailError,actionState:ae,actionError:se,followUpPrompt:le,followUpSelectedModel:ue,followUpSelectedVariant:fe,followUpSelectedSkills:me,availableModels:A,availableSkills:M,isLoadingAgentSettings:P,isSendingFollowUp:ge,followUpError:_e,onBack:Gt,onRetry:Pt,onAction:Zt,onFollowUpPromptChange:U,onFollowUpModelChange:$t,onFollowUpVariantChange:pe,onFollowUpSkillsChange:he,onFollowUpKeyDown:en,onFollowUpSubmit:tn,isLargeScreen:!0}):(0,Z.jsx)(y0,{selectedProjectId:e.selectedProjectId,bundleId:e.selectedBundleId,bundleDetail:e.bundleDetail,openNonce:De,mobileDetailView:je,error:e.bundleDetailError,actionState:V,actionError:H,followUpPrompt:ye,isSendingFollowUp:xe,followUpError:Ce,availableModels:A,onBack:Kt,onRetry:Ft,onAction:Qt,onDetailViewChange:Me,onSelectTicket:Ht,onFollowUpPromptChange:be,onFollowUpKeyDown:nn,onFollowUpSubmit:rn,isLargeScreen:!0})})]}):(0,Z.jsx)(i0,{selectedProjectId:e.selectedProjectId,tickets:e.tickets,selectedBundleId:e.selectedBundleId,selectedTicketId:e.selectedTicketId,error:e.ticketsError,onRetry:Nt,onSelectBundle:Vt,onSelectTicket:Ht}):null,i===`chats`?vt?(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden lg:grid-cols-[minmax(15rem,18rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`min-h-0`,children:(0,Z.jsx)(a0,{selectedProjectId:e.selectedProjectId,chatSessions:e.chatSessions,selectedChatSessionId:e.selectedChatSessionId,error:e.chatSessionsError,onRetry:jt,onOpenNewChat:Bt,onSelectChat:zt})}),(0,Z.jsxs)(`div`,{className:`hidden min-h-0 lg:flex lg:flex-col lg:overflow-hidden`,children:[(0,Z.jsx)(b0,{selectedProjectId:e.selectedProjectId,chatSession:e.chatSessionDetail,chatSessionId:e.selectedChatSessionId,openNonce:Te,error:e.chatSessionDetailError,isStopping:B===e.selectedChatSessionId,composerMode:e.chatSessionDetail?.mode??b,composerTool:X,prompt:v,selectedModel:C,selectedVariant:T,selectedSkills:D,availableModels:A,availableSkills:M,isLoadingAgentSettings:P,isSending:I,isUpdatingMode:R,composerDisabledReason:yt,onBack:Ut,onRetry:Mt,onStop:Xt,onModeChange:Wt,onPromptChange:y,onModelChange:qt,onVariantChange:E,onSkillsChange:k,onPromptKeyDown:Jt,onSubmit:Yt,isLargeScreen:!0}),te?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-200`,children:te}):null]})]}):(0,Z.jsx)(a0,{selectedProjectId:e.selectedProjectId,chatSessions:e.chatSessions,selectedChatSessionId:e.selectedChatSessionId,error:e.chatSessionsError,onRetry:jt,onOpenNewChat:Bt,onSelectChat:zt}):null]})}),bt?null:(0,Z.jsx)(V1,{activeSection:i,onChange:St})]})},A0=({socket:e=MW,children:t})=>(0,Z.jsx)(DY.Provider,{value:e,children:t}),j0=()=>typeof window<`u`&&window.location.pathname.startsWith(`/mobile`),M0=()=>{let e=j0();return $l(e?null:MW),(0,Z.jsx)(yt,{i18n:Ne,children:(0,Z.jsx)(St,{children:(0,Z.jsxs)(A0,{children:[e&&(0,Z.jsx)(k0,{}),!e&&(0,Z.jsx)(I$,{})]})})})};document.documentElement.classList.add(`dark`),document.documentElement.style.colorScheme=`dark`,(0,rt.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(M0,{}));export{ed as a,Oc as c,Ms as d,Is as f,Fs as h,td as i,Os as l,Ns as m,of as n,Nc as o,Ps as p,$u as r,jc as s,MW as t,As as u};
|
|
149
|
+
`),stages:``,priority:`normal`},XX=e=>e.split(`
|
|
150
|
+
`).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),ZX=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},QX=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=GX(a?`suggested.saveAsNewDecision`:`suggested.accept`),s=e.kind===`decision`?e.decision:e.instruction;return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(WX,{children:GX(`suggested.badge`,{kind:e.kind})}),a?(0,Z.jsx)(WX,{tone:`muted`,children:GX(`suggested.duplicateBadge`)}):null]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:GX(`suggested.review`)}),(0,Z.jsx)(K,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:GX(`suggested.dismiss`)})]})]})})},$X=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?GX(`suggested.saveAsNewDecision`):GX(`suggested.acceptAs`,{kind:e.kind});return(0,Z.jsx)(Os,{open:t,onOpenChange:a,children:(0,Z.jsxs)(Ms,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Ns,{children:[(0,Z.jsx)(Fs,{children:e.title}),(0,Z.jsx)(Is,{children:GX(`suggested.reviewDescription`,{kind:e.kind})})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:GX(`suggested.duplicateTitle`)}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}):null,n?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:GX(`editor.titleLabel`)}),(0,Z.jsx)(`input`,{"aria-label":GX(`editor.titleAriaLabel`),value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:GX(`editor.scopeLabel`)}),(0,Z.jsx)(`input`,{"aria-label":GX(`editor.scopeAriaLabel`),value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:i.kind===`decision`?GX(`suggested.decision`):GX(`suggested.instruction`)}),(0,Z.jsx)(`textarea`,{"aria-label":i.kind===`decision`?GX(`suggested.decision`):GX(`suggested.instruction`),value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`min-h-32 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:GX(`editor.rationaleLabel`)}),(0,Z.jsx)(`textarea`,{"aria-label":GX(`editor.rationaleAriaLabel`),value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:GX(`suggested.implicationsMultiline`)}),(0,Z.jsx)(`textarea`,{"aria-label":GX(`editor.implicationsAriaLabel`),value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:GX(`suggested.stagesMultiline`)}),(0,Z.jsx)(`textarea`,{"aria-label":GX(`editor.stagesLabel`),value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:GX(`editor.priorityLabel`)}),(0,Z.jsxs)(`select`,{"aria-label":GX(`editor.priorityAriaLabel`),value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,Z.jsx)(`option`,{value:`low`,children:GX(`priorityLabels.low`)}),(0,Z.jsx)(`option`,{value:`normal`,children:GX(`priorityLabels.normal`)}),(0,Z.jsx)(`option`,{value:`high`,children:GX(`priorityLabels.high`)})]})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e.kind===`decision`?GX(`suggested.decision`):GX(`suggested.instruction`)}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-foreground`,children:e.kind===`decision`?e.decision:e.instruction})]}),e.rationale?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:GX(`editor.rationaleLabel`)}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-muted-foreground`,children:e.rationale})]}):null,e.kind===`decision`&&e.implications.length>0?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:GX(`editor.implicationsLabel`)}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:e.implications.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}):null,e.kind===`convention`?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:GX(`editor.stagesLabel`)}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:e.stages.map(e=>KX(e)).join(`, `)||GX(`suggested.noneSpecified`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:GX(`editor.priorityLabel`)}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:qX(e.priority)})]})]}):null]})]}),(0,Z.jsxs)(Ps,{className:`flex flex-wrap gap-2 sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:GX(`suggested.cancelEdits`)}):(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:GX(`suggested.edit`)}),(0,Z.jsx)(K,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(e),children:GX(`suggested.dismiss`)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d?(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:GX(`suggested.updateExistingDecision`)}):null,(0,Z.jsx)(K,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})]})]})})},eZ=({projectId:e,suggestions:t,title:n,description:r,emptyState:i=null,onSuggestionsChanged:a})=>{let[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(JX),[f,p]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{l(e=>e&&!t.some(t=>t.id===e)?null:e),s(e=>e&&!t.some(t=>t.id===e)?null:e)},[t]);let m=o?t.find(e=>e.id===o)??null:null,h=()=>{l(null),d(JX())},g=e=>{s(e.id),l(e.id),d(YX(e))},_=e=>{c&&c!==e.id&&h(),s(e.id)},v=e=>{e||(s(null),c&&h())},y=async(t,n)=>{let r=c===t.id?u:YX(t),i=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:XX(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:ZX(r.stages),priority:r.priority};p(t.id);try{if(n){if(t.kind!==`decision`)throw Error(GX(`messages.onlyDecisionSuggestionsCanUpdate`));let n=t.duplicate_match?.decision;if(!n)throw Error(GX(`messages.noExistingDecision`));await Le(e,t.id,n.id,i)}else await w(e,t.id,i);h(),s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:GX(`messages.saveSuggestionError`),{id:`project-memory-suggestion-error`})}finally{p(null)}},b=async t=>{p(t.id);try{await Me(e,t.id),c===t.id&&h(),o===t.id&&s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:GX(`messages.dismissSuggestionError`),{id:`project-memory-suggestion-error`})}finally{p(null)}};return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[n||r?(0,Z.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,Z.jsxs)(`div`,{children:[n?(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:n}):null,r?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}):null]})}):null,t.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,Z.jsx)(QX,{suggestion:e,isPending:f===e.id,onReview:_,onAccept:e=>y(e,!1),onDismiss:b},e.id))}):i?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:i}):null,(0,Z.jsx)($X,{suggestion:m,isOpen:!!m,isEditing:c===m?.id,isPending:f===m?.id,draft:c===m?.id?u:m?YX(m):u,onOpenChange:v,onStartEdit:g,onDraftChange:d,onCancelEdit:h,onAccept:y,onDismiss:b})]})},tZ=()=>({selectedDiffPath:`all`,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}),nZ=[{key:`today`,label:`Today`},{key:`yesterday`,label:`Yesterday`},{key:`last_7_days`,label:`Last 7 Days`},{key:`older`,label:`Older`}],rZ=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},iZ=e=>e.activity_at??e.last_user_message_at??e.created_at,aZ=(e,t)=>{let n=iZ(e),r=iZ(t);return n===r?e.created_at===t.created_at?t.id.localeCompare(e.id):t.created_at.localeCompare(e.created_at):r.localeCompare(n)},oZ=e=>[...e].sort(aZ),sZ=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),cZ=(e,t=new Date)=>{let n=rZ(iZ(e));if(!n)return`older`;let r=sZ(t),i=new Date(r);i.setDate(i.getDate()-1);let a=new Date(r);return a.setDate(a.getDate()-6),n>=r?`today`:n>=i?`yesterday`:n>=a?`last_7_days`:`older`},lZ=(e,t=new Date)=>{let n=new Map;for(let r of oZ(e)){let e=cZ(r,t);n.set(e,[...n.get(e)??[],r])}return nZ.flatMap(e=>{let t=n.get(e.key)??[];return t.length===0?[]:[{key:e.key,label:e.label,sessions:t}]})},uZ=e=>{let t={...e};return delete t.messages,t.agent_log=null,t.agent_message_id=null,t.previous_agent_log=null,t.previous_agent_message_id=null,t.streaming_response=null,t},dZ=(e,t)=>Ne.t(`chatView.${e}`,t),fZ=1500,pZ=`archon.chat-run-config`,mZ=`archon.chat-changes-panel-layout`,hZ=`archon.chat-session-list-layout`,gZ=`archon.chat-draft`,_Z=512,vZ=360,yZ=.6,bZ=6,xZ=`.`,SZ=`/`,CZ=`Slash`,wZ=`NumpadDivide`,TZ=600,EZ=4,DZ=`mt-1 flex min-h-5 flex-wrap items-center gap-2 text-xs text-muted-foreground`,OZ=(e,t)=>{let n=Number.isFinite(e)?Math.round(e):_Z;if(!Number.isFinite(t))return Math.max(vZ,n);let r=Math.max(vZ,Math.round(t*yZ));return Math.max(vZ,Math.min(r,n))},kZ=e=>dZ(e===`claude`?`tool.claude`:`tool.opencode`),AZ=({availableModelsById:e,model:t})=>t?e.get(t)??t:null,jZ=e=>dZ(e===`plan`?`mode.plan`:`mode.build`),MZ=e=>dZ(e===`plan`?`placeholders.plan`:`placeholders.build`),NZ=e=>dZ(`pendingMemorySuggestions`,{count:e}),PZ=e=>e===`plan`?`build`:`plan`,FZ=e=>!e.defaultPrevented&&!e.altKey&&!e.shiftKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&e.key===xZ,IZ=e=>!e.defaultPrevented&&!e.altKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&(e.key===SZ||e.code===CZ||e.code===wZ),LZ=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??navigator.userAgent;return/mac/i.test(e)},RZ=()=>LZ()?dZ(`shortcuts.modifierMac`):dZ(`shortcuts.modifierDefault`),zZ=({modifierLabel:e,keys:t,ariaHidden:n=!1})=>(0,Z.jsxs)(`span`,{"aria-hidden":n,className:`flex items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(pw,{"aria-hidden":n,children:e}),t.map(e=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(pw,{"aria-hidden":n,children:e})]},e))]}),BZ=({label:e,modifierLabel:t,keys:n})=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(zZ,{modifierLabel:t,keys:n,ariaHidden:!0})]}),VZ=({modelLabel:e,tool:t})=>e??kZ(t),HZ=()=>dZ(`user.you`),UZ=e=>{if(!Number.isFinite(e))return`0`;if(e>=1e6){let t=e/1e6,n=t<10?2:1;return`${t.toFixed(n)}M`}return e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`},WZ=({totalTokens:e,contextWindow:t})=>!Number.isFinite(e)||!Number.isFinite(t)||t<=0?null:Math.round(e/t*100),GZ=({tool:e,model:t,availableModels:n,fallbackContextWindow:r})=>e===`opencode`?(n.find(e=>e.id===t)??null)?.context_window??r:r,KZ=({projectId:e,tool:t})=>`${pZ}:${e}:${t}`,qZ=({projectId:e,tool:t,chatSessionId:n})=>n?`${gZ}:${e}:session:${n}`:`${gZ}:${e}:draft:${t}`,JZ=e=>`${mZ}:${e}`,YZ=e=>`${hZ}:${e}`,XZ=e=>{if(!e)return``;try{return window.localStorage.getItem(e)??``}catch{return``}},ZZ=({storageKey:e,value:t})=>{if(e)try{if(t){window.localStorage.setItem(e,t);return}window.localStorage.removeItem(e)}catch{}},QZ=e=>{if(!e)return{isOpen:!0,width:_Z};try{let t=window.localStorage.getItem(JZ(e));if(!t)return{isOpen:!0,width:_Z};let n=JSON.parse(t),r=typeof n.width==`number`&&Number.isFinite(n.width)?Math.max(vZ,Math.round(n.width)):_Z;return{isOpen:n.isOpen!==!1,width:r}}catch{return{isOpen:!0,width:_Z}}},$Z=e=>{if(!e)return{isOpen:!0};try{let t=window.localStorage.getItem(YZ(e));return t?{isOpen:JSON.parse(t).isOpen!==!1}:{isOpen:!0}}catch{return{isOpen:!0}}},eQ=({projectId:e,isOpen:t,width:n})=>{if(e)try{window.localStorage.setItem(JZ(e),JSON.stringify({isOpen:t,width:n}))}catch{}},tQ=({projectId:e,isOpen:t})=>{if(e)try{window.localStorage.setItem(YZ(e),JSON.stringify({isOpen:t}))}catch{}},nQ=({projectId:e,tool:t})=>{if(!e||t!==`opencode`)return null;try{let n=window.localStorage.getItem(KZ({projectId:e,tool:t}));if(!n)return null;let r=JSON.parse(n),i=(typeof r.model==`string`?r.model.trim():``)||null,a=r.mode===`plan`||r.mode===`build`?r.mode:null;return!i&&!a?null:{model:i,variant:i&&typeof r.variant==`string`&&r.variant.trim()||null,mode:a}}catch{return null}},rQ=({projectId:e,tool:t,model:n,variant:r,mode:i})=>{if(!(!e||t!==`opencode`||!n&&!i))try{window.localStorage.setItem(KZ({projectId:e,tool:t}),JSON.stringify({model:n,variant:n?r:null,mode:i}))}catch{}},iQ=({projectId:e,tool:t})=>nQ({projectId:e,tool:t})?.mode??`plan`,aQ=({activeProjectId:e,helperModel:t,helperVariant:n,activeTool:r,availableModels:i})=>{let a=nQ({projectId:e,tool:r}),o=new Set(i.map(e=>e.id)),s=e=>e?o.size===0?!0:o.has(e):!1,c=t??``,l=a?.model??``,u=s(l)?l:s(c)?c:``,d=u===l?a?.variant??null:u&&u===c?n??null:null,f=i.find(e=>e.id===u)??null;return{model:u,variant:f?f.variants.includes(d??``)?d??``:``:u?d??``:``,mode:a?.mode??`plan`}},oQ=e=>e&&e.replace(/\s+/g,` `).trim()||null,sQ=e=>{let t=oQ(e.first_user_message_preview);if(t)return t;let n=e.messages?.find(e=>e.role===`user`)?.content;return oQ(n)},cQ=({chatSessionId:e,instruction:t,attachments:n,createdAt:r})=>({id:`optimistic:${e}:${r}`,chat_session_id:e,role:`user`,kind:`prompt`,content:t,attachments:n,created_at:r}),lQ=({session:e,instruction:t,attachments:n,createdAt:r})=>({...e,messages:[...e.messages??[],cQ({chatSessionId:e.id,instruction:t,attachments:n,createdAt:r})],activity_at:r,last_user_message_at:r,updated_at:r}),uQ=e=>!!(e.first_user_message_preview||e.last_user_message_at||e.messages?.some(e=>e.role===`user`)),dQ=({activeProject:e,activeProjectBranchState:t,session:n})=>!e||n.target_available===!1?!1:n.target_kind===`bundle`?e.active_target_kind===`bundle`&&!!n.target_bundle_id&&e.active_target_bundle_id===n.target_bundle_id:e.active_target_kind===`bundle`?!1:!t||!n.target_branch_snapshot?!0:t?.status!==`ready`||!t.branch?!1:t.branch===n.target_branch_snapshot,fQ=({session:e,activeProject:t,activeProjectBranchState:n})=>e.target_kind===`bundle`?e.target_label_snapshot||dZ(`targets.bundleFallback`):!t||t.active_target_kind===`bundle`||n?.status!==`ready`||!n.branch||!e.target_branch_snapshot||n.branch===e.target_branch_snapshot?null:dZ(`targets.repoRootWithBranch`,{branch:e.target_branch_snapshot}),pQ=e=>e.target_kind===`bundle`?e.target_label_snapshot||dZ(`targets.bundleFallback`):e.target_branch_snapshot?dZ(`targets.repoRootWithBranch`,{branch:e.target_branch_snapshot}):dZ(`targets.repoRoot`),mQ=({activeProject:e,activeProjectBranchState:t})=>e?e.active_target_kind===`bundle`?dZ(`targets.selectedBundleTarget`):t?.branch?dZ(`targets.repoRootWithBranch`,{branch:t.branch}):dZ(`targets.repoRoot`):dZ(`targets.currentTarget`),hQ=e=>e.agent_status===`running`?dZ(`sidebar.deleteDisabledReason`):null,gQ=({count:e,title:t,isDeleting:n,onConfirm:r,onCancel:i})=>{let a=e>1;return(0,Z.jsxs)(du,{onClose:i,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:dZ(a?`deleteSessionModal.bulkTitle`:`deleteSessionModal.title`)}),t?(0,Z.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:t}):null,(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:a?dZ(`deleteSessionModal.bulkDescription`,{count:e}):dZ(`deleteSessionModal.description`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(K,{type:`button`,variant:`ghost`,onClick:i,disabled:n,children:dZ(`deleteSessionModal.cancel`)}),(0,Z.jsx)(K,{type:`button`,variant:`destructive`,onClick:r,disabled:n,children:dZ(n?`deleteSessionModal.deleting`:`deleteSessionModal.delete`)})]})]})},_Q=({activeProject:e,activeProjectBranchState:t,activeSessionId:n,chatModeShortcutModifierLabel:r,deletingSessionIds:i,finishedBackgroundSessionIds:a,hasDeletableSessions:o,isCreatingSession:s,isSelectionMode:c,isDraftOpen:l,isLoadingSessions:u,isOpen:d,isSendingPrompt:f,selectedSessionCount:p,selectedSessionIds:m,sessionGroups:h,sessions:g,onConfirmDeleteSelectedSessions:_,onConfirmDeleteSession:v,onDraftOpen:y,onEnterSelectionMode:b,onExitSelectionMode:x,onSetSessionSelection:S,onSessionSelect:C,onToggleSessionSelection:w,onToggleOpen:T})=>{let E=(0,Y.useMemo)(()=>new Set(g.filter(e=>!hQ(e)&&!i.has(e.id)).map(e=>e.id)),[i,g]),D=(0,Y.useRef)(null),O=(0,Y.useRef)(!1),k=(0,Y.useRef)(null),A=(0,Y.useCallback)(()=>{k.current!==null&&(window.clearTimeout(k.current),k.current=null)},[]),j=(0,Y.useCallback)(()=>{A(),k.current=window.setTimeout(()=>{O.current=!1,k.current=null},0)},[A]),M=(0,Y.useCallback)(()=>{D.current&&(D.current=null,j())},[j]),N=(0,Y.useCallback)(e=>{let t=D.current;!t||t.visitedSessionIds.has(e)||!E.has(e)||(t.visitedSessionIds.add(e),S(e,t.mode===`select`))},[S,E]),P=(0,Y.useCallback)(e=>{let t=D.current;!t||e.pointerId!==t.pointerId||M()},[M]);return(0,Y.useEffect)(()=>{if(!c){M();return}return window.addEventListener(`pointerup`,P),window.addEventListener(`pointercancel`,P),()=>{window.removeEventListener(`pointerup`,P),window.removeEventListener(`pointercancel`,P),M(),A()}},[A,P,c,M]),(0,Z.jsx)(`aside`,{"data-testid":`chat-sessions-sidebar`,"data-state":d?`expanded`:`collapsed`,"aria-label":dZ(`sidebar.ariaLabel`),className:G(`relative z-20 flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background/40 transition-[width] duration-200 ease-out motion-reduce:transition-none`,d?`w-72`:`w-16`),children:d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-start gap-2 border-b border-border/70 px-4 py-3.5`,children:[(0,Z.jsxs)(K,{type:`button`,size:`sm`,className:`gap-2`,onClick:y,disabled:s||f,children:[(0,Z.jsx)(Ll,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:dZ(`sidebar.newSession`)}),(0,Z.jsx)(zZ,{modifierLabel:r,keys:[SZ],ariaHidden:!0})]}),(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":dZ(`sidebar.collapseAriaLabel`),"aria-expanded":d,className:`ml-auto`,onClick:T,children:(0,Z.jsx)(CX,{className:`h-4 w-4`})})]}),g.length>0?(0,Z.jsx)(`div`,{className:`px-4 py-2.5`,children:c?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:x,disabled:i.size>0,children:dZ(`sidebar.cancelSelection`)}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`destructive`,className:`h-7 px-2 text-xs`,onClick:_,disabled:p===0||i.size>0,children:dZ(`sidebar.deleteSelected`)})]}),(0,Z.jsx)(`div`,{className:`flex justify-end text-xs font-medium text-muted-foreground`,children:dZ(`sidebar.selectedCount`,{count:p})})]}):o?(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:b,children:[(0,Z.jsx)(SX,{className:`h-3.5 w-3.5`}),dZ(`sidebar.select`)]}):null}):null,(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:u&&g.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground`,children:dZ(`sidebar.loadingSessions`)}):g.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:dZ(`sidebar.noSessions`)}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:h.map(r=>(0,Z.jsxs)(`section`,{"aria-label":r.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`div`,{className:`px-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/80`,children:r.label}),r.sessions.map(r=>{let o=!l&&r.id===n,s=sQ(r),u=fQ({session:r,activeProject:e,activeProjectBranchState:t}),d=hQ(r),f=i.has(r.id),p=!!d||f,h=m.has(r.id),g=r.agent_status===`running`?`running`:r.agent_status===`stopped`?`interrupted`:!o&&a.has(r.id)?`finished`:null,_=g===`interrupted`?null:g;return(0,Z.jsxs)(`div`,{"data-chat-session-id":r.id,"data-chat-session-selectable":p?`false`:`true`,className:G(`group relative rounded-xl border transition-colors`,o?`border-sky-400/40 bg-sky-500/10 text-foreground ring-1 ring-sky-400/40`:`border-border/50 bg-card/35 text-muted-foreground hover:border-border/80 hover:bg-card/60 hover:text-foreground`),onPointerDownCapture:e=>{!c||p||e.pointerType&&e.pointerType!==`mouse`||typeof e.button==`number`&&e.button!==0||(e.preventDefault(),A(),O.current=!0,D.current={pointerId:e.pointerId,mode:h?`deselect`:`select`,visitedSessionIds:new Set},N(r.id))},onPointerMove:e=>{let t=D.current;!t||t.pointerId!==e.pointerId||N(r.id)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":[r.title,jZ(r.mode),kZ(r.tool),e?.memory_enabled&&r.pending_memory_suggestion_count>0?NZ(r.pending_memory_suggestion_count):null,g===`running`?dZ(`sidebar.running`):g===`interrupted`?dZ(`sidebar.interrupted`):g===`finished`?dZ(`sidebar.finished`):null].filter(Boolean).join(` `),className:`flex w-full min-w-0 cursor-pointer items-start gap-2 rounded-xl px-3 py-2 pr-11 text-left transition-colors focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,onClick:()=>{if(c){if(O.current){O.current=!1;return}if(p)return;w(r.id);return}C(r)},children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[u?(0,Z.jsx)(`div`,{className:`mb-1 truncate text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75`,children:u}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:r.title}),e?.memory_enabled&&r.pending_memory_suggestion_count>0?(0,Z.jsx)(WX,{tone:o?`default`:`muted`,className:`shrink-0`,"aria-label":NZ(r.pending_memory_suggestion_count),title:NZ(r.pending_memory_suggestion_count),children:r.pending_memory_suggestion_count}):null]}),s?(0,Z.jsx)(`div`,{className:G(`mt-0.5 line-clamp-1 text-xs leading-4`,o?`text-foreground/70`:`text-muted-foreground`),children:s}):null,r.target_available===!1?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-1 text-[11px] leading-4 text-amber-200/90`,children:r.target_unavailable_reason??dZ(`sidebar.targetUnavailable`)}):null]}),(0,Z.jsx)(Il,{state:_,className:`mt-1`})]})}),c?(0,Z.jsx)(`div`,{className:`absolute top-2 right-2 flex h-7 w-7 items-center justify-center`,title:d??dZ(`sidebar.selectSessionTitle`,{title:r.title}),children:(0,Z.jsx)(`input`,{type:`checkbox`,"aria-label":dZ(`sidebar.selectSessionAriaLabel`,{title:r.title}),checked:h,disabled:p,onClick:e=>{e.stopPropagation()},onChange:()=>{O.current||w(r.id)},className:`h-4 w-4 rounded border-border bg-background text-primary`})}):(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":dZ(`sidebar.deleteSessionAriaLabel`),className:G(`absolute top-2 right-2 h-7 w-7 shrink-0 rounded-md border border-transparent text-muted-foreground transition-all duration-150 hover:border-border/70 hover:bg-card/80 hover:text-foreground focus-visible:border-border/70 focus-visible:bg-card/80 focus-visible:text-foreground`,`opacity-100 sm:opacity-0 sm:pointer-events-none sm:group-hover:pointer-events-auto sm:group-focus-within:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,p&&`sm:disabled:opacity-0 sm:group-hover:disabled:opacity-50 sm:group-focus-within:disabled:opacity-50`,(o||f)&&`sm:pointer-events-auto sm:opacity-100 sm:disabled:opacity-50`,d&&`cursor-not-allowed text-muted-foreground/50 hover:border-transparent hover:bg-transparent hover:text-muted-foreground/50 focus-visible:border-transparent focus-visible:bg-transparent focus-visible:text-muted-foreground/50`),title:d??dZ(`sidebar.deleteSessionTitle`,{title:r.title}),disabled:p,onClick:e=>{e.stopPropagation(),v(r.id)},children:(0,Z.jsx)(Su,{className:`h-4 w-4`})})]},r.id)})]},r.key))})})]}):(0,Z.jsxs)(`div`,{"data-testid":`chat-sessions-rail`,className:`flex h-full w-full flex-col items-center gap-2 bg-background/80 py-3`,children:[(0,Z.jsx)(yc,{content:(0,Z.jsx)(BZ,{label:dZ(`shortcuts.startNewSession`),modifierLabel:r,keys:[SZ]}),side:`right`,children:(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,"aria-label":dZ(`sidebar.newSession`),className:`h-9 w-9`,onClick:y,disabled:s||f,children:(0,Z.jsx)(Ll,{className:`h-4 w-4`})})}),(0,Z.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":dZ(`sidebar.openAriaLabel`),"aria-expanded":d,className:`h-9 w-9`,onClick:T,children:(0,Z.jsx)(wX,{className:`h-4 w-4`})})]})})},vQ=({proposals:e,isApplying:t,onApply:n})=>e.status===`applied`?(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:dZ(`ticketProposal.createdTitle`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:dZ(`ticketProposal.createdDescription`,{count:e.created_tickets.length})}),e.created_tickets.length>0?(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1 text-foreground`,children:e.created_tickets.map(e=>(0,Z.jsx)(`li`,{children:e.title},e.ticket_id))}):null]}):(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:dZ(`ticketProposal.proposedTitle`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:dZ(`ticketProposal.proposedDescription`)}),(0,Z.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e.tickets.map(e=>(0,Z.jsxs)(`li`,{className:`rounded border border-border/60 bg-background/80 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-muted-foreground`,children:e.description})]},e.key))}),e.dependencies.length>0?(0,Z.jsx)(`div`,{className:`mt-3 text-muted-foreground`,children:dZ(`ticketProposal.dependenciesLabel`,{value:e.dependencies.map(e=>`${e.blocker_key} -> ${e.dependent_key}`).join(`, `)})}):null,(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(K,{type:`button`,size:`sm`,onClick:n,disabled:t,children:dZ(t?`ticketProposal.creating`:`ticketProposal.create`)})})]}),yQ=({activeProjectId:e,activeProject:t,activeProjectBranchState:n=null,activeTool:r,onRestoreSessionTarget:i,onReviewCapabilityChange:a,isExternallyResizing:o=!1,showChangesPanel:s=!0})=>{let c=IY(),[l,u]=(0,Y.useState)([]),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(()=>iQ({projectId:e,tool:r})),[x,C]=(0,Y.useState)({}),[w,T]=(0,Y.useState)({}),[E,D]=(0,Y.useState)({}),[O,k]=(0,Y.useState)([]),[A,j]=(0,Y.useState)([]),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(``),[I,L]=(0,Y.useState)([]),[R,z]=(0,Y.useState)(!1),[B,ee]=(0,Y.useState)(!1),[te,ne]=(0,Y.useState)(!1),[V,re]=(0,Y.useState)(!1),[H,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)(null),[se,ce]=(0,Y.useState)([]),[le,U]=(0,Y.useState)(()=>new Set),[ue,de]=(0,Y.useState)(!1),[fe,me]=(0,Y.useState)(()=>new Set),[he,ge]=(0,Y.useState)(!1),[W,_e]=(0,Y.useState)(!1),[ve,ye]=(0,Y.useState)(null),[xe,Se]=(0,Y.useState)([]),[Ce,we]=(0,Y.useState)(!1),[Te,Ee]=(0,Y.useState)(!1),[De,Oe]=(0,Y.useState)(0),[ke,Ae]=(0,Y.useState)(tZ),[je,Me]=(0,Y.useState)(()=>$Z(e).isOpen),[Ne,Pe]=(0,Y.useState)(()=>QZ(e).isOpen),[Fe,Ie]=(0,Y.useState)(!1),[Le,Re]=(0,Y.useState)(!1),[ze,Be]=(0,Y.useState)(()=>QZ(e).width),[Ve,He]=(0,Y.useState)(0),[Ue,We]=(0,Y.useState)(null),[Ge,Ke]=(0,Y.useState)(()=>new Set),qe=(0,Y.useRef)({model:``,variant:``,skills:[],showModelSelector:!1}),Je=(0,Y.useRef)(!1),Ye=(0,Y.useRef)(null),Xe=(0,Y.useRef)(0),Ze=(0,Y.useRef)(0),Qe=(0,Y.useRef)(null),$e=(0,Y.useRef)(null),et=(0,Y.useRef)(null),q=(0,Y.useRef)(null),J=(0,Y.useRef)(null),tt=(0,Y.useRef)(null),nt=(0,Y.useRef)(!1),rt=(0,Y.useRef)(!1),it=(0,Y.useRef)(0),at=(0,Y.useRef)(_Z),ot=(0,Y.useRef)(_Z),st=(0,Y.useRef)(!1),ct=(0,Y.useRef)(0),lt=(0,Y.useRef)({id:null,status:null}),ut=(0,Y.useRef)(new Map),dt=(0,Y.useRef)({}),ft=(0,Y.useRef)({}),pt=(0,Y.useRef)(new Set),mt=(0,Y.useRef)(!1),ht=e?qZ({projectId:e,tool:_?r:p?.tool??r,chatSessionId:_?null:d}):null,gt=ht?x[ht]??``:``,_t=_?r:p?.tool??r,vt=p?w[p.id]??[]:[],X=(p?E[p.id]??0:0)>0;(0,Y.useEffect)(()=>{Je.current=_},[_]),(0,Y.useEffect)(()=>{dt.current=x},[x]),(0,Y.useEffect)(()=>{ft.current=w},[w]),(0,Y.useEffect)(()=>{if(!ht||pt.current.has(ht))return;pt.current.add(ht);let e=XZ(ht);e&&C(t=>Object.prototype.hasOwnProperty.call(t,ht)?t:{...t,[ht]:e})},[ht]),(0,Y.useEffect)(()=>{!ht||!Object.prototype.hasOwnProperty.call(x,ht)||ZZ({storageKey:ht,value:x[ht]??``})},[ht,x]),(0,Y.useEffect)(()=>{Ye.current=d},[d]);let yt=(0,Y.useCallback)(()=>{Ze.current+=1},[]),bt=(0,Y.useCallback)(e=>{yt(),m(e)},[yt]);(0,Y.useEffect)(()=>{if(!mt.current){mt.current=!0;return}let t=QZ(e),n=$Z(e);Je.current=!1,st.current=!1,pt.current=new Set,f(null),bt(null),v(!1),C({}),T({}),D({}),oe(null),ce([]),U(new Set),de(!1),me(new Set),We(null),Se([]),Ee(!1),ee(!1),Ae(tZ()),Ke(new Set),ut.current=new Map,ot.current=t.width,Me(n.isOpen),Be(t.width),Pe(t.isOpen)},[e,bt]),(0,Y.useEffect)(()=>{Fe||(ot.current=ze,et.current&&(et.current.style.setProperty(`--chat-changes-panel-width`,`${ze}px`),et.current.setAttribute(`data-desktop-width`,String(ze))))},[ze,Fe]),(0,Y.useEffect)(()=>{if(!s||!Qe.current)return;let e=Qe.current.getBoundingClientRect().width;if(e<=0)return;let t=OZ(ze,e);t!==ze&&(ot.current=t,Be(t))},[ze,s]),(0,Y.useEffect)(()=>{tQ({projectId:e,isOpen:je})},[e,je]),(0,Y.useEffect)(()=>{s&&eQ({projectId:e,isOpen:Ne,width:ze})},[e,ze,Ne,s]),(0,Y.useEffect)(()=>{Ee(!1)},[d,_]);let xt=(0,Y.useCallback)(e=>{let t=uZ(e);u(e=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return oZ([...e,t]);let r=[...e];return r[n]=t,oZ(r)})},[]),St=(0,Y.useCallback)(t=>{let n=Array.from(new Set(t));if(n.length===0)return;let i=new Set(n),a=Ye.current,o=e?n.map(t=>qZ({projectId:e,tool:r,chatSessionId:t})):[];C(e=>{let t=o.filter(t=>Object.prototype.hasOwnProperty.call(e,t));if(t.length===0)return e;let n={...e};for(let e of t)delete n[e];return n}),T(e=>{let t={...e},r=!1;for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],r=!0);return r?t:e}),D(e=>{let t={...e},r=!1;for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],r=!0);return r?t:e});for(let e of o)ZZ({storageKey:e,value:``});u(e=>{let t=e.filter(e=>!i.has(e.id));if(a&&i.has(a)){let e=t[0]??null;f(e?.id??null),bt(null),v(e===null),Se([]),we(!1),Ee(!1)}return t}),Ke(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e}),We(e=>e?.sessionId&&i.has(e.sessionId)?null:e),oe(e=>e&&i.has(e)?null:e),ce(e=>e.filter(e=>!i.has(e))),U(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e}),me(e=>{let t=new Set(e),r=!1;for(let e of n)t.delete(e)&&(r=!0);return r?t:e})},[e,r,bt]),Ct=(0,Y.useCallback)(e=>{St([e])},[St]),wt=(0,Y.useCallback)((e,t)=>{e&&C(n=>n[e]===t?n:{...n,[e]:t})},[]),Tt=(0,Y.useCallback)(e=>{e&&(C(t=>t[e]===``?t:{...t,[e]:``}),ZZ({storageKey:e,value:``}))},[]),Et=(0,Y.useCallback)((e,t)=>{T(n=>{if(t.length===0){if(!Object.prototype.hasOwnProperty.call(n,e))return n;let t={...n};return delete t[e],t}return{...n,[e]:t}})},[]),Dt=(0,Y.useCallback)(e=>{T(t=>{if(!Object.prototype.hasOwnProperty.call(t,e))return t;let n={...t};return delete n[e],n}),D(t=>{if(!Object.prototype.hasOwnProperty.call(t,e))return t;let n={...t};return delete n[e],n})},[]),Ot=(0,Y.useCallback)((e,t)=>{D(n=>{let r=Math.max(0,(n[e]??0)+t);if(r===0){if(!Object.prototype.hasOwnProperty.call(n,e))return n;let t={...n};return delete t[e],t}return{...n,[e]:r}})},[]),kt=(0,Y.useCallback)(({fromStorageKey:e,toStorageKey:t})=>{if(!e||!t||e===t)return;let n=Object.prototype.hasOwnProperty.call(dt.current,e)?dt.current[e]??``:XZ(e);C(r=>{let i={...r,[t]:n};return delete i[e],i}),ZZ({storageKey:t,value:n}),ZZ({storageKey:e,value:``})},[]),At=(0,Y.useCallback)((e,t)=>{u(n=>{let r=n.findIndex(t=>t.id===e);if(r===-1)return n;let i=n[r];if(i.pending_memory_suggestion_count===t)return n;let a=[...n];return a[r]={...i,pending_memory_suggestion_count:t},a}),m(n=>!n||n.id!==e||n.pending_memory_suggestion_count===t?n:(Ze.current+=1,{...n,pending_memory_suggestion_count:t}))},[]),jt=(0,Y.useCallback)(async r=>{if(!e){u([]),f(null),bt(null),v(!1),ee(!1);return}z(!0);try{let i=await Yb(e,r);if(r?.aborted)return;let a=oZ(i.map(uZ)),o=a[0]??null,s=t?.active_target_kind===`bundle`||n?.status!==`loading`;u(a),f(e=>Je.current?null:e&&a.some(t=>t.id===e)?e:e?a[0]?.id??null:st.current?null:o?s?(st.current=!0,dQ({activeProject:t,activeProjectBranchState:n,session:o})?o.id:null):null:(st.current=!0,null)),a.length===0&&v(!0)}catch(e){S(e)||Q.error(e instanceof Error?e.message:dZ(`errors.loadSessions`))}finally{r?.aborted||(z(!1),ee(!0))}},[t,n,e,bt]),Mt=(0,Y.useCallback)(async(t,n)=>{if(!e){bt(null);return}ne(!0);let r=Xe.current+1;Xe.current=r;let i=Ze.current;try{let a=await Zb(e,t,n);if(n?.aborted)return;let o=Ze.current!==i,s=Xe.current===r,c=Ye.current===t&&!Je.current;if(!s||o||!c)return;bt(a),xt(a)}catch(e){S(e)||Q.error(e instanceof Error?e.message:dZ(`errors.loadSession`))}finally{n?.aborted||ne(!1)}},[e,bt,xt]),Nt=(0,Y.useCallback)(async(n,r)=>{if(!e||!t?.memory_enabled){Se([]),we(!1);return}we(!0);try{let t=await be(e,null,r,n);if(r?.aborted)return;Se(t.suggestions),At(n,t.suggestions.length)}catch(e){S(e)||Q.error(e instanceof Error?e.message:dZ(`errors.loadMemorySuggestions`))}finally{r?.aborted||we(!1)}},[t?.memory_enabled,e,At]),Pt=(0,Y.useCallback)(()=>{Se(e=>{let t=e.length>0?e.slice(0,-1):e;return d&&At(d,t.length),t}),Oe(e=>e+1),jt(),d&&Mt(d)},[d,Mt,jt,At]);(0,Y.useEffect)(()=>{let e=new AbortController;return jt(e.signal),()=>{e.abort()}},[jt]),(0,Y.useEffect)(()=>{if(Je.current||_||d||st.current||l.length===0||t?.active_target_kind!==`bundle`&&n?.status===`loading`)return;st.current=!0;let e=l[0]??null;e&&dQ({activeProject:t,activeProjectBranchState:n,session:e})&&f(e.id)},[t,n,d,_,l]),(0,Y.useEffect)(()=>{if(_t!==`opencode`){k([]),j([]),_e(!1);return}let t=new AbortController;return(async()=>{_e(!0);try{let[n,r]=await Promise.all([Sn(_t,t.signal),mw(_t,t.signal,e)]);k(n),j(r)}catch(e){S(e)||(k(e=>e),j(e=>e))}finally{t.signal.aborted||_e(!1)}})(),()=>{t.abort()}},[e,_t]),(0,Y.useEffect)(()=>{if(_||!d){bt(null);return}if(p?.id===d)return;bt(null);let e=new AbortController;return Mt(d,e.signal),()=>{e.abort()}},[p,d,_,Mt,bt]),(0,Y.useEffect)(()=>{if(!t?.memory_enabled||_||!d){Se([]),we(!1);return}let e=new AbortController;return Nt(d,e.signal),()=>{e.abort()}},[t?.memory_enabled,d,_,Nt,De]),(0,Y.useEffect)(()=>{!Te||Ce||xe.length>0||Ee(!1)},[Ce,Te,xe.length]),(0,Y.useEffect)(()=>{if(!d||p?.agent_status!==`running`)return;let e=new AbortController,t=window.setInterval(()=>{Promise.all([jt(e.signal),Mt(d,e.signal)])},fZ);return()=>{e.abort(),window.clearInterval(t)}},[p?.agent_status,d,Mt,jt]),(0,Y.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||(t.id===d&&bt(t),uQ(t)&&xt(t))},n=t=>{!t||t.project_id!==e||Ct(t.id)};return c.on(`chat-session:created`,t),c.on(`chat-session:updated`,t),c.on(`chat-session:deleted`,n),()=>{c.off(`chat-session:created`,t),c.off(`chat-session:updated`,t),c.off(`chat-session:deleted`,n)}},[e,d,Ct,bt,c,xt]),(0,Y.useEffect)(()=>{_&&b(iQ({projectId:e,tool:r}))},[e,r,_]),(0,Y.useEffect)(()=>{if(_t!==`opencode`){N(``),F(``),L([]);return}if(_){let n=aQ({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:_t,availableModels:O});N(n.model),F(n.variant),L([]);return}N(p?.model??t?.helper_model??``),F(p?.variant??t?.helper_variant??``),L(p?.skills??[])},[e,t?.helper_model,t?.helper_variant,p?.id,p?.model,p?.skills,p?.variant,O,_t,_]),(0,Y.useEffect)(()=>{let e=O.find(e=>e.id===M)??null;F(t=>e?e.variants.includes(t)?t:``:t)},[O,M]),(0,Y.useEffect)(()=>{if(_t!==`opencode`||!_||!M||P)return;let n=aQ({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:_t,availableModels:O});n.model===M&&n.variant&&F(n.variant)},[e,t?.helper_model,t?.helper_variant,_t,O,_,M,P]),(0,Y.useEffect)(()=>{if(!ae)return;let e=p?.id===ae?p:l.find(e=>e.id===ae)??null;(!e||e.agent_status!==`running`)&&oe(null)},[p,ae,l]),(0,Y.useEffect)(()=>{let e=lt.current,n=p?.id??null,r=p?.agent_status??null;e.id===n&&e.status===`running`&&r===`done`&&t?.memory_enabled&&n&&Oe(e=>e+1),lt.current={id:n,status:r}},[t?.memory_enabled,e,p?.agent_status,p?.id,p?.title]),(0,Y.useEffect)(()=>{d&&Ke(e=>{if(!e.has(d))return e;let t=new Set(e);return t.delete(d),t})},[d]),(0,Y.useEffect)(()=>{Ue&&Ue.sessionId!==d&&We(null)},[d,Ue]),(0,Y.useEffect)(()=>{let e=ut.current,t=new Map,n=[];for(let r of l){let i=e.get(r.id)??null,a=r.agent_status??null;i===`running`&&a===`done`&&r.id!==d&&n.push(r),t.set(r.id,a)}ut.current=t,Ke(e=>{let t=new Set(e),r=!1,i=new Set(l.map(e=>e.id));for(let e of t)i.has(e)||(t.delete(e),r=!0);for(let e of l){let i=e.agent_status??null,a=n.some(t=>t.id===e.id);if((e.id===d||i!==`done`)&&t.delete(e.id)){r=!0;continue}a&&!t.has(e.id)&&(t.add(e.id),r=!0)}return r?t:e})},[e,d,l]);let Ft=(0,Y.useMemo)(()=>new Map(O.map(e=>[e.id,e.label])),[O]),It=(0,Y.useMemo)(()=>lZ(l),[l]),Lt=(0,Y.useMemo)(()=>se.length===0?[]:se.flatMap(e=>{let t=l.find(t=>t.id===e)??(p?.id===e?p:null);return t?[t]:[]}),[p,se,l]),Rt=Lt.length===1?Lt[0]?.title??null:null;(0,Y.useEffect)(()=>{se.length>0&&Lt.length!==se.length&&ce(Lt.map(e=>e.id))},[se,Lt]),(0,Y.useEffect)(()=>{let e=new Set(l.filter(e=>!hQ(e)&&!le.has(e.id)).map(e=>e.id));me(t=>{let n=new Set(Array.from(t).filter(t=>e.has(t)));return n.size===t.size?t:n})},[le,l]),(0,Y.useEffect)(()=>{!ue||je||(de(!1),me(new Set))},[je,ue]);let zt=(0,Y.useMemo)(()=>p?VZ({modelLabel:AZ({availableModelsById:Ft,model:p.model}),tool:p.tool}):null,[p,Ft]),Bt=(0,Y.useMemo)(()=>p?(p.messages??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,attachments:e.attachments??[],ticket_proposals:e.ticket_proposals??null,created_at:e.created_at,displayTitle:e.role===`assistant`?zt??kZ(p.tool):HZ()})):[],[p,zt]),Vt=p?.id&&p.agent_status===`running`&&Ue?.sessionId===p.id?Ue.turnKey:null,Ht=_t===`opencode`&&O.length>0,Ut=_t===`opencode`&&!Ht&&W;(0,Y.useEffect)(()=>{qe.current={model:M,variant:P,skills:I,showModelSelector:Ht}},[M,I,P,Ht]);let Wt=(0,Y.useMemo)(()=>O.find(e=>e.id===M)??null,[O,M]),Gt=_?y:p?.mode??`build`,Kt=_?dZ(`composer.newChatTitle`):p?.title??dZ(`composer.chatTitle`),qt=_?r:p?.tool??r,Jt=(0,Y.useMemo)(()=>RZ(),[]),Yt=Ht?M||null:p?.model??null,Xt=qt===`opencode`,Zt=AZ({availableModelsById:Ft,model:Yt}),Qt=(0,Y.useMemo)(()=>{let e=p?.usage_snapshot_total_tokens??null;if(e===null)return null;let t=GZ({tool:qt,model:Yt,availableModels:O,fallbackContextWindow:p?.usage_snapshot_context_window??null});if(t===null)return null;let n=WZ({totalTokens:e,contextWindow:t});return n===null?null:`${UZ(e)} (${n}%)`},[p?.usage_snapshot_context_window,p?.usage_snapshot_total_tokens,O,Yt,qt]),$t=_?`draft:${e??`none`}:${r}`:p?.id,en=(0,Y.useCallback)(()=>{Je.current=!0,v(!0),b(iQ({projectId:e,tool:r})),g(null),f(null),bt(null),oe(null),de(!1),me(new Set),We(null)},[e,r,bt]),tn=(0,Y.useCallback)((e,t=null)=>{Je.current=!1,v(!1),g(null),f(e),bt(t)},[bt]),nn=(0,Y.useCallback)(async()=>{if(!(!p||!i)){g(p.id);try{await i(p)}catch(e){Q.error(e instanceof Error?e.message:dZ(`errors.restoreTarget`))}finally{g(e=>e===p.id?null:e)}}},[p,i]),rn=!!(p&&p.target_available!==!1&&!_&&!dQ({activeProject:t,activeProjectBranchState:n,session:p})),an=rn&&p?dZ(`review.mismatchReason`,{sessionTarget:pQ(p),currentTarget:mQ({activeProject:t,activeProjectBranchState:n})}):null,on=rn&&h===null,sn=(0,Y.useCallback)(async r=>{g(r.id);let a=r;if(e)try{let t=await Zb(e,r.id);a=t,xt(t)}catch(e){Q.error(e instanceof Error?e.message:dZ(`errors.loadSession`)),g(e=>e===r.id?null:e);return}if(a.target_available===!1){tn(a.id,a);return}if(!dQ({activeProject:t,activeProjectBranchState:n,session:a})&&i)try{if(!await i(a)){g(e=>e===a.id?null:e);return}}catch(e){Q.error(e instanceof Error?e.message:dZ(`errors.restoreTarget`)),g(e=>e===a.id?null:e);return}tn(a.id,a)},[t,n,e,i,tn,xt]),cn=(0,Y.useCallback)(()=>{He(e=>e+1)},[]),ln=(0,Y.useCallback)(async t=>{if(_){let n=qe.current;b(t),rQ({projectId:e,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,mode:t}),cn();return}if(!(!e||!p||p.mode===t||he)){ge(!0);try{let n=await Qb(e,p.id,{mode:t});rQ({projectId:e,tool:n.tool,model:n.model,variant:n.variant,mode:n.mode}),bt(n),xt(n),cn()}catch(e){Q.error(e instanceof Error?e.message:dZ(`errors.updateMode`))}finally{ge(!1)}}},[e,p,r,cn,_,he,bt,xt]),un=(0,Y.useCallback)(async({instruction:t,attachments:n,targetSession:r})=>{if(!e)return null;let i=qe.current;ct.current+=1;let a={sessionId:r.id,turnKey:`${r.id}:${ct.current}`};We(a);try{let a=await $b(e,r.id,{instruction:t,...n.length>0?{attachment_ids:n.map(e=>e.id)}:{},tool:r.tool,model:i.showModelSelector&&i.model||null,variant:i.showModelSelector&&i.model&&i.variant||null,skills:i.showModelSelector?i.skills:[]});return rQ({projectId:e,tool:a.tool,model:a.model,variant:a.variant,mode:a.mode}),Je.current=!1,bt(a),f(a.id),v(!1),xt(a),a}catch(e){throw We(e=>e?.turnKey===a.turnKey?null:e),e}},[e,bt,xt]),dn=(0,Y.useCallback)(async({fromStorageKey:t})=>{if(!e)return null;let n=qe.current,i=await Xb(e,{mode:Gt,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,skills:n.showModelSelector?n.skills:[]});Je.current=!1,v(!1),f(i.id),bt(i);let a=qZ({projectId:e,tool:i.tool,chatSessionId:i.id});return kt({fromStorageKey:t,toStorageKey:a}),{session:i,storageKey:a}},[e,r,Gt,kt,bt]),fn=(0,Y.useCallback)(async t=>{if(!e||H||V||X||p?.agent_status===`running`||p?.target_available===!1||on)return!1;let n=t.trim(),r=p?ft.current[p.id]??[]:[];if(!n&&r.length===0)return!1;ie(!0);let i=null,a=p,o=e&&p?qZ({projectId:e,tool:p.tool,chatSessionId:p.id}):null,s=r;try{let t=p;if(!t){re(!0);let e=await dn({fromStorageKey:ht});i=e?.session??null,t=i,o=e?.storageKey??null,s=i?ft.current[i.id]??[]:[]}if(!t)return!1;Tt(o??ht);let r=lQ({session:t,instruction:n,attachments:s,createdAt:new Date().toISOString()});bt(r),f(r.id),xt(r);let a=await un({instruction:n,attachments:s,targetSession:t});return Tt(a&&e?qZ({projectId:e,tool:a.tool,chatSessionId:a.id}):o),a&&Dt(a.id),!0}catch(e){throw wt(o??ht,n),i?(bt(i),f(i.id),v(!1),xt(i)):a&&(bt(a),xt(a)),e}finally{re(!1),ie(!1)}},[e,p,Dt,Tt,dn,ht,V,H,X,bt,un,wt,on,xt]),pn=(0,Y.useCallback)(e=>{Je.current=!0,v(!0),b(e),g(null),f(null),bt(null),oe(null),We(null)},[bt]),mn=(0,Y.useCallback)(async t=>{if(!e||t.length===0||_t!==`opencode`)return;let n=t.slice(0,EZ);if(n.length===0)return;let r=null,i=p;try{if(i||=(re(!0),r=await dn({fromStorageKey:ht}),r?.session??null),!i)return;if((ft.current[i.id]??[]).length+n.length>EZ){Q.error(`You can attach up to 4 images per turn.`);return}Ot(i.id,1);let t=await ex(e,i.id,n),a=ft.current[i.id]??[];Et(i.id,[...a,...t.attachments])}catch(t){if(r&&!gt.trim())try{await rx(e,r.session.id),Ct(r.session.id),pn(r.session.mode)}catch{}Q.error(t instanceof Error?t.message:dZ(`errors.uploadAttachments`))}finally{i&&Ot(i.id,-1),re(!1)}},[e,p,dn,gt,ht,Ot,pn,Ct,Et,_t]),hn=(0,Y.useCallback)(async t=>{if(!e||!p)return;let n=(ft.current[p.id]??[]).filter(e=>e.id!==t);try{await tx(e,p.id,t),Et(p.id,n),n.length===0&&!gt.trim()&&(p.messages?.length??0)===0&&(await rx(e,p.id),Ct(p.id),pn(p.mode))}catch(e){Q.error(e instanceof Error?e.message:dZ(`errors.removeAttachment`))}},[e,p,gt,pn,Ct,Et]),gn=(0,Y.useCallback)(e=>{if(_t!==`opencode`)return;let t=Array.from(e.clipboardData.items).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>e!==null);t.length!==0&&(e.preventDefault(),mn(t))},[_t,mn]),_n=(0,Y.useCallback)(async e=>{await fn(e)},[fn]),vn=!!(e&&(_||p&&p.target_available!==!1&&!on)),yn=p?.agent_status===`running`,bn=p?.agent_status===`stopped`,xn=yn&&ae===p?.id,Cn=vn&&!yn&&!H&&!V&&!X,wn=vn?p?.target_available===!1?p.target_unavailable_reason??dZ(`review.unavailableTarget`):on?an??dZ(`review.restoreTargetFallback`):yn?dZ(`review.waitTurn`):X?dZ(`review.waitUpload`):V||H?dZ(`review.waitPrompt`):null:dZ(`review.missingTarget`),Tn=(0,Y.useCallback)(async()=>{if(!(!e||!p||p.agent_status!==`running`||xn)){oe(p.id);try{await nx(e,p.id)}catch(e){oe(e=>e===p.id?null:e),Q.error(e instanceof Error?e.message:dZ(`errors.interruptResponse`))}}},[e,p,xn]),En=(0,Y.useCallback)(async()=>{if(!e||se.length===0||le.size>0)return;let t=Array.from(new Set(se)),n=ue||t.length>1;U(new Set(t));let r=await Promise.allSettled(t.map(async t=>(await rx(e,t),t))),i=[],a=[];for(let[e,n]of r.entries()){if(n.status===`fulfilled`){i.push(n.value);continue}a.push({sessionId:t[e]??``,message:n.reason instanceof Error?n.reason.message:null})}if(i.length>0&&St(i),U(new Set),a.length===0){ce([]),n&&(de(!1),me(new Set),Q.success(dZ(`toasts.deleteSelectedSuccess`,{count:i.length})));return}let o=a.map(e=>e.sessionId);if(ce(o),n&&me(new Set(o)),i.length>0){Q.error(dZ(`toasts.deleteSelectedPartial`,{count:i.length,deletedCount:i.length,failedCount:a.length}));return}Q.error(a[0]?.message??dZ(`errors.deleteSession`))},[e,se,le,ue,St]),Dn=(0,Y.useMemo)(()=>l.some(e=>!hQ(e)),[l]),On=(0,Y.useCallback)((e,t)=>{me(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),kn=(0,Y.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(HX,{value:Gt,planInactiveTooltip:(0,Z.jsx)(BZ,{label:dZ(`shortcuts.switchToPlan`),modifierLabel:Jt,keys:[xZ]}),buildInactiveTooltip:(0,Z.jsx)(BZ,{label:dZ(`shortcuts.switchToBuild`),modifierLabel:Jt,keys:[xZ]}),disabled:he,onChange:e=>{ln(e)}}),yn?(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:xn,onClick:()=>{Tn()},children:[xn?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Nc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:dZ(xn?`review.interrupting`:`review.interrupt`)})]}):null]}),[Jt,Gt,Tn,ln,xn,yn,he]),An=(0,Y.useMemo)(()=>Ht?(0,Z.jsx)(xP,{model:M,variant:P,skills:I,showModelSelector:!0,showSkillsSelector:!0,availableModels:O,availableSkills:A,selectedModel:Wt,onModelChange:e=>{let t=O.find(t=>t.id===e)??null;N(e),F(e=>t&&t.variants.includes(e)?e:``)},onVariantChange:F,onSkillsChange:L,modelSelectId:`project-chat-model-selector`,variantSelectId:`project-chat-variant-selector`,skillsSelectId:`project-chat-skills-selector`,disabled:H||V||p?.agent_status===`running`}):Ut?(0,Z.jsx)(bP,{dataTestId:`chat-model-selector-skeleton`}):null,[p?.agent_status,O,A,V,H,Wt,M,I,P,Ht,Ut]);(0,Y.useEffect)(()=>{if(a)return()=>{a(null)}},[a]),(0,Y.useEffect)(()=>{if(a){if(!e||!vn){a(null);return}a({chatSessionId:p?.id??null,canSubmitReviewPrompt:Cn,reviewSubmitDisabledReason:wn,mode:Gt,onModeChange:ln,isUpdatingMode:he,promptPlaceholder:MZ(Gt),promptComposerControls:kn,promptComposerInlineControls:An,submitPrompt:_n})}},[e,p,Cn,Gt,ln,_n,vn,he,a,kn,An,wn]);let jn=async()=>{if(!(!gt.trim()&&vt.length===0||X))try{if(!await fn(gt))return}catch(e){Q.error(e instanceof Error?e.message:dZ(`errors.sendPrompt`))}},Mn=e=>{e.key!==`Enter`||e.shiftKey||p?.agent_status===`running`||V||H||X||(e.preventDefault(),jn())};(0,Y.useEffect)(()=>{let t=t=>{if(IZ(t)){if(!e||V||H)return;t.preventDefault(),en(),cn();return}FZ(t)&&(!e||!_&&!p||(t.preventDefault(),ln(PZ(Gt))))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,p,Gt,cn,en,ln,V,_,H]);let Nn=(0,Y.useCallback)(async t=>{if(!(!e||!p)){ye(t);try{let n=await ox(e,p.id,t);bt(n.chatSession),xt(n.chatSession),Q.success(dZ(`ticketProposal.createdFromChat`,{count:n.created_tickets.length}))}catch(e){Q.error(e instanceof Error?e.message:dZ(`errors.createTickets`))}finally{ye(e=>e===t?null:e)}}},[e,p,bt,xt]),Pn=(0,Y.useCallback)(e=>{if(!Qe.current)return;let t=Qe.current.getBoundingClientRect().width,n=OZ(e,t);ot.current=n,et.current&&(et.current.style.setProperty(`--chat-changes-panel-width`,`${n}px`),et.current.setAttribute(`data-desktop-width`,String(n)))},[]),Fn=(0,Y.useCallback)(()=>{tt.current?.(),tt.current=null},[]),In=(0,Y.useCallback)(e=>{let t=q.current,n=J.current,r=nt.current;if(t!==null){if(q.current=null,J.current=null,nt.current=!1,Ie(!1),Re(!1),Fn(),e!==null&&typeof $e.current?.hasPointerCapture==`function`&&$e.current.hasPointerCapture(e)&&typeof $e.current.releasePointerCapture==`function`&&$e.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;Be(ot.current),Pe(!0);return}Be(ot.current)}},[Fn]),Ln=(0,Y.useCallback)((e,t)=>{if(q.current!==e)return;let n=t-it.current,r=at.current-n;if(J.current===`collapsed`){if(!nt.current&&r<bZ)return;nt.current||(nt.current=!0,rt.current=!0,Re(!0),Ie(!0))}Pn(r)},[Pn]),Rn=(0,Y.useCallback)((e,t)=>{if(q.current===e){if(t!==null&&(J.current===`inline`||nt.current)){let e=t-it.current;Pn(at.current-e)}In(e)}},[In,Pn]),zn=(0,Y.useCallback)(e=>{if(!s)return;e.preventDefault(),q.current=e.pointerId,J.current=Ne?`inline`:`collapsed`,nt.current=!1,rt.current=!1,it.current=e.clientX,at.current=Ne?ot.current:0,Ie(Ne),Fn(),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=e=>{Ln(e.pointerId,e.clientX)},n=e=>{Rn(e.pointerId,e.clientX)},r=e=>{Rn(e.pointerId,e.clientX)};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),tt.current=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r)}},[Rn,Ln,Ne,s,Fn]),Bn=(0,Y.useCallback)(e=>{Ln(e.pointerId,e.clientX)},[Ln]),Vn=(0,Y.useCallback)(e=>{Rn(e.pointerId,e.clientX)},[Rn]),Hn=(0,Y.useCallback)(e=>{Rn(e.pointerId,e.clientX)},[Rn]),Un=(0,Y.useCallback)(e=>{q.current===e.pointerId&&In(e.pointerId)},[In]),Wn=(0,Y.useCallback)(()=>{if(rt.current){rt.current=!1;return}Pe(!0)},[]),Gn=(0,Y.useCallback)(()=>{Pe(!1)},[]),Kn=(0,Y.useCallback)(e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),Wn())},[Wn]);(0,Y.useEffect)(()=>{s||(q.current=null,J.current=null,nt.current=!1,rt.current=!1,Ie(!1),Re(!1),Fn())},[s,Fn]),(0,Y.useEffect)(()=>()=>{Fn()},[Fn]);let qn=!!d,Jn=p?.target_available===!1,Yn=Jn?p?.target_unavailable_reason??dZ(`review.unavailableTarget`):null,Xn=_||!!(p&&p.target_available!==!1&&!on),Zn=!!(t?.memory_enabled&&p&&(xe.length>0||Ce)),Qn=s&&(_||qn)&&!Jn&&!on,$n=Qn&&!Ne&&!Le,er=Qn&&(Ne||Le),tr=`${$t??`none`}:${Qn?`changes-enabled`:`changes-disabled`}:${er?`panel-visible`:`panel-hidden`}`,nr=p||_?(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(VX,{projectId:e,messages:p?Bt:[],internalLog:p?.agent_log??null,currentThinkingMessageId:p?.agent_message_id??null,previousThinkingLog:p?.previous_agent_log??null,previousThinkingMessageId:p?.previous_agent_message_id??null,pendingAgentTitle:zt,streamingResponse:p?.streaming_response??null,isRunning:p?.agent_status===`running`,isLoading:!_&&te,canShowComposer:Xn,cardClassName:`border-t-0`,isExternallyResizing:o||Fe,pendingAgentRevealKey:Vt,pendingAgentRevealDelayMs:TZ,composerFocusNonce:Ve,header:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,children:Kt}),(0,Z.jsxs)(`div`,{className:DZ,children:[_?null:(0,Z.jsx)(TT,{tool:p?.tool,className:`text-[11px]`}),Zt?(0,Z.jsx)(`p`,{children:Zt}):null,bn?(0,Z.jsx)(`div`,{className:`inline-flex items-center rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100`,children:dZ(`sidebar.interrupted`)}):null,Qt?(0,Z.jsx)(`div`,{"data-testid":`chat-context-usage-badge`,className:`inline-flex items-center rounded-full border border-border/80 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-foreground`,children:Qt}):null]})]}),Zn?(0,Z.jsx)(K,{type:`button`,size:`xs`,variant:`outline`,className:`gap-2`,onClick:()=>Ee(!0),children:Ce?dZ(`composer.loadingMemory`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:dZ(`composer.memorySuggestions`)}),(0,Z.jsx)(WX,{children:xe.length})]})}):null]}),on&&an?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{children:an}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{nn()},children:dZ(`composer.switchBack`)}),(0,Z.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:en,children:dZ(`composer.startNewSession`)})]})]})}):null,Jn&&Yn?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:Yn}):null]}),composerControls:kn,composerInlineControls:An,composerTheme:Gt,layoutKey:$t,scrollLayoutKey:tr,followUpPrompt:gt,draftAttachments:vt,followUpPlaceholder:MZ(Gt),emptyStateText:null,renderMessageFooter:e=>e.ticket_proposals?(0,Z.jsx)(vQ,{proposals:e.ticket_proposals,isApplying:ve===e.id,onApply:()=>{Nn(e.id)}}):null,isSendingFollowUp:H||V,isUploadingAttachments:X,canAttachImages:Xt,followUpDisabledReason:Jn?Yn??void 0:p?.agent_status===`running`?dZ(`review.waitTurnShort`):X?dZ(`review.waitUpload`):void 0,onFollowUpPromptChange:e=>{wt(ht,e)},onFollowUpKeyDown:Mn,onFollowUpPaste:gn,onUploadAttachments:e=>{mn(e)},onRemoveAttachment:e=>{hn(e)},onFollowUpSubmit:()=>{jn()}})}):qn?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:dZ(`composer.loadingSession`)}):!B||R?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:dZ(`sidebar.loadingSessions`)}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6`,children:(0,Z.jsxs)(mu,{className:`w-full max-w-lg border-dashed border-border/70 bg-card/40`,children:[(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{children:dZ(`composer.noSessionSelectedTitle`)}),(0,Z.jsx)(_u,{children:dZ(`composer.noSessionSelectedDescription`)})]}),(0,Z.jsx)(yu,{children:(0,Z.jsx)(K,{type:`button`,onClick:en,disabled:!e||V||H,children:dZ(`composer.startNewSession`)})})]})}),rr=Qn?(0,Z.jsx)(`div`,{ref:$e,"aria-label":dZ($n?`composer.openDiff`:`composer.resizeDiffPanel`),"aria-orientation":$n?void 0:`vertical`,className:G($n?`group flex h-8 w-full shrink-0 touch-none select-none items-center justify-center border-t border-border/70 bg-background/90 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground xl:h-auto xl:w-7 xl:cursor-col-resize xl:border-l xl:border-t-0`:`group hidden w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 transition-colors xl:flex`,Fe&&!$n&&`bg-background`),"data-testid":$n?`collapsed-changes-rail`:void 0,onLostPointerCapture:Un,onPointerCancel:Hn,onPointerDown:zn,onPointerMove:Bn,onPointerUp:Vn,onClick:$n?Wn:void 0,onKeyDown:$n?Kn:void 0,role:$n?`button`:`separator`,tabIndex:$n?0:void 0,children:$n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`hidden h-full w-full items-center justify-center xl:flex`,children:(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(kc,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]})}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium xl:hidden`,children:[(0,Z.jsx)(kc,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:dZ(`composer.diff`)})]})]}):(0,Z.jsx)(`div`,{className:G(`h-14 w-1.5 rounded-full transition-colors`,Fe?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`)})}):null,ir=Te&&e&&t?.memory_enabled?(0,Z.jsx)(du,{onClose:()=>Ee(!1),overlayClassName:`bg-background/45 p-4 backdrop-blur-sm`,panelClassName:`w-full max-w-3xl`,renderContent:({closeButton:t})=>(0,Z.jsxs)(mu,{size:`sm`,className:`max-h-[calc(100vh-2rem)] w-full gap-0 overflow-hidden border-border/80 bg-card/95 shadow-2xl`,children:[(0,Z.jsxs)(hu,{className:`border-b border-border/80 pb-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(gu,{children:dZ(`composer.memorySuggestionsTitle`)}),(0,Z.jsx)(_u,{children:dZ(`composer.memorySuggestionsDescription`)})]}),(0,Z.jsx)(vu,{children:t})]}),(0,Z.jsx)(yu,{className:`min-h-0 flex-1 overflow-y-auto pt-4`,children:(0,Z.jsx)(eZ,{projectId:e,suggestions:xe,emptyState:dZ(`composer.memorySuggestionsEmpty`),onSuggestionsChanged:Pt})})]}),closeButtonLabel:dZ(`composer.closeMemorySuggestions`)}):null,ar=Lt.length>0?(0,Z.jsx)(gQ,{count:Lt.length,title:Rt,isDeleting:le.size>0,onConfirm:()=>{En()},onCancel:()=>{le.size>0||ce([])}}):null;return(0,Z.jsxs)(`div`,{"data-testid":`chat-view-shell`,className:`relative flex min-h-0 flex-1 overflow-hidden border-t border-border/70`,children:[(0,Z.jsx)(_Q,{activeProject:t,activeProjectBranchState:n,activeSessionId:d,chatModeShortcutModifierLabel:Jt,deletingSessionIds:le,finishedBackgroundSessionIds:Ge,hasDeletableSessions:Dn,isCreatingSession:V||!e,isSelectionMode:ue,isDraftOpen:_,isLoadingSessions:R,isOpen:je,isSendingPrompt:H,selectedSessionCount:fe.size,selectedSessionIds:fe,sessionGroups:It,sessions:l,onConfirmDeleteSelectedSessions:()=>{ce(Array.from(fe))},onConfirmDeleteSession:e=>{ce([e])},onDraftOpen:en,onEnterSelectionMode:()=>{de(!0),me(new Set)},onExitSelectionMode:()=>{de(!1),me(new Set)},onSetSessionSelection:On,onSessionSelect:e=>{sn(e)},onToggleSessionSelection:e=>{me(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},onToggleOpen:()=>{Me(e=>!e)}}),(0,Z.jsxs)(`div`,{ref:Qe,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden xl:flex-row`,children:[(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:nr}),Qn?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yc,{content:dZ(`composer.openDiff`),disabled:!$n,side:`left`,children:rr}),er?(0,Z.jsx)(BX,{projectId:e,chatSessionId:_?null:d,canSubmitReviewPrompt:Cn,reviewSubmitDisabledReason:wn,onSubmitReviewPrompt:_n,state:ke,onStateChange:Ae,isResizing:Fe,onClose:Gn,desktopWidth:ze,panelElementRef:et}):null]}):null]}),ir,ar]})},bQ=({className:e})=>(0,Z.jsx)(yo,{"aria-hidden":`true`,className:e}),xQ=({activeProject:e})=>e?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/60 pb-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Memory archive`}),(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name})]})}),(0,Z.jsx)(dp,{mode:`edit`,projectId:e.id,memoryEnabled:e.memory_enabled,persistedMemoryEnabled:e.memory_enabled,onMemoryEnabledChange:()=>{},showActivationControls:!1,archiveLayout:!0})]})}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Select a project to view memory.`}),SQ=()=>({hasRunning:!1,hasFinishedUnseen:!1,hasErrorUnseen:!1}),CQ=()=>({board:SQ(),memory:SQ(),chat:SQ()}),wQ=(e,t)=>{let n=e[t];return!n.hasFinishedUnseen&&!n.hasErrorUnseen?e:{...e,[t]:{...n,hasFinishedUnseen:!1,hasErrorUnseen:!1}}},TQ=e=>({hasRunning:e.board.hasRunning||e.chat.hasRunning,hasFinishedUnseen:e.board.hasFinishedUnseen||e.chat.hasFinishedUnseen,hasErrorUnseen:e.board.hasErrorUnseen||e.chat.hasErrorUnseen}),EQ=e=>e.hasErrorUnseen?`error`:e.hasRunning?`running`:e.hasFinishedUnseen?`finished`:null,DQ=(e,t)=>t?null:EQ(e),OQ=320,kQ=.7,AQ=28,jQ=6,MQ=(e,t)=>{let n=Math.max(OQ,Math.round(t*kQ));return Math.max(OQ,Math.min(n,Math.round(e)))},NQ=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return[...e,t];let r=e.slice();return r[n]=t,r},PQ=(e,t)=>{if(t.type===`reset`)return CQ();if(t.type===`mark-workspace-visible`)return wQ(e,t.workspace);let n=e[t.workspace],r={...n,hasRunning:t.activity.hasRunning,hasFinishedUnseen:t.visibleWorkspace===t.workspace?!1:n.hasFinishedUnseen||t.activity.didFinish,hasErrorUnseen:t.visibleWorkspace===t.workspace?!1:n.hasErrorUnseen||t.activity.didError};return n.hasRunning===r.hasRunning&&n.hasFinishedUnseen===r.hasFinishedUnseen&&n.hasErrorUnseen===r.hasErrorUnseen?e:{...e,[t.workspace]:r}},FQ=({activeProjectId:e,onActivity:t})=>{let{tickets:n}=WY(),r=(0,Y.useRef)(new Map);return(0,Y.useEffect)(()=>{r.current=new Map},[e]),(0,Y.useEffect)(()=>{let e=r.current,i=new Map,a=!1,o=!1;for(let t of n){let n=e.get(t.id)??null,r=t.agent_status??null;n===`running`&&r===`done`&&(a=!0),n===`running`&&r===`error`&&(o=!0),i.set(t.id,r)}r.current=i,t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:a,didError:o})},[t,n]),null},IQ=({activeProjectId:e,onActivity:t})=>{let n=IY(),[r,i]=(0,Y.useState)([]),a=(0,Y.useRef)(new Map);return(0,Y.useEffect)(()=>{if(!e)return;let t=new AbortController;return(async()=>{try{let n=await Yb(e,t.signal);if(t.signal.aborted)return;i(n)}catch(e){S(e)}})(),()=>{t.abort()}},[e,n]),(0,Y.useEffect)(()=>{if(!e)return;let t=new AbortController,n=rq(()=>{document.visibilityState===`visible`&&Yb(e,t.signal).then(e=>{t.signal.aborted||i(e)}).catch(e=>{S(e)})});return()=>{t.abort(),n()}},[e,n]),(0,Y.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||i(e=>NQ(e,t))},r=t=>{!t||t.project_id!==e||i(e=>e.filter(e=>e.id!==t.id))};return n.on(`chat-session:created`,t),n.on(`chat-session:updated`,t),n.on(`chat-session:deleted`,r),()=>{n.off(`chat-session:created`,t),n.off(`chat-session:updated`,t),n.off(`chat-session:deleted`,r)}},[e,n]),(0,Y.useEffect)(()=>{let n=a.current,i=new Map,o=[],s=!1;for(let e of r){let t=n.get(e.id)??null,r=e.agent_status??null;t===`running`&&r===`done`&&o.push(e),t===`running`&&r===`error`&&(s=!0),i.set(e.id,r)}a.current=i;for(let e of o)e.title&&PY(`Chat response ready`,e.title);o.length>0&&e&&eq(e),t({hasRunning:r.some(e=>e.agent_status===`running`),didFinish:o.length>0,didError:s})},[e,t,r]),null},LQ=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onRestoreChatSessionTarget:a,onChatReviewCapabilityChange:o,onPreviewReviewCapabilityChange:s,previewDisplayMode:c=`hidden`,previewPane:l=null,previewPaneWidth:u=480,isPreviewButtonDisabled:d=!1,previewButtonTitle:f,visibleWorkspace:p,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,onBoardLoadedProjectIdChange:_,onPreviewToggle:v,onPreviewPaneWidthChange:y,onRunStopped:b,onRunStatusChange:x,onWorkspaceActivityChange:S,onWorkspaceActivityEvent:C,refreshKey:w=0})=>{let T=(0,Y.useRef)(null),E=(0,Y.useRef)(null),D=(0,Y.useRef)(null),O=(0,Y.useRef)(null),k=(0,Y.useRef)(!1),A=(0,Y.useRef)(!1),j=(0,Y.useRef)(0),M=(0,Y.useRef)(u),N=(0,Y.useRef)(u),P=p===`board`||p===`chat`,F=l!==null,[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,ee]=(0,Y.useState)(u),[te,ne]=(0,Y.useReducer)(PQ,void 0,CQ),V=P&&F&&c===`expanded`,re=P&&F&&c===`inline`,H=P&&F&&c===`hidden`&&!R,ie=(re||R)&&!V,ae=V||ie,oe=P&&F&&!V,se=I?B:u,ce=p!==`chat`||!ie,le=e=>{let t=D.current,n=O.current,r=k.current;if(t!==null){if(D.current=null,O.current=null,k.current=!1,L(!1),z(!1),e!==null&&E.current?.hasPointerCapture(e)&&E.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;y?.(N.current),v?.();return}y?.(N.current)}},U=e=>{if(!T.current)return;let t=T.current.getBoundingClientRect().width,n=MQ(e,t);N.current=n,ee(n)},ue=e=>{y&&(H&&d||(e.preventDefault(),D.current=e.pointerId,O.current=H?`collapsed`:`inline`,k.current=!1,A.current=!1,j.current=e.clientX,M.current=H?0:N.current,L(!H),e.currentTarget.setPointerCapture(e.pointerId)))},de=e=>{if(D.current!==e.pointerId)return;let t=e.clientX-j.current,n=M.current-t;if(O.current===`collapsed`){if(!k.current&&n<jQ)return;k.current||(k.current=!0,A.current=!0,z(!0),L(!0))}U(n)},fe=e=>{if(D.current===e.pointerId){if(O.current===`inline`||k.current){let t=e.clientX-j.current;U(M.current-t)}le(e.pointerId)}},pe=e=>{D.current===e.pointerId&&le(e.pointerId)},me=(0,Y.useCallback)((e,t)=>{C?.(e,t),ne({type:`update-workspace`,workspace:e,activity:t,visibleWorkspace:p})},[C,p]);(0,Y.useEffect)(()=>{ne({type:`reset`})},[e]),(0,Y.useEffect)(()=>{p!==`memory`&&ne({type:`mark-workspace-visible`,workspace:p})},[p]),(0,Y.useEffect)(()=>{S?.(te)},[S,te]),(0,Y.useEffect)(()=>{I||(N.current=u),!F&&(D.current=null,O.current=null,k.current=!1,A.current=!1,N.current=u)},[F,I,u]);let he=()=>{if(A.current){A.current=!1;return}d||v?.()};return(0,Z.jsx)(UY,{activeProjectId:e,refreshKey:w,onLoadedProjectIdChange:_,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,children:(0,Z.jsxs)(`div`,{ref:T,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(FQ,{activeProjectId:e,onActivity:e=>{me(`board`,e)}}),(0,Z.jsx)(IQ,{activeProjectId:e,onActivity:e=>{me(`chat`,e)}}),p===`memory`?(0,Z.jsx)(`div`,{id:`project-workspace-panel-memory`,role:`tabpanel`,"aria-labelledby":`project-workspace-tab-memory`,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(xQ,{activeProject:t})}):(0,Z.jsxs)(`div`,{id:p===`chat`?`project-workspace-panel-chat`:`project-workspace-panel-board`,role:`tabpanel`,"aria-labelledby":p===`chat`?`project-workspace-tab-chat`:`project-workspace-tab-board`,className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:p===`chat`?(0,Z.jsx)(yQ,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeTool:i,isExternallyResizing:I,onRestoreSessionTarget:a,onReviewCapabilityChange:o,showChangesPanel:ce}):(0,Z.jsx)(xX,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:s,onRunStopped:b,onRunStatusChange:x,refreshKey:w})}),[oe?(0,Z.jsx)(yc,{content:d?f??`Preview unavailable`:`Open preview`,disabled:!H,side:`left`,children:(0,Z.jsx)(`div`,{"aria-label":H?f??`Show preview`:`Resize preview pane`,"aria-orientation":H?void 0:`vertical`,className:H?`group flex shrink-0 touch-none select-none items-center justify-center border-l border-border/70 bg-background/90 transition-colors ${d?`cursor-not-allowed text-muted-foreground/60`:`cursor-col-resize text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`:`group flex w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 ${I?`bg-background`:``}`,"data-preview-divider":`true`,"data-testid":H?`collapsed-preview-rail`:void 0,onLostPointerCapture:pe,onPointerCancel:fe,onPointerDown:ue,onPointerMove:de,onPointerUp:fe,onClick:H?he:void 0,onKeyDown:H?e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),he())}:void 0,ref:E,role:H?`button`:`separator`,style:H?{width:`${AQ}px`}:void 0,tabIndex:H?d?-1:0:void 0,children:H?(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(bQ,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]}):(0,Z.jsx)(`div`,{className:`h-14 w-1.5 rounded-full transition-colors ${I?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`}`})})},`preview-divider`):null,ae?(0,Z.jsx)(`div`,{className:V?`fixed inset-0 z-50 bg-black/70 p-4 sm:p-6`:`min-h-0 shrink-0 border-l border-border/70 bg-[#11131a]`,style:V?void 0:{width:`${se}px`},children:(0,Z.jsx)(`div`,{className:`h-full w-full`,children:l})},`preview-container`):null]]})]})})},RQ=({isExpanded:e,isVisible:t,project:n,onClose:r,onToggleExpanded:i})=>(0,Z.jsx)(`div`,{className:[`fixed inset-x-4 bottom-24 z-40`,e?`top-20`:`h-[min(28rem,calc(100vh-8rem))]`,t?`block`:`hidden`].join(` `),children:(0,Z.jsx)(WW,{createSession:()=>xT(n.id),isExpanded:e,isVisible:t,ariaLabel:`Project terminal for ${n.name}`,title:n.name,closeLabel:`Close terminal`,className:e?`h-full w-full rounded-2xl shadow-2xl`:`mx-auto h-full max-w-6xl shadow-2xl`,onClose:r,onToggleExpanded:i})}),zQ=({activeWorkspace:e,activityByWorkspace:t,memoryEnabled:n=!1,onWorkspaceChange:r})=>(0,Z.jsx)(`div`,{role:`tablist`,"aria-label":`Project workspace`,className:`inline-flex items-end gap-1 border-b border-border/70`,children:(n?[`board`,`chat`,`memory`]:[`board`,`chat`]).map(n=>{let i=e===n,a=DQ(t[n],i),o=n===`board`?`border-sky-300/70 bg-sky-500/8 text-sky-200`:n===`memory`?`border-amber-300/70 bg-amber-500/8 text-amber-200`:`border-emerald-300/70 bg-emerald-500/8 text-emerald-200`;return(0,Z.jsx)(`button`,{id:`project-workspace-tab-${n}`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`project-workspace-panel-${n}`,tabIndex:i?0:-1,className:G(`cursor-pointer rounded-t-lg border-b-2 px-4 py-2.5 text-[15px] font-medium transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,i?o:`border-transparent text-muted-foreground hover:border-border hover:bg-background/35 hover:text-foreground`),onClick:()=>r(n),children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:n===`board`?`Board`:n===`memory`?`Memory`:`Chat`}),(0,Z.jsx)(Il,{state:a,className:`mt-0`})]})},n)})}),BQ=32,VQ=5.5,HQ=2,UQ=24,WQ=8,GQ=new Map,KQ={running:{fill:`#fcd34d`,stroke:`#f59e0b`},finished:{fill:`#34d399`,stroke:`#059669`},error:{fill:`#fb7185`,stroke:`#e11d48`}},qQ=e=>e.replaceAll(`&`,`&`).replaceAll(`"`,`"`).replaceAll(`<`,`<`).replaceAll(`>`,`>`),JQ=e=>{if(!e)return null;let t=e.trim().match(/^([0-9]+(?:\.[0-9]+)?)/);return t?Number(t[1]):null},YQ=e=>{let t=new DOMParser().parseFromString(e,`image/svg+xml`);if(t.querySelector(`parsererror`))return null;let n=t.documentElement;if(n.nodeName.toLowerCase()!==`svg`)return null;let r=n.getAttribute(`viewBox`)?.trim(),i=JQ(n.getAttribute(`width`)),a=JQ(n.getAttribute(`height`)),o=r??(i&&a?`0 0 ${i} ${a}`:`0 0 ${BQ} ${BQ}`);return`<svg ${[Array.from(n.attributes).filter(e=>![`width`,`height`,`viewBox`,`x`,`y`,`preserveAspectRatio`].includes(e.name)).map(e=>`${e.name}="${qQ(e.value)}"`).join(` `),`x="0"`,`y="0"`,`width="${BQ}"`,`height="${BQ}"`,`viewBox="${qQ(o)}"`,`preserveAspectRatio="xMidYMid meet"`].filter(e=>e.length>0).join(` `)}>${n.innerHTML}</svg>`},XQ=async e=>{if(!e)return null;let t=GQ.get(e);if(t)return t;let n=(async()=>{try{if(e.startsWith(`data:image/svg+xml,`))return YQ(decodeURIComponent(e.slice(19)));if(e.startsWith(`data:image/svg+xml;base64,`))return YQ(atob(e.slice(26)));let t=await fetch(e);return t.ok?YQ(await t.text()):null}catch{return null}})();return GQ.set(e,n),n},ZQ=async(e,t)=>{let{fill:n,stroke:r}=KQ[e],i=await XQ(t);return i?[`<svg xmlns="http://www.w3.org/2000/svg" width="${BQ}" height="${BQ}" viewBox="0 0 ${BQ} ${BQ}">`,i,`<circle cx="${UQ}" cy="${WQ}" r="${VQ}" fill="${n}" stroke="${r}" stroke-width="${HQ}"/>`,`</svg>`].join(``):null},QQ=async(e,t)=>{if(!e)return t;let n=await ZQ(e,t);return n?`data:image/svg+xml,${encodeURIComponent(n)}`:t},$Q=()=>{let e=document.querySelector(`link[rel="icon"]`);if(e)return e;let t=document.createElement(`link`);return t.rel=`icon`,document.head.appendChild(t),t},e$=({defaultHref:e,state:t})=>{let n=$Q(),r=Number(n.dataset.browserTabActivityRequestId??`0`)+1;if(n.dataset.browserTabActivityState=t??`default`,n.dataset.browserTabActivityRequestId=String(r),!t){if(e){n.href=e;return}n.removeAttribute(`href`);return}QQ(t,e).then(e=>{if(n.dataset.browserTabActivityRequestId===String(r)){if(e){n.href=e;return}n.removeAttribute(`href`)}})},t$=(e,t)=>Ne.t(`common:projectFooter.${e}`,t),n$=1e3,r$=`archon.active-project-id`,i$=`archon.workspace-by-project`,a$=`archon.preview-mode-by-project`,o$=`archon.dismissed-preview-run-context-by-project`,s$=5e3,c$=`archon.preview-pane-width`,l$=`archon.preview-viewport-preset`,u$=`archon.preview-zoom`,d$=480,f$=`responsive`,p$=1,m$={hasMounted:!1,isOpen:!1,isExpanded:!1},h$=`hidden`,g$=(0,Y.lazy)(()=>$W(()=>Promise.resolve().then(()=>uJ).then(e=>({default:e.TicketChangesModal})),void 0)),_$=(0,Y.lazy)(()=>$W(()=>import(`./TestsDialog-uqH8RzXV.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),v$=e=>{if(!e)return null;try{return JSON.parse(e)}catch{return null}},y$=e=>{let t=v$(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0):[]},b$=e=>{let t=v$(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.name==`string`?t.name:``,r=typeof t.cmd==`string`?t.cmd:``,i=typeof t.cwd==`string`?t.cwd:``;return n.trim()===``&&r.trim()===``&&i.trim()===``?[]:[{name:n,cmd:r,cwd:i}]}):[]},x$=e=>{let t=v$(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.source==`string`?t.source:``,r=typeof t.target==`string`?t.target:``,i=t.mode===`copy`||t.mode===`symlink`?t.mode:`copy`;return n.trim()===``&&r.trim()===``?[]:[{source:n,target:r,mode:i}]}):[]},S$=e=>({name:e.name,repoPath:e.repo_path,linkedProjectIds:e.linked_project_ids,runSetup:y$(e.run_setup),runServices:b$(e.run_services),testCommands:vY(e.test_commands),runIde:e.run_ide??``,previewServiceName:e.preview_service_name??``,previewPath:e.preview_path??``,previewCapabilityMode:e.preview_capability_mode??`auto`,helperModel:e.helper_model??``,helperVariant:e.helper_variant??``,commitMessageRules:e.commit_message_rules??``,autoParkStaleTickets:e.auto_park_stale_tickets,memoryEnabled:e.memory_enabled,worktreeSync:x$(e.worktree_sync)}),C$=e=>{let t=e.testCommands??[],n=e.previewServiceName?.trim()||null,r=e.previewPath?.trim()||``,i=r===``||r===`/`?null:r,a=n||i||e.previewCapabilityMode===`force_web`||e.previewCapabilityMode===`force_disabled`?e.previewCapabilityMode??`auto`:null;return{name:e.name,repo_path:e.repoPath,linked_project_ids:e.linkedProjectIds,run_setup:e.runSetup.length>0?e.runSetup:null,run_services:e.runServices.length>0?e.runServices.map(e=>({...e.name?{name:e.name}:{},cmd:e.cmd,...e.cwd?{cwd:e.cwd}:{}})):null,...t.length>0?{test_commands:t.map(e=>({id:e.id,name:e.name,command:e.command,runner:e.runner,...e.cwd?{cwd:e.cwd}:{}}))}:{},run_ide:e.runIde||null,preview_service_name:n,preview_path:i,preview_capability_mode:a,helper_model:e.helperModel||null,helper_variant:e.helperModel&&e.helperVariant||null,commit_message_rules:e.commitMessageRules||null,auto_park_stale_tickets:e.autoParkStaleTickets,memory_enabled:e.memoryEnabled,worktree_sync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source,...e.target?{target:e.target}:{},mode:e.mode})):null}},w$=e=>e?y$(e.run_setup).length>0||b$(e.run_services).length>0||(e.run_ide?.trim().length??0)>0:!1,T$=(e,t,n)=>`${e} ${e===1?t:n}`,E$=e=>{if(!e.repo_path_locked)return null;let t=[];return e.ticket_count>0&&t.push(T$(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&t.push(T$(e.worktree_count,`worktree exists`,`worktrees exist`)),t.length===0?`Repository path is locked for this project.`:`Repository path is locked because ${t.join(` and `)}.`},D$=(e,t)=>{if(t.length<=1)return`Keep at least one project in Archon.`;let n=[];e.ticket_count>0&&n.push(T$(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&n.push(T$(e.worktree_count,`worktree exists`,`worktrees exist`));let r=t.filter(t=>t.linked_project_ids.includes(e.id)).length;return r>0&&n.push(T$(r,`project links to it`,`projects link to it`)),n.length===0?null:`This project can't be deleted while ${n.join(` and `)}.`},O$=(e,t)=>e.id!==t.projectId||e.ticket_count===t.ticketCount&&e.worktree_count===t.worktreeCount&&e.repo_path_locked===t.repoPathLocked?e:{...e,ticket_count:t.ticketCount,worktree_count:t.worktreeCount,repo_path_locked:t.repoPathLocked},k$=(e,t)=>({projectId:e,branch:t.branch,status:t.status,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.has_upstream??!1,canPull:t.can_pull??!1,diffStats:t.diff_stats??null}),A$=e=>({projectId:e,branch:null,status:`loading`,ahead:0,behind:0,hasUpstream:!1,canPull:!1,diffStats:null}),j$=(e,t)=>t?e[t]??m$:m$,M$=(e,t)=>t?e[t]??h$:h$,N$=()=>{let e=window.localStorage.getItem(c$),t=Number(e);return Number.isFinite(t)&&t>=320?t:d$},P$=()=>{let e=window.localStorage.getItem(l$);return e===`phone`||e===`tablet`||e===`laptop`||e===`responsive`?e:f$},F$=()=>{let e=Number(window.localStorage.getItem(u$));return Number.isFinite(e)&&e>0?e:p$},I$=()=>{let e=v$(window.localStorage.getItem(i$));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`board`||e===`chat`||e===`memory`))},L$=()=>{let e=v$(window.localStorage.getItem(a$));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`hidden`||e===`inline`||e===`expanded`))},R$=()=>{let e=v$(window.localStorage.getItem(o$));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`||e===null))},z$=e=>!!e?.preview_service_name?.trim()&&e?.preview_capability_mode!==`force_disabled`,B$=({activeRun:e,project:t})=>{if(!e||e.kind!==`project`||!t)return!1;let n=t.active_target_kind??`repo_root`,r=t.active_target_bundle_id??null;return e.project_id===t.id&&(e.target_kind??`repo_root`)===n&&((e.target_kind??`repo_root`)!==`bundle`||e.target_bundle_id===r)},V$=({activeRun:e,project:t,projectId:n})=>!e||!n?null:e.kind===`ticket`?e.project_id===n?e:null:B$({activeRun:e,project:t})?e:null,H$=`Project root has uncommitted changes. Confirm branch switch to continue.`,U$=({activeProject:e,activeProjectBranchState:t,nextTarget:n})=>e?n.kind===`bundle`?e.active_target_kind!==`bundle`||e.active_target_bundle_id!==n.bundleId:e.active_target_kind===`bundle`?!0:n.branch?t?.branch!==n.branch:!1:!1,W$=()=>{let[e,t]=(0,Y.useState)(`opencode`),[n,r]=(0,Y.useState)(!1),[i,o]=(0,Y.useState)([]),[s,c]=(0,Y.useState)(()=>window.localStorage.getItem(r$)),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[g,_]=(0,Y.useState)({}),[y,b]=(0,Y.useState)({}),[x,C]=(0,Y.useState)({}),[w,T]=(0,Y.useState)({}),[E,D]=(0,Y.useState)({}),[k,A]=(0,Y.useState)(L$),[j,N]=(0,Y.useState)(R$),[P,I]=(0,Y.useState)(N$),[L,R]=(0,Y.useState)(P$),[z,B]=(0,Y.useState)(F$),[ee,te]=(0,Y.useState)(null),[ne,V]=(0,Y.useState)([]),[re,H]=(0,Y.useState)(!1),[ie,se]=(0,Y.useState)(``),[ce,U]=(0,Y.useState)(``),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(null),[he,ge]=(0,Y.useState)(null),[W,_e]=(0,Y.useState)(null),[ye,be]=(0,Y.useState)(!1),[G,xe]=(0,Y.useState)({}),[Se,Ce]=(0,Y.useState)(I$),[we,Te]=(0,Y.useState)(()=>CQ()),[Ee,Oe]=(0,Y.useState)(()=>SQ()),[K,Ae]=(0,Y.useState)(0),[je,Me]=(0,Y.useState)(null),[Ne,Pe]=(0,Y.useState)(null),[Fe,Ie]=(0,Y.useState)({}),[Le,Re]=(0,Y.useState)({}),[ze,Be]=(0,Y.useState)({}),[Ve,He]=(0,Y.useState)({}),[We,Ge]=(0,Y.useState)(!1),[Ke,Je]=(0,Y.useState)(!1),[Ye,Xe]=(0,Y.useState)(null),Qe=(0,Y.useRef)(null),et=(0,Y.useRef)(null),q=(0,Y.useRef)(null),J=i.find(e=>e.id===s)??null,tt=!!J?.memory_enabled,nt=s?Se[s]??`board`:`board`,rt=nt===`memory`?tt?`memory`:`board`:nt,it=J!==null,at=w$(J),ot=!!J?.run_ide?.trim(),st=s!==null&&d===s,ct=s!==null&&(!at||p===s),lt=s?g[s]??A$(s):null,ut=s?y[s]??null:null,dt=s?!!x[s]:!1,ft=s?w[s]??null:null,pt=s?Fe[s]??[]:[],mt=s?!!Le[s]:!1,ht=s?ze[s]??{current_branch:null,default_branch:null,previous_branch:null}:{current_branch:null,default_branch:null,previous_branch:null},gt=s?!!Ve[s]:!1,_t=s?E[s]??null:null,vt=M$(k,s),X=vt!==`hidden`,yt=V$({activeRun:l,project:J,projectId:s}),bt=yt?.context_key??null,xt=s?j[s]??null:null,St=z$(J),Ct=bt===ee,Tt=(0,Y.useMemo)(()=>TQ(we),[we]),Et=(0,Y.useMemo)(()=>EQ({hasRunning:Tt.hasRunning,hasFinishedUnseen:Ee.hasFinishedUnseen,hasErrorUnseen:Ee.hasErrorUnseen}),[Tt.hasRunning,Ee.hasErrorUnseen,Ee.hasFinishedUnseen]);(0,Y.useEffect)(()=>{Me(null),Pe(null),et.current=null},[s]),(0,Y.useEffect)(()=>{Pe(null)},[rt]),(0,Y.useEffect)(()=>{X||(et.current=null)},[X]),(0,Y.useEffect)(()=>{let e=je?.target?.kind??null;if(e===`ticket`||e===`bundle`){et.current=je;return}(rt===`board`||!X)&&(et.current=je)},[X,je,rt]),(0,Y.useEffect)(()=>{Te(CQ())},[s]),(0,Y.useEffect)(()=>{Oe(SQ())},[s]);let Dt=(0,Y.useCallback)((e,t)=>{document.visibilityState!==`visible`&&(!t.didFinish&&!t.didError||Oe(e=>{let n={...e,hasFinishedUnseen:e.hasFinishedUnseen||t.didFinish,hasErrorUnseen:e.hasErrorUnseen||t.didError};return e.hasFinishedUnseen===n.hasFinishedUnseen&&e.hasErrorUnseen===n.hasErrorUnseen?e:n}))},[]);(0,Y.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&Oe(e=>!e.hasFinishedUnseen&&!e.hasErrorUnseen?e:{...e,hasFinishedUnseen:!1,hasErrorUnseen:!1})};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]),(0,Y.useEffect)(()=>(Qe.current===null&&(Qe.current=document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)??`/favicon.svg`),e$({defaultHref:Qe.current,state:Et}),()=>{e$({defaultHref:Qe.current,state:null})}),[Et]);let Ot=(0,Y.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;try{let t=await ue(e,r,{refreshRemote:n});if(r?.aborted)return;_(n=>({...n,[e]:k$(e,t)}))}catch(t){if(S(t))return;if(t instanceof O&&t.status===404){_(t=>({...t,[e]:{...A$(e),status:`unknown`}}));return}_(t=>({...t,[e]:{projectId:e,branch:t[e]?.branch??null,status:`unknown`,ahead:t[e]?.ahead??0,behind:t[e]?.behind??0,hasUpstream:t[e]?.hasUpstream??!1,canPull:t[e]?.canPull??!1,diffStats:t[e]?.diffStats??null}}))}},[]),kt=(0,Y.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r,suppressLoading:i=!1}=t;i||C(t=>({...t,[e]:!0}));try{let t=await ke(e,{refreshRemote:n,signal:r});if(r?.aborted)return;b(n=>({...n,[e]:t}))}catch(t){if(S(t))return;t instanceof O&&t.status===404&&b(t=>({...t,[e]:null}))}finally{!r?.aborted&&!i&&C(t=>({...t,[e]:!1}))}},[]),At=(0,Y.useCallback)((e,t)=>{T(n=>({...n,[e]:t}))},[]),jt=(0,Y.useCallback)(async(e,t)=>{b(n=>({...n,[e.id]:t})),e.active_target_kind!==`bundle`&&await Ot(e.id),eq(e.id)},[Ot]);(0,Y.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let{tool:n}=await Cn(e.signal);t(n)}catch(e){S(e)}finally{e.signal.aborted||r(!0)}})(),()=>{e.abort()}},[]),(0,Y.useEffect)(()=>{if(!de||i.length>0&&pe===null||re)return;let e=new AbortController;return(async()=>{try{V(await Sn(`opencode`,e.signal))}catch(e){S(e)||V(e=>e)}finally{e.signal.aborted||H(!0)}})(),()=>{e.abort()}},[re,pe,i.length,de]),(0,Y.useEffect)(()=>{let e=new AbortController,t=window.localStorage.getItem(r$);return(async()=>{try{let n=await le(e.signal);if(e.signal.aborted)return;o(n);let r=n[0]?.id??null;c(n.some(e=>e.id===t)?t:r)}catch(e){S(e)||o([])}finally{e.signal.aborted||fe(!0)}})(),()=>{e.abort()}},[]),(0,Y.useEffect)(()=>{if(de){if(s){window.localStorage.setItem(r$,s);return}window.localStorage.removeItem(r$)}},[s,de]),(0,Y.useEffect)(()=>{window.localStorage.setItem(i$,JSON.stringify(Se))},[Se]),(0,Y.useEffect)(()=>{window.localStorage.setItem(a$,JSON.stringify(k))},[k]),(0,Y.useEffect)(()=>{window.localStorage.setItem(o$,JSON.stringify(j))},[j]),(0,Y.useEffect)(()=>{_(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),b(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),C(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,Y.useEffect)(()=>{xe(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,Y.useEffect)(()=>{let e=new Set(i.map(e=>e.id));Ie(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Re(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Be(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),He(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t))))},[i]),(0,Y.useEffect)(()=>{de&&(D(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),A(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),N(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}))},[i,de]),(0,Y.useEffect)(()=>{de&&Ce(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i,de]),(0,Y.useEffect)(()=>{if(!de||!s||!it)return;let e=!1,t=null,n=null;_(e=>e[s]?e:{...e,[s]:A$(s)});let r=async(r=!1)=>{let i=r?`remote`:`local`;if(t){if(n===`remote`||n===i)return;t.abort()}let a=new AbortController;t=a,n=i;try{await Promise.all([Ot(s,{refreshRemote:r,signal:a.signal}),kt(s,{refreshRemote:r,signal:a.signal})])}catch{if(e||a.signal.aborted)return}finally{t===a&&(t=null,n=null)}};r(!1);let i=rq(()=>{document.visibilityState===`visible`&&r(!1)});return()=>{e=!0,t?.abort(),i()}},[s,it,de,Ot,kt]),(0,Y.useEffect)(()=>{if(s)return tq(e=>{e===s&&(Ot(e),kt(e))})},[s,Ot,kt]),(0,Y.useEffect)(()=>{if(!s||!it)return;let e=ut?.operation_state??`idle`;if(!(ft===`rebase`||e!==`idle`))return;let t=!1,n=null,r=null,i=async()=>{r?.abort(),r=new AbortController;try{await kt(s,{signal:r.signal,suppressLoading:!0})}catch{}finally{t||(n=window.setTimeout(()=>{i()},n$))}};return i(),()=>{t=!0,r?.abort(),n!==null&&window.clearTimeout(n)}},[ft,s,ut?.operation_state,it,kt]);let Mt=(0,Y.useCallback)(async e=>{let t=s;if(!t){u(null),m(null);return}try{let n=await Vt(t,e);e?.aborted||(u(n.active_run),m(t))}catch(e){S(e)}},[s]),Nt=(0,Y.useCallback)(async e=>{let t=s;if(t)try{let n=await Bt(t,e);e?.aborted||D(e=>({...e,[t]:n}))}catch(e){S(e)}},[s]);(0,Y.useEffect)(()=>{if(!de)return;if(!at){u(null),m(null);return}if(!st)return;let e=new AbortController;m(null),Mt(e.signal);let t=window.setInterval(()=>{Mt(e.signal)},s$),n=rq(()=>{document.visibilityState===`visible`&&Mt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[st,at,de,Mt]),(0,Y.useEffect)(()=>{if(!de||!s||!st||!St)return;let e=new AbortController;Nt(e.signal);let t=window.setInterval(()=>{Nt(e.signal)},s$),n=rq(()=>{document.visibilityState===`visible`&&Nt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[s,st,St,de,Nt]),(0,Y.useEffect)(()=>{window.localStorage.setItem(c$,String(P))},[P]),(0,Y.useEffect)(()=>{window.localStorage.setItem(l$,L)},[L]),(0,Y.useEffect)(()=>{window.localStorage.setItem(u$,String(z))},[z]),(0,Y.useEffect)(()=>{s&&bt&&N(e=>{let t=e[s]??null;return!t||t===bt?e:{...e,[s]:null}})},[s,bt]),(0,Y.useEffect)(()=>{!s||!yt||!z$(J)||xt!==yt.context_key&&A(e=>M$(e,s)===`hidden`?{...e,[s]:`inline`}:e)},[J,s,xt,yt]);let Pt=async e=>{try{t((await wn(e)).tool)}catch{}},Ft=(0,Y.useCallback)(e=>{o(t=>t.map(t=>t.id===e.id?e:t))},[]),It=(0,Y.useCallback)((e,t)=>{Ie(n=>{let r=[t,...(n[e]??[]).filter(e=>e.id!==t.id)];return{...n,[e]:r}})},[]),Lt=(0,Y.useCallback)(async e=>{He(t=>({...t,[e]:!0}));try{let t=await ve(e);Be(n=>({...n,[e]:t}))}catch(e){Q.error(e instanceof O?e.message:`Unable to load the project target options right now.`,{id:`project-target-selector-load-error`})}finally{He(t=>({...t,[e]:!1}))}},[]),Rt=async e=>{try{let t=await F(C$(e));return o(e=>[...e,t]),c(t.id),me(null),null}catch(e){return e instanceof O?e.message:`Unable to create the project right now.`}},Wt=async e=>{if(!J)return`Select a project before editing settings.`;try{let t=await h(J.id,C$(e));return o(e=>e.map(e=>e.id===t.id?t:e)),Ae(e=>e+1),me(null),null}catch(e){return e instanceof O?e.message:`Unable to update the project right now.`}},Gt=async()=>{if(!J)return`Select a project before deleting it.`;try{await Ue(J.id);let e=i.filter(e=>e.id!==J.id);return o(e),c(e[0]?.id??null),me(null),null}catch(e){return e instanceof O?e.message:`Unable to delete the project right now.`}},Kt=(0,Y.useCallback)(e=>{o(t=>t.map(t=>O$(t,e)))},[]),qt=(0,Y.useCallback)((e,t)=>{e&&Ie(n=>({...n,[e]:t}))},[]),Jt=(0,Y.useCallback)((e,t)=>{e&&Re(n=>({...n,[e]:t}))},[]),Yt=async(e,t,n)=>await oe({repo_path:e,helper_model:t||null,helper_variant:t&&n||null}),Xt=async()=>(await ae()).repo_path,Zt=(0,Y.useCallback)(async e=>{let t=await De({repo_path:e});return{valid:t.valid,repoRoot:t.repo_root,error:t.error,willInitialize:t.will_initialize,hasInitialCommit:t.has_initial_commit}},[]),Qt=(0,Y.useCallback)(async()=>{if(!(!J||ye)){be(!0);try{let e=await a(J.id);o(t=>t.map(t=>t.id===e.id?e:t)),Q.success(`Initial commit created.`,{id:`project-initial-commit-success`}),Ot(e.id),kt(e.id)}catch(e){Q.error(e instanceof O?e.message:`Unable to create the initial commit right now.`,{id:`project-initial-commit-error`})}finally{be(!1)}}},[J,ye,Ot,kt]),$t=(0,Y.useCallback)((e,t)=>{A(t=>({...t,[e]:`hidden`})),t&&N(n=>({...n,[e]:t}))},[]),en=(0,Y.useCallback)(()=>{s&&$t(s,bt)},[s,$t,bt]),tn=(0,Y.useCallback)(e=>{s&&(A(e=>({...e,[s]:`hidden`})),e&&u(t=>t?.context_key===e?null:t))},[s]),nn=(0,Y.useCallback)(async()=>{if(!yt||ee===yt.context_key)return;let{context_key:e}=yt;te(e);try{yt.kind===`ticket`?await hn(yt.ticket_id,yt.project_id):u((await Ut(yt.project_id)).active_run),tn(e),await Promise.all([Mt(),Nt()])}catch(e){Q.error(e instanceof O?e.message:`Unable to stop the preview run right now.`,{id:`app-preview-run-stop-error`})}finally{te(t=>t===e?null:t)}},[tn,yt,Nt,Mt,ee]),rn=(0,Y.useCallback)(e=>{!e||!s||Lt(s)},[s,Lt]),an=(0,Y.useCallback)(e=>new Promise(t=>{q.current=t,Xe(e)}),[]),on=(0,Y.useCallback)(e=>{let t=q.current;q.current=null,Xe(null),t?.(e)},[]),sn=(0,Y.useCallback)(async e=>{if(!J||!s)throw Error(`Select a project first.`);if(!U$({activeProject:J,activeProjectBranchState:lt,nextTarget:e})||!l||l.kind!==`project`||l.project_id!==J.id)return!0;if(!await an({title:`Stop current run and switch target?`,description:`Switching targets will stop the current run and close its preview.`,confirmLabel:`Stop and switch`,cancelLabel:`Keep current target`,confirmVariant:`destructive`}))return!1;try{let e=l.context_key,t=await Ut(J.id);return tn(e),u(t.active_run),await Nt(),!0}catch(e){return Q.error(e instanceof O?e.message:`Unable to stop the project run right now.`,{id:`project-target-switch-stop-run-error`}),!1}},[J,lt,s,l,tn,Nt,an]),cn=(0,Y.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);return await sn({kind:`bundle`,bundleId:e})?(Ft(await M(s,{kind:`bundle`,bundle_id:e})),b(e=>({...e,[s]:null})),await Promise.all([Ot(s),kt(s)]),!0):!1},[s,sn,Ot,kt,Ft]),ln=(0,Y.useCallback)(async(e,t={})=>{if(!s)throw Error(`Select a project first.`);if(!await sn({kind:`repo_root`,branch:e}))return!1;let n=n=>M(s,{kind:`repo_root`,...e?{branch:e}:{},...t.createBranch===!1?{create_branch:!1}:{},...n?{confirm_dirty_switch:!0}:{}}),r;try{r=await n(t.confirmDirtySwitch===!0)}catch(e){if(!t.confirmDirtySwitch&&e instanceof O&&e.status===409&&e.message===H$){if(!await an({title:`Switch repo root branch?`,description:`${H$}\n\nSwitch anyway?`,confirmLabel:`Switch anyway`,cancelLabel:`Keep current branch`}))return!1;r=await n(!0)}else throw e}return Ft(r),b(e=>({...e,[s]:null})),await Promise.all([Ot(s),kt(s),Lt(s)]),!0},[s,sn,Lt,Ot,kt,Ft,an]),un=(0,Y.useCallback)(async e=>!e.target_kind||e.target_available===!1?!0:e.target_kind===`bundle`?e.target_bundle_id?await cn(e.target_bundle_id):!1:await ln(e.target_branch_snapshot??null,{createBranch:!1}),[cn,ln]),dn=(0,Y.useCallback)(()=>{Ge(!0)},[]),fn=(0,Y.useCallback)(()=>{Ge(!1)},[]),pn=(0,Y.useCallback)(e=>{if(e){cn(e);return}ln(null)},[cn,ln]),mn=(0,Y.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);let t=await wt(s,{name:e,prepare:!0});return It(s,t),Ae(e=>e+1),t},[s,It]),gn=(0,Y.useCallback)(async e=>{if(!s)throw Error(`Select a project first.`);await zt(s,e),Ie(t=>({...t,[s]:(t[s]??[]).filter(t=>t.id!==e)})),Ae(e=>e+1)},[s]),_n=(0,Y.useCallback)(async()=>{if(!J)return;let e=J.active_target_kind??`repo_root`,t=J.active_target_bundle_id??null,n=l?.kind===`project`&&l.project_id===J.id&&(l.target_kind??`repo_root`)===e&&((l.target_kind??`repo_root`)!==`bundle`||l.target_bundle_id===t),r=n?l?.context_key??null:null,i=!n&&z$(J)&&vt===`hidden`;i&&(A(e=>({...e,[J.id]:`inline`})),N(e=>({...e,[J.id]:null})));try{let e=n?await Ut(J.id):await Ht(J.id);n&&tn(r),u(e.active_run),Nt()}catch(e){i&&A(e=>({...e,[J.id]:`hidden`})),Q.error(e instanceof O?e.message:`Unable to update the project run right now.`,{id:`app-project-run-error`})}},[vt,J,l,tn,Nt]),vn=(0,Y.useCallback)(async()=>{if(!(!J||!ot))try{await qe(J.id)}catch(e){Q.error(e instanceof Error?e.message:`Unable to open the IDE right now.`,{id:`app-project-open-ide-error`})}},[J,ot]),yn=(0,Y.useCallback)(async()=>{if(J){At(J.id,`pull`);try{let e=await $e(J.id);await jt(J,e),Q.success(e.behind===0?t$(`branchSynced`):t$(`branchUpdated`),{id:`app-project-pull-success`})}catch(e){Q.error(e instanceof O?e.message:t$(`syncFallbackError`),{id:`app-project-pull-error`})}finally{At(J.id,null)}}},[J,jt,At]),bn=(0,Y.useCallback)(async()=>{if(!J)return;let e=ut?.base_branch??null;At(J.id,`rebase`);try{let t=await Ze(J.id);await jt(J,t);let n=t.base_branch??e;Q.success(n?t$(`branchRebasedOnto`,{branch:n}):t$(`branchRebased`),{id:`app-project-rebase-success`})}catch(e){await Promise.allSettled([Ot(J.id),kt(J.id,{suppressLoading:!0})]),Q.error(e instanceof O?e.message:t$(`rebaseFallbackError`),{id:`app-project-rebase-error`})}finally{At(J.id,null)}},[J,ut?.base_branch,jt,Ot,kt,At]),xn=(0,Y.useCallback)(async()=>{if(J){At(J.id,`abort`);try{await jt(J,await v(J.id)),Q.success(t$(`gitOperationAborted`),{id:`app-project-abort-success`})}catch(e){Q.error(e instanceof O?e.message:t$(`abortFallbackError`),{id:`app-project-abort-error`})}finally{At(J.id,null)}}},[J,jt,At]),Tn=(0,Y.useCallback)(()=>{J&&ge({projectId:J.id,title:J.name})},[J]),En=(0,Y.useCallback)(()=>{if(!he)return;let{projectId:e}=he;ge(null),Ot(e),kt(e)},[Ot,kt,he]),Dn=(0,Y.useCallback)(()=>{J&&_e({projectId:J.id,targetKind:J.active_target_kind??`repo_root`,targetBundleId:J.active_target_bundle_id??null})},[J]),On=(0,Y.useCallback)(()=>{_e(null)},[]),kn=j$(G,s),An=J?vY(J.test_commands).length>0:!1,jn=rt===`chat`?Ne:null,Mn=et.current,Nn=Mn?.target?.kind??null,Pn=rt===`chat`?Nn===`ticket`||Nn===`bundle`?{target:Mn?.target??null,canSelect:!1,disabledReason:`This preview belongs to a ticket run. Return to Board to send preview comments.`,promptMode:Mn?.promptMode??null,onPromptModeChange:Mn?.onPromptModeChange??null,isUpdatingPromptMode:Mn?.isUpdatingPromptMode??!1,promptPlaceholder:Mn?.promptPlaceholder??null,promptComposerControls:Mn?.promptComposerControls,promptComposerInlineControls:Mn?.promptComposerInlineControls,submitPrompt:null}:jn?{target:{kind:`chat_session`,id:jn.chatSessionId??`draft:${s}`},canSelect:jn.canSubmitReviewPrompt,disabledReason:jn.canSubmitReviewPrompt?null:jn.reviewSubmitDisabledReason??`Wait for the current chat turn to finish before sending preview comments.`,promptMode:jn.mode,onPromptModeChange:jn.onModeChange,isUpdatingPromptMode:jn.isUpdatingMode,promptPlaceholder:jn.promptPlaceholder,promptComposerControls:jn.promptComposerControls,promptComposerInlineControls:jn.promptComposerInlineControls,submitPrompt:jn.canSubmitReviewPrompt?jn.submitPrompt:null}:{target:null,canSelect:!1,disabledReason:`Select a chat session to send preview comments.`,submitPrompt:null}:je,Fn=jn?.canSubmitReviewPrompt??!1,In=rt===`chat`?jn?jn.reviewSubmitDisabledReason:`Select a chat session to send review comments.`:void 0,Ln=(0,Y.useCallback)(()=>{s&&xe(e=>{let t=e[s]??m$;return{...e,[s]:{hasMounted:!0,isOpen:!t.isOpen,isExpanded:t.isExpanded}}})},[s]),Rn=(0,Y.useCallback)(e=>{xe(t=>{let n=t[e]??m$;return!n.hasMounted||!n.isOpen?t:{...t,[e]:m$}})},[]),zn=(0,Y.useCallback)(e=>{xe(t=>{let n=t[e]??m$;return{...t,[e]:{hasMounted:!0,isOpen:n.isOpen,isExpanded:!n.isExpanded}}})},[]),Bn=(0,Y.useCallback)(()=>{me(`create`)},[]),Vn=(0,Y.useCallback)(()=>{if(s){if(X){en();return}A(e=>({...e,[s]:`inline`})),N(e=>({...e,[s]:null}))}},[s,en,X]),Hn=(0,Y.useCallback)(()=>{s&&A(e=>{let t=M$(e,s);return{...e,[s]:t===`expanded`?`inline`:`expanded`}})},[s]),Un=J?J.preview_service_name?.trim()?J.preview_capability_mode===`force_disabled`?`Preview is disabled for this project.`:_t?.state===`unsupported`?_t.message??`Preview is unavailable for this project.`:X?`Hide preview`:`Show preview`:`Choose a named preview service in project settings first.`:`Select a project first.`,Wn=!J||!J.preview_service_name?.trim()||J.preview_capability_mode===`force_disabled`||_t?.state===`unsupported`,Gn=J&&J.preview_service_name?.trim()?(0,Z.jsx)(Jb,{project:J,mode:vt===`expanded`?`expanded`:`inline`,status:_t,viewportPreset:L,zoom:z,activeRun:yt,reviewCapability:Pn,isStoppingActiveRun:Ct,onHide:en,onStopActiveRun:()=>{nn()},onToggleExpanded:Hn,onViewportPresetChange:R,onZoomChange:B}):null;return(0,Z.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-[linear-gradient(180deg,_rgba(15,16,21,1),_rgba(9,10,14,1))] text-foreground`,children:[(0,Z.jsx)(iu,{}),i.length>0&&(0,Z.jsx)(`header`,{className:`border-b border-border bg-background/95 px-6 py-3 backdrop-blur`,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-center`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 lg:justify-self-start`,children:(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-[20rem] sm:max-w-[30rem]`,children:(0,Z.jsx)(wc,{activeProjectId:s,projects:i,onEditProject:()=>me(`edit`),onProjectChange:c})})}),s&&(0,Z.jsx)(`div`,{className:`flex justify-start lg:col-start-2 lg:row-start-1 lg:justify-center`,children:(0,Z.jsx)(zQ,{activeWorkspace:rt,activityByWorkspace:we,memoryEnabled:tt,onWorkspaceChange:e=>{s&&(Ce(t=>({...t,[s]:e})),Te(t=>wQ(t,e)))}})}),(0,Z.jsx)(`div`,{className:`w-full lg:col-start-3 lg:row-start-1 lg:w-auto lg:justify-self-end`,children:(0,Z.jsx)(ru,{activeTool:e,onCreateProject:Bn,onMobileAccessOpen:()=>Je(!0),onToolChange:Pt})})]})}),de?i.length===0?(0,Z.jsx)(Sc,{activeTool:e,availableHelperModels:ne,helperModel:ie,helperVariant:ce,isHelperModelsLoaded:re,isToolLoaded:n,onCreateProject:Bn,onHelperModelChange:e=>{se(e),U(``)},onHelperVariantChange:U,onToolChange:Pt}):(0,Z.jsxs)(Z.Fragment,{children:[J?.has_initial_commit===!1&&(0,Z.jsx)(pu,{isSubmitting:ye,onCreateInitialCommit:()=>{Qt()}}),(0,Z.jsx)(LQ,{activeProjectId:s,activeProject:J,activeProjectBranchState:lt,activeRun:l,activeTool:e,onRestoreChatSessionTarget:un,onChatReviewCapabilityChange:Pe,isPreviewButtonDisabled:Wn,onPreviewReviewCapabilityChange:Me,onPreviewToggle:Vn,onRunStopped:tn,onWorkspaceActivityChange:Te,onWorkspaceActivityEvent:Dt,previewDisplayMode:vt,previewPane:Gn,previewPaneWidth:P,previewButtonTitle:Un,visibleWorkspace:rt,refreshKey:K,onBoardLoadedProjectIdChange:f,onBundlesChange:qt,onBundlesLoadingChange:Jt,onPreviewPaneWidthChange:I,onProjectUsageChange:Kt,onRunStatusChange:()=>{Mt(),Nt()}},s??`no-project`)]}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading projects...`}),i.length>0&&(0,Z.jsx)(Fl,{activeProject:J,activeRun:l,branchState:lt,targetGitStatus:ut,isBoardLoadedForActiveProject:st,activeProjectBranchAction:ft,isProjectIdeAvailable:ot,isProjectRunAvailable:at,isRunStatusLoadedForActiveProject:ct,isTerminalOpen:kn.isOpen,targetBundles:pt,targetBranchSuggestions:ht,isTargetBundleLoading:mt,isTargetSelectorLoading:gt,isTargetGitStatusLoading:dt,hasConfiguredTests:An,onProjectIdeOpen:()=>{vn()},onProjectPull:()=>{yn()},onProjectRebase:bn,onProjectAbortGitOperation:xn,onProjectRunToggle:()=>{_n()},onProjectChangesOpen:Tn,onProjectTestsOpen:Dn,onTerminalToggle:Ln,onTargetSelectorOpenChange:rn,onSelectBundleTarget:cn,onSelectRepoRootTarget:ln,onManageBundles:dn}),(0,Z.jsx)(Md,{activeProjectId:s,open:Ke,onOpenChange:Je}),We&&J&&(0,Z.jsx)(wu,{bundles:pt,selectedBundleId:J.active_target_kind===`bundle`?J.active_target_bundle_id??null:null,activeTargetBundleId:J.active_target_kind===`bundle`?J.active_target_bundle_id??null:null,onSelectBundle:pn,onCreateBundle:mn,onDeleteBundle:gn,onClose:fn}),Ye&&(0,Z.jsx)(fu,{title:Ye.title,description:Ye.description,confirmLabel:Ye.confirmLabel,cancelLabel:Ye.cancelLabel,confirmVariant:Ye.confirmVariant,onConfirm:()=>on(!0),onCancel:()=>on(!1)}),i.map(e=>{let t=j$(G,e.id);return t.hasMounted?(0,Z.jsx)(RQ,{project:e,isExpanded:t.isExpanded,isVisible:e.id===s&&t.isOpen,onClose:()=>Rn(e.id),onToggleExpanded:()=>zn(e.id)},e.id):null}),pe&&(0,Z.jsx)(Ip,{mode:pe,projectId:pe===`edit`&&J?J.id:null,availableHelperModels:ne,isLoadingHelperModels:!re,isAutoConfigReady:n,initialValues:pe===`edit`&&J?S$(J):i.length===0?{name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],testCommands:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:ie,helperVariant:ce,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}:void 0,linkedProjectOptions:i.filter(e=>e.id!==J?.id).map(e=>({id:e.id,name:e.name})),repoPathLocked:pe===`edit`&&J?J.repo_path_locked:!1,repoPathLockedMessage:pe===`edit`&&J?E$(J):null,deleteBlockedMessage:pe===`edit`&&J?D$(J,i):null,onDelete:pe===`edit`?Gt:void 0,onAutoConfig:Yt,onBrowseRepoPath:Xt,onValidateRepoPath:Zt,onClose:()=>me(null),onSubmit:pe===`edit`?Wt:Rt}),he&&he.projectId===s&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(g$,{scope:`project_root`,projectId:he.projectId,title:he.title,onSubmitReviewPrompt:jn?.submitPrompt,canSubmitReviewPrompt:Fn,reviewSubmitDisabledReason:In??void 0,canAddReviewComments:Fn,canModifyChanges:!0,onClose:En})}),W&&W.projectId===s&&J&&(0,Z.jsx)(Y.Suspense,{fallback:null,children:(0,Z.jsx)(_$,{scope:`project`,projectId:W.projectId,targetKind:W.targetKind,targetBundleId:W.targetBundleId,testCommands:vY(J.test_commands),onClose:On})})]})},G$=({className:e})=>(0,Z.jsx)(fo,{"aria-hidden":`true`,className:e}),K$=({className:e})=>(0,Z.jsx)(ho,{"aria-hidden":`true`,className:e}),q$=({className:e})=>(0,Z.jsx)(Oo,{"aria-hidden":`true`,className:e}),J$=`X-Archon-Mobile-CSRF`,Y$=async(e,t={})=>{let n=await fetch(e,{credentials:`include`,...t});if(!n.ok)throw new O(await _(n,`Mobile request failed.`),n.status);return n},X$=async(e,t={})=>await(await Y$(e,t)).json(),Z$=e=>X$(`/mobile/projects`,{signal:e}),Q$=(e,t)=>X$(`/mobile/projects/${encodeURIComponent(e)}/summary`,{signal:t}),$$=(e,t)=>X$(`/mobile/projects/${encodeURIComponent(e)}/target-options`,{signal:t}),e1=(e,t)=>X$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions`,{signal:t}),t1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}`,{signal:n}),n1=(e,t)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets`,{signal:t}),r1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}`,{signal:n}),i1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}`,{signal:n}),a1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/build`,s1(n)),o1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/review`,s1(n)),s1=(e,t,n=`POST`)=>({method:n,headers:{"Content-Type":`application/json`,[J$]:e},body:t===void 0?void 0:JSON.stringify(t)}),c1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions`,s1(t,n)),l1=(e,t,n,r)=>X$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}/messages`,s1(n,r)),u1=(e,t,n,r)=>X$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}`,s1(n,r,`PATCH`)),d1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/chat-sessions/${encodeURIComponent(t)}/stop`,s1(n)),f1=(e,t,n,r)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/state`,s1(n,{state:r},`PATCH`)),p1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/run`,s1(n)),m1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/stop`,s1(n)),h1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/stop-build`,s1(n)),g1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/resume-build`,s1(n)),_1=(e,t,n,r)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}`,s1(n,r,`PATCH`)),v1=(e,t,n,r)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/plan-follow-up`,s1(n,{instruction:r})),y1=(e,t,n,r)=>X$(`/mobile/projects/${encodeURIComponent(e)}/tickets/${encodeURIComponent(t)}/follow-up`,s1(n,{instruction:r})),b1=(e,t,n,r)=>X$(`/mobile/projects/${encodeURIComponent(e)}/bundles/${encodeURIComponent(t)}/follow-up`,s1(n,{instruction:r})),x1=(e,t,n)=>X$(`/mobile/projects/${encodeURIComponent(e)}/target`,s1(t,n)),S1=(e,t)=>X$(`/mobile/models?tool=${encodeURIComponent(e)}`,{signal:t}),C1=(e,t,n)=>{let r=new URLSearchParams({tool:e});return t&&r.set(`project_id`,t),X$(`/mobile/skills?${r.toString()}`,{signal:n})},w1=e=>X$(`/mobile-auth/status`,{signal:e}),T1=(e,t)=>X$(`/mobile-auth/pair/preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t}),E1=e=>X$(`/mobile-auth/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),D1=e=>X$(`/mobile-auth/logout`,{method:`POST`,headers:{[J$]:e}}),O1=()=>BW(window.location.origin,{withCredentials:!0}),k1=e=>Ne.t(`common:mobileApp.${e}`),A1={key:`overview`,label:k1(`navigation.overview`),Icon:G$},j1={key:`tickets`,label:k1(`navigation.tickets`),Icon:q$,ctaAriaLabel:k1(`overviewActions.ticketsAriaLabel`)},M1={key:`chats`,label:k1(`navigation.chats`),Icon:em,ctaAriaLabel:k1(`overviewActions.chatsAriaLabel`)},N1=[A1,j1,M1],P1=`Project root has uncommitted changes. Confirm branch switch to continue.`,F1=e=>e?`Repo root (${e})`:`Repo root`,I1=e=>{if(!e)return`Repo root`;if(e.length<=20)return e;let t=e.split(`/`).filter(Boolean),n=t[t.length-1]??e;return n.length<=17?`.../${n}`:`${n.slice(0,16)}...`},L1=(e,t)=>{if(!e)return`Target`;if(e.active_target_kind===`bundle`&&e.active_target_bundle_id){let n=t?.bundles.find(t=>t.id===e.active_target_bundle_id)??null;return n?Tl(n):`Selected bundle`}return I1(t?.current_branch??null)},R1=({children:e})=>(0,Z.jsx)(`main`,{className:`min-h-screen bg-background text-foreground`,children:(0,Z.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-lg items-center px-4 py-8`,children:(0,Z.jsx)(`div`,{className:`w-full`,children:e})})}),z1=({title:e,description:t,children:n})=>(0,Z.jsx)(R1,{children:(0,Z.jsxs)(mu,{className:`w-full border-border/80 bg-card/90 shadow-2xl shadow-black/20`,children:[(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{children:e}),(0,Z.jsx)(_u,{children:t})]}),n?(0,Z.jsx)(yu,{className:`space-y-4`,children:n}):null]})}),B1=e=>e===`connected`?{label:`Connected`,variant:`success`,indicatorState:`finished`}:e===`reconnecting`?{label:`Reconnecting`,variant:`warning`,indicatorState:`running`}:e===`unavailable`?{label:`Offline`,variant:`destructive`,indicatorState:`error`}:{label:`Connecting`,variant:`outline`,indicatorState:`running`},V1=({status:e})=>{let t=B1(e);return(0,Z.jsxs)(U,{variant:t.variant,className:`gap-1.5 px-2.5 py-1 text-[11px] uppercase tracking-[0.14em]`,children:[(0,Z.jsx)(Il,{state:t.indicatorState,className:`mt-0`}),t.label]})},H1=()=>{let[e,t]=(0,Y.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(min-width: 1024px)`).matches);return(0,Y.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(min-width: 1024px)`),n=n=>{t(n?.matches??e.matches)};return n(),typeof e.addEventListener==`function`?(e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)):(e.addListener(n),()=>e.removeListener(n))},[]),e},U1=({status:e,onRetry:t})=>e===`connected`?null:e===`unavailable`?(0,Z.jsx)(mu,{className:`border-red-500/25 bg-destructive/10 shadow-none`,children:(0,Z.jsxs)(yu,{className:`flex flex-col gap-3 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-red-100`,children:`Desktop Archon is currently unreachable.`}),(0,Z.jsx)(`p`,{className:`text-sm text-red-200/85`,children:`Mobile access may have been disabled, the backend may have restarted, or this phone lost network access.`})]}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(K,{variant:`warning`,onClick:t,children:`Retry connection`})})]})}):(0,Z.jsx)(mu,{className:`border-amber-500/25 bg-amber-500/10 shadow-none`,children:(0,Z.jsx)(yu,{className:`pt-5 text-sm text-amber-100`,children:e===`connecting`?`Connecting to live updates from desktop Archon...`:`Reconnecting to desktop Archon. Existing content stays visible while this phone reconnects.`})}),W1=({title:e,description:t,children:n})=>(0,Z.jsxs)(`div`,{className:`flex max-h-[80vh] flex-col overflow-hidden`,children:[(0,Z.jsxs)(Ns,{className:`border-b border-border/70 px-4 py-4`,children:[(0,Z.jsx)(Fs,{children:e}),t?(0,Z.jsx)(Is,{children:t}):null]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:n})]}),G1=({projects:e,selectedProjectId:t,error:n,onSelectProject:r,onRetry:i})=>n?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:n}),(0,Z.jsx)(K,{variant:`warning`,onClick:i,children:`Retry projects`})]}):e?e.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No projects are available on the desktop instance yet.`}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{let n=e.id===t;return(0,Z.jsxs)(`button`,{type:`button`,className:G(`w-full rounded-2xl border px-4 py-3 text-left transition-colors`,n?`border-primary/50 bg-primary/10`:`border-border/80 bg-card/60 hover:border-primary/30 hover:bg-accent/60`),onClick:()=>r(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.repo_path})]}),n&&(0,Z.jsx)(U,{variant:`info`,children:`Current`})]}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:(0,Z.jsxs)(`span`,{children:[e.ticket_count,` tickets`]})})]},e.id)})}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading projects...`}),K1=({open:e,projects:t,selectedProjectId:n,error:r,onOpenChange:i,onSelectProject:a,onRetry:o})=>(0,Z.jsx)(Os,{open:e,onOpenChange:i,children:(0,Z.jsx)(Ms,{showCloseButton:!1,"aria-describedby":void 0,className:`top-auto right-0 bottom-0 left-0 max-w-none translate-x-0 translate-y-0 overflow-hidden rounded-t-3xl rounded-b-none border-x-0 border-b-0 p-0 sm:top-1/2 sm:right-auto sm:bottom-auto sm:left-1/2 sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl sm:border sm:p-0`,children:(0,Z.jsx)(W1,{title:`Projects`,children:(0,Z.jsx)(G1,{projects:t,selectedProjectId:n,error:r,onSelectProject:e=>{a(e),i(!1)},onRetry:o})})})}),q1=({open:e,project:t,targetOptions:n,error:r,isLoading:i,isSubmitting:a,onOpenChange:o,onRetry:s,onSelectBundle:c,onSelectRepoRoot:l})=>{let[u,d]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{e&&d(n?.current_branch??``)},[e,n?.current_branch]);let f=t?.active_target_kind!==`bundle`,p=hl(n?.bundles??[]),m=[{key:`default`,label:`Default branch`,branch:n?.default_branch??null},{key:`previous`,label:`Previous branch`,branch:n?.previous_branch??null}].filter(e=>e.branch&&e.branch!==n?.current_branch).filter((e,t,n)=>n.findIndex(t=>t.branch===e.branch)===t),h=t?r?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:r}),(0,Z.jsx)(K,{variant:`warning`,onClick:s,children:`Retry target options`})]}):n?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`Project target`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Choose the repo root or a prepared bundle for new chats and desktop work launched from this phone.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Xs,{className:`text-xs font-medium text-muted-foreground`,children:`Target`}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/70 bg-background/40 p-2`,children:[(0,Z.jsx)(K,{type:`button`,variant:f?`secondary`:`ghost`,className:`w-full justify-start`,disabled:a,onClick:()=>l(null),children:F1(n.current_branch)}),(0,Z.jsxs)(`div`,{className:`relative min-h-10`,"data-testid":`mobile-target-options`,children:[i&&(0,Z.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-10 text-muted-foreground`,"data-testid":`mobile-target-options-spinner`,children:(0,Z.jsx)(pe,{className:`h-3.5 w-3.5 animate-spin`})}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto pr-7`,children:p.length===0&&!i?(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:`No prepared bundles are available yet.`}):p.map(e=>(0,Z.jsx)(K,{type:`button`,variant:t.active_target_kind===`bundle`&&t.active_target_bundle_id===e.id?`secondary`:`ghost`,className:`w-full justify-start`,disabled:a,onClick:()=>c(e.id),children:(0,Z.jsx)(`span`,{className:`truncate`,children:Tl(e)})},e.id))})]})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Xs,{className:`text-xs font-medium text-muted-foreground`,children:`Repo root branch`}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/70 bg-background/40 p-3`,children:[(0,Z.jsx)(`div`,{className:`space-y-2`,children:m.length>0?m.map(({key:e,label:t,branch:n})=>(0,Z.jsxs)(K,{type:`button`,variant:`outline`,className:`w-full justify-between gap-3`,disabled:!f||a||!n,onClick:()=>l(n),children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n})]},e)):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i?`Loading branch suggestions...`:`No suggested branches available.`})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsx)(Xs,{htmlFor:`mobile-project-target-branch-input`,className:`text-xs text-muted-foreground`,children:`Switch or create branch`}),(0,Z.jsx)(We,{id:`mobile-project-target-branch-input`,value:u,disabled:!f||a,onChange:e=>d(e.target.value),placeholder:`feature/quick-fix`})]}),(0,Z.jsx)(K,{type:`button`,disabled:!f||!u.trim()||a,onClick:()=>l(u.trim()),children:`Switch`})]}),f?null:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Switch to repo root to choose a branch.`})]})]})]}):(0,Z.jsx)(Q1,{text:`Loading target options...`}):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a project before choosing a target.`});return(0,Z.jsx)(Os,{open:e,onOpenChange:o,children:(0,Z.jsx)(Ms,{showCloseButton:!1,"aria-describedby":void 0,className:`top-auto right-0 bottom-0 left-0 max-w-none translate-x-0 translate-y-0 overflow-hidden rounded-t-3xl rounded-b-none border-x-0 border-b-0 p-0 sm:top-1/2 sm:right-auto sm:bottom-auto sm:left-1/2 sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl sm:border sm:p-0`,children:(0,Z.jsx)(W1,{title:`Target`,description:t?L1(t,n):void 0,children:h})})})},J1=({selectedProject:e,targetLabel:t,isTargetLoading:n,isTargetDisabled:r,connectionState:i,onOpenProjects:a,onOpenTargetSelector:o})=>(0,Z.jsx)(`header`,{className:`sticky top-0 z-20 border-b border-border/70 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between gap-3 px-3 pb-3 pt-4 sm:px-4`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`Choose project`,className:`min-w-0 flex-1 text-left`,onClick:a,children:[(0,Z.jsx)(`div`,{className:`truncate text-base font-medium text-foreground`,children:e?.name??`Choose a project`}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e?.repo_path??`Select a desktop project to continue`})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(V1,{status:i}),(0,Z.jsxs)(K,{variant:`outline`,size:`sm`,"aria-label":`Choose target`,"data-testid":`mobile-target-trigger`,className:`h-8 max-w-32 gap-2 px-2.5 sm:max-w-40`,disabled:r,onClick:o,children:[(0,Z.jsx)(Dl,{className:`h-3.5 w-3.5 shrink-0`}),n?(0,Z.jsx)(Ec,{className:`h-3.5 w-16`}):(0,Z.jsx)(`span`,{className:`truncate text-xs sm:text-sm`,children:t})]}),(0,Z.jsx)(K,{variant:`outline`,size:`icon-sm`,"aria-label":`Choose project`,onClick:a,children:(0,Z.jsx)(of,{className:`h-4 w-4`})})]})]})}),Y1=({activeSection:e,onChange:t})=>(0,Z.jsx)(`nav`,{className:`fixed inset-x-0 bottom-0 z-20 border-t border-border/70 bg-background/95 px-3 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] pt-2 backdrop-blur supports-[backdrop-filter]:bg-background/85 sm:px-4 lg:hidden`,children:(0,Z.jsx)(`div`,{className:`mx-auto flex max-w-6xl gap-2`,children:N1.map(n=>{let r=n.key===e,i=n.Icon;return(0,Z.jsxs)(K,{type:`button`,variant:r?`secondary`:`ghost`,className:`h-11 flex-1 gap-2`,"aria-current":r?`page`:void 0,onClick:()=>t(n.key),children:[(0,Z.jsx)(i,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:n.label})]},n.key)})})}),X1=({title:e,description:t,action:n})=>(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsxs)(hu,{children:[(0,Z.jsx)(gu,{children:e}),(0,Z.jsx)(_u,{children:t})]}),n?(0,Z.jsx)(yu,{children:n}):null]}),Z1=({label:e,value:t,accentClassName:n})=>(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:G(`text-xl font-semibold text-foreground`,n),children:t}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs uppercase tracking-[0.14em] text-muted-foreground`,children:e})]}),Q1=({text:e})=>(0,Z.jsxs)(`div`,{"aria-live":`polite`,className:`flex items-center gap-2 px-1 py-3 text-sm text-muted-foreground`,role:`status`,children:[(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{children:e})]}),$1=()=>(0,Z.jsxs)(`div`,{className:`space-y-3`,"data-testid":`mobile-overview-skeleton`,children:[(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(hu,{className:`border-b border-border/70 pb-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(Ec,{className:`h-6 w-28`}),(0,Z.jsx)(Ec,{className:`h-6 w-28 rounded-full`})]})}),(0,Z.jsxs)(yu,{className:`space-y-4 pt-5`,children:[(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:Array.from({length:6},(e,t)=>(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(Ec,{className:`h-6 w-10`}),(0,Z.jsx)(Ec,{className:`mt-2 h-3 w-16`})]},t))}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,Z.jsx)(Ec,{className:`h-10 w-full rounded-xl`}),(0,Z.jsx)(Ec,{className:`h-10 w-full rounded-xl`})]})]})]}),(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(hu,{children:(0,Z.jsx)(Ec,{className:`h-6 w-20`})}),(0,Z.jsx)(yu,{children:(0,Z.jsx)(Ec,{className:`h-10 w-40 rounded-xl`})})]})]}),e0=({isLoggingOut:e,onLogout:t})=>(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsx)(hu,{children:(0,Z.jsx)(gu,{children:`Session`})}),(0,Z.jsx)(yu,{children:(0,Z.jsxs)(K,{variant:`destructive`,className:`gap-2`,disabled:e,onClick:t,children:[(0,Z.jsx)(K$,{className:`h-4 w-4`}),e?`Logging out...`:`Log out this phone`]})})]}),t0=({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r})=>{let i=r?.agent_status===`running`||!!n?.some(e=>e.agent_status===`running`);if(e?.kind===`ticket`)return{label:`Ticket run active`,variant:`success`};if(i)return{label:`Chat active`,variant:`success`};if(e)return{label:`Project run active`,variant:`success`};let a=t?.filter(e=>e.agent_status===`running`&&e.parked_at===null)??[];return a.some(e=>e.state===`review`)?{label:`Reviewing`,variant:`warning`}:a.some(e=>e.state===`build`)?{label:`Building`,variant:`success`}:a.some(e=>e.state===`plan`)?{label:`Planning`,variant:`info`}:{label:`Idle`,variant:`outline`}},n0=({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r})=>{let i=t0({activeRun:e,tickets:t,chatSessions:n,chatSessionDetail:r});return(0,Z.jsx)(U,{variant:i.variant,children:i.label})},r0=({selectedProjectId:e,summary:t,tickets:n,error:r,chatSessions:i,chatSessionDetail:a,onRetry:o,onOpenTickets:s,onOpenChats:c})=>{let l=j1.Icon,u=M1.Icon;return r?(0,Z.jsx)(X1,{title:`Project summary unavailable`,description:r,action:(0,Z.jsx)(K,{variant:`warning`,onClick:o,children:`Retry summary`})}):e?!t||t.project.id!==e?(0,Z.jsx)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:(0,Z.jsx)(yu,{className:`pt-5 text-sm text-muted-foreground`,children:`Loading project summary...`})}):(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:[(0,Z.jsxs)(hu,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(gu,{children:`Overview`}),(0,Z.jsx)(vu,{children:(0,Z.jsx)(n0,{activeRun:t.active_run,tickets:n,chatSessions:i,chatSessionDetail:a})})]}),(0,Z.jsxs)(yu,{className:`space-y-4 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:[(0,Z.jsx)(Z1,{label:`Tickets`,value:t.tickets.total}),(0,Z.jsx)(Z1,{label:`Plan`,value:t.tickets.plan,accentClassName:`text-sky-200`}),(0,Z.jsx)(Z1,{label:`Build`,value:t.tickets.build,accentClassName:`text-emerald-200`}),(0,Z.jsx)(Z1,{label:`Review`,value:t.tickets.review,accentClassName:`text-amber-200`}),(0,Z.jsx)(Z1,{label:`Done`,value:t.tickets.parked}),(0,Z.jsx)(Z1,{label:`Bundles`,value:t.project.bundle_count??0})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,Z.jsxs)(K,{variant:`outline`,className:`gap-2`,"aria-label":j1.ctaAriaLabel,onClick:s,children:[(0,Z.jsx)(l,{className:`h-4 w-4`}),j1.label]}),(0,Z.jsxs)(K,{variant:`outline`,className:`gap-2`,"aria-label":M1.ctaAriaLabel,onClick:c,children:[(0,Z.jsx)(u,{className:`h-4 w-4`}),M1.label]})]})]})]}):(0,Z.jsx)(X1,{title:`Choose a project`,description:`Select a desktop project before opening tickets or chats from this phone.`})},i0=e=>e.parked_at?`parked`:e.state,a0=e=>{let t=i0(e);return t===`parked`?`Done`:`${t.slice(0,1).toUpperCase()}${t.slice(1)}`},o0=e=>e===`plan`?`info`:e===`build`?`success`:e===`review`?`warning`:`outline`,s0=({ticket:e,isSelected:t,onSelectTicket:n,className:r})=>(0,Z.jsxs)(`button`,{type:`button`,className:G(`w-full rounded-2xl border px-4 py-3 text-left transition-colors`,t?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`,r),onClick:()=>n(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.title})}),(0,Z.jsx)(U,{variant:o0(i0(e)),children:a0(e)})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:[e.agent_status?(0,Z.jsx)(`span`,{children:e.agent_status}):null,e.branch?(0,Z.jsx)(`span`,{children:e.branch}):null,e.bundle?.name?(0,Z.jsx)(`span`,{children:e.bundle.name}):null]})]}),c0=({group:e,selectedBundleId:t,selectedTicketId:n,onSelectBundle:r,onSelectTicket:i})=>{let a=e.bundle.id===t,o=e.tickets.some(e=>e.id===n),[s,c]=(0,Y.useState)(o),l=Tl(e.bundle)||e.bundle.branch||e.bundle.name||`Bundle`,u=e.tickets.filter(e=>e.agent_status===`running`).length,d=a||o;return(0,Y.useEffect)(()=>{o&&c(!0)},[o]),(0,Z.jsxs)($u,{open:s,onOpenChange:c,children:[(0,Z.jsxs)(`div`,{className:G(`flex items-start gap-2 rounded-2xl border px-4 py-3 transition-colors`,d?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`),children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,"aria-label":`Open bundle ${l}`,onClick:()=>r(e.bundle.id),children:(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(U,{variant:`outline`,children:`Bundle`}),(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:l})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[e.tickets.length,` ticket`,e.tickets.length===1?``:`s`]}),u>0?(0,Z.jsxs)(`span`,{children:[u,` running`]}):null,e.bundle.branch?(0,Z.jsx)(`span`,{children:e.bundle.branch}):null]})]})})}),(0,Z.jsx)(ed,{asChild:!0,children:(0,Z.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mt-0.5 shrink-0`,"aria-label":`Toggle bundle tickets for ${l}`,children:(0,Z.jsx)(Oe,{className:G(`h-4 w-4 transition-transform`,s&&`rotate-180`)})})})]}),(0,Z.jsx)(td,{className:`pt-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2 pl-3`,children:e.tickets.map(t=>(0,Z.jsx)(s0,{ticket:t,isSelected:t.id===n,onSelectTicket:t=>i(t,e.bundle.id),className:`rounded-xl`},t.id))})})]})},l0=(e,t)=>bl(e,[],t),u0=e=>[{key:`plan`,label:`Plan`,tickets:e.filter(e=>!e.parked_at&&e.state===`plan`),items:l0(e.filter(e=>!e.parked_at&&e.state===`plan`),`plan`)},{key:`build`,label:`Build`,tickets:e.filter(e=>!e.parked_at&&e.state===`build`),items:l0(e.filter(e=>!e.parked_at&&e.state===`build`),`build`)},{key:`review`,label:`Review`,tickets:e.filter(e=>!e.parked_at&&e.state===`review`),items:l0(e.filter(e=>!e.parked_at&&e.state===`review`),`review`)},{key:`parked`,label:`Done`,tickets:e.filter(e=>e.parked_at),items:l0(e.filter(e=>e.parked_at),`done`)}].filter(e=>e.tickets.length>0),d0=(e,t)=>{if(!e)return e;let n=new Map(t.tickets.map(e=>[e.id,e]));return e.map(e=>n.get(e.id)??e)},f0=({selectedProjectId:e,tickets:t,selectedBundleId:n,selectedTicketId:r,error:i,onRetry:a,onSelectBundle:o,onSelectTicket:s})=>{if(!e)return(0,Z.jsx)(X1,{title:`Choose a project`,description:`Select a project before browsing tickets from this phone.`});if(i)return(0,Z.jsx)(X1,{title:`Tickets unavailable`,description:i,action:(0,Z.jsx)(K,{variant:`warning`,onClick:a,children:`Retry tickets`})});if(!t)return(0,Z.jsx)(mu,{className:`border-border/80 bg-card/70 shadow-none`,children:(0,Z.jsx)(yu,{className:`pt-5 text-sm text-muted-foreground`,children:`Loading tickets...`})});if(t.length===0)return(0,Z.jsx)(X1,{title:`No tickets`,description:`This project does not have any tickets yet.`});let c=u0(t);return(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none lg:flex lg:min-h-0 lg:flex-col`,children:[(0,Z.jsxs)(hu,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(gu,{children:`Tickets`}),(0,Z.jsxs)(_u,{children:[t.length,` total`]})]}),(0,Z.jsx)(yu,{className:`space-y-4 pt-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto`,children:c.map(e=>(0,Z.jsxs)(`section`,{className:`space-y-2`,"aria-label":`${e.label} tickets`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`span`,{children:e.tickets.length})]}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.items.map(e=>e.kind===`bundle`?(0,Z.jsx)(c0,{group:e.group,selectedBundleId:n,selectedTicketId:r,onSelectBundle:o,onSelectTicket:s},e.group.id):(0,Z.jsx)(s0,{ticket:e.ticket,isSelected:e.ticket.id===r,onSelectTicket:e=>s(e,null)},e.ticket.id))})]},e.key))})]})},p0=({selectedProjectId:e,chatSessions:t,selectedChatSessionId:n,error:r,onRetry:i,onOpenNewChat:a,onSelectChat:o})=>e?r?(0,Z.jsx)(X1,{title:`Chats unavailable`,description:r,action:(0,Z.jsx)(K,{variant:`warning`,onClick:i,children:`Retry chats`})}):(0,Z.jsxs)(mu,{className:`border-border/80 bg-card/70 shadow-none lg:flex lg:min-h-0 lg:flex-col`,children:[(0,Z.jsxs)(hu,{className:`border-b border-border/70 pb-4`,children:[(0,Z.jsx)(gu,{children:`Chats`}),(0,Z.jsx)(_u,{children:t?`${t.length} recent`:`Loading chats...`}),(0,Z.jsx)(vu,{children:(0,Z.jsx)(K,{variant:`outline`,size:`sm`,onClick:a,children:`New chat`})})]}),(0,Z.jsx)(yu,{className:`space-y-2 pt-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto`,children:t?t.length===0?(0,Z.jsx)(X1,{title:`No chats`,description:`Start a new chat to plan or build from this project.`,action:(0,Z.jsx)(K,{onClick:a,children:`Start a chat`})}):t.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:G(`w-full rounded-xl border px-3 py-2.5 text-left transition-colors`,e.id===n?`border-primary/50 bg-primary/10`:`border-border/70 bg-card/40 hover:border-primary/30 hover:bg-accent/50`),onClick:()=>o(e.id),children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 pr-2 text-sm font-medium text-foreground line-clamp-2 break-words`,children:e.title}),(0,Z.jsx)(U,{variant:e.agent_status===`running`?`warning`:e.mode===`plan`?`info`:`success`,children:e.agent_status??e.mode})]})},e.id)):(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading chats...`})})]}):(0,Z.jsx)(X1,{title:`Choose a project`,description:`Select a project before browsing chats from this phone.`}),m0=({label:e,disabled:t,onClick:n})=>(0,Z.jsx)(K,{type:`button`,variant:`outline`,disabled:t,onClick:n,children:e}),h0=e=>{let t=e.tickets.filter(e=>!e.parked_at),n=t.filter(e=>e.state===`plan`),r=t.filter(e=>e.state===`build`),i=t.filter(e=>e.state===`review`),a=t.some(e=>e.agent_status===`running`),o=t.find(e=>Tw(e)&&e.agent_status===`running`&&!!e.session_id)??null,s=t.find(e=>Tw(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,c=[];n.length>0&&c.push({id:`build`,label:`Build Bundle`,pendingLabel:`Building Bundle...`,ariaLabel:`Build Bundle`,disabled:!1,disabledReason:null});let l=r.length>0&&r.every(e=>e.agent_status===`done`),u=r.length===0&&i.length>0&&e.can_re_review===!0&&!a;return(l||u)&&c.push({id:`review`,label:u?`Re-run review`:`Review Bundle`,pendingLabel:`Reviewing Bundle...`,ariaLabel:u?`Re-run review`:`Review Bundle`,disabled:!1,disabledReason:null}),o&&c.push({id:`pause-build`,label:`Pause Build`,pendingLabel:`Pausing Build...`,ariaLabel:`Pause Build`,title:`Pause the build session. You can resume it later.`,disabled:!1,disabledReason:null}),!o&&s&&c.push({id:`resume-build`,label:`Resume`,pendingLabel:`Resuming...`,ariaLabel:`Resume`,disabled:!1,disabledReason:null}),{actions:c,runningBuildTicketId:o?.id??null,resumableBuildTicketId:s?.id??null}},g0=({ticket:e,actionState:t,actionError:n,onAction:r})=>{let i=qW(e,{reviewLabel:e.worktree_bundle_id===null?`Review`:`Review Bundle`}),a=e.worktree_bundle_id===null&&e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`&&!e.parked_at?[{id:`review`,label:`Re-run review`,pendingLabel:`Re-running review...`,ariaLabel:`Re-run review`,disabled:!1,disabledReason:null},...i]:i;return a.length===0?null:(0,Z.jsx)(GW,{actions:a,activeAction:t,disableWhenActive:!0,className:`space-y-3`,heading:`Actions`,headingClassName:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,actionsClassName:`flex flex-wrap gap-2`,showDisabledReason:!0,disabledReasonClassName:`text-sm text-amber-200`,error:n,errorClassName:`text-sm text-red-200`,renderAction:({action:e,label:t,disabled:n})=>(0,Z.jsx)(m0,{label:t,disabled:n,onClick:()=>r(e.id)},e.id)})},_0=({bundleDetail:e,actionState:t,actionError:n,onAction:r})=>{let{actions:i}=h0(e);return i.length===0?null:(0,Z.jsx)(GW,{actions:i,activeAction:t,disableWhenActive:!0,className:`space-y-3`,heading:`Actions`,headingClassName:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,actionsClassName:`flex flex-wrap gap-2`,error:n,errorClassName:`text-sm text-red-200`,renderAction:({action:e,label:t,disabled:n})=>(0,Z.jsx)(m0,{label:t,disabled:n,onClick:()=>r(e.id)},e.id)})},v0=(e,t)=>(e??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,created_at:e.created_at,ticket_id:t??null,ticket_proposals:`ticket_proposals`in e?e.ticket_proposals??null:null})),y0=({title:e,subtitle:t,badges:n,backLabel:r,onBack:i,action:a})=>(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[i?(0,Z.jsxs)(K,{variant:`ghost`,size:`sm`,className:`h-8 px-2.5 lg:hidden`,"aria-label":r,onClick:i,children:[(0,Z.jsx)(nT,{className:`h-4 w-4`}),`Back`]}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e}),t?(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t}):null]})]}),a?(0,Z.jsx)(`div`,{className:`shrink-0`,children:a}):null]}),n?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n}):null]}),b0=({title:e,backLabel:t,onBack:n,action:r})=>(0,Z.jsxs)(`div`,{className:`-mx-3 flex shrink-0 items-center justify-between gap-3 border-b border-border/80 bg-background/95 px-3 py-2.5 backdrop-blur supports-[backdrop-filter]:bg-background/85 sm:-mx-4 sm:px-4 lg:hidden`,children:[(0,Z.jsxs)(K,{variant:`ghost`,size:`sm`,className:`h-8 px-2.5`,"aria-label":t,onClick:n,children:[(0,Z.jsx)(nT,{className:`h-4 w-4`}),`Back`]}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:r})]}),x0=({title:e,backLabel:t,onBack:n,action:r,subheader:i,children:a})=>(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(b0,{title:e,backLabel:t,onBack:n,action:r}),i?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-border/70 py-2 lg:hidden`,children:i}):null,(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:a})]}),S0=({value:e,onTranscript:t,onDetails:n})=>(0,Z.jsxs)(`div`,{className:`flex gap-2 px-3 sm:px-0`,children:[(0,Z.jsx)(K,{type:`button`,variant:e===`transcript`?`secondary`:`ghost`,className:`h-9 flex-1`,"aria-pressed":e===`transcript`,onClick:t,children:`Transcript`}),(0,Z.jsx)(K,{type:`button`,variant:e===`details`?`secondary`:`ghost`,className:`h-9 flex-1`,"aria-pressed":e===`details`,onClick:n,children:`Details`})]}),C0=({controls:e})=>{let[t,n]=(0,Y.useState)(!1);return(0,Z.jsxs)($u,{open:t,onOpenChange:n,children:[(0,Z.jsx)(`div`,{className:`px-1 pb-1`,children:(0,Z.jsx)(ed,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 gap-1.5 px-2 text-xs text-muted-foreground`,children:[`Options`,(0,Z.jsx)(Oe,{className:G(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]})})}),(0,Z.jsx)(td,{className:`px-1 pb-1`,children:(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-background/35 p-2`,children:e})})]})},w0=({ticket:e})=>{let t=[{label:`State`,value:a0(e)},{label:`Tool`,value:e.tool},{label:`Agent`,value:e.agent_status},{label:`Branch`,value:e.branch},{label:`Bundle`,value:e.bundle?.name??null},{label:`Model`,value:e.model},{label:`Variant`,value:e.variant}].filter(e=>!!e.value);return t.length===0?null:(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-xl border border-border/70 bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Details`}),(0,Z.jsx)(`dl`,{className:`grid gap-2 text-sm sm:grid-cols-2`,children:t.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-lg border border-border/60 bg-background/50 px-3 py-2`,children:[(0,Z.jsx)(`dt`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,Z.jsx)(`dd`,{className:`break-words text-foreground`,children:e.value})]},e.label))})]})},T0=({ticket:e,badges:t,actionState:n,actionError:r,onAction:i,className:a})=>(0,Z.jsxs)(mu,{className:G(`flex min-h-0 min-w-0 flex-col border-border/80 bg-card/70 shadow-none`,a),children:[(0,Z.jsx)(hu,{className:`min-w-0 pb-3`,children:(0,Z.jsx)(y0,{title:e.title,badges:t})}),(0,Z.jsxs)(yu,{className:`min-h-0 min-w-0 flex-1 space-y-3 overflow-y-auto pt-0`,children:[(0,Z.jsx)(g0,{ticket:e,actionState:n,actionError:r,onAction:i}),e.description?(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-xl border border-border/70 bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Description`}),(0,Z.jsx)(HM,{content:e.description,className:`min-w-0 text-foreground`})]}):null,(0,Z.jsx)(w0,{ticket:e})]})]}),E0=({bundleDetail:e,title:t,subtitle:n,badges:r,actionState:i,actionError:a,onAction:o,orderedTickets:s,highlightedTicketId:c,isTicketListOpen:l,onTicketListOpenChange:u,onSelectTicket:d,className:f})=>(0,Z.jsxs)(mu,{className:G(`flex min-h-0 min-w-0 flex-col border-border/80 bg-card/70 shadow-none`,f),children:[(0,Z.jsx)(hu,{className:`min-w-0 pb-3`,children:(0,Z.jsx)(y0,{title:t,subtitle:n,badges:r})}),(0,Z.jsxs)(yu,{className:`min-h-0 min-w-0 flex-1 space-y-3 overflow-y-auto pt-0`,children:[(0,Z.jsx)(_0,{bundleDetail:e,actionState:i,actionError:a,onAction:o}),(0,Z.jsxs)($u,{open:l,onOpenChange:u,children:[(0,Z.jsx)(ed,{asChild:!0,children:(0,Z.jsxs)(K,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs text-muted-foreground`,children:[`Tickets`,(0,Z.jsx)(Oe,{className:G(`h-3.5 w-3.5 transition-transform`,l&&`rotate-180`)})]})}),(0,Z.jsx)(td,{className:`pt-2`,children:(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-background/35 p-3`,children:(0,Z.jsx)(gG,{tickets:s,highlightedTicketId:c,onOpenTicketDetails:e=>d(e.id,e.worktree_bundle_id)})})})]})]})]}),D0=({selectedProjectId:e,bundleId:t,bundleDetail:n,openNonce:r,mobileDetailView:i,error:a,actionState:o,actionError:s,followUpPrompt:c,isSendingFollowUp:l,followUpError:u,availableModels:d,onBack:f,onRetry:p,onAction:m,onDetailViewChange:h,onSelectTicket:g,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y,isLargeScreen:b})=>{let[x,S]=(0,Y.useState)(!0);if((0,Y.useEffect)(()=>{S(!0)},[t,r]),!e)return(0,Z.jsx)(X1,{title:`Choose a project`,description:`Select a project before opening bundle details from this phone.`});if(!t)return(0,Z.jsx)(X1,{title:`Choose a bundle`,description:`Open a bundle to review its transcript and grouped ticket progress.`});if(a)return(0,Z.jsx)(x0,{title:`Bundle unavailable`,backLabel:`Back to tickets`,onBack:f,children:(0,Z.jsx)(X1,{title:`Bundle unavailable`,description:a,action:(0,Z.jsx)(K,{variant:`warning`,onClick:p,children:`Retry bundle`})})});if(!n||n.bundle.id!==t)return(0,Z.jsx)(x0,{title:`Loading bundle`,backLabel:`Back to tickets`,onBack:f,children:(0,Z.jsx)(Q1,{text:`Loading bundle details...`})});let C=Tl(n.bundle)||n.bundle.branch||n.bundle.name||`Bundle`,w=new Map(d.map(e=>[e.id,e.label])),T=xG(n.tickets,w),E=wG(n),D=SG(n.tickets,n.execution_order_ticket_ids),O=CG(n.tickets,w,T,n.execution_order_ticket_ids),k=lT(n.tickets,E?.state??null),A=n.tickets.find(e=>e.agent_status===`running`)??E,j=A??E??n.tickets[0]??null,M=A?.agent_status===`running`?T[A.id]??A.model??`Agent`:null,N=!!(E&&E.state!==`plan`&&vl(E)),P=n.tickets.some(e=>e.agent_status===`running`)?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,F=`mobile-bundle:${n.bundle.id}:${r}`,I=`${n.tickets.length} ticket${n.tickets.length===1?``:`s`}`,L=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(iT,{status:k}),(0,Z.jsx)(U,{variant:`outline`,children:I}),j?(0,Z.jsxs)(U,{variant:`outline`,children:[`Target: `,j.title]}):null]});return(0,Z.jsx)(x0,{title:C,backLabel:`Back to tickets`,onBack:f,subheader:b?void 0:(0,Z.jsx)(S0,{value:i,onTranscript:()=>h(`transcript`),onDetails:()=>h(`details`)}),children:b?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden pt-3`,children:[(0,Z.jsx)(E0,{bundleDetail:n,title:C,subtitle:n.bundle.branch,badges:L,actionState:o,actionError:s,onAction:m,orderedTickets:D,highlightedTicketId:n.target_ticket_id,isTicketListOpen:x,onTicketListOpenChange:S,onSelectTicket:g,className:`shrink-0`}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(pG,{projectId:e,followUpTicketId:n.target_ticket_id,messages:O,internalLog:A?.agent_log??null,currentThinkingMessageId:A?.agent_message_id??E?.agent_message_id??null,legacyThinkingTicketId:A?.id??E?.id??null,previousThinkingLog:A?.previous_agent_log??E?.previous_agent_log??null,previousThinkingMessageId:A?.previous_agent_message_id??E?.previous_agent_message_id??null,pendingAgentTitle:M,streamingResponse:A?.streaming_response??null,isRunning:n.tickets.some(e=>e.agent_status===`running`),canShowComposer:N,composerTheme:Cw(E?.state??null),layoutKey:F,scrollLayoutKey:F,followUpPrompt:c,followUpPlaceholder:j?`Follow up on: ${j.title}`:`Follow up on this bundle`,isSendingFollowUp:l,followUpDisabledReason:P,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y},F)}),u?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-red-200`,children:u}):null]}):i===`details`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(E0,{bundleDetail:n,title:C,subtitle:n.bundle.branch,badges:L,actionState:o,actionError:s,onAction:m,orderedTickets:D,highlightedTicketId:n.target_ticket_id,isTicketListOpen:x,onTicketListOpenChange:S,onSelectTicket:g,className:`h-full`})}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(pG,{projectId:e,followUpTicketId:n.target_ticket_id,messages:O,internalLog:A?.agent_log??null,currentThinkingMessageId:A?.agent_message_id??E?.agent_message_id??null,legacyThinkingTicketId:A?.id??E?.id??null,previousThinkingLog:A?.previous_agent_log??E?.previous_agent_log??null,previousThinkingMessageId:A?.previous_agent_message_id??E?.previous_agent_message_id??null,pendingAgentTitle:M,streamingResponse:A?.streaming_response??null,isRunning:n.tickets.some(e=>e.agent_status===`running`),canShowComposer:N,composerTheme:Cw(E?.state??null),layoutKey:F,scrollLayoutKey:F,followUpPrompt:c,followUpPlaceholder:j?`Follow up on: ${j.title}`:`Follow up on this bundle`,isSendingFollowUp:l,followUpDisabledReason:P,onFollowUpPromptChange:_,onFollowUpKeyDown:v,onFollowUpSubmit:y},F),u?(0,Z.jsx)(`p`,{className:`shrink-0 px-1 pt-2 text-sm text-red-200`,children:u}):null]})})},O0=({selectedProjectId:e,chatSession:t,chatSessionId:n,openNonce:r,error:i,isStopping:a,composerMode:o,composerTool:s,prompt:c,selectedModel:l,selectedVariant:u,selectedSkills:d,availableModels:f,availableSkills:p,isLoadingAgentSettings:m,isSending:h,isUpdatingMode:g,composerDisabledReason:_,onBack:v,onRetry:y,onStop:b,onModeChange:x,onPromptChange:S,onModelChange:C,onVariantChange:w,onSkillsChange:T,onPromptKeyDown:E,onSubmit:D,isLargeScreen:O})=>{if(!e)return(0,Z.jsx)(X1,{title:`Choose a project`,description:`Select a project before opening the chat workspace.`});if(n&&i)return(0,Z.jsx)(X1,{title:`Chat unavailable`,description:i,action:(0,Z.jsx)(K,{variant:`warning`,onClick:y,children:`Retry chat`})});if(n&&(!t||t.id!==n))return(0,Z.jsx)(x0,{title:`Loading chat`,backLabel:`Back to chats`,onBack:v,children:(0,Z.jsx)(Q1,{text:`Loading chat transcript...`})});let k=t?.mode??o,A=s===`opencode`&&f.length>0,j=f.find(e=>e.id===l)??null,M=v0(t?.messages),N=t?.agent_status===`running`?(0,Z.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a,onClick:b,children:[a?(0,Z.jsx)(pe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Nc,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:a?`Interrupting...`:`Interrupt`})]}):null,P=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{variant:k===`plan`?`info`:`success`,children:k}),(0,Z.jsx)(U,{variant:`outline`,children:t?.tool??s}),t?.agent_status?(0,Z.jsx)(U,{variant:`outline`,children:t.agent_status}):null]}),F=A?(0,Z.jsx)(xP,{model:l,variant:u,skills:d,showModelSelector:!0,showSkillsSelector:!0,availableModels:f,availableSkills:p,selectedModel:j,onModelChange:C,onVariantChange:w,onSkillsChange:T,modelSelectId:`mobile-chat-model-selector`,variantSelectId:`mobile-chat-variant-selector`,skillsSelectId:`mobile-chat-skills-selector`,disabled:!!_||h}):s===`opencode`&&m?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading model controls...`}):null,I=!O&&F?(0,Z.jsx)(C0,{controls:F}):F,L=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,Z.jsx)(HX,{value:k,disabled:!!_||h||g,onChange:x})}),R=O?void 0:({showThinkingControl:e})=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-1`,children:[L,(0,Z.jsx)(`div`,{className:`ml-auto`,children:e})]}),z=`mobile-chat:${n??`new`}:${r}`;return(0,Z.jsx)(x0,{title:t?.title??`New chat`,backLabel:`Back to chats`,onBack:v,action:N,children:(0,Z.jsx)(VX,{projectId:e,messages:M,internalLog:t?.agent_log??null,currentThinkingMessageId:t?.agent_message_id??null,previousThinkingLog:t?.previous_agent_log??null,previousThinkingMessageId:t?.previous_agent_message_id??null,pendingAgentTitle:t?.title??`Archon`,streamingResponse:t?.streaming_response??null,isRunning:t?.agent_status===`running`,canShowComposer:!0,header:O?(0,Z.jsx)(y0,{title:t?.title??`New chat`,subtitle:t?.target_label_snapshot??`Project root`,badges:P}):R,composerControls:O?L:void 0,composerInlineControls:I,composerTheme:k,forceScrollToBottomKey:z,layoutKey:z,scrollLayoutKey:z,composerFocusNonce:r,blurComposerOnSendStart:!O,followUpPrompt:c,followUpPlaceholder:n?`Continue this chat`:k===`plan`?`Ask Archon to scope or reason through project work`:`Ask Archon to build or verify something in this project`,emptyStateText:n?`No messages yet.`:`Start a new project chat from this phone.`,isSendingFollowUp:h,followUpDisabledReason:_??void 0,hidePendingAgentTitle:!O,onFollowUpPromptChange:S,onFollowUpKeyDown:E,onFollowUpSubmit:D},z)})},k0=({selectedProjectId:e,ticketId:t,ticket:n,openNonce:r,error:i,actionState:a,actionError:o,followUpPrompt:s,followUpSelectedModel:c,followUpSelectedVariant:l,followUpSelectedSkills:u,availableModels:d,availableSkills:f,isLoadingAgentSettings:p,isSendingFollowUp:m,followUpError:h,onBack:g,onRetry:_,onAction:v,onFollowUpPromptChange:y,onFollowUpModelChange:b,onFollowUpVariantChange:x,onFollowUpSkillsChange:S,onFollowUpKeyDown:C,onFollowUpSubmit:w,isLargeScreen:T})=>{let[E,D]=(0,Y.useState)(`transcript`);if((0,Y.useEffect)(()=>{D(`transcript`)},[r,t]),!e)return(0,Z.jsx)(X1,{title:`Choose a project`,description:`Select a project before opening ticket details from this phone.`});if(!t)return(0,Z.jsx)(X1,{title:`Choose a ticket`,description:`Open a ticket to review its transcript and continue the workflow.`});if(i)return(0,Z.jsx)(X1,{title:`Ticket unavailable`,description:i,action:(0,Z.jsx)(K,{variant:`warning`,onClick:_,children:`Retry ticket`})});if(!n||n.id!==t)return(0,Z.jsx)(x0,{title:`Loading ticket`,backLabel:`Back to tickets`,onBack:g,children:(0,Z.jsx)(Q1,{text:`Loading ticket details...`})});let O=JW(n,{requireWorktree:!0}),k=v0(n.messages,n.id),A=d.find(e=>e.id===c)??null,j=n.tool===`opencode`&&d.length>0?(0,Z.jsx)(xP,{model:c,variant:l,skills:u,showModelSelector:!0,showSkillsSelector:!0,availableModels:d,availableSkills:f,selectedModel:A,onModelChange:b,onVariantChange:x,onSkillsChange:S,modelSelectId:`mobile-ticket-follow-up-model-selector`,variantSelectId:`mobile-ticket-follow-up-variant-selector`,skillsSelectId:`mobile-ticket-follow-up-skills-selector`,disabled:!!O.disabledReason||m}):n.tool===`opencode`&&p?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading model controls...`}):null,M=!T&&j?(0,Z.jsx)(C0,{controls:j}):j,N=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{variant:o0(i0(n)),children:a0(n)}),n.tool?(0,Z.jsx)(U,{variant:`outline`,children:n.tool}):null,n.agent_status?(0,Z.jsx)(U,{variant:`outline`,children:n.agent_status}):null,n.branch?(0,Z.jsx)(U,{variant:`outline`,children:n.branch}):null,n.bundle?.name?(0,Z.jsx)(U,{variant:`outline`,children:n.bundle.name}):null]}),P=`mobile-ticket:${n.id}:${r}`,F=(0,Z.jsx)(S0,{value:E,onTranscript:()=>D(`transcript`),onDetails:()=>D(`details`)});return(0,Z.jsx)(x0,{title:n.title,backLabel:`Back to tickets`,onBack:g,subheader:T?void 0:F,children:T?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden pt-3`,children:[(0,Z.jsx)(T0,{ticket:n,badges:N,actionState:a,actionError:o,onAction:v,className:`shrink-0`}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(HN,{projectId:e,followUpTicketId:n.id,messages:k,internalLog:n.agent_log??null,currentThinkingMessageId:n.agent_message_id??null,previousThinkingLog:n.previous_agent_log??null,previousThinkingMessageId:n.previous_agent_message_id??null,pendingAgentTitle:n.title,streamingResponse:n.streaming_response??null,isRunning:n.agent_status===`running`,canShowComposer:!0,followUpComposerControls:j,composerTheme:n.state,forceScrollToBottomKey:P,layoutKey:P,scrollLayoutKey:P,followUpPrompt:s,followUpPlaceholder:O.placeholder,emptyStateText:`No follow-up messages yet.`,isSendingFollowUp:m,followUpDisabledReason:O.disabledReason??void 0,onFollowUpPromptChange:y,onFollowUpKeyDown:C,onFollowUpSubmit:w},P)}),h?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-red-200`,children:h}):null]}):E===`details`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(T0,{ticket:n,badges:N,actionState:a,actionError:o,onAction:v,className:`h-full`})}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Z.jsx)(HN,{projectId:e,followUpTicketId:n.id,messages:k,internalLog:n.agent_log??null,currentThinkingMessageId:n.agent_message_id??null,previousThinkingLog:n.previous_agent_log??null,previousThinkingMessageId:n.previous_agent_message_id??null,pendingAgentTitle:n.title,streamingResponse:n.streaming_response??null,isRunning:n.agent_status===`running`,canShowComposer:!0,followUpComposerControls:M,composerTheme:n.state,surfaceVariant:`chat`,composerSize:`compact-on-laptop`,forceScrollToBottomKey:P,layoutKey:P,scrollLayoutKey:P,followUpPrompt:s,followUpPlaceholder:O.placeholder,emptyStateText:`No follow-up messages yet.`,isSendingFollowUp:m,followUpDisabledReason:O.disabledReason??void 0,onFollowUpPromptChange:y,onFollowUpKeyDown:C,onFollowUpSubmit:w},P),h?(0,Z.jsx)(`p`,{className:`shrink-0 px-1 pt-2 text-sm text-red-200`,children:h}):null]})})},A0=()=>{let e=new URLSearchParams(window.location.search),t=new URLSearchParams(window.location.hash.slice(1)),n=e.get(`mobileAccessId`)??``,r=e.get(`pairingId`)??``,i=t.get(`pairingSecret`)??``;return!n||!r||!i?null:{mobileAccessId:n,pairingId:r,pairingSecret:i}},j0=()=>{window.history.replaceState({},``,`/mobile`)},M0=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},N0=(e,t)=>e instanceof O&&e.message?e.message:t,P0=e=>({status:`authenticated`,csrfToken:e,projects:null,selectedProjectId:null,projectError:null,projectSummary:null,projectSummaryError:null,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),F0=(e=`pairing_required`)=>({status:`unauthenticated`,reason:e}),I0=e=>e instanceof O&&(e.status===401||e.status===403),L0=()=>{let[e,t]=(0,Y.useState)({status:`checking`}),[n,r]=(0,Y.useState)(`connecting`),[i,a]=(0,Y.useState)(`overview`),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(`build`),[C,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(``),[D,k]=(0,Y.useState)([]),[A,j]=(0,Y.useState)([]),[M,N]=(0,Y.useState)([]),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,ee]=(0,Y.useState)(null),[te,ne]=(0,Y.useState)(null),[V,re]=(0,Y.useState)(null),[H,ie]=(0,Y.useState)(null),[ae,oe]=(0,Y.useState)(null),[se,ce]=(0,Y.useState)(null),[le,U]=(0,Y.useState)(``),[ue,de]=(0,Y.useState)(``),[fe,pe]=(0,Y.useState)(``),[me,he]=(0,Y.useState)([]),[ge,W]=(0,Y.useState)(!1),[_e,ve]=(0,Y.useState)(null),[ye,be]=(0,Y.useState)(``),[xe,Se]=(0,Y.useState)(!1),[Ce,we]=(0,Y.useState)(null),[Te,Ee]=(0,Y.useState)(0),[De,Oe]=(0,Y.useState)(0),[ke,Ae]=(0,Y.useState)(0),[je,Me]=(0,Y.useState)(`transcript`),[Ne,Pe]=(0,Y.useState)(null),[Fe,Ie]=(0,Y.useState)(null),[Le,Re]=(0,Y.useState)(!1),[ze,Be]=(0,Y.useState)(!1),[Ve,He]=(0,Y.useState)(!1),[Ue,We]=(0,Y.useState)(null),[Ge,Ke]=(0,Y.useState)(null),qe=(0,Y.useRef)(null),Je=(0,Y.useRef)(null),Ye=(0,Y.useRef)(null),Xe=(0,Y.useRef)(null),Ze=(0,Y.useCallback)(e=>I0(e)?(t(F0(`session_revoked`)),r(`unavailable`),s(!1),l(!1),d(!1),p(!1),!0):!1,[]),Qe=(0,Y.useCallback)(async(e,n,r,i)=>{try{let a=await r1(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedTicketId!==r?t:{...t,ticketDetail:a,ticketDetailError:null})}catch(i){if(!S(i)){if(Ze(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedTicketId!==r?t:{...t,ticketDetail:null,ticketDetailError:N0(i,`Unable to load ticket details.`)})}}},[Ze]),$e=(0,Y.useCallback)(async(e,n,r,i)=>{try{let a=await i1(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedBundleId!==r?t:{...t,bundleDetail:a,bundleDetailError:null,tickets:d0(t.tickets,a)})}catch(i){if(!S(i)){if(Ze(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedBundleId!==r?t:{...t,bundleDetail:null,bundleDetailError:N0(i,`Unable to load bundle details.`)})}}},[Ze]),et=(0,Y.useCallback)(async(e,n,r)=>{try{let i=await n1(n,r);t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n)return t;let r=t.selectedTicketId&&i.some(e=>e.id===t.selectedTicketId)?t.selectedTicketId:null,a=t.selectedBundleId&&i.some(e=>e.worktree_bundle_id===t.selectedBundleId)?t.selectedBundleId:null;return{...t,tickets:i,ticketsError:null,selectedBundleId:a,bundleDetail:a?t.bundleDetail:null,bundleDetailError:a?t.bundleDetailError:null,selectedTicketId:r,ticketDetail:r?t.ticketDetail:null,ticketDetailError:r?t.ticketDetailError:null}})}catch(r){if(!S(r)){if(Ze(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,tickets:null,ticketsError:N0(r,`Unable to load project tickets.`),selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null})}}},[Ze]),q=(0,Y.useCallback)(async(e,n,r,i)=>{try{let a=await t1(n,r,i);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedChatSessionId!==r?t:{...t,chatSessionDetail:a,chatSessionDetailError:null})}catch(i){if(!S(i)){if(Ze(i))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n||t.selectedChatSessionId!==r?t:{...t,chatSessionDetail:null,chatSessionDetailError:N0(i,`Unable to load chat transcript.`)})}}},[Ze]),J=(0,Y.useCallback)(async(e,n,r)=>{try{let i=await e1(n,r);t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n)return t;let r=t.selectedChatSessionId&&i.some(e=>e.id===t.selectedChatSessionId)?t.selectedChatSessionId:null;return{...t,chatSessions:i,chatSessionsError:null,selectedChatSessionId:r,chatSessionDetail:r?t.chatSessionDetail:null,chatSessionDetailError:r?t.chatSessionDetailError:null}})}catch(r){if(!S(r)){if(Ze(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,chatSessions:null,chatSessionsError:N0(r,`Unable to load project chats.`),selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null})}}},[Ze]),tt=(0,Y.useCallback)(async(e,n,r)=>{try{let i=await Q$(n,r);t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,projectSummary:i,projectSummaryError:null})}catch(r){if(!S(r)){if(Ze(r))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e||t.selectedProjectId!==n?t:{...t,projectSummary:null,projectSummaryError:N0(r,`Unable to load the project summary.`)})}}},[Ze]),nt=(0,Y.useCallback)(async(e,t,n)=>{Be(!0);try{let e=await $$(t,n),r=qe.current;if(r&&r!==t)return;Pe(e),Ie(null),We(null)}catch(e){if(!S(e)){if(Ze(e))return;let n=qe.current;if(n&&n!==t)return;Pe(null),Ie(N0(e,`Unable to load project target options.`))}}finally{n?.aborted||Be(!1)}},[Ze]),rt=(0,Y.useCallback)(e=>{t(t=>t.status===`authenticated`?{...t,projects:t.projects?.map(t=>t.id===e.id?e:t)??t.projects,projectSummary:t.projectSummary?.project.id===e.id?{...t.projectSummary,project:e}:t.projectSummary}:t)},[]),it=(0,Y.useCallback)(async(e,n,r)=>{try{let i=await Z$(n),a=r&&i.some(e=>e.id===r)?r:i[0]?.id??null;t(t=>{if(t.status!==`authenticated`||t.csrfToken!==e)return t;let n=!!(t.selectedProjectId&&a&&t.selectedProjectId===a);return{...t,projects:i,selectedProjectId:a,projectError:null,projectSummary:n?t.projectSummary:null,projectSummaryError:n?t.projectSummaryError:null,chatSessions:n?t.chatSessions:null,chatSessionsError:n?t.chatSessionsError:null,selectedChatSessionId:n?t.selectedChatSessionId:null,chatSessionDetail:n?t.chatSessionDetail:null,chatSessionDetailError:n?t.chatSessionDetailError:null,tickets:n?t.tickets:null,ticketsError:n?t.ticketsError:null,selectedBundleId:n?t.selectedBundleId:null,bundleDetail:n?t.bundleDetail:null,bundleDetailError:n?t.bundleDetailError:null,selectedTicketId:n?t.selectedTicketId:null,ticketDetail:n?t.ticketDetail:null,ticketDetailError:n?t.ticketDetailError:null}});let o=a?i.find(e=>e.id===a)??null:null;a&&(tt(e,a,n),o?.active_target_kind===`bundle`&&nt(e,a,n),J(e,a,n),et(e,a,n))}catch(n){if(!S(n)){if(Ze(n))return;t(t=>t.status!==`authenticated`||t.csrfToken!==e?t:{...t,projects:t.projects??[],projectError:N0(n,`Unable to load projects from desktop Archon.`)})}}},[Ze,J,tt,nt,et]),at=(0,Y.useCallback)(async e=>{t({status:`checking`}),r(`connecting`);try{let n=await w1(e);if(n.authenticated&&n.csrf_token){r(`connecting`),t(P0(n.csrf_token)),it(n.csrf_token,e,n.preferred_project_id);return}t(F0())}catch(e){S(e)||t({status:`error`,message:N0(e,`Mobile access is unavailable. Make sure it is still enabled on desktop Archon.`)})}},[it]),ot=(0,Y.useCallback)((e,n,i)=>{r(`connecting`),t(P0(e)),it(e,i,n)},[it]);(0,Y.useEffect)(()=>{let e=new AbortController;if(window.location.pathname===`/mobile/pair`){let n=A0();return j0(),n?(t({status:`pairing`}),T1(n,e.signal).then(e=>{t({status:`pairing_confirmation`,payload:n,displayCode:e.display_code,expiresAt:e.expires_at,error:null})}).catch(e=>{t({status:`error`,message:N0(e,`Pairing failed. Regenerate the pairing link from desktop Archon and try again.`)})}),()=>e.abort()):(t({status:`error`,message:`Pairing link is missing required pairing details.`}),()=>e.abort())}return at(e.signal),()=>e.abort()},[ot,at]);let st=e.status===`authenticated`?e.csrfToken:null,ct=e.status===`authenticated`?e.selectedProjectId:null,lt=e.status===`authenticated`?e.selectedChatSessionId:null,ut=e.status===`authenticated`?e.selectedBundleId:null,dt=e.status===`authenticated`?e.selectedTicketId:null,ft=e.status===`authenticated`?e.projects?.find(t=>t.id===e.selectedProjectId)??null:null,pt=e.status===`authenticated`?e.chatSessionDetail:null,mt=e.status===`authenticated`?e.bundleDetail:null,ht=e.status===`authenticated`?e.ticketDetail:null,gt=L1(ft,Ne),_t=ze&&(!ft||ft.active_target_kind===`bundle`),vt=H1(),X=pt?.tool??`opencode`,yt=e.status!==`authenticated`||!e.selectedProjectId?`Choose a project before sending a prompt.`:R?`Wait for the chat mode change before sending another prompt.`:pt?.agent_status===`running`?`Stop or wait for the current response before sending another prompt.`:null,bt=!vt&&(i===`tickets`&&(u&&!!dt||c&&!!ut)||i===`chats`&&f);(0,Y.useEffect)(()=>{qe.current=ct},[ct]),(0,Y.useEffect)(()=>{ct||(Pe(null),Ie(null),We(null),Re(!1),Be(!1),He(!1))},[ct]),(0,Y.useEffect)(()=>{Je.current=lt},[lt]),(0,Y.useEffect)(()=>{Ye.current=ut},[ut]),(0,Y.useEffect)(()=>{Xe.current=dt},[dt]),(0,Y.useEffect)(()=>{if(!st||!ct){j([]),N([]),F(!1);return}if(!(X===`opencode`||ht?.tool===`opencode`)){j([]),N([]),F(!1);return}let e=new AbortController;return F(!0),Promise.all([S1(`opencode`,e.signal),C1(`opencode`,ct,e.signal)]).then(([e,t])=>{j(e),N(t)}).catch(e=>{Ze(e)||S(e)||(j([]),N([]))}).finally(()=>{e.signal.aborted||F(!1)}),()=>e.abort()},[st,X,Ze,ct,ht?.tool]),(0,Y.useEffect)(()=>{if(X!==`opencode`){w(``),E(``),k([]);return}w(pt?.model??ft?.helper_model??``),E(pt?.variant??ft?.helper_variant??``),k(pt?.skills??[])},[X,pt?.id,pt?.model,pt?.skills,pt?.variant,ft?.helper_model,ft?.helper_variant]),(0,Y.useEffect)(()=>{pt?.mode&&x(pt.mode)},[pt?.id,pt?.mode]),(0,Y.useEffect)(()=>{let e=A.find(e=>e.id===C)??null;E(t=>e?e.variants.includes(t)?t:``:t)},[A,C]),(0,Y.useEffect)(()=>{U(``),ve(null),de(ht?.model??``),pe(ht?.variant??``),he(ht?.skills??[])},[ht?.id,ht?.model,ht?.skills,ht?.variant]),(0,Y.useEffect)(()=>{be(``),we(null)},[mt?.bundle.id]),(0,Y.useEffect)(()=>{let e=A.find(e=>e.id===ue)??null;pe(t=>e?e.variants.includes(t)?t:``:t)},[A,ue]),(0,Y.useEffect)(()=>{if(!st)return;let e=O1();r(`connecting`);let t=()=>{let e=qe.current,t=Je.current,n=Ye.current,r=Xe.current;it(st,void 0,e),e&&(tt(st,e),J(st,e),et(st,e)),e&&t&&q(st,e,t),e&&n&&$e(st,e,n),e&&r&&Qe(st,e,r)},n=()=>{r(`connected`),t()},i=()=>{r(`reconnecting`)},a=()=>{r(`unavailable`)},o=()=>{it(st,void 0,qe.current)},s=(e=null)=>{let t=qe.current;t&&(e?.project_id&&e.project_id!==t||tt(st,t))},c=(e=null)=>{let t=qe.current;t&&(e?.project_id&&e.project_id!==t||J(st,t))},l=(e=null)=>{let t=qe.current;t&&(e?.project_id&&e.project_id!==t||et(st,t))},u=(e=null)=>{let t=qe.current,n=Je.current;!t||!n||e?.project_id&&e.project_id!==t||e?.id&&e.id!==n||q(st,t,n)},d=(e=null)=>{let t=qe.current,n=Xe.current;!t||!n||e?.project_id&&e.project_id!==t||e?.id&&e.id!==n||Qe(st,t,n)},f=(e=null)=>{let t=qe.current,n=Ye.current;!t||!n||e?.project_id&&e.project_id!==t||$e(st,t,n)};return e.on(`connect`,n),e.on(`disconnect`,i),e.on(`connect_error`,a),e.on(`ticket:created`,s),e.on(`ticket:created`,l),e.on(`ticket:updated`,s),e.on(`ticket:updated`,l),e.on(`ticket:updated`,f),e.on(`ticket:updated`,d),e.on(`ticket:deleted`,o),e.on(`ticket:deleted`,l),e.on(`ticket:deleted`,f),e.on(`ticket-dependency:created`,s),e.on(`ticket-dependency:deleted`,s),e.on(`chat-session:created`,c),e.on(`chat-session:updated`,c),e.on(`chat-session:updated`,u),e.on(`chat-session:deleted`,c),()=>{e.off(`connect`,n),e.off(`disconnect`,i),e.off(`connect_error`,a),e.off(`ticket:created`,s),e.off(`ticket:created`,l),e.off(`ticket:updated`,s),e.off(`ticket:updated`,l),e.off(`ticket:updated`,f),e.off(`ticket:updated`,d),e.off(`ticket:deleted`,o),e.off(`ticket:deleted`,l),e.off(`ticket:deleted`,f),e.off(`ticket-dependency:created`,s),e.off(`ticket-dependency:deleted`,s),e.off(`chat-session:created`,c),e.off(`chat-session:updated`,c),e.off(`chat-session:updated`,u),e.off(`chat-session:deleted`,c),e.disconnect()}},[st,$e,q,J,tt,it,Qe,et]),(0,Y.useEffect)(()=>{ut||l(!1)},[ut]),(0,Y.useEffect)(()=>{dt||d(!1)},[dt]);let xt=()=>{at()},St=e=>{a(e),l(!1),d(!1),p(!1),Ke(null)},Ct=()=>{s(!0)},wt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(We(null),Re(!0),!Ne&&!ze&&nt(e.csrfToken,e.selectedProjectId))},Tt=()=>{e.status===`authenticated`&&(h(!0),D1(e.csrfToken).then(()=>t(F0())).catch(e=>{Ze(e)||t({status:`error`,message:N0(e,`Logout failed. Mobile access may have already been revoked from desktop Archon.`)})}).finally(()=>h(!1)))},Et=()=>{if(e.status!==`pairing_confirmation`||g)return;let n=e.payload;_(!0),t({...e,error:null}),E1(n).then(e=>{if(e.authenticated&&e.csrf_token){window.history.replaceState({},``,`/mobile`),ot(e.csrf_token,e.preferred_project_id);return}t(F0())}).catch(e=>{t(t=>t.status===`pairing_confirmation`?{...t,error:N0(e,`Pairing failed. Regenerate the pairing link from desktop Archon and try again.`)}:t)}).finally(()=>_(!1))},Dt=()=>{window.history.replaceState({},``,`/mobile`),t(F0())},Ot=()=>{e.status===`authenticated`&&(t({...e,projects:null,projectError:null}),it(e.csrfToken))},kt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,projectSummary:null,projectSummaryError:null}),tt(e.csrfToken,e.selectedProjectId))},At=()=>{e.status!==`authenticated`||!e.selectedProjectId||(Pe(null),Ie(null),We(null),nt(e.csrfToken,e.selectedProjectId))},jt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null}),J(e.csrfToken,e.selectedProjectId))},Mt=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedChatSessionId||(t({...e,chatSessionDetail:null,chatSessionDetailError:null}),q(e.csrfToken,e.selectedProjectId,e.selectedChatSessionId))},Nt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),et(e.csrfToken,e.selectedProjectId))},Pt=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||(t({...e,ticketDetail:null,ticketDetailError:null}),Qe(e.csrfToken,e.selectedProjectId,e.selectedTicketId))},Ft=()=>{e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||(t({...e,bundleDetail:null,bundleDetailError:null}),$e(e.csrfToken,e.selectedProjectId,e.selectedBundleId))},It=n=>{if(e.status!==`authenticated`)return;let r=e.projects?.find(e=>e.id===n)??null;qe.current=n,t({...e,selectedProjectId:n,projectSummary:null,projectSummaryError:null,chatSessions:null,chatSessionsError:null,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null,tickets:null,ticketsError:null,selectedBundleId:null,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),re(null),ie(null),oe(null),ce(null),ne(null),ce(null),setStopRunError(null),we(null),Pe(null),Ie(null),We(null),s(!1),Re(!1),l(!1),d(!1),p(!1),Me(`transcript`),Ke(null),a(`overview`),tt(e.csrfToken,n),r?.active_target_kind===`bundle`&&nt(e.csrfToken,n),J(e.csrfToken,n),et(e.csrfToken,n)},Lt=async t=>{if(!(e.status!==`authenticated`||!e.selectedProjectId)){He(!0),We(null);try{rt(await x1(e.selectedProjectId,e.csrfToken,{kind:`bundle`,bundle_id:t})),Re(!1),tt(e.csrfToken,e.selectedProjectId),nt(e.csrfToken,e.selectedProjectId)}catch(e){if(Ze(e))return;We(N0(e,`Unable to update the project target right now.`))}finally{He(!1)}}},Rt=async(t,n={})=>{if(e.status!==`authenticated`||!e.selectedProjectId)return;He(!0),We(null);let r=r=>x1(e.selectedProjectId??``,e.csrfToken,{kind:`repo_root`,...t?{branch:t}:{},...n.createBranch===!1?{create_branch:!1}:{},...r?{confirm_dirty_switch:!0}:{}});try{let t;try{t=await r(n.confirmDirtySwitch===!0)}catch(e){if(!n.confirmDirtySwitch&&e instanceof O&&e.status===409&&e.message===P1){if(!window.confirm(`${P1}\n\nSwitch anyway?`))return;t=await r(!0)}else throw e}rt(t),Re(!1),tt(e.csrfToken,e.selectedProjectId),nt(e.csrfToken,e.selectedProjectId)}catch(e){if(Ze(e))return;We(N0(e,`Unable to update the project target right now.`))}finally{He(!1)}},zt=n=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedChatSessionId:n,chatSessionDetail:null,chatSessionDetailError:null}),ne(null),Ee(e=>e+1),p(!0),a(`chats`),q(e.csrfToken,e.selectedProjectId,n))},Bt=()=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedChatSessionId:null,chatSessionDetail:null,chatSessionDetailError:null}),ne(null),y(``),Ee(e=>e+1),p(!0),a(`chats`))},Vt=n=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedBundleId:n,bundleDetail:null,bundleDetailError:null,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),re(null),ie(null),ce(null),we(null),Ke(null),Me(`transcript`),Oe(e=>e+1),l(!0),d(!1),a(`tickets`),$e(e.csrfToken,e.selectedProjectId,n))},Ht=(n,r)=>{e.status!==`authenticated`||!e.selectedProjectId||(t({...e,selectedTicketId:n,ticketDetail:null,ticketDetailError:null}),Ke(r),Ae(e=>e+1),l(r!==null),d(!0),a(`tickets`),Qe(e.csrfToken,e.selectedProjectId,n))},Ut=()=>{p(!1)},Wt=n=>{if(e.status!==`authenticated`||!e.selectedProjectId)return;if(!e.chatSessionDetail||!e.selectedChatSessionId){x(n);return}if(e.chatSessionDetail.mode===n||R)return;let r=e.selectedProjectId,i=e.selectedChatSessionId,a=e.csrfToken;z(!0),ne(null),u1(r,i,a,{mode:n}).then(e=>{x(e.mode),t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedChatSessionId!==i)return t;let n=t.chatSessions?.map(t=>t.id===e.id?e:t)??t.chatSessions;return{...t,chatSessions:n,chatSessionDetail:e,chatSessionDetailError:null}})}).catch(e=>{Ze(e)||ne(N0(e,`Unable to update the chat mode right now.`))}).finally(()=>z(!1))},Gt=()=>{if(e.status===`authenticated`&&Ge&&e.selectedBundleId===Ge){t({...e,selectedTicketId:null,ticketDetail:null,ticketDetailError:null}),d(!1),l(!0),Ke(null);return}Ke(null),d(!1)},Kt=()=>{l(!1)},qt=e=>{let t=A.find(t=>t.id===e)??null;w(e),E(e=>t&&t.variants.includes(e)?e:``)},Jt=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Yt())},Yt=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||I||yt)return;let n=v.trim();if(!n)return;let r=e.selectedProjectId,i=e.csrfToken,a=X===`opencode`&&C?C:null,o=X===`opencode`&&C&&T?T:null,s=X===`opencode`?D:[];ne(null),L(!0);let c=e=>l1(r,e.id,i,{instruction:n,tool:e.tool,model:a,variant:o,skills:s});(e.chatSessionDetail?c(e.chatSessionDetail):c1(r,i,{mode:b,tool:X,model:a,variant:o,skills:s}).then(c)).then(e=>{y(``),p(!0),t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r)return t;let n=t.chatSessions??[],i=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];return{...t,chatSessions:i,selectedChatSessionId:e.id,chatSessionDetail:e,chatSessionDetailError:null}}),J(i,r)}).catch(e=>{Ze(e)||ne(N0(e,`Unable to send the chat prompt.`))}).finally(()=>L(!1))},Xt=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedChatSessionId||B)return;let t=e.selectedProjectId,n=e.selectedChatSessionId;ne(null),ee(n),d1(t,n,e.csrfToken).then(()=>q(e.csrfToken,t,n)).catch(e=>{Ze(e)||ne(N0(e,`Unable to stop the chat response.`))}).finally(()=>ee(null))},Zt=n=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||ae||(n===`stop-run`||n===`pause-build`)&&!window.confirm(`Stop this ticket action on the desktop machine?`))return;let r=e.selectedProjectId,i=e.selectedTicketId,a=e.csrfToken,o=n===`build`?f1(r,i,a,`build`):n===`review`?f1(r,i,a,`review`):n===`run`?p1(r,i,a):n===`stop-run`?m1(r,i,a):n===`pause-build`?h1(r,i,a):g1(r,i,a);oe(n),ce(null),o.then(e=>{t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedTicketId!==i)return t;let n=t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets;return{...t,tickets:n,ticketDetail:e,ticketDetailError:null}}),tt(a,r),et(a,r),Qe(a,r,i)}).catch(e=>{Ze(e)||ce(N0(e,`Unable to update this ticket from mobile.`))}).finally(()=>oe(null))},Qt=n=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||!e.bundleDetail||V)return;let r=e.selectedProjectId,i=e.selectedBundleId,a=e.csrfToken,o=e.bundleDetail,{runningBuildTicketId:s,resumableBuildTicketId:c}=h0(o);if(n===`pause-build`&&!window.confirm(`Pause this bundle build on the desktop machine?`))return;let l=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:d0(t.tickets,e),bundleDetail:e,bundleDetailError:null})},u=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets,bundleDetail:t.bundleDetail?{...t.bundleDetail,tickets:t.bundleDetail.tickets.map(t=>t.id===e.id?e:t)}:t.bundleDetail,bundleDetailError:null})},d=n===`build`?a1(r,i,a):n===`review`?o1(r,i,a):n===`pause-build`?s?h1(r,s,a):null:c?g1(r,c,a):null;d&&(re(n),ie(null),d.then(e=>{`tickets`in e?l(e):u(e),tt(a,r),et(a,r),$e(a,r,i)}).catch(e=>{Ze(e)||ie(N0(e,`Unable to update this bundle from mobile.`))}).finally(()=>re(null)))},$t=e=>{let t=A.find(t=>t.id===e)??null;de(e),pe(e=>t&&t.variants.includes(e)?e:``)},en=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),tn())},tn=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedTicketId||!e.ticketDetail||ge)return;let n=le.trim();if(!n)return;let r=e.selectedProjectId,i=e.ticketDetail,a=e.csrfToken,o=YW(i,{model:ue||null,variant:fe||null,skills:me}),s=()=>i.state===`plan`?v1(r,i.id,a,n):y1(r,i.id,a,n),c=e=>{t(t=>{if(t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedTicketId!==i.id)return t;let n=t.tickets?.map(t=>t.id===e.id?e:t)??t.tickets;return{...t,tickets:n,ticketDetail:e,ticketDetailError:null}})};W(!0),ve(null),(async()=>{o.shouldPersist&&c(await _1(r,i.id,a,{model:o.model,variant:o.variant,skills:o.skills})),c(await s()),U(``),et(a,r),Qe(a,r,i.id)})().catch(e=>{Ze(e)||ve(N0(e,`Unable to send the ticket follow-up.`))}).finally(()=>W(!1))},nn=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),rn())},rn=()=>{if(e.status!==`authenticated`||!e.selectedProjectId||!e.selectedBundleId||!e.bundleDetail||xe)return;let n=ye.trim();if(!n)return;let r=e.selectedProjectId,i=e.selectedBundleId,a=e.csrfToken,o=e=>{t(t=>t.status!==`authenticated`||t.selectedProjectId!==r||t.selectedBundleId!==i?t:{...t,tickets:d0(t.tickets,e),bundleDetail:e,bundleDetailError:null})};Se(!0),we(null),b1(r,i,a,n).then(e=>{o(e),be(``),et(a,r),$e(a,r,i)}).catch(e=>{Ze(e)||we(N0(e,`Unable to send the bundle follow-up.`))}).finally(()=>Se(!1))};return e.status===`checking`?(0,Z.jsx)(z1,{title:`Checking mobile session`,description:`Archon is validating this browser before showing project controls.`}):e.status===`pairing`?(0,Z.jsx)(z1,{title:`Checking pairing link`,description:`Keep this page open while Archon verifies the one-time pairing link.`}):e.status===`pairing_confirmation`?(0,Z.jsxs)(z1,{title:`Compare pairing code`,description:`Confirm this code matches the desktop dialog before pairing this phone.`,children:[(0,Z.jsx)(mu,{className:`border-primary/25 bg-primary/10 shadow-none`,children:(0,Z.jsxs)(yu,{className:`space-y-2 pt-5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-foreground`,children:`Verification code`}),(0,Z.jsx)(`div`,{className:`font-mono text-3xl font-semibold tracking-[0.18em] text-foreground`,children:e.displayCode}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Expires at `,M0(e.expiresAt)]})]})}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`If this code does not match the desktop dialog, cancel and regenerate the pairing link from desktop Archon.`}),e.error?(0,Z.jsx)(`p`,{className:`text-sm text-red-200`,children:e.error}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(K,{size:`lg`,disabled:g,onClick:Et,children:g?`Pairing...`:`Pair this phone`}),(0,Z.jsx)(K,{variant:`outline`,size:`lg`,disabled:g,onClick:Dt,children:`Cancel`})]})]}):e.status===`unauthenticated`?(0,Z.jsx)(z1,{title:e.reason===`session_revoked`?`Mobile session revoked`:`Pairing required`,description:e.reason===`session_revoked`?`This mobile session is no longer valid. Scan the QR code or open the pairing link from desktop Archon to continue.`:`This browser is not paired. Scan the QR code or open the pairing link from desktop Archon.`,children:(0,Z.jsx)(K,{onClick:xt,children:`Retry`})}):e.status===`error`?(0,Z.jsx)(z1,{title:`Mobile access unavailable`,description:e.message,children:(0,Z.jsx)(K,{onClick:xt,children:`Retry`})}):(0,Z.jsxs)(`main`,{className:G(`bg-background text-foreground`,bt?`flex h-[100dvh] flex-col overflow-hidden`:`min-h-screen`),children:[(0,Z.jsx)(K1,{open:o,projects:e.projects,selectedProjectId:e.selectedProjectId,error:e.projectError,onOpenChange:s,onSelectProject:It,onRetry:Ot}),(0,Z.jsx)(q1,{open:Le,project:ft,targetOptions:Ne,error:Ue??Fe,isLoading:ze,isSubmitting:Ve,onOpenChange:Re,onRetry:At,onSelectBundle:e=>{Lt(e)},onSelectRepoRoot:(e,t)=>{Rt(e,t)}}),(0,Z.jsx)(J1,{selectedProject:ft,targetLabel:gt,isTargetLoading:_t,isTargetDisabled:!ct,connectionState:n,onOpenProjects:Ct,onOpenTargetSelector:wt}),bt?(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-6xl flex-1 flex-col overflow-hidden px-3 py-3 sm:px-4`,children:[i===`tickets`?(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:u&&e.selectedTicketId?(0,Z.jsx)(k0,{selectedProjectId:e.selectedProjectId,ticketId:e.selectedTicketId,ticket:e.ticketDetail,openNonce:ke,error:e.ticketDetailError,actionState:ae,actionError:se,followUpPrompt:le,followUpSelectedModel:ue,followUpSelectedVariant:fe,followUpSelectedSkills:me,availableModels:A,availableSkills:M,isLoadingAgentSettings:P,isSendingFollowUp:ge,followUpError:_e,onBack:Gt,onRetry:Pt,onAction:Zt,onFollowUpPromptChange:U,onFollowUpModelChange:$t,onFollowUpVariantChange:pe,onFollowUpSkillsChange:he,onFollowUpKeyDown:en,onFollowUpSubmit:tn,isLargeScreen:!1}):(0,Z.jsx)(D0,{selectedProjectId:e.selectedProjectId,bundleId:e.selectedBundleId,bundleDetail:e.bundleDetail,openNonce:De,mobileDetailView:je,error:e.bundleDetailError,actionState:V,actionError:H,followUpPrompt:ye,isSendingFollowUp:xe,followUpError:Ce,availableModels:A,onBack:Kt,onRetry:Ft,onAction:Qt,onDetailViewChange:Me,onSelectTicket:Ht,onFollowUpPromptChange:be,onFollowUpKeyDown:nn,onFollowUpSubmit:rn,isLargeScreen:!1})}):null,i===`chats`?(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(O0,{selectedProjectId:e.selectedProjectId,chatSession:e.chatSessionDetail,chatSessionId:e.selectedChatSessionId,openNonce:Te,error:e.chatSessionDetailError,isStopping:B===e.selectedChatSessionId,composerMode:e.chatSessionDetail?.mode??b,composerTool:X,prompt:v,selectedModel:C,selectedVariant:T,selectedSkills:D,availableModels:A,availableSkills:M,isLoadingAgentSettings:P,isSending:I,isUpdatingMode:R,composerDisabledReason:yt,onBack:Ut,onRetry:Mt,onStop:Xt,onModeChange:Wt,onPromptChange:y,onModelChange:qt,onVariantChange:E,onSkillsChange:k,onPromptKeyDown:Jt,onSubmit:Yt,isLargeScreen:!1}),te?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-200`,children:te}):null]}):null]}):(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-3 py-3 pb-[calc(env(safe-area-inset-bottom)+5rem)] sm:px-4 lg:flex lg:min-h-[calc(100dvh-4.5rem)] lg:flex-col lg:overflow-hidden lg:pb-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-3 lg:flex lg:min-h-0 lg:flex-1 lg:flex-col`,children:[(0,Z.jsx)(U1,{status:n,onRetry:xt}),i===`overview`?(0,Z.jsx)(`div`,{className:`space-y-3 lg:flex lg:min-h-0 lg:flex-1 lg:flex-col`,children:e.projectError?(0,Z.jsx)(X1,{title:`Projects unavailable`,description:e.projectError,action:(0,Z.jsx)(K,{variant:`warning`,onClick:Ot,children:`Retry projects`})}):e.selectedProjectId&&!e.projectSummary&&!e.projectSummaryError?(0,Z.jsx)($1,{}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(r0,{selectedProjectId:e.selectedProjectId,summary:e.projectSummary,tickets:e.tickets,error:e.projectSummaryError,chatSessions:e.chatSessions,chatSessionDetail:e.chatSessionDetail,onRetry:kt,onOpenTickets:()=>St(`tickets`),onOpenChats:()=>St(`chats`)}),(0,Z.jsx)(e0,{isLoggingOut:m,onLogout:Tt})]})}):null,i===`tickets`?vt?(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden lg:grid-cols-[minmax(15rem,18rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`min-h-0`,children:(0,Z.jsx)(f0,{selectedProjectId:e.selectedProjectId,tickets:e.tickets,selectedBundleId:e.selectedBundleId,selectedTicketId:e.selectedTicketId,error:e.ticketsError,onRetry:Nt,onSelectBundle:Vt,onSelectTicket:Ht})}),(0,Z.jsx)(`div`,{className:`hidden min-h-0 lg:flex lg:flex-col lg:overflow-hidden`,children:u&&e.selectedTicketId?(0,Z.jsx)(k0,{selectedProjectId:e.selectedProjectId,ticketId:e.selectedTicketId,ticket:e.ticketDetail,openNonce:ke,error:e.ticketDetailError,actionState:ae,actionError:se,followUpPrompt:le,followUpSelectedModel:ue,followUpSelectedVariant:fe,followUpSelectedSkills:me,availableModels:A,availableSkills:M,isLoadingAgentSettings:P,isSendingFollowUp:ge,followUpError:_e,onBack:Gt,onRetry:Pt,onAction:Zt,onFollowUpPromptChange:U,onFollowUpModelChange:$t,onFollowUpVariantChange:pe,onFollowUpSkillsChange:he,onFollowUpKeyDown:en,onFollowUpSubmit:tn,isLargeScreen:!0}):(0,Z.jsx)(D0,{selectedProjectId:e.selectedProjectId,bundleId:e.selectedBundleId,bundleDetail:e.bundleDetail,openNonce:De,mobileDetailView:je,error:e.bundleDetailError,actionState:V,actionError:H,followUpPrompt:ye,isSendingFollowUp:xe,followUpError:Ce,availableModels:A,onBack:Kt,onRetry:Ft,onAction:Qt,onDetailViewChange:Me,onSelectTicket:Ht,onFollowUpPromptChange:be,onFollowUpKeyDown:nn,onFollowUpSubmit:rn,isLargeScreen:!0})})]}):(0,Z.jsx)(f0,{selectedProjectId:e.selectedProjectId,tickets:e.tickets,selectedBundleId:e.selectedBundleId,selectedTicketId:e.selectedTicketId,error:e.ticketsError,onRetry:Nt,onSelectBundle:Vt,onSelectTicket:Ht}):null,i===`chats`?vt?(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden lg:grid-cols-[minmax(15rem,18rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`min-h-0`,children:(0,Z.jsx)(p0,{selectedProjectId:e.selectedProjectId,chatSessions:e.chatSessions,selectedChatSessionId:e.selectedChatSessionId,error:e.chatSessionsError,onRetry:jt,onOpenNewChat:Bt,onSelectChat:zt})}),(0,Z.jsxs)(`div`,{className:`hidden min-h-0 lg:flex lg:flex-col lg:overflow-hidden`,children:[(0,Z.jsx)(O0,{selectedProjectId:e.selectedProjectId,chatSession:e.chatSessionDetail,chatSessionId:e.selectedChatSessionId,openNonce:Te,error:e.chatSessionDetailError,isStopping:B===e.selectedChatSessionId,composerMode:e.chatSessionDetail?.mode??b,composerTool:X,prompt:v,selectedModel:C,selectedVariant:T,selectedSkills:D,availableModels:A,availableSkills:M,isLoadingAgentSettings:P,isSending:I,isUpdatingMode:R,composerDisabledReason:yt,onBack:Ut,onRetry:Mt,onStop:Xt,onModeChange:Wt,onPromptChange:y,onModelChange:qt,onVariantChange:E,onSkillsChange:k,onPromptKeyDown:Jt,onSubmit:Yt,isLargeScreen:!0}),te?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-200`,children:te}):null]})]}):(0,Z.jsx)(p0,{selectedProjectId:e.selectedProjectId,chatSessions:e.chatSessions,selectedChatSessionId:e.selectedChatSessionId,error:e.chatSessionsError,onRetry:jt,onOpenNewChat:Bt,onSelectChat:zt}):null]})}),bt?null:(0,Z.jsx)(Y1,{activeSection:i,onChange:St})]})},R0=({socket:e=VW,children:t})=>(0,Z.jsx)(FY.Provider,{value:e,children:t}),z0=()=>typeof window<`u`&&window.location.pathname.startsWith(`/mobile`),B0=()=>{let e=z0();return $l(e?null:VW),(0,Z.jsx)(yt,{i18n:Ne,children:(0,Z.jsx)(St,{children:(0,Z.jsxs)(R0,{children:[e&&(0,Z.jsx)(L0,{}),!e&&(0,Z.jsx)(W$,{})]})})})};document.documentElement.classList.add(`dark`),document.documentElement.style.colorScheme=`dark`,(0,rt.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(B0,{}));export{ed as a,Oc as c,Ms as d,Is as f,Fs as h,td as i,Os as l,Ns as m,of as n,Nc as o,Ps as p,$u as r,jc as s,VW as t,As as u};
|