specrails-desktop 2.30.0 → 2.30.2
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/client/dist/assets/{ActivityFeedPage-AQgpr9qG.js → ActivityFeedPage-9DZOvIcY.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-I7a0usG7.js → AgentBrowserCapture-DqyHbzk7.js} +1 -1
- package/client/dist/assets/{AgentModeCodePane-BqOVg15n.js → AgentModeCodePane-BAYyFRmY.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-4SG6FF27.js → AgentModeJobsPane-CTIHMUKN.js} +1 -1
- package/client/dist/assets/{AgentsPage-C3FgYlEi.js → AgentsPage-DuyJuaFs.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-BcMNByW5.js → AnalyticsPage-BY7gtCx6.js} +1 -1
- package/client/dist/assets/{CodePage-CgdDkXp-.js → CodePage-vyQr40Vl.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-DPMcS88n.js → DesktopAnalyticsPage-CkXUFj3F.js} +1 -1
- package/client/dist/assets/{DocsDialog-BC7574Zi.js → DocsDialog-PhdCJNVj.js} +1 -1
- package/client/dist/assets/{DocsPage-Dd9yilUg.js → DocsPage-BY-wDthx.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-CqC_0VQL.js → InteractiveJobComposer-C9I0A4KR.js} +1 -1
- package/client/dist/assets/{JobDetailModal-BFNXOhk1.js → JobDetailModal-I_RoQJV4.js} +1 -1
- package/client/dist/assets/{JobDetailPage-DM-6zYpA.js → JobDetailPage-CU4FEnUC.js} +1 -1
- package/client/dist/assets/{JobsPage-1dkjPk1k.js → JobsPage-DcllM4Ip.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-BPeqz6cG.js → LoopBuilderPage-DGm_iuff.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-EdkyYaGN.js → LoopPreviewModal-BC-TeFdD.js} +1 -1
- package/client/dist/assets/{LoopsPage-nZfgiaK8.js → LoopsPage-SqglnXlp.js} +1 -1
- package/client/dist/assets/{PluginsPage-CwFfFBzW.js → PluginsPage-B89S8o1a.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-DHsxLFMT.js → ProjectSettingsDialog-nEs-ENrE.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-wcI3nGNr.js → TemplatePreviewModal-D4qW-J9B.js} +1 -1
- package/client/dist/assets/{TicketDetailModal-7EloKP1C.js → TicketDetailModal-CI47Dq9E.js} +2 -2
- package/client/dist/assets/{dist-js-zvt5ap3o.js → dist-js-Dj72W6qo.js} +1 -1
- package/client/dist/assets/{dist-js-Bt2zW2YG.js → dist-js-jwoXo0YD.js} +1 -1
- package/client/dist/assets/{index-xkzK3E5i.js → index-F9r8mWP_.js} +5 -5
- package/client/dist/index.html +2 -2
- package/docs/internals/interactive-jobs.md +1 -1
- package/package.json +1 -1
- package/server/dist/core-update-manager.js +10 -3
- package/server/dist/framework-manager.js +22 -8
- package/server/dist/interactive-job-session.js +48 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/JobDetailModal-
|
|
2
|
-
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-CNC7AqOf.js";import{n as a,t as o}from"./jsx-runtime-zu2_FqZY.js";import{t as s}from"./react-dom-DiWzBDP9.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{a as l,c as u,d,i as f,l as p,o as m,r as h,s as g,t as _}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as v,c as y,d as b,f as x,g as S,h as C,i as w,l as T,m as E,n as D,o as O,p as k,r as A,s as j,t as M,u as N,y as P}from"./i18n-Bf9Ckd10.js";import{t as F}from"./Trans-CPISVji8.js";import{n as I,t as L}from"./createLucideIcon-Bjbbp_KS.js";import{n as R,t as z}from"./dist-bVqfYmby.js";import{t as B}from"./arrow-left-CpIR4j7G.js";import{a as V,c as H,d as U,f as W,g as ee,h as te,i as G,l as K,m as ne,n as re,o as ie,p as ae,r as oe,s as se,t as ce,u as le}from"./useBrowserCaptureSession-CkBJShUw.js";import{t as q}from"./arrow-up-right-9DoMn7fD.js";import{a as ue,c as de,i as fe,l as pe,n as me,o as he,r as ge,s as _e,t as ve,u as ye}from"./MinimizedChatsContext-Cs34FPTz.js";import{n as be,t as J}from"./external-link-BcU5EWZp.js";import{t as xe}from"./chevron-right-CViMxucY.js";import{A as Se,B as Ce,C as we,D as Te,E as Ee,F as De,I as Oe,M as ke,N as Ae,O as je,P as Me,S as Ne,T as Pe,V as Fe,_ as Ie,a as Le,b as Re,c as ze,d as Be,f as Ve,g as He,h as Ue,i as We,j as Ge,k as Ke,l as qe,m as Je,n as Ye,o as Xe,p as Ze,r as Qe,s as $e,t as et,u as tt,v as nt,w as rt,x as it,y as at}from"./TicketDetailModal-7EloKP1C.js";import{t as ot}from"./circle-x-CMYsN4ZH.js";import{t as st}from"./download-CFHyyHcw.js";import{t as ct}from"./file-text-CFT-xXKN.js";import{t as lt}from"./git-branch-BRM0F5GN.js";import{t as ut}from"./loader-circle-DcygOQpC.js";import{t as dt}from"./pencil-C9RkrIPZ.js";import{t as ft}from"./play-DNlrawbS.js";import{t as pt}from"./plus-CsnjfkmX.js";import{t as mt}from"./save-28sIlCdr.js";import{t as ht}from"./search-Cq_gE3Ik.js";import{t as gt}from"./sparkles-DrY8hb0X.js";import{t as _t}from"./trash-2-BOU3WdZZ.js";import{t as vt}from"./triangle-alert-H9T4jAmh.js";import{t as yt}from"./x-CBMI9ejn.js";import{t as bt}from"./zap-CHo3aCD1.js";import{a as xt,i as St,n as Ct,r as wt,t as Tt}from"./auth-D_5bQv5W.js";import{n as Et,t as Dt}from"./useSharedWebSocket-DaPh7QBL.js";import{t as Ot}from"./api-B2M7CtDw.js";import{n as kt,r as At,t as jt}from"./useDesktop-B4pSBIDd.js";import{n as Mt,t as Nt}from"./dist-Cez5CRkX.js";import{n as Pt,t as Y}from"./button-BUIIBQPT.js";import{t as X}from"./utils-BC4DHlz2.js";import{C as Ft,D as It,E as Lt,S as Rt,T as zt,_ as Bt,a as Vt,b as Ht,c as Ut,d as Wt,f as Gt,g as Kt,h as qt,i as Jt,l as Yt,m as Xt,n as Zt,o as Qt,p as $t,r as en,s as tn,t as nn,u as rn,v as an,w as on,x as sn,y as cn}from"./dialog-CzIekCw0.js";import{t as ln}from"./jira-api-BgFIr8eD.js";import{n as un,t as dn}from"./lib-CGdyxIWg.js";import{t as fn}from"./getTimezoneOffsetInMilliseconds-qrcBaLW1.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 pn=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}}}})),mn=i(((e,t)=>{t.exports=pn()})),hn=i((e=>{var t=mn(),n=a(),r=s();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 o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(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 l(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 u(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 d(e){if(c(e)!==e)throw Error(i(188))}function f(e){var t=e.alternate;if(!t){if(t=c(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 o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return d(a),e;if(o===r)return d(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var s=!1,l=a.child;l;){if(l===n){s=!0,n=a,r=o;break}if(l===r){s=!0,r=a,n=o;break}l=l.sibling}if(!s){for(l=o.child;l;){if(l===n){s=!0,n=o,r=a;break}if(l===r){s=!0,r=o,n=a;break}l=l.sibling}if(!s)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 p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},R=[],z=-1;function B(e){return{current:e}}function V(e){0>z||(e.current=R[z],R[z]=null,z--)}function H(e,t){z++,R[z]=e.current,e.current=t}var U=B(null),W=B(null),ee=B(null),te=B(null);function G(e,t){switch(H(ee,t),H(W,e),H(U,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}}V(U),H(U,e)}function K(){V(U),V(W),V(ee)}function ne(e){e.memoizedState!==null&&H(te,e);var t=U.current,n=Ud(t,e.type);t!==n&&(H(W,e),H(U,n))}function re(e){W.current===e&&(V(U),V(W)),te.current===e&&(V(te),$f._currentValue=L)}var ie,ae;function oe(e){if(ie===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ie=t&&t[1]||``,ae=-1<e.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/JobDetailModal-I_RoQJV4.js","assets/rolldown-runtime-CNC7AqOf.js","assets/jsx-runtime-zu2_FqZY.js","assets/react-dom-DiWzBDP9.js","assets/i18n-Bf9Ckd10.js","assets/preload-helper-Czpn1I53.js","assets/createLucideIcon-Bjbbp_KS.js","assets/activity-DiyjsgQV.js","assets/addspec-Rw8uVBC1.js","assets/agent-BuUpgqVx.js","assets/agents-DhG7mg6-.js","assets/agentstudio-BIUe1Im2.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-DZ8Aoq3I.js","assets/attachments-B53PG733.js","assets/browser-CXUcnTMI.js","assets/builder-Cc_Lf79C.js","assets/chat-BGD7MXAy.js","assets/code-BDXEM4ml.js","assets/commands-DyUZQ1FI.js","assets/common-DHsv9N5d.js","assets/dashboard-Cslu_GCH.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CmKWERE0.js","assets/jobs-DoSaFzAa.js","assets/loops-BzfXWEwO.js","assets/mcp-uDkXYu4L.js","assets/nav-myFaXRHD.js","assets/settings-B0ypw9uw.js","assets/setup-ajB4rYm-.js","assets/specs-DII0C8gw.js","assets/terminal-BFRZnMPP.js","assets/tickets-D_yDquEw.js","assets/dist-bVqfYmby.js","assets/useBrowserCaptureSession-CkBJShUw.js","assets/auth-D_5bQv5W.js","assets/api-B2M7CtDw.js","assets/InteractiveJobComposer-C9I0A4KR.js","assets/MinimizedChatsContext-Cs34FPTz.js","assets/chunk-KS7C4IRE-Cx5sqopX.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/useSharedWebSocket-DaPh7QBL.js","assets/useDesktop-B4pSBIDd.js","assets/brain-DI9lHkKY.js","assets/external-link-BcU5EWZp.js","assets/chevron-right-CViMxucY.js","assets/TicketDetailModal-CI47Dq9E.js","assets/Trans-CPISVji8.js","assets/arrow-left-CpIR4j7G.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/file-text-CFT-xXKN.js","assets/git-branch-BRM0F5GN.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/play-DNlrawbS.js","assets/plus-CsnjfkmX.js","assets/save-28sIlCdr.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/zap-CHo3aCD1.js","assets/button-BUIIBQPT.js","assets/dist-Cez5CRkX.js","assets/clsx-CjueKrWZ.js","assets/utils-BC4DHlz2.js","assets/dialog-CzIekCw0.js","assets/jira-api-BgFIr8eD.js","assets/lib-CGdyxIWg.js","assets/formatDistanceToNow-ByKli7Q_.js","assets/getTimezoneOffsetInMilliseconds-qrcBaLW1.js","assets/spending-DMnCXy84.js","assets/lib-C7Mhm-gT.js","assets/job-time-BCL7wee9.js","assets/LoopPreviewModal-BC-TeFdD.js","assets/TemplatePreviewModal-D4qW-J9B.js","assets/ProjectSettingsDialog-nEs-ENrE.js","assets/addon-image-BRmmRHgQ.js","assets/addon-ligatures-qIZUPvRV.js","assets/addon-webgl-C2d7lriQ.js","assets/AgentModeCodePane-BAYyFRmY.js","assets/AgentModeJobsPane-CTIHMUKN.js","assets/format-command-Dfa1o2d-.js","assets/AgentBrowserCapture-DqyHbzk7.js","assets/JobDetailPage-CU4FEnUC.js","assets/JobsPage-DcllM4Ip.js","assets/ExportDropdown-BrtfWzEG.js","assets/AnalyticsPage-BY7gtCx6.js","assets/arrow-up-right-9DoMn7fD.js","assets/BarChart-nBOMNfiy.js","assets/value-s-gzBeyF.js","assets/ActivityFeedPage-9DZOvIcY.js","assets/AgentsPage-DuyJuaFs.js","assets/CodePage-vyQr40Vl.js","assets/IntegrationsPage-Bs00_tl4.js","assets/PluginsPage-B89S8o1a.js","assets/DesktopAnalyticsPage-CkXUFj3F.js","assets/DocsPage-BY-wDthx.js","assets/atom-one-dark-qiGhVQxg.js","assets/atom-one-dark-B-oHczHB.css","assets/DocsDialog-PhdCJNVj.js","assets/LoopsPage-SqglnXlp.js","assets/upload-DYMjAQ6M.js","assets/LoopBuilderPage-DGm_iuff.js","assets/LoopBuilderPage-DtxX27Jz.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-CNC7AqOf.js";import{n as a,t as o}from"./jsx-runtime-zu2_FqZY.js";import{t as s}from"./react-dom-DiWzBDP9.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{a as l,c as u,d,i as f,l as p,o as m,r as h,s as g,t as _}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as v,c as y,d as b,f as x,g as S,h as C,i as w,l as T,m as E,n as D,o as O,p as k,r as A,s as j,t as M,u as N,y as P}from"./i18n-Bf9Ckd10.js";import{t as F}from"./Trans-CPISVji8.js";import{n as I,t as L}from"./createLucideIcon-Bjbbp_KS.js";import{n as R,t as z}from"./dist-bVqfYmby.js";import{t as B}from"./arrow-left-CpIR4j7G.js";import{a as V,c as H,d as U,f as W,g as ee,h as te,i as G,l as K,m as ne,n as re,o as ie,p as ae,r as oe,s as se,t as ce,u as le}from"./useBrowserCaptureSession-CkBJShUw.js";import{t as q}from"./arrow-up-right-9DoMn7fD.js";import{a as ue,c as de,i as fe,l as pe,n as me,o as he,r as ge,s as _e,t as ve,u as ye}from"./MinimizedChatsContext-Cs34FPTz.js";import{n as be,t as J}from"./external-link-BcU5EWZp.js";import{t as xe}from"./chevron-right-CViMxucY.js";import{A as Se,B as Ce,C as we,D as Te,E as Ee,F as De,I as Oe,M as ke,N as Ae,O as je,P as Me,S as Ne,T as Pe,V as Fe,_ as Ie,a as Le,b as Re,c as ze,d as Be,f as Ve,g as He,h as Ue,i as We,j as Ge,k as Ke,l as qe,m as Je,n as Ye,o as Xe,p as Ze,r as Qe,s as $e,t as et,u as tt,v as nt,w as rt,x as it,y as at}from"./TicketDetailModal-CI47Dq9E.js";import{t as ot}from"./circle-x-CMYsN4ZH.js";import{t as st}from"./download-CFHyyHcw.js";import{t as ct}from"./file-text-CFT-xXKN.js";import{t as lt}from"./git-branch-BRM0F5GN.js";import{t as ut}from"./loader-circle-DcygOQpC.js";import{t as dt}from"./pencil-C9RkrIPZ.js";import{t as ft}from"./play-DNlrawbS.js";import{t as pt}from"./plus-CsnjfkmX.js";import{t as mt}from"./save-28sIlCdr.js";import{t as ht}from"./search-Cq_gE3Ik.js";import{t as gt}from"./sparkles-DrY8hb0X.js";import{t as _t}from"./trash-2-BOU3WdZZ.js";import{t as vt}from"./triangle-alert-H9T4jAmh.js";import{t as yt}from"./x-CBMI9ejn.js";import{t as bt}from"./zap-CHo3aCD1.js";import{a as xt,i as St,n as Ct,r as wt,t as Tt}from"./auth-D_5bQv5W.js";import{n as Et,t as Dt}from"./useSharedWebSocket-DaPh7QBL.js";import{t as Ot}from"./api-B2M7CtDw.js";import{n as kt,r as At,t as jt}from"./useDesktop-B4pSBIDd.js";import{n as Mt,t as Nt}from"./dist-Cez5CRkX.js";import{n as Pt,t as Y}from"./button-BUIIBQPT.js";import{t as X}from"./utils-BC4DHlz2.js";import{C as Ft,D as It,E as Lt,S as Rt,T as zt,_ as Bt,a as Vt,b as Ht,c as Ut,d as Wt,f as Gt,g as Kt,h as qt,i as Jt,l as Yt,m as Xt,n as Zt,o as Qt,p as $t,r as en,s as tn,t as nn,u as rn,v as an,w as on,x as sn,y as cn}from"./dialog-CzIekCw0.js";import{t as ln}from"./jira-api-BgFIr8eD.js";import{n as un,t as dn}from"./lib-CGdyxIWg.js";import{t as fn}from"./getTimezoneOffsetInMilliseconds-qrcBaLW1.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 pn=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}}}})),mn=i(((e,t)=>{t.exports=pn()})),hn=i((e=>{var t=mn(),n=a(),r=s();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 o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(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 l(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 u(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 d(e){if(c(e)!==e)throw Error(i(188))}function f(e){var t=e.alternate;if(!t){if(t=c(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 o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return d(a),e;if(o===r)return d(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var s=!1,l=a.child;l;){if(l===n){s=!0,n=a,r=o;break}if(l===r){s=!0,r=a,n=o;break}l=l.sibling}if(!s){for(l=o.child;l;){if(l===n){s=!0,n=o,r=a;break}if(l===r){s=!0,r=o,n=a;break}l=l.sibling}if(!s)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 p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},R=[],z=-1;function B(e){return{current:e}}function V(e){0>z||(e.current=R[z],R[z]=null,z--)}function H(e,t){z++,R[z]=e.current,e.current=t}var U=B(null),W=B(null),ee=B(null),te=B(null);function G(e,t){switch(H(ee,t),H(W,e),H(U,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}}V(U),H(U,e)}function K(){V(U),V(W),V(ee)}function ne(e){e.memoizedState!==null&&H(te,e);var t=U.current,n=Ud(t,e.type);t!==n&&(H(W,e),H(U,n))}function re(e){W.current===e&&(V(U),V(W)),te.current===e&&(V(te),$f._currentValue=L)}var ie,ae;function oe(e){if(ie===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ie=t&&t[1]||``,ae=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ie+e+ae}var se=!1;function ce(e,t){if(!e||se)return``;se=!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(`
|
|
@@ -57,10 +57,10 @@ Error generating stack: `+e.message+`
|
|
|
57
57
|
|
|
58
58
|
`).trim()}function ZL(e,t=!1){if(!e.includes(KL))return{body:e,draft:null,pending:!1};let n=null,r=``,i=0;GL.lastIndex=0;let a;for(;(a=GL.exec(e))!==null;){r+=e.slice(i,a.index),i=a.index+a[0].length;let t=YL(a[1]);t&&(n=t)}r+=e.slice(i);let o=!1,s=r.indexOf(KL);if(s!==-1){let e=YL(r.slice(s+13).replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``));e?(n=e,r=r.slice(0,s)):t&&(r=r.slice(0,s),o=!0)}return{body:XL(r),draft:n,pending:o}}var QL={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`},$L=X(`text-xs leading-6 text-foreground/85`,`[&_p]:my-2 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h2]:mt-3 [&_h2]:mb-1 [&_h2]:text-[11px] [&_h2]:font-semibold [&_h2]:uppercase [&_h2]:tracking-wider [&_h2]:text-foreground/60 [&_h2:first-child]:mt-0`,`[&_h3]:mt-2 [&_h3]:mb-1 [&_h3]:text-xs [&_h3]:font-semibold`,`[&_ul]:my-1.5 [&_ul]:list-disc [&_ul]:pl-4 [&_ol]:my-1.5 [&_ol]:list-decimal [&_ol]:pl-4 [&_li]:my-0.5`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-2`,`[&_strong]:font-semibold`);function eR({draft:e}){let{t}=I(`agent`),[n,r]=(0,Z.useState)(!1),i=e.description.trim().length>0,a=e.acceptanceCriteria;return(0,Q.jsxs)(`div`,{"data-testid":`agent-spec-draft-card`,className:`my-1 overflow-hidden rounded-xl border border-accent-primary/25 bg-card/80 shadow-lg backdrop-blur`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/40 bg-accent-primary/[0.06] px-3.5 py-2`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest text-accent-primary/90`,children:[(0,Q.jsx)(gt,{className:`h-3 w-3`}),t(`specDraft.heading`)]}),(0,Q.jsx)(`span`,{className:X(`rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,QL[e.priority]),children:t(`explore:priority.${e.priority}`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-3.5 py-3`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold leading-snug text-foreground`,children:e.title.trim()||t(`specDraft.untitled`)}),e.labels.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.labels.map((e,t)=>(0,Q.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[10px] text-foreground/70`,children:e},`${t}-${e}`))}),i&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:X(`relative`,!n&&`max-h-28 overflow-hidden`),children:[(0,Q.jsx)(`div`,{className:$L,children:(0,Q.jsx)(un,{remarkPlugins:[dn],children:e.description})}),!n&&(0,Q.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-card to-transparent`})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"data-agent-interactive":!0,className:`mt-1 flex items-center gap-1 text-[11px] text-accent-info transition-colors hover:text-foreground`,children:[n?(0,Q.jsx)(de,{className:`h-3 w-3`}):(0,Q.jsx)(pe,{className:`h-3 w-3`}),t(n?`specDraft.collapse`:`specDraft.expand`)]})]}),a.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-foreground/50`,children:[t(`specDraft.acceptanceCriteria`),` · `,a.length]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:a.map((e,t)=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-1.5 text-xs leading-5 text-foreground/85`,children:[(0,Q.jsx)(Pn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success/80`}),(0,Q.jsx)(`span`,{children:e})]},`${t}-${e}`))})]})]})]})}function tR(){let{t:e}=I(`agent`);return(0,Q.jsxs)(`span`,{"data-testid":`agent-spec-draft-pending`,className:`inline-flex w-fit items-center gap-1.5 rounded-full border border-accent-primary/25 bg-accent-primary/10 px-2.5 py-1 text-[11px] text-accent-primary/90`,children:[(0,Q.jsx)(gt,{className:`h-3 w-3 animate-pulse`}),e(`specDraft.drafting`)]})}var nR=`#agentref:`;function rR(e){return e.kind===`ticket`?`${nR}ticket:${e.ticketId}`:e.kind===`pull-request`?`${nR}pr:${e.prNumber}${e.prUrl?`:${encodeURIComponent(e.prUrl)}`:``}`:e.kind===`loop`?`${nR}loop:${e.loopId}`:`${nR}job:${e.jobId}`}function iR(e){if(!e||!e.startsWith(nR))return null;let t=e.slice(10);if(t.startsWith(`ticket:`)){let e=Number.parseInt(t.slice(7),10);return Number.isInteger(e)&&e>0?{kind:`ticket`,ticketId:e}:null}if(t.startsWith(`pr:`)){let[,e,n]=/^pr:(\d+)(?::(.+))?$/.exec(t)??[],r=Number.parseInt(e??``,10);if(!Number.isInteger(r)||r<=0)return null;let i=n?decodeURIComponent(n):void 0;return i?{kind:`pull-request`,prNumber:r,prUrl:i}:{kind:`pull-request`,prNumber:r}}if(t.startsWith(`job:`)){let e=t.slice(4);return oR.test(e)?{kind:`job`,jobId:e}:null}if(t.startsWith(`loop:`)){let e=t.slice(5);return cR.test(e)||oR.test(e)?{kind:`loop`,loopId:e}:null}return null}var aR=`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`,oR=RegExp(`^${aR}$`),sR=`factory:(?:implement|batch|freestyle)`,cR=RegExp(`^${sR}$`),lR=/\b(jobs?|runs?|loops?|rails?|ejecuci[oó]n(?:es)?|trabajos?|bucles?)\b|(?:loop|job|run)[a-z]*id/i;function uR(e){let t=new Set;for(let n of e.split(`
|
|
59
59
|
`)){if(!lR.test(n))continue;let e=new RegExp(aR,`g`),r;for(;(r=e.exec(n))!==null;)t.add(r[0].toLowerCase())}return t}var dR=/[\w#&$-]/,fR=/[\w-]/;function pR(e,t){let n=/\b(?:PR|pull request)\s*#?(\d{1,10})\b/gi,r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=e[r.index+r[0].length];if(n!==void 0&&dR.test(n)||i!==void 0&&fR.test(i))continue;let a=Number.parseInt(r[1],10);!Number.isInteger(a)||a<=0||t.push({start:r.index,end:r.index+r[0].length,segment:{kind:`pull-request`,prNumber:a,label:`PR #${a}`}})}let i=/https?:\/\/[^\s<>)]+\/pull\/(\d{1,10})(?:[/?#][^\s<>)]*)?/gi,a;for(;(a=i.exec(e))!==null;){let e=Number.parseInt(a[1],10);if(!Number.isInteger(e)||e<=0)continue;let n=a[0].replace(/[.,;:!?…]+$/u,``);t.push({start:a.index,end:a.index+n.length,segment:{kind:`pull-request`,prNumber:e,prUrl:n,label:`PR #${e}`}})}}function mR(e){if(!e)return null;let t=/^https?:\/\/[^\s<>)]+\/pull\/(\d{1,10})(?:[/?#][^\s<>)]*)?$/i.exec(e);if(!t)return null;let n=Number.parseInt(t[1],10);return!Number.isInteger(n)||n<=0?null:{prNumber:n,prUrl:e}}function hR(e,t){let n=/#(\d{1,6})/g,r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=r.index+r[0].length,a=e[i];if(n!==void 0&&dR.test(n)||a!==void 0&&fR.test(a))continue;let o=Number.parseInt(r[1],10);if(!Number.isInteger(o)||o<=0)continue;let s=i,c=`#${o}`,l=/^([ \t]*[—–][ \t]*)([^\n#]{1,80})/.exec(e.slice(s));if(l){let e=l[2].replace(/[\s.,;:!?…]+$/u,``);e.length>0&&(s+=l[1].length+e.length,c=`#${o} — ${e}`)}t.push({start:r.index,end:s,segment:{kind:`ticket`,ticketId:o,label:c}})}}function gR(e,t,n){let r=new RegExp(aR,`g`),i;for(;(i=r.exec(e))!==null;){let r=e[i.index-1],a=e[i.index+i[0].length];if(r!==void 0&&dR.test(r)||a!==void 0&&fR.test(a))continue;let o=i[0].toLowerCase();t.has(o)&&n.push({start:i.index,end:i.index+i[0].length,segment:{kind:`job`,jobId:o,label:`${o.slice(0,8)}…`}})}}function _R(e,t){let n=new RegExp(sR,`g`),r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1],i=e[r.index+r[0].length];n!==void 0&&dR.test(n)||i!==void 0&&fR.test(i)||t.push({start:r.index,end:r.index+r[0].length,segment:{kind:`loop`,loopId:r[0],label:r[0]}})}}function vR(e,t){let n=[];if(pR(e,n),hR(e,n),gR(e,t,n),_R(e,n),n.length===0)return[{kind:`text`,text:e}];n.sort((e,t)=>e.start-t.start);let r=[],i=0;for(let t of n)t.start<i||(t.start>i&&r.push({kind:`text`,text:e.slice(i,t.start)}),r.push(t.segment),i=t.end);return i<e.length&&r.push({kind:`text`,text:e.slice(i)}),r}var yR=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function bR(e){return e.kind===`text`?{type:`text`,value:e.text}:{type:`link`,url:rR(e.kind===`ticket`?{kind:`ticket`,ticketId:e.ticketId}:e.kind===`pull-request`?{kind:`pull-request`,prNumber:e.prNumber,prUrl:e.prUrl}:e.kind===`loop`?{kind:`loop`,loopId:e.loopId}:{kind:`job`,jobId:e.jobId}),children:[{type:`text`,value:e.label}]}}function xR(e,t){let n=e.children;if(n)for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.type===`inlineCode`&&typeof r.value==`string`){let i=r.value.trim();if(oR.test(i)&&t.has(i.toLowerCase())){let t=i.toLowerCase();n.splice(e,1,bR({kind:`job`,jobId:t,label:`${t.slice(0,8)}…`}))}else cR.test(i)&&n.splice(e,1,bR({kind:`loop`,loopId:i,label:i}));continue}if(r.type===`link`&&typeof r.url==`string`){let t=mR(r.url);t&&n.splice(e,1,bR({kind:`pull-request`,prNumber:t.prNumber,prUrl:t.prUrl,label:`PR #${t.prNumber}`}));continue}if(!yR.has(r.type))if(r.type===`text`&&typeof r.value==`string`){let i=vR(r.value,t);i.some(e=>e.kind!==`text`)&&n.splice(e,1,...i.map(bR))}else xR(r,t)}}function SR(){return(e,t)=>{xR(e,uR(t==null?``:String(t)))}}function CR({refTarget:e,onOpen:t,children:n}){let{t:r}=I(`agent`),i=e.kind===`ticket`?r(`refs.openTicket`,{id:e.ticketId}):e.kind===`pull-request`?r(`refs.openPullRequest`,{id:e.prNumber}):e.kind===`loop`?r(`refs.openLoop`,{id:e.loopId}):r(`refs.openJob`,{id:e.jobId.slice(0,8)}),a=e.kind===`ticket`?Me:e.kind===`pull-request`?Oe:e.kind===`loop`?Jr:Dn;return(0,Q.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-ref-chip`,"data-ref-kind":e.kind,onClick:n=>{n.stopPropagation(),t(e)},title:i,"aria-label":i,className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,`hover:-translate-y-px hover:shadow-sm`,e.kind===`ticket`?`border-accent-primary/35 bg-accent-primary/10 text-accent-primary hover:border-accent-primary/60 hover:bg-accent-primary/15`:e.kind===`pull-request`?`border-accent-success/35 bg-accent-success/10 text-accent-success hover:border-accent-success/60 hover:bg-accent-success/15`:e.kind===`loop`?`border-accent-highlight/35 bg-accent-highlight/10 text-accent-highlight hover:border-accent-highlight/60 hover:bg-accent-highlight/15`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:border-accent-info/60 hover:bg-accent-info/15`),children:[(0,Q.jsx)(a,{className:`h-3 w-3 shrink-0 opacity-70`}),(0,Q.jsx)(`span`,{className:`max-w-[280px] truncate`,children:n})]})}var wR=X(`text-sm leading-7 text-foreground`,`[&_p]:my-3.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h1]:mt-5 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold`,`[&_h2]:mt-5 [&_h2]:mb-2 [&_h2]:text-[15px] [&_h2]:font-semibold`,`[&_h3]:mt-4 [&_h3]:mb-1.5 [&_h3]:text-sm [&_h3]:font-semibold`,`[&_strong]:font-semibold [&_strong]:text-foreground`,`[&_em]:italic`,`[&_a]:text-accent-info [&_a]:underline [&_a]:underline-offset-2`,`[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-1`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-3`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground`,`[&_blockquote]:my-2 [&_blockquote]:border-l-2 [&_blockquote]:border-accent-primary/40 [&_blockquote]:pl-3 [&_blockquote]:text-foreground/80`,`[&_hr]:my-3 [&_hr]:border-border/60`,`[&_table]:my-2 [&_table]:w-full [&_table]:border-collapse [&_table]:overflow-hidden [&_table]:rounded-lg`,`[&_th]:border [&_th]:border-border [&_th]:bg-surface [&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:font-semibold`,`[&_td]:border [&_td]:border-border [&_td]:px-2.5 [&_td]:py-1.5`,`[&_tr:nth-child(even)]:bg-surface/40`);function TR({text:e,timestampIso:t}){let{t:n}=I(`agent`),[r,i]=(0,Z.useState)(!1);return(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{try{let n=e;if(t){let r=eE(t);r&&(n=`[${Yy(r,`yyyy-MM-dd HH:mm:ss`)}]\n${e}`)}await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)}catch{}},"aria-label":n(`copy`),title:n(`copy`),className:`rounded-md p-1 text-foreground/40 opacity-0 transition-opacity hover:bg-surface hover:text-foreground group-hover:opacity-100`,"data-agent-interactive":!0,children:r?(0,Q.jsx)(be,{className:`h-3 w-3 text-accent-success`}):(0,Q.jsx)(Un,{className:`h-3 w-3`})})}function ER({iso:e}){if(!e)return null;let t=eE(e);if(!t)return null;let n=v();return(0,Q.jsx)(`time`,{dateTime:t.toISOString(),title:Yy(t,`PPpp`,{locale:n}),className:`shrink-0 select-none font-mono text-[10px] leading-none tabular-nums tracking-tight text-foreground/25 transition-colors duration-200 group-hover:text-foreground/50`,children:Yy(t,`yyyy-MM-dd HH:mm:ss`)})}function DR(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function OR(e){return e.mimeType.startsWith(`image/`)||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(e.filename)}function kR({conversationId:e,attachment:t,onClose:n}){let{t:r}=I(`agent`),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,Z.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),TE(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`attachment.loadFailed`))}),()=>{n=!0}},[t,e,r]),(0,Z.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=OR(t),l=r(`attachment.download`),u=i?(0,Q.jsxs)(`a`,{href:i,download:t.filename,onClick:e=>e.stopPropagation(),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-white transition-opacity hover:opacity-90`,"data-agent-interactive":!0,children:[(0,Q.jsx)(st,{className:`h-4 w-4`}),l]}):(0,Q.jsxs)(`button`,{type:`button`,disabled:!0,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-white opacity-45`,children:[o?(0,Q.jsx)(st,{className:`h-4 w-4`}):(0,Q.jsx)(ut,{className:`h-4 w-4 animate-spin`}),l]});return(0,Si.createPortal)((0,Q.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":c?r(`attachment.previewTitle`,{name:t.filename}):r(`attachment.downloadTitle`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm animate-in fade-in-0 duration-150`,onClick:n,children:c?(0,Q.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-white/10 bg-black/30 px-3 py-2 text-white`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`close`),className:`inline-flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm text-white/75 transition-colors hover:bg-white/10 hover:text-white`,"data-agent-interactive":!0,children:[(0,Q.jsx)(B,{className:`h-4 w-4`}),r(`close`)]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium text-white/95`,children:t.filename}),(0,Q.jsx)(`div`,{className:`text-[11px] text-white/45`,children:DR(t.size)||t.mimeType})]}),u]}),(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center overflow-auto p-6`,children:o?(0,Q.jsx)(`div`,{className:`rounded-xl border border-white/10 bg-white/5 px-8 py-7 text-center text-sm text-white/80`,children:r(`attachment.loadError`,{error:o})}):i?(0,Q.jsx)(`img`,{src:i,alt:t.filename,className:`max-h-full max-w-full rounded-xl object-contain shadow-2xl animate-in zoom-in-95 duration-150`}):(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-xl border border-white/10 bg-white/5 px-5 py-3 text-sm text-white/70`,children:[(0,Q.jsx)(ut,{className:`h-4 w-4 animate-spin`}),r(`attachment.loading`)]})})]}):(0,Q.jsxs)(`div`,{className:`w-full max-w-sm rounded-2xl border border-border/70 bg-card p-4 text-foreground shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-surface/70`,children:(0,Q.jsx)($n,{className:`h-5 w-5 text-accent-primary`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`attachment.downloadTitle`)}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs font-medium text-foreground/70`,children:t.filename}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[11px] text-foreground/45`,children:[DR(t.size),t.mimeType].filter(Boolean).join(` · `)})]})]}),(0,Q.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-foreground/70`,children:r(`attachment.downloadPrompt`)}),o&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,Q.jsx)(Nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:r(`attachment.loadError`,{error:o})})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-border/70 bg-surface/70 px-3 py-2 text-sm text-foreground/75 transition-colors hover:bg-surface hover:text-foreground`,"data-agent-interactive":!0,children:r(`attachment.cancelDownload`)}),u]})]})}),document.body)}function AR({conversationId:e,attachments:t}){let{t:n}=I(`agent`),[r,i]=(0,Z.useState)(null);return!e||!t||t.length===0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 border-t border-border/40 pt-2`,children:t.map(e=>{let t=OR(e),r=t?gr:ct;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e),title:e.filename,"aria-label":n(t?`attachment.openPreview`:`attachment.openDownload`,{name:e.filename}),className:`inline-flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border/60 bg-background/45 px-2 py-1 text-left text-[11px] text-foreground/75 transition-colors hover:border-accent-primary/45 hover:bg-accent-primary/10 hover:text-foreground`,"data-agent-interactive":!0,children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.filename}),e.size>0&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[10px] text-foreground/35`,children:DR(e.size)})]},e.id)})}),(0,Q.jsx)(kR,{conversationId:e,attachment:r,onClose:()=>i(null)})]})}function jR(e){return e===`project`||e===`alias`?En:e===`spec`?ct:e===`job`?wn:e===`trace`?fr:e===`conversation`?wn:e===`file`?Lr:e===`pr`?Oe:e===`action`?gt:xn}function MR(e){return e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`spec`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function NR({refItem:e}){let t=jR(e.kind);return(0,Q.jsxs)(`span`,{title:[e.label,e.scope?.projectName,e.status].filter(Boolean).join(` · `)||e.token,className:X(`mx-0.5 inline-flex max-w-[16rem] translate-y-[2px] items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium leading-4 shadow-sm shadow-black/5`,MR(e.kind)),"data-agent-context-token":e.kind,children:[(0,Q.jsx)(t,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label||e.token})]})}function PR({content:e,contextRefs:t}){if(!t||t.length===0)return(0,Q.jsx)(Q.Fragment,{children:e});let n=[],r=0,i=0,a=new Set,o=t.map((t,n)=>({ref:t,originalIndex:n,index:t.token?e.indexOf(t.token):-1})).filter(e=>e.index>=0).sort((e,t)=>e.index-t.index||e.originalIndex-t.originalIndex);for(let t of o){let o=e.indexOf(t.ref.token,r);o<r||o===-1||(o>r&&n.push(e.slice(r,o)),n.push((0,Q.jsx)(NR,{refItem:t.ref},`${t.ref.kind}:${t.ref.id}:${o}:${t.originalIndex}`)),r=o+t.ref.token.length,a.add(t.originalIndex),i++)}r<e.length&&n.push(e.slice(r));let s=t.filter((e,t)=>!a.has(t));return s.length===0?(0,Q.jsx)(Q.Fragment,{children:i?n:e}):(0,Q.jsxs)(Q.Fragment,{children:[s.map((e,t)=>(0,Q.jsx)(NR,{refItem:e},`unmatched:${e.kind}:${e.id}:${t}`)),e.trim()&&(0,Q.jsx)(`span`,{className:`mx-0.5`}),i?n:e]})}function FR({role:e,content:t,createdAt:n,streaming:r,isLast:i,onPickOption:a,refsProjectId:o,onOpenRef:s,contextRefs:c,attachments:l,conversationId:u}){let d=e===`user`,{openWebView:f,canOpenWebView:p}=We(),m=!d&&!r&&!!o&&!!s,h=(0,Z.useMemo)(()=>m?[dn,SR]:[dn],[m]),g=(0,Z.useMemo)(()=>({a:({href:e,children:t})=>{let n=iR(e);return n&&s?(0,Q.jsx)(CR,{refTarget:n,onOpen:s,children:t}):(0,Q.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,"data-agent-interactive":!0,onClick:t=>{p&&typeof e==`string`&&/^https?:\/\//i.test(e)&&(t.preventDefault(),t.stopPropagation(),f(e))},children:t})}}),[f,p,s]);if(d)return(0,Q.jsxs)(`div`,{className:`group flex flex-col items-end gap-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-end gap-1`,children:[(0,Q.jsx)(TR,{text:t,timestampIso:n}),(0,Q.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-br-sm border border-border/50 bg-foreground/[0.06] px-3.5 py-2 text-sm text-foreground`,children:[(0,Q.jsx)(PR,{content:t,contextRefs:c}),(0,Q.jsx)(AR,{conversationId:u,attachments:l})]})]}),n&&(0,Q.jsx)(`div`,{className:`pr-1.5`,children:(0,Q.jsx)(ER,{iso:n})})]});let{body:_,options:v}=WL(t),{body:y,draft:b,pending:x}=ZL(_,r),S=!!v&&!!i&&!r&&!!a;return(0,Q.jsxs)(`div`,{className:`group flex flex-col gap-1`,children:[(0,Q.jsx)(`div`,{className:X(`max-w-full`,wR),children:(0,Q.jsx)(un,{remarkPlugins:h,components:g,children:y})}),b&&(0,Q.jsx)(eR,{draft:b}),x&&(0,Q.jsx)(tR,{}),S&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:v.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>a?.(e),className:`rounded-full border border-border/60 bg-surface/70 px-3 py-1 text-xs text-foreground/80 transition-colors hover:border-accent-primary/45 hover:bg-accent-primary/15 hover:text-foreground`,"data-agent-interactive":!0,children:e},`${t}-${e}`))}),!r&&(y.trim()||n)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y.trim()&&(0,Q.jsx)(TR,{text:y,timestampIso:n}),n&&(0,Q.jsx)(ER,{iso:n})]})]})}var IR=(0,Z.createContext)(null);function LR({children:e}){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)([]),l=(0,Z.useCallback)(()=>n(!0),[]),u=(0,Z.useCallback)(()=>n(!1),[]),d=(0,Z.useCallback)(()=>n(e=>!e),[]),f=(0,Z.useCallback)(()=>i(!0),[]),p=(0,Z.useCallback)(()=>i(!1),[]),m=(0,Z.useCallback)(()=>i(e=>!e),[]),h=(0,Z.useCallback)(()=>o(!0),[]),g=(0,Z.useCallback)(()=>o(!1),[]),_=(0,Z.useCallback)(e=>{c(t=>[...t,e])},[]),v=(0,Z.useCallback)(()=>{let e=[];return c(t=>(e=t,t.length?[]:t)),e},[]),y=(0,Z.useMemo)(()=>({codePaneOpen:t,openCodePane:l,closeCodePane:u,toggleCodePane:d,jobsPaneOpen:r,openJobsPane:f,closeJobsPane:p,toggleJobsPane:m,browserOpen:a,openBrowser:h,closeBrowser:g,pendingCaptures:s,queueCapture:_,consumePendingCaptures:v}),[t,l,u,d,r,f,p,m,a,h,g,s,_,v]);return(0,Q.jsx)(IR.Provider,{value:y,children:e})}var RR={codePaneOpen:!1,openCodePane:()=>{},closeCodePane:()=>{},toggleCodePane:()=>{},jobsPaneOpen:!1,openJobsPane:()=>{},closeJobsPane:()=>{},toggleJobsPane:()=>{},browserOpen:!1,openBrowser:()=>{},closeBrowser:()=>{},pendingCaptures:[],queueCapture:()=>{},consumePendingCaptures:()=>[]};function zR(){return(0,Z.useContext)(IR)??RR}var BR=(0,Z.createContext)(null),VR=new Set([`exited`,`killed`,`failed`]),HR=8e3;function UR({children:e}){let{registerHandler:t,unregisterHandler:n}=Et(),{active:r,draftPinnedProjectId:i}=UV(),{activeProjectId:a}=At(),o=r?.pinned_project_id??i??a,s=r?.id??null,[c,l]=(0,Z.useState)([]),u=(0,Z.useRef)(new Map),d=(0,Z.useCallback)(e=>{let t=u.current.get(e);t&&window.clearTimeout(t),u.current.delete(e)},[]),f=(0,Z.useCallback)(e=>{let t=e;if(t.type===`background_process.started`&&t.process){d(t.process.pid),l(e=>e.some(e=>e.pid===t.process.pid)?e:[...e,t.process]);return}if(t.type===`background_process.exited`&&t.process){let e=t.process;if(d(e.pid),e.status===`killed`){l(t=>t.filter(t=>t.pid!==e.pid));return}let n={...e,completedAt:Date.now()};l(t=>t.some(t=>t.pid===e.pid)?t.map(t=>t.pid===e.pid?n:t):[...t,n]);let r=window.setTimeout(()=>{l(t=>t.filter(t=>t.pid!==e.pid)),u.current.delete(e.pid)},HR);u.current.set(e.pid,r)}},[d]);(0,Z.useEffect)(()=>(t(`background-processes`,f),()=>n(`background-processes`)),[f,t,n]),(0,Z.useEffect)(()=>{if(!o||!s)return;let e=!0;return(async()=>{try{let t=new URLSearchParams({chatId:s}),n=await fetch(`${xt}/api/projects/${encodeURIComponent(o)}/background-processes?${t.toString()}`);if(!n.ok)return;let r=await n.json();if(!e||!Array.isArray(r.processes)||r.processes.length===0)return;l(e=>{let t=new Map(e.map(e=>[e.pid,e]));for(let e of r.processes??[])t.set(e.pid,e);return Array.from(t.values())})}catch{}})(),()=>{e=!1}},[s,o]),(0,Z.useEffect)(()=>()=>{for(let e of u.current.values())window.clearTimeout(e);u.current.clear()},[]);let p=(0,Z.useMemo)(()=>c.filter(e=>e.projectId===o&&e.chatId===s&&(!VR.has(e.status)||e.status!==`killed`&&e.completedAt!==void 0)),[c,o,s]),m=(0,Z.useCallback)(async e=>{!o||!s||await fetch(`${xt}/api/projects/${encodeURIComponent(o)}/background-processes/${encodeURIComponent(String(e))}?chatId=${encodeURIComponent(s)}`,{method:`DELETE`})},[s,o]),h=(0,Z.useMemo)(()=>({processes:p,kill:m}),[p,m]);return(0,Q.jsx)(BR.Provider,{value:h,children:e})}function WR(){return(0,Z.useContext)(BR)||{processes:[],kill:async()=>void 0}}var GR=new Set([`@`,`#`,`/`]),KR=/[\s()[\]{}<>"']/;function qR(e,t=e.length){let n=Math.max(0,Math.min(t,e.length));for(let t=n-1;t>=0;t--){let r=e[t];if(r===`
|
|
60
|
-
`||r===` `||r===` `)break;if(!GR.has(r))continue;let i=t===0?``:e[t-1];if(i&&!KR.test(i))continue;let a=e.slice(t+1,n);if(/[()[\]{}<>"']/.test(a))return null;let o=r;return{trigger:o,mode:o===`@`?`reference`:o===`#`?`trace`:`action`,query:a,start:t,end:n}}return null}function JR(e){return`${e.kind}:${e.id}`}function YR(e){return{kind:e.kind,id:e.id,label:e.label,token:e.token,scope:{projectId:e.projectId??null,projectName:e.projectName??null},status:e.status??null,metadata:e.metadata}}function XR(e,t){return t?e.find(e=>e.id===t)?.name??null:null}function ZR(e){return{kind:`project`,id:e.id,label:e.name,token:`@${e.name}`,detail:e.path,projectId:e.id,projectName:e.name,metadata:{slug:e.slug,path:e.path}}}function QR(e,t,n){return{kind:`spec`,id:String(e.id),label:e.title,token:`@${e.title}`,detail:n?`${n} / #${e.id}`:`#${e.id}`,status:e.status,projectId:t,projectName:n,metadata:{ticketId:e.id,priority:e.priority,labels:e.labels,shortSummary:e.short_summary??null}}}function $R(e,t,n){let r=e.id.slice(0,8);return{kind:`job`,id:e.id,label:r,token:`#${r}`,detail:n?`${n} / ${e.command}`:e.command,status:e.status,projectId:t,projectName:n,metadata:{command:e.command,startedAt:e.started_at,costUsd:e.total_cost_usd??null}}}function ez(e,t){let n=e.title||`Untitled mission`;return{kind:`conversation`,id:e.id,label:n,token:`@${n}`,detail:t?`Mission / ${t}`:`Mission`,projectId:e.pinned_project_id,projectName:t,metadata:{provider:e.provider}}}function tz(e,t){let n=t.trim().toLowerCase();return!n||[e.title,e.subtitle,e.detail,e.group,...e.keywords??[]].filter(Boolean).join(` `).toLowerCase().includes(n)}function nz(e){let t=new Set,n=[];for(let r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function rz(e,t){return nz(e).filter(e=>tz(e,t)).slice(0,12)}function iz(e){let t=XR(e.projects,e.pinnedProjectId),n=e.pinnedProjectId?e.projects.find(t=>t.id===e.pinnedProjectId)??null:null,r=[];if(n&&r.push({id:`alias:current-project:${n.id}`,mode:`reference`,title:`@current`,subtitle:n.name,detail:`Pinned project`,group:`Current`,icon:`alias`,chip:{...ZR(n),kind:`alias`,id:`current:${n.id}`,token:`@current`},keywords:[`this`,`project`,n.name]}),e.activeConversation){let n=ez(e.activeConversation,t);r.push({id:`conversation:${e.activeConversation.id}`,mode:`reference`,title:n.label,subtitle:n.detail,detail:`Current mission`,group:`Created here`,icon:`conversation`,chip:n,keywords:[`mission`,`conversation`,`last`]})}for(let t of e.chips)r.push({id:`chip:${JR(t)}`,mode:`reference`,title:t.label,subtitle:t.detail,detail:`Already in context`,group:`Current context`,icon:t.kind,chip:t});let i=e.tickets.map(n=>{let r=QR(n,e.pinnedProjectId,t),i=n.status===`on_review`||n.status===`in_progress`||n.status===`draft`;return{id:`spec:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:n.title,subtitle:`Spec #${n.id}${n.status?` · ${n.status}`:``}`,detail:r.detail,group:i?`Active in project`:`Specs`,icon:`spec`,chip:r,keywords:[String(n.id),n.priority??``,...n.labels??[]]}});r.push(...i);let a=e.jobs.slice(0,8).map(n=>{let r=$R(n,e.pinnedProjectId,t);return{id:`job:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:r.label,subtitle:`Job · ${n.status}`,detail:n.command,group:n.status===`running`||n.status===`failed`?`Needs attention`:`Recent jobs`,icon:`job`,chip:r,keywords:[n.id,n.command,n.status]}});r.push(...a);for(let t of e.projects){let n=ZR(t);r.push({id:`project:${t.id}`,mode:`reference`,title:t.name,subtitle:`Project`,detail:t.path,group:t.id===e.activeProjectId?`Current app project`:`Projects`,icon:`project`,chip:n,keywords:[t.slug,t.path]})}return r}function az(e){let t=XR(e.projects,e.pinnedProjectId),n=[];for(let r of e.jobs){let i=$R(r,e.pinnedProjectId,t);n.push({id:`trace:job:${r.id}`,mode:`trace`,title:i.label,subtitle:`${r.status} · ${r.command}`,detail:t??void 0,group:r.status===`failed`||r.status===`running`?`Active traces`:`Recent traces`,icon:`job`,chip:{...i,kind:`trace`},keywords:[r.id,r.command,r.status,`failed`,`running`,`deploy`,`run`]})}for(let r of e.tickets){let i=QR(r,e.pinnedProjectId,t);n.push({id:`trace:spec:${r.id}`,mode:`trace`,title:`#${r.id}`,subtitle:`${r.title} · ${r.status}`,detail:t??void 0,group:`IDs`,icon:`spec`,chip:{...i,kind:`trace`,token:`#${r.id}`},keywords:[String(r.id),r.title,r.status]})}return n}var oz=[{id:`action:create-spec`,mode:`action`,title:`Create spec`,subtitle:`Turn this into a structured spec`,group:`Create`,icon:`action`,insertText:`/create spec`,tierLevel:2,risk:`cost`,keywords:[`new ticket quick add`]},{id:`action:explore-spec`,mode:`action`,title:`Explore spec`,subtitle:`Refine a fuzzy idea first`,group:`Refine`,icon:`action`,insertText:`/explore spec`,tierLevel:2,risk:`cost`,keywords:[`discovery draft requirements`]},{id:`action:update-spec`,mode:`action`,title:`Update spec`,subtitle:`Edit the selected spec`,group:`Refine`,icon:`action`,insertText:`/update spec`,tierLevel:1,keywords:[`edit ticket`]},{id:`action:assign-rail`,mode:`action`,title:`Assign to rail`,subtitle:`Put selected specs on a rail`,group:`Execute`,icon:`action`,insertText:`/assign to rail`,tierLevel:1,keywords:[`tickets rail`]},{id:`action:launch-rail`,mode:`action`,title:`Launch rail`,subtitle:`Run the selected rail or spec`,group:`Execute`,icon:`action`,insertText:`/launch rail`,tierLevel:2,risk:`cost`,keywords:[`run implement`]},{id:`action:launch-all`,mode:`action`,title:`Launch all eligible rails`,subtitle:`Start every ready rail in parallel`,group:`Execute`,icon:`action`,insertText:`/launch all eligible rails`,tierLevel:2,risk:`cost`,keywords:[`all rails run`]},{id:`action:status`,mode:`action`,title:`Show status`,subtitle:`Summarize the current workbench`,group:`Review`,icon:`action`,insertText:`/status`,tierLevel:0,keywords:[`state overview`]},{id:`action:diagnose`,mode:`action`,title:`Diagnose`,subtitle:`Inspect git, jobs, setup, Jira, and failures`,group:`Review`,icon:`action`,insertText:`/diagnose`,tierLevel:0,keywords:[`debug health failed`]},{id:`action:compare`,mode:`action`,title:`Compare`,subtitle:`Compare selected specs, jobs, diffs, or costs`,group:`Review`,icon:`action`,insertText:`/compare`,tierLevel:0,keywords:[`diff versus`]},{id:`action:summarize`,mode:`action`,title:`Summarize`,subtitle:`Condense selected context`,group:`Review`,icon:`action`,insertText:`/summarize`,tierLevel:0,keywords:[`recap`]},{id:`action:save-as-spec`,mode:`action`,title:`Save as spec`,subtitle:`Capture the selected context as durable work`,group:`Create`,icon:`action`,insertText:`/save as spec`,tierLevel:1,keywords:[`persist capture`]},{id:`action:generate-report`,mode:`action`,title:`Generate report`,subtitle:`Create a written artifact from selected context`,group:`Create`,icon:`action`,insertText:`/generate report`,tierLevel:1,keywords:[`document export`]},{id:`action:show-spend`,mode:`action`,title:`Show spend`,subtitle:`Review cost and budget impact`,group:`Review`,icon:`action`,insertText:`/show spend`,tierLevel:0,keywords:[`cost budget analytics`]},{id:`action:search`,mode:`action`,title:`Search current project`,subtitle:`Find specs, jobs, files, or context`,group:`Navigate`,icon:`action`,insertText:`/search`,tierLevel:0,keywords:[`find`]},{id:`action:search-all`,mode:`action`,title:`Search all projects`,subtitle:`Fan out across registered projects`,group:`Navigate`,icon:`action`,insertText:`/search all projects`,tierLevel:0,keywords:[`global home`]},{id:`action:open`,mode:`action`,title:`Open item`,subtitle:`Open the selected object in Specrails`,group:`Navigate`,icon:`action`,insertText:`/open`,tierLevel:0,keywords:[`navigate`]},{id:`action:wait`,mode:`action`,title:`Wait for result`,subtitle:`Follow a running job or trace`,group:`Review`,icon:`action`,insertText:`/wait for result`,tierLevel:0,keywords:[`watch running`]},{id:`action:show-diff`,mode:`action`,title:`Show diff`,subtitle:`Inspect changes from the selected job`,group:`Review`,icon:`action`,insertText:`/show diff`,tierLevel:0,keywords:[`files changes`]},{id:`action:diagnostic`,mode:`action`,title:`Export diagnostic`,subtitle:`Collect job telemetry and logs`,group:`Review`,icon:`action`,insertText:`/export diagnostic`,tierLevel:0,keywords:[`zip logs telemetry`]},{id:`action:cancel-job`,mode:`action`,title:`Cancel job`,subtitle:`Stop or delete a selected job`,group:`Clean up`,icon:`action`,insertText:`/cancel job`,tierLevel:3,risk:`destructive`,keywords:[`stop kill`]},{id:`action:refine-contract`,mode:`action`,title:`Refine contract`,subtitle:`Add or refresh the Contract Layer`,group:`Refine`,icon:`action`,insertText:`/refine contract`,tierLevel:2,risk:`cost`,keywords:[`contract`]},{id:`action:split-epic`,mode:`action`,title:`Split epic`,subtitle:`Decompose a large spec into children`,group:`Refine`,icon:`action`,insertText:`/split epic`,tierLevel:2,risk:`cost`,keywords:[`smash children`]},{id:`action:files-touched`,mode:`action`,title:`Show files touched`,subtitle:`Inspect provenance for selected work`,group:`Review`,icon:`action`,insertText:`/show files touched`,tierLevel:0,keywords:[`provenance`]},{id:`action:connect-jira`,mode:`action`,title:`Connect Jira`,subtitle:`Start the Jira connection flow`,group:`Integrate`,icon:`action`,insertText:`/connect Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:sync-jira`,mode:`action`,title:`Sync Jira`,subtitle:`Refresh Jira-backed specs`,group:`Integrate`,icon:`action`,insertText:`/sync Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:install-plugin`,mode:`action`,title:`Install plugin`,subtitle:`Preview and install an integration`,group:`Integrate`,icon:`action`,insertText:`/install plugin`,tierLevel:1,keywords:[`mcp integration`]},{id:`action:set-budget`,mode:`action`,title:`Set budget`,subtitle:`Adjust spend guardrails`,group:`Configure`,icon:`action`,insertText:`/set budget`,tierLevel:1,keywords:[`cost limit`]}];function sz(e,t,n){let r=new Set(t.map(e=>e.kind)),i=0;return t.length===0&&([`action:create-spec`,`action:search`,`action:status`,`action:diagnose`,`action:show-spend`].includes(e.id)&&(i+=40),n.pinnedProjectId&&e.id===`action:launch-all`&&(i+=30)),r.has(`project`)&&[`action:status`,`action:search`,`action:launch-all`,`action:show-spend`,`action:sync-jira`,`action:install-plugin`].includes(e.id)&&(i+=50),r.has(`spec`)&&[`action:update-spec`,`action:assign-rail`,`action:launch-rail`,`action:refine-contract`,`action:split-epic`,`action:files-touched`,`action:show-spend`].includes(e.id)&&(i+=70),(r.has(`job`)||r.has(`trace`))&&[`action:open`,`action:wait`,`action:compare`,`action:show-diff`,`action:diagnostic`,`action:cancel-job`].includes(e.id)&&(i+=80),r.has(`file`)&&[`action:summarize`,`action:show-diff`,`action:files-touched`].includes(e.id)&&(i+=60),i}function cz(e){return[...oz].sort((t,n)=>sz(n,e.chips,e)-sz(t,e.chips,e)).map(e=>({...e,chip:{kind:`action`,id:e.id,label:e.title,token:e.insertText??`/${e.title.toLowerCase()}`,detail:e.subtitle,metadata:{tierLevel:e.tierLevel,risk:e.risk??null}}}))}function lz(e,t){return e===`reference`?iz(t):e===`trace`?az(t):cz(t)}function uz(e,t){let n=t.trim();if(!n)return[];let r=n.slice(0,80),i=[{id:`fallback:search-all:${e}:${r}`,mode:e,title:`Search all Specrails`,subtitle:`Find "${r}" across every project`,group:`No matches`,icon:`action`,insertText:`/search all projects ${r}`,tierLevel:0,keywords:[`fallback global search all`]},{id:`fallback:ask-agent:${e}:${r}`,mode:e,title:`Ask agent about "${r}"`,subtitle:`Keep the wording and let the agent resolve it`,group:`No matches`,icon:`action`,insertText:r,tierLevel:0,keywords:[`fallback ask agent clarify`]}];return e===`trace`?i.splice(1,0,{id:`fallback:archived:${e}:${r}`,mode:e,title:`Include archived results`,subtitle:`Search completed, canceled, and old traces for "${r}"`,group:`No matches`,icon:`action`,insertText:`/search all projects archived ${r}`,tierLevel:0,keywords:[`fallback archived old completed canceled`]}):i.splice(1,0,{id:`fallback:create-spec:${e}:${r}`,mode:e,title:`Create "${r}"`,subtitle:`Turn this unmatched reference into a spec`,group:`No matches`,icon:`action`,insertText:`/create spec ${r}`,tierLevel:2,risk:`cost`,keywords:[`fallback create new spec`]}),i}function dz(e,t,n){let r=n.insertText??n.chip?.token??n.title,i=t?.start??e.length,a=t?.end??e.length,o=e.slice(0,i),s=e.slice(a),c=o&&!/\s$/.test(o)?` `:``,l=s&&!/^\s/.test(s)?` `:``;return{text:`${o}${c}${r}${l}${s}`,caret:o.length+c.length+r.length+l.length}}var fz=`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground outline-none transition-colors hover:bg-surface/70 focus-visible:ring-2 focus-visible:ring-accent-primary/50 disabled:cursor-not-allowed disabled:opacity-50`,pz=`overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,mz=`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground outline-none hover:bg-surface/70 focus-visible:bg-surface/70`;function hz({label:e,value:t,options:n,icon:r,onSelect:i,placeholder:a,disabled:o=!1,testId:s}){return(0,Q.jsxs)(cp,{value:t,onValueChange:i,disabled:o||n.length===0,children:[(0,Q.jsxs)(lp,{"aria-label":e,title:e,"data-agent-interactive":!0,"data-testid":s,className:fz,children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,Q.jsx)(up,{placeholder:a??e,className:`max-w-[160px] truncate`}),(0,Q.jsx)(dp,{asChild:!0,children:(0,Q.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})})]}),(0,Q.jsx)(fp,{children:(0,Q.jsxs)(pp,{position:`popper`,side:`top`,align:`start`,sideOffset:4,collisionPadding:8,className:`z-[80] min-w-[12rem] max-w-[20rem] ${pz} data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1`,children:[(0,Q.jsx)(yp,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,Q.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(mp,{className:`max-h-72 py-1`,children:n.map(e=>{let t=e.icon??r;return(0,Q.jsxs)(gp,{value:e.value,className:`${mz} relative cursor-default select-none pr-9 data-[highlighted]:bg-surface/70 data-[state=checked]:font-medium`,children:[(0,Q.jsx)(t,{className:`h-4 w-4 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,Q.jsx)(_p,{children:(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})}),(0,Q.jsx)(vp,{className:`absolute right-3 flex items-center`,children:(0,Q.jsx)(be,{className:`h-3.5 w-3.5 text-accent-primary`})})]},e.value)})}),(0,Q.jsx)(bp,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,Q.jsx)(pe,{className:`h-3.5 w-3.5`})})]})})]})}function gz({pinnedProjectId:e,onSelect:t}){let{t:n}=I(`agent`),{projects:r}=At(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(0),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useId)(),p=(0,Z.useCallback)((e=!1)=>{a(!1),s(``),l(0),e&&d.current?.focus()},[]);(0,Z.useEffect)(()=>{if(!i)return;let e=e=>{u.current&&!u.current.contains(e.target)&&p()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i,p]);let m=r.find(t=>t.id===e)??null,h=(0,Z.useMemo)(()=>{let e=o.trim().toLowerCase();return e?r.filter(t=>t.name.toLowerCase().includes(e)):r},[r,o]),g=h.length+1;(0,Z.useEffect)(()=>{l(o.trim()?h.length>0?1:-1:0)},[o,h.length]);let _=()=>{let t=e?r.findIndex(t=>t.id===e):-1;l(t>=0?t+1:0),a(!0)},v=e=>{t(e),p(!0)},y=()=>{if(!(c<0))if(c===0)v(null);else{let e=h[c-1];e&&v(e.id)}};return(0,Q.jsxs)(`div`,{className:`relative`,ref:u,"data-agent-interactive":!0,onKeyDown:e=>{if(!i){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),_());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;l(e=>(e+t+g)%g)}else e.key===`Enter`?(e.preventDefault(),y()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p(!0))},children:[(0,Q.jsxs)(`button`,{ref:d,type:`button`,onClick:()=>i?p():_(),"aria-haspopup":`listbox`,"aria-expanded":i,"aria-controls":f,className:fz,children:[m?(0,Q.jsx)(ir,{className:`h-3.5 w-3.5 text-accent-primary`}):(0,Q.jsx)(hr,{className:`h-3.5 w-3.5 text-foreground/70`}),(0,Q.jsx)(`span`,{className:`max-w-[160px] truncate`,children:m?m.name:n(`project.home`)}),(0,Q.jsx)(pe,{className:`h-3.5 w-3.5 text-foreground/50`})]}),(0,Q.jsx)(MF,{children:i&&(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-64 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Q.jsx)(ht,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),role:`combobox`,placeholder:n(`project.searchProjectsPlaceholder`),"aria-label":n(`project.searchProjectsPlaceholder`),"aria-expanded":i,"aria-autocomplete":`list`,"aria-controls":f,"aria-activedescendant":c>=0?`${f}-option-${c}`:void 0,className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Q.jsxs)(`div`,{id:f,role:`listbox`,"aria-label":n(`project.allProjects`),className:`max-h-72 overflow-y-auto py-1`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-1 text-[11px] uppercase tracking-wide text-foreground/40`,children:n(`project.recents`)}),(0,Q.jsx)(_z,{id:`${f}-option-0`,icon:(0,Q.jsx)(hr,{className:`h-4 w-4`}),label:n(`project.home`),active:!e,highlighted:c===0,onMouseEnter:()=>l(0),onClick:()=>v(null),index:0}),h.map((t,n)=>(0,Q.jsx)(_z,{id:`${f}-option-${n+1}`,icon:(0,Q.jsx)(ir,{className:`h-4 w-4 text-accent-primary`}),label:t.name,active:t.id===e,highlighted:c===n+1,onMouseEnter:()=>l(n+1),onClick:()=>v(t.id),index:n+1},t.id))]})]})})]})}function _z({id:e,icon:t,label:n,active:r,highlighted:i,onMouseEnter:a,onClick:o,index:s}){return(0,Q.jsxs)(ML.button,{id:e,type:`button`,role:`option`,"aria-selected":r,tabIndex:-1,onMouseEnter:a,onClick:o,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(s*.03,.18)},className:`${mz} ${i?`bg-surface/70`:``}`,children:[t,(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:n}),r&&(0,Q.jsx)(be,{className:`h-3.5 w-3.5 text-accent-primary`})]})}var vz=[{level:0,key:`observe`,icon:Xn,tone:`text-foreground/70`,bar:`bg-accent-info`},{level:1,key:`edit`,icon:dt,tone:`text-accent-info`,bar:`bg-accent-info`},{level:2,key:`operate`,icon:bt,tone:`text-accent-warning`,bar:`bg-accent-warning`},{level:3,key:`autonomous`,icon:tr,tone:`text-destructive`,bar:`bg-destructive`}];function yz({level:e,onCycle:t}){let{t:n}=I(`agent`),r=vz[e],i=r.icon;return(0,Q.jsxs)(`button`,{type:`button`,onClick:t,title:n(`tier.${r.key}.desc`),"aria-label":`${n(`tier.${r.key}.name`)} — ${n(`tier.cycleHint`)}`,className:`group flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/70 px-2.5 py-1 text-xs font-medium ${r.tone} transition-colors hover:bg-surface`,"data-agent-interactive":!0,children:[(0,Q.jsxs)(ML.span,{initial:{scale:.8},animate:{scale:[1,1.18,1]},transition:{duration:.28,ease:`easeOut`},className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(i,{className:`h-3.5 w-3.5`}),n(`tier.${r.key}.name`)]},e),(0,Q.jsx)(`span`,{className:`ml-1 flex gap-0.5`,"aria-hidden":!0,children:vz.map(t=>(0,Q.jsx)(`span`,{className:`h-1 w-2 rounded-full transition-colors duration-200 ${t.level<=e?r.bar:`bg-border/50`}`},t.level))})]})}function bz({models:e,model:t,onSelect:n,status:r=`ready`,disabled:i=!1,testId:a=`agent-model-selector`}){let{t:o}=I(`agent`),s=t??e.find(e=>e.default)?.value??e[0]?.value??``,c=o(r===`loading`?`model.loading`:r===`error`?`model.unavailable`:`model.label`);return(0,Q.jsx)(hz,{label:o(`model.label`),value:s,options:e.map(e=>({value:e.value,label:e.label})),icon:gt,onSelect:n,placeholder:c,disabled:i||r!==`ready`,testId:a})}function xz(e){return{provider:e,models:[],efforts:[],supportsImageInput:!0,status:`loading`}}function Sz(e){let[t,n]=(0,Z.useState)(()=>xz(e));return(0,Z.useEffect)(()=>{let t=!0;return n(xz(e)),hE(e).then(r=>{t&&n({provider:e,models:r.models,efforts:r.efforts,supportsImageInput:r.supportsImageInput,status:`ready`})}).catch(()=>{t&&n({...xz(e),status:`error`})}),()=>{t=!1}},[e]),t.provider===e?t:xz(e)}function Cz({projectId:e}){let{t}=I(`agent`),{isStreaming:n}=UV(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``),d=(0,Z.useRef)(null),f=`${xt}/api/projects/${e}/git`,p=(0,Z.useCallback)(async()=>{try{let e=await fetch(f);if(!e.ok)return;i(await e.json())}catch{}},[f]);(0,Z.useEffect)(()=>{i(null),p()},[p]);let m=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{m.current&&!n&&p(),m.current=n},[n,p]),(0,Z.useEffect)(()=>{if(!s)return;let e=e=>{d.current&&!d.current.contains(e.target)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let h=(0,Z.useCallback)(async e=>{if(c(!1),u(``),!(!e||e===r?.branch)){o(!0);try{let n=await fetch(`${f}/checkout`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({branch:e})}),r=await n.json().catch(()=>({}));if(!n.ok){R.error(t(`git.switchFailed`),{description:r.error}),p();return}i(r),R.success(t(`git.switched`,{branch:e}))}catch{R.error(t(`git.switchFailed`)),p()}finally{o(!1)}}},[f,r?.branch,t,p]),g=(0,Z.useMemo)(()=>{if(!r)return[];let e=l.trim().toLowerCase();return e?r.branches.filter(t=>t.toLowerCase().includes(e)):r.branches},[r,l]);if(!r?.git)return null;let _=a||n,v=r.detached?t(`git.detached`):r.branch??t(`git.detached`),y=new Map((r.worktrees??[]).filter(e=>!e.isMain&&e.branch).map(e=>[e.branch,e])),b=g.filter(e=>!y.has(e)),x=g.filter(e=>y.has(e)),S=async e=>{c(!1),u(``);try{await navigator.clipboard.writeText(e.path),R.success(t(`git.worktreePathCopied`),{description:e.path})}catch{R.info?.(e.path)}};return(0,Q.jsxs)(`div`,{ref:d,className:`relative mt-1.5 flex min-w-0 items-center gap-2 px-1 text-[11px] text-foreground/50`,"data-agent-interactive":!0,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{_||c(e=>!e)},disabled:_,"aria-label":t(`git.branch`),"aria-expanded":s,title:t(_&&n?`git.lockedWhileWorking`:`git.branch`),className:`flex max-w-[220px] shrink-0 items-center gap-1.5 rounded-md border border-border/50 bg-surface/60 px-1.5 py-0.5 text-[11px] text-foreground transition-colors hover:bg-surface disabled:opacity-50`,children:[a?(0,Q.jsx)(ut,{className:`h-3 w-3 shrink-0 animate-spin text-accent-primary/70`}):(0,Q.jsx)(lt,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:v}),(0,Q.jsx)(pe,{className:`h-3 w-3 shrink-0 text-foreground/40`})]}),(0,Q.jsx)(MF,{children:s&&(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute bottom-full left-0 z-20 mb-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Q.jsx)(ht,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:t(`git.searchPlaceholder`),"aria-label":t(`git.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Q.jsxs)(`div`,{className:`max-h-64 overflow-y-auto py-1`,role:`listbox`,"aria-label":t(`git.branch`),children:[g.length===0&&(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:t(`git.noMatches`)}),b.map((e,t)=>(0,Q.jsxs)(ML.button,{type:`button`,role:`option`,"aria-selected":e===r.branch,onClick:()=>void h(e),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.02,.16)},className:`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,Q.jsx)(lt,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),e===r.branch&&(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`})]},e)),x.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-1 border-t border-border/50 px-3 pb-0.5 pt-1.5 text-[10px] uppercase tracking-wide text-foreground/40`,children:t(`git.worktrees`)}),x.map((e,n)=>{let r=y.get(e);return(0,Q.jsxs)(ML.button,{type:`button`,role:`option`,"aria-selected":!1,onClick:()=>void S(r),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(n*.02,.16)},title:t(`git.copyWorktreePath`),className:`group flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,Q.jsx)(nr,{className:`h-3.5 w-3.5 shrink-0 text-accent-secondary/80`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-mono text-xs`,children:e}),(0,Q.jsx)(`span`,{className:`block truncate text-[10px] text-foreground/40`,children:r.path})]}),(0,Q.jsx)(Un,{className:`h-3 w-3 shrink-0 text-foreground/30 opacity-0 transition-opacity group-hover:opacity-100`})]},e)})]})]})]})}),r.dirty&&(0,Q.jsx)(`span`,{title:t(`git.dirty`),"aria-label":t(`git.dirty`),className:`h-1.5 w-1.5 shrink-0 rounded-full bg-accent-warning`}),r.lastCommit&&(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`${r.lastCommit.hash} · ${r.lastCommit.subject}`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-foreground/40`,children:r.lastCommit.hash}),` · `,r.lastCommit.subject]})]})}var wz={reference:xn,trace:fr,action:gt},Tz={project:En,spec:ct,job:wn,trace:fr,conversation:wn,file:Lr,alias:xn,pr:Oe,action:gt};function Ez(e){return e===`reference`?`@`:e===`trace`?`#`:`/`}function Dz(e){return e===`spec`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function Oz({chips:e,onRemove:t}){let{t:n}=I(`agent`);return e.length===0?null:(0,Q.jsx)(Q.Fragment,{children:e.map(e=>{let r=Tz[e.kind]??xn;return(0,Q.jsxs)(`span`,{title:[e.label,e.detail,e.projectName,e.status].filter(Boolean).join(` · `),className:`inline-flex max-w-[240px] items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] ${Dz(e.kind)}`,children:[(0,Q.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),e.status&&(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:e.status}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":n(`palette.remove`,{label:e.label}),className:`rounded-sm text-foreground/45 hover:bg-background/60 hover:text-foreground`,children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]},`${e.kind}:${e.id}`)})})}function kz({items:e,mode:t,query:n,activeIndex:r,onActiveIndexChange:i,onSelect:a}){let{t:o}=I(`agent`),s=wz[t],c=``;return(0,Q.jsxs)(`div`,{"data-testid":`agent-context-palette`,className:`absolute bottom-[calc(100%+0.5rem)] left-0 right-0 z-30 overflow-hidden rounded-lg border border-border/70 bg-background/95 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-6 w-6 items-center justify-center rounded-md bg-surface text-foreground/70`,children:(0,Q.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`text-xs font-medium text-foreground`,children:[Ez(t),` `,o(`palette.mode.${t}.title`)]}),(0,Q.jsx)(`div`,{className:`truncate text-[11px] text-foreground/45`,children:n?o(`palette.filtering`,{query:n}):o(`palette.mode.${t}.hint`)})]}),(0,Q.jsx)(`div`,{className:`hidden text-[10px] text-foreground/35 sm:block`,children:o(`palette.keyboard`)})]}),e.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3 text-xs text-foreground/55`,children:[(0,Q.jsx)(ht,{className:`h-3.5 w-3.5 text-foreground/35`}),(0,Q.jsx)(`span`,{children:n?o(`palette.noMatchesFor`,{query:n}):o(`palette.noMatches`)})]}):(0,Q.jsx)(`div`,{className:`max-h-[19rem] overflow-y-auto py-1`,children:e.map((e,t)=>{let n=Tz[e.icon]??gt,o=e.group!==c;c=e.group;let s=t===r;return(0,Q.jsxs)(`div`,{children:[o&&(0,Q.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/35`,children:e.group}),(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":s,onMouseEnter:()=>i(t),onMouseDown:e=>e.preventDefault(),onClick:()=>a(e),className:`flex w-full items-center gap-2 px-2.5 py-2 text-left transition-colors ${s?`bg-accent-primary/10 text-foreground`:`text-foreground/80 hover:bg-surface/70`}`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${s?`bg-background text-accent-primary`:`bg-surface text-foreground/50`}`,children:(0,Q.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title}),e.risk&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border/60 px-1 py-0.5 text-[10px] uppercase text-foreground/45`,children:e.risk})]}),(e.subtitle||e.detail)&&(0,Q.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-foreground/45`,children:[e.subtitle,e.subtitle&&e.detail?` · `:``,e.detail]})]})]})]},e.id)})})]})}function Az({open:e,canAttach:t,uploading:n,onToggle:r,onClose:i,onOpenMode:a,onAttachFile:o}){let{t:s}=I(`agent`),c=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t instanceof Node&&c.current?.contains(t)||i()},n=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n,!0)}},[e,i]),(0,Q.jsxs)(`div`,{ref:c,className:`relative mb-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:r,"aria-label":s(`palette.addContextAction`),title:s(`palette.addContextAction`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/50 hover:bg-surface hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(pt,{className:`h-4 w-4`})}),e&&(0,Q.jsxs)(`div`,{className:`absolute bottom-8 left-0 z-40 w-64 overflow-hidden rounded-lg border border-border/70 bg-background/95 py-1 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`reference`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Q.jsx)(xn,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.reference`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.referenceHint`)})]})]}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`trace`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Q.jsx)(fr,{className:`h-4 w-4 text-accent-info`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.trace`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.traceHint`)})]})]}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`action`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Q.jsx)(gt,{className:`h-4 w-4 text-accent-highlight`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.action`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.actionHint`)})]})]}),(0,Q.jsx)(`div`,{className:`my-1 border-t border-border/60`}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:o,disabled:!t||n,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface disabled:cursor-not-allowed disabled:opacity-45`,children:[(0,Q.jsx)(Lr,{className:`h-4 w-4 text-foreground/50`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.fileAttachment`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.fileAttachmentHint`)})]})]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:!0,className:`flex w-full cursor-not-allowed items-center gap-2 px-3 py-2 text-left text-sm opacity-45`,children:[(0,Q.jsx)(On,{className:`h-4 w-4 text-foreground/50`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.browserCapture`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.browserCaptureHint`)})]})]})]})]})}var jz={"accent-primary":`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,"accent-info":`border-accent-info/40 bg-accent-info/10 text-accent-info`,"accent-highlight":`border-accent-highlight/40 bg-accent-highlight/10 text-accent-highlight`};function Mz({process:e,accentVariant:t,onKill:n}){let[r,i]=(0,Z.useState)(Date.now());(0,Z.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let a=iv(r-e.startedAt),o=e.status===`exited`||e.status===`failed`||e.status===`killed`;return(0,Q.jsx)(_m,{delayDuration:150,children:(0,Q.jsxs)(vm,{children:[(0,Q.jsx)(ym,{asChild:!0,children:(0,Q.jsxs)(`span`,{"data-testid":`background-process-chip`,className:`group inline-flex max-w-[220px] items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] transition-colors ${jz[t]}`,children:[(0,Q.jsx)(fi,{className:`h-3 w-3 shrink-0 ${o?``:`animate-pulse`}`}),(0,Q.jsx)(`span`,{className:e.status===`failed`?`shrink-0 font-medium text-destructive`:`shrink-0 text-foreground/60`,children:e.status}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.command}),!o&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Kill ${e.command}`,title:`Kill ${e.command}`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.pid)},className:`rounded-sm p-0.5 opacity-70 transition-opacity hover:bg-background/60 hover:opacity-100 group-hover:opacity-100`,children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]})}),(0,Q.jsx)(bm,{children:o?`${e.status} after ${a}`:a})]})})}var Nz=[`claude`,`codex`,`gemini`];function Pz(e,t){if(!t)return{text:e,caret:e.length};let n=e.slice(0,t.start),r=e.slice(t.end);/\s$/.test(n)&&/^\s/.test(r)&&(r=r.replace(/^\s+/,``));let i=n&&r&&!/\s$/.test(n)&&!/^\s/.test(r)?` `:``;return{text:`${n}${i}${r}`,caret:n.length+i.length}}var Fz=new Map,Iz=new Map,Lz=`__new-mission__`;function Rz({autoFocus:e=!1,hideProjectSelector:t=!1}){let{t:n}=I(`agent`),{active:r,messages:i,conversations:a,isStreaming:o,providersReady:s,draftPinnedProjectId:c,draftProvider:l,draftModel:u,draftTierLevel:d,draftEffort:f,setEffort:p,send:m,abort:h,cycleTier:g,setProvider:_,setModel:v,setPinnedProject:y,materializeDraftConversation:b,queuedMessages:x,editQueuedMessage:S,wasQueueConsumed:C}=UV(),{pendingCaptures:w,consumePendingCaptures:T}=zR(),{processes:E,kill:D}=WR(),{projects:O,activeProjectId:k}=At(),A=r?.id??Lz,[j,M]=(0,Z.useState)(()=>Fz.get(A)??``),N=e=>{M(e),e?Fz.set(A,e):Fz.delete(A)},[P,F]=(0,Z.useState)(null),[L,z]=(0,Z.useState)(()=>Iz.get(A)??[]),B=(0,Z.useRef)(A);B.current=A;let V=(e,t)=>{let n=Iz.get(e)??[],r=typeof t==`function`?t(n):t;r.length>0?Iz.set(e,r):Iz.delete(e);let i=B.current;(i===e||i===Lz&&e!==Lz)&&z(r)},[H,U]=(0,Z.useState)(!1),W=(0,Z.useRef)(null),ee=(0,Z.useRef)(null),[te,G]=(0,Z.useState)([]),[K,ne]=(0,Z.useState)(null),[re,ie]=(0,Z.useState)(0),[ae,oe]=(0,Z.useState)(!1),[se,ce]=(0,Z.useState)([]),[le,q]=(0,Z.useState)([]),ue=P!==null,de=(0,Z.useMemo)(()=>i.filter(e=>e.role===`user`).map(e=>e.content),[i]),[fe,pe]=(0,Z.useState)(null),me=(0,Z.useRef)(``),he=(0,Z.useRef)(``),ge=fe===null?-1:x.findIndex(e=>e.queueId===fe),_e=ge>=0?x[ge]:null,ve=fe!==null,ye=s===!1,J=!ye,xe=r?.provider??l,Se=r?r.pinned_project_id:c,Ce=Se,we=(0,Z.useMemo)(()=>({projects:O,conversations:a,activeConversation:r,pinnedProjectId:Ce,activeProjectId:k,tickets:se,jobs:le,chips:te}),[O,a,r,Ce,k,se,le,te]),Te=(0,Z.useMemo)(()=>K?lz(K.mode,we):[],[K,we]),Ee=(0,Z.useMemo)(()=>{if(!K)return[];let e=rz(Te,K.query);return e.length>0?e:uz(K.mode,K.query)},[Te,K]),De=K!==null&&!ve,Oe=j.trim().length>0||te.length>0,ke=[`accent-primary`,`accent-info`,`accent-highlight`],Ae=r?.id??null;(0,Z.useEffect)(()=>{z(Iz.get(Ae??Lz)??[]),F(null),ne(null),oe(!1),G([]),pe(null),M(Fz.get(Ae??Lz)??``)},[Ae]),(0,Z.useEffect)(()=>{if(!Ce){ce([]),q([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${xt}/api/projects/${encodeURIComponent(Ce)}/tickets`),fetch(`${xt}/api/projects/${encodeURIComponent(Ce)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;ce(Array.isArray(r.tickets)?r.tickets:[]),q(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;ce([]),q([])}})(),()=>{e=!1}},[Ce]),(0,Z.useEffect)(()=>{ie(0)},[K?.mode,K?.query]),(0,Z.useEffect)(()=>{re>=Ee.length&&ie(Math.max(0,Ee.length-1))},[re,Ee.length]),(0,Z.useEffect)(()=>{if(w.length===0)return;let e=T();e.length&&V(A,t=>[...t,...e])},[w,T,A]);let je=Sz(xe),{models:Me,efforts:Ne,supportsImageInput:Pe}=je,Fe=(r?r.reasoning_effort:f)??`medium`,Ie=e=>{let t=Fz.get(Lz);t&&(Fz.has(e)||Fz.set(e,t),Fz.delete(Lz),M(Fz.get(e)??t));let n=Iz.get(Lz);if(n?.length){let t=Iz.get(e)??[];V(e,[...t,...n]),Iz.delete(Lz)}},Le=async e=>{if(e.length===0)return;U(!0);let t=r;if(!t)try{t=await b(),Ie(t.id)}catch(e){R.error(e instanceof Error?e.message:n(`workspace.uploadFailed`)),U(!1);return}for(let r of e){if(!Pe&&r.type.startsWith(`image/`)){R.error(n(`imagesUnsupported`));continue}try{let e=await SE(t.id,r);V(t.id,t=>[...t,e])}catch(e){R.error(e instanceof Error?e.message:n(`workspace.uploadFailed`))}}U(!1)},Re=e=>{V(A,t=>t.filter(t=>t.id!==e)),r&&EE(r.id,e)},ze=(e,t)=>{let n=qR(e,t);ne(n),n&&oe(!1)},Be=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,Ve=e=>{requestAnimationFrame(()=>{ee.current?.focus(),ee.current?.setSelectionRange(e,e)})},He=e=>{if(ve)return;let t=Be(e),n=ee.current,r=n?.selectionStart??j.length,i=n?.selectionEnd??r,a=`${j.slice(0,r)}${t}${j.slice(i)}`;N(a),F(null),oe(!1),ne({mode:e,trigger:t,query:``,start:r,end:r+1}),Ve(r+1)},Ue=e=>{let t=e.chip?Pz(j,K):dz(j,K,e);N(t.text),F(null),ne(null),oe(!1),e.chip&&G(t=>t.some(t=>JR(t)===JR(e.chip))?t:[...t,e.chip]),Ve(t.caret)},We=e=>{let t=JR(e);G(e=>e.filter(e=>JR(e)!==t))},Ge=e=>{let t=x[e];t&&(pe(t.queueId),he.current=t.text,M(t.text))},Ke=e=>{me.current=ue?``:j,F(null),Ge(e)},qe=(e,t)=>{pe(null),e===`keep`?N(t??j):M(me.current)},Je=async()=>{let e=_e,t=j.trim();if(!(!e||!t))try{await S(e.queueId,t)===`saved`?qe(`restore`):(R.info(n(`queueEdit.dispatched`)),qe(`keep`))}catch{R.error(n(`queueEdit.saveFailed`))}};(0,Z.useEffect)(()=>{if(fe===null||x.some(e=>e.queueId===fe))return;let e=j!==he.current;C(fe)&&R.info(n(`queueEdit.dispatched`)),qe(e?`keep`:`restore`)},[fe,x]);let Ye=()=>{if(ye||!Oe)return;let e=j.trim()||te.map(e=>e.token).join(` `),t={...L.length?{attachmentIds:L.map(e=>e.id)}:{},...te.length?{contextRefs:te.map(YR)}:{}};m(e,L.length||te.length?t:void 0),N(``),V(A,[]),G([]),ne(null),oe(!1),F(null)},Xe=e=>{if(de[e]===void 0){F(null);return}F(e),N(de[e])};return(0,Q.jsxs)(`div`,{className:`shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[r===null&&!t&&(0,Q.jsx)(gz,{pinnedProjectId:c,onSelect:e=>void y(e)}),(0,Q.jsx)(hz,{label:n(`provider.label`),value:xe,options:Nz.map(e=>({value:e,label:n(`provider.${e}`)})),icon:wn,onSelect:e=>{_(e).catch(()=>R.error(n(`error.generic`)))},testId:`agent-provider-selector`}),(0,Q.jsx)(bz,{models:Me,model:r?r.model:u,status:je.status,onSelect:e=>{v(e).catch(()=>R.error(n(`error.generic`)))}}),Ne.length>0&&(0,Q.jsx)(hz,{label:n(`effort.label`),value:Fe,options:Ne.map(e=>({value:e,label:n(`effort.${e}`)})),icon:ar,onSelect:e=>{p(e).catch(()=>R.error(n(`error.generic`)))},testId:`agent-effort-selector`}),(0,Q.jsx)(`div`,{className:`ml-auto`,children:(0,Q.jsx)(yz,{level:r?.tier_level??d,onCycle:()=>void g()})})]}),ve&&_e&&(0,Q.jsxs)(`div`,{"data-testid":`queue-edit-chip`,className:`mb-1 flex items-center gap-1.5 rounded-md border border-accent-highlight/30 bg-accent-highlight/10 px-2 py-1 text-[11px] text-accent-highlight`,children:[(0,Q.jsx)(dt,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n(`queueEdit.editing`,{n:ge+1,m:x.length})}),(0,Q.jsx)(`span`,{className:`truncate text-foreground/45`,children:n(`queueEdit.hint`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>qe(`restore`),"aria-label":n(`queueEdit.cancel`),title:n(`queueEdit.cancel`),className:`ml-auto rounded-sm p-0.5 text-foreground/50 hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]}),ue&&(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,Q.jsx)(mr,{className:`h-3 w-3`}),n(`history.hint`)]}),L.length>0&&(0,Q.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:L.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[11px] text-foreground/80`,children:[(0,Q.jsx)(Lr,{className:`h-3 w-3 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.filename}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>Re(e.id),"aria-label":n(`close`),className:`rounded-sm hover:bg-muted`,children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]},e.id))}),E.length>0&&(0,Q.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:E.map((e,t)=>(0,Q.jsx)(Mz,{process:e,accentVariant:ke[t%ke.length],onKill:e=>void D(e)},e.pid))}),(0,Q.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border bg-background/60 px-3 py-2 ${ve?`border-accent-highlight/50`:ue?`border-accent-info/40`:`border-border/60`}`,onDragOver:e=>{J&&e.preventDefault()},onDrop:e=>{if(!J)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&Le(t)},children:[De&&(0,Q.jsx)(kz,{items:Ee,mode:K.mode,query:K.query,activeIndex:re,onActiveIndexChange:ie,onSelect:Ue}),J&&(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`input`,{ref:W,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&&Le(t),e.target.value=``}})}),(0,Q.jsx)(Az,{open:ae,canAttach:J,uploading:H,onToggle:()=>{oe(e=>!e),ne(null)},onClose:()=>oe(!1),onOpenMode:He,onAttachFile:()=>{oe(!1),W.current?.click()}}),(0,Q.jsxs)(`div`,{className:`flex min-h-[3.25rem] flex-1 flex-wrap items-start gap-1.5`,children:[!ve&&(0,Q.jsx)(Oz,{chips:te,onRemove:We}),(0,Q.jsx)(`textarea`,{ref:ee,value:j,autoFocus:e,onChange:e=>{if(ve){M(e.target.value);return}ue&&F(null),N(e.target.value),ze(e.target.value,e.target.selectionStart??e.target.value.length)},onClick:e=>ze(e.currentTarget.value,e.currentTarget.selectionStart??e.currentTarget.value.length),onKeyDown:e=>{if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),g();return}if(De){if(e.key===`ArrowDown`){e.preventDefault(),Ee.length>0&&ie(e=>Math.min(Ee.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Ee.length>0&&ie(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=Ee[re]??Ee[0];t&&Ue(t);return}if(e.key===`Escape`){e.preventDefault(),ne(null);return}}if(e.key===`Backspace`&&j.length===0&&te.length>0&&!ve){e.preventDefault(),G(e=>e.slice(0,-1));return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),ve?Je():Ye();return}if(e.key===`Escape`&&ve){e.preventDefault(),e.stopPropagation(),qe(`restore`);return}let t=e.currentTarget,n=t.selectionStart===0&&t.selectionEnd===0,r=t.selectionStart===j.length&&t.selectionEnd===j.length;if(e.key===`ArrowUp`){if(ve){_e!==null&&j===_e.text&&n&&ge>0&&(e.preventDefault(),Ge(ge-1));return}if(x.length>0){n&&(e.preventDefault(),Ke(x.length-1));return}!ue&&j===``&&de.length>0?(e.preventDefault(),Xe(de.length-1)):ue&&(e.preventDefault(),Xe(Math.max(0,P-1)));return}if(e.key===`ArrowDown`){if(ve){_e!==null&&j===_e.text&&r&&(e.preventDefault(),ge<x.length-1?Ge(ge+1):qe(`restore`));return}if(x.length>0)return;ue&&(e.preventDefault(),P<de.length-1?Xe(P+1):(F(null),N(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&ue&&F(null)},onPaste:e=>{if(!J)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),Le(t))},rows:2,disabled:ye,placeholder:te.length>0?``:n(ye?`noProvider.placeholder`:o?`queue.placeholder`:`composerPlaceholder`),"data-agent-interactive":!0,title:ve?n(`queueEdit.hint`):ue?n(`history.hint`):void 0,className:`min-h-[3.25rem] max-h-64 min-w-[12rem] flex-1 resize-y bg-transparent text-sm outline-none placeholder:text-foreground/40 disabled:opacity-60 ${ue?`italic text-foreground/50`:`text-foreground`}`})]}),ve?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void Je(),disabled:ye||!j.trim(),"aria-label":n(`queueEdit.save`),title:n(`queueEdit.save`),className:`rounded-lg bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,Q.jsx)(be,{className:`h-4 w-4`})}):o&&!Oe?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void h(),"aria-label":n(`stop`),title:n(`stop`),className:`rounded-lg bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,Q.jsx)(ci,{className:`h-4 w-4`,fill:`currentColor`})}):o?(0,Q.jsxs)(`button`,{type:`button`,onClick:Ye,disabled:ye,"aria-label":n(`queue.send`),title:n(`queue.sendHint`),className:`relative rounded-lg bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:[(0,Q.jsx)($r,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-background ring-1 ring-border`,children:(0,Q.jsx)(Ln,{className:`h-2.5 w-2.5 text-accent-info`})})]}):(0,Q.jsx)(`button`,{type:`button`,onClick:Ye,disabled:ye||!Oe,"aria-label":n(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,Q.jsx)($r,{className:`h-4 w-4`})})]}),Se&&(0,Q.jsx)(Cz,{projectId:Se})]})}var zz=e=>e===`running`||e===`queued`;function Bz(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${n%60}m`}function Vz(){try{return Et()}catch{return null}}var Hz=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function Uz(e,t,n){let{live:r}=n,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(()=>Date.now());(0,Z.useEffect)(()=>{let n=!1;return fetch(`${xt}/api/projects/${e}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{if(n)return;let t=e?.job;t&&(s(typeof t.status==`string`?t.status:null),l(Hz(t.started_at)),d(Hz(t.finished_at)),typeof t.total_cost_usd==`number`&&p(t.total_cost_usd),typeof t.num_turns==`number`&&h(t.num_turns),_(t.loopPaused===!0),y(typeof t.loopPauseReason==`string`?t.loopPauseReason:null)),a(!0)}).catch(()=>{n||a(!0)}),()=>{n=!0}},[e,t,r]);let S=zz(o)&&u===null,C=Vz(),w=(0,Z.useId)();return(0,Z.useEffect)(()=>{if(!C||!r)return;let e=`run-vitals-${t}-${w}`;return C.registerHandler(e,e=>{let n=e;if(n?.type===`loop.run_paused`&&n.loopRunId===t){_(!0),y(typeof n.reason==`string`?n.reason:null),s(`running`),d(null);return}if((n?.type===`loop.run_resumed`||n?.type===`loop.run_completed`)&&n.loopRunId===t){_(!1),y(null);return}n?.jobId===t&&(n.type===`job.turn_done`?(typeof n.totals?.total_cost_usd==`number`&&p(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&h(n.totals.num_turns)):n.type===`job.finalized`&&(typeof n.totals?.total_cost_usd==`number`&&p(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&h(n.totals.num_turns),typeof n.status==`string`&&s(n.status),_(!1),y(null),d(Hz(n.timestamp)??Date.now())))}),()=>C.unregisterHandler(e)},[C,r,t,w]),(0,Z.useEffect)(()=>{if(!r||!S||c===null)return;let e=setInterval(()=>x(Date.now()),1e3);return()=>clearInterval(e)},[r,S,c]),{status:o,paused:g,pausedReason:v,running:S,elapsedMs:c===null?null:Math.max(0,(u??b)-c),costUsd:f,numTurns:m,loaded:i}}function Wz(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var Gz=15e3;function Kz(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function qz(e){let{projectId:t,jobId:n,timeoutMs:r=Gz}=e,i=t?`${xt}/api/projects/${t}`:Ot(),a;try{a=await fetch(`${i}/jobs/${n}/cancel`,{method:`POST`,signal:Kz(r)})}catch(e){let t=e;return{ok:!1,error:t?.name===`TimeoutError`||t?.name===`AbortError`?`Request timed out after ${Math.round(r/1e3)}s`:t?.message||String(e),httpStatus:null}}if(a.ok){let e=`canceled`;try{let t=await a.json();t&&typeof t.status==`string`&&(e=t.status)}catch{}return{ok:!0,status:e}}let o=typeof a.status==`number`?a.status:null,s=o==null?``:` (HTTP ${o})`,c=``;try{typeof a.text==`function`?c=await a.text():typeof a.json==`function`&&(c=JSON.stringify(await a.json()))}catch{}let l=c.slice(0,200).trim();try{let e=JSON.parse(c);e&&typeof e.error==`string`&&e.error&&(l=e.error)}catch{}let u=typeof a.statusText==`string`?a.statusText:``;return{ok:!1,error:l?`${l}${s}`:`HTTP ${o??`?`}${u?` ${u}`:``}`,httpStatus:o}}var Jz=(0,Z.lazy)(()=>c(()=>import(`./JobDetailModal-BFNXOhk1.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75]))),Yz={building:lt,on_review:lt,pr_draft:Oe,pr_ready:Oe,no_changes:Pn,completed:Pn,pr_closed:ot,superseded:Oe,implementation_failed:vt,pr_failed:vt,merged:sr,discarded:ot},Xz={building:`text-accent-primary/70`,on_review:`text-accent-primary`,pr_draft:`text-accent-info`,pr_ready:`text-accent-info`,no_changes:`text-accent-success`,completed:`text-accent-success`,pr_closed:`text-accent-warning`,superseded:`text-foreground/40`,implementation_failed:`text-destructive`,pr_failed:`text-destructive`,merged:`text-accent-success`,discarded:`text-foreground/40`};function Zz({envelope:e}){let{t}=I(`agent`),n=Cv(e);return n.units.length===0&&!n.partial?null:(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1.5`,"data-testid":`agent-pr-unit-evidence`,children:[n.partial&&(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-accent-warning`,children:t(`prCard.partialSummary`,{succeeded:n.succeededCount,failed:n.failedCount,total:n.totalCount})}),n.units.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.units.map(e=>{let n=e.implementationOutcome===`failed`||e.implementationOutcome==null&&!e.succeeded,r=e.deliveryOutcome===`no_changes`||e.changed===!1,i=e.deliveryOutcome===`blocked`,a=t(n?`prCard.unit.failed`:i?`prCard.unit.blocked`:r?`prCard.unit.noChanges`:`prCard.unit.succeeded`);return(0,Q.jsxs)(`span`,{title:e.failureCode??e.branch,className:X(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px]`,n?`border-destructive/35 bg-destructive/10 text-destructive`:i?`border-accent-warning/35 bg-accent-warning/10 text-accent-warning`:`border-accent-success/30 bg-accent-success/10 text-accent-success`),children:[`#`,e.ticketId,` · `,a]},`${e.ticketId}-${e.runId??e.branch}`)})})]})}function Qz(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function $z({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=I(`agent`),s=Uz(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:Bz(s.elapsedMs),u=s.costUsd!=null&&s.costUsd>0,d=(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-40`,children:`·`});return(0,Z.useEffect)(()=>{a?.(t,{paused:s.paused,pausedReason:s.pausedReason})},[a,t,s.paused,s.pausedReason]),(0,Q.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`pr-run-log-chip`,onClick:e=>{e.stopPropagation(),i(t)},title:o(`prCard.viewLog`,{ref:c}),"aria-label":o(`prCard.viewLog`,{ref:c}),className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 py-px align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,s.paused?`border-accent-warning/45 bg-accent-warning/10 text-accent-warning hover:-translate-y-px hover:border-accent-warning/65 hover:bg-accent-warning/15 hover:shadow-sm`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:-translate-y-px hover:border-accent-info/60 hover:bg-accent-info/15 hover:shadow-sm`),children:[(s.paused||s.running&&r)&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 shrink-0 animate-pulse rounded-full`,s.paused?`bg-accent-warning`:`bg-accent-info`)}),(0,Q.jsx)(`span`,{className:`max-w-[160px] truncate`,children:c}),d,(0,Q.jsx)(Qr,{className:`h-3 w-3 shrink-0 opacity-70`}),l&&(0,Q.jsxs)(Q.Fragment,{children:[d,(0,Q.jsx)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runElapsedAria`,{elapsed:l}),children:l})]}),u&&(0,Q.jsxs)(Q.Fragment,{children:[d,(0,Q.jsxs)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runCostAria`,{cost:`$${s.costUsd.toFixed(2)}`}),children:[`$`,s.costUsd.toFixed(2)]})]})]})}function eB({envelope:e}){let{t}=I(`agent`),{projects:n}=At(),{applyPrDecisionSnapshot:r}=UV(),{openWebView:i,canOpenWebView:a}=We(),{openRef:o}=FL(),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),D=T??e,[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)({}),[M,N]=(0,Z.useState)(null),{decision:P,prUrl:F,prState:L}=D,z=Cv(D),B=gv(D.statusCode,D.statusDetail),V=D.operation==null&&B,H=n.find(e=>e.id===D.projectId)?.name??D.projectId,U=P===`pr_draft`&&!F,W=P===`building`&&L===`pr-created`&&!!D.branch,ee=D.prNumber?`#${D.prNumber}`:F?Qz(F):null,te=z.terminal,G=mv(D.statusCode)?t(`common:prDeliveryStatus.${D.statusCode}`):null,K=z.partial&&z.deliverableCount>0&&(P===`on_review`||P===`pr_draft`&&!F);(0,Z.useEffect)(()=>{E(null)},[e]),(0,Z.useEffect)(()=>{c(null),f(!1),m(!1),g(!1),v(!1),b(!1),S(!1),w(!1)},[P,F,D.prDeliveryId]);let ne=(0,Z.useCallback)((e,t)=>{j(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),re=async e=>{if(!M){N(e);try{let n=await qz({projectId:D.projectId,jobId:e,kind:`loop-run`});n.ok?R.info(t(`prCard.stopExecutionSent`)):R.error(t(`prCard.stopExecutionFailed`),{description:n.error})}finally{N(null)}}},ie=async e=>{if(!(l||s||D.operation)){c(e);try{let n=await PE(D.projectId,{prDeliveryId:D.prDeliveryId,action:e,expectedDecision:P}),i=null;if(n.snapshot){let e=FE(D,n.snapshot);i=r(e),i!==`stale`&&E(e)}if(i===`stale`){R.info(t(`prCard.alreadyResolved`));return}if(n.kind===`recovering`)R.info(t(`common:prRecovery.inProgress`));else if(n.kind===`busy`)R.info(t(`prCard.operation.${n.operation??`inProgress`}`));else if(n.kind===`stale`)R.info(t(`prCard.alreadyResolved`));else if(n.kind===`blocked`)R.warning(n.reason===`dirty`?t(`prCard.mergeLocalBlockedDirty`,{base:n.base||D.baseBranch}):t(`prCard.mergeLocalBlockedBranch`,{base:n.base||D.baseBranch,current:n.current??`?`}));else if(n.kind===`failed`)R.error(t(`prCard.actionFailed`),{description:n.detail});else if(n.kind===`ok`&&e===`recover-and-retry`)if(n.deliveryVerified){let e=(n.verifiedSha??n.snapshot?.deliverySha??``).slice(0,8);R.success(t(`prCard.recoverAndRetryVerified`,{sha:e}))}else n.recoveryUnavailable||n.snapshot?.statusCode===`recovery_unavailable`?R.info(t(`prCard.recoveryUnavailable`),{description:t(`prCard.recoveryUnavailableBody`)}):R.warning(t(`prCard.recoveryStillBlocked`),{description:n.detail??void 0});else if(n.kind===`ok`&&e===`create-pr`&&z.retryablePush&&n.deliveryVerified){let e=(n.verifiedSha??n.snapshot?.deliverySha??D.deliverySha??``).slice(0,8);R.success(t(n.pushed?`prCard.retryPushVerified`:`prCard.commitAlreadyVerified`,{sha:e}))}else if(n.kind===`ok`&&e===`create-pr`&&n.detail)R.error(t(`prCard.deliveryNeedsAttention`),{description:n.detail});else if(n.kind===`ok`&&e===`poll-merge`&&n.deliveryVerified===!1)R.warning(t(`prCard.commitMissingRetry`));else if(n.kind===`ok`&&e===`poll-merge`&&n.deliveryVerified&&!n.merged){let e=(n.verifiedSha??n.snapshot?.deliverySha??D.deliverySha??``).slice(0,8);R.success(t(`prCard.prVerifiedWaiting`,{sha:e}))}else e===`poll-merge`&&!n.merged&&n.decision!==`pr_closed`?R.info(t(`prCard.notMergedYet`)):e===`merge-local`&&n.kind===`ok`&&n.decision===`merged`&&R.success(t(`prCard.mergedLocally`,{base:D.baseBranch}))}catch(e){R.error(t(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{c(null)}}},ae=async()=>{if(!(s||l||D.operation)){u(!0);try{let e=await IE(D.projectId,D.prDeliveryId);e.kind===`ok`?R.success(t(`prCard.checkoutSuccess`,{branch:D.branch??``})):e.kind===`recovering`?R.info(t(`common:prRecovery.inProgress`)):e.error===`checkout_dirty`?R.warning(t(`prCard.checkoutDirtyTitle`),{description:t(`prCard.checkoutDirtyBody`)}):e.error===`checkout_not_deliverable`?R.warning(t(`prCard.checkoutNotDeliverableTitle`),{description:t(`prCard.checkoutNotDeliverableBody`)}):e.error===`checkout_safety_unknown`?R.warning(t(`prCard.checkoutSafetyUnknownTitle`),{description:t(`prCard.checkoutSafetyUnknownBody`)}):R.warning(t(`prCard.checkoutFailed`),{description:e.detail})}catch(e){R.error(t(`prCard.checkoutFailed`),{description:e instanceof Error?e.message:void 0})}finally{u(!1)}}},oe=async()=>{let e=z.recoveryWorktreePaths;if(e.length===0){R.info(t(`prCard.localResultUnavailableHere`));return}let n=e.join(`
|
|
60
|
+
`||r===` `||r===` `)break;if(!GR.has(r))continue;let i=t===0?``:e[t-1];if(i&&!KR.test(i))continue;let a=e.slice(t+1,n);if(/[()[\]{}<>"']/.test(a))return null;let o=r;return{trigger:o,mode:o===`@`?`reference`:o===`#`?`trace`:`action`,query:a,start:t,end:n}}return null}function JR(e){return`${e.kind}:${e.id}`}function YR(e){return{kind:e.kind,id:e.id,label:e.label,token:e.token,scope:{projectId:e.projectId??null,projectName:e.projectName??null},status:e.status??null,metadata:e.metadata}}function XR(e,t){return t?e.find(e=>e.id===t)?.name??null:null}function ZR(e){return{kind:`project`,id:e.id,label:e.name,token:`@${e.name}`,detail:e.path,projectId:e.id,projectName:e.name,metadata:{slug:e.slug,path:e.path}}}function QR(e,t,n){return{kind:`spec`,id:String(e.id),label:e.title,token:`@${e.title}`,detail:n?`${n} / #${e.id}`:`#${e.id}`,status:e.status,projectId:t,projectName:n,metadata:{ticketId:e.id,priority:e.priority,labels:e.labels,shortSummary:e.short_summary??null}}}function $R(e,t,n){let r=e.id.slice(0,8);return{kind:`job`,id:e.id,label:r,token:`#${r}`,detail:n?`${n} / ${e.command}`:e.command,status:e.status,projectId:t,projectName:n,metadata:{command:e.command,startedAt:e.started_at,costUsd:e.total_cost_usd??null}}}function ez(e,t){let n=e.title||`Untitled mission`;return{kind:`conversation`,id:e.id,label:n,token:`@${n}`,detail:t?`Mission / ${t}`:`Mission`,projectId:e.pinned_project_id,projectName:t,metadata:{provider:e.provider}}}function tz(e,t){let n=t.trim().toLowerCase();return!n||[e.title,e.subtitle,e.detail,e.group,...e.keywords??[]].filter(Boolean).join(` `).toLowerCase().includes(n)}function nz(e){let t=new Set,n=[];for(let r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function rz(e,t){return nz(e).filter(e=>tz(e,t)).slice(0,12)}function iz(e){let t=XR(e.projects,e.pinnedProjectId),n=e.pinnedProjectId?e.projects.find(t=>t.id===e.pinnedProjectId)??null:null,r=[];if(n&&r.push({id:`alias:current-project:${n.id}`,mode:`reference`,title:`@current`,subtitle:n.name,detail:`Pinned project`,group:`Current`,icon:`alias`,chip:{...ZR(n),kind:`alias`,id:`current:${n.id}`,token:`@current`},keywords:[`this`,`project`,n.name]}),e.activeConversation){let n=ez(e.activeConversation,t);r.push({id:`conversation:${e.activeConversation.id}`,mode:`reference`,title:n.label,subtitle:n.detail,detail:`Current mission`,group:`Created here`,icon:`conversation`,chip:n,keywords:[`mission`,`conversation`,`last`]})}for(let t of e.chips)r.push({id:`chip:${JR(t)}`,mode:`reference`,title:t.label,subtitle:t.detail,detail:`Already in context`,group:`Current context`,icon:t.kind,chip:t});let i=e.tickets.map(n=>{let r=QR(n,e.pinnedProjectId,t),i=n.status===`on_review`||n.status===`in_progress`||n.status===`draft`;return{id:`spec:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:n.title,subtitle:`Spec #${n.id}${n.status?` · ${n.status}`:``}`,detail:r.detail,group:i?`Active in project`:`Specs`,icon:`spec`,chip:r,keywords:[String(n.id),n.priority??``,...n.labels??[]]}});r.push(...i);let a=e.jobs.slice(0,8).map(n=>{let r=$R(n,e.pinnedProjectId,t);return{id:`job:${r.projectId??`home`}:${n.id}`,mode:`reference`,title:r.label,subtitle:`Job · ${n.status}`,detail:n.command,group:n.status===`running`||n.status===`failed`?`Needs attention`:`Recent jobs`,icon:`job`,chip:r,keywords:[n.id,n.command,n.status]}});r.push(...a);for(let t of e.projects){let n=ZR(t);r.push({id:`project:${t.id}`,mode:`reference`,title:t.name,subtitle:`Project`,detail:t.path,group:t.id===e.activeProjectId?`Current app project`:`Projects`,icon:`project`,chip:n,keywords:[t.slug,t.path]})}return r}function az(e){let t=XR(e.projects,e.pinnedProjectId),n=[];for(let r of e.jobs){let i=$R(r,e.pinnedProjectId,t);n.push({id:`trace:job:${r.id}`,mode:`trace`,title:i.label,subtitle:`${r.status} · ${r.command}`,detail:t??void 0,group:r.status===`failed`||r.status===`running`?`Active traces`:`Recent traces`,icon:`job`,chip:{...i,kind:`trace`},keywords:[r.id,r.command,r.status,`failed`,`running`,`deploy`,`run`]})}for(let r of e.tickets){let i=QR(r,e.pinnedProjectId,t);n.push({id:`trace:spec:${r.id}`,mode:`trace`,title:`#${r.id}`,subtitle:`${r.title} · ${r.status}`,detail:t??void 0,group:`IDs`,icon:`spec`,chip:{...i,kind:`trace`,token:`#${r.id}`},keywords:[String(r.id),r.title,r.status]})}return n}var oz=[{id:`action:create-spec`,mode:`action`,title:`Create spec`,subtitle:`Turn this into a structured spec`,group:`Create`,icon:`action`,insertText:`/create spec`,tierLevel:2,risk:`cost`,keywords:[`new ticket quick add`]},{id:`action:explore-spec`,mode:`action`,title:`Explore spec`,subtitle:`Refine a fuzzy idea first`,group:`Refine`,icon:`action`,insertText:`/explore spec`,tierLevel:2,risk:`cost`,keywords:[`discovery draft requirements`]},{id:`action:update-spec`,mode:`action`,title:`Update spec`,subtitle:`Edit the selected spec`,group:`Refine`,icon:`action`,insertText:`/update spec`,tierLevel:1,keywords:[`edit ticket`]},{id:`action:assign-rail`,mode:`action`,title:`Assign to rail`,subtitle:`Put selected specs on a rail`,group:`Execute`,icon:`action`,insertText:`/assign to rail`,tierLevel:1,keywords:[`tickets rail`]},{id:`action:launch-rail`,mode:`action`,title:`Launch rail`,subtitle:`Run the selected rail or spec`,group:`Execute`,icon:`action`,insertText:`/launch rail`,tierLevel:2,risk:`cost`,keywords:[`run implement`]},{id:`action:launch-all`,mode:`action`,title:`Launch all eligible rails`,subtitle:`Start every ready rail in parallel`,group:`Execute`,icon:`action`,insertText:`/launch all eligible rails`,tierLevel:2,risk:`cost`,keywords:[`all rails run`]},{id:`action:status`,mode:`action`,title:`Show status`,subtitle:`Summarize the current workbench`,group:`Review`,icon:`action`,insertText:`/status`,tierLevel:0,keywords:[`state overview`]},{id:`action:diagnose`,mode:`action`,title:`Diagnose`,subtitle:`Inspect git, jobs, setup, Jira, and failures`,group:`Review`,icon:`action`,insertText:`/diagnose`,tierLevel:0,keywords:[`debug health failed`]},{id:`action:compare`,mode:`action`,title:`Compare`,subtitle:`Compare selected specs, jobs, diffs, or costs`,group:`Review`,icon:`action`,insertText:`/compare`,tierLevel:0,keywords:[`diff versus`]},{id:`action:summarize`,mode:`action`,title:`Summarize`,subtitle:`Condense selected context`,group:`Review`,icon:`action`,insertText:`/summarize`,tierLevel:0,keywords:[`recap`]},{id:`action:save-as-spec`,mode:`action`,title:`Save as spec`,subtitle:`Capture the selected context as durable work`,group:`Create`,icon:`action`,insertText:`/save as spec`,tierLevel:1,keywords:[`persist capture`]},{id:`action:generate-report`,mode:`action`,title:`Generate report`,subtitle:`Create a written artifact from selected context`,group:`Create`,icon:`action`,insertText:`/generate report`,tierLevel:1,keywords:[`document export`]},{id:`action:show-spend`,mode:`action`,title:`Show spend`,subtitle:`Review cost and budget impact`,group:`Review`,icon:`action`,insertText:`/show spend`,tierLevel:0,keywords:[`cost budget analytics`]},{id:`action:search`,mode:`action`,title:`Search current project`,subtitle:`Find specs, jobs, files, or context`,group:`Navigate`,icon:`action`,insertText:`/search`,tierLevel:0,keywords:[`find`]},{id:`action:search-all`,mode:`action`,title:`Search all projects`,subtitle:`Fan out across registered projects`,group:`Navigate`,icon:`action`,insertText:`/search all projects`,tierLevel:0,keywords:[`global home`]},{id:`action:open`,mode:`action`,title:`Open item`,subtitle:`Open the selected object in Specrails`,group:`Navigate`,icon:`action`,insertText:`/open`,tierLevel:0,keywords:[`navigate`]},{id:`action:wait`,mode:`action`,title:`Wait for result`,subtitle:`Follow a running job or trace`,group:`Review`,icon:`action`,insertText:`/wait for result`,tierLevel:0,keywords:[`watch running`]},{id:`action:show-diff`,mode:`action`,title:`Show diff`,subtitle:`Inspect changes from the selected job`,group:`Review`,icon:`action`,insertText:`/show diff`,tierLevel:0,keywords:[`files changes`]},{id:`action:diagnostic`,mode:`action`,title:`Export diagnostic`,subtitle:`Collect job telemetry and logs`,group:`Review`,icon:`action`,insertText:`/export diagnostic`,tierLevel:0,keywords:[`zip logs telemetry`]},{id:`action:cancel-job`,mode:`action`,title:`Cancel job`,subtitle:`Stop or delete a selected job`,group:`Clean up`,icon:`action`,insertText:`/cancel job`,tierLevel:3,risk:`destructive`,keywords:[`stop kill`]},{id:`action:refine-contract`,mode:`action`,title:`Refine contract`,subtitle:`Add or refresh the Contract Layer`,group:`Refine`,icon:`action`,insertText:`/refine contract`,tierLevel:2,risk:`cost`,keywords:[`contract`]},{id:`action:split-epic`,mode:`action`,title:`Split epic`,subtitle:`Decompose a large spec into children`,group:`Refine`,icon:`action`,insertText:`/split epic`,tierLevel:2,risk:`cost`,keywords:[`smash children`]},{id:`action:files-touched`,mode:`action`,title:`Show files touched`,subtitle:`Inspect provenance for selected work`,group:`Review`,icon:`action`,insertText:`/show files touched`,tierLevel:0,keywords:[`provenance`]},{id:`action:connect-jira`,mode:`action`,title:`Connect Jira`,subtitle:`Start the Jira connection flow`,group:`Integrate`,icon:`action`,insertText:`/connect Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:sync-jira`,mode:`action`,title:`Sync Jira`,subtitle:`Refresh Jira-backed specs`,group:`Integrate`,icon:`action`,insertText:`/sync Jira`,tierLevel:1,keywords:[`integration`]},{id:`action:install-plugin`,mode:`action`,title:`Install plugin`,subtitle:`Preview and install an integration`,group:`Integrate`,icon:`action`,insertText:`/install plugin`,tierLevel:1,keywords:[`mcp integration`]},{id:`action:set-budget`,mode:`action`,title:`Set budget`,subtitle:`Adjust spend guardrails`,group:`Configure`,icon:`action`,insertText:`/set budget`,tierLevel:1,keywords:[`cost limit`]}];function sz(e,t,n){let r=new Set(t.map(e=>e.kind)),i=0;return t.length===0&&([`action:create-spec`,`action:search`,`action:status`,`action:diagnose`,`action:show-spend`].includes(e.id)&&(i+=40),n.pinnedProjectId&&e.id===`action:launch-all`&&(i+=30)),r.has(`project`)&&[`action:status`,`action:search`,`action:launch-all`,`action:show-spend`,`action:sync-jira`,`action:install-plugin`].includes(e.id)&&(i+=50),r.has(`spec`)&&[`action:update-spec`,`action:assign-rail`,`action:launch-rail`,`action:refine-contract`,`action:split-epic`,`action:files-touched`,`action:show-spend`].includes(e.id)&&(i+=70),(r.has(`job`)||r.has(`trace`))&&[`action:open`,`action:wait`,`action:compare`,`action:show-diff`,`action:diagnostic`,`action:cancel-job`].includes(e.id)&&(i+=80),r.has(`file`)&&[`action:summarize`,`action:show-diff`,`action:files-touched`].includes(e.id)&&(i+=60),i}function cz(e){return[...oz].sort((t,n)=>sz(n,e.chips,e)-sz(t,e.chips,e)).map(e=>({...e,chip:{kind:`action`,id:e.id,label:e.title,token:e.insertText??`/${e.title.toLowerCase()}`,detail:e.subtitle,metadata:{tierLevel:e.tierLevel,risk:e.risk??null}}}))}function lz(e,t){return e===`reference`?iz(t):e===`trace`?az(t):cz(t)}function uz(e,t){let n=t.trim();if(!n)return[];let r=n.slice(0,80),i=[{id:`fallback:search-all:${e}:${r}`,mode:e,title:`Search all Specrails`,subtitle:`Find "${r}" across every project`,group:`No matches`,icon:`action`,insertText:`/search all projects ${r}`,tierLevel:0,keywords:[`fallback global search all`]},{id:`fallback:ask-agent:${e}:${r}`,mode:e,title:`Ask agent about "${r}"`,subtitle:`Keep the wording and let the agent resolve it`,group:`No matches`,icon:`action`,insertText:r,tierLevel:0,keywords:[`fallback ask agent clarify`]}];return e===`trace`?i.splice(1,0,{id:`fallback:archived:${e}:${r}`,mode:e,title:`Include archived results`,subtitle:`Search completed, canceled, and old traces for "${r}"`,group:`No matches`,icon:`action`,insertText:`/search all projects archived ${r}`,tierLevel:0,keywords:[`fallback archived old completed canceled`]}):i.splice(1,0,{id:`fallback:create-spec:${e}:${r}`,mode:e,title:`Create "${r}"`,subtitle:`Turn this unmatched reference into a spec`,group:`No matches`,icon:`action`,insertText:`/create spec ${r}`,tierLevel:2,risk:`cost`,keywords:[`fallback create new spec`]}),i}function dz(e,t,n){let r=n.insertText??n.chip?.token??n.title,i=t?.start??e.length,a=t?.end??e.length,o=e.slice(0,i),s=e.slice(a),c=o&&!/\s$/.test(o)?` `:``,l=s&&!/^\s/.test(s)?` `:``;return{text:`${o}${c}${r}${l}${s}`,caret:o.length+c.length+r.length+l.length}}var fz=`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground outline-none transition-colors hover:bg-surface/70 focus-visible:ring-2 focus-visible:ring-accent-primary/50 disabled:cursor-not-allowed disabled:opacity-50`,pz=`overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,mz=`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground outline-none hover:bg-surface/70 focus-visible:bg-surface/70`;function hz({label:e,value:t,options:n,icon:r,onSelect:i,placeholder:a,disabled:o=!1,testId:s}){return(0,Q.jsxs)(cp,{value:t,onValueChange:i,disabled:o||n.length===0,children:[(0,Q.jsxs)(lp,{"aria-label":e,title:e,"data-agent-interactive":!0,"data-testid":s,className:fz,children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,Q.jsx)(up,{placeholder:a??e,className:`max-w-[160px] truncate`}),(0,Q.jsx)(dp,{asChild:!0,children:(0,Q.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})})]}),(0,Q.jsx)(fp,{children:(0,Q.jsxs)(pp,{position:`popper`,side:`top`,align:`start`,sideOffset:4,collisionPadding:8,className:`z-[80] min-w-[12rem] max-w-[20rem] ${pz} data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1`,children:[(0,Q.jsx)(yp,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,Q.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(mp,{className:`max-h-72 py-1`,children:n.map(e=>{let t=e.icon??r;return(0,Q.jsxs)(gp,{value:e.value,className:`${mz} relative cursor-default select-none pr-9 data-[highlighted]:bg-surface/70 data-[state=checked]:font-medium`,children:[(0,Q.jsx)(t,{className:`h-4 w-4 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,Q.jsx)(_p,{children:(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})}),(0,Q.jsx)(vp,{className:`absolute right-3 flex items-center`,children:(0,Q.jsx)(be,{className:`h-3.5 w-3.5 text-accent-primary`})})]},e.value)})}),(0,Q.jsx)(bp,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,Q.jsx)(pe,{className:`h-3.5 w-3.5`})})]})})]})}function gz({pinnedProjectId:e,onSelect:t}){let{t:n}=I(`agent`),{projects:r}=At(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(0),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useId)(),p=(0,Z.useCallback)((e=!1)=>{a(!1),s(``),l(0),e&&d.current?.focus()},[]);(0,Z.useEffect)(()=>{if(!i)return;let e=e=>{u.current&&!u.current.contains(e.target)&&p()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i,p]);let m=r.find(t=>t.id===e)??null,h=(0,Z.useMemo)(()=>{let e=o.trim().toLowerCase();return e?r.filter(t=>t.name.toLowerCase().includes(e)):r},[r,o]),g=h.length+1;(0,Z.useEffect)(()=>{l(o.trim()?h.length>0?1:-1:0)},[o,h.length]);let _=()=>{let t=e?r.findIndex(t=>t.id===e):-1;l(t>=0?t+1:0),a(!0)},v=e=>{t(e),p(!0)},y=()=>{if(!(c<0))if(c===0)v(null);else{let e=h[c-1];e&&v(e.id)}};return(0,Q.jsxs)(`div`,{className:`relative`,ref:u,"data-agent-interactive":!0,onKeyDown:e=>{if(!i){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),_());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;l(e=>(e+t+g)%g)}else e.key===`Enter`?(e.preventDefault(),y()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p(!0))},children:[(0,Q.jsxs)(`button`,{ref:d,type:`button`,onClick:()=>i?p():_(),"aria-haspopup":`listbox`,"aria-expanded":i,"aria-controls":f,className:fz,children:[m?(0,Q.jsx)(ir,{className:`h-3.5 w-3.5 text-accent-primary`}):(0,Q.jsx)(hr,{className:`h-3.5 w-3.5 text-foreground/70`}),(0,Q.jsx)(`span`,{className:`max-w-[160px] truncate`,children:m?m.name:n(`project.home`)}),(0,Q.jsx)(pe,{className:`h-3.5 w-3.5 text-foreground/50`})]}),(0,Q.jsx)(MF,{children:i&&(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-64 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Q.jsx)(ht,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),role:`combobox`,placeholder:n(`project.searchProjectsPlaceholder`),"aria-label":n(`project.searchProjectsPlaceholder`),"aria-expanded":i,"aria-autocomplete":`list`,"aria-controls":f,"aria-activedescendant":c>=0?`${f}-option-${c}`:void 0,className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Q.jsxs)(`div`,{id:f,role:`listbox`,"aria-label":n(`project.allProjects`),className:`max-h-72 overflow-y-auto py-1`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-1 text-[11px] uppercase tracking-wide text-foreground/40`,children:n(`project.recents`)}),(0,Q.jsx)(_z,{id:`${f}-option-0`,icon:(0,Q.jsx)(hr,{className:`h-4 w-4`}),label:n(`project.home`),active:!e,highlighted:c===0,onMouseEnter:()=>l(0),onClick:()=>v(null),index:0}),h.map((t,n)=>(0,Q.jsx)(_z,{id:`${f}-option-${n+1}`,icon:(0,Q.jsx)(ir,{className:`h-4 w-4 text-accent-primary`}),label:t.name,active:t.id===e,highlighted:c===n+1,onMouseEnter:()=>l(n+1),onClick:()=>v(t.id),index:n+1},t.id))]})]})})]})}function _z({id:e,icon:t,label:n,active:r,highlighted:i,onMouseEnter:a,onClick:o,index:s}){return(0,Q.jsxs)(ML.button,{id:e,type:`button`,role:`option`,"aria-selected":r,tabIndex:-1,onMouseEnter:a,onClick:o,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(s*.03,.18)},className:`${mz} ${i?`bg-surface/70`:``}`,children:[t,(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:n}),r&&(0,Q.jsx)(be,{className:`h-3.5 w-3.5 text-accent-primary`})]})}var vz=[{level:0,key:`observe`,icon:Xn,tone:`text-foreground/70`,bar:`bg-accent-info`},{level:1,key:`edit`,icon:dt,tone:`text-accent-info`,bar:`bg-accent-info`},{level:2,key:`operate`,icon:bt,tone:`text-accent-warning`,bar:`bg-accent-warning`},{level:3,key:`autonomous`,icon:tr,tone:`text-destructive`,bar:`bg-destructive`}];function yz({level:e,onCycle:t}){let{t:n}=I(`agent`),r=vz[e],i=r.icon;return(0,Q.jsxs)(`button`,{type:`button`,onClick:t,title:n(`tier.${r.key}.desc`),"aria-label":`${n(`tier.${r.key}.name`)} — ${n(`tier.cycleHint`)}`,className:`group flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/70 px-2.5 py-1 text-xs font-medium ${r.tone} transition-colors hover:bg-surface`,"data-agent-interactive":!0,children:[(0,Q.jsxs)(ML.span,{initial:{scale:.8},animate:{scale:[1,1.18,1]},transition:{duration:.28,ease:`easeOut`},className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(i,{className:`h-3.5 w-3.5`}),n(`tier.${r.key}.name`)]},e),(0,Q.jsx)(`span`,{className:`ml-1 flex gap-0.5`,"aria-hidden":!0,children:vz.map(t=>(0,Q.jsx)(`span`,{className:`h-1 w-2 rounded-full transition-colors duration-200 ${t.level<=e?r.bar:`bg-border/50`}`},t.level))})]})}function bz({models:e,model:t,onSelect:n,status:r=`ready`,disabled:i=!1,testId:a=`agent-model-selector`}){let{t:o}=I(`agent`),s=t??e.find(e=>e.default)?.value??e[0]?.value??``,c=o(r===`loading`?`model.loading`:r===`error`?`model.unavailable`:`model.label`);return(0,Q.jsx)(hz,{label:o(`model.label`),value:s,options:e.map(e=>({value:e.value,label:e.label})),icon:gt,onSelect:n,placeholder:c,disabled:i||r!==`ready`,testId:a})}function xz(e){return{provider:e,models:[],efforts:[],supportsImageInput:!0,status:`loading`}}function Sz(e){let[t,n]=(0,Z.useState)(()=>xz(e));return(0,Z.useEffect)(()=>{let t=!0;return n(xz(e)),hE(e).then(r=>{t&&n({provider:e,models:r.models,efforts:r.efforts,supportsImageInput:r.supportsImageInput,status:`ready`})}).catch(()=>{t&&n({...xz(e),status:`error`})}),()=>{t=!1}},[e]),t.provider===e?t:xz(e)}function Cz({projectId:e}){let{t}=I(`agent`),{isStreaming:n}=UV(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``),d=(0,Z.useRef)(null),f=`${xt}/api/projects/${e}/git`,p=(0,Z.useCallback)(async()=>{try{let e=await fetch(f);if(!e.ok)return;i(await e.json())}catch{}},[f]);(0,Z.useEffect)(()=>{i(null),p()},[p]);let m=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{m.current&&!n&&p(),m.current=n},[n,p]),(0,Z.useEffect)(()=>{if(!s)return;let e=e=>{d.current&&!d.current.contains(e.target)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let h=(0,Z.useCallback)(async e=>{if(c(!1),u(``),!(!e||e===r?.branch)){o(!0);try{let n=await fetch(`${f}/checkout`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({branch:e})}),r=await n.json().catch(()=>({}));if(!n.ok){R.error(t(`git.switchFailed`),{description:r.error}),p();return}i(r),R.success(t(`git.switched`,{branch:e}))}catch{R.error(t(`git.switchFailed`)),p()}finally{o(!1)}}},[f,r?.branch,t,p]),g=(0,Z.useMemo)(()=>{if(!r)return[];let e=l.trim().toLowerCase();return e?r.branches.filter(t=>t.toLowerCase().includes(e)):r.branches},[r,l]);if(!r?.git)return null;let _=a||n,v=r.detached?t(`git.detached`):r.branch??t(`git.detached`),y=new Map((r.worktrees??[]).filter(e=>!e.isMain&&e.branch).map(e=>[e.branch,e])),b=g.filter(e=>!y.has(e)),x=g.filter(e=>y.has(e)),S=async e=>{c(!1),u(``);try{await navigator.clipboard.writeText(e.path),R.success(t(`git.worktreePathCopied`),{description:e.path})}catch{R.info?.(e.path)}};return(0,Q.jsxs)(`div`,{ref:d,className:`relative mt-1.5 flex min-w-0 items-center gap-2 px-1 text-[11px] text-foreground/50`,"data-agent-interactive":!0,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{_||c(e=>!e)},disabled:_,"aria-label":t(`git.branch`),"aria-expanded":s,title:t(_&&n?`git.lockedWhileWorking`:`git.branch`),className:`flex max-w-[220px] shrink-0 items-center gap-1.5 rounded-md border border-border/50 bg-surface/60 px-1.5 py-0.5 text-[11px] text-foreground transition-colors hover:bg-surface disabled:opacity-50`,children:[a?(0,Q.jsx)(ut,{className:`h-3 w-3 shrink-0 animate-spin text-accent-primary/70`}):(0,Q.jsx)(lt,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:v}),(0,Q.jsx)(pe,{className:`h-3 w-3 shrink-0 text-foreground/40`})]}),(0,Q.jsx)(MF,{children:s&&(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute bottom-full left-0 z-20 mb-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Q.jsx)(ht,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:t(`git.searchPlaceholder`),"aria-label":t(`git.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Q.jsxs)(`div`,{className:`max-h-64 overflow-y-auto py-1`,role:`listbox`,"aria-label":t(`git.branch`),children:[g.length===0&&(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:t(`git.noMatches`)}),b.map((e,t)=>(0,Q.jsxs)(ML.button,{type:`button`,role:`option`,"aria-selected":e===r.branch,onClick:()=>void h(e),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.02,.16)},className:`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,Q.jsx)(lt,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),e===r.branch&&(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`})]},e)),x.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-1 border-t border-border/50 px-3 pb-0.5 pt-1.5 text-[10px] uppercase tracking-wide text-foreground/40`,children:t(`git.worktrees`)}),x.map((e,n)=>{let r=y.get(e);return(0,Q.jsxs)(ML.button,{type:`button`,role:`option`,"aria-selected":!1,onClick:()=>void S(r),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(n*.02,.16)},title:t(`git.copyWorktreePath`),className:`group flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground hover:bg-surface/70`,children:[(0,Q.jsx)(nr,{className:`h-3.5 w-3.5 shrink-0 text-accent-secondary/80`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-mono text-xs`,children:e}),(0,Q.jsx)(`span`,{className:`block truncate text-[10px] text-foreground/40`,children:r.path})]}),(0,Q.jsx)(Un,{className:`h-3 w-3 shrink-0 text-foreground/30 opacity-0 transition-opacity group-hover:opacity-100`})]},e)})]})]})]})}),r.dirty&&(0,Q.jsx)(`span`,{title:t(`git.dirty`),"aria-label":t(`git.dirty`),className:`h-1.5 w-1.5 shrink-0 rounded-full bg-accent-warning`}),r.lastCommit&&(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`${r.lastCommit.hash} · ${r.lastCommit.subject}`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-foreground/40`,children:r.lastCommit.hash}),` · `,r.lastCommit.subject]})]})}var wz={reference:xn,trace:fr,action:gt},Tz={project:En,spec:ct,job:wn,trace:fr,conversation:wn,file:Lr,alias:xn,pr:Oe,action:gt};function Ez(e){return e===`reference`?`@`:e===`trace`?`#`:`/`}function Dz(e){return e===`spec`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`job`||e===`trace`?`border-accent-info/30 bg-accent-info/10 text-accent-info`:e===`action`?`border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`:e===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function Oz({chips:e,onRemove:t}){let{t:n}=I(`agent`);return e.length===0?null:(0,Q.jsx)(Q.Fragment,{children:e.map(e=>{let r=Tz[e.kind]??xn;return(0,Q.jsxs)(`span`,{title:[e.label,e.detail,e.projectName,e.status].filter(Boolean).join(` · `),className:`inline-flex max-w-[240px] items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] ${Dz(e.kind)}`,children:[(0,Q.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),e.status&&(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:e.status}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":n(`palette.remove`,{label:e.label}),className:`rounded-sm text-foreground/45 hover:bg-background/60 hover:text-foreground`,children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]},`${e.kind}:${e.id}`)})})}function kz({items:e,mode:t,query:n,activeIndex:r,onActiveIndexChange:i,onSelect:a}){let{t:o}=I(`agent`),s=wz[t],c=``;return(0,Q.jsxs)(`div`,{"data-testid":`agent-context-palette`,className:`absolute bottom-[calc(100%+0.5rem)] left-0 right-0 z-30 overflow-hidden rounded-lg border border-border/70 bg-background/95 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-6 w-6 items-center justify-center rounded-md bg-surface text-foreground/70`,children:(0,Q.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`text-xs font-medium text-foreground`,children:[Ez(t),` `,o(`palette.mode.${t}.title`)]}),(0,Q.jsx)(`div`,{className:`truncate text-[11px] text-foreground/45`,children:n?o(`palette.filtering`,{query:n}):o(`palette.mode.${t}.hint`)})]}),(0,Q.jsx)(`div`,{className:`hidden text-[10px] text-foreground/35 sm:block`,children:o(`palette.keyboard`)})]}),e.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3 text-xs text-foreground/55`,children:[(0,Q.jsx)(ht,{className:`h-3.5 w-3.5 text-foreground/35`}),(0,Q.jsx)(`span`,{children:n?o(`palette.noMatchesFor`,{query:n}):o(`palette.noMatches`)})]}):(0,Q.jsx)(`div`,{className:`max-h-[19rem] overflow-y-auto py-1`,children:e.map((e,t)=>{let n=Tz[e.icon]??gt,o=e.group!==c;c=e.group;let s=t===r;return(0,Q.jsxs)(`div`,{children:[o&&(0,Q.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/35`,children:e.group}),(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":s,onMouseEnter:()=>i(t),onMouseDown:e=>e.preventDefault(),onClick:()=>a(e),className:`flex w-full items-center gap-2 px-2.5 py-2 text-left transition-colors ${s?`bg-accent-primary/10 text-foreground`:`text-foreground/80 hover:bg-surface/70`}`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${s?`bg-background text-accent-primary`:`bg-surface text-foreground/50`}`,children:(0,Q.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title}),e.risk&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border/60 px-1 py-0.5 text-[10px] uppercase text-foreground/45`,children:e.risk})]}),(e.subtitle||e.detail)&&(0,Q.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-foreground/45`,children:[e.subtitle,e.subtitle&&e.detail?` · `:``,e.detail]})]})]})]},e.id)})})]})}function Az({open:e,canAttach:t,uploading:n,onToggle:r,onClose:i,onOpenMode:a,onAttachFile:o}){let{t:s}=I(`agent`),c=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t instanceof Node&&c.current?.contains(t)||i()},n=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n,!0)}},[e,i]),(0,Q.jsxs)(`div`,{ref:c,className:`relative mb-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:r,"aria-label":s(`palette.addContextAction`),title:s(`palette.addContextAction`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/50 hover:bg-surface hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(pt,{className:`h-4 w-4`})}),e&&(0,Q.jsxs)(`div`,{className:`absolute bottom-8 left-0 z-40 w-64 overflow-hidden rounded-lg border border-border/70 bg-background/95 py-1 shadow-xl shadow-black/15 backdrop-blur`,children:[(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`reference`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Q.jsx)(xn,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.reference`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.referenceHint`)})]})]}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`trace`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Q.jsx)(fr,{className:`h-4 w-4 text-accent-info`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.trace`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.traceHint`)})]})]}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(`action`),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface`,children:[(0,Q.jsx)(gt,{className:`h-4 w-4 text-accent-highlight`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.action`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.actionHint`)})]})]}),(0,Q.jsx)(`div`,{className:`my-1 border-t border-border/60`}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:o,disabled:!t||n,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-surface disabled:cursor-not-allowed disabled:opacity-45`,children:[(0,Q.jsx)(Lr,{className:`h-4 w-4 text-foreground/50`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.fileAttachment`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.fileAttachmentHint`)})]})]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:!0,className:`flex w-full cursor-not-allowed items-center gap-2 px-3 py-2 text-left text-sm opacity-45`,children:[(0,Q.jsx)(On,{className:`h-4 w-4 text-foreground/50`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:s(`palette.plus.browserCapture`)}),(0,Q.jsx)(`span`,{className:`block truncate text-[11px] text-foreground/45`,children:s(`palette.plus.browserCaptureHint`)})]})]})]})]})}var jz={"accent-primary":`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,"accent-info":`border-accent-info/40 bg-accent-info/10 text-accent-info`,"accent-highlight":`border-accent-highlight/40 bg-accent-highlight/10 text-accent-highlight`};function Mz({process:e,accentVariant:t,onKill:n}){let[r,i]=(0,Z.useState)(Date.now());(0,Z.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let a=iv(r-e.startedAt),o=e.status===`exited`||e.status===`failed`||e.status===`killed`;return(0,Q.jsx)(_m,{delayDuration:150,children:(0,Q.jsxs)(vm,{children:[(0,Q.jsx)(ym,{asChild:!0,children:(0,Q.jsxs)(`span`,{"data-testid":`background-process-chip`,className:`group inline-flex max-w-[220px] items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] transition-colors ${jz[t]}`,children:[(0,Q.jsx)(fi,{className:`h-3 w-3 shrink-0 ${o?``:`animate-pulse`}`}),(0,Q.jsx)(`span`,{className:e.status===`failed`?`shrink-0 font-medium text-destructive`:`shrink-0 text-foreground/60`,children:e.status}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.command}),!o&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Kill ${e.command}`,title:`Kill ${e.command}`,onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.pid)},className:`rounded-sm p-0.5 opacity-70 transition-opacity hover:bg-background/60 hover:opacity-100 group-hover:opacity-100`,children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]})}),(0,Q.jsx)(bm,{children:o?`${e.status} after ${a}`:a})]})})}var Nz=[`claude`,`codex`,`gemini`];function Pz(e,t){if(!t)return{text:e,caret:e.length};let n=e.slice(0,t.start),r=e.slice(t.end);/\s$/.test(n)&&/^\s/.test(r)&&(r=r.replace(/^\s+/,``));let i=n&&r&&!/\s$/.test(n)&&!/^\s/.test(r)?` `:``;return{text:`${n}${i}${r}`,caret:n.length+i.length}}var Fz=new Map,Iz=new Map,Lz=`__new-mission__`;function Rz({autoFocus:e=!1,hideProjectSelector:t=!1}){let{t:n}=I(`agent`),{active:r,messages:i,conversations:a,isStreaming:o,providersReady:s,draftPinnedProjectId:c,draftProvider:l,draftModel:u,draftTierLevel:d,draftEffort:f,setEffort:p,send:m,abort:h,cycleTier:g,setProvider:_,setModel:v,setPinnedProject:y,materializeDraftConversation:b,queuedMessages:x,editQueuedMessage:S,wasQueueConsumed:C}=UV(),{pendingCaptures:w,consumePendingCaptures:T}=zR(),{processes:E,kill:D}=WR(),{projects:O,activeProjectId:k}=At(),A=r?.id??Lz,[j,M]=(0,Z.useState)(()=>Fz.get(A)??``),N=e=>{M(e),e?Fz.set(A,e):Fz.delete(A)},[P,F]=(0,Z.useState)(null),[L,z]=(0,Z.useState)(()=>Iz.get(A)??[]),B=(0,Z.useRef)(A);B.current=A;let V=(e,t)=>{let n=Iz.get(e)??[],r=typeof t==`function`?t(n):t;r.length>0?Iz.set(e,r):Iz.delete(e);let i=B.current;(i===e||i===Lz&&e!==Lz)&&z(r)},[H,U]=(0,Z.useState)(!1),W=(0,Z.useRef)(null),ee=(0,Z.useRef)(null),[te,G]=(0,Z.useState)([]),[K,ne]=(0,Z.useState)(null),[re,ie]=(0,Z.useState)(0),[ae,oe]=(0,Z.useState)(!1),[se,ce]=(0,Z.useState)([]),[le,q]=(0,Z.useState)([]),ue=P!==null,de=(0,Z.useMemo)(()=>i.filter(e=>e.role===`user`).map(e=>e.content),[i]),[fe,pe]=(0,Z.useState)(null),me=(0,Z.useRef)(``),he=(0,Z.useRef)(``),ge=fe===null?-1:x.findIndex(e=>e.queueId===fe),_e=ge>=0?x[ge]:null,ve=fe!==null,ye=s===!1,J=!ye,xe=r?.provider??l,Se=r?r.pinned_project_id:c,Ce=Se,we=(0,Z.useMemo)(()=>({projects:O,conversations:a,activeConversation:r,pinnedProjectId:Ce,activeProjectId:k,tickets:se,jobs:le,chips:te}),[O,a,r,Ce,k,se,le,te]),Te=(0,Z.useMemo)(()=>K?lz(K.mode,we):[],[K,we]),Ee=(0,Z.useMemo)(()=>{if(!K)return[];let e=rz(Te,K.query);return e.length>0?e:uz(K.mode,K.query)},[Te,K]),De=K!==null&&!ve,Oe=j.trim().length>0||te.length>0,ke=[`accent-primary`,`accent-info`,`accent-highlight`],Ae=r?.id??null;(0,Z.useEffect)(()=>{z(Iz.get(Ae??Lz)??[]),F(null),ne(null),oe(!1),G([]),pe(null),M(Fz.get(Ae??Lz)??``)},[Ae]),(0,Z.useEffect)(()=>{if(!Ce){ce([]),q([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${xt}/api/projects/${encodeURIComponent(Ce)}/tickets`),fetch(`${xt}/api/projects/${encodeURIComponent(Ce)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;ce(Array.isArray(r.tickets)?r.tickets:[]),q(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;ce([]),q([])}})(),()=>{e=!1}},[Ce]),(0,Z.useEffect)(()=>{ie(0)},[K?.mode,K?.query]),(0,Z.useEffect)(()=>{re>=Ee.length&&ie(Math.max(0,Ee.length-1))},[re,Ee.length]),(0,Z.useEffect)(()=>{if(w.length===0)return;let e=T();e.length&&V(A,t=>[...t,...e])},[w,T,A]);let je=Sz(xe),{models:Me,efforts:Ne,supportsImageInput:Pe}=je,Fe=(r?r.reasoning_effort:f)??`medium`,Ie=e=>{let t=Fz.get(Lz);t&&(Fz.has(e)||Fz.set(e,t),Fz.delete(Lz),M(Fz.get(e)??t));let n=Iz.get(Lz);if(n?.length){let t=Iz.get(e)??[];V(e,[...t,...n]),Iz.delete(Lz)}},Le=async e=>{if(e.length===0)return;U(!0);let t=r;if(!t)try{t=await b(),Ie(t.id)}catch(e){R.error(e instanceof Error?e.message:n(`workspace.uploadFailed`)),U(!1);return}for(let r of e){if(!Pe&&r.type.startsWith(`image/`)){R.error(n(`imagesUnsupported`));continue}try{let e=await SE(t.id,r);V(t.id,t=>[...t,e])}catch(e){R.error(e instanceof Error?e.message:n(`workspace.uploadFailed`))}}U(!1)},Re=e=>{V(A,t=>t.filter(t=>t.id!==e)),r&&EE(r.id,e)},ze=(e,t)=>{let n=qR(e,t);ne(n),n&&oe(!1)},Be=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,Ve=e=>{requestAnimationFrame(()=>{ee.current?.focus(),ee.current?.setSelectionRange(e,e)})},He=e=>{if(ve)return;let t=Be(e),n=ee.current,r=n?.selectionStart??j.length,i=n?.selectionEnd??r,a=`${j.slice(0,r)}${t}${j.slice(i)}`;N(a),F(null),oe(!1),ne({mode:e,trigger:t,query:``,start:r,end:r+1}),Ve(r+1)},Ue=e=>{let t=e.chip?Pz(j,K):dz(j,K,e);N(t.text),F(null),ne(null),oe(!1),e.chip&&G(t=>t.some(t=>JR(t)===JR(e.chip))?t:[...t,e.chip]),Ve(t.caret)},We=e=>{let t=JR(e);G(e=>e.filter(e=>JR(e)!==t))},Ge=e=>{let t=x[e];t&&(pe(t.queueId),he.current=t.text,M(t.text))},Ke=e=>{me.current=ue?``:j,F(null),Ge(e)},qe=(e,t)=>{pe(null),e===`keep`?N(t??j):M(me.current)},Je=async()=>{let e=_e,t=j.trim();if(!(!e||!t))try{await S(e.queueId,t)===`saved`?qe(`restore`):(R.info(n(`queueEdit.dispatched`)),qe(`keep`))}catch{R.error(n(`queueEdit.saveFailed`))}};(0,Z.useEffect)(()=>{if(fe===null||x.some(e=>e.queueId===fe))return;let e=j!==he.current;C(fe)&&R.info(n(`queueEdit.dispatched`)),qe(e?`keep`:`restore`)},[fe,x]);let Ye=()=>{if(ye||!Oe)return;let e=j.trim()||te.map(e=>e.token).join(` `),t={...L.length?{attachmentIds:L.map(e=>e.id)}:{},...te.length?{contextRefs:te.map(YR)}:{}};m(e,L.length||te.length?t:void 0),N(``),V(A,[]),G([]),ne(null),oe(!1),F(null)},Xe=e=>{if(de[e]===void 0){F(null);return}F(e),N(de[e])};return(0,Q.jsxs)(`div`,{className:`shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[r===null&&!t&&(0,Q.jsx)(gz,{pinnedProjectId:c,onSelect:e=>void y(e)}),(0,Q.jsx)(hz,{label:n(`provider.label`),value:xe,options:Nz.map(e=>({value:e,label:n(`provider.${e}`)})),icon:wn,onSelect:e=>{_(e).catch(()=>R.error(n(`error.generic`)))},testId:`agent-provider-selector`}),(0,Q.jsx)(bz,{models:Me,model:r?r.model:u,status:je.status,onSelect:e=>{v(e).catch(()=>R.error(n(`error.generic`)))}}),Ne.length>0&&(0,Q.jsx)(hz,{label:n(`effort.label`),value:Fe,options:Ne.map(e=>({value:e,label:n(`effort.${e}`)})),icon:ar,onSelect:e=>{p(e).catch(()=>R.error(n(`error.generic`)))},testId:`agent-effort-selector`}),(0,Q.jsx)(`div`,{className:`ml-auto`,children:(0,Q.jsx)(yz,{level:r?.tier_level??d,onCycle:()=>void g()})})]}),ve&&_e&&(0,Q.jsxs)(`div`,{"data-testid":`queue-edit-chip`,className:`mb-1 flex items-center gap-1.5 rounded-md border border-accent-highlight/30 bg-accent-highlight/10 px-2 py-1 text-[11px] text-accent-highlight`,children:[(0,Q.jsx)(dt,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n(`queueEdit.editing`,{n:ge+1,m:x.length})}),(0,Q.jsx)(`span`,{className:`truncate text-foreground/45`,children:n(`queueEdit.hint`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>qe(`restore`),"aria-label":n(`queueEdit.cancel`),title:n(`queueEdit.cancel`),className:`ml-auto rounded-sm p-0.5 text-foreground/50 hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]}),ue&&(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,Q.jsx)(mr,{className:`h-3 w-3`}),n(`history.hint`)]}),L.length>0&&(0,Q.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:L.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[11px] text-foreground/80`,children:[(0,Q.jsx)(Lr,{className:`h-3 w-3 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.filename}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>Re(e.id),"aria-label":n(`close`),className:`rounded-sm hover:bg-muted`,children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]},e.id))}),E.length>0&&(0,Q.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:E.map((e,t)=>(0,Q.jsx)(Mz,{process:e,accentVariant:ke[t%ke.length],onKill:e=>void D(e)},e.pid))}),(0,Q.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border bg-background/60 px-3 py-2 ${ve?`border-accent-highlight/50`:ue?`border-accent-info/40`:`border-border/60`}`,onDragOver:e=>{J&&e.preventDefault()},onDrop:e=>{if(!J)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&Le(t)},children:[De&&(0,Q.jsx)(kz,{items:Ee,mode:K.mode,query:K.query,activeIndex:re,onActiveIndexChange:ie,onSelect:Ue}),J&&(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`input`,{ref:W,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&&Le(t),e.target.value=``}})}),(0,Q.jsx)(Az,{open:ae,canAttach:J,uploading:H,onToggle:()=>{oe(e=>!e),ne(null)},onClose:()=>oe(!1),onOpenMode:He,onAttachFile:()=>{oe(!1),W.current?.click()}}),(0,Q.jsxs)(`div`,{className:`flex min-h-[3.25rem] flex-1 flex-wrap items-start gap-1.5`,children:[!ve&&(0,Q.jsx)(Oz,{chips:te,onRemove:We}),(0,Q.jsx)(`textarea`,{ref:ee,value:j,autoFocus:e,onChange:e=>{if(ve){M(e.target.value);return}ue&&F(null),N(e.target.value),ze(e.target.value,e.target.selectionStart??e.target.value.length)},onClick:e=>ze(e.currentTarget.value,e.currentTarget.selectionStart??e.currentTarget.value.length),onKeyDown:e=>{if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),g();return}if(De){if(e.key===`ArrowDown`){e.preventDefault(),Ee.length>0&&ie(e=>Math.min(Ee.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Ee.length>0&&ie(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=Ee[re]??Ee[0];t&&Ue(t);return}if(e.key===`Escape`){e.preventDefault(),ne(null);return}}if(e.key===`Backspace`&&j.length===0&&te.length>0&&!ve){e.preventDefault(),G(e=>e.slice(0,-1));return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),ve?Je():Ye();return}if(e.key===`Escape`&&ve){e.preventDefault(),e.stopPropagation(),qe(`restore`);return}let t=e.currentTarget,n=t.selectionStart===0&&t.selectionEnd===0,r=t.selectionStart===j.length&&t.selectionEnd===j.length;if(e.key===`ArrowUp`){if(ve){_e!==null&&j===_e.text&&n&&ge>0&&(e.preventDefault(),Ge(ge-1));return}if(x.length>0){n&&(e.preventDefault(),Ke(x.length-1));return}!ue&&j===``&&de.length>0?(e.preventDefault(),Xe(de.length-1)):ue&&(e.preventDefault(),Xe(Math.max(0,P-1)));return}if(e.key===`ArrowDown`){if(ve){_e!==null&&j===_e.text&&r&&(e.preventDefault(),ge<x.length-1?Ge(ge+1):qe(`restore`));return}if(x.length>0)return;ue&&(e.preventDefault(),P<de.length-1?Xe(P+1):(F(null),N(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&ue&&F(null)},onPaste:e=>{if(!J)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),Le(t))},rows:2,disabled:ye,placeholder:te.length>0?``:n(ye?`noProvider.placeholder`:o?`queue.placeholder`:`composerPlaceholder`),"data-agent-interactive":!0,title:ve?n(`queueEdit.hint`):ue?n(`history.hint`):void 0,className:`min-h-[3.25rem] max-h-64 min-w-[12rem] flex-1 resize-y bg-transparent text-sm outline-none placeholder:text-foreground/40 disabled:opacity-60 ${ue?`italic text-foreground/50`:`text-foreground`}`})]}),ve?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void Je(),disabled:ye||!j.trim(),"aria-label":n(`queueEdit.save`),title:n(`queueEdit.save`),className:`rounded-lg bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,Q.jsx)(be,{className:`h-4 w-4`})}):o&&!Oe?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void h(),"aria-label":n(`stop`),title:n(`stop`),className:`rounded-lg bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,Q.jsx)(ci,{className:`h-4 w-4`,fill:`currentColor`})}):o?(0,Q.jsxs)(`button`,{type:`button`,onClick:Ye,disabled:ye,"aria-label":n(`queue.send`),title:n(`queue.sendHint`),className:`relative rounded-lg bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:[(0,Q.jsx)($r,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-background ring-1 ring-border`,children:(0,Q.jsx)(Ln,{className:`h-2.5 w-2.5 text-accent-info`})})]}):(0,Q.jsx)(`button`,{type:`button`,onClick:Ye,disabled:ye||!Oe,"aria-label":n(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,Q.jsx)($r,{className:`h-4 w-4`})})]}),Se&&(0,Q.jsx)(Cz,{projectId:Se})]})}var zz=e=>e===`running`||e===`queued`;function Bz(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${n%60}m`}function Vz(){try{return Et()}catch{return null}}var Hz=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function Uz(e,t,n){let{live:r}=n,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(()=>Date.now());(0,Z.useEffect)(()=>{let n=!1;return fetch(`${xt}/api/projects/${e}/jobs/${t}`).then(e=>e.ok?e.json():null).then(e=>{if(n)return;let t=e?.job;t&&(s(typeof t.status==`string`?t.status:null),l(Hz(t.started_at)),d(Hz(t.finished_at)),typeof t.total_cost_usd==`number`&&p(t.total_cost_usd),typeof t.num_turns==`number`&&h(t.num_turns),_(t.loopPaused===!0),y(typeof t.loopPauseReason==`string`?t.loopPauseReason:null)),a(!0)}).catch(()=>{n||a(!0)}),()=>{n=!0}},[e,t,r]);let S=zz(o)&&u===null,C=Vz(),w=(0,Z.useId)();return(0,Z.useEffect)(()=>{if(!C||!r)return;let e=`run-vitals-${t}-${w}`;return C.registerHandler(e,e=>{let n=e;if(n?.type===`loop.run_paused`&&n.loopRunId===t){_(!0),y(typeof n.reason==`string`?n.reason:null),s(`running`),d(null);return}if((n?.type===`loop.run_resumed`||n?.type===`loop.run_completed`)&&n.loopRunId===t){_(!1),y(null);return}n?.jobId===t&&(n.type===`job.turn_done`?(typeof n.totals?.total_cost_usd==`number`&&p(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&h(n.totals.num_turns)):n.type===`job.finalized`&&(typeof n.totals?.total_cost_usd==`number`&&p(n.totals.total_cost_usd),typeof n.totals?.num_turns==`number`&&h(n.totals.num_turns),typeof n.status==`string`&&s(n.status),_(!1),y(null),d(Hz(n.timestamp)??Date.now())))}),()=>C.unregisterHandler(e)},[C,r,t,w]),(0,Z.useEffect)(()=>{if(!r||!S||c===null)return;let e=setInterval(()=>x(Date.now()),1e3);return()=>clearInterval(e)},[r,S,c]),{status:o,paused:g,pausedReason:v,running:S,elapsedMs:c===null?null:Math.max(0,(u??b)-c),costUsd:f,numTurns:m,loaded:i}}function Wz(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var Gz=15e3;function Kz(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function qz(e){let{projectId:t,jobId:n,timeoutMs:r=Gz}=e,i=t?`${xt}/api/projects/${t}`:Ot(),a;try{a=await fetch(`${i}/jobs/${n}/cancel`,{method:`POST`,signal:Kz(r)})}catch(e){let t=e;return{ok:!1,error:t?.name===`TimeoutError`||t?.name===`AbortError`?`Request timed out after ${Math.round(r/1e3)}s`:t?.message||String(e),httpStatus:null}}if(a.ok){let e=`canceled`;try{let t=await a.json();t&&typeof t.status==`string`&&(e=t.status)}catch{}return{ok:!0,status:e}}let o=typeof a.status==`number`?a.status:null,s=o==null?``:` (HTTP ${o})`,c=``;try{typeof a.text==`function`?c=await a.text():typeof a.json==`function`&&(c=JSON.stringify(await a.json()))}catch{}let l=c.slice(0,200).trim();try{let e=JSON.parse(c);e&&typeof e.error==`string`&&e.error&&(l=e.error)}catch{}let u=typeof a.statusText==`string`?a.statusText:``;return{ok:!1,error:l?`${l}${s}`:`HTTP ${o??`?`}${u?` ${u}`:``}`,httpStatus:o}}var Jz=(0,Z.lazy)(()=>c(()=>import(`./JobDetailModal-I_RoQJV4.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75]))),Yz={building:lt,on_review:lt,pr_draft:Oe,pr_ready:Oe,no_changes:Pn,completed:Pn,pr_closed:ot,superseded:Oe,implementation_failed:vt,pr_failed:vt,merged:sr,discarded:ot},Xz={building:`text-accent-primary/70`,on_review:`text-accent-primary`,pr_draft:`text-accent-info`,pr_ready:`text-accent-info`,no_changes:`text-accent-success`,completed:`text-accent-success`,pr_closed:`text-accent-warning`,superseded:`text-foreground/40`,implementation_failed:`text-destructive`,pr_failed:`text-destructive`,merged:`text-accent-success`,discarded:`text-foreground/40`};function Zz({envelope:e}){let{t}=I(`agent`),n=Cv(e);return n.units.length===0&&!n.partial?null:(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1.5`,"data-testid":`agent-pr-unit-evidence`,children:[n.partial&&(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-accent-warning`,children:t(`prCard.partialSummary`,{succeeded:n.succeededCount,failed:n.failedCount,total:n.totalCount})}),n.units.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.units.map(e=>{let n=e.implementationOutcome===`failed`||e.implementationOutcome==null&&!e.succeeded,r=e.deliveryOutcome===`no_changes`||e.changed===!1,i=e.deliveryOutcome===`blocked`,a=t(n?`prCard.unit.failed`:i?`prCard.unit.blocked`:r?`prCard.unit.noChanges`:`prCard.unit.succeeded`);return(0,Q.jsxs)(`span`,{title:e.failureCode??e.branch,className:X(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px]`,n?`border-destructive/35 bg-destructive/10 text-destructive`:i?`border-accent-warning/35 bg-accent-warning/10 text-accent-warning`:`border-accent-success/30 bg-accent-success/10 text-accent-success`),children:[`#`,e.ticketId,` · `,a]},`${e.ticketId}-${e.runId??e.branch}`)})})]})}function Qz(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function $z({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=I(`agent`),s=Uz(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:Bz(s.elapsedMs),u=s.costUsd!=null&&s.costUsd>0,d=(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-40`,children:`·`});return(0,Z.useEffect)(()=>{a?.(t,{paused:s.paused,pausedReason:s.pausedReason})},[a,t,s.paused,s.pausedReason]),(0,Q.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`pr-run-log-chip`,onClick:e=>{e.stopPropagation(),i(t)},title:o(`prCard.viewLog`,{ref:c}),"aria-label":o(`prCard.viewLog`,{ref:c}),className:X(`inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full border px-1.5 py-px align-baseline font-mono text-[0.82em] leading-[1.45] transition-all`,s.paused?`border-accent-warning/45 bg-accent-warning/10 text-accent-warning hover:-translate-y-px hover:border-accent-warning/65 hover:bg-accent-warning/15 hover:shadow-sm`:`border-accent-info/35 bg-accent-info/10 text-accent-info hover:-translate-y-px hover:border-accent-info/60 hover:bg-accent-info/15 hover:shadow-sm`),children:[(s.paused||s.running&&r)&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 shrink-0 animate-pulse rounded-full`,s.paused?`bg-accent-warning`:`bg-accent-info`)}),(0,Q.jsx)(`span`,{className:`max-w-[160px] truncate`,children:c}),d,(0,Q.jsx)(Qr,{className:`h-3 w-3 shrink-0 opacity-70`}),l&&(0,Q.jsxs)(Q.Fragment,{children:[d,(0,Q.jsx)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runElapsedAria`,{elapsed:l}),children:l})]}),u&&(0,Q.jsxs)(Q.Fragment,{children:[d,(0,Q.jsxs)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runCostAria`,{cost:`$${s.costUsd.toFixed(2)}`}),children:[`$`,s.costUsd.toFixed(2)]})]})]})}function eB({envelope:e}){let{t}=I(`agent`),{projects:n}=At(),{applyPrDecisionSnapshot:r}=UV(),{openWebView:i,canOpenWebView:a}=We(),{openRef:o}=FL(),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),D=T??e,[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)({}),[M,N]=(0,Z.useState)(null),{decision:P,prUrl:F,prState:L}=D,z=Cv(D),B=gv(D.statusCode,D.statusDetail),V=D.operation==null&&B,H=n.find(e=>e.id===D.projectId)?.name??D.projectId,U=P===`pr_draft`&&!F,W=P===`building`&&L===`pr-created`&&!!D.branch,ee=D.prNumber?`#${D.prNumber}`:F?Qz(F):null,te=z.terminal,G=mv(D.statusCode)?t(`common:prDeliveryStatus.${D.statusCode}`):null,K=z.partial&&z.deliverableCount>0&&(P===`on_review`||P===`pr_draft`&&!F);(0,Z.useEffect)(()=>{E(null)},[e]),(0,Z.useEffect)(()=>{c(null),f(!1),m(!1),g(!1),v(!1),b(!1),S(!1),w(!1)},[P,F,D.prDeliveryId]);let ne=(0,Z.useCallback)((e,t)=>{j(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),re=async e=>{if(!M){N(e);try{let n=await qz({projectId:D.projectId,jobId:e,kind:`loop-run`});n.ok?R.info(t(`prCard.stopExecutionSent`)):R.error(t(`prCard.stopExecutionFailed`),{description:n.error})}finally{N(null)}}},ie=async e=>{if(!(l||s||D.operation)){c(e);try{let n=await PE(D.projectId,{prDeliveryId:D.prDeliveryId,action:e,expectedDecision:P}),i=null;if(n.snapshot){let e=FE(D,n.snapshot);i=r(e),i!==`stale`&&E(e)}if(i===`stale`){R.info(t(`prCard.alreadyResolved`));return}if(n.kind===`recovering`)R.info(t(`common:prRecovery.inProgress`));else if(n.kind===`busy`)R.info(t(`prCard.operation.${n.operation??`inProgress`}`));else if(n.kind===`stale`)R.info(t(`prCard.alreadyResolved`));else if(n.kind===`blocked`)R.warning(n.reason===`dirty`?t(`prCard.mergeLocalBlockedDirty`,{base:n.base||D.baseBranch}):t(`prCard.mergeLocalBlockedBranch`,{base:n.base||D.baseBranch,current:n.current??`?`}));else if(n.kind===`failed`)R.error(t(`prCard.actionFailed`),{description:n.detail});else if(n.kind===`ok`&&e===`recover-and-retry`)if(n.deliveryVerified){let e=(n.verifiedSha??n.snapshot?.deliverySha??``).slice(0,8);R.success(t(`prCard.recoverAndRetryVerified`,{sha:e}))}else n.recoveryUnavailable||n.snapshot?.statusCode===`recovery_unavailable`?R.info(t(`prCard.recoveryUnavailable`),{description:t(`prCard.recoveryUnavailableBody`)}):R.warning(t(`prCard.recoveryStillBlocked`),{description:n.detail??void 0});else if(n.kind===`ok`&&e===`create-pr`&&z.retryablePush&&n.deliveryVerified){let e=(n.verifiedSha??n.snapshot?.deliverySha??D.deliverySha??``).slice(0,8);R.success(t(n.pushed?`prCard.retryPushVerified`:`prCard.commitAlreadyVerified`,{sha:e}))}else if(n.kind===`ok`&&e===`create-pr`&&n.detail)R.error(t(`prCard.deliveryNeedsAttention`),{description:n.detail});else if(n.kind===`ok`&&e===`poll-merge`&&n.deliveryVerified===!1)R.warning(t(`prCard.commitMissingRetry`));else if(n.kind===`ok`&&e===`poll-merge`&&n.deliveryVerified&&!n.merged){let e=(n.verifiedSha??n.snapshot?.deliverySha??D.deliverySha??``).slice(0,8);R.success(t(`prCard.prVerifiedWaiting`,{sha:e}))}else e===`poll-merge`&&!n.merged&&n.decision!==`pr_closed`?R.info(t(`prCard.notMergedYet`)):e===`merge-local`&&n.kind===`ok`&&n.decision===`merged`&&R.success(t(`prCard.mergedLocally`,{base:D.baseBranch}))}catch(e){R.error(t(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{c(null)}}},ae=async()=>{if(!(s||l||D.operation)){u(!0);try{let e=await IE(D.projectId,D.prDeliveryId);e.kind===`ok`?R.success(t(`prCard.checkoutSuccess`,{branch:D.branch??``})):e.kind===`recovering`?R.info(t(`common:prRecovery.inProgress`)):e.error===`checkout_dirty`?R.warning(t(`prCard.checkoutDirtyTitle`),{description:t(`prCard.checkoutDirtyBody`)}):e.error===`checkout_not_deliverable`?R.warning(t(`prCard.checkoutNotDeliverableTitle`),{description:t(`prCard.checkoutNotDeliverableBody`)}):e.error===`checkout_safety_unknown`?R.warning(t(`prCard.checkoutSafetyUnknownTitle`),{description:t(`prCard.checkoutSafetyUnknownBody`)}):R.warning(t(`prCard.checkoutFailed`),{description:e.detail})}catch(e){R.error(t(`prCard.checkoutFailed`),{description:e instanceof Error?e.message:void 0})}finally{u(!1)}}},oe=async()=>{let e=z.recoveryWorktreePaths;if(e.length===0){R.info(t(`prCard.localResultUnavailableHere`));return}let n=e.join(`
|
|
61
61
|
`),r=!1;try{await navigator.clipboard.writeText(n),r=!0}catch{}try{ze()&&await tt(e[0])}catch{}r?R.success(t(`prCard.localResultPathCopied`),{description:n}):R.info(t(`prCard.localResultPath`),{description:n})},se=(e,t)=>{a&&(e.preventDefault(),e.stopPropagation(),i(t))},ce=D.ticketIds.length>0&&(0,Q.jsx)(Q.Fragment,{children:D.ticketIds.map(e=>(0,Q.jsxs)(CR,{refTarget:{kind:`ticket`,ticketId:e},onOpen:e=>void o(D.projectId,e),children:[`#`,e]},e))}),le=D.runIds??[],q=e=>le.length===1&&D.ticketIds.length>1?D.ticketIds.map(e=>`#${e}`).join(` `):D.ticketIds[e]==null?null:`#${D.ticketIds[e]}`,ue=le.find(e=>A[e]?.paused)??null,de=ue?A[ue]?.pausedReason??null:null,fe=le.length>0&&(0,Q.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,"data-testid":`pr-run-log-chips`,children:le.map((e,t)=>(0,Q.jsx)($z,{projectId:D.projectId,runId:e,ticketLabel:q(t),live:P===`building`,onOpen:k,onVitals:ne},e))}),pe=P===`building`&&ue!==null,me=ue?q(le.indexOf(ue))??ue.slice(0,8):null,he=O&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Jz,{jobId:O,projectId:D.projectId,onClose:()=>k(null)})});if(P===`building`)return(0,Q.jsxs)(`div`,{"data-testid":`agent-pr-decision-card`,className:`rounded-xl border border-border/60 bg-card/80 px-3.5 py-2.5 text-xs text-foreground/60 shadow-lg backdrop-blur-xl`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[pe?(0,Q.jsx)(vt,{className:`h-3.5 w-3.5 text-accent-warning`}):W?(0,Q.jsx)(Oe,{className:`h-3.5 w-3.5 text-accent-info`}):(0,Q.jsx)(ut,{className:`h-3.5 w-3.5 animate-spin text-accent-primary/70`}),(0,Q.jsx)(`span`,{className:X(!W&&!pe&&`animate-pulse`,pe&&`text-accent-warning`),children:t(pe?`prCard.title.paused`:W?`prCard.title.buildingExistingPr`:`prCard.title.building`)})]}),ce&&(0,Q.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:ce}),W&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:[F?(0,Q.jsxs)(`a`,{href:F,target:`_blank`,rel:`noreferrer`,onClick:e=>se(e,F),title:F,"data-agent-interactive":!0,className:`inline-flex items-center gap-1 rounded-full border border-accent-info/40 bg-accent-info/10 px-2 py-0.5 font-mono text-[11px] text-accent-info transition-colors hover:border-accent-info/60 hover:bg-accent-info/15`,children:[(0,Q.jsx)(Oe,{className:`h-3 w-3`}),ee??t(`prCard.openPr`),(0,Q.jsx)(J,{className:`h-2.5 w-2.5 opacity-60`})]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/40 bg-accent-info/10 px-2 py-0.5 font-mono text-[11px] text-accent-info`,children:[(0,Q.jsx)(Oe,{className:`h-3 w-3`}),ee??t(`prCard.existingPr`)]}),(0,Q.jsxs)(`span`,{title:t(`git.branch`),className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-foreground/70`,children:[(0,Q.jsx)(lt,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Q.jsx)(`span`,{className:`truncate`,children:D.branch})]})]}),pe&&ue&&(0,Q.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 px-2 py-1.5 text-[11px] text-accent-warning`,"data-testid":`pr-run-paused-actions`,children:[(0,Q.jsx)(vt,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:de??void 0,children:[me?t(`prCard.pausedForRun`,{ref:me}):t(`prCard.paused`),de?`: ${de}`:``]}),(0,Q.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:e=>{e.stopPropagation(),k(ue)},className:`inline-flex items-center gap-1 rounded-md border border-accent-warning/40 bg-surface/70 px-2 py-0.5 font-medium text-accent-warning transition-colors hover:bg-accent-warning/15`,children:[(0,Q.jsx)(ft,{className:`h-3 w-3`}),t(`prCard.resume`)]}),(0,Q.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:M===ue,onClick:e=>{e.stopPropagation(),re(ue)},className:`inline-flex items-center gap-1 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-0.5 font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-default disabled:opacity-60`,children:[M===ue?(0,Q.jsx)(ut,{className:`h-3 w-3 animate-spin`}):(0,Q.jsx)(ci,{className:`h-3 w-3`}),t(`prCard.stopExecution`)]})]}),fe&&(0,Q.jsx)(`div`,{className:`pl-[22px]`,children:fe}),(0,Q.jsx)(`p`,{className:`mt-1 pl-[22px] text-[11px] leading-4 text-foreground/40`,children:t(W?`prCard.buildingExistingPrHint`:`prCard.buildingHint`)}),he]});let ge=Yz[P],_e=z.superseded?t(`prCard.title.superseded`):z.noChanges?t(`prCard.title.no_changes`):z.deliveryBlocked?t(`prCard.title.delivery_blocked`):z.retryablePush?t(`prCard.title.update_failed`):z.closed?t(`prCard.title.pr_closed`):z.partial?t(`prCard.title.partial`):D.statusCode===`existing_pr_updated`?t(`prCard.title.existing_pr_updated`):t(U?`prCard.title.pr_draft_degraded`:`prCard.title.${P}`),ve=`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-2.5 py-1 text-xs font-medium text-white transition-colors hover:bg-accent-primary/90 disabled:cursor-default disabled:opacity-60`,ye=X(`inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:cursor-default disabled:opacity-60`,`border-border/60 text-foreground/70 hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),be=s!==null||l||D.operation!=null,xe=!!D.operation||V||z.partial||z.deliveryBlocked||z.retryablePush||z.retryablePrCreation||z.closed||z.implementationFailed,Se=(0,Q.jsx)(ut,{className:`h-3 w-3 animate-spin`}),Ce=(e,t)=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>void ie(e),disabled:be,"data-agent-interactive":!0,className:ve,children:[s===e&&Se,t]}),we=F&&D.branch&&D.deliverySha&&!z.deliveryBlocked&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>void ae(),disabled:be,"data-testid":`agent-pr-checkout`,"data-agent-interactive":!0,title:t(`prCard.checkoutTooltip`,{branch:D.branch}),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:pointer-events-none disabled:opacity-50`,children:[l?Se:(0,Q.jsx)(lt,{className:`h-3 w-3`}),t(`prCard.checkout`)]}),Te=z.recoveryWorktreePaths.length>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>void oe(),disabled:be,"data-testid":`agent-pr-inspect-local-result`,"data-agent-interactive":!0,title:t(`prCard.inspectLocalResultTooltip`),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:pointer-events-none disabled:opacity-50`,children:[(0,Q.jsx)(rr,{className:`h-3 w-3`,"aria-hidden":!0}),t(`prCard.inspectLocalResult`)]}),Ee=z.recoveryRecheck,De=(z.manualRecovery||Ee)&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),disabled:be,"data-testid":Ee?`agent-pr-recheck-recovery`:`agent-pr-recover-and-retry`,"data-agent-interactive":!0,className:Ee?`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:pointer-events-none disabled:opacity-50`:ve,children:[s===`recover-and-retry`?Se:(0,Q.jsx)(Xr,{className:`h-3 w-3`,"aria-hidden":!0}),t(Ee?`prCard.recheckRecovery`:`prCard.recoverAndRetry`)]}),ke=(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>v(!0),disabled:be,"data-testid":`agent-pr-merge-local`,"data-agent-interactive":!0,title:t(`prCard.mergeLocalTooltip`,{base:D.baseBranch}),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-2 py-1 text-[11px] font-medium text-accent-success transition-colors hover:bg-accent-success/20 disabled:pointer-events-none disabled:opacity-50`,children:[s===`merge-local`&&Se,t(`prCard.mergeLocal`)]}),Ae=(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f(!0),disabled:be,"data-agent-interactive":!0,className:ye,children:[s===`discard`&&Se,t(`prCard.discard`)]}),je=(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>m(!0),disabled:be,"data-agent-interactive":!0,className:ye,children:[s===`dismiss`&&Se,t(`prCard.dismiss`)]}),Ne=(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),disabled:be,"data-agent-interactive":!0,className:ye,children:[s===`discard`&&Se,t(`prCard.discardLocalResult`)]}),Pe=(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),disabled:be,"data-agent-interactive":!0,className:ve,children:[s===`acknowledge-no-changes`&&Se,t(`prCard.markDone`)]}),Fe=(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S(!0),disabled:be,"data-agent-interactive":!0,className:ye,children:[s===`discard`&&Se,t(`prCard.refine`)]}),Ie=F&&(0,Q.jsxs)(`a`,{href:F,target:`_blank`,rel:`noreferrer`,onClick:e=>se(e,F),title:F,"data-agent-interactive":!0,className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-accent-info transition-colors hover:border-accent-info/50 hover:bg-accent-info/10`,children:[(0,Q.jsx)(Oe,{className:`h-3 w-3`}),ee??t(`prCard.openPr`),(0,Q.jsx)(J,{className:`h-2.5 w-2.5 opacity-60`})]});return(0,Q.jsxs)(`div`,{"data-testid":`agent-pr-decision-card`,className:X(`rounded-xl border border-border/60 bg-card/80 px-3.5 py-3 shadow-lg backdrop-blur-xl`,P===`merged`&&`border-accent-success/30`,P===`completed`&&`border-accent-success/30`,P===`discarded`&&`opacity-70`),children:[xe&&(0,Q.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-label":D.operation?t(`prCard.operation.${D.operation}`):V?t(`common:prRecovery.interrupted`):_e,className:`sr-only`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ge,{className:X(`h-4 w-4 shrink-0`,Xz[P])}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:_e}),(0,Q.jsx)(`span`,{className:`max-w-[140px] shrink-0 truncate text-[11px] text-foreground/50`,title:H,children:H}),(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-foreground/60`,children:t(`prCard.rail`,{index:D.railIndex+1})})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsxs)(`span`,{title:t(`prCard.base`),className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 font-mono text-[11px] text-foreground/70`,children:[(0,Q.jsx)(lt,{className:`h-3 w-3 text-accent-primary/70`}),`→ `,D.baseBranch]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-surface/60 px-2 py-0.5 text-[11px] text-foreground/70`,children:[(0,Q.jsx)(Me,{className:`h-3 w-3 text-accent-secondary/80`}),t(`prCard.specCount`,{count:D.ticketIds.length})]}),ce,Ie,D.deliverySha&&(0,Q.jsxs)(`span`,{"data-testid":`agent-pr-delivery-sha`,title:D.deliverySha,className:X(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,D.deliveryOutcome===`delivered`?`border-accent-success/35 bg-accent-success/10 text-accent-success`:`border-border/60 bg-surface/60 text-foreground/65`),children:[(0,Q.jsx)(Pn,{className:`h-3 w-3`}),t(`prCard.deliveryCommit`,{sha:D.deliverySha.slice(0,8)})]})]}),fe,D.operation&&(0,Q.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-[11px] font-medium text-accent-info`,"data-testid":`agent-pr-operation`,children:[(0,Q.jsx)(ut,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),t(`prCard.operation.${D.operation}`)]}),V&&(0,Q.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-info`,"data-testid":`agent-pr-recovery-interrupted`,children:[(0,Q.jsx)(Xr,{className:`mt-px h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t(`common:prRecovery.interrupted`)})]}),(0,Q.jsx)(Zz,{envelope:D}),G&&(0,Q.jsx)(`p`,{className:`mt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,"data-testid":`agent-pr-status-code`,children:G}),!te&&z.deliveryBlocked&&(0,Q.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,Q.jsx)(vt,{className:`mt-px h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[z.recoveryUnavailable?t(`prCard.recoveryUnavailableBody`):t(z.partial?`prCard.partialDeliveryBlockedNote`:`prCard.deliveryBlockedNote`),D.statusDetail&&!B&&!z.recoveryUnavailable?(0,Q.jsx)(`span`,{className:`mt-0.5 block text-foreground/50`,children:D.statusDetail}):null]})]}),!te&&z.recoveryUnavailable&&D.statusDetail&&!B&&(0,Q.jsxs)(`details`,{className:`mt-1.5 text-[10px] leading-4 text-foreground/55`,"data-testid":`agent-pr-recovery-technical-detail`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground/65`,children:t(`prCard.recoveryDetailSummary`)}),(0,Q.jsx)(`p`,{className:`mt-1 break-words`,children:D.statusDetail})]}),!te&&z.retryablePush&&(0,Q.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,Q.jsx)(vt,{className:`mt-px h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[t(`prCard.retryPushNote`),D.statusDetail&&!B?(0,Q.jsx)(`span`,{className:`mt-0.5 block text-foreground/50`,children:D.statusDetail}):null]})]}),D.statusDetail&&!B&&!z.deliveryBlocked&&!z.retryablePush&&(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/45`,"data-testid":`agent-pr-status-detail`,children:D.statusDetail}),!te&&!F&&(L===`pushed`||L===`local-only`)&&(0,Q.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,Q.jsx)(vt,{className:`mt-px h-3 w-3 shrink-0`}),t(L===`local-only`?`prCard.degraded.localOnly`:`prCard.degraded.pushed`)]}),z.cleanupWarnings.length>0&&(0,Q.jsxs)(`div`,{className:`mt-2 rounded-md border border-accent-warning/35 bg-accent-warning/10 px-2 py-1.5 text-[11px] text-accent-warning`,"data-testid":`agent-pr-cleanup-warning`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:t(`prCard.cleanupIncomplete`,{count:z.cleanupWarnings.length})}),(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4 text-foreground/60`,children:z.cleanupWarnings.map((e,t)=>(0,Q.jsx)(`li`,{children:e},`${t}-${e}`))})]}),z.safetyArchives.length>0&&(0,Q.jsxs)(`details`,{className:`mt-2 rounded-md border border-accent-info/25 bg-accent-info/5 px-2 py-1.5 text-[11px] text-foreground/65`,"data-agent-interactive":!0,"data-testid":`agent-pr-safety-archives`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer font-medium text-accent-info`,children:t(`prCard.safetyArchiveTitle`,{count:z.safetyArchives.length})}),(0,Q.jsx)(`p`,{className:`mt-1 leading-4`,children:t(`prCard.safetyArchiveHint`)}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[10px] text-foreground/50`,children:z.safetyArchives.map(e=>(0,Q.jsx)(`li`,{className:`break-all`,children:e},e))})]}),(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:`easeOut`},className:`mt-2.5`,children:[z.noChanges&&!te&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,Q.jsx)(Pn,{className:`h-3.5 w-3.5`}),z.continuation?t(`prCard.noChangesExisting`):t(`prCard.noChangesNote`)]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:z.continuation?je:(0,Q.jsxs)(Q.Fragment,{children:[Pe,Fe]})})]}),!te&&z.deliveryBlocked&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[Te,De,z.continuation?z.hasDiscardableRecoveryResult?Ne:je:Ae]}),!te&&z.retryablePush&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[we,Ce(`create-pr`,t(`prCard.retryPush`)),z.continuation?je:Ae]}),!te&&z.retryablePrCreation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Ce(`create-pr`,t(`prCard.retryPr`)),ke,z.continuation?je:Ae]}),!te&&z.closed&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[we,Ce(`reopen`,t(`prCard.reopen`)),z.continuation?je:Ae]}),!te&&K&&!z.deliveryBlocked&&!z.retryablePush&&!z.retryablePrCreation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Ce(`create-pr`,t(`prCard.createPartialPr`,{count:z.deliverableCount})),z.continuation?je:Ae]}),P===`on_review`&&!z.noChanges&&!z.partial&&!z.deliveryBlocked&&!z.retryablePush&&!z.retryablePrCreation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Ce(`create-pr`,t(`prCard.createPr`)),ke,z.continuation?je:Ae]}),P===`pr_draft`&&!U&&!z.deliveryBlocked&&!z.retryablePush&&!z.retryablePrCreation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[we,Ce(`publish`,t(`prCard.publish`)),z.continuation?je:Ae]}),U&&!K&&!z.deliveryBlocked&&!z.retryablePush&&!z.retryablePrCreation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Ce(`create-pr`,t(`prCard.retryPr`)),ke,z.continuation?je:Ae]}),P===`pr_ready`&&!z.deliveryBlocked&&!z.retryablePush&&!z.retryablePrCreation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[we,Ce(`poll-merge`,t(`prCard.verifyPr`)),z.continuation?je:Ae]}),P===`pr_failed`&&!z.deliveryBlocked&&!z.retryablePush&&!z.retryablePrCreation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[we,Ce(`create-pr`,t(`prCard.retry`)),!F&&ke,z.continuation?je:Ae]}),P===`implementation_failed`&&z.implementationFailed&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] leading-4 text-destructive`,children:[(0,Q.jsx)(vt,{className:`mt-px h-3 w-3 shrink-0`}),t(`prCard.implementationFailedNote`)]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:z.continuation?je:Ae})]}),P===`merged`&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,Q.jsx)(Pn,{className:`h-3.5 w-3.5`}),t(`prCard.mergedNote`)]}),P===`discarded`&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,Q.jsx)(ot,{className:`h-3.5 w-3.5`}),t(`prCard.discardedNote`)]}),P===`completed`&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,Q.jsx)(Pn,{className:`h-3.5 w-3.5`}),t(`prCard.completedNote`)]}),P===`superseded`&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,Q.jsx)(Oe,{className:`h-3.5 w-3.5`}),t(`prCard.supersededNote`)]})]},`${P}-${F??``}`),(0,Q.jsx)(nn,{open:_,onOpenChange:v,children:(0,Q.jsxs)(Zt,{className:`max-w-sm`,"data-testid":`agent-pr-merge-local-confirm`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:t(`prCard.confirm.mergeLocalTitle`)}),(0,Q.jsx)(en,{children:t(`prCard.confirm.mergeLocalBody`,{base:D.baseBranch})})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>v(!1),children:t(`common:actions.cancel`)}),(0,Q.jsx)(Y,{size:`sm`,disabled:be,"data-testid":`agent-pr-merge-local-confirm-btn`,onClick:()=>{v(!1),ie(`merge-local`)},children:t(`prCard.mergeLocal`)})]})]})}),(0,Q.jsx)(nn,{open:C,onOpenChange:w,children:(0,Q.jsxs)(Zt,{className:`max-w-sm`,"data-testid":`agent-pr-recover-and-retry-confirm`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:t(Ee?`prCard.confirm.recheckRecoveryTitle`:`prCard.confirm.recoverAndRetryTitle`)}),(0,Q.jsx)(en,{children:t(Ee?`prCard.confirm.recheckRecoveryBody`:`prCard.confirm.recoverAndRetryBody`,{branch:D.branch??``})})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>w(!1),children:t(`common:actions.cancel`)}),(0,Q.jsx)(Y,{size:`sm`,disabled:be,"data-testid":`agent-pr-recover-and-retry-confirm-btn`,onClick:()=>{w(!1),ie(`recover-and-retry`)},children:t(Ee?`prCard.recheckRecovery`:`prCard.recoverAndRetry`)})]})]})}),(0,Q.jsx)(nn,{open:d,onOpenChange:f,children:(0,Q.jsxs)(Zt,{className:`max-w-sm`,"data-testid":`agent-pr-discard-confirm`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:t(P===`implementation_failed`?`prCard.confirm.implementationFailedDiscardTitle`:`prCard.confirm.freshDiscardTitle`)}),(0,Q.jsx)(en,{children:t(P===`implementation_failed`?`prCard.confirm.implementationFailedDiscardBody`:`prCard.confirm.freshDiscardBody`)})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>f(!1),children:t(`common:actions.cancel`)}),(0,Q.jsx)(Y,{variant:`destructive`,size:`sm`,disabled:be,"data-testid":`agent-pr-discard-confirm-btn`,onClick:()=>{f(!1),ie(`discard`)},children:t(`prCard.discard`)})]})]})}),(0,Q.jsx)(nn,{open:p,onOpenChange:m,children:(0,Q.jsxs)(Zt,{className:`max-w-sm`,"data-testid":`agent-pr-dismiss-confirm`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:t(`prCard.confirm.dismissTitle`)}),(0,Q.jsx)(en,{children:t(`prCard.confirm.dismissBody`)})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>m(!1),children:t(`common:actions.cancel`)}),(0,Q.jsx)(Y,{size:`sm`,disabled:be,"data-testid":`agent-pr-dismiss-confirm-btn`,onClick:()=>{m(!1),ie(`dismiss`)},children:t(`prCard.dismiss`)})]})]})}),(0,Q.jsx)(nn,{open:h,onOpenChange:g,children:(0,Q.jsxs)(Zt,{className:`max-w-sm`,"data-testid":`agent-pr-discard-local-confirm`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:t(`prCard.confirm.discardLocalTitle`)}),(0,Q.jsx)(en,{children:t(`prCard.confirm.discardLocalBody`)})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>g(!1),children:t(`common:actions.cancel`)}),(0,Q.jsx)(Y,{variant:`destructive`,size:`sm`,disabled:be,"data-testid":`agent-pr-discard-local-confirm-btn`,onClick:()=>{g(!1),ie(`discard`)},children:t(`prCard.discardLocalResult`)})]})]})}),(0,Q.jsx)(nn,{open:y,onOpenChange:b,children:(0,Q.jsxs)(Zt,{className:`max-w-sm`,"data-testid":`agent-pr-no-changes-done-confirm`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:t(`prCard.confirm.noChangesDoneTitle`)}),(0,Q.jsx)(en,{children:t(`prCard.confirm.noChangesDoneBody`)})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>b(!1),children:t(`common:actions.cancel`)}),(0,Q.jsx)(Y,{size:`sm`,disabled:be,"data-testid":`agent-pr-no-changes-done-confirm-btn`,onClick:()=>{b(!1),ie(`acknowledge-no-changes`)},children:t(`prCard.markDone`)})]})]})}),(0,Q.jsx)(nn,{open:x,onOpenChange:S,children:(0,Q.jsxs)(Zt,{className:`max-w-sm`,"data-testid":`agent-pr-refine-confirm`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:t(`prCard.confirm.refineTitle`)}),(0,Q.jsx)(en,{children:t(`prCard.confirm.refineBody`)})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>S(!1),children:t(`common:actions.cancel`)}),(0,Q.jsx)(Y,{variant:`destructive`,size:`sm`,disabled:be,"data-testid":`agent-pr-refine-confirm-btn`,onClick:()=>{S(!1),ie(`discard`)},children:t(`prCard.refine`)})]})]})}),he]})}var tB={building:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,on_review:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,pr_draft:`border-accent-info/40 bg-accent-info/10 text-accent-info`,pr_ready:`border-accent-info/40 bg-accent-info/10 text-accent-info`,no_changes:`border-accent-success/40 bg-accent-success/10 text-accent-success`,completed:`border-accent-success/40 bg-accent-success/10 text-accent-success`,pr_closed:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,superseded:`border-border/60 bg-surface/60 text-foreground/40`,implementation_failed:`border-destructive/40 bg-destructive/10 text-destructive`,pr_failed:`border-destructive/40 bg-destructive/10 text-destructive`,merged:`border-accent-success/40 bg-accent-success/10 text-accent-success`,discarded:`border-border/60 bg-surface/60 text-foreground/50`};function nB({decision:e}){let{t}=I(`agent`);return(0,Q.jsx)(`span`,{"data-testid":`pr-decision-pill`,className:X(`inline-flex shrink-0 items-center rounded-full border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide`,tB[e]),children:t(`prCard.pinned.state.${e}`)})}var rB=e=>`specrails-desktop:agent-pr-dock-collapsed:${e}`,iB=e=>`specrails-desktop:agent-pr-dock-card-collapsed:${e}`;function aB(e){try{return sessionStorage.getItem(rB(e))===`1`}catch{return!1}}function oB(e,t){try{t?sessionStorage.setItem(rB(e),`1`):sessionStorage.removeItem(rB(e))}catch{}}function sB(e){try{let t=sessionStorage.getItem(iB(e)),n=t?JSON.parse(t):[];return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}}function cB(e,t){try{t.size===0?sessionStorage.removeItem(iB(e)):sessionStorage.setItem(iB(e),JSON.stringify([...t]))}catch{}}function lB({pinned:e,conversationId:t,inline:n}){let{t:r}=I(`agent`),[i,a]=(0,Z.useState)(()=>aB(t)),[o,s]=(0,Z.useState)(()=>sB(t));if((0,Z.useEffect)(()=>{a(aB(t)),s(sB(t))},[t]),e.length===0)return null;let c=e[e.length-1],l=e=>{oB(t,e),a(e)},u=e=>{s(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),cB(t,r),r})},d=e=>{let t=r(`prCard.rail`,{index:e.railIndex+1}),n=e.ticketIds.map(e=>`#${e}`).join(` `);return n?`${t} · ${n}`:t};return(0,Q.jsx)(ML.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:{duration:.2,ease:`easeOut`},"data-testid":`agent-pr-pinned-dock`,className:X(`shrink-0`,n?`px-4 pb-2`:`px-3 pb-2`),children:(0,Q.jsx)(`div`,{className:X(n&&`mx-auto w-full max-w-[680px]`),children:i?(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-expand`,"data-agent-interactive":!0,onClick:()=>l(!1),"aria-label":r(`prCard.pinned.expand`),title:r(`prCard.pinned.expand`),className:`flex w-full items-center gap-2 rounded-xl border border-border/60 bg-card/80 px-3 py-1.5 text-xs text-foreground/70 shadow-lg backdrop-blur-xl transition-colors hover:border-accent-primary/40 hover:bg-surface/60`,children:[(0,Q.jsx)(zr,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:r(`prCard.pinned.collapsed`,{count:e.length})}),(0,Q.jsx)(nB,{decision:c.envelope.decision}),(0,Q.jsx)(de,{className:`h-3.5 w-3.5 shrink-0 opacity-60`})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,Q.jsx)(zr,{className:`h-3 w-3 text-accent-primary/60`}),r(`prCard.pinned.label`),e.length>1&&(0,Q.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/60 px-1.5 py-px text-[9px] tabular-nums text-foreground/55`,children:e.length})]}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`agent-pr-dock-collapse`,"data-agent-interactive":!0,onClick:()=>l(!0),"aria-label":r(`prCard.pinned.collapse`),title:r(`prCard.pinned.collapse`),className:`rounded p-0.5 text-foreground/45 transition-colors hover:bg-surface hover:text-foreground`,children:(0,Q.jsx)(pe,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{"data-testid":`agent-pr-dock-stack`,className:`max-h-[45vh] space-y-1.5 overflow-y-auto overscroll-contain`,children:e.map(e=>{let t=e.envelope.prDeliveryId,n=o.has(t);return(0,Q.jsxs)(`div`,{"data-testid":`agent-pr-dock-card`,className:`space-y-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-card-toggle`,"data-agent-interactive":!0,onClick:()=>u(t),"aria-expanded":!n,"aria-label":r(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),title:r(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),className:X(`flex w-full items-center gap-2 rounded-lg border px-2.5 py-1 text-[11px] text-foreground/70 transition-colors`,n?`border-border/60 bg-card/80 shadow backdrop-blur-xl hover:border-accent-primary/40 hover:bg-surface/70`:`border-transparent bg-transparent hover:bg-surface/50`),children:[(0,Q.jsx)(Oe,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium`,children:d(e.envelope)}),(0,Q.jsx)(nB,{decision:e.envelope.decision}),n?(0,Q.jsx)(de,{className:`h-3 w-3 shrink-0 opacity-60`}):(0,Q.jsx)(pe,{className:`h-3 w-3 shrink-0 opacity-60`})]}),!n&&(0,Q.jsx)(eB,{envelope:e.envelope})]},e.messageId)})})]})})})}function uB(e){return e?e.charAt(0).toUpperCase()+e.slice(1):`Unknown`}function dB(e,t,n,r){let i=e.title?.trim()||`Untitled mission`,a=r?.exportedAt??new Date().toISOString(),o=[`Mission: ${i}`,`Mission ID: ${e.id}`];return n?.name&&o.push(`Project: ${n.name}`),n?.path&&o.push(`Project path: ${n.path}`),o.push(`Exported at: ${a}`,``,`Messages:`),t.length===0?(o.push(`No messages loaded.`),o.join(`
|
|
62
62
|
`)):(t.forEach((e,t)=>{t>0&&o.push(``),o.push(`[${e.created_at}] ${uB(e.role)}`,e.content)}),o.join(`
|
|
63
|
-
`))}function fB(e,t){let n=(e??``).normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),r=t.trim()||`mission`;return`${n||r}.txt`}function pB(){let{t:e}=I(`agent`),{active:t,messages:n,renameConversation:r,deleteConversation:i,startNewConversation:a,favoriteConversationIds:o,toggleFavoriteConversation:s}=UV(),{projects:c}=At(),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=t?.pinned_project_id?c.find(e=>e.id===t.pinned_project_id)??null:null,S=t?.title?.trim()||e(`header.untitled`),C=t?o.has(t.id):!1;(0,Z.useEffect)(()=>{if(!l)return;let e=e=>{y.current&&!y.current.contains(e.target)&&u(!1)},t=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]),(0,Z.useEffect)(()=>{l||v(!1)},[l]),(0,Z.useEffect)(()=>{d&&(b.current?.focus(),b.current?.select())},[d]);let w=(0,Z.useCallback)(()=>{m(t?.title??``),f(!0),u(!1)},[t?.title]),T=(0,Z.useCallback)(async()=>{if(t&&(f(!1),(t.title??``)!==p.trim()))try{await r(t.id,p)}catch{R.error(e(`header.renameFailed`))}},[t,p,r,e]),E=(0,Z.useCallback)(async(t,n)=>{u(!1);try{await navigator.clipboard.writeText(t),g(n),setTimeout(()=>g(e=>e===n?null:e),1400)}catch{R.error(e(`header.copyFailed`))}},[e]),D=(0,Z.useCallback)(async()=>{if(t){u(!1);try{await navigator.clipboard.writeText(dB(t,n,x)),g(`transcript`),R.success(e(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>g(e=>e===`transcript`?null:e),1400)}catch{R.error(e(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[t,n,x,e]),O=(0,Z.useCallback)(()=>{if(t){u(!1);try{let r=dB(t,n,x),i=new Blob([r],{type:`text/plain;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=fB(t.title,t.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),R.success(e(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{R.error(e(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[t,n,x,e]),k=(0,Z.useCallback)(async()=>{if(t){u(!1),v(!1);try{await i(t.id),a(t.pinned_project_id)}catch{R.error(e(`header.deleteFailed`))}}},[t,i,a,e]),A=(0,Z.useCallback)(()=>{t&&(s(t.id),u(!1))},[t,s]);if(!t)return null;let j=[{id:`name`,label:e(`header.copyName`),value:t.title??S},{id:`id`,label:e(`header.copyId`),value:t.id},...x?[{id:`project`,label:e(`header.copyProject`),value:x.name},{id:`path`,label:e(`header.copyProjectPath`),value:x.path}]:[]];return(0,Q.jsxs)(`div`,{ref:y,"data-agent-interactive":!0,className:`relative flex h-12 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm`,children:[x&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:x.path,children:x.path}),(0,Q.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),d?(0,Q.jsx)(`input`,{ref:b,value:p,onChange:e=>m(e.target.value),onBlur:()=>void T(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),T()):e.key===`Escape`&&(e.preventDefault(),f(!1))},placeholder:e(`header.renamePlaceholder`),className:`min-w-0 flex-1 rounded-md border border-accent-primary/40 bg-surface/60 px-2 py-0.5 text-sm text-foreground outline-none focus:border-accent-primary/70`,maxLength:200}):(0,Q.jsx)(`button`,{type:`button`,onDoubleClick:w,title:e(`header.renameHint`),className:`min-w-0 flex-1 truncate text-left font-medium text-foreground/85`,children:S})]}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-menu-trigger`,"aria-label":e(`header.menu`),"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(e=>!e),className:X(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground/45 transition-colors hover:bg-surface hover:text-foreground/80`,l&&`bg-surface text-foreground/80`),children:(0,Q.jsx)(Yn,{className:`h-4 w-4`})}),(0,Q.jsx)(MF,{children:l&&(0,Q.jsx)(ML.div,{role:`menu`,"data-testid":`agent-conv-menu`,initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.14,ease:`easeOut`},className:`absolute right-3 top-11 z-50 min-w-[220px] overflow-hidden rounded-xl border border-border/50 bg-card/95 p-1 shadow-2xl backdrop-blur-xl`,children:_?(0,Q.jsxs)(`div`,{className:`p-2`,"data-testid":`agent-conv-delete-confirm`,children:[(0,Q.jsx)(`p`,{className:`px-1 pb-2.5 text-xs leading-relaxed text-foreground/70`,children:e(`header.deleteConfirm`)}),(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-delete-confirm-btn`,onClick:()=>void k(),className:`flex-1 rounded-lg bg-destructive/90 px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-destructive`,children:e(`header.delete`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`flex-1 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs text-foreground/80 transition-colors hover:bg-surface/80`,children:e(`common:actions.cancel`)})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-rename`,onClick:w,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Q.jsx)(dt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),e(`header.rename`)]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-favorite`,onClick:A,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Q.jsx)(pr,{className:X(`h-3.5 w-3.5 shrink-0`,C?`text-accent-primary`:`text-foreground/50`),fill:C?`currentColor`:`none`}),e(C?`header.removeFavorite`:`header.addFavorite`)]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-delete`,onClick:()=>v(!0),className:`group/del flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-destructive/10 hover:text-destructive`,children:[(0,Q.jsx)(_t,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),e(`header.delete`)]}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border/50`}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-transcript`,onClick:()=>void D(),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===`transcript`?(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,Q.jsx)(Un,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-export-transcript`,onClick:O,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Q.jsx)(st,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.exportTranscript`,{defaultValue:`Export transcript (.txt)`})})]}),j.map(e=>e===`divider`?null:(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-${e.id}`,onClick:()=>void E(e.value,e.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===e.id?(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,Q.jsx)(Un,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]},e.id))]})})})]})}var mB=new Set([`building`,`on_review`,`pr_draft`,`no_changes`,`pr_closed`,`implementation_failed`,`pr_failed`]);function hB(e){return mB.has(e)}function gB(e){let t=[];for(let[n,r]of e.entries()){if(r.role!==`system`)continue;let e=ME(r.content);e&&t.push({messageId:r.id,envelope:e,position:n})}let n=new Map;for(let e of t){let t=n.get(e.envelope.prDeliveryId);if(!t){n.set(e.envelope.prDeliveryId,e);continue}let r=bv(t.envelope.updatedAt,e.envelope.updatedAt);(r===1||r===null&&e.position>t.position)&&n.set(e.envelope.prDeliveryId,e)}let r=new Set(t.map(({envelope:e})=>e.supersedesDeliveryId).filter(e=>!!e)),i=new Set,a=[...n.values()];for(let e of a){let t=e.envelope.restoredFromDeliveryId;if(!t)continue;let n=null;for(let t of a){if(t.envelope.supersedesDeliveryId!==e.envelope.prDeliveryId)continue;if(!n){n=t;continue}let r=bv(n.envelope.createdAt,t.envelope.createdAt);(r===1||(r===0||r===null)&&t.position>n.position)&&(n=t)}n&&n.envelope.prDeliveryId!==t||(r.delete(e.envelope.prDeliveryId),r.add(t),i.add(t))}let o=new Map;for(let e of n.values()){if(r.has(e.envelope.prDeliveryId))continue;let t=o.get(e.envelope.railIndex)??[];t.push(e),o.set(e.envelope.railIndex,t)}for(let e of o.values()){if(e.length<=1)continue;let t=e[0];for(let n of e.slice(1))bv(t.envelope.createdAt,n.envelope.createdAt)===1&&(t=n);for(let n of e)n.envelope.prDeliveryId!==t.envelope.prDeliveryId&&r.add(n.envelope.prDeliveryId)}let s=t.map(e=>r.has(e.envelope.prDeliveryId)&&(e.envelope.decision!==`superseded`||i.has(e.envelope.prDeliveryId))?{...e,envelope:{...e.envelope,decision:i.has(e.envelope.prDeliveryId)?`discarded`:`superseded`}}:e),c=new Map,l=new Set,u=[];for(let e of s){if(n.get(e.envelope.prDeliveryId)?.messageId!==e.messageId){l.add(e.messageId);continue}c.set(e.messageId,e.envelope),hB(e.envelope.decision)&&u.push(e)}return{byMessageId:c,duplicateMessageIds:l,pinned:u}}var _B=(0,Z.lazy)(()=>c(()=>import(`./JobDetailModal-BFNXOhk1.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75]))),vB=(0,Z.lazy)(()=>c(()=>import(`./LoopPreviewModal-EdkyYaGN.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([76,1,2,3,40,5,6,45,56,64,65,66,67,77,52,54,57,68,42]))),yB=new Set;function bB({variant:e}){let{t}=I(`agent`),{active:n,messages:r,streamingText:i,isStreaming:a,liveTools:o,queuedMessages:s,mcpEnabled:c,enablingMcp:l,enableMcpServer:u,providersReady:d,cycleTier:f,send:p}=UV(),m=(0,Z.useRef)(null),h=Hg(i,a),{openRef:g,jobRef:_,closeJobRef:v,loopRef:y,closeLoopRef:b}=FL(),x=n?.pinned_project_id??null,[S,C]=(0,Z.useState)(new Map),w=(0,Z.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.attachment_ids??[])e.add(n);return[...e].sort()},[r]).join(`\0`);(0,Z.useEffect)(()=>{let e=w?w.split(`\0`):[];if(!n?.id||e.length===0){C(new Map);return}let t=!1,r=new Set(e);return CE(n.id).then(e=>{t||C(new Map(e.filter(e=>r.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||C(new Map)}),()=>{t=!0}},[n?.id,w]);let T=(0,Z.useMemo)(()=>x?e=>{g(x,e)}:void 0,[x,g]),E=kb().id===`code-rain`?t(`emptyTitleCodeRain`):t(`emptyTitle`),D=(0,Z.useMemo)(()=>gB(r),[r]),O=(0,Z.useRef)(!0),k=()=>{let e=m.current;e&&(O.current=e.scrollHeight-e.scrollTop-e.clientHeight<48)};(0,Z.useEffect)(()=>{O.current&&m.current?.scrollTo?.({top:m.current.scrollHeight,behavior:`auto`})},[r.length,h,o.length,s.length]);let A=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),f())},j=e===`inline`,M=j?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden `,onKeyDown:A,children:[d===!1&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,Q.jsx)(Mr,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-warning`}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:t(`noProvider.title`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:t(`noProvider.body`)})]})]}),d!==!1&&!c&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,Q.jsx)(ri,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:t(`degraded.body`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void u(),disabled:l,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:t(l?`degraded.enabling`:`degraded.enable`)})]}),j&&n&&(0,Q.jsx)(pB,{}),(0,Q.jsxs)(`div`,{className:M,children:[(0,Q.jsxs)(ML.div,{ref:m,onScroll:k,initial:j?{opacity:0,y:8}:!1,animate:{opacity:1,y:0},transition:{duration:.35,ease:`easeOut`},className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[r.length===0&&!a&&(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,Q.jsx)(wn,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:E}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:t(`emptyHint`)})]}),r.map((e,n)=>{if(e.role===`system`){let n=D.byMessageId.get(e.id);return n?hB(n.decision)?(0,Q.jsxs)(`div`,{"data-testid":`agent-pr-pinned-marker`,className:`flex items-center gap-2 rounded-lg border border-border/40 bg-surface/30 px-3 py-1.5 text-[11px] text-foreground/45 backdrop-blur-sm`,children:[(0,Q.jsx)(zr,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(`prCard.pinned.marker`)}),(0,Q.jsx)(nB,{decision:n.decision})]},e.id):(0,Q.jsx)(eB,{envelope:n},e.id):(D.duplicateMessageIds.has(e.id)||yB.has(e.id)||(yB.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}return(0,Q.jsx)(FR,{role:e.role,content:e.content,createdAt:e.created_at,isLast:!a&&n===r.length-1,onPickOption:e=>void p(e),refsProjectId:x,onOpenRef:T,contextRefs:e.context_refs,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>S.get(e)).filter(e=>!!e)},e.id)}),a&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,Q.jsx)(FR,{role:`assistant`,content:h,streaming:!0}),(0,Q.jsx)(RL,{tool:o.length?o[o.length-1].tool:null})]}),s.length>0&&(0,Q.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:s.map(e=>(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-br-sm border border-dashed border-border/70 bg-foreground/[0.03] px-3.5 py-2 text-sm text-foreground/60`,children:[(0,Q.jsxs)(`span`,{className:`mb-0.5 flex items-center justify-end gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,Q.jsx)(Ln,{className:`h-3 w-3`}),t(`queue.queued`)]}),(0,Q.jsx)(PR,{content:e.text,contextRefs:e.contextRefs})]})},e.queueId))})]}),(0,Q.jsx)(MF,{initial:!1,children:n&&D.pinned.length>0&&(0,Q.jsx)(lB,{pinned:D.pinned,conversationId:n.id,inline:j},`agent-pr-pinned-dock`)}),j?(0,Q.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,Q.jsx)(ML.div,{layoutId:`agent-composer-dock`,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`mx-auto w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`,children:(0,Q.jsx)(Rz,{})})}):(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-surface/30 p-3`,children:(0,Q.jsx)(Rz,{hideProjectSelector:!0})})]}),_&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(_B,{jobId:_.jobId,projectId:_.projectId,onClose:v})}),y&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(vB,{loop:y,onClose:b})})]})}var xB=8,SB=3e3;function CB(){let{t:e}=I(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=UV(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useMemo)(()=>{let e=e=>{let t=Date.parse(e.updated_at);return Number.isNaN(t)?0:t};return[...t].sort((t,n)=>e(n)-e(t))},[t]),b=t.length>xB,x=(0,Z.useMemo)(()=>{let t=u.trim().toLowerCase();if(!t)return y;let n=e(`mission.untitled`).toLowerCase();return y.filter(e=>(e.title?.trim().toLowerCase()||n).includes(t))},[y,u,e]),S=x.length+1,C=(0,Z.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=null,h(null)},[]);(0,Z.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]),(0,Z.useEffect)(()=>{if(!c)return;let e=e=>{_.current&&!_.current.contains(e.target)&&T()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let w=()=>{let e=n?y.findIndex(e=>e.id===n.id):-1;p(e>=0?e+1:0),l(!0)},T=()=>{l(!1),d(``),C()},E=e=>{e!==n?.id&&r(e),T()},D=()=>{a(null),T()},O=e=>{g.current&&clearTimeout(g.current),h(e),g.current=setTimeout(()=>{h(null),g.current=null},SB)},k=async t=>{C();let a=n?.id===t,o=y.find(e=>e.id!==t)??null;try{await i(t),a&&o&&await r(o.id)}catch{R.error(e(`mission.deleteFailed`))}},A=()=>{if(f===0)D();else{let e=x[f-1];e&&E(e.id)}},j=e=>{if(!c){e.key===`ArrowDown`&&(e.preventDefault(),w());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p(e=>(e+t+S)%S)}else e.key===`Home`?(e.preventDefault(),p(0)):e.key===`End`?(e.preventDefault(),p(S-1)):e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m?C():(T(),v.current?.focus()))},M=n?.title?.trim()||e(`mission.untitled`);return(0,Q.jsxs)(`div`,{className:`relative min-w-0`,ref:_,"data-agent-interactive":!0,onKeyDown:j,children:[(0,Q.jsxs)(`button`,{ref:v,type:`button`,"data-testid":`mission-trigger`,onClick:()=>c?T():w(),"aria-haspopup":`listbox`,"aria-expanded":c,"aria-controls":`agent-mission-listbox`,title:e(`mission.label`),className:`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground hover:bg-surface/70`,children:[(0,Q.jsx)(_e,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:M}),(0,Q.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,Q.jsx)(MF,{children:c&&(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[b&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Q.jsx)(ht,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>{d(e.target.value),p(0)},placeholder:e(`mission.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Q.jsxs)(`div`,{id:`agent-mission-listbox`,role:`listbox`,"aria-label":e(`mission.label`),"aria-activedescendant":`agent-mission-opt-${f}`,className:`max-h-72 overflow-y-auto py-1`,children:[(0,Q.jsxs)(ML.div,{id:`agent-mission-opt-0`,role:`option`,"aria-selected":!1,tabIndex:-1,"data-testid":`mission-new`,onClick:D,onMouseEnter:()=>p(0),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14},className:`flex w-full cursor-pointer items-center gap-2.5 px-3 py-1.5 text-left text-sm font-medium text-foreground ${f===0?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,Q.jsx)(pt,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),x.length>0&&(0,Q.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),x.length===0&&u.trim()!==``&&(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),x.map((e,t)=>(0,Q.jsx)(wB,{conversation:e,index:t+1,highlighted:f===t+1,activeId:n?.id??null,streaming:o.has(e.id),queuedCount:s.get(e.id)?.queued.length??0,confirming:m===e.id,onHover:()=>p(t+1),onSelect:()=>E(e.id),onArmDelete:()=>O(e.id),onConfirmDelete:()=>void k(e.id),onCancelDelete:C},e.id))]})]})})]})}function wB({conversation:e,index:t,highlighted:n,activeId:r,streaming:i,queuedCount:a,confirming:o,onHover:s,onSelect:c,onArmDelete:l,onConfirmDelete:u,onCancelDelete:d}){let{t:f}=I(`agent`),p=e.title?.trim()||f(`mission.untitled`),m=e.id===r;return o?(0,Q.jsxs)(`div`,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,"data-testid":`mission-row-${e.id}`,className:`flex w-full items-center gap-2 bg-destructive/10 px-3 py-1.5 text-sm`,children:[(0,Q.jsx)(_t,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-destructive`,children:f(i?`mission.deleteLiveConfirm`:`mission.deleteConfirm`)}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-yes`,onClick:e=>{e.stopPropagation(),u()},"aria-label":f(`mission.confirmDelete`),className:`rounded-md p-1 text-destructive hover:bg-destructive/20`,children:(0,Q.jsx)(be,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-no`,onClick:e=>{e.stopPropagation(),d()},"aria-label":f(`mission.cancelDelete`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface`,children:(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`})})]}):(0,Q.jsxs)(ML.div,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,tabIndex:-1,"data-testid":`mission-row-${e.id}`,onClick:c,onMouseEnter:s,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.03,.18)},className:`group flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-sm text-foreground ${n?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-foreground/40`,title:nE(e.updated_at),children:tE(e.updated_at)}),i&&(0,Q.jsxs)(`span`,{"data-testid":`mission-live-${e.id}`,"aria-label":f(`mission.working`),className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,Q.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,Q.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),a>0&&(0,Q.jsx)(`span`,{"data-testid":`mission-queued-${e.id}`,"aria-label":f(`mission.queuedBadge`,{n:a}),title:f(`mission.queuedBadge`,{n:a}),className:`shrink-0 rounded-full border border-border/60 bg-surface px-1.5 text-[9px] font-semibold leading-4 text-foreground/60`,children:a}),m&&(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`mission-delete-${e.id}`,onClick:e=>{e.stopPropagation(),l()},"aria-label":f(`mission.delete`,{title:p}),className:`shrink-0 rounded-md p-0.5 text-foreground/50 opacity-0 transition-opacity hover:bg-surface hover:text-destructive focus-visible:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100`,children:(0,Q.jsx)(_t,{className:`h-3.5 w-3.5`})})]})}function TB({active:e,inset:t=-4,radius:n=`9999px`,className:r}){let i=jL();return(0,Q.jsx)(MF,{children:e&&(0,Q.jsxs)(ML.span,{"aria-hidden":!0,"data-testid":`builder-halo`,"data-reduced-motion":i?`true`:void 0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.15},transition:{duration:.35,ease:`easeOut`},style:{inset:t},className:`pointer-events-none absolute ${r??``}`,children:[(0,Q.jsx)(`span`,{className:`absolute inset-0 overflow-hidden`,style:{borderRadius:n,padding:`2px`,WebkitMask:`linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)`,WebkitMaskComposite:`xor`,maskComposite:`exclude`},children:(0,Q.jsx)(`span`,{className:`absolute left-1/2 top-1/2 aspect-square w-[250%] -translate-x-1/2 -translate-y-1/2 ${i?``:`animate-[builder-halo-spin_2.6s_linear_infinite]`}`,style:{background:`conic-gradient(from 0deg, transparent 0%, color-mix(in srgb, var(--color-accent-primary) 90%, transparent) 18%, color-mix(in srgb, var(--color-accent-highlight) 85%, transparent) 32%, transparent 55%)`}})}),(0,Q.jsx)(`span`,{className:`absolute inset-0 opacity-60`,style:{borderRadius:n,boxShadow:`0 0 12px 2px color-mix(in srgb, var(--color-accent-primary) 45%, transparent), inset 0 0 8px 1px color-mix(in srgb, var(--color-accent-highlight) 30%, transparent)`}})]})})}var EB=/```blueprint-draft\s*\n([\s\S]*?)\n\s*```/g,DB=/```blueprint-draft(?![\s\S]*?\n\s*```)/,OB=new Set([`planned`,`committed`,`done`]),kB=new Set([`scaffold`,`feature`,`verification`]),AB=new Set([`critical`,`high`,`medium`,`low`]);function jB(e){return typeof e==`string`?e:``}function MB(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function NB(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{name:jB(t.name),pitch:jB(t.pitch),audience:jB(t.audience)}}function PB(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={language:jB(t.language),framework:jB(t.framework),db:jB(t.db)};return typeof t.notes==`string`&&t.notes!==``&&(n.notes=t.notes),n}function FB(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=jB(e.id),i=jB(e.title);if(r===``&&i===``)continue;let a={id:r,title:i,goal:jB(e.goal),status:OB.has(e.status)?e.status:`planned`,plannedSpecs:MB(e.plannedSpecs)};if(Array.isArray(e.ticketIds)){let t=e.ticketIds.filter(e=>typeof e==`number`&&Number.isInteger(e));t.length>0&&(a.ticketIds=t)}t.push(a)}return t}function IB(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=jB(e.title);if(r===``)continue;let i={kind:kB.has(e.kind)?e.kind:`feature`,title:r,shortSummary:jB(e.shortSummary),description:jB(e.description),acceptanceCriteria:MB(e.acceptanceCriteria),priority:AB.has(e.priority)?e.priority:`medium`,labels:MB(e.labels)};typeof e.dependsOnIndex==`number`&&Number.isInteger(e.dependsOnIndex)&&e.dependsOnIndex>=0&&(i.dependsOnIndex=e.dependsOnIndex),t.push(i)}return t}function LB(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.blueprintVersion!=`number`||!Number.isInteger(t.blueprintVersion)?null:{blueprintVersion:t.blueprintVersion,product:NB(t.product),coreFlow:jB(t.coreFlow),platform:jB(t.platform),stack:PB(t.stack),assumptions:MB(t.assumptions),milestones:FB(t.milestones),specsComplete:t.specsComplete===!0,m1Specs:IB(t.m1Specs)}}function RB(e){if(!e||!e.includes("```blueprint-draft"))return{stripped:e??``,blueprint:null,rawBlueprint:null,hadBlocks:!1};let t=null,n=null,r=!1,i=``,a=0;EB.lastIndex=0;let o;for(;(o=EB.exec(e))!==null;){r=!0,i+=e.slice(a,o.index),a=o.index+o[0].length;try{let e=JSON.parse(o[1]),r=LB(e);r&&(t=r,n=e)}catch{}}return i+=e.slice(a),{stripped:i,blueprint:t,rawBlueprint:n,hadBlocks:r}}function zB(e){if(!e||!e.includes("```blueprint-draft"))return e??``;let t=DB.exec(e);return t?e.slice(0,t.index):e}function BB(e){return e?{product:e.product.name!==``&&e.product.pitch!==``,coreFlow:e.coreFlow!==``,platform:e.platform!==``,stack:e.stack.language!==``||e.stack.framework!==``,milestones:e.milestones.length>0}:{product:!1,coreFlow:!1,platform:!1,stack:!1,milestones:!1}}var VB={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`}};function HB(e){return e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`project`}function UB({blueprint:e,onSubmit:t,onBack:n,submitting:r,error:i,errorDetail:a}){let{t:o}=I(`builder`),{status:s}=sT(),[c,l]=(0,Z.useState)(e.product.name||``),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(new Set([`claude`])),[g,_]=(0,Z.useState)({claude:!0}),[v,y]=(0,Z.useState)(!1),b=(0,Z.useMemo)(()=>`~/projects/${HB(c)}`,[c]),x=u?f:b;(0,Z.useEffect)(()=>{fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n!==`tiers`&&(t[n]=!!r);_(t);let n=new Set;for(let[e,r]of Object.entries(t))r&&n.add(e);n.size>0&&h(n)}).catch(()=>{})},[]);let S=s?.prerequisites.find(e=>e.key===`gh`),C=!!(S?.installed&&S?.executable!==!1),w=C&&!!S?.authenticated,T=[`claude`,`codex`,`gemini`,...Object.keys(g)].filter((e,t,n)=>n.indexOf(e)===t).filter(e=>m.has(e)&&g[e]),E=c.trim()!==``&&x.trim()!==``&&T.length>0&&!r;return(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col gap-4 p-6`,"data-testid":`commit-form`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:o(`commit.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`commit.description`)})]}),i&&(0,Q.jsxs)(`div`,{className:`rounded-md bg-destructive/10 p-2 text-xs text-destructive`,"data-testid":`commit-error`,children:[(0,Q.jsx)(`p`,{children:o(`commit.errors.${i}`,{defaultValue:o(`commit.errors.generic`)})}),a&&(0,Q.jsx)(`p`,{className:`mt-1 opacity-80`,children:a})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.nameLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsx)(ox,{value:c,onChange:e=>l(e.target.value),"data-testid":`commit-name`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.locationLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsx)(ox,{value:x,onChange:e=>{d(!0),p(e.target.value)},"data-testid":`commit-location`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:o(`commit.locationHint`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:o(`commit.providersLabel`)}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:Object.keys(g).map(e=>{let{icon:t,label:n}=VB[e]??{icon:`•`,label:e},r=g[e],i=m.has(e)&&r;return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":i,disabled:!r,"data-testid":`commit-provider-${e}`,onClick:()=>{h(t=>{let n=new Set(t);if(n.has(e)){if(n.size===1)return t;n.delete(e)}else n.add(e);return n})},className:X(`flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors`,i?`border-accent-primary/60 bg-accent-primary/10`:`border-border/30 text-muted-foreground`,!r&&`cursor-not-allowed opacity-40`),children:[(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n})]},e)})})]}),C&&(0,Q.jsxs)(`label`,{className:X(`flex items-center gap-2 rounded-md border border-border/30 px-3 py-2 text-xs`,!w&&`opacity-50`),children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:v&&w,disabled:!w,onChange:e=>y(e.target.checked),"data-testid":`commit-github`}),(0,Q.jsx)(cr,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:o(`commit.githubLabel`)}),!w&&(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:o(`commit.githubAuthHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between pt-2`,children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:n,disabled:r,children:o(`commit.back`)}),(0,Q.jsxs)(Y,{size:`sm`,disabled:!E,"data-testid":`commit-submit`,onClick:()=>t({name:c.trim(),location:x.trim(),providers:T,createGithubRepo:v&&w}),children:[(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),o(r?`commit.creating`:`commit.submit`)]})]})]})}var WB=[`claude`,`codex`,`gemini`];function GB({session:e,autoFocus:t=!1}){let{t:n}=I(`builder`),{t:r}=I(`agent`),i=()=>{!e.draft.trim()||e.busy||!e.conversationReady||(e.send(e.draft),e.setDraft(``))};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,Q.jsx)(dr,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:n(`mode.title`)})]}),(0,Q.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(hz,{label:r(`provider.label`),value:e.provider,options:WB.map(e=>({value:e,label:r(`provider.${e}`)})),icon:wn,onSelect:e.setProvider,disabled:e.busy||!e.conversationReady,testId:`builder-provider-selector`}),(0,Q.jsx)(bz,{models:e.models,model:e.model,onSelect:e.setModel,disabled:e.busy||!e.conversationReady,testId:`builder-model-selector`}),e.efforts.length>0&&(0,Q.jsx)(hz,{label:r(`effort.label`),value:e.effort,options:e.efforts.map(e=>({value:e,label:r(`effort.${e}`)})),icon:ar,onSelect:e.setEffort,disabled:e.busy||!e.conversationReady,testId:`builder-effort-selector`}),e.showSurpriseMe&&(0,Q.jsxs)(`button`,{type:`button`,onClick:e.surpriseMe,disabled:e.busy||!e.conversationReady,className:`ml-auto inline-flex items-center gap-1.5 rounded-full border border-accent-highlight/40 bg-accent-highlight/10 px-3 py-1 text-[11px] text-accent-highlight transition-colors hover:bg-accent-highlight/20 disabled:opacity-40`,"data-testid":`surprise-me`,children:[(0,Q.jsx)(gt,{className:`h-3 w-3`}),n(`shell.surpriseMe`)]})]}),(0,Q.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border border-border/60 bg-background/60 px-3 py-2`,children:[(0,Q.jsx)(`textarea`,{value:e.draft,autoFocus:t,onChange:t=>e.setDraft(t.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),i())},rows:2,placeholder:n(`shell.inputPlaceholder`),"aria-label":n(`shell.inputPlaceholder`),"data-agent-interactive":!0,className:`min-h-[3.25rem] max-h-64 min-w-[12rem] flex-1 resize-y bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`,"data-testid":`builder-input`}),(0,Q.jsx)(`button`,{type:`button`,onClick:i,disabled:e.busy||!e.draft.trim()||!e.conversationReady,"aria-label":r(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,"data-testid":`builder-send`,children:(0,Q.jsx)($r,{className:`h-4 w-4`})})]})]})}function KB(e){return`M${e}`}function qB(e,t){let n=KB(t);return e.filter(e=>e.status===`todo`&&Array.isArray(e.labels)&&e.labels.includes(n)).map(e=>e.id)}async function JB(e,t,n=fetch){let r=`/api/projects/${e}`,i=await n(`${r}/tickets`,{cache:`no-store`});if(!i.ok)return{ok:!1,reason:`no-tickets`};let a=await i.json(),o=qB(Array.isArray(a)?a:a.tickets??[],t);if(o.length===0)return{ok:!1,reason:`no-tickets`};let s=await n(`${r}/rails`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:KB(t)})});if(!s.ok)return{ok:!1,reason:`rail-create-failed`,detail:(await s.json().catch(()=>({}))).error};let{rail:c}=await s.json(),l=await n(`${r}/rails/${c.railIndex}/tickets`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({ticketIds:o,mode:`batch-implement`})});if(!l.ok)return{ok:!1,reason:`assign-failed`,detail:(await l.json().catch(()=>({}))).error};let u=await n(`${r}/rails/${c.railIndex}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:`batch-implement`})});return u.ok?{ok:!0,railIndex:c.railIndex,ticketCount:o.length}:{ok:!1,reason:`launch-failed`,detail:(await u.json().catch(()=>({}))).error}}var YB=[`Problem Statement`,`Proposed Solution`,`Out of Scope`,`Technical Considerations`,`Estimated Complexity`],XB=new Set([`scaffold`,`feature`,`verification`]),ZB=new Set([`critical`,`high`,`medium`,`low`]),QB=/^(?:todo|tbd|n\/?a|works?|test(?: it)?|criterion|acceptance criterion)$/i;function $B(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function eV(e){return e.trim().toLocaleLowerCase(`en-US`)}function tV(e){let t=[...e.matchAll(/^##[ \t]+(.+?)[ \t]*$/gm)],n=t.map(e=>e[1].trim()),r=new Map;return t.forEach((i,a)=>{let o=(i.index??0)+i[0].length,s=a+1<t.length?t[a+1].index??e.length:e.length;r.set(n[a],e.slice(o,s).trim())}),{headings:n,bodies:r}}function nV(e){return e.split(/\r?\n/).filter(e=>/^\s*[-*+]\s+\S/.test(e)).length}function rV(e,t){let n=[],r=$B(e),i=Array.isArray(r?.m1Specs)?r.m1Specs:[],a=t.milestoneLabel.trim().toUpperCase(),o=(e,t,r,i)=>{n.push({specIndex:e,field:t,code:r,message:i})};r?.specsComplete!==!0&&o(null,`specsComplete`,`batch_incomplete`,`Generation is not complete yet.`),(i.length<t.minSpecs||i.length>t.maxSpecs)&&o(null,`m1Specs`,`spec_count`,`The batch needs ${t.minSpecs}-${t.maxSpecs} specs.`);let s=new Map;return i.forEach((e,n)=>{let r=$B(e),i=n+1;if(!r){o(n,`spec`,`invalid_shape`,`Spec ${i} must be an object.`);return}let c=typeof r.kind==`string`?r.kind:``;XB.has(c)||o(n,`kind`,`invalid_kind`,`Spec ${i} needs a valid kind.`),t.requireScaffold&&n===0&&c!==`scaffold`&&o(n,`kind`,`scaffold_first`,`The first spec must be the project scaffold.`),t.requireScaffold&&n>0&&c===`scaffold`&&o(n,`kind`,`duplicate_scaffold`,`Spec ${i} cannot be another scaffold.`);let l=typeof r.title==`string`?r.title.trim():``;if(!l)o(n,`title`,`required`,`Spec ${i} needs a title.`);else{let e=eV(l),t=s.get(e);t===void 0?s.set(e,n):o(n,`title`,`duplicate`,`Spec ${i} duplicates spec ${t+1}.`)}let u=typeof r.shortSummary==`string`?r.shortSummary.trim():``;(!u||u.length>240||/[\r\n]/.test(u))&&o(n,`shortSummary`,`summary`,`Spec ${i} needs a one-line summary under 240 characters.`);let d=typeof r.priority==`string`?r.priority:``;ZB.has(d)||o(n,`priority`,`invalid_priority`,`Spec ${i} needs a valid priority.`);let f=typeof r.description==`string`?r.description.trim():``,p=tV(f);(!/^## Problem Statement(?:\r?\n|$)/.test(f)||p.headings.length!==YB.length||p.headings.some((e,t)=>e!==YB[t]))&&o(n,`description`,`canonical_sections`,`Spec ${i} is missing the canonical sections.`);for(let e of YB)(p.bodies.get(e)??``).trim()||o(n,`description`,`empty_section`,`Spec ${i} has an empty ${e} section.`);for(let e of[`Out of Scope`,`Technical Considerations`]){let t=p.bodies.get(e)??``;t&&nV(t)<2&&o(n,`description`,`section_bullets`,`Spec ${i} needs two ${e} bullets.`)}let m=p.bodies.get(`Estimated Complexity`)??``;m&&!/^(?:Low|Medium|High|Very High)\s*(?:[—\-:]\s*)\S/i.test(m)&&o(n,`description`,`complexity_format`,`Spec ${i} needs a justified complexity.`),t.requireScaffold&&n===0&&f&&!/\bREADME\b/i.test(f)&&o(n,`description`,`scaffold_readme`,`The scaffold spec must mention the existing README.`);let h=Array.isArray(r.acceptanceCriteria)?r.acceptanceCriteria:[];(h.length<4||h.length>10)&&o(n,`acceptanceCriteria`,`criteria_count`,`Spec ${i} needs 4-10 acceptance criteria.`);let g=new Set;h.forEach((e,t)=>{let r=typeof e==`string`?e.trim():``;if(r.length<10||QB.test(r)){o(n,`acceptanceCriteria`,`criterion_quality`,`Spec ${i} criterion ${t+1} is not concrete.`);return}let a=eV(r);g.has(a)&&o(n,`acceptanceCriteria`,`duplicate_criterion`,`Spec ${i} repeats an acceptance criterion.`),g.add(a)});let _=Array.isArray(r.labels)?r.labels.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean):[];new Set(_.map(e=>e.toUpperCase())).has(a)||o(n,`labels`,`milestone_label`,`Spec ${i} needs the ${a} label.`),_.every(e=>e.toUpperCase()===a)&&o(n,`labels`,`domain_label`,`Spec ${i} needs a domain label.`);let v=r.dependsOnIndex;v!==void 0&&(!Number.isInteger(v)||v<0||v>=n)&&o(n,`dependsOnIndex`,`invalid_dependency`,`Spec ${i} must depend only on an earlier spec.`),t.requireScaffold&&n===0&&v!==void 0&&o(n,`dependsOnIndex`,`scaffold_dependency`,`The scaffold cannot declare a dependency.`)}),{valid:n.length===0,issues:n}}var iV=new Set([`gh_not_installed`,`gh_not_authenticated`,`gh_scope`,`gh_repo_exists`,`gh_network`]);function aV(e){return`progress.githubErrors.${e&&iV.has(e)?e:`generic`}`}var oV=[`create-dir`,`git-init`,`assemble`,`blueprint`,`tickets`,`register`,`github`];function sV(e,t){let{t:n}=I(`builder`),{registerHandler:r,unregisterHandler:i}=Et(),{setActiveProjectId:a}=At(),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(`chat`),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)([]),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(`claude`),[L,z]=(0,Z.useState)(null),[B,V]=(0,Z.useState)([]),[H,U]=(0,Z.useState)([]),[W,ee]=(0,Z.useState)(`medium`),[te,G]=(0,Z.useState)(``),K=(0,Z.useRef)(null),ne=(0,Z.useRef)(null),re=(0,Z.useRef)(!1),ie=(0,Z.useRef)(W),ae=(0,Z.useRef)(H),oe=(0,Z.useRef)(!1),se=(0,Z.useRef)(t.onFinished);(0,Z.useEffect)(()=>{K.current=o},[o]),(0,Z.useEffect)(()=>{ne.current=w},[w]),(0,Z.useEffect)(()=>{ie.current=W},[W]),(0,Z.useEffect)(()=>{ae.current=H},[H]),(0,Z.useEffect)(()=>{se.current=t.onFinished},[t.onFinished]),(0,Z.useEffect)(()=>{if(!e||o)return;let t=!1;return fetch(`/api/blueprint/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).then(e=>e.json()).then(e=>{!t&&e.conversation&&(s(e.conversation.id),e.conversation.provider&&F(e.conversation.provider),z(e.conversation.model??null))}).catch(()=>{t||R.error(n(`errors.startFailed`))}),()=>{t=!0}},[e,o,n]),(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return V([]),U([]),fetch(`/api/blueprint/models?provider=${encodeURIComponent(P)}`).then(e=>e.json()).then(e=>{if(t)return;V(e.models??[]);let n=e.efforts??[];U(n),ee(e=>n.includes(e)?e:n.includes(`medium`)?`medium`:n[0]??`medium`)}).catch(()=>{}),()=>{t=!0}},[e,P]);let ce=(0,Z.useCallback)(e=>{F(e),z(null);let t=K.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).catch(()=>{})},[]),le=(0,Z.useCallback)(e=>{z(e);let t=K.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:e})}).catch(()=>{})},[]);(0,Z.useEffect)(()=>{if(!e)return;let t=`builder-session`;return r(t,e=>{let t=e,r=K.current!==null&&t.conversationId===K.current,i=ne.current!==null&&t.commitId===ne.current;if(t.type===`blueprint.stream`&&r)d(e=>(e??``)+String(t.delta??``));else if(t.type===`blueprint.done`&&r){d(null),_(!1);let e=String(t.fullText??``);l(t=>[...t,{role:`assistant`,content:e,createdAt:new Date().toISOString()}]);let n=LB(t.blueprint);if(n)p(n),h(t.rawBlueprint===void 0?t.blueprint:t.rawBlueprint);else{let t=RB(e);t.blueprint&&(p(t.blueprint),h(t.rawBlueprint))}}else if(t.type===`blueprint.error`&&r)d(null),_(!1),R.error(n(`errors.turnFailed`),{description:String(t.error??``)});else if(t.type===`blueprint.commit_progress`&&i){let e=String(t.step),r=t.status,i=typeof t.detail==`string`?t.detail:void 0,a=typeof t.code==`string`?t.code:void 0;e===`github`&&r===`warning`&&!re.current&&(re.current=!0,R.warning(n(aV(a)),{description:i})),D(t=>[...t.filter(t=>t.step!==e),{step:e,status:r,detail:i,code:a}])}else t.type===`blueprint.commit_done`&&i?(k(String(t.projectId)),y(`done`)):t.type===`blueprint.commit_failed`&&i&&(oe.current=!1,N(!1),R.error(n(`errors.commitFailed`),{description:String(t.error??``)}),y(`commit`),x(`commit_failed`),C(String(t.error??``)))}),()=>i(t)},[e,r,i,n]);let q=(0,Z.useCallback)(e=>{let t=K.current,r=e.trim();if(!t||!r||g)return;l(e=>[...e,{role:`user`,content:r,createdAt:new Date().toISOString()}]),_(!0);let i=ie.current,a=ae.current.includes(i);fetch(`/api/blueprint/conversations/${t}/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:r,...a?{reasoning_effort:i}:{}})}).then(e=>{!e.ok&&e.status!==202&&(_(!1),R.error(n(`errors.turnFailed`)))}).catch(()=>{_(!1),R.error(n(`errors.turnFailed`))})},[g,n]),ue=(0,Z.useCallback)(()=>q(n(`prompts.surpriseMe`)),[q,n]),de=(0,Z.useCallback)(e=>{!f||oe.current||(oe.current=!0,N(!0),x(null),C(null),D([]),re.current=!1,fetch(`/api/blueprint/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({blueprint:m??f,...e})}).then(async e=>{let t=await e.json().catch(()=>({}));e.status===202&&t.commitId?(T(t.commitId),ne.current=t.commitId,y(`progress`)):(x(t.error??`generic`),C(t.detail??null)),oe.current=!1,N(!1)}).catch(()=>{oe.current=!1,N(!1),x(`generic`),C(null)}))},[f,m]),fe=(0,Z.useCallback)(async()=>{if(!(!O||A)){j(!0);try{let e=await JB(O,1);e.ok?(R.success(n(`done.launchToast`,{count:e.ticketCount})),a(O),se.current()):R.error(n(`done.launchFailed`),{description:e.detail??e.reason})}finally{j(!1)}}},[O,A,a,n]),pe=(0,Z.useCallback)(()=>{O&&a(O),se.current()},[O,a]),me=(0,Z.useCallback)(()=>{let e=K.current;e&&fetch(`/api/blueprint/conversations/${e}/abort`,{method:`POST`}).catch(()=>{}),s(null),l([]),d(null),p(null),h(null),_(!1),y(`chat`),x(null),C(null),T(null),D([]),re.current=!1,k(null),j(!1),oe.current=!1,N(!1),F(`claude`),z(null),V([]),U([]),ee(`medium`),G(``)},[]),he=BB(f),ge=Object.values(he).some(Boolean)||c.length>0||te.trim().length>0,_e=(0,Z.useMemo)(()=>rV(m??f,{milestoneLabel:`M1`,minSpecs:5,maxSpecs:10,requireScaffold:!0}),[f,m]);return{phase:v,messages:c,streamBuffer:u,blueprint:f,busy:g,commitError:b,commitErrorDetail:S,commitSteps:E,createdProjectId:O,launching:A,submitting:M,conversationReady:o!==null,dirty:ge,canProposeCommit:_e.valid,specQualityDetail:_e.issues[0]?.message??null,showSurpriseMe:c.length<=1&&v===`chat`,provider:P,model:L,models:B,efforts:H,effort:W,draft:te,setDraft:G,setEffort:ee,setProvider:ce,setModel:le,send:q,surpriseMe:ue,goToCommit:()=>y(`commit`),backToChat:()=>y(`chat`),submitCommit:de,launchM1:fe,openProject:pe,abortAndReset:me}}var cV=`w-full rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`;function lV({variant:e}){let{t}=I(`builder`),{builderMode:n}=UV(),r=n.session,[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{o.current?.scrollTo?.({top:o.current.scrollHeight})},[r.messages,r.streamBuffer]);let s=(0,Z.useCallback)(()=>{r.dirty&&r.phase!==`done`?a(!0):n.exit()},[r.dirty,r.phase,n]),c=(0,Z.useCallback)(e=>{e.key===`Escape`&&(e.stopPropagation(),i?a(!1):r.phase===`commit`&&!r.submitting?r.backToChat():r.phase===`chat`&&s())},[i,r,s]),l=r.messages.length===0&&r.streamBuffer===null&&!r.busy,u=e===`inline`?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,Q.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,onKeyDown:c,"data-testid":`builder-conversation`,children:[r.phase===`chat`&&(l?(0,Q.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.34,1.56,.64,1]},className:X(`w-full`,e===`inline`?`max-w-[680px]`:`max-w-[560px]`),children:[(0,Q.jsxs)(`div`,{className:`mb-4 text-center`,children:[(0,Q.jsx)(gt,{className:`mx-auto h-7 w-7 text-accent-primary/60`}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium`,children:t(`shell.emptyTitle`)}),(0,Q.jsx)(`p`,{className:`mx-auto mt-1 max-w-sm text-xs text-muted-foreground`,children:t(`shell.emptyHint`)})]}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(TB,{active:!0,inset:-3,radius:`1rem`}),(0,Q.jsx)(ML.div,{layoutId:e===`inline`?`builder-composer-dock`:void 0,"data-testid":`builder-composer-card`,"data-composer-position":`hero`,"data-layout-id":e===`inline`?`builder-composer-dock`:void 0,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:cV,children:(0,Q.jsx)(GB,{session:r,autoFocus:!0})})]})]})}):(0,Q.jsxs)(`div`,{className:u,children:[(0,Q.jsxs)(`div`,{ref:o,className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,"data-testid":`builder-messages`,children:[r.messages.map((e,t)=>(0,Q.jsx)(FR,{role:e.role,content:e.content,createdAt:e.createdAt,isLast:r.streamBuffer===null&&!r.busy&&t===r.messages.length-1,onPickOption:e=>r.send(e)},`${t}-${e.createdAt}`)),(r.busy||r.streamBuffer!==null)&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[r.streamBuffer!==null&&zB(r.streamBuffer)&&(0,Q.jsx)(FR,{role:`assistant`,content:zB(r.streamBuffer),streaming:!0}),(0,Q.jsx)(RL,{tool:null})]})]}),(0,Q.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,Q.jsx)(ML.div,{layoutId:e===`inline`?`builder-composer-dock`:void 0,"data-testid":`builder-composer-card`,"data-composer-position":`docked`,"data-layout-id":e===`inline`?`builder-composer-dock`:void 0,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:X(cV,e===`inline`&&`mx-auto max-w-[680px]`),children:(0,Q.jsx)(GB,{session:r})})})]})),r.phase===`commit`&&r.blueprint&&(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto`,children:(0,Q.jsx)(UB,{blueprint:r.blueprint,onSubmit:r.submitCommit,onBack:r.backToChat,submitting:r.submitting,error:r.commitError,errorDetail:r.commitErrorDetail})}),r.phase===`progress`&&(0,Q.jsxs)(`div`,{className:`mx-auto mt-10 w-full max-w-md p-6`,"data-testid":`commit-progress`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:t(`progress.title`)}),(0,Q.jsx)(`ul`,{className:`mt-4 space-y-2`,children:oV.map(e=>{let n=r.commitSteps.find(t=>t.step===e);return!n&&e===`github`?null:(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[!n&&(0,Q.jsx)(Fn,{className:`h-3.5 w-3.5 text-muted-foreground/40`}),n?.status===`running`&&(0,Q.jsx)(ut,{className:`h-3.5 w-3.5 animate-spin text-accent-info`}),n?.status===`done`&&(0,Q.jsx)(be,{className:`h-3.5 w-3.5 text-accent-success`}),n?.status===`warning`&&(0,Q.jsx)(vt,{className:`h-3.5 w-3.5 text-accent-warning`}),n?.status===`failed`&&(0,Q.jsx)(yt,{className:`h-3.5 w-3.5 text-destructive`}),(0,Q.jsx)(`span`,{className:X(!n&&`text-muted-foreground/50`),children:t(`progress.steps.${e}`)}),n?.status===`warning`&&e===`github`?(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-accent-warning`,title:n.detail,children:t(aV(n.code))}):n?.detail&&(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,title:n.detail,children:n.detail})]},e)})})]}),r.phase===`done`&&(0,Q.jsxs)(`div`,{className:`mx-auto mt-12 w-full max-w-md p-6 text-center`,"data-testid":`commit-done`,children:[(0,Q.jsx)(be,{className:`mx-auto h-10 w-10 rounded-full bg-accent-success/15 p-2 text-accent-success`}),(0,Q.jsx)(`h2`,{className:`mt-3 text-sm font-semibold`,children:t(`done.title`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`done.description`)}),(0,Q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2`,children:[(0,Q.jsxs)(Y,{onClick:()=>void r.launchM1(),disabled:r.launching,"data-testid":`launch-m1`,children:[r.launching?(0,Q.jsx)(ut,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),t(`done.launchM1`)]}),(0,Q.jsx)(Y,{variant:`outline`,onClick:r.openProject,"data-testid":`open-project`,children:t(`done.openProject`)})]})]}),i&&(0,Q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/70 backdrop-blur-sm`,"data-testid":`builder-exit-confirm`,children:(0,Q.jsxs)(`div`,{className:`w-72 rounded-lg border border-border/60 bg-card p-4 shadow-xl`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`builder-exit-confirm-title`,children:[(0,Q.jsx)(`p`,{id:`builder-exit-confirm-title`,className:`text-sm font-medium`,children:t(`mode.exitConfirmTitle`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`mode.exitConfirmBody`)}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>a(!1),"data-testid":`builder-exit-cancel`,children:t(`mode.exitConfirmCancel`)}),(0,Q.jsx)(Y,{variant:`destructive`,size:`sm`,onClick:()=>{a(!1),n.exit()},"data-testid":`builder-exit-confirm-btn`,children:t(`mode.exitConfirmDiscard`)})]})]})})]})}var uV=X(`text-sm leading-7 text-foreground`,`[&_p]:my-3 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold`,`[&_h2]:mt-4 [&_h2]:mb-1.5 [&_h2]:text-[15px] [&_h2]:font-semibold`,`[&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:text-sm [&_h3]:font-semibold`,`[&_strong]:font-semibold [&_strong]:text-foreground`,`[&_em]:italic`,`[&_a]:text-accent-info [&_a]:underline [&_a]:underline-offset-2`,`[&_ul]:my-2.5 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-2.5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-1`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-3`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground`,`[&_hr]:my-3 [&_hr]:border-border/60`),dV={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`};function fV({spec:e,index:t,milestoneLabel:n=`M1`,onClose:r}){let{t:i}=I(`builder`),{t:a}=I(`tickets`),o=`blueprint-spec-summary-${t}`;return(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,Si.createPortal)((0,Q.jsxs)(`div`,{"data-testid":`blueprint-spec-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:r,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":e.title,"aria-describedby":e.shortSummary.trim()?o:void 0,className:`relative flex max-h-[82vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-border/40 bg-popover shadow-2xl backdrop-blur-md`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border/40 px-5 py-4`,children:[(0,Q.jsx)(ct,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-primary`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:i(`specModal.eyebrow`,{milestone:n,index:t+1})}),(0,Q.jsx)(`h2`,{className:`mt-0.5 text-base font-semibold text-foreground`,children:e.title}),e.shortSummary.trim()&&(0,Q.jsxs)(`p`,{id:o,className:`mt-1 text-xs leading-5 text-muted-foreground`,"data-testid":`blueprint-spec-summary`,children:[(0,Q.jsxs)(`span`,{className:`sr-only`,children:[i(`specModal.summary`),`: `]}),e.shortSummary]}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[(0,Q.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,dV[e.priority]),"data-testid":`blueprint-spec-priority`,"aria-label":`${i(`specModal.priority`)}: ${a(`priority.${e.priority}`)}`,children:a(`priority.${e.priority}`)}),e.labels.map(e=>(0,Q.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] text-accent-primary`,children:e},e)),e.dependsOnIndex!==void 0&&(0,Q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-[9px] text-muted-foreground`,children:i(`panel.dependsOn`,{index:e.dependsOnIndex+1})})]})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(`specModal.close`),"data-agent-interactive":!0,className:`rounded-md p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground`,"data-testid":`blueprint-spec-modal-close`,children:(0,Q.jsx)(yt,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[(0,Q.jsx)(`section`,{"aria-label":i(`specModal.description`),"data-testid":`blueprint-spec-description`,children:e.description.trim()?(0,Q.jsx)(`div`,{className:uV,children:(0,Q.jsx)(un,{remarkPlugins:[dn],children:e.description})}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.empty`)})}),(0,Q.jsxs)(`section`,{"aria-labelledby":`blueprint-spec-criteria-heading`,"data-testid":`blueprint-spec-acceptance-criteria`,children:[(0,Q.jsxs)(`h3`,{id:`blueprint-spec-criteria-heading`,className:`mb-2 flex items-center justify-between gap-2 text-xs font-semibold uppercase tracking-wider text-foreground/60`,children:[(0,Q.jsx)(`span`,{children:i(`specModal.acceptanceCriteria`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] tabular-nums text-muted-foreground`,children:e.acceptanceCriteria.length})]}),e.acceptanceCriteria.length>0?(0,Q.jsx)(`ol`,{className:`space-y-2`,children:e.acceptanceCriteria.map((e,t)=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-2 text-sm leading-6 text-foreground/85`,"data-testid":`blueprint-spec-criterion-${t}`,children:[(0,Q.jsx)(Pn,{className:`mt-1 h-4 w-4 shrink-0 text-accent-success`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:e})]},`${t}-${e}`))}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.criteriaEmpty`)})]})]})]})]}),document.body)}var pV={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`};function mV({blueprint:e,milestoneLabel:t=`M1`}){let{t:n}=I(`builder`),{t:r}=I(`tickets`),i=BB(e),[a,o]=(0,Z.useState)(null),s=[{key:`product`,label:n(`panel.product`),value:e?.product.name??``},{key:`coreFlow`,label:n(`panel.coreFlow`),value:e?.coreFlow??``},{key:`platform`,label:n(`panel.platform`),value:e?.platform??``},{key:`stack`,label:n(`panel.stack`),value:e?[e.stack.language,e.stack.framework,e.stack.db].filter(Boolean).join(` · `):``},{key:`milestones`,label:n(`panel.milestones`),value:e&&e.milestones.length>0?n(`panel.milestonesValue`,{count:e.milestones.length}):``}];return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`blueprint-panel`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`panel.title`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:s.map(e=>(0,Q.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-xs transition-colors`,i[e.key]?`border-accent-success/30 bg-accent-success/5`:`border-border/30`),"data-testid":`dimension-${e.key}`,children:[i[e.key]?(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-label":`✓`}):(0,Q.jsx)(yt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/40`,"aria-label":`✗`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label}),e.value&&(0,Q.jsx)(`span`,{className:`ml-auto truncate text-muted-foreground`,title:e.value,children:e.value})]},e.key))})]}),e&&e.assumptions.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`panel.assumptions`)}),(0,Q.jsx)(`ul`,{className:`space-y-0.5`,children:e.assumptions.map((e,t)=>(0,Q.jsx)(`li`,{className:`text-[11px] text-muted-foreground before:mr-1.5 before:content-['·']`,children:e},t))})]}),e&&e.m1Specs.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`h4`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Q.jsx)(br,{className:`h-3 w-3`}),n(`panel.m1Specs`,{count:e.m1Specs.length})]}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:e.m1Specs.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(t),"data-agent-interactive":!0,className:`w-full rounded-lg border border-border/40 bg-surface/50 p-2.5 text-left shadow-sm transition-colors animate-in fade-in slide-in-from-bottom-1 hover:border-accent-primary/50 hover:bg-surface/80 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,"data-testid":`m1-spec-card-${t}`,title:n(`specModal.open`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(ct,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium leading-tight`,children:e.title}),e.shortSummary.trim()&&(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-4 text-muted-foreground`,"data-testid":`m1-spec-summary-${t}`,children:e.shortSummary}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,pV[e.priority]),"data-testid":`m1-spec-priority-${t}`,children:r(`priority.${e.priority}`)}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/50 bg-surface/70 px-1.5 py-px text-[9px] text-muted-foreground`,"data-testid":`m1-spec-criteria-count-${t}`,children:[(0,Q.jsx)(wr,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),n(`panel.criteriaCount`,{count:e.acceptanceCriteria.length})]}),e.labels.map(e=>(0,Q.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] text-accent-primary`,children:e},e)),e.dependsOnIndex!==void 0&&(0,Q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-[9px] text-muted-foreground`,children:n(`panel.dependsOn`,{index:e.dependsOnIndex+1})})]})]})]})},`${t}-${e.title}`))})]}),e&&e.milestones.length>1&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`panel.laterMilestones`)}),e.milestones.slice(1).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/20 px-2.5 py-1.5`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:e.title}),e.plannedSpecs.length>0&&(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e.plannedSpecs.join(` · `)})]},e.id||e.title))]}),!e&&(0,Q.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground/60`,children:n(`panel.empty`)}),e&&a!==null&&e.m1Specs[a]&&(0,Q.jsx)(fV,{spec:e.m1Specs[a],index:a,milestoneLabel:t,onClose:()=>o(null)})]})}function hV(){let{t:e}=I(`agent`),{t}=I(`builder`),{minimize:n,startNewConversation:r,cycleTier:i,active:a,draftPinnedProjectId:o,setPinnedProject:s,builderMode:c}=UV(),[l,u]=(0,Z.useState)(!1),d=c.active,f=e=>{d||e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),i())},{panelRef:p,panelStyle:m,headerHandleProps:h,resizeHandles:g}=Ut({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ML.div,{ref:p,initial:{opacity:0,scale:.85,y:8},animate:{opacity:1,scale:1,y:0},transition:{duration:.22,ease:[.34,1.56,.64,1]},style:l?{position:`fixed`,inset:12,width:`auto`,height:`auto`,maxWidth:`none`,maxHeight:`none`}:m,role:`dialog`,"aria-label":d?t(`mode.title`):e(`title`),onKeyDown:f,className:`fixed z-[60] flex flex-col overflow-hidden rounded-2xl border border-border/60 bg-card/90 shadow-2xl backdrop-blur-xl ${l?``:`bottom-4 right-4 h-[78vh] max-h-[94vh] max-w-[92vw] ${d?`w-[860px]`:`w-[520px]`}`}`,children:[(0,Q.jsxs)(`div`,{...l?{}:h,onDoubleClick:()=>u(e=>!e),className:`flex shrink-0 items-center gap-2 border-b border-border/50 bg-surface/40 px-3 py-2 ${l?``:`cursor-grab`}`,children:[(0,Q.jsxs)(`span`,{className:`relative flex h-5 w-5 shrink-0 items-center justify-center`,children:[(0,Q.jsx)(TB,{active:d&&c.session.messages.length===0&&c.session.phase===`chat`,inset:-3}),(0,Q.jsx)(wn,{className:`h-4 w-4 shrink-0 text-accent-primary`})]}),(0,Q.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/80`,children:d?t(`mode.title`):e(`title`)}),!d&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(gz,{pinnedProjectId:a?a.pinned_project_id:o,onSelect:e=>void s(e)}),(0,Q.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border/60`,"aria-hidden":!0}),(0,Q.jsx)(CB,{})]}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[!d&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(null),title:e(`newConversation`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,Q.jsx)(pt,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-label":e(l?`restore`:`maximize`),title:e(l?`restore`:`maximize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:l?(0,Q.jsx)(Or,{className:`h-4 w-4`}):(0,Q.jsx)(Dr,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":e(`minimize`),title:e(`minimize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,Q.jsx)(yt,{className:`h-4 w-4`})})]})]}),d?(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Q.jsx)(lV,{variant:`floating`}),(0,Q.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border/40 lg:w-80`,children:[(0,Q.jsx)(mV,{blueprint:c.session.blueprint}),c.session.phase===`chat`&&(0,Q.jsxs)(`div`,{className:`border-t border-border/40 p-3`,children:[(0,Q.jsxs)(Y,{className:`w-full`,size:`sm`,disabled:!c.session.canProposeCommit,onClick:c.session.goToCommit,"data-testid":`builder-create-specs`,children:[(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),t(`shell.createSpecs`)]}),!c.session.canProposeCommit&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,children:c.session.specQualityDetail??t(`shell.createSpecsHint`)})]})]})]}):(0,Q.jsx)(bB,{variant:`floating`})]}),!l&&(0,Q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,Q.jsx)(tn,{handles:g})})]})}var gV=`specrails-desktop:agent-bubble-pos`,_V=56,vV=12;function yV(){try{let e=localStorage.getItem(gV);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function bV(e){let t=Math.max(vV,window.innerWidth-_V-vV),n=Math.max(vV,window.innerHeight-_V-vV);return{left:Math.min(Math.max(vV,e.left),t),top:Math.min(Math.max(vV,e.top),n)}}function xV(){return{left:Math.round(window.innerWidth/2-_V/2),top:window.innerHeight-_V-20}}function SV(){let{t:e}=I(`agent`),{t}=I(`builder`),{open:n,isStreaming:r,active:i,builderMode:a}=UV(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(()=>bV(yV()??xV())),u=AL(0),d=AL(0),f=(0,Z.useRef)(!1),p=a.active?a.session.busy:r;(0,Z.useEffect)(()=>{let e=()=>l(e=>bV(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,Z.useCallback)(e=>{try{localStorage.setItem(gV,JSON.stringify(e))}catch{}},[]);return(0,Q.jsxs)(ML.button,{type:`button`,onClick:()=>{if(f.current){f.current=!1;return}n()},onHoverStart:()=>s(!0),onHoverEnd:()=>s(!1),"aria-label":e(`trigger`),title:`${e(`trigger`)} (⌘⇧A)`,drag:!0,dragMomentum:!1,dragElastic:0,style:{position:`fixed`,left:c.left,top:c.top,x:u,y:d},onDragStart:()=>{f.current=!0},onDragEnd:()=>{let e=bV({left:c.left+u.get(),top:c.top+d.get()});u.set(0),d.set(0),l(e),m(e),setTimeout(()=>{f.current=!1},0)},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:420,damping:28},whileHover:{scale:1.06},whileTap:{scale:.94},whileDrag:{scale:1.1,cursor:`grabbing`},className:`z-[60] flex h-14 items-center gap-2 rounded-full border border-border/60 bg-card/85 px-3 shadow-2xl backdrop-blur-xl cursor-grab`,children:[(0,Q.jsxs)(`span`,{className:`relative flex h-9 w-9 items-center justify-center rounded-full bg-accent-primary/15`,children:[(0,Q.jsx)(TB,{active:a.active&&a.session.messages.length===0&&a.session.phase===`chat`,inset:-4}),(0,Q.jsx)(wn,{className:`h-5 w-5 text-accent-primary`}),p&&(0,Q.jsx)(ML.span,{className:`absolute inset-0 rounded-full ring-2 ring-accent-success`,animate:{opacity:[.8,.2,.8],scale:[1,1.18,1]},transition:{duration:1.4,repeat:1/0,ease:`easeInOut`}})]}),(0,Q.jsx)(MF,{initial:!1,children:(o||p)&&(0,Q.jsx)(ML.span,{initial:{opacity:0,width:0,marginRight:0},animate:{opacity:1,width:`auto`,marginRight:4},exit:{opacity:0,width:0,marginRight:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden whitespace-nowrap text-sm font-medium text-foreground`,children:p?e(`thinking`):a.active?t(`mode.title`):i?.title||e(`trigger`)})})]})}var CV={streamingText:``,isStreaming:!1,liveTools:[],queued:[]},wV=`specrails-desktop:favorite-agent-conversations`;function TV(){try{let e=localStorage.getItem(wV);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function EV(e){try{localStorage.setItem(wV,JSON.stringify([...e]))}catch{}}function DV(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var OV=new Set([`completed`,`merged`,`discarded`,`superseded`]);function kV(e,t){return JSON.stringify(e)===JSON.stringify(t)}function AV(e){if(!e.createdAt)return null;let t=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(e.createdAt)?`${e.createdAt.replace(` `,`T`)}Z`:e.createdAt,n=Date.parse(t);return Number.isFinite(n)?n:null}function jV(e,t){if(t.supersedesDeliveryId===e.prDeliveryId)return 1;if(e.supersedesDeliveryId===t.prDeliveryId)return-1;let n=AV(e),r=AV(t);return n==null||r==null?null:r<n?-1:+(r>n)}function MV(e,t){let n=null;for(let r of e){if(r.supersedesDeliveryId!==t)continue;if(!n){n=r;continue}let e=AV(n),i=AV(r);(e==null||i==null||i>=e)&&(n=r)}return n}function NV(e,t){let n=t.restoredFromDeliveryId;if(!n)return!1;let r=MV(e,t.prDeliveryId);return!r||r.prDeliveryId===n}function PV(e,t){let n=e.filter(e=>e.role===`system`).map(e=>ME(e.content)).filter(e=>e!==null),r=[...n].reverse().find(e=>e.prDeliveryId===t.prDeliveryId),i=NV(n,t);if(r){let e=OV.has(r.decision),n=OV.has(t.decision),a=bv(r.updatedAt,t.updatedAt);if(a===-1||a===0&&!kV(r,t)||e&&!n&&!(i&&r.decision===`superseded`))return!0}let a=new Set(n.map(e=>e.supersedesDeliveryId).filter(e=>!!e));if(i)return!1;if(a.has(t.prDeliveryId)&&t.decision!==`superseded`)return!0;for(let e of n){if(e.railIndex!==t.railIndex||e.prDeliveryId===t.prDeliveryId||a.has(e.prDeliveryId))continue;let n=jV(e,t);if(n===-1||(n===0||n===null)&&!OV.has(e.decision)&&t.supersedesDeliveryId!==e.prDeliveryId)return!0}return!1}function FV(e,t){let n=t.restoredFromDeliveryId;if(!n)return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let t=ME(e.content);return!t||t.prDeliveryId!==n||OV.has(t.decision)?e:(r=!0,{...e,content:JSON.stringify({...t,decision:`discarded`})})});return r?i:e}function IV(e,t){let n=e.filter(e=>e.role===`system`).map(e=>ME(e.content)).filter(e=>e!==null);if(n.some(e=>e.restoredFromDeliveryId===t.prDeliveryId&&NV(n,e)))return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let n=ME(e.content);return!n||n.railIndex!==t.railIndex||n.prDeliveryId===t.prDeliveryId||OV.has(n.decision)||jV(n,t)!==1?e:(r=!0,{...e,content:JSON.stringify({...n,decision:`superseded`})})});return r?i:e}function LV(e,t,n){if(PV(e,n))return e;let r=IV(FV(e,n),n),i=JSON.stringify(n),a=r.flatMap((e,t)=>e.role===`system`&&ME(e.content)?.prDeliveryId===n.prDeliveryId?[t]:[]);if(a.length>0){let e=a[a.length-1];if(a.length===1&&r[e].content===i)return r;let t=new Set(a.slice(0,-1));return r.flatMap((n,r)=>t.has(r)?[]:[r===e?{...n,content:i}:n])}return[...r,{id:`prd-${n.prDeliveryId}`,conversation_id:t,role:`system`,content:i,created_at:new Date().toISOString()}]}var RV=(0,Z.createContext)(null),zV=0,BV=0;function VV({children:e}){let{registerHandler:t,unregisterHandler:n,connectionStatus:r}=Et(),{uiMode:i}=iw(),{setActiveProjectId:a}=At(),[o,s]=(0,Z.useState)(`hidden`),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=(0,Z.useRef)(f);m.current=f;let[h,g]=(0,Z.useState)(TV),[_,v]=(0,Z.useState)(new Set),[y,b]=(0,Z.useState)(new Map),[x,S]=(0,Z.useState)(!0),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=(0,Z.useRef)(null);k.current=D;let[A,j]=(0,Z.useState)(`claude`),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(0),[I,L]=(0,Z.useState)(null),z=(0,Z.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});z.current={provider:A,model:M,tierLevel:P,effort:I};let B=(0,Z.useRef)(null);B.current=u?.id??null;let V=(0,Z.useRef)(y);V.current=y;let H=(0,Z.useRef)(new Set),U=(0,Z.useRef)(null),W=(0,Z.useRef)(0),ee=(0,Z.useRef)(0),te=(0,Z.useCallback)(e=>{let t=B.current;if(!t)return`untracked`;if(PV(m.current,e))return`stale`;if(!m.current.some(t=>t.role===`system`&&ME(t.content)?.prDeliveryId===e.prDeliveryId))return`untracked`;W.current++;let n=LV(m.current,t,e);return m.current=n,p(n=>{if(!n.some(t=>t.role===`system`&&ME(t.content)?.prDeliveryId===e.prDeliveryId))return m.current=n,n;let r=LV(n,t,e);return m.current=r,r}),`accepted`},[]),G=(0,Z.useCallback)((e,t)=>{b(n=>{let r=t(n.get(e)??CV),i=new Map(n);return r===null||!r.isStreaming&&!r.streamingText&&r.liveTools.length===0&&r.queued.length===0?i.delete(e):i.set(e,r),i})},[]),K=(0,Z.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===B.current&&!t||v(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),ne=(0,Z.useCallback)(e=>{v(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,Z.useEffect)(()=>{if(!at||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=B.current;e&&ne(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[ne]);let re=(u?y.get(u.id):void 0)??CV,ie=re.streamingText,ae=re.isStreaming,oe=re.liveTools,se=re.queued,ce=(0,Z.useMemo)(()=>{let e=new Set;for(let[t,n]of y)n.isStreaming&&e.add(t);return e},[y]),le=(0,Z.useCallback)(async()=>{try{let e=await gE();l(e),g(t=>{let n=DV(t,e);return n.size===t.size?t:(EV(n),n)})}catch{}},[]),q=(0,Z.useCallback)(async()=>{try{let e=await RE();S(e.enabled)}catch{S(!1)}},[]),ue=(0,Z.useCallback)(async()=>{try{E((await LE()).any)}catch{E(!0)}},[]);(0,Z.useEffect)(()=>at?(t(`agent-chat`,e=>{let t=e;if(typeof t.type!=`string`||!t.type.startsWith(`agent_`))return;if(t.type===`agent_title`&&t.conversationId){let e=t.title??null;l(n=>n.map(n=>n.id===t.conversationId?{...n,title:e}:n)),d(n=>n&&n.id===t.conversationId?{...n,title:e}:n);return}let n=t.conversationId;if(!n)return;let r=n===B.current;if(t.type===`agent_stream`)K(n),G(n,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(t.delta??``)}));else if(t.type===`agent_tool`)G(n,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${zV++}`,tool:t.tool??`tool`}]}));else if(t.type===`agent_done`){K(n);let e=t.fullText??``;r&&p(t=>{let r=t[t.length-1];return r&&r.role===`assistant`&&r.content===e&&!r.id.startsWith(`local-`)?t:[...t,{id:`local-${Date.now()}`,conversation_id:n,role:`assistant`,content:e,created_at:new Date().toISOString()}]}),G(n,e=>({...CV,queued:e.queued}))}else if(t.type===`agent_error`){K(n),G(n,e=>({...CV,queued:e.queued}));let e=t.error||`The agent turn failed.`;R.error(e),r&&p(t=>[...t,{id:`err-${Date.now()}`,conversation_id:n,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(t.type===`agent_queued`)G(n,e=>t.queueId&&e.queued.some(e=>e.queueId===t.queueId)?e:{...e,queued:[...e.queued,{queueId:t.queueId??`srv-${BV++}`,text:t.text??``,contextRefs:t.contextRefs}]});else if(t.type===`agent_dequeued`)t.queueId&&H.current.add(t.queueId),G(n,e=>{let n=t.queueId?e.queued.findIndex(e=>e.queueId===t.queueId):0,r=n===-1?0:n;return{...e,queued:e.queued.filter((e,t)=>t!==r),isStreaming:!0,streamingText:``,liveTools:[]}}),r&&t.text&&p(e=>[...e,{id:`local-u-${Date.now()}`,conversation_id:n,role:`user`,content:t.text,context_refs:t.contextRefs??[],created_at:new Date().toISOString()}]);else if(t.type===`agent_queue_cleared`)G(n,e=>({...e,queued:[]}));else if(t.type===`agent_queue_edited`)G(n,e=>({...e,queued:e.queued.map(e=>t.queueId&&e.queueId===t.queueId?{...e,text:t.text??e.text,contextRefs:t.contextRefs??e.contextRefs}:e)}));else if(t.type===`agent_pr_decision`&&(K(n),r)){let t=jE(e);if(t){W.current++;let e=LV(m.current,n,t);m.current=e,p(e=>{let r=LV(e,n,t);return m.current=r,r})}}}),()=>n(`agent-chat`)):void 0,[t,n,G,K]);let de=(0,Z.useCallback)(async e=>{let t=++ee.current;W.current++;let{conversation:n,messages:r}=await vE(e);t===ee.current&&(W.current++,d(n),m.current=r,p(r),ne(e))},[ne]),fe=(0,Z.useCallback)(async()=>{let e=B.current;if(!e)return;let t=W.current;try{let n=await vE(e);if(B.current!==e||W.current!==t)return;let r=n.messages.filter(e=>e.role===`system`).map(e=>ME(e.content)).filter(e=>e!==null);if(r.length===0)return;p(t=>{let n=r.reduce((t,n)=>LV(t,e,n),t);return m.current=n,n})}catch{}},[]);(0,Z.useEffect)(()=>{let e=()=>{fe()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[fe]);let pe=(0,Z.useRef)(r);(0,Z.useEffect)(()=>{let e=pe.current;pe.current=r,r===`connected`&&e!==`connected`&&fe()},[r,fe]);let me=(0,Z.useCallback)(async()=>{if(u)return u;let e=await gE();if(l(e),g(t=>{let n=DV(t,e);return n.size===t.size?t:(EV(n),n)}),e.length>0)return await de(e[0].id),e[0];let t=await _E({});return l(e=>[t,...e]),d(t),p([]),t},[u,de]),he=(0,Z.useCallback)(()=>{s(`open`),le(),q(),ue(),me()},[le,q,ue,me]),ge=(0,Z.useCallback)(()=>s(`hidden`),[]),_e=(0,Z.useCallback)(()=>s(`minimized`),[]),[ve,ye]=(0,Z.useState)(!1),be=(0,Z.useRef)(null),J=(0,Z.useCallback)(()=>{be.current?.abortAndReset(),ye(!1)},[]),xe=sV(ve,{onFinished:J});be.current=xe;let Se=(0,Z.useCallback)(()=>{ye(!0),i!==`agent`&&he()},[i,he]),Ce=(0,Z.useCallback)(()=>{s(e=>e===`open`?`minimized`:`open`),o!==`open`&&(le(),q(),ue(),me())},[o,le,q,ue,me]),we=(0,Z.useCallback)(async()=>{if(u)return u;if(U.current)return U.current;let e=_E({pinnedProjectId:k.current,provider:z.current.provider,model:z.current.model,tierLevel:z.current.tierLevel,reasoningEffort:z.current.effort}).then(e=>(l(t=>[e,...t]),d(e),p([]),e)).finally(()=>{U.current=null});return U.current=e,e},[u]),Te=(0,Z.useCallback)(async(e,t)=>{let n=e.trim();if(!n)return;let r=u??await we(),i=`q-${Date.now()}-${BV++}`,a=new Date().toISOString();l(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:a},...e.filter(e=>e.id!==r.id)]),d(e=>e&&e.id===r.id?{...e,updated_at:a}:e);let o={id:`local-u-${Date.now()}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],created_at:a},s=V.current.get(r.id)?.isStreaming===!0;s?G(r.id,e=>({...e,queued:[...e.queued,{queueId:i,text:n,contextRefs:t?.contextRefs}]})):(p(e=>[...e,o]),G(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let c=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,a=(await xE(r.id,n,{tierLevel:r.tier_level,attachments:c,queueId:i,contextRefs:e}))?.queued===!0;a&&!s?(p(e=>e.filter(e=>e.id!==o.id)),H.current.has(i)||G(r.id,e=>e.queued.some(e=>e.queueId===i)?e:{...e,queued:[...e.queued,{queueId:i,text:n,contextRefs:t?.contextRefs}]})):!a&&s&&(G(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==i),isStreaming:!0})),p(e=>[...e,o]))}catch(e){s?G(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==i)})):G(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),R.error(e instanceof Error?e.message:`Failed to send message.`)}},[u,we,G]),Ee=(0,Z.useCallback)(async()=>{u&&(G(u.id,()=>null),await DE(u.id))},[u,G]),De=(0,Z.useCallback)(async(e,t)=>{let n=u;if(!n)return`conflict`;let r=await OE(n.id,e,t);return r===`saved`&&G(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[u,G]),Oe=(0,Z.useCallback)(e=>H.current.has(e),[]),ke=(0,Z.useCallback)(async e=>{if(!u)return;let t=await yE(u.id,e);d(t),l(e=>e.map(e=>e.id===t.id?t:e))},[u]),Ae=(0,Z.useCallback)(async e=>{u?await ke({tierLevel:e}):F(e)},[u,ke]),je=(0,Z.useCallback)(async()=>{let e=((u?.tier_level??P)+1)%4;await Ae(e)},[u,P,Ae]),Me=(0,Z.useCallback)(async e=>{u?await ke({provider:e}):(j(e),N(null),L(null))},[u,ke]),Ne=(0,Z.useCallback)(async e=>{u?await ke({model:e}):N(e)},[u,ke]),Pe=(0,Z.useCallback)(async e=>{u?await ke({reasoningEffort:e}):L(e)},[u,ke]),Fe=(0,Z.useCallback)(async e=>{u?await ke({pinnedProjectId:e}):O(e),!u&&e&&i===`agent`&&a(e)},[u,ke,i,a]),Ie=(0,Z.useCallback)(e=>{J(),d(null),p([]),O(e??null),j(`claude`),N(null),F(0),L(null)},[J]),Le=(0,Z.useCallback)(async e=>{J();let t=await _E({pinnedProjectId:e===void 0?u?.pinned_project_id??null:e});l(e=>[t,...e]),d(t),p([])},[u,J]),Re=(0,Z.useCallback)(async e=>{J(),await de(e)},[de,J]),ze=(0,Z.useCallback)(async e=>{await bE(e),l(t=>t.filter(t=>t.id!==e)),g(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),EV(n),n}),G(e,()=>null),B.current===e&&(d(null),p([]))},[G]),Be=(0,Z.useCallback)(async(e,t)=>{let n=t.trim()||null,r;l(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),d(t=>t&&t.id===e?{...t,title:n}:t);try{await yE(e,{title:n})}catch(t){throw l(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),d(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),Ve=(0,Z.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),EV(n),n})},[]),He=(0,Z.useCallback)(async()=>{w(!0);try{await zE(),await q()}finally{w(!1)}},[q]),Ue=(0,Z.useMemo)(()=>({visibility:o,open:he,close:ge,minimize:_e,toggle:Ce,conversations:c,active:u,messages:f,streamingText:ie,isStreaming:ae,liveTools:oe,queuedMessages:se,streamingConversationIds:ce,liveByConversation:y,unreadConversationIds:_,favoriteConversationIds:h,mcpEnabled:x,enablingMcp:C,enableMcpServer:He,providersReady:T,send:Te,abort:Ee,editQueuedMessage:De,wasQueueConsumed:Oe,cycleTier:je,setTier:Ae,setProvider:Me,setModel:Ne,setPinnedProject:Fe,newConversation:Le,startNewConversation:Ie,materializeDraftConversation:we,draftPinnedProjectId:D,draftProvider:A,draftModel:M,draftTierLevel:P,draftEffort:I,setEffort:Pe,selectConversation:Re,deleteConversation:ze,renameConversation:Be,toggleFavoriteConversation:Ve,refreshConversations:le,applyPrDecisionSnapshot:te,builderMode:{active:ve,enter:Se,exit:J,session:xe}}),[o,he,ge,_e,Ce,ve,Se,J,xe,c,u,f,ie,ae,oe,se,ce,y,_,h,x,C,He,T,Te,Ee,De,Oe,je,Ae,Me,Ne,Fe,Le,Ie,we,D,A,M,P,I,Pe,Re,ze,Be,Ve,le,te]),We=at&&i!==`agent`;return(0,Q.jsxs)(RV.Provider,{value:Ue,children:[e,We&&o===`open`&&(0,Q.jsx)(hV,{}),We&&o!==`open`&&(0,Q.jsx)(SV,{})]})}var HV={visibility:`hidden`,open:()=>{},close:()=>{},minimize:()=>{},toggle:()=>{},conversations:[],active:null,messages:[],streamingText:``,isStreaming:!1,liveTools:[],queuedMessages:[],streamingConversationIds:new Set,unreadConversationIds:new Set,liveByConversation:new Map,favoriteConversationIds:new Set,mcpEnabled:!0,enablingMcp:!1,enableMcpServer:async()=>{},providersReady:!0,send:async()=>{},abort:async()=>{},editQueuedMessage:async()=>`conflict`,wasQueueConsumed:()=>!1,cycleTier:async()=>{},setTier:async()=>{},setProvider:async()=>{},setModel:async()=>{},setPinnedProject:async()=>{},newConversation:async()=>{},startNewConversation:()=>{},materializeDraftConversation:async()=>{throw Error(`AgentChatProvider is not mounted`)},draftPinnedProjectId:null,draftProvider:`claude`,draftModel:null,draftTierLevel:0,draftEffort:null,setEffort:async()=>{},selectConversation:async()=>{},deleteConversation:async()=>{},renameConversation:async()=>{},toggleFavoriteConversation:()=>{},refreshConversations:async()=>{},applyPrDecisionSnapshot:()=>`untracked`,builderMode:{active:!1,enter:()=>{},exit:()=>{},session:{phase:`chat`,messages:[],streamBuffer:null,blueprint:null,busy:!1,commitError:null,commitErrorDetail:null,commitSteps:[],createdProjectId:null,launching:!1,submitting:!1,conversationReady:!1,dirty:!1,canProposeCommit:!1,specQualityDetail:null,showSurpriseMe:!0,provider:`claude`,model:null,models:[],efforts:[],effort:`medium`,draft:``,setDraft:()=>{},setEffort:()=>{},setProvider:()=>{},setModel:()=>{},send:()=>{},surpriseMe:()=>{},goToCommit:()=>{},backToChat:()=>{},submitCommit:()=>{},launchM1:async()=>{},openProject:()=>{},abortAndReset:()=>{}}}};function UV(){return(0,Z.useContext)(RV)??HV}var WV=(0,Z.lazy)(()=>c(()=>import(`./ProjectSettingsDialog-DHsxLFMT.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([78,1,2,6,54,44,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,3,36,43,37,67,66,68,42,65]))),GV=`specrails-desktop:agentTreeExpanded`;function KV(){try{let e=localStorage.getItem(GV);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function qV(e){try{localStorage.setItem(GV,JSON.stringify([...e]))}catch{}}function JV(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var YV=`__home__`,XV=`__favorites__`;function ZV({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=I(`agent`),u=e.title?.trim()||l(`untitled`),[d,f]=(0,Z.useState)(!1),p=(0,Z.useRef)(null),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(r);(0,Z.useEffect)(()=>{if(g.current&&!r){h(!0);let e=setTimeout(()=>h(!1),900);return g.current=r,()=>clearTimeout(e)}g.current=r},[r]),(0,Z.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);function _(e){e.stopPropagation(),d?(p.current&&clearTimeout(p.current),f(!1),c()):(f(!0),p.current=setTimeout(()=>{f(!1),p.current=null},3e3))}function v(e){e.stopPropagation(),s?.()}function y(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o()))}return(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:y,className:X(`group relative flex items-center gap-2 w-full h-7 rounded-md transition-colors`,n?`pl-7 pr-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:u,"aria-current":t?`true`:void 0,children:[(0,Q.jsx)(De,{className:X(`w-3.5 h-3.5 flex-shrink-0`,t&&`text-accent-primary`,r&&!i&&`text-accent-primary animate-pulse`,i&&`text-destructive conversation-unread-glow`)}),n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`relative text-[11px] truncate flex-1 text-left`,children:[u,(r||m)&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:X(`title-shimmer pointer-events-none absolute inset-0 truncate transition-opacity duration-700`,r?`opacity-100`:`opacity-0`),children:u})]}),(0,Q.jsx)(`span`,{className:X(`flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/45`,d?`hidden`:`group-hover:hidden`),title:nE(e.updated_at),children:tE(e.updated_at)}),(0,Q.jsx)(`button`,{type:`button`,onClick:v,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,a?`flex w-3.5 h-3.5 text-accent-primary hover:text-accent-primary`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-accent-primary`),"aria-label":l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),title:l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),children:(0,Q.jsx)(pr,{className:`w-2.5 h-2.5`,fill:a?`currentColor`:`none`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:_,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,d?`flex px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-foreground`),"aria-label":l(d?`confirmDeleteConversation`:`deleteConversation`,{title:u}),children:d?l(`confirmShort`):(0,Q.jsx)(yt,{className:`w-2.5 h-2.5`})})]})]})}function QV({project:e,isActive:t,expanded:n,onSelect:r,onRemove:i,agentMode:a=!1,hasTree:o=!1,treeOpen:s=!1,onToggleTree:c,conversations:l=[],activeConversationId:u=null,streamingConversationIds:d,unreadConversationIds:f,onSelectConversation:p,onToggleConversationFavorite:m,onDeleteConversation:h,onOpenProjectSettings:g}){let{t:_}=I(`nav`),[v,y]=(0,Z.useState)(!1),b=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);function x(e){e.stopPropagation(),v?(b.current&&clearTimeout(b.current),y(!1),i()):(y(!0),b.current=setTimeout(()=>{y(!1),b.current=null},3e3))}function S(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))}let C=a&&o&&n,w=(0,Q.jsx)(rr,{className:X(`flex-shrink-0 w-4 h-4`,t&&`text-accent-primary`)});return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:S,className:X(`group relative flex items-center gap-2 w-full h-8 rounded-md transition-colors`,n?`px-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:e.name,"aria-current":t?`page`:void 0,children:[C?(0,Q.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Q.jsx)(`span`,{className:`flex transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:w}),(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c?.()},className:`absolute inset-0 hidden items-center justify-center rounded-sm hover:bg-muted group-hover:flex group-focus-within:flex`,"aria-label":_(s?`projects.collapse`:`projects.expand`,{name:e.name}),"aria-expanded":s,children:s?(0,Q.jsx)(pe,{className:`w-3.5 h-3.5`}):(0,Q.jsx)(xe,{className:`w-3.5 h-3.5`})})]}):w,n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:e.name}),g&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g()},className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all w-3.5 h-3.5`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`),"aria-label":_(`projects.settings`,{name:e.name}),title:_(`projects.settings`,{name:e.name}),children:(0,Q.jsx)(ni,{className:`w-2.5 h-2.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:x,className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`,v?`opacity-100 px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`w-3.5 h-3.5`),"aria-label":_(v?`projects.confirmRemove`:`projects.remove`,{name:e.name}),children:v?_(`projects.confirmShort`):(0,Q.jsx)(yt,{className:`w-2.5 h-2.5`})})]})]}),a&&s&&n&&l.length>0&&(0,Q.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:l.map(e=>(0,Q.jsx)(ZV,{conversation:e,active:e.id===u,streaming:d?.has(e.id)??!1,unread:f?.has(e.id)??!1,expanded:n,onSelect:()=>p?.(e.id),onToggleFavorite:()=>m?.(e.id),onDelete:()=>h?.(e.id)},e.id))})]})}var $V={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function eH({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a}){let{t:o}=I(`nav`),{t:s}=I(`agent`),{projects:c,activeProjectId:l,setActiveProjectId:d,removeProject:f}=At(),m=p(),h=u(),g=h.pathname.startsWith(`/loops`),_=h.pathname.startsWith(`/plugins`),v=g||_||h.pathname.startsWith(`/docs`),{leftMode:y,cycleLeftMode:b}=fE(),{uiMode:x,toggleUiMode:S}=iw(),C=UV(),w=x===`agent`,T=(0,Z.useMemo)(()=>{let e=new Map,t=new Set(c.map(e=>e.id));for(let n of C.conversations){if(C.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:YV,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[C.conversations,C.favoriteConversationIds,c]),E=(0,Z.useMemo)(()=>C.conversations.filter(e=>C.favoriteConversationIds.has(e.id)),[C.conversations,C.favoriteConversationIds]),D=T.get(YV)??[],[O,k]=(0,Z.useState)(KV),A=O.has(XV),[j,M]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{!w||!l||k(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),qV(t),t})},[w,l]);let N=e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),qV(n),n})},P=e=>{C.selectConversation(e),v&&m(`/`)},F=e=>{C.deleteConversation(e).catch(()=>{})},L=e=>{C.toggleFavoriteConversation(e)};function R(e){if(w){d(e),N(e);return}if(e===l){v&&m(`/`);return}d(e)}let[z,B]=(0,Z.useState)(!1),V=y===`pinned-open`||y===`unpinned`&&z,H=ZT(`left-arc`,{side:`left`,defaultWidth:240,min:200,max:460,collapsedWidth:44,expanded:V}),U=y!==`unpinned`,W=o($V[y]),ee=[{label:o(`arcSidebar.docs`),icon:Cn,action:i},{label:o(`arcSidebar.analytics`),icon:An,action:r},{label:o(`arcSidebar.settings`),icon:ni,action:a}];async function te(e){try{await f(e.id)}catch{}}return(0,Q.jsxs)(`div`,{ref:H.panelRef,className:X(`relative flex flex-col h-full border-r border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{y===`unpinned`&&B(!0)},onMouseLeave:()=>{y===`unpinned`&&!H.dragging&&B(!1)},children:[V&&(0,Q.jsx)(QT,{side:`left`,dragging:H.dragging,width:H.width,min:200,max:460,label:o(`arcSidebar.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:H.onGripPointerDown,onKeyDown:H.onGripKeyDown}),(0,Q.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,V?`px-3 justify-between`:`justify-center`),children:[V&&(0,Q.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:o(`arcSidebar.desktopTitle`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:b,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,U?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":W,title:o(`sidebarPin.withShortcut`,{label:W,shortcut:`⌥⌘B`}),children:(0,Q.jsx)(Fr,{className:`w-4 h-4`})})]}),Re&&(0,Q.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[w&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{C.startNewConversation(l),v&&m(`/`)},className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`bg-accent-primary/15 text-accent-primary hover:bg-accent-primary/25`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`newAgent`),title:V?void 0:s(`newAgent`),children:[(0,Q.jsx)(pt,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`newAgent`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:S,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(w?`switchToKanban`:`switchToAgent`),title:s(w?`switchToKanban`:`switchToAgent`),children:[w?(0,Q.jsx)(xr,{className:`w-4 h-4 flex-shrink-0`}):(0,Q.jsx)(wn,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),V&&(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:s(w?`switchToKanban`:`switchToAgent`)})]}),w&&(0,Q.jsxs)(`button`,{type:`button`,onClick:JV,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`search`),title:V?void 0:s(`search`),children:[(0,Q.jsx)(ht,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`search`)})]})]}),we&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`py-2 px-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,V?`px-2`:`px-0 justify-center`,g?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.loops`),"aria-current":g?`page`:void 0,title:V?void 0:o(`arcSidebar.loops`),children:[(0,Q.jsx)(vi,{className:X(`w-4 h-4 flex-shrink-0`,g&&`text-accent-primary`)}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.loops`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:X(`mt-0.5 flex items-center gap-2 w-full h-8 rounded-md transition-colors`,V?`px-2`:`px-0 justify-center`,_?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.plugins`),"aria-current":_?`page`:void 0,title:V?void 0:o(`arcSidebar.plugins`),children:[(0,Q.jsx)(Hr,{className:X(`w-4 h-4 flex-shrink-0`,_&&`text-accent-primary`)}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.plugins`)})]})]}),(0,Q.jsx)(`div`,{className:`border-t border-border`,"aria-hidden":!0})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1.5 space-y-0.5`,children:[w&&E.length>0&&(0,Q.jsxs)(`div`,{className:`mb-2 space-y-0.5 border-b border-border/70 pb-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>N(XV),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`favoriteMissions`),"aria-expanded":A,title:V?void 0:s(`favoriteMissions`),children:[V?(0,Q.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Q.jsx)(pr,{className:`h-4 w-4 fill-current text-accent-primary transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,Q.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:A?(0,Q.jsx)(pe,{className:`w-3.5 h-3.5`}):(0,Q.jsx)(xe,{className:`w-3.5 h-3.5`})})]}):(0,Q.jsx)(pr,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),V&&(0,Q.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`favoriteMissions`)})]}),A&&V&&(0,Q.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:E.map(e=>(0,Q.jsx)(ZV,{conversation:e,active:e.id===C.active?.id,streaming:C.streamingConversationIds.has(e.id),unread:C.unreadConversationIds.has(e.id),favorite:!0,expanded:V,onSelect:()=>P(e.id),onToggleFavorite:()=>L(e.id),onDelete:()=>F(e.id)},e.id))})]}),w&&D.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>N(YV),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`home`),"aria-expanded":O.has(YV),title:V?void 0:s(`home`),children:[V?(0,Q.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Q.jsx)(hr,{className:`h-4 w-4 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,Q.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:O.has(YV)?(0,Q.jsx)(pe,{className:`w-3.5 h-3.5`}):(0,Q.jsx)(xe,{className:`w-3.5 h-3.5`})})]}):(0,Q.jsx)(hr,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`home`)})]}),O.has(YV)&&V&&(0,Q.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:D.map(e=>(0,Q.jsx)(ZV,{conversation:e,active:e.id===C.active?.id,streaming:C.streamingConversationIds.has(e.id),unread:C.unreadConversationIds.has(e.id),expanded:V,onSelect:()=>P(e.id),onToggleFavorite:()=>L(e.id),onDelete:()=>F(e.id)},e.id))})]}),c.map(e=>{let t=T.get(e.id)??[];return(0,Q.jsx)(QV,{project:e,isActive:e.id===l&&!v,expanded:V,onSelect:()=>R(e.id),onRemove:()=>te(e),agentMode:w,hasTree:t.length>0,treeOpen:O.has(e.id),onToggleTree:()=>N(e.id),conversations:t,activeConversationId:C.active?.id??null,streamingConversationIds:C.streamingConversationIds,unreadConversationIds:C.unreadConversationIds,onSelectConversation:P,onToggleConversationFavorite:L,onDeleteConversation:F,onOpenProjectSettings:w?()=>{d(e.id),M(!0)}:void 0},e.id)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":o(`projects.addProject`),title:V?void 0:o(`projects.addProject`),children:[(0,Q.jsx)(pt,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`projects.addProject`)})]})]}),(0,Q.jsx)(`div`,{className:`border-t border-border py-2 px-1.5 space-y-0.5`,children:ee.map(({label:e,icon:t,action:n})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":e,title:V?void 0:e,children:[(0,Q.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:e})]},e))}),j&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(WV,{open:!0,onClose:()=>M(!1)})})]})}function tH({open:e,onClose:t,onCommitted:n,projectId:r,milestoneId:i,blueprint:a}){let{t:o}=I(`builder`),{registerHandler:s,unregisterHandler:c}=Et(),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=(0,Z.useRef)(r),D=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{T.current=l},[l]),(0,Z.useEffect)(()=>{E.current=r},[r]);let O=a.milestones.find(e=>e.id===i),k=i.toUpperCase(),A=(0,Z.useMemo)(()=>rV(_??h,{milestoneLabel:k,minSpecs:1,maxSpecs:10,requireScaffold:!1}),[h,_,k]);(0,Z.useEffect)(()=>{if(!e||l)return;let t=!1;return fetch(`${Ot()}/chat/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`milestone`,milestone:i})}).then(e=>e.json()).then(e=>{if(t||!e.conversation)return;u(e.conversation.id);let n=O?.plannedSpecs??[],r={label:k,title:O?.title??k,planned:n.join(`; `)},i=n.length>0?o(`prompts.milestoneSeedWithPlanned`,r):o(`prompts.milestoneSeed`,r);f([{role:`user`,content:i}]),S(!0),fetch(`${Ot()}/chat/conversations/${e.conversation.id}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:i})}).catch(()=>{S(!1),R.error(o(`errors.turnFailed`))})}).catch(()=>{t||R.error(o(`errors.startFailed`))}),()=>{t=!0}},[e,l,i,O,k,o]),(0,Z.useEffect)(()=>{if(!e)return;let t=`milestone-generate-${i}`;return s(t,e=>{let t=e;if(t.conversationId===T.current&&!(t.projectId&&t.projectId!==E.current))if(t.type===`chat_stream`)m(e=>(e??``)+String(t.delta??``));else if(t.type===`chat_done`){m(null),S(!1);let e=String(t.fullText??``),n=RB(e);f(t=>[...t,{role:`assistant`,content:n.stripped.trim()||e}]),n.blueprint&&(g(n.blueprint),v(n.rawBlueprint))}else t.type===`chat_error`&&(m(null),S(!1),R.error(o(`errors.turnFailed`),{description:String(t.error??``)}))}),()=>c(t)},[e,i,s,c,o]),(0,Z.useEffect)(()=>{D.current?.scrollTo?.({top:D.current.scrollHeight})},[d,p]);let j=(0,Z.useCallback)(e=>{let t=T.current,n=e.trim();!t||!n||x||(f(e=>[...e,{role:`user`,content:n}]),b(``),S(!0),fetch(`${Ot()}/chat/conversations/${t}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n})}).catch(()=>{S(!1),R.error(o(`errors.turnFailed`))}))},[x,o]),M=(0,Z.useCallback)(()=>{let e=_??h,r=e&&typeof e==`object`&&!Array.isArray(e)?e:null,a=Array.isArray(r?.m1Specs)?r.m1Specs:[];!A.valid||C||(w(!0),fetch(`${Ot()}/blueprint/commit-milestone`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({milestoneId:i,specsComplete:r?.specsComplete,specs:a})}).then(async e=>{if(e.status===201){let r=await e.json();R.success(o(`milestone.commitToast`,{count:r.insertedIds.length,label:k})),n?.(),t()}else{let t=await e.json().catch(()=>({}));R.error(o(`milestone.commitFailed`),{description:t.detail??t.error})}}).catch(()=>R.error(o(`milestone.commitFailed`))).finally(()=>w(!1)))},[h,_,A.valid,C,i,k,t,n,o]);if(!e)return null;let N=h?.m1Specs.length??0;return(0,Q.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-sm`,"data-testid":`milestone-shell`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/40 px-4 py-2.5`,children:[(0,Q.jsx)(dr,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsx)(`h1`,{className:`text-sm font-semibold`,children:o(`milestone.title`,{label:k})}),O&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O.title}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":o(`shell.close`),"data-testid":`milestone-close`,children:(0,Q.jsx)(yt,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col border-r border-border/40`,children:[(0,Q.jsxs)(`div`,{ref:D,className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[d.map((e,t)=>(0,Q.jsx)(`div`,{className:X(`max-w-[85%] whitespace-pre-wrap rounded-lg px-3 py-2 text-xs leading-relaxed`,e.role===`user`?`ml-auto bg-accent-primary/15`:`bg-surface/70`),children:e.content},t)),p!==null&&(0,Q.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-lg bg-surface/70 px-3 py-2 text-xs leading-relaxed`,children:[zB(p),(0,Q.jsx)(`span`,{className:`ml-0.5 inline-block h-3 w-1.5 animate-pulse bg-accent-primary/70 align-middle`})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-border/40 p-3`,children:[(0,Q.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),j(y))},rows:2,placeholder:o(`milestone.inputPlaceholder`),className:`min-h-[2.5rem] flex-1 resize-none rounded-md border border-border/40 bg-surface/50 px-3 py-2 text-xs focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`}),(0,Q.jsx)(Y,{size:`sm`,onClick:()=>j(y),disabled:x||!y.trim()||!l,children:x?(0,Q.jsx)(ut,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(ei,{className:`h-3.5 w-3.5`})})]})]}),(0,Q.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col lg:w-96`,children:[(0,Q.jsx)(mV,{blueprint:h,milestoneLabel:k}),(0,Q.jsxs)(`div`,{className:`border-t border-border/40 p-3`,children:[(0,Q.jsxs)(Y,{className:`w-full`,size:`sm`,disabled:!A.valid||C,onClick:M,"data-testid":`milestone-commit`,children:[C?(0,Q.jsx)(ut,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),o(`milestone.commit`,{count:N,label:k})]}),!A.valid&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,"data-testid":`milestone-quality-detail`,children:A.issues[0]?.message})]})]})]})]})}function nH(e,t=0){let[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(!e){r(null);return}let t=!1;return fetch(`/api/projects/${e}/blueprint`,{cache:`no-store`}).then(e=>e.ok?e.json():null).then(e=>{t||r(e?LB(e.blueprint):null)}).catch(()=>{t||r(null)}),()=>{t=!0}},[e,t]),n}function rH(e,t){return e.milestones.map((e,n)=>{let r=n+1,i=KB(r),a=t.filter(e=>Array.isArray(e.labels)&&e.labels.includes(i));return{id:e.id,title:e.title,status:e.status,n:r,done:a.filter(e=>e.status===`done`).length,total:a.length}})}function iH({expanded:e}){let{t}=I(`builder`),{activeProjectId:n}=At(),[r,i]=(0,Z.useState)(0),a=nH(n,r),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!o||!n)return;let e=!1;return fetch(`${Ot()}/tickets`,{cache:`no-store`}).then(e=>e.json()).then(t=>{e||l(Array.isArray(t)?t:t.tickets??[])}).catch(()=>{}),()=>{e=!0}},[o,n]),(0,Z.useEffect)(()=>{if(!o)return;let e=e=>{m.current&&!m.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let h=(0,Z.useCallback)(async()=>{if(!(!n||u)){d(!0);try{let e=await JB(n,1);e.ok?(R.success(t(`done.launchToast`,{count:e.ticketCount})),s(!1)):R.error(t(`done.launchFailed`),{description:e.detail??e.reason})}finally{d(!1)}}},[n,u,t]);if(!a||!n)return null;let g=rH(a,c),_=c.some(e=>e.status===`todo`&&e.labels?.includes(`M1`)),v=g.find(e=>e.status===`planned`&&e.n>1);return(0,Q.jsxs)(`div`,{ref:m,className:`relative`,"data-testid":`builder-sidebar-entry`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,e?`px-2`:`px-0 justify-center`,o?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:e?void 0:t(`sidebar.title`),"data-testid":`builder-sidebar-toggle`,children:[(0,Q.jsx)(dr,{className:`w-4 h-4 flex-shrink-0`}),e&&(0,Q.jsx)(`span`,{className:`text-xs truncate`,children:t(`sidebar.title`)})]}),o&&(0,Q.jsxs)(`div`,{className:`absolute bottom-0 right-full z-[60] mr-2 w-64 rounded-lg border border-border/50 bg-background p-3 shadow-xl`,"data-testid":`builder-sidebar-panel`,children:[(0,Q.jsx)(`h4`,{className:`text-xs font-semibold`,children:t(`sidebar.title`)}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:g.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/30 px-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] font-semibold text-accent-primary`,children:t(`sidebar.milestone`,{n:e.n})}),(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium`,children:e.title}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] tabular-nums text-muted-foreground`,children:t(`sidebar.progress`,{done:e.done,total:e.total})})]}),e.total>0&&(0,Q.jsx)(`div`,{className:`mt-1 h-1 overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent-success transition-all`,style:{width:`${Math.round(e.done/e.total*100)}%`}})})]},e.id||e.n))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[_&&(0,Q.jsxs)(`button`,{type:`button`,onClick:h,disabled:u,className:`inline-flex items-center justify-center gap-1.5 rounded-md bg-accent-primary/15 px-2 py-1.5 text-[11px] font-medium text-accent-primary transition-colors hover:bg-accent-primary/25 disabled:opacity-50`,"data-testid":`sidebar-launch-m1`,children:[u?(0,Q.jsx)(ut,{className:`h-3 w-3 animate-spin`}):(0,Q.jsx)(Yr,{className:`h-3 w-3`}),t(`sidebar.launchM1`)]}),v&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{p(v.id),s(!1)},className:`inline-flex items-center justify-center gap-1.5 rounded-md border border-accent-highlight/40 px-2 py-1.5 text-[11px] font-medium text-accent-highlight transition-colors hover:bg-accent-highlight/10`,title:t(`sidebar.generateHint`),"data-testid":`sidebar-generate-next`,children:[(0,Q.jsx)(gt,{className:`h-3 w-3`}),t(`sidebar.generateNext`,{n:v.n})]})]})]}),f&&(0,Q.jsx)(tH,{open:!0,onClose:()=>p(null),onCommitted:()=>i(e=>e+1),projectId:n,milestoneId:f,blueprint:a})]})}var aH={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function oH(){let{t:e}=I(`nav`),{rightMode:t,cycleRightMode:n}=fE(),{projects:r,activeProjectId:i}=At(),[a,o]=(0,Z.useState)(!1),s=t===`pinned-open`||t===`unpinned`&&a,c=t!==`unpinned`,l=e(aH[t]),u=r.find(e=>e.id===i),d=u?kt(u):[`claude`],f=nt&&vh(`agents`,d),p=[{to:`/`,end:!0,icon:Sr,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:Dn,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:kn,label:e(`rightSidebar.analytics`)},...f?[{to:`/agents`,end:!1,icon:wn,label:e(`rightSidebar.agents`)}]:[],...it?[{to:`/code`,end:!1,icon:zn,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:ni,label:e(`rightSidebar.settings`)}];return(0,Q.jsxs)(`div`,{className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0`,`transition-all duration-200 ease-in-out overflow-hidden`,s?`w-44`:`w-11`),onMouseEnter:()=>{t===`unpinned`&&o(!0)},onMouseLeave:()=>{t===`unpinned`&&o(!1)},children:[(0,Q.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,s?`px-3 justify-between`:`justify-center`),children:[s&&(0,Q.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`rightSidebar.projectTitle`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,c?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":l,title:e(`sidebarPin.withShortcut`,{label:l,shortcut:`⌘B`}),children:(0,Q.jsx)(Ir,{className:`w-4 h-4`})})]}),(0,Q.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,Q.jsx)(iH,{expanded:s}),p.map(({to:e,end:t,icon:n,label:r})=>(0,Q.jsxs)(h,{to:e,end:t,className:({isActive:e})=>X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,s?`px-2`:`px-0 justify-center`,e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:s?void 0:r,children:[(0,Q.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}),s&&(0,Q.jsx)(`span`,{className:`text-xs truncate`,children:r})]},e))]})]})}function sH(e){return{darwin:{title:`macOS`,intro:e(`setup:instructions.darwin.intro`),commands:[{label:e(`setup:instructions.darwin.installNodeGit`),command:`brew install node git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`},{label:`Homebrew`,url:`https://brew.sh`}]},win32:{title:`Windows`,intro:e(`setup:instructions.win32.intro`),commands:[{label:e(`setup:instructions.win32.installNode`),command:`winget install OpenJS.NodeJS.LTS`},{label:e(`setup:instructions.win32.installGit`),command:`winget install Git.Git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitWindows`),url:`https://git-scm.com/download/win`}],note:e(`setup:instructions.win32.note`)},linux:{title:`Linux`,intro:e(`setup:instructions.linux.intro`),commands:[{label:e(`setup:instructions.linux.debian`),command:`sudo apt install -y nodejs npm git`},{label:e(`setup:instructions.linux.fedora`),command:`sudo dnf install -y nodejs npm git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`}]}}}var cH=[`darwin`,`win32`,`linux`];async function lH(e){try{if(navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function uH({command:e}){let{t}=I(`setup`),[n,r]=(0,Z.useState)(!1);return(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await lH(e)&&(r(!0),window.setTimeout(()=>r(!1),1500))},className:`h-7 px-2 gap-1.5 text-[11px]`,"data-testid":`install-copy-button`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(be,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Un,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function dH({platform:e,primary:t}){let{t:n}=I(`setup`),r=sH(n)[e];return(0,Q.jsxs)(`section`,{"data-testid":`install-section-${e}`,className:X(`rounded-lg border px-3 py-3`,t?`border-border/40 bg-background/40`:`border-border/20 bg-background/20`),children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r.title}),r.intro&&(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r.intro}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-2`,children:r.commands.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/30 bg-background/60 px-2 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-1`,children:e.label}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`code`,{className:`text-xs text-foreground font-mono break-all`,children:e.command}),(0,Q.jsx)(uH,{command:e.command})]})]},e.command))}),r.links.length>0&&(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1`,children:r.links.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-accent-info hover:underline`,children:[e.label,(0,Q.jsx)(J,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function fH(){let{t:e}=I(`setup`),[t,n]=(0,Z.useState)(`idle`);return(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{n(`copying`);try{let e=await fetch(`${xt}/api/setup-prerequisites?diagnostic=1`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();await navigator.clipboard.writeText(JSON.stringify(t,null,2)),n(`copied`),setTimeout(()=>n(`idle`),1800)}catch{n(`error`),setTimeout(()=>n(`idle`),2400)}},disabled:t===`copying`,className:`gap-1.5 text-[11px]`,"data-testid":`copy-diagnostics-button`,children:[t===`copied`?(0,Q.jsx)(be,{className:`w-3 h-3 text-accent-success`}):(0,Q.jsx)(In,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function pH({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=I(`setup`),[o,s]=(0,Z.useState)(!1),c=n?.platform??`darwin`,l=cH.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,Q.jsx)(nn,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Zt,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:a(`instructions.corrupted.title`)}),(0,Q.jsx)(en,{children:a(`instructions.corrupted.description`)})]}),(0,Q.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`instructions.corrupted.body`)}),(0,Q.jsx)(`div`,{className:`flex justify-end mt-2`,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,"data-testid":`install-corrupted-close-button`,children:a(`common:actions.close`)})})]})}):(0,Q.jsx)(nn,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Zt,{movableResizable:!0,className:`max-w-xl`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:a(`instructions.title`)}),(0,Q.jsx)(en,{children:a(`instructions.description`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(dH,{platform:c,primary:!0}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground underline-offset-2 hover:underline`,"data-testid":`install-toggle-others`,children:a(o?`instructions.hideOtherPlatforms`:`instructions.showOtherPlatforms`)}),o&&(0,Q.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,Q.jsx)(dH,{platform:e,primary:!1},e))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,Q.jsx)(fH,{}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:a(`common:actions.close`)}),(0,Q.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,onClick:r,disabled:i,className:`gap-1.5`,"data-testid":`install-recheck-button`,children:[(0,Q.jsx)(qr,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var mH=typeof window<`u`&&`__TAURI_INTERNALS__`in window,hH=[`claude`,`codex`,`gemini`],gH={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`}};function _H(e){let t=hH.filter(t=>t in e),n=Object.keys(e).filter(e=>!hH.includes(e));return[...t,...n]}function vH({open:e,onClose:t,onOpenBuilder:n}){let r=Pe&&!!n,[i,a]=(0,Z.useState)(r?`choose`:`existing`),[o,s]=(0,Z.useState)(new Set([`claude`])),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)({claude:!0,codex:!1}),[_,v]=(0,Z.useState)(!1),{t:y}=I(`setup`),{addProject:b,startSetupWizard:x,setActiveProjectId:S}=At(),{status:C,isLoading:w,error:T,recheck:E}=sT(),D=(0,Z.useMemo)(()=>{if(!C||C.ok)return null;let e=C.missingRequired.map(e=>e.label);return e.length===0?null:y(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[C,y]),O=C!==null&&!C.ok&&!T;(0,Z.useEffect)(()=>{e&&fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n!==`tiers`&&(t[n]=!!r);g(t);let n=new Set;for(let e of _H(t))t[e]&&n.add(e);n.size===0&&n.add(`claude`),s(n)}).catch(()=>{})},[e]);function k(e){s(t=>{let n=new Set(t);if(n.has(e)){if(n.size===1)return t;n.delete(e)}else n.add(e);return n})}let A=_H(h).filter(e=>o.has(e)&&h[e]);async function j(){let e=l.trim();if(!e){R.error(y(`addProject.errors.pathRequired`));return}if(A.length===0){R.error(y(`addProject.errors.selectProvider`));return}m(!0);try{let t=await b(e,d.trim()||void 0,A);if(!t)return;let{project:n}=t;t.has_specrails===!1?(M(),S(n.id),x(n.id)):(R.success(y(`addProject.toasts.registered`,{name:n.name})),M())}catch(e){R.error(y(`addProject.errors.addFailed`),{description:e.message})}finally{m(!1)}}function M(){u(``),f(``),a(r?`choose`:`existing`),t()}function N(e){e||M()}let P=!Object.values(h).some(Boolean);return i===`choose`?(0,Q.jsx)(nn,{open:e,onOpenChange:N,children:(0,Q.jsxs)(Zt,{className:`max-w-md`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsxs)(Qt,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(rr,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,Q.jsx)(en,{children:y(`addProject.chooser.description`)})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 py-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`chooser-existing`,onClick:()=>a(`existing`),className:`flex flex-col items-start gap-2 rounded-lg border border-border/40 p-4 text-left transition-colors hover:border-accent-primary/50 hover:bg-accent-primary/5 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[(0,Q.jsx)(nr,{className:`h-5 w-5 text-accent-info`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.existingTitle`)}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.existingDescription`)})]}),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`chooser-new`,onClick:()=>{M(),n?.()},className:`flex flex-col items-start gap-2 rounded-lg border border-border/40 p-4 text-left transition-colors hover:border-accent-highlight/50 hover:bg-accent-highlight/5 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[(0,Q.jsx)(gt,{className:`h-5 w-5 text-accent-highlight`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.newTitle`)}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.newDescription`)})]})]})]})}):(0,Q.jsx)(nn,{open:e,onOpenChange:N,children:(0,Q.jsxs)(Zt,{movableResizable:!0,className:`max-w-md`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsxs)(Qt,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(rr,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,Q.jsx)(en,{children:y(`addProject.description`)})]}),P&&(0,Q.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:y(`addProject.noProviderDetected`)}),(0,Q.jsx)(lT,{status:C,isLoading:w,error:T,onMoreInfo:()=>v(!0),onRefresh:E}),(0,Q.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.pathLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(ox,{placeholder:y(`addProject.pathPlaceholder`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&j()},autoFocus:!0,className:`flex-1`}),mH&&(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,title:y(`addProject.browseForFolder`),onClick:async()=>{try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-Bt2zW2YG.js`);return{open:e}},[]),t=await e({directory:!0,multiple:!1,title:y(`addProject.selectProjectFolder`)});typeof t==`string`&&t&&(u(t),d||f(t.split(`/`).filter(Boolean).pop()??``))}catch{}},children:(0,Q.jsx)(rr,{className:`w-4 h-4`})})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.pathHint`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.nameLabel`),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:y(`addProject.optional`)})]}),(0,Q.jsx)(ox,{placeholder:y(`addProject.namePlaceholder`),value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&j()}}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.nameHint`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:y(`addProject.providersLabel`)}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:_H(h).map(e=>{let{icon:t,label:n}=gH[e]??{icon:`•`,label:e},r=h[e],i=o.has(e)&&r;return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":i,disabled:!r,onClick:()=>k(e),"data-testid":`provider-toggle-${e}`,className:X(`flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-left transition-colors text-xs`,`focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,i?`border-accent-primary/60 bg-accent-primary/10 text-foreground`:`border-border/30 text-muted-foreground hover:border-border/60`,!r&&`opacity-40 cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:X(`inline-flex h-3.5 w-3.5 items-center justify-center rounded-sm border text-[9px] leading-none`,i?`border-accent-primary bg-accent-primary text-background`:`border-border/50`),"aria-hidden":!0,children:i?`✓`:``}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n}),!r&&(0,Q.jsx)(`span`,{className:`text-[9px] text-muted-foreground/60`,children:y(`addProject.notFound`)})]},e)})}),(0,Q.jsx)(`p`,{className:`text-[9px] text-muted-foreground/70`,children:A.length>1?y(`addProject.multiProviderHint`):y(`addProject.singleProviderHint`)})]})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:t,disabled:p,children:y(`common:actions.cancel`)}),(0,Q.jsx)(Y,{size:`sm`,onClick:j,disabled:p||!l.trim()||P||A.length===0||O||w,title:O?D??void 0:void 0,"data-testid":`add-project-submit`,children:y(p?`addProject.adding`:`addProject.submit`)})]}),(0,Q.jsx)(pH,{open:_,onClose:()=>v(!1),status:C,onRecheck:E,isRechecking:w})]})})}var yH=1,bH=.9,xH=.8,SH=.17,CH=.1,wH=.999,TH=.9999,EH=.99,DH=/[\\\/_+.#"@\[\(\{&]/,OH=/[\\\/_+.#"@\[\(\{&]/g,kH=/[\s-]/,AH=/[\s-]/g;function jH(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?yH:EH;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=jH(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=yH:DH.test(e.charAt(l-1))?(d*=xH,p=e.slice(i,l-1).match(OH),p&&i>0&&(d*=wH**+p.length)):kH.test(e.charAt(l-1))?(d*=bH,m=e.slice(i,l-1).match(AH),m&&i>0&&(d*=wH**+m.length)):(d*=SH,i>0&&(d*=wH**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=TH)),(d<CH&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=jH(e,t,n,r,l+1,a+2,o),f*CH>d&&(d=f*CH)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function MH(e){return e.toLowerCase().replace(AH,` `)}function NH(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,jH(e,t,MH(e),MH(t),0,0,{})}var PH=`[cmdk-group=""]`,FH=`[cmdk-group-items=""]`,IH=`[cmdk-group-heading=""]`,LH=`[cmdk-item=""]`,RH=`${LH}:not([aria-disabled="true"])`,zH=`cmdk-item-select`,BH=`data-value`,VH=(e,t,n)=>NH(e,t,n),HH=Z.createContext(void 0),UH=()=>Z.useContext(HH),WH=Z.createContext(void 0),GH=()=>Z.useContext(WH),KH=Z.createContext(void 0),qH=Z.forwardRef((e,t)=>{let n=sU(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=sU(()=>new Set),i=sU(()=>new Map),a=sU(()=>new Map),o=sU(()=>new Set),s=aU(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=on(),y=on(),b=on(),x=Z.useRef(null),S=uU();oU(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),oU(()=>{S(6,k)},[]);let C=Z.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Z.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??VH;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(FH);t?t.appendChild(e.parentElement===t?e:e.closest(`${FH} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${FH} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${PH}[${BH}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(BH);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(PH)?.querySelector(IH))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${LH}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(RH)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(BH))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(BH))}function P(e){let t=A()?.closest(PH),n;for(;t&&!n;)t=e>0?rU(t,PH):iU(t,PH),n=t?.querySelector(RH);n?C.setState(`value`,n.getAttribute(BH)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Z.createElement(Rt.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(zH);t.dispatchEvent(e)}}}}},Z.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:pU},c),fU(e,e=>Z.createElement(WH.Provider,{value:C},Z.createElement(HH.Provider,{value:w},e))))}),JH=Z.forwardRef((e,t)=>{let n=on(),r=Z.useRef(null),i=Z.useContext(KH),a=UH(),o=aU(e),s=o.current?.forceMount??i?.forceMount;oU(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=lU(n,r,[e.value,e.children,r],e.keywords),l=GH(),u=cU(e=>e.value&&e.value===c.current),d=cU(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);Z.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(zH,f),()=>t.removeEventListener(zH,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Z.createElement(Rt.div,{ref:Nt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),YH=Z.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=on(),s=Z.useRef(null),c=Z.useRef(null),l=on(),u=UH(),d=cU(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));oU(()=>u.group(o),[]),lU(o,s,[e.value,e.heading,c]);let f=Z.useMemo(()=>({id:o,forceMount:i}),[i]);return Z.createElement(Rt.div,{ref:Nt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&Z.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),fU(e,e=>Z.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Z.createElement(KH.Provider,{value:f},e))))}),XH=Z.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Z.useRef(null),a=cU(e=>!e.search);return!n&&!a?null:Z.createElement(Rt.div,{ref:Nt(i,t),...r,"cmdk-separator":``,role:`separator`})}),ZH=Z.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=GH(),o=cU(e=>e.search),s=cU(e=>e.selectedItemId),c=UH();return Z.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Z.createElement(Rt.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),QH=Z.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Z.useRef(null),o=Z.useRef(null),s=cU(e=>e.selectedItemId),c=UH();return Z.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Z.createElement(Rt.div,{ref:Nt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},fU(e,e=>Z.createElement(`div`,{ref:Nt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),$H=Z.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Z.createElement(Gt,{open:n,onOpenChange:r},Z.createElement(Wt,{container:o},Z.createElement(rn,{"cmdk-overlay":``,className:i}),Z.createElement(Yt,{"aria-label":e.label,"cmdk-dialog":``,className:a},Z.createElement(qH,{ref:t,...s}))))}),eU=Z.forwardRef((e,t)=>cU(e=>e.filtered.count===0)?Z.createElement(Rt.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),tU=Z.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Z.createElement(Rt.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},fU(e,e=>Z.createElement(`div`,{"aria-hidden":!0},e)))}),nU=Object.assign(qH,{List:QH,Item:JH,Input:ZH,Group:YH,Separator:XH,Dialog:$H,Empty:eU,Loading:tU});function rU(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function iU(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function aU(e){let t=Z.useRef(e);return oU(()=>{t.current=e}),t}var oU=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function sU(e){let t=Z.useRef();return t.current===void 0&&(t.current=e()),t}function cU(e){let t=GH(),n=()=>e(t.snapshot());return Z.useSyncExternalStore(t.subscribe,n,n)}function lU(e,t,n,r=[]){let i=Z.useRef(),a=UH();return oU(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(BH,s),i.current=s}),i}var uU=()=>{let[e,t]=Z.useState(),n=sU(()=>new Map);return oU(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function dU(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function fU({asChild:e,children:t},n){return e&&Z.isValidElement(t)?Z.cloneElement(dU(t),{ref:t.ref},n(t.props.children)):n(t)}var pU={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function mU({onOpenSettings:e,onOpenAnalytics:t,onOpenDocs:n}){let{t:r}=I(`commands`),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),{projects:u,activeProjectId:d,setActiveProjectId:f}=At(),{leftMode:m,rightMode:h,cycleLeftMode:g,cycleRightMode:_}=fE(),v=r(m===`pinned-open`?`palette.sidebar.collapseLeftKeepPinned`:m===`pinned-collapsed`?`palette.sidebar.unpinLeft`:`palette.sidebar.pinLeftOpen`),y=r(h===`pinned-open`?`palette.sidebar.collapseRightKeepPinned`:h===`pinned-collapsed`?`palette.sidebar.unpinRight`:`palette.sidebar.pinRightOpen`),b=p(),x=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,Z.useEffect)(()=>{if(!i){x.current=!1;return}if(x.current)return;x.current=!0;async function e(){try{let[e,t]=await Promise.all([fetch(`${Ot()}/config`),fetch(`${Ot()}/jobs?limit=10`)]);if(e.ok){let t=await e.json();s(t.commands)}if(t.ok){let e=await t.json();l(e.jobs)}}catch{}}e()},[i]);let S=(0,Z.useCallback)(e=>{f(e),a(!1)},[f]),C=(0,Z.useCallback)(async e=>{a(!1);try{let t=await fetch(`${Ot()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:`/specrails:${e}`})}),n=await t.json();if(!t.ok)throw Error(n.error??r(`errors.spawnFailed`));R.success(r(`toasts.queued`,{name:e})),b(`/jobs/${n.jobId}`)}catch(e){R.error(e instanceof Error?e.message:r(`errors.spawnFailed`))}},[b,r]),w=(0,Z.useCallback)(e=>{a(!1),b(`/jobs/${e}`)},[b]),T=(0,Z.useCallback)(e=>{a(!1),b(e)},[b]),E=(0,Z.useCallback)(e=>{e&&(a(!1),e())},[]),D=`flex items-center gap-3 px-3 py-2 rounded-lg cursor-pointer text-sm data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground`;return(0,Q.jsxs)(nU.Dialog,{open:i,onOpenChange:a,label:r(`palette.label`),className:X(`fixed left-[50%] top-[50%] z-50 w-full max-w-lg translate-x-[-50%] translate-y-[-50%]`,`border border-border/30 bg-popover shadow-2xl backdrop-blur-md rounded-xl overflow-hidden`),children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:r(`palette.label`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border/30`,children:[(0,Q.jsx)(ht,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(nU.Input,{placeholder:r(`palette.searchPlaceholder`),className:`flex-1 h-11 bg-transparent text-sm outline-none placeholder:text-muted-foreground/50`}),(0,Q.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-0.5 rounded border border-border/50 bg-muted/30 px-1.5 py-0.5 text-[10px] text-muted-foreground font-mono`,children:`esc`})]}),(0,Q.jsxs)(nU.List,{className:`max-h-80 overflow-y-auto p-2`,children:[(0,Q.jsx)(nU.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`palette.noResults`)}),u.length>0&&(0,Q.jsx)(nU.Group,{heading:r(`palette.groups.projects`),children:u.map(e=>(0,Q.jsxs)(nU.Item,{value:e.name,keywords:[e.slug],onSelect:()=>S(e.id),className:X(D,e.id===d&&`text-accent-primary`),children:[(0,Q.jsx)(rr,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),e.id===d&&(0,Q.jsx)(`span`,{className:`text-[10px] text-accent-primary font-medium`,children:r(`palette.activeBadge`)})]},e.id))}),o.length>0&&(0,Q.jsx)(nU.Group,{heading:r(`palette.groups.spec`),children:o.map(e=>(0,Q.jsxs)(nU.Item,{value:e.name,keywords:[e.slug,e.description??``],onSelect:()=>C(e.slug),className:D,children:[(0,Q.jsx)(bt,{className:`w-4 h-4 text-accent-info shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),e.description&&(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60 ml-2 truncate`,children:e.description})]})]},e.id))}),c.length>0&&(0,Q.jsx)(nU.Group,{heading:r(`palette.groups.jobs`),children:c.map(e=>(0,Q.jsxs)(nU.Item,{value:`${e.command} ${e.id}`,keywords:[e.status],onSelect:()=>w(e.id),className:D,children:[(0,Q.jsx)(Dn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e.command}),(0,Q.jsx)(`span`,{className:X(`text-[10px] font-medium`,e.status===`completed`&&`text-accent-success`,e.status===`failed`&&`text-destructive`,e.status===`running`&&`text-accent-info`,e.status===`queued`&&`text-muted-foreground`),children:r(`common:status.${e.status}`,{defaultValue:e.status})})]},e.id))}),(0,Q.jsxs)(nU.Group,{heading:r(`palette.groups.navigation`),children:[(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.dashboard`),keywords:[`home`],onSelect:()=>T(`/`),className:D,children:[(0,Q.jsx)(Sr,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.dashboard`)})]}),t&&(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.desktopAnalytics`),keywords:[`cross-project`,`desktop`],onSelect:()=>E(t),className:D,children:[(0,Q.jsx)(jn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.desktopAnalytics`)})]}),(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.projectAnalytics`),keywords:[`metrics`],onSelect:()=>T(`/analytics`),className:D,children:[(0,Q.jsx)(kn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.projectAnalytics`)})]}),(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.activityFeed`),keywords:[`log`],onSelect:()=>T(`/activity`),className:D,children:[(0,Q.jsx)(vn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.activityFeed`)})]}),(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.desktopSettings`),keywords:[`configuration`],onSelect:()=>e?E(e):T(`/settings`),className:D,children:[(0,Q.jsx)(ni,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.desktopSettings`)})]}),(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.docs`),keywords:[`documentation`],onSelect:()=>n?E(n):T(`/docs`),className:D,children:[(0,Q.jsx)(ct,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.docs`)})]}),(0,Q.jsxs)(nU.Item,{value:v,keywords:[`sidebar`,`panel`,`left`,`pin`,`collapse`,`unpin`,`cycle`],onSelect:()=>{g(),a(!1)},className:D,children:[(0,Q.jsx)(Fr,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:v})]}),(0,Q.jsxs)(nU.Item,{value:y,keywords:[`sidebar`,`panel`,`right`,`nav`,`pin`,`collapse`,`unpin`,`cycle`],onSelect:()=>{_(),a(!1)},className:D,children:[(0,Q.jsx)(Ir,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:y})]})]})]}),(0,Q.jsx)(`div`,{className:`flex items-center justify-between px-3 py-2 border-t border-border/30 text-[10px] text-muted-foreground/50`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{className:`font-mono`,children:`↑↓`}),` `,r(`palette.footer.navigate`)]}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{className:`font-mono`,children:`↵`}),` `,r(`palette.footer.select`)]}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{className:`font-mono`,children:`esc`}),` `,r(`palette.footer.close`)]})]})})]})}var hU=`
|
|
63
|
+
`))}function fB(e,t){let n=(e??``).normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),r=t.trim()||`mission`;return`${n||r}.txt`}function pB(){let{t:e}=I(`agent`),{active:t,messages:n,renameConversation:r,deleteConversation:i,startNewConversation:a,favoriteConversationIds:o,toggleFavoriteConversation:s}=UV(),{projects:c}=At(),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=t?.pinned_project_id?c.find(e=>e.id===t.pinned_project_id)??null:null,S=t?.title?.trim()||e(`header.untitled`),C=t?o.has(t.id):!1;(0,Z.useEffect)(()=>{if(!l)return;let e=e=>{y.current&&!y.current.contains(e.target)&&u(!1)},t=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]),(0,Z.useEffect)(()=>{l||v(!1)},[l]),(0,Z.useEffect)(()=>{d&&(b.current?.focus(),b.current?.select())},[d]);let w=(0,Z.useCallback)(()=>{m(t?.title??``),f(!0),u(!1)},[t?.title]),T=(0,Z.useCallback)(async()=>{if(t&&(f(!1),(t.title??``)!==p.trim()))try{await r(t.id,p)}catch{R.error(e(`header.renameFailed`))}},[t,p,r,e]),E=(0,Z.useCallback)(async(t,n)=>{u(!1);try{await navigator.clipboard.writeText(t),g(n),setTimeout(()=>g(e=>e===n?null:e),1400)}catch{R.error(e(`header.copyFailed`))}},[e]),D=(0,Z.useCallback)(async()=>{if(t){u(!1);try{await navigator.clipboard.writeText(dB(t,n,x)),g(`transcript`),R.success(e(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>g(e=>e===`transcript`?null:e),1400)}catch{R.error(e(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[t,n,x,e]),O=(0,Z.useCallback)(()=>{if(t){u(!1);try{let r=dB(t,n,x),i=new Blob([r],{type:`text/plain;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=fB(t.title,t.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),R.success(e(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{R.error(e(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[t,n,x,e]),k=(0,Z.useCallback)(async()=>{if(t){u(!1),v(!1);try{await i(t.id),a(t.pinned_project_id)}catch{R.error(e(`header.deleteFailed`))}}},[t,i,a,e]),A=(0,Z.useCallback)(()=>{t&&(s(t.id),u(!1))},[t,s]);if(!t)return null;let j=[{id:`name`,label:e(`header.copyName`),value:t.title??S},{id:`id`,label:e(`header.copyId`),value:t.id},...x?[{id:`project`,label:e(`header.copyProject`),value:x.name},{id:`path`,label:e(`header.copyProjectPath`),value:x.path}]:[]];return(0,Q.jsxs)(`div`,{ref:y,"data-agent-interactive":!0,className:`relative flex h-12 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm`,children:[x&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:x.path,children:x.path}),(0,Q.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),d?(0,Q.jsx)(`input`,{ref:b,value:p,onChange:e=>m(e.target.value),onBlur:()=>void T(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),T()):e.key===`Escape`&&(e.preventDefault(),f(!1))},placeholder:e(`header.renamePlaceholder`),className:`min-w-0 flex-1 rounded-md border border-accent-primary/40 bg-surface/60 px-2 py-0.5 text-sm text-foreground outline-none focus:border-accent-primary/70`,maxLength:200}):(0,Q.jsx)(`button`,{type:`button`,onDoubleClick:w,title:e(`header.renameHint`),className:`min-w-0 flex-1 truncate text-left font-medium text-foreground/85`,children:S})]}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-menu-trigger`,"aria-label":e(`header.menu`),"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(e=>!e),className:X(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground/45 transition-colors hover:bg-surface hover:text-foreground/80`,l&&`bg-surface text-foreground/80`),children:(0,Q.jsx)(Yn,{className:`h-4 w-4`})}),(0,Q.jsx)(MF,{children:l&&(0,Q.jsx)(ML.div,{role:`menu`,"data-testid":`agent-conv-menu`,initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.14,ease:`easeOut`},className:`absolute right-3 top-11 z-50 min-w-[220px] overflow-hidden rounded-xl border border-border/50 bg-card/95 p-1 shadow-2xl backdrop-blur-xl`,children:_?(0,Q.jsxs)(`div`,{className:`p-2`,"data-testid":`agent-conv-delete-confirm`,children:[(0,Q.jsx)(`p`,{className:`px-1 pb-2.5 text-xs leading-relaxed text-foreground/70`,children:e(`header.deleteConfirm`)}),(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-delete-confirm-btn`,onClick:()=>void k(),className:`flex-1 rounded-lg bg-destructive/90 px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-destructive`,children:e(`header.delete`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`flex-1 rounded-lg border border-border/60 px-2.5 py-1.5 text-xs text-foreground/80 transition-colors hover:bg-surface/80`,children:e(`common:actions.cancel`)})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-rename`,onClick:w,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Q.jsx)(dt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),e(`header.rename`)]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-favorite`,onClick:A,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Q.jsx)(pr,{className:X(`h-3.5 w-3.5 shrink-0`,C?`text-accent-primary`:`text-foreground/50`),fill:C?`currentColor`:`none`}),e(C?`header.removeFavorite`:`header.addFavorite`)]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-delete`,onClick:()=>v(!0),className:`group/del flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-destructive/10 hover:text-destructive`,children:[(0,Q.jsx)(_t,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),e(`header.delete`)]}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border/50`}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-transcript`,onClick:()=>void D(),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===`transcript`?(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,Q.jsx)(Un,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-export-transcript`,onClick:O,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[(0,Q.jsx)(st,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.exportTranscript`,{defaultValue:`Export transcript (.txt)`})})]}),j.map(e=>e===`divider`?null:(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-${e.id}`,onClick:()=>void E(e.value,e.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-sm text-foreground/85 transition-colors hover:bg-surface/80`,children:[h===e.id?(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,Q.jsx)(Un,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]},e.id))]})})})]})}var mB=new Set([`building`,`on_review`,`pr_draft`,`no_changes`,`pr_closed`,`implementation_failed`,`pr_failed`]);function hB(e){return mB.has(e)}function gB(e){let t=[];for(let[n,r]of e.entries()){if(r.role!==`system`)continue;let e=ME(r.content);e&&t.push({messageId:r.id,envelope:e,position:n})}let n=new Map;for(let e of t){let t=n.get(e.envelope.prDeliveryId);if(!t){n.set(e.envelope.prDeliveryId,e);continue}let r=bv(t.envelope.updatedAt,e.envelope.updatedAt);(r===1||r===null&&e.position>t.position)&&n.set(e.envelope.prDeliveryId,e)}let r=new Set(t.map(({envelope:e})=>e.supersedesDeliveryId).filter(e=>!!e)),i=new Set,a=[...n.values()];for(let e of a){let t=e.envelope.restoredFromDeliveryId;if(!t)continue;let n=null;for(let t of a){if(t.envelope.supersedesDeliveryId!==e.envelope.prDeliveryId)continue;if(!n){n=t;continue}let r=bv(n.envelope.createdAt,t.envelope.createdAt);(r===1||(r===0||r===null)&&t.position>n.position)&&(n=t)}n&&n.envelope.prDeliveryId!==t||(r.delete(e.envelope.prDeliveryId),r.add(t),i.add(t))}let o=new Map;for(let e of n.values()){if(r.has(e.envelope.prDeliveryId))continue;let t=o.get(e.envelope.railIndex)??[];t.push(e),o.set(e.envelope.railIndex,t)}for(let e of o.values()){if(e.length<=1)continue;let t=e[0];for(let n of e.slice(1))bv(t.envelope.createdAt,n.envelope.createdAt)===1&&(t=n);for(let n of e)n.envelope.prDeliveryId!==t.envelope.prDeliveryId&&r.add(n.envelope.prDeliveryId)}let s=t.map(e=>r.has(e.envelope.prDeliveryId)&&(e.envelope.decision!==`superseded`||i.has(e.envelope.prDeliveryId))?{...e,envelope:{...e.envelope,decision:i.has(e.envelope.prDeliveryId)?`discarded`:`superseded`}}:e),c=new Map,l=new Set,u=[];for(let e of s){if(n.get(e.envelope.prDeliveryId)?.messageId!==e.messageId){l.add(e.messageId);continue}c.set(e.messageId,e.envelope),hB(e.envelope.decision)&&u.push(e)}return{byMessageId:c,duplicateMessageIds:l,pinned:u}}var _B=(0,Z.lazy)(()=>c(()=>import(`./JobDetailModal-I_RoQJV4.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75]))),vB=(0,Z.lazy)(()=>c(()=>import(`./LoopPreviewModal-BC-TeFdD.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([76,1,2,3,40,5,6,45,56,64,65,66,67,77,52,54,57,68,42]))),yB=new Set;function bB({variant:e}){let{t}=I(`agent`),{active:n,messages:r,streamingText:i,isStreaming:a,liveTools:o,queuedMessages:s,mcpEnabled:c,enablingMcp:l,enableMcpServer:u,providersReady:d,cycleTier:f,send:p}=UV(),m=(0,Z.useRef)(null),h=Hg(i,a),{openRef:g,jobRef:_,closeJobRef:v,loopRef:y,closeLoopRef:b}=FL(),x=n?.pinned_project_id??null,[S,C]=(0,Z.useState)(new Map),w=(0,Z.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.attachment_ids??[])e.add(n);return[...e].sort()},[r]).join(`\0`);(0,Z.useEffect)(()=>{let e=w?w.split(`\0`):[];if(!n?.id||e.length===0){C(new Map);return}let t=!1,r=new Set(e);return CE(n.id).then(e=>{t||C(new Map(e.filter(e=>r.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||C(new Map)}),()=>{t=!0}},[n?.id,w]);let T=(0,Z.useMemo)(()=>x?e=>{g(x,e)}:void 0,[x,g]),E=kb().id===`code-rain`?t(`emptyTitleCodeRain`):t(`emptyTitle`),D=(0,Z.useMemo)(()=>gB(r),[r]),O=(0,Z.useRef)(!0),k=()=>{let e=m.current;e&&(O.current=e.scrollHeight-e.scrollTop-e.clientHeight<48)};(0,Z.useEffect)(()=>{O.current&&m.current?.scrollTo?.({top:m.current.scrollHeight,behavior:`auto`})},[r.length,h,o.length,s.length]);let A=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),f())},j=e===`inline`,M=j?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden `,onKeyDown:A,children:[d===!1&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,Q.jsx)(Mr,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-warning`}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:t(`noProvider.title`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:t(`noProvider.body`)})]})]}),d!==!1&&!c&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:[(0,Q.jsx)(ri,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:t(`degraded.body`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void u(),disabled:l,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:t(l?`degraded.enabling`:`degraded.enable`)})]}),j&&n&&(0,Q.jsx)(pB,{}),(0,Q.jsxs)(`div`,{className:M,children:[(0,Q.jsxs)(ML.div,{ref:m,onScroll:k,initial:j?{opacity:0,y:8}:!1,animate:{opacity:1,y:0},transition:{duration:.35,ease:`easeOut`},className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[r.length===0&&!a&&(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,Q.jsx)(wn,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:E}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:t(`emptyHint`)})]}),r.map((e,n)=>{if(e.role===`system`){let n=D.byMessageId.get(e.id);return n?hB(n.decision)?(0,Q.jsxs)(`div`,{"data-testid":`agent-pr-pinned-marker`,className:`flex items-center gap-2 rounded-lg border border-border/40 bg-surface/30 px-3 py-1.5 text-[11px] text-foreground/45 backdrop-blur-sm`,children:[(0,Q.jsx)(zr,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(`prCard.pinned.marker`)}),(0,Q.jsx)(nB,{decision:n.decision})]},e.id):(0,Q.jsx)(eB,{envelope:n},e.id):(D.duplicateMessageIds.has(e.id)||yB.has(e.id)||(yB.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}return(0,Q.jsx)(FR,{role:e.role,content:e.content,createdAt:e.created_at,isLast:!a&&n===r.length-1,onPickOption:e=>void p(e),refsProjectId:x,onOpenRef:T,contextRefs:e.context_refs,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>S.get(e)).filter(e=>!!e)},e.id)}),a&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,Q.jsx)(FR,{role:`assistant`,content:h,streaming:!0}),(0,Q.jsx)(RL,{tool:o.length?o[o.length-1].tool:null})]}),s.length>0&&(0,Q.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:s.map(e=>(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-br-sm border border-dashed border-border/70 bg-foreground/[0.03] px-3.5 py-2 text-sm text-foreground/60`,children:[(0,Q.jsxs)(`span`,{className:`mb-0.5 flex items-center justify-end gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,Q.jsx)(Ln,{className:`h-3 w-3`}),t(`queue.queued`)]}),(0,Q.jsx)(PR,{content:e.text,contextRefs:e.contextRefs})]})},e.queueId))})]}),(0,Q.jsx)(MF,{initial:!1,children:n&&D.pinned.length>0&&(0,Q.jsx)(lB,{pinned:D.pinned,conversationId:n.id,inline:j},`agent-pr-pinned-dock`)}),j?(0,Q.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,Q.jsx)(ML.div,{layoutId:`agent-composer-dock`,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`mx-auto w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`,children:(0,Q.jsx)(Rz,{})})}):(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-surface/30 p-3`,children:(0,Q.jsx)(Rz,{hideProjectSelector:!0})})]}),_&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(_B,{jobId:_.jobId,projectId:_.projectId,onClose:v})}),y&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(vB,{loop:y,onClose:b})})]})}var xB=8,SB=3e3;function CB(){let{t:e}=I(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=UV(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useMemo)(()=>{let e=e=>{let t=Date.parse(e.updated_at);return Number.isNaN(t)?0:t};return[...t].sort((t,n)=>e(n)-e(t))},[t]),b=t.length>xB,x=(0,Z.useMemo)(()=>{let t=u.trim().toLowerCase();if(!t)return y;let n=e(`mission.untitled`).toLowerCase();return y.filter(e=>(e.title?.trim().toLowerCase()||n).includes(t))},[y,u,e]),S=x.length+1,C=(0,Z.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=null,h(null)},[]);(0,Z.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]),(0,Z.useEffect)(()=>{if(!c)return;let e=e=>{_.current&&!_.current.contains(e.target)&&T()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let w=()=>{let e=n?y.findIndex(e=>e.id===n.id):-1;p(e>=0?e+1:0),l(!0)},T=()=>{l(!1),d(``),C()},E=e=>{e!==n?.id&&r(e),T()},D=()=>{a(null),T()},O=e=>{g.current&&clearTimeout(g.current),h(e),g.current=setTimeout(()=>{h(null),g.current=null},SB)},k=async t=>{C();let a=n?.id===t,o=y.find(e=>e.id!==t)??null;try{await i(t),a&&o&&await r(o.id)}catch{R.error(e(`mission.deleteFailed`))}},A=()=>{if(f===0)D();else{let e=x[f-1];e&&E(e.id)}},j=e=>{if(!c){e.key===`ArrowDown`&&(e.preventDefault(),w());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p(e=>(e+t+S)%S)}else e.key===`Home`?(e.preventDefault(),p(0)):e.key===`End`?(e.preventDefault(),p(S-1)):e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m?C():(T(),v.current?.focus()))},M=n?.title?.trim()||e(`mission.untitled`);return(0,Q.jsxs)(`div`,{className:`relative min-w-0`,ref:_,"data-agent-interactive":!0,onKeyDown:j,children:[(0,Q.jsxs)(`button`,{ref:v,type:`button`,"data-testid":`mission-trigger`,onClick:()=>c?T():w(),"aria-haspopup":`listbox`,"aria-expanded":c,"aria-controls":`agent-mission-listbox`,title:e(`mission.label`),className:`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground hover:bg-surface/70`,children:[(0,Q.jsx)(_e,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:M}),(0,Q.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,Q.jsx)(MF,{children:c&&(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.16,ease:`easeOut`},className:`absolute left-0 top-full z-10 mt-1 w-72 overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,children:[b&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Q.jsx)(ht,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,Q.jsx)(`input`,{autoFocus:!0,value:u,onChange:e=>{d(e.target.value),p(0)},placeholder:e(`mission.searchPlaceholder`),className:`w-full bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`})]}),(0,Q.jsxs)(`div`,{id:`agent-mission-listbox`,role:`listbox`,"aria-label":e(`mission.label`),"aria-activedescendant":`agent-mission-opt-${f}`,className:`max-h-72 overflow-y-auto py-1`,children:[(0,Q.jsxs)(ML.div,{id:`agent-mission-opt-0`,role:`option`,"aria-selected":!1,tabIndex:-1,"data-testid":`mission-new`,onClick:D,onMouseEnter:()=>p(0),initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14},className:`flex w-full cursor-pointer items-center gap-2.5 px-3 py-1.5 text-left text-sm font-medium text-foreground ${f===0?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,Q.jsx)(pt,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),x.length>0&&(0,Q.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),x.length===0&&u.trim()!==``&&(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),x.map((e,t)=>(0,Q.jsx)(wB,{conversation:e,index:t+1,highlighted:f===t+1,activeId:n?.id??null,streaming:o.has(e.id),queuedCount:s.get(e.id)?.queued.length??0,confirming:m===e.id,onHover:()=>p(t+1),onSelect:()=>E(e.id),onArmDelete:()=>O(e.id),onConfirmDelete:()=>void k(e.id),onCancelDelete:C},e.id))]})]})})]})}function wB({conversation:e,index:t,highlighted:n,activeId:r,streaming:i,queuedCount:a,confirming:o,onHover:s,onSelect:c,onArmDelete:l,onConfirmDelete:u,onCancelDelete:d}){let{t:f}=I(`agent`),p=e.title?.trim()||f(`mission.untitled`),m=e.id===r;return o?(0,Q.jsxs)(`div`,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,"data-testid":`mission-row-${e.id}`,className:`flex w-full items-center gap-2 bg-destructive/10 px-3 py-1.5 text-sm`,children:[(0,Q.jsx)(_t,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-destructive`,children:f(i?`mission.deleteLiveConfirm`:`mission.deleteConfirm`)}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-yes`,onClick:e=>{e.stopPropagation(),u()},"aria-label":f(`mission.confirmDelete`),className:`rounded-md p-1 text-destructive hover:bg-destructive/20`,children:(0,Q.jsx)(be,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`mission-confirm-no`,onClick:e=>{e.stopPropagation(),d()},"aria-label":f(`mission.cancelDelete`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface`,children:(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`})})]}):(0,Q.jsxs)(ML.div,{id:`agent-mission-opt-${t}`,role:`option`,"aria-selected":m,tabIndex:-1,"data-testid":`mission-row-${e.id}`,onClick:c,onMouseEnter:s,initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.14,delay:Math.min(t*.03,.18)},className:`group flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-sm text-foreground ${n?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-foreground/40`,title:nE(e.updated_at),children:tE(e.updated_at)}),i&&(0,Q.jsxs)(`span`,{"data-testid":`mission-live-${e.id}`,"aria-label":f(`mission.working`),className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,Q.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,Q.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),a>0&&(0,Q.jsx)(`span`,{"data-testid":`mission-queued-${e.id}`,"aria-label":f(`mission.queuedBadge`,{n:a}),title:f(`mission.queuedBadge`,{n:a}),className:`shrink-0 rounded-full border border-border/60 bg-surface px-1.5 text-[9px] font-semibold leading-4 text-foreground/60`,children:a}),m&&(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`mission-delete-${e.id}`,onClick:e=>{e.stopPropagation(),l()},"aria-label":f(`mission.delete`,{title:p}),className:`shrink-0 rounded-md p-0.5 text-foreground/50 opacity-0 transition-opacity hover:bg-surface hover:text-destructive focus-visible:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100`,children:(0,Q.jsx)(_t,{className:`h-3.5 w-3.5`})})]})}function TB({active:e,inset:t=-4,radius:n=`9999px`,className:r}){let i=jL();return(0,Q.jsx)(MF,{children:e&&(0,Q.jsxs)(ML.span,{"aria-hidden":!0,"data-testid":`builder-halo`,"data-reduced-motion":i?`true`:void 0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.15},transition:{duration:.35,ease:`easeOut`},style:{inset:t},className:`pointer-events-none absolute ${r??``}`,children:[(0,Q.jsx)(`span`,{className:`absolute inset-0 overflow-hidden`,style:{borderRadius:n,padding:`2px`,WebkitMask:`linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)`,WebkitMaskComposite:`xor`,maskComposite:`exclude`},children:(0,Q.jsx)(`span`,{className:`absolute left-1/2 top-1/2 aspect-square w-[250%] -translate-x-1/2 -translate-y-1/2 ${i?``:`animate-[builder-halo-spin_2.6s_linear_infinite]`}`,style:{background:`conic-gradient(from 0deg, transparent 0%, color-mix(in srgb, var(--color-accent-primary) 90%, transparent) 18%, color-mix(in srgb, var(--color-accent-highlight) 85%, transparent) 32%, transparent 55%)`}})}),(0,Q.jsx)(`span`,{className:`absolute inset-0 opacity-60`,style:{borderRadius:n,boxShadow:`0 0 12px 2px color-mix(in srgb, var(--color-accent-primary) 45%, transparent), inset 0 0 8px 1px color-mix(in srgb, var(--color-accent-highlight) 30%, transparent)`}})]})})}var EB=/```blueprint-draft\s*\n([\s\S]*?)\n\s*```/g,DB=/```blueprint-draft(?![\s\S]*?\n\s*```)/,OB=new Set([`planned`,`committed`,`done`]),kB=new Set([`scaffold`,`feature`,`verification`]),AB=new Set([`critical`,`high`,`medium`,`low`]);function jB(e){return typeof e==`string`?e:``}function MB(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function NB(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{name:jB(t.name),pitch:jB(t.pitch),audience:jB(t.audience)}}function PB(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={language:jB(t.language),framework:jB(t.framework),db:jB(t.db)};return typeof t.notes==`string`&&t.notes!==``&&(n.notes=t.notes),n}function FB(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=jB(e.id),i=jB(e.title);if(r===``&&i===``)continue;let a={id:r,title:i,goal:jB(e.goal),status:OB.has(e.status)?e.status:`planned`,plannedSpecs:MB(e.plannedSpecs)};if(Array.isArray(e.ticketIds)){let t=e.ticketIds.filter(e=>typeof e==`number`&&Number.isInteger(e));t.length>0&&(a.ticketIds=t)}t.push(a)}return t}function IB(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=jB(e.title);if(r===``)continue;let i={kind:kB.has(e.kind)?e.kind:`feature`,title:r,shortSummary:jB(e.shortSummary),description:jB(e.description),acceptanceCriteria:MB(e.acceptanceCriteria),priority:AB.has(e.priority)?e.priority:`medium`,labels:MB(e.labels)};typeof e.dependsOnIndex==`number`&&Number.isInteger(e.dependsOnIndex)&&e.dependsOnIndex>=0&&(i.dependsOnIndex=e.dependsOnIndex),t.push(i)}return t}function LB(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.blueprintVersion!=`number`||!Number.isInteger(t.blueprintVersion)?null:{blueprintVersion:t.blueprintVersion,product:NB(t.product),coreFlow:jB(t.coreFlow),platform:jB(t.platform),stack:PB(t.stack),assumptions:MB(t.assumptions),milestones:FB(t.milestones),specsComplete:t.specsComplete===!0,m1Specs:IB(t.m1Specs)}}function RB(e){if(!e||!e.includes("```blueprint-draft"))return{stripped:e??``,blueprint:null,rawBlueprint:null,hadBlocks:!1};let t=null,n=null,r=!1,i=``,a=0;EB.lastIndex=0;let o;for(;(o=EB.exec(e))!==null;){r=!0,i+=e.slice(a,o.index),a=o.index+o[0].length;try{let e=JSON.parse(o[1]),r=LB(e);r&&(t=r,n=e)}catch{}}return i+=e.slice(a),{stripped:i,blueprint:t,rawBlueprint:n,hadBlocks:r}}function zB(e){if(!e||!e.includes("```blueprint-draft"))return e??``;let t=DB.exec(e);return t?e.slice(0,t.index):e}function BB(e){return e?{product:e.product.name!==``&&e.product.pitch!==``,coreFlow:e.coreFlow!==``,platform:e.platform!==``,stack:e.stack.language!==``||e.stack.framework!==``,milestones:e.milestones.length>0}:{product:!1,coreFlow:!1,platform:!1,stack:!1,milestones:!1}}var VB={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`}};function HB(e){return e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`project`}function UB({blueprint:e,onSubmit:t,onBack:n,submitting:r,error:i,errorDetail:a}){let{t:o}=I(`builder`),{status:s}=sT(),[c,l]=(0,Z.useState)(e.product.name||``),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(new Set([`claude`])),[g,_]=(0,Z.useState)({claude:!0}),[v,y]=(0,Z.useState)(!1),b=(0,Z.useMemo)(()=>`~/projects/${HB(c)}`,[c]),x=u?f:b;(0,Z.useEffect)(()=>{fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n!==`tiers`&&(t[n]=!!r);_(t);let n=new Set;for(let[e,r]of Object.entries(t))r&&n.add(e);n.size>0&&h(n)}).catch(()=>{})},[]);let S=s?.prerequisites.find(e=>e.key===`gh`),C=!!(S?.installed&&S?.executable!==!1),w=C&&!!S?.authenticated,T=[`claude`,`codex`,`gemini`,...Object.keys(g)].filter((e,t,n)=>n.indexOf(e)===t).filter(e=>m.has(e)&&g[e]),E=c.trim()!==``&&x.trim()!==``&&T.length>0&&!r;return(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col gap-4 p-6`,"data-testid":`commit-form`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:o(`commit.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`commit.description`)})]}),i&&(0,Q.jsxs)(`div`,{className:`rounded-md bg-destructive/10 p-2 text-xs text-destructive`,"data-testid":`commit-error`,children:[(0,Q.jsx)(`p`,{children:o(`commit.errors.${i}`,{defaultValue:o(`commit.errors.generic`)})}),a&&(0,Q.jsx)(`p`,{className:`mt-1 opacity-80`,children:a})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.nameLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsx)(ox,{value:c,onChange:e=>l(e.target.value),"data-testid":`commit-name`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.locationLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsx)(ox,{value:x,onChange:e=>{d(!0),p(e.target.value)},"data-testid":`commit-location`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:o(`commit.locationHint`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:o(`commit.providersLabel`)}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:Object.keys(g).map(e=>{let{icon:t,label:n}=VB[e]??{icon:`•`,label:e},r=g[e],i=m.has(e)&&r;return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":i,disabled:!r,"data-testid":`commit-provider-${e}`,onClick:()=>{h(t=>{let n=new Set(t);if(n.has(e)){if(n.size===1)return t;n.delete(e)}else n.add(e);return n})},className:X(`flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors`,i?`border-accent-primary/60 bg-accent-primary/10`:`border-border/30 text-muted-foreground`,!r&&`cursor-not-allowed opacity-40`),children:[(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n})]},e)})})]}),C&&(0,Q.jsxs)(`label`,{className:X(`flex items-center gap-2 rounded-md border border-border/30 px-3 py-2 text-xs`,!w&&`opacity-50`),children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:v&&w,disabled:!w,onChange:e=>y(e.target.checked),"data-testid":`commit-github`}),(0,Q.jsx)(cr,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:o(`commit.githubLabel`)}),!w&&(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:o(`commit.githubAuthHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between pt-2`,children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:n,disabled:r,children:o(`commit.back`)}),(0,Q.jsxs)(Y,{size:`sm`,disabled:!E,"data-testid":`commit-submit`,onClick:()=>t({name:c.trim(),location:x.trim(),providers:T,createGithubRepo:v&&w}),children:[(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),o(r?`commit.creating`:`commit.submit`)]})]})]})}var WB=[`claude`,`codex`,`gemini`];function GB({session:e,autoFocus:t=!1}){let{t:n}=I(`builder`),{t:r}=I(`agent`),i=()=>{!e.draft.trim()||e.busy||!e.conversationReady||(e.send(e.draft),e.setDraft(``))};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,Q.jsx)(dr,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:n(`mode.title`)})]}),(0,Q.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(hz,{label:r(`provider.label`),value:e.provider,options:WB.map(e=>({value:e,label:r(`provider.${e}`)})),icon:wn,onSelect:e.setProvider,disabled:e.busy||!e.conversationReady,testId:`builder-provider-selector`}),(0,Q.jsx)(bz,{models:e.models,model:e.model,onSelect:e.setModel,disabled:e.busy||!e.conversationReady,testId:`builder-model-selector`}),e.efforts.length>0&&(0,Q.jsx)(hz,{label:r(`effort.label`),value:e.effort,options:e.efforts.map(e=>({value:e,label:r(`effort.${e}`)})),icon:ar,onSelect:e.setEffort,disabled:e.busy||!e.conversationReady,testId:`builder-effort-selector`}),e.showSurpriseMe&&(0,Q.jsxs)(`button`,{type:`button`,onClick:e.surpriseMe,disabled:e.busy||!e.conversationReady,className:`ml-auto inline-flex items-center gap-1.5 rounded-full border border-accent-highlight/40 bg-accent-highlight/10 px-3 py-1 text-[11px] text-accent-highlight transition-colors hover:bg-accent-highlight/20 disabled:opacity-40`,"data-testid":`surprise-me`,children:[(0,Q.jsx)(gt,{className:`h-3 w-3`}),n(`shell.surpriseMe`)]})]}),(0,Q.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border border-border/60 bg-background/60 px-3 py-2`,children:[(0,Q.jsx)(`textarea`,{value:e.draft,autoFocus:t,onChange:t=>e.setDraft(t.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),i())},rows:2,placeholder:n(`shell.inputPlaceholder`),"aria-label":n(`shell.inputPlaceholder`),"data-agent-interactive":!0,className:`min-h-[3.25rem] max-h-64 min-w-[12rem] flex-1 resize-y bg-transparent text-sm text-foreground outline-none placeholder:text-foreground/40`,"data-testid":`builder-input`}),(0,Q.jsx)(`button`,{type:`button`,onClick:i,disabled:e.busy||!e.draft.trim()||!e.conversationReady,"aria-label":r(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,"data-testid":`builder-send`,children:(0,Q.jsx)($r,{className:`h-4 w-4`})})]})]})}function KB(e){return`M${e}`}function qB(e,t){let n=KB(t);return e.filter(e=>e.status===`todo`&&Array.isArray(e.labels)&&e.labels.includes(n)).map(e=>e.id)}async function JB(e,t,n=fetch){let r=`/api/projects/${e}`,i=await n(`${r}/tickets`,{cache:`no-store`});if(!i.ok)return{ok:!1,reason:`no-tickets`};let a=await i.json(),o=qB(Array.isArray(a)?a:a.tickets??[],t);if(o.length===0)return{ok:!1,reason:`no-tickets`};let s=await n(`${r}/rails`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:KB(t)})});if(!s.ok)return{ok:!1,reason:`rail-create-failed`,detail:(await s.json().catch(()=>({}))).error};let{rail:c}=await s.json(),l=await n(`${r}/rails/${c.railIndex}/tickets`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({ticketIds:o,mode:`batch-implement`})});if(!l.ok)return{ok:!1,reason:`assign-failed`,detail:(await l.json().catch(()=>({}))).error};let u=await n(`${r}/rails/${c.railIndex}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:`batch-implement`})});return u.ok?{ok:!0,railIndex:c.railIndex,ticketCount:o.length}:{ok:!1,reason:`launch-failed`,detail:(await u.json().catch(()=>({}))).error}}var YB=[`Problem Statement`,`Proposed Solution`,`Out of Scope`,`Technical Considerations`,`Estimated Complexity`],XB=new Set([`scaffold`,`feature`,`verification`]),ZB=new Set([`critical`,`high`,`medium`,`low`]),QB=/^(?:todo|tbd|n\/?a|works?|test(?: it)?|criterion|acceptance criterion)$/i;function $B(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function eV(e){return e.trim().toLocaleLowerCase(`en-US`)}function tV(e){let t=[...e.matchAll(/^##[ \t]+(.+?)[ \t]*$/gm)],n=t.map(e=>e[1].trim()),r=new Map;return t.forEach((i,a)=>{let o=(i.index??0)+i[0].length,s=a+1<t.length?t[a+1].index??e.length:e.length;r.set(n[a],e.slice(o,s).trim())}),{headings:n,bodies:r}}function nV(e){return e.split(/\r?\n/).filter(e=>/^\s*[-*+]\s+\S/.test(e)).length}function rV(e,t){let n=[],r=$B(e),i=Array.isArray(r?.m1Specs)?r.m1Specs:[],a=t.milestoneLabel.trim().toUpperCase(),o=(e,t,r,i)=>{n.push({specIndex:e,field:t,code:r,message:i})};r?.specsComplete!==!0&&o(null,`specsComplete`,`batch_incomplete`,`Generation is not complete yet.`),(i.length<t.minSpecs||i.length>t.maxSpecs)&&o(null,`m1Specs`,`spec_count`,`The batch needs ${t.minSpecs}-${t.maxSpecs} specs.`);let s=new Map;return i.forEach((e,n)=>{let r=$B(e),i=n+1;if(!r){o(n,`spec`,`invalid_shape`,`Spec ${i} must be an object.`);return}let c=typeof r.kind==`string`?r.kind:``;XB.has(c)||o(n,`kind`,`invalid_kind`,`Spec ${i} needs a valid kind.`),t.requireScaffold&&n===0&&c!==`scaffold`&&o(n,`kind`,`scaffold_first`,`The first spec must be the project scaffold.`),t.requireScaffold&&n>0&&c===`scaffold`&&o(n,`kind`,`duplicate_scaffold`,`Spec ${i} cannot be another scaffold.`);let l=typeof r.title==`string`?r.title.trim():``;if(!l)o(n,`title`,`required`,`Spec ${i} needs a title.`);else{let e=eV(l),t=s.get(e);t===void 0?s.set(e,n):o(n,`title`,`duplicate`,`Spec ${i} duplicates spec ${t+1}.`)}let u=typeof r.shortSummary==`string`?r.shortSummary.trim():``;(!u||u.length>240||/[\r\n]/.test(u))&&o(n,`shortSummary`,`summary`,`Spec ${i} needs a one-line summary under 240 characters.`);let d=typeof r.priority==`string`?r.priority:``;ZB.has(d)||o(n,`priority`,`invalid_priority`,`Spec ${i} needs a valid priority.`);let f=typeof r.description==`string`?r.description.trim():``,p=tV(f);(!/^## Problem Statement(?:\r?\n|$)/.test(f)||p.headings.length!==YB.length||p.headings.some((e,t)=>e!==YB[t]))&&o(n,`description`,`canonical_sections`,`Spec ${i} is missing the canonical sections.`);for(let e of YB)(p.bodies.get(e)??``).trim()||o(n,`description`,`empty_section`,`Spec ${i} has an empty ${e} section.`);for(let e of[`Out of Scope`,`Technical Considerations`]){let t=p.bodies.get(e)??``;t&&nV(t)<2&&o(n,`description`,`section_bullets`,`Spec ${i} needs two ${e} bullets.`)}let m=p.bodies.get(`Estimated Complexity`)??``;m&&!/^(?:Low|Medium|High|Very High)\s*(?:[—\-:]\s*)\S/i.test(m)&&o(n,`description`,`complexity_format`,`Spec ${i} needs a justified complexity.`),t.requireScaffold&&n===0&&f&&!/\bREADME\b/i.test(f)&&o(n,`description`,`scaffold_readme`,`The scaffold spec must mention the existing README.`);let h=Array.isArray(r.acceptanceCriteria)?r.acceptanceCriteria:[];(h.length<4||h.length>10)&&o(n,`acceptanceCriteria`,`criteria_count`,`Spec ${i} needs 4-10 acceptance criteria.`);let g=new Set;h.forEach((e,t)=>{let r=typeof e==`string`?e.trim():``;if(r.length<10||QB.test(r)){o(n,`acceptanceCriteria`,`criterion_quality`,`Spec ${i} criterion ${t+1} is not concrete.`);return}let a=eV(r);g.has(a)&&o(n,`acceptanceCriteria`,`duplicate_criterion`,`Spec ${i} repeats an acceptance criterion.`),g.add(a)});let _=Array.isArray(r.labels)?r.labels.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean):[];new Set(_.map(e=>e.toUpperCase())).has(a)||o(n,`labels`,`milestone_label`,`Spec ${i} needs the ${a} label.`),_.every(e=>e.toUpperCase()===a)&&o(n,`labels`,`domain_label`,`Spec ${i} needs a domain label.`);let v=r.dependsOnIndex;v!==void 0&&(!Number.isInteger(v)||v<0||v>=n)&&o(n,`dependsOnIndex`,`invalid_dependency`,`Spec ${i} must depend only on an earlier spec.`),t.requireScaffold&&n===0&&v!==void 0&&o(n,`dependsOnIndex`,`scaffold_dependency`,`The scaffold cannot declare a dependency.`)}),{valid:n.length===0,issues:n}}var iV=new Set([`gh_not_installed`,`gh_not_authenticated`,`gh_scope`,`gh_repo_exists`,`gh_network`]);function aV(e){return`progress.githubErrors.${e&&iV.has(e)?e:`generic`}`}var oV=[`create-dir`,`git-init`,`assemble`,`blueprint`,`tickets`,`register`,`github`];function sV(e,t){let{t:n}=I(`builder`),{registerHandler:r,unregisterHandler:i}=Et(),{setActiveProjectId:a}=At(),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(`chat`),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)([]),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(`claude`),[L,z]=(0,Z.useState)(null),[B,V]=(0,Z.useState)([]),[H,U]=(0,Z.useState)([]),[W,ee]=(0,Z.useState)(`medium`),[te,G]=(0,Z.useState)(``),K=(0,Z.useRef)(null),ne=(0,Z.useRef)(null),re=(0,Z.useRef)(!1),ie=(0,Z.useRef)(W),ae=(0,Z.useRef)(H),oe=(0,Z.useRef)(!1),se=(0,Z.useRef)(t.onFinished);(0,Z.useEffect)(()=>{K.current=o},[o]),(0,Z.useEffect)(()=>{ne.current=w},[w]),(0,Z.useEffect)(()=>{ie.current=W},[W]),(0,Z.useEffect)(()=>{ae.current=H},[H]),(0,Z.useEffect)(()=>{se.current=t.onFinished},[t.onFinished]),(0,Z.useEffect)(()=>{if(!e||o)return;let t=!1;return fetch(`/api/blueprint/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).then(e=>e.json()).then(e=>{!t&&e.conversation&&(s(e.conversation.id),e.conversation.provider&&F(e.conversation.provider),z(e.conversation.model??null))}).catch(()=>{t||R.error(n(`errors.startFailed`))}),()=>{t=!0}},[e,o,n]),(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return V([]),U([]),fetch(`/api/blueprint/models?provider=${encodeURIComponent(P)}`).then(e=>e.json()).then(e=>{if(t)return;V(e.models??[]);let n=e.efforts??[];U(n),ee(e=>n.includes(e)?e:n.includes(`medium`)?`medium`:n[0]??`medium`)}).catch(()=>{}),()=>{t=!0}},[e,P]);let ce=(0,Z.useCallback)(e=>{F(e),z(null);let t=K.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).catch(()=>{})},[]),le=(0,Z.useCallback)(e=>{z(e);let t=K.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:e})}).catch(()=>{})},[]);(0,Z.useEffect)(()=>{if(!e)return;let t=`builder-session`;return r(t,e=>{let t=e,r=K.current!==null&&t.conversationId===K.current,i=ne.current!==null&&t.commitId===ne.current;if(t.type===`blueprint.stream`&&r)d(e=>(e??``)+String(t.delta??``));else if(t.type===`blueprint.done`&&r){d(null),_(!1);let e=String(t.fullText??``);l(t=>[...t,{role:`assistant`,content:e,createdAt:new Date().toISOString()}]);let n=LB(t.blueprint);if(n)p(n),h(t.rawBlueprint===void 0?t.blueprint:t.rawBlueprint);else{let t=RB(e);t.blueprint&&(p(t.blueprint),h(t.rawBlueprint))}}else if(t.type===`blueprint.error`&&r)d(null),_(!1),R.error(n(`errors.turnFailed`),{description:String(t.error??``)});else if(t.type===`blueprint.commit_progress`&&i){let e=String(t.step),r=t.status,i=typeof t.detail==`string`?t.detail:void 0,a=typeof t.code==`string`?t.code:void 0;e===`github`&&r===`warning`&&!re.current&&(re.current=!0,R.warning(n(aV(a)),{description:i})),D(t=>[...t.filter(t=>t.step!==e),{step:e,status:r,detail:i,code:a}])}else t.type===`blueprint.commit_done`&&i?(k(String(t.projectId)),y(`done`)):t.type===`blueprint.commit_failed`&&i&&(oe.current=!1,N(!1),R.error(n(`errors.commitFailed`),{description:String(t.error??``)}),y(`commit`),x(`commit_failed`),C(String(t.error??``)))}),()=>i(t)},[e,r,i,n]);let q=(0,Z.useCallback)(e=>{let t=K.current,r=e.trim();if(!t||!r||g)return;l(e=>[...e,{role:`user`,content:r,createdAt:new Date().toISOString()}]),_(!0);let i=ie.current,a=ae.current.includes(i);fetch(`/api/blueprint/conversations/${t}/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:r,...a?{reasoning_effort:i}:{}})}).then(e=>{!e.ok&&e.status!==202&&(_(!1),R.error(n(`errors.turnFailed`)))}).catch(()=>{_(!1),R.error(n(`errors.turnFailed`))})},[g,n]),ue=(0,Z.useCallback)(()=>q(n(`prompts.surpriseMe`)),[q,n]),de=(0,Z.useCallback)(e=>{!f||oe.current||(oe.current=!0,N(!0),x(null),C(null),D([]),re.current=!1,fetch(`/api/blueprint/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({blueprint:m??f,...e})}).then(async e=>{let t=await e.json().catch(()=>({}));e.status===202&&t.commitId?(T(t.commitId),ne.current=t.commitId,y(`progress`)):(x(t.error??`generic`),C(t.detail??null)),oe.current=!1,N(!1)}).catch(()=>{oe.current=!1,N(!1),x(`generic`),C(null)}))},[f,m]),fe=(0,Z.useCallback)(async()=>{if(!(!O||A)){j(!0);try{let e=await JB(O,1);e.ok?(R.success(n(`done.launchToast`,{count:e.ticketCount})),a(O),se.current()):R.error(n(`done.launchFailed`),{description:e.detail??e.reason})}finally{j(!1)}}},[O,A,a,n]),pe=(0,Z.useCallback)(()=>{O&&a(O),se.current()},[O,a]),me=(0,Z.useCallback)(()=>{let e=K.current;e&&fetch(`/api/blueprint/conversations/${e}/abort`,{method:`POST`}).catch(()=>{}),s(null),l([]),d(null),p(null),h(null),_(!1),y(`chat`),x(null),C(null),T(null),D([]),re.current=!1,k(null),j(!1),oe.current=!1,N(!1),F(`claude`),z(null),V([]),U([]),ee(`medium`),G(``)},[]),he=BB(f),ge=Object.values(he).some(Boolean)||c.length>0||te.trim().length>0,_e=(0,Z.useMemo)(()=>rV(m??f,{milestoneLabel:`M1`,minSpecs:5,maxSpecs:10,requireScaffold:!0}),[f,m]);return{phase:v,messages:c,streamBuffer:u,blueprint:f,busy:g,commitError:b,commitErrorDetail:S,commitSteps:E,createdProjectId:O,launching:A,submitting:M,conversationReady:o!==null,dirty:ge,canProposeCommit:_e.valid,specQualityDetail:_e.issues[0]?.message??null,showSurpriseMe:c.length<=1&&v===`chat`,provider:P,model:L,models:B,efforts:H,effort:W,draft:te,setDraft:G,setEffort:ee,setProvider:ce,setModel:le,send:q,surpriseMe:ue,goToCommit:()=>y(`commit`),backToChat:()=>y(`chat`),submitCommit:de,launchM1:fe,openProject:pe,abortAndReset:me}}var cV=`w-full rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`;function lV({variant:e}){let{t}=I(`builder`),{builderMode:n}=UV(),r=n.session,[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{o.current?.scrollTo?.({top:o.current.scrollHeight})},[r.messages,r.streamBuffer]);let s=(0,Z.useCallback)(()=>{r.dirty&&r.phase!==`done`?a(!0):n.exit()},[r.dirty,r.phase,n]),c=(0,Z.useCallback)(e=>{e.key===`Escape`&&(e.stopPropagation(),i?a(!1):r.phase===`commit`&&!r.submitting?r.backToChat():r.phase===`chat`&&s())},[i,r,s]),l=r.messages.length===0&&r.streamBuffer===null&&!r.busy,u=e===`inline`?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,Q.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,onKeyDown:c,"data-testid":`builder-conversation`,children:[r.phase===`chat`&&(l?(0,Q.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,Q.jsxs)(ML.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.34,1.56,.64,1]},className:X(`w-full`,e===`inline`?`max-w-[680px]`:`max-w-[560px]`),children:[(0,Q.jsxs)(`div`,{className:`mb-4 text-center`,children:[(0,Q.jsx)(gt,{className:`mx-auto h-7 w-7 text-accent-primary/60`}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium`,children:t(`shell.emptyTitle`)}),(0,Q.jsx)(`p`,{className:`mx-auto mt-1 max-w-sm text-xs text-muted-foreground`,children:t(`shell.emptyHint`)})]}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(TB,{active:!0,inset:-3,radius:`1rem`}),(0,Q.jsx)(ML.div,{layoutId:e===`inline`?`builder-composer-dock`:void 0,"data-testid":`builder-composer-card`,"data-composer-position":`hero`,"data-layout-id":e===`inline`?`builder-composer-dock`:void 0,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:cV,children:(0,Q.jsx)(GB,{session:r,autoFocus:!0})})]})]})}):(0,Q.jsxs)(`div`,{className:u,children:[(0,Q.jsxs)(`div`,{ref:o,className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,"data-testid":`builder-messages`,children:[r.messages.map((e,t)=>(0,Q.jsx)(FR,{role:e.role,content:e.content,createdAt:e.createdAt,isLast:r.streamBuffer===null&&!r.busy&&t===r.messages.length-1,onPickOption:e=>r.send(e)},`${t}-${e.createdAt}`)),(r.busy||r.streamBuffer!==null)&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[r.streamBuffer!==null&&zB(r.streamBuffer)&&(0,Q.jsx)(FR,{role:`assistant`,content:zB(r.streamBuffer),streaming:!0}),(0,Q.jsx)(RL,{tool:null})]})]}),(0,Q.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,Q.jsx)(ML.div,{layoutId:e===`inline`?`builder-composer-dock`:void 0,"data-testid":`builder-composer-card`,"data-composer-position":`docked`,"data-layout-id":e===`inline`?`builder-composer-dock`:void 0,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:X(cV,e===`inline`&&`mx-auto max-w-[680px]`),children:(0,Q.jsx)(GB,{session:r})})})]})),r.phase===`commit`&&r.blueprint&&(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto`,children:(0,Q.jsx)(UB,{blueprint:r.blueprint,onSubmit:r.submitCommit,onBack:r.backToChat,submitting:r.submitting,error:r.commitError,errorDetail:r.commitErrorDetail})}),r.phase===`progress`&&(0,Q.jsxs)(`div`,{className:`mx-auto mt-10 w-full max-w-md p-6`,"data-testid":`commit-progress`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:t(`progress.title`)}),(0,Q.jsx)(`ul`,{className:`mt-4 space-y-2`,children:oV.map(e=>{let n=r.commitSteps.find(t=>t.step===e);return!n&&e===`github`?null:(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[!n&&(0,Q.jsx)(Fn,{className:`h-3.5 w-3.5 text-muted-foreground/40`}),n?.status===`running`&&(0,Q.jsx)(ut,{className:`h-3.5 w-3.5 animate-spin text-accent-info`}),n?.status===`done`&&(0,Q.jsx)(be,{className:`h-3.5 w-3.5 text-accent-success`}),n?.status===`warning`&&(0,Q.jsx)(vt,{className:`h-3.5 w-3.5 text-accent-warning`}),n?.status===`failed`&&(0,Q.jsx)(yt,{className:`h-3.5 w-3.5 text-destructive`}),(0,Q.jsx)(`span`,{className:X(!n&&`text-muted-foreground/50`),children:t(`progress.steps.${e}`)}),n?.status===`warning`&&e===`github`?(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-accent-warning`,title:n.detail,children:t(aV(n.code))}):n?.detail&&(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,title:n.detail,children:n.detail})]},e)})})]}),r.phase===`done`&&(0,Q.jsxs)(`div`,{className:`mx-auto mt-12 w-full max-w-md p-6 text-center`,"data-testid":`commit-done`,children:[(0,Q.jsx)(be,{className:`mx-auto h-10 w-10 rounded-full bg-accent-success/15 p-2 text-accent-success`}),(0,Q.jsx)(`h2`,{className:`mt-3 text-sm font-semibold`,children:t(`done.title`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`done.description`)}),(0,Q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2`,children:[(0,Q.jsxs)(Y,{onClick:()=>void r.launchM1(),disabled:r.launching,"data-testid":`launch-m1`,children:[r.launching?(0,Q.jsx)(ut,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),t(`done.launchM1`)]}),(0,Q.jsx)(Y,{variant:`outline`,onClick:r.openProject,"data-testid":`open-project`,children:t(`done.openProject`)})]})]}),i&&(0,Q.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/70 backdrop-blur-sm`,"data-testid":`builder-exit-confirm`,children:(0,Q.jsxs)(`div`,{className:`w-72 rounded-lg border border-border/60 bg-card p-4 shadow-xl`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`builder-exit-confirm-title`,children:[(0,Q.jsx)(`p`,{id:`builder-exit-confirm-title`,className:`text-sm font-medium`,children:t(`mode.exitConfirmTitle`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`mode.exitConfirmBody`)}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>a(!1),"data-testid":`builder-exit-cancel`,children:t(`mode.exitConfirmCancel`)}),(0,Q.jsx)(Y,{variant:`destructive`,size:`sm`,onClick:()=>{a(!1),n.exit()},"data-testid":`builder-exit-confirm-btn`,children:t(`mode.exitConfirmDiscard`)})]})]})})]})}var uV=X(`text-sm leading-7 text-foreground`,`[&_p]:my-3 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold`,`[&_h2]:mt-4 [&_h2]:mb-1.5 [&_h2]:text-[15px] [&_h2]:font-semibold`,`[&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:text-sm [&_h3]:font-semibold`,`[&_strong]:font-semibold [&_strong]:text-foreground`,`[&_em]:italic`,`[&_a]:text-accent-info [&_a]:underline [&_a]:underline-offset-2`,`[&_ul]:my-2.5 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-2.5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-1`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-3`,`[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground`,`[&_hr]:my-3 [&_hr]:border-border/60`),dV={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`};function fV({spec:e,index:t,milestoneLabel:n=`M1`,onClose:r}){let{t:i}=I(`builder`),{t:a}=I(`tickets`),o=`blueprint-spec-summary-${t}`;return(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,Si.createPortal)((0,Q.jsxs)(`div`,{"data-testid":`blueprint-spec-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:r,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":e.title,"aria-describedby":e.shortSummary.trim()?o:void 0,className:`relative flex max-h-[82vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-border/40 bg-popover shadow-2xl backdrop-blur-md`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border/40 px-5 py-4`,children:[(0,Q.jsx)(ct,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-primary`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:i(`specModal.eyebrow`,{milestone:n,index:t+1})}),(0,Q.jsx)(`h2`,{className:`mt-0.5 text-base font-semibold text-foreground`,children:e.title}),e.shortSummary.trim()&&(0,Q.jsxs)(`p`,{id:o,className:`mt-1 text-xs leading-5 text-muted-foreground`,"data-testid":`blueprint-spec-summary`,children:[(0,Q.jsxs)(`span`,{className:`sr-only`,children:[i(`specModal.summary`),`: `]}),e.shortSummary]}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[(0,Q.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,dV[e.priority]),"data-testid":`blueprint-spec-priority`,"aria-label":`${i(`specModal.priority`)}: ${a(`priority.${e.priority}`)}`,children:a(`priority.${e.priority}`)}),e.labels.map(e=>(0,Q.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] text-accent-primary`,children:e},e)),e.dependsOnIndex!==void 0&&(0,Q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-[9px] text-muted-foreground`,children:i(`panel.dependsOn`,{index:e.dependsOnIndex+1})})]})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(`specModal.close`),"data-agent-interactive":!0,className:`rounded-md p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground`,"data-testid":`blueprint-spec-modal-close`,children:(0,Q.jsx)(yt,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[(0,Q.jsx)(`section`,{"aria-label":i(`specModal.description`),"data-testid":`blueprint-spec-description`,children:e.description.trim()?(0,Q.jsx)(`div`,{className:uV,children:(0,Q.jsx)(un,{remarkPlugins:[dn],children:e.description})}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.empty`)})}),(0,Q.jsxs)(`section`,{"aria-labelledby":`blueprint-spec-criteria-heading`,"data-testid":`blueprint-spec-acceptance-criteria`,children:[(0,Q.jsxs)(`h3`,{id:`blueprint-spec-criteria-heading`,className:`mb-2 flex items-center justify-between gap-2 text-xs font-semibold uppercase tracking-wider text-foreground/60`,children:[(0,Q.jsx)(`span`,{children:i(`specModal.acceptanceCriteria`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] tabular-nums text-muted-foreground`,children:e.acceptanceCriteria.length})]}),e.acceptanceCriteria.length>0?(0,Q.jsx)(`ol`,{className:`space-y-2`,children:e.acceptanceCriteria.map((e,t)=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-2 text-sm leading-6 text-foreground/85`,"data-testid":`blueprint-spec-criterion-${t}`,children:[(0,Q.jsx)(Pn,{className:`mt-1 h-4 w-4 shrink-0 text-accent-success`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:e})]},`${t}-${e}`))}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.criteriaEmpty`)})]})]})]})]}),document.body)}var pV={critical:`border-destructive/35 bg-destructive/15 text-destructive`,high:`border-accent-warning/35 bg-accent-warning/15 text-accent-warning`,medium:`border-accent-info/35 bg-accent-info/15 text-accent-info`,low:`border-border/60 bg-surface/70 text-foreground/60`};function mV({blueprint:e,milestoneLabel:t=`M1`}){let{t:n}=I(`builder`),{t:r}=I(`tickets`),i=BB(e),[a,o]=(0,Z.useState)(null),s=[{key:`product`,label:n(`panel.product`),value:e?.product.name??``},{key:`coreFlow`,label:n(`panel.coreFlow`),value:e?.coreFlow??``},{key:`platform`,label:n(`panel.platform`),value:e?.platform??``},{key:`stack`,label:n(`panel.stack`),value:e?[e.stack.language,e.stack.framework,e.stack.db].filter(Boolean).join(` · `):``},{key:`milestones`,label:n(`panel.milestones`),value:e&&e.milestones.length>0?n(`panel.milestonesValue`,{count:e.milestones.length}):``}];return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`blueprint-panel`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`panel.title`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:s.map(e=>(0,Q.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-xs transition-colors`,i[e.key]?`border-accent-success/30 bg-accent-success/5`:`border-border/30`),"data-testid":`dimension-${e.key}`,children:[i[e.key]?(0,Q.jsx)(be,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-label":`✓`}):(0,Q.jsx)(yt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/40`,"aria-label":`✗`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label}),e.value&&(0,Q.jsx)(`span`,{className:`ml-auto truncate text-muted-foreground`,title:e.value,children:e.value})]},e.key))})]}),e&&e.assumptions.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`panel.assumptions`)}),(0,Q.jsx)(`ul`,{className:`space-y-0.5`,children:e.assumptions.map((e,t)=>(0,Q.jsx)(`li`,{className:`text-[11px] text-muted-foreground before:mr-1.5 before:content-['·']`,children:e},t))})]}),e&&e.m1Specs.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`h4`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Q.jsx)(br,{className:`h-3 w-3`}),n(`panel.m1Specs`,{count:e.m1Specs.length})]}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:e.m1Specs.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(t),"data-agent-interactive":!0,className:`w-full rounded-lg border border-border/40 bg-surface/50 p-2.5 text-left shadow-sm transition-colors animate-in fade-in slide-in-from-bottom-1 hover:border-accent-primary/50 hover:bg-surface/80 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,"data-testid":`m1-spec-card-${t}`,title:n(`specModal.open`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(ct,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium leading-tight`,children:e.title}),e.shortSummary.trim()&&(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-4 text-muted-foreground`,"data-testid":`m1-spec-summary-${t}`,children:e.shortSummary}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,pV[e.priority]),"data-testid":`m1-spec-priority-${t}`,children:r(`priority.${e.priority}`)}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border/50 bg-surface/70 px-1.5 py-px text-[9px] text-muted-foreground`,"data-testid":`m1-spec-criteria-count-${t}`,children:[(0,Q.jsx)(wr,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),n(`panel.criteriaCount`,{count:e.acceptanceCriteria.length})]}),e.labels.map(e=>(0,Q.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] text-accent-primary`,children:e},e)),e.dependsOnIndex!==void 0&&(0,Q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-[9px] text-muted-foreground`,children:n(`panel.dependsOn`,{index:e.dependsOnIndex+1})})]})]})]})},`${t}-${e.title}`))})]}),e&&e.milestones.length>1&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`panel.laterMilestones`)}),e.milestones.slice(1).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/20 px-2.5 py-1.5`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:e.title}),e.plannedSpecs.length>0&&(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e.plannedSpecs.join(` · `)})]},e.id||e.title))]}),!e&&(0,Q.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground/60`,children:n(`panel.empty`)}),e&&a!==null&&e.m1Specs[a]&&(0,Q.jsx)(fV,{spec:e.m1Specs[a],index:a,milestoneLabel:t,onClose:()=>o(null)})]})}function hV(){let{t:e}=I(`agent`),{t}=I(`builder`),{minimize:n,startNewConversation:r,cycleTier:i,active:a,draftPinnedProjectId:o,setPinnedProject:s,builderMode:c}=UV(),[l,u]=(0,Z.useState)(!1),d=c.active,f=e=>{d||e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),i())},{panelRef:p,panelStyle:m,headerHandleProps:h,resizeHandles:g}=Ut({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ML.div,{ref:p,initial:{opacity:0,scale:.85,y:8},animate:{opacity:1,scale:1,y:0},transition:{duration:.22,ease:[.34,1.56,.64,1]},style:l?{position:`fixed`,inset:12,width:`auto`,height:`auto`,maxWidth:`none`,maxHeight:`none`}:m,role:`dialog`,"aria-label":d?t(`mode.title`):e(`title`),onKeyDown:f,className:`fixed z-[60] flex flex-col overflow-hidden rounded-2xl border border-border/60 bg-card/90 shadow-2xl backdrop-blur-xl ${l?``:`bottom-4 right-4 h-[78vh] max-h-[94vh] max-w-[92vw] ${d?`w-[860px]`:`w-[520px]`}`}`,children:[(0,Q.jsxs)(`div`,{...l?{}:h,onDoubleClick:()=>u(e=>!e),className:`flex shrink-0 items-center gap-2 border-b border-border/50 bg-surface/40 px-3 py-2 ${l?``:`cursor-grab`}`,children:[(0,Q.jsxs)(`span`,{className:`relative flex h-5 w-5 shrink-0 items-center justify-center`,children:[(0,Q.jsx)(TB,{active:d&&c.session.messages.length===0&&c.session.phase===`chat`,inset:-3}),(0,Q.jsx)(wn,{className:`h-4 w-4 shrink-0 text-accent-primary`})]}),(0,Q.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/80`,children:d?t(`mode.title`):e(`title`)}),!d&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(gz,{pinnedProjectId:a?a.pinned_project_id:o,onSelect:e=>void s(e)}),(0,Q.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border/60`,"aria-hidden":!0}),(0,Q.jsx)(CB,{})]}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[!d&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(null),title:e(`newConversation`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,Q.jsx)(pt,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-label":e(l?`restore`:`maximize`),title:e(l?`restore`:`maximize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:l?(0,Q.jsx)(Or,{className:`h-4 w-4`}):(0,Q.jsx)(Dr,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":e(`minimize`),title:e(`minimize`),"data-agent-interactive":!0,className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,Q.jsx)(yt,{className:`h-4 w-4`})})]})]}),d?(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Q.jsx)(lV,{variant:`floating`}),(0,Q.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border/40 lg:w-80`,children:[(0,Q.jsx)(mV,{blueprint:c.session.blueprint}),c.session.phase===`chat`&&(0,Q.jsxs)(`div`,{className:`border-t border-border/40 p-3`,children:[(0,Q.jsxs)(Y,{className:`w-full`,size:`sm`,disabled:!c.session.canProposeCommit,onClick:c.session.goToCommit,"data-testid":`builder-create-specs`,children:[(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),t(`shell.createSpecs`)]}),!c.session.canProposeCommit&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,children:c.session.specQualityDetail??t(`shell.createSpecsHint`)})]})]})]}):(0,Q.jsx)(bB,{variant:`floating`})]}),!l&&(0,Q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,Q.jsx)(tn,{handles:g})})]})}var gV=`specrails-desktop:agent-bubble-pos`,_V=56,vV=12;function yV(){try{let e=localStorage.getItem(gV);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function bV(e){let t=Math.max(vV,window.innerWidth-_V-vV),n=Math.max(vV,window.innerHeight-_V-vV);return{left:Math.min(Math.max(vV,e.left),t),top:Math.min(Math.max(vV,e.top),n)}}function xV(){return{left:Math.round(window.innerWidth/2-_V/2),top:window.innerHeight-_V-20}}function SV(){let{t:e}=I(`agent`),{t}=I(`builder`),{open:n,isStreaming:r,active:i,builderMode:a}=UV(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(()=>bV(yV()??xV())),u=AL(0),d=AL(0),f=(0,Z.useRef)(!1),p=a.active?a.session.busy:r;(0,Z.useEffect)(()=>{let e=()=>l(e=>bV(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,Z.useCallback)(e=>{try{localStorage.setItem(gV,JSON.stringify(e))}catch{}},[]);return(0,Q.jsxs)(ML.button,{type:`button`,onClick:()=>{if(f.current){f.current=!1;return}n()},onHoverStart:()=>s(!0),onHoverEnd:()=>s(!1),"aria-label":e(`trigger`),title:`${e(`trigger`)} (⌘⇧A)`,drag:!0,dragMomentum:!1,dragElastic:0,style:{position:`fixed`,left:c.left,top:c.top,x:u,y:d},onDragStart:()=>{f.current=!0},onDragEnd:()=>{let e=bV({left:c.left+u.get(),top:c.top+d.get()});u.set(0),d.set(0),l(e),m(e),setTimeout(()=>{f.current=!1},0)},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:420,damping:28},whileHover:{scale:1.06},whileTap:{scale:.94},whileDrag:{scale:1.1,cursor:`grabbing`},className:`z-[60] flex h-14 items-center gap-2 rounded-full border border-border/60 bg-card/85 px-3 shadow-2xl backdrop-blur-xl cursor-grab`,children:[(0,Q.jsxs)(`span`,{className:`relative flex h-9 w-9 items-center justify-center rounded-full bg-accent-primary/15`,children:[(0,Q.jsx)(TB,{active:a.active&&a.session.messages.length===0&&a.session.phase===`chat`,inset:-4}),(0,Q.jsx)(wn,{className:`h-5 w-5 text-accent-primary`}),p&&(0,Q.jsx)(ML.span,{className:`absolute inset-0 rounded-full ring-2 ring-accent-success`,animate:{opacity:[.8,.2,.8],scale:[1,1.18,1]},transition:{duration:1.4,repeat:1/0,ease:`easeInOut`}})]}),(0,Q.jsx)(MF,{initial:!1,children:(o||p)&&(0,Q.jsx)(ML.span,{initial:{opacity:0,width:0,marginRight:0},animate:{opacity:1,width:`auto`,marginRight:4},exit:{opacity:0,width:0,marginRight:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden whitespace-nowrap text-sm font-medium text-foreground`,children:p?e(`thinking`):a.active?t(`mode.title`):i?.title||e(`trigger`)})})]})}var CV={streamingText:``,isStreaming:!1,liveTools:[],queued:[]},wV=`specrails-desktop:favorite-agent-conversations`;function TV(){try{let e=localStorage.getItem(wV);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function EV(e){try{localStorage.setItem(wV,JSON.stringify([...e]))}catch{}}function DV(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var OV=new Set([`completed`,`merged`,`discarded`,`superseded`]);function kV(e,t){return JSON.stringify(e)===JSON.stringify(t)}function AV(e){if(!e.createdAt)return null;let t=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(e.createdAt)?`${e.createdAt.replace(` `,`T`)}Z`:e.createdAt,n=Date.parse(t);return Number.isFinite(n)?n:null}function jV(e,t){if(t.supersedesDeliveryId===e.prDeliveryId)return 1;if(e.supersedesDeliveryId===t.prDeliveryId)return-1;let n=AV(e),r=AV(t);return n==null||r==null?null:r<n?-1:+(r>n)}function MV(e,t){let n=null;for(let r of e){if(r.supersedesDeliveryId!==t)continue;if(!n){n=r;continue}let e=AV(n),i=AV(r);(e==null||i==null||i>=e)&&(n=r)}return n}function NV(e,t){let n=t.restoredFromDeliveryId;if(!n)return!1;let r=MV(e,t.prDeliveryId);return!r||r.prDeliveryId===n}function PV(e,t){let n=e.filter(e=>e.role===`system`).map(e=>ME(e.content)).filter(e=>e!==null),r=[...n].reverse().find(e=>e.prDeliveryId===t.prDeliveryId),i=NV(n,t);if(r){let e=OV.has(r.decision),n=OV.has(t.decision),a=bv(r.updatedAt,t.updatedAt);if(a===-1||a===0&&!kV(r,t)||e&&!n&&!(i&&r.decision===`superseded`))return!0}let a=new Set(n.map(e=>e.supersedesDeliveryId).filter(e=>!!e));if(i)return!1;if(a.has(t.prDeliveryId)&&t.decision!==`superseded`)return!0;for(let e of n){if(e.railIndex!==t.railIndex||e.prDeliveryId===t.prDeliveryId||a.has(e.prDeliveryId))continue;let n=jV(e,t);if(n===-1||(n===0||n===null)&&!OV.has(e.decision)&&t.supersedesDeliveryId!==e.prDeliveryId)return!0}return!1}function FV(e,t){let n=t.restoredFromDeliveryId;if(!n)return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let t=ME(e.content);return!t||t.prDeliveryId!==n||OV.has(t.decision)?e:(r=!0,{...e,content:JSON.stringify({...t,decision:`discarded`})})});return r?i:e}function IV(e,t){let n=e.filter(e=>e.role===`system`).map(e=>ME(e.content)).filter(e=>e!==null);if(n.some(e=>e.restoredFromDeliveryId===t.prDeliveryId&&NV(n,e)))return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let n=ME(e.content);return!n||n.railIndex!==t.railIndex||n.prDeliveryId===t.prDeliveryId||OV.has(n.decision)||jV(n,t)!==1?e:(r=!0,{...e,content:JSON.stringify({...n,decision:`superseded`})})});return r?i:e}function LV(e,t,n){if(PV(e,n))return e;let r=IV(FV(e,n),n),i=JSON.stringify(n),a=r.flatMap((e,t)=>e.role===`system`&&ME(e.content)?.prDeliveryId===n.prDeliveryId?[t]:[]);if(a.length>0){let e=a[a.length-1];if(a.length===1&&r[e].content===i)return r;let t=new Set(a.slice(0,-1));return r.flatMap((n,r)=>t.has(r)?[]:[r===e?{...n,content:i}:n])}return[...r,{id:`prd-${n.prDeliveryId}`,conversation_id:t,role:`system`,content:i,created_at:new Date().toISOString()}]}var RV=(0,Z.createContext)(null),zV=0,BV=0;function VV({children:e}){let{registerHandler:t,unregisterHandler:n,connectionStatus:r}=Et(),{uiMode:i}=iw(),{setActiveProjectId:a}=At(),[o,s]=(0,Z.useState)(`hidden`),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=(0,Z.useRef)(f);m.current=f;let[h,g]=(0,Z.useState)(TV),[_,v]=(0,Z.useState)(new Set),[y,b]=(0,Z.useState)(new Map),[x,S]=(0,Z.useState)(!0),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=(0,Z.useRef)(null);k.current=D;let[A,j]=(0,Z.useState)(`claude`),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(0),[I,L]=(0,Z.useState)(null),z=(0,Z.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});z.current={provider:A,model:M,tierLevel:P,effort:I};let B=(0,Z.useRef)(null);B.current=u?.id??null;let V=(0,Z.useRef)(y);V.current=y;let H=(0,Z.useRef)(new Set),U=(0,Z.useRef)(null),W=(0,Z.useRef)(0),ee=(0,Z.useRef)(0),te=(0,Z.useCallback)(e=>{let t=B.current;if(!t)return`untracked`;if(PV(m.current,e))return`stale`;if(!m.current.some(t=>t.role===`system`&&ME(t.content)?.prDeliveryId===e.prDeliveryId))return`untracked`;W.current++;let n=LV(m.current,t,e);return m.current=n,p(n=>{if(!n.some(t=>t.role===`system`&&ME(t.content)?.prDeliveryId===e.prDeliveryId))return m.current=n,n;let r=LV(n,t,e);return m.current=r,r}),`accepted`},[]),G=(0,Z.useCallback)((e,t)=>{b(n=>{let r=t(n.get(e)??CV),i=new Map(n);return r===null||!r.isStreaming&&!r.streamingText&&r.liveTools.length===0&&r.queued.length===0?i.delete(e):i.set(e,r),i})},[]),K=(0,Z.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===B.current&&!t||v(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),ne=(0,Z.useCallback)(e=>{v(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,Z.useEffect)(()=>{if(!at||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=B.current;e&&ne(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[ne]);let re=(u?y.get(u.id):void 0)??CV,ie=re.streamingText,ae=re.isStreaming,oe=re.liveTools,se=re.queued,ce=(0,Z.useMemo)(()=>{let e=new Set;for(let[t,n]of y)n.isStreaming&&e.add(t);return e},[y]),le=(0,Z.useCallback)(async()=>{try{let e=await gE();l(e),g(t=>{let n=DV(t,e);return n.size===t.size?t:(EV(n),n)})}catch{}},[]),q=(0,Z.useCallback)(async()=>{try{let e=await RE();S(e.enabled)}catch{S(!1)}},[]),ue=(0,Z.useCallback)(async()=>{try{E((await LE()).any)}catch{E(!0)}},[]);(0,Z.useEffect)(()=>at?(t(`agent-chat`,e=>{let t=e;if(typeof t.type!=`string`||!t.type.startsWith(`agent_`))return;if(t.type===`agent_title`&&t.conversationId){let e=t.title??null;l(n=>n.map(n=>n.id===t.conversationId?{...n,title:e}:n)),d(n=>n&&n.id===t.conversationId?{...n,title:e}:n);return}let n=t.conversationId;if(!n)return;let r=n===B.current;if(t.type===`agent_stream`)K(n),G(n,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(t.delta??``)}));else if(t.type===`agent_tool`)G(n,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${zV++}`,tool:t.tool??`tool`}]}));else if(t.type===`agent_done`){K(n);let e=t.fullText??``;r&&p(t=>{let r=t[t.length-1];return r&&r.role===`assistant`&&r.content===e&&!r.id.startsWith(`local-`)?t:[...t,{id:`local-${Date.now()}`,conversation_id:n,role:`assistant`,content:e,created_at:new Date().toISOString()}]}),G(n,e=>({...CV,queued:e.queued}))}else if(t.type===`agent_error`){K(n),G(n,e=>({...CV,queued:e.queued}));let e=t.error||`The agent turn failed.`;R.error(e),r&&p(t=>[...t,{id:`err-${Date.now()}`,conversation_id:n,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(t.type===`agent_queued`)G(n,e=>t.queueId&&e.queued.some(e=>e.queueId===t.queueId)?e:{...e,queued:[...e.queued,{queueId:t.queueId??`srv-${BV++}`,text:t.text??``,contextRefs:t.contextRefs}]});else if(t.type===`agent_dequeued`)t.queueId&&H.current.add(t.queueId),G(n,e=>{let n=t.queueId?e.queued.findIndex(e=>e.queueId===t.queueId):0,r=n===-1?0:n;return{...e,queued:e.queued.filter((e,t)=>t!==r),isStreaming:!0,streamingText:``,liveTools:[]}}),r&&t.text&&p(e=>[...e,{id:`local-u-${Date.now()}`,conversation_id:n,role:`user`,content:t.text,context_refs:t.contextRefs??[],created_at:new Date().toISOString()}]);else if(t.type===`agent_queue_cleared`)G(n,e=>({...e,queued:[]}));else if(t.type===`agent_queue_edited`)G(n,e=>({...e,queued:e.queued.map(e=>t.queueId&&e.queueId===t.queueId?{...e,text:t.text??e.text,contextRefs:t.contextRefs??e.contextRefs}:e)}));else if(t.type===`agent_pr_decision`&&(K(n),r)){let t=jE(e);if(t){W.current++;let e=LV(m.current,n,t);m.current=e,p(e=>{let r=LV(e,n,t);return m.current=r,r})}}}),()=>n(`agent-chat`)):void 0,[t,n,G,K]);let de=(0,Z.useCallback)(async e=>{let t=++ee.current;W.current++;let{conversation:n,messages:r}=await vE(e);t===ee.current&&(W.current++,d(n),m.current=r,p(r),ne(e))},[ne]),fe=(0,Z.useCallback)(async()=>{let e=B.current;if(!e)return;let t=W.current;try{let n=await vE(e);if(B.current!==e||W.current!==t)return;let r=n.messages.filter(e=>e.role===`system`).map(e=>ME(e.content)).filter(e=>e!==null);if(r.length===0)return;p(t=>{let n=r.reduce((t,n)=>LV(t,e,n),t);return m.current=n,n})}catch{}},[]);(0,Z.useEffect)(()=>{let e=()=>{fe()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[fe]);let pe=(0,Z.useRef)(r);(0,Z.useEffect)(()=>{let e=pe.current;pe.current=r,r===`connected`&&e!==`connected`&&fe()},[r,fe]);let me=(0,Z.useCallback)(async()=>{if(u)return u;let e=await gE();if(l(e),g(t=>{let n=DV(t,e);return n.size===t.size?t:(EV(n),n)}),e.length>0)return await de(e[0].id),e[0];let t=await _E({});return l(e=>[t,...e]),d(t),p([]),t},[u,de]),he=(0,Z.useCallback)(()=>{s(`open`),le(),q(),ue(),me()},[le,q,ue,me]),ge=(0,Z.useCallback)(()=>s(`hidden`),[]),_e=(0,Z.useCallback)(()=>s(`minimized`),[]),[ve,ye]=(0,Z.useState)(!1),be=(0,Z.useRef)(null),J=(0,Z.useCallback)(()=>{be.current?.abortAndReset(),ye(!1)},[]),xe=sV(ve,{onFinished:J});be.current=xe;let Se=(0,Z.useCallback)(()=>{ye(!0),i!==`agent`&&he()},[i,he]),Ce=(0,Z.useCallback)(()=>{s(e=>e===`open`?`minimized`:`open`),o!==`open`&&(le(),q(),ue(),me())},[o,le,q,ue,me]),we=(0,Z.useCallback)(async()=>{if(u)return u;if(U.current)return U.current;let e=_E({pinnedProjectId:k.current,provider:z.current.provider,model:z.current.model,tierLevel:z.current.tierLevel,reasoningEffort:z.current.effort}).then(e=>(l(t=>[e,...t]),d(e),p([]),e)).finally(()=>{U.current=null});return U.current=e,e},[u]),Te=(0,Z.useCallback)(async(e,t)=>{let n=e.trim();if(!n)return;let r=u??await we(),i=`q-${Date.now()}-${BV++}`,a=new Date().toISOString();l(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:a},...e.filter(e=>e.id!==r.id)]),d(e=>e&&e.id===r.id?{...e,updated_at:a}:e);let o={id:`local-u-${Date.now()}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],created_at:a},s=V.current.get(r.id)?.isStreaming===!0;s?G(r.id,e=>({...e,queued:[...e.queued,{queueId:i,text:n,contextRefs:t?.contextRefs}]})):(p(e=>[...e,o]),G(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let c=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,a=(await xE(r.id,n,{tierLevel:r.tier_level,attachments:c,queueId:i,contextRefs:e}))?.queued===!0;a&&!s?(p(e=>e.filter(e=>e.id!==o.id)),H.current.has(i)||G(r.id,e=>e.queued.some(e=>e.queueId===i)?e:{...e,queued:[...e.queued,{queueId:i,text:n,contextRefs:t?.contextRefs}]})):!a&&s&&(G(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==i),isStreaming:!0})),p(e=>[...e,o]))}catch(e){s?G(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==i)})):G(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),R.error(e instanceof Error?e.message:`Failed to send message.`)}},[u,we,G]),Ee=(0,Z.useCallback)(async()=>{u&&(G(u.id,()=>null),await DE(u.id))},[u,G]),De=(0,Z.useCallback)(async(e,t)=>{let n=u;if(!n)return`conflict`;let r=await OE(n.id,e,t);return r===`saved`&&G(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[u,G]),Oe=(0,Z.useCallback)(e=>H.current.has(e),[]),ke=(0,Z.useCallback)(async e=>{if(!u)return;let t=await yE(u.id,e);d(t),l(e=>e.map(e=>e.id===t.id?t:e))},[u]),Ae=(0,Z.useCallback)(async e=>{u?await ke({tierLevel:e}):F(e)},[u,ke]),je=(0,Z.useCallback)(async()=>{let e=((u?.tier_level??P)+1)%4;await Ae(e)},[u,P,Ae]),Me=(0,Z.useCallback)(async e=>{u?await ke({provider:e}):(j(e),N(null),L(null))},[u,ke]),Ne=(0,Z.useCallback)(async e=>{u?await ke({model:e}):N(e)},[u,ke]),Pe=(0,Z.useCallback)(async e=>{u?await ke({reasoningEffort:e}):L(e)},[u,ke]),Fe=(0,Z.useCallback)(async e=>{u?await ke({pinnedProjectId:e}):O(e),!u&&e&&i===`agent`&&a(e)},[u,ke,i,a]),Ie=(0,Z.useCallback)(e=>{J(),d(null),p([]),O(e??null),j(`claude`),N(null),F(0),L(null)},[J]),Le=(0,Z.useCallback)(async e=>{J();let t=await _E({pinnedProjectId:e===void 0?u?.pinned_project_id??null:e});l(e=>[t,...e]),d(t),p([])},[u,J]),Re=(0,Z.useCallback)(async e=>{J(),await de(e)},[de,J]),ze=(0,Z.useCallback)(async e=>{await bE(e),l(t=>t.filter(t=>t.id!==e)),g(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),EV(n),n}),G(e,()=>null),B.current===e&&(d(null),p([]))},[G]),Be=(0,Z.useCallback)(async(e,t)=>{let n=t.trim()||null,r;l(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),d(t=>t&&t.id===e?{...t,title:n}:t);try{await yE(e,{title:n})}catch(t){throw l(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),d(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),Ve=(0,Z.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),EV(n),n})},[]),He=(0,Z.useCallback)(async()=>{w(!0);try{await zE(),await q()}finally{w(!1)}},[q]),Ue=(0,Z.useMemo)(()=>({visibility:o,open:he,close:ge,minimize:_e,toggle:Ce,conversations:c,active:u,messages:f,streamingText:ie,isStreaming:ae,liveTools:oe,queuedMessages:se,streamingConversationIds:ce,liveByConversation:y,unreadConversationIds:_,favoriteConversationIds:h,mcpEnabled:x,enablingMcp:C,enableMcpServer:He,providersReady:T,send:Te,abort:Ee,editQueuedMessage:De,wasQueueConsumed:Oe,cycleTier:je,setTier:Ae,setProvider:Me,setModel:Ne,setPinnedProject:Fe,newConversation:Le,startNewConversation:Ie,materializeDraftConversation:we,draftPinnedProjectId:D,draftProvider:A,draftModel:M,draftTierLevel:P,draftEffort:I,setEffort:Pe,selectConversation:Re,deleteConversation:ze,renameConversation:Be,toggleFavoriteConversation:Ve,refreshConversations:le,applyPrDecisionSnapshot:te,builderMode:{active:ve,enter:Se,exit:J,session:xe}}),[o,he,ge,_e,Ce,ve,Se,J,xe,c,u,f,ie,ae,oe,se,ce,y,_,h,x,C,He,T,Te,Ee,De,Oe,je,Ae,Me,Ne,Fe,Le,Ie,we,D,A,M,P,I,Pe,Re,ze,Be,Ve,le,te]),We=at&&i!==`agent`;return(0,Q.jsxs)(RV.Provider,{value:Ue,children:[e,We&&o===`open`&&(0,Q.jsx)(hV,{}),We&&o!==`open`&&(0,Q.jsx)(SV,{})]})}var HV={visibility:`hidden`,open:()=>{},close:()=>{},minimize:()=>{},toggle:()=>{},conversations:[],active:null,messages:[],streamingText:``,isStreaming:!1,liveTools:[],queuedMessages:[],streamingConversationIds:new Set,unreadConversationIds:new Set,liveByConversation:new Map,favoriteConversationIds:new Set,mcpEnabled:!0,enablingMcp:!1,enableMcpServer:async()=>{},providersReady:!0,send:async()=>{},abort:async()=>{},editQueuedMessage:async()=>`conflict`,wasQueueConsumed:()=>!1,cycleTier:async()=>{},setTier:async()=>{},setProvider:async()=>{},setModel:async()=>{},setPinnedProject:async()=>{},newConversation:async()=>{},startNewConversation:()=>{},materializeDraftConversation:async()=>{throw Error(`AgentChatProvider is not mounted`)},draftPinnedProjectId:null,draftProvider:`claude`,draftModel:null,draftTierLevel:0,draftEffort:null,setEffort:async()=>{},selectConversation:async()=>{},deleteConversation:async()=>{},renameConversation:async()=>{},toggleFavoriteConversation:()=>{},refreshConversations:async()=>{},applyPrDecisionSnapshot:()=>`untracked`,builderMode:{active:!1,enter:()=>{},exit:()=>{},session:{phase:`chat`,messages:[],streamBuffer:null,blueprint:null,busy:!1,commitError:null,commitErrorDetail:null,commitSteps:[],createdProjectId:null,launching:!1,submitting:!1,conversationReady:!1,dirty:!1,canProposeCommit:!1,specQualityDetail:null,showSurpriseMe:!0,provider:`claude`,model:null,models:[],efforts:[],effort:`medium`,draft:``,setDraft:()=>{},setEffort:()=>{},setProvider:()=>{},setModel:()=>{},send:()=>{},surpriseMe:()=>{},goToCommit:()=>{},backToChat:()=>{},submitCommit:()=>{},launchM1:async()=>{},openProject:()=>{},abortAndReset:()=>{}}}};function UV(){return(0,Z.useContext)(RV)??HV}var WV=(0,Z.lazy)(()=>c(()=>import(`./ProjectSettingsDialog-nEs-ENrE.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([78,1,2,6,54,44,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,3,36,43,37,67,66,68,42,65]))),GV=`specrails-desktop:agentTreeExpanded`;function KV(){try{let e=localStorage.getItem(GV);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function qV(e){try{localStorage.setItem(GV,JSON.stringify([...e]))}catch{}}function JV(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var YV=`__home__`,XV=`__favorites__`;function ZV({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=I(`agent`),u=e.title?.trim()||l(`untitled`),[d,f]=(0,Z.useState)(!1),p=(0,Z.useRef)(null),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(r);(0,Z.useEffect)(()=>{if(g.current&&!r){h(!0);let e=setTimeout(()=>h(!1),900);return g.current=r,()=>clearTimeout(e)}g.current=r},[r]),(0,Z.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);function _(e){e.stopPropagation(),d?(p.current&&clearTimeout(p.current),f(!1),c()):(f(!0),p.current=setTimeout(()=>{f(!1),p.current=null},3e3))}function v(e){e.stopPropagation(),s?.()}function y(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o()))}return(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:y,className:X(`group relative flex items-center gap-2 w-full h-7 rounded-md transition-colors`,n?`pl-7 pr-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:u,"aria-current":t?`true`:void 0,children:[(0,Q.jsx)(De,{className:X(`w-3.5 h-3.5 flex-shrink-0`,t&&`text-accent-primary`,r&&!i&&`text-accent-primary animate-pulse`,i&&`text-destructive conversation-unread-glow`)}),n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`relative text-[11px] truncate flex-1 text-left`,children:[u,(r||m)&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:X(`title-shimmer pointer-events-none absolute inset-0 truncate transition-opacity duration-700`,r?`opacity-100`:`opacity-0`),children:u})]}),(0,Q.jsx)(`span`,{className:X(`flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/45`,d?`hidden`:`group-hover:hidden`),title:nE(e.updated_at),children:tE(e.updated_at)}),(0,Q.jsx)(`button`,{type:`button`,onClick:v,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,a?`flex w-3.5 h-3.5 text-accent-primary hover:text-accent-primary`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-accent-primary`),"aria-label":l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),title:l(a?`removeFavoriteConversation`:`addFavoriteConversation`,{title:u}),children:(0,Q.jsx)(pr,{className:`w-2.5 h-2.5`,fill:a?`currentColor`:`none`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:_,className:X(`flex-shrink-0 items-center justify-center rounded-sm transition-colors hover:bg-muted`,d?`flex px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`hidden group-hover:flex w-3.5 h-3.5 text-muted-foreground/60 hover:text-foreground`),"aria-label":l(d?`confirmDeleteConversation`:`deleteConversation`,{title:u}),children:d?l(`confirmShort`):(0,Q.jsx)(yt,{className:`w-2.5 h-2.5`})})]})]})}function QV({project:e,isActive:t,expanded:n,onSelect:r,onRemove:i,agentMode:a=!1,hasTree:o=!1,treeOpen:s=!1,onToggleTree:c,conversations:l=[],activeConversationId:u=null,streamingConversationIds:d,unreadConversationIds:f,onSelectConversation:p,onToggleConversationFavorite:m,onDeleteConversation:h,onOpenProjectSettings:g}){let{t:_}=I(`nav`),[v,y]=(0,Z.useState)(!1),b=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);function x(e){e.stopPropagation(),v?(b.current&&clearTimeout(b.current),y(!1),i()):(y(!0),b.current=setTimeout(()=>{y(!1),b.current=null},3e3))}function S(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))}let C=a&&o&&n,w=(0,Q.jsx)(rr,{className:X(`flex-shrink-0 w-4 h-4`,t&&`text-accent-primary`)});return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:S,className:X(`group relative flex items-center gap-2 w-full h-8 rounded-md transition-colors`,n?`px-2`:`px-0 justify-center`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:n?void 0:e.name,"aria-current":t?`page`:void 0,children:[C?(0,Q.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Q.jsx)(`span`,{className:`flex transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:w}),(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c?.()},className:`absolute inset-0 hidden items-center justify-center rounded-sm hover:bg-muted group-hover:flex group-focus-within:flex`,"aria-label":_(s?`projects.collapse`:`projects.expand`,{name:e.name}),"aria-expanded":s,children:s?(0,Q.jsx)(pe,{className:`w-3.5 h-3.5`}):(0,Q.jsx)(xe,{className:`w-3.5 h-3.5`})})]}):w,n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:e.name}),g&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g()},className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all w-3.5 h-3.5`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`),"aria-label":_(`projects.settings`,{name:e.name}),title:_(`projects.settings`,{name:e.name}),children:(0,Q.jsx)(ni,{className:`w-2.5 h-2.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:x,className:X(`flex-shrink-0 flex items-center justify-center rounded-sm transition-all`,`opacity-0 group-hover:opacity-50 hover:!opacity-100 hover:bg-muted`,v?`opacity-100 px-1 h-4 text-[10px] text-destructive bg-destructive/10 hover:bg-destructive/20`:`w-3.5 h-3.5`),"aria-label":_(v?`projects.confirmRemove`:`projects.remove`,{name:e.name}),children:v?_(`projects.confirmShort`):(0,Q.jsx)(yt,{className:`w-2.5 h-2.5`})})]})]}),a&&s&&n&&l.length>0&&(0,Q.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:l.map(e=>(0,Q.jsx)(ZV,{conversation:e,active:e.id===u,streaming:d?.has(e.id)??!1,unread:f?.has(e.id)??!1,expanded:n,onSelect:()=>p?.(e.id),onToggleFavorite:()=>m?.(e.id),onDelete:()=>h?.(e.id)},e.id))})]})}var $V={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function eH({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a}){let{t:o}=I(`nav`),{t:s}=I(`agent`),{projects:c,activeProjectId:l,setActiveProjectId:d,removeProject:f}=At(),m=p(),h=u(),g=h.pathname.startsWith(`/loops`),_=h.pathname.startsWith(`/plugins`),v=g||_||h.pathname.startsWith(`/docs`),{leftMode:y,cycleLeftMode:b}=fE(),{uiMode:x,toggleUiMode:S}=iw(),C=UV(),w=x===`agent`,T=(0,Z.useMemo)(()=>{let e=new Map,t=new Set(c.map(e=>e.id));for(let n of C.conversations){if(C.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:YV,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[C.conversations,C.favoriteConversationIds,c]),E=(0,Z.useMemo)(()=>C.conversations.filter(e=>C.favoriteConversationIds.has(e.id)),[C.conversations,C.favoriteConversationIds]),D=T.get(YV)??[],[O,k]=(0,Z.useState)(KV),A=O.has(XV),[j,M]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{!w||!l||k(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),qV(t),t})},[w,l]);let N=e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),qV(n),n})},P=e=>{C.selectConversation(e),v&&m(`/`)},F=e=>{C.deleteConversation(e).catch(()=>{})},L=e=>{C.toggleFavoriteConversation(e)};function R(e){if(w){d(e),N(e);return}if(e===l){v&&m(`/`);return}d(e)}let[z,B]=(0,Z.useState)(!1),V=y===`pinned-open`||y===`unpinned`&&z,H=ZT(`left-arc`,{side:`left`,defaultWidth:240,min:200,max:460,collapsedWidth:44,expanded:V}),U=y!==`unpinned`,W=o($V[y]),ee=[{label:o(`arcSidebar.docs`),icon:Cn,action:i},{label:o(`arcSidebar.analytics`),icon:An,action:r},{label:o(`arcSidebar.settings`),icon:ni,action:a}];async function te(e){try{await f(e.id)}catch{}}return(0,Q.jsxs)(`div`,{ref:H.panelRef,className:X(`relative flex flex-col h-full border-r border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{y===`unpinned`&&B(!0)},onMouseLeave:()=>{y===`unpinned`&&!H.dragging&&B(!1)},children:[V&&(0,Q.jsx)(QT,{side:`left`,dragging:H.dragging,width:H.width,min:200,max:460,label:o(`arcSidebar.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:H.onGripPointerDown,onKeyDown:H.onGripKeyDown}),(0,Q.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,V?`px-3 justify-between`:`justify-center`),children:[V&&(0,Q.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:o(`arcSidebar.desktopTitle`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:b,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,U?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":W,title:o(`sidebarPin.withShortcut`,{label:W,shortcut:`⌥⌘B`}),children:(0,Q.jsx)(Fr,{className:`w-4 h-4`})})]}),Re&&(0,Q.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[w&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{C.startNewConversation(l),v&&m(`/`)},className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`bg-accent-primary/15 text-accent-primary hover:bg-accent-primary/25`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`newAgent`),title:V?void 0:s(`newAgent`),children:[(0,Q.jsx)(pt,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`newAgent`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:S,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(w?`switchToKanban`:`switchToAgent`),title:s(w?`switchToKanban`:`switchToAgent`),children:[w?(0,Q.jsx)(xr,{className:`w-4 h-4 flex-shrink-0`}):(0,Q.jsx)(wn,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),V&&(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:s(w?`switchToKanban`:`switchToAgent`)})]}),w&&(0,Q.jsxs)(`button`,{type:`button`,onClick:JV,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`search`),title:V?void 0:s(`search`),children:[(0,Q.jsx)(ht,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`search`)})]})]}),we&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`py-2 px-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,V?`px-2`:`px-0 justify-center`,g?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.loops`),"aria-current":g?`page`:void 0,title:V?void 0:o(`arcSidebar.loops`),children:[(0,Q.jsx)(vi,{className:X(`w-4 h-4 flex-shrink-0`,g&&`text-accent-primary`)}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.loops`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:X(`mt-0.5 flex items-center gap-2 w-full h-8 rounded-md transition-colors`,V?`px-2`:`px-0 justify-center`,_?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":o(`arcSidebar.plugins`),"aria-current":_?`page`:void 0,title:V?void 0:o(`arcSidebar.plugins`),children:[(0,Q.jsx)(Hr,{className:X(`w-4 h-4 flex-shrink-0`,_&&`text-accent-primary`)}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.plugins`)})]})]}),(0,Q.jsx)(`div`,{className:`border-t border-border`,"aria-hidden":!0})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1.5 space-y-0.5`,children:[w&&E.length>0&&(0,Q.jsxs)(`div`,{className:`mb-2 space-y-0.5 border-b border-border/70 pb-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>N(XV),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`favoriteMissions`),"aria-expanded":A,title:V?void 0:s(`favoriteMissions`),children:[V?(0,Q.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Q.jsx)(pr,{className:`h-4 w-4 fill-current text-accent-primary transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,Q.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:A?(0,Q.jsx)(pe,{className:`w-3.5 h-3.5`}):(0,Q.jsx)(xe,{className:`w-3.5 h-3.5`})})]}):(0,Q.jsx)(pr,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),V&&(0,Q.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`favoriteMissions`)})]}),A&&V&&(0,Q.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:E.map(e=>(0,Q.jsx)(ZV,{conversation:e,active:e.id===C.active?.id,streaming:C.streamingConversationIds.has(e.id),unread:C.unreadConversationIds.has(e.id),favorite:!0,expanded:V,onSelect:()=>P(e.id),onToggleFavorite:()=>L(e.id),onDelete:()=>F(e.id)},e.id))})]}),w&&D.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>N(YV),className:X(`group flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":s(`home`),"aria-expanded":O.has(YV),title:V?void 0:s(`home`),children:[V?(0,Q.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,Q.jsx)(hr,{className:`h-4 w-4 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,Q.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:O.has(YV)?(0,Q.jsx)(pe,{className:`w-3.5 h-3.5`}):(0,Q.jsx)(xe,{className:`w-3.5 h-3.5`})})]}):(0,Q.jsx)(hr,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`home`)})]}),O.has(YV)&&V&&(0,Q.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:D.map(e=>(0,Q.jsx)(ZV,{conversation:e,active:e.id===C.active?.id,streaming:C.streamingConversationIds.has(e.id),unread:C.unreadConversationIds.has(e.id),expanded:V,onSelect:()=>P(e.id),onToggleFavorite:()=>L(e.id),onDelete:()=>F(e.id)},e.id))})]}),c.map(e=>{let t=T.get(e.id)??[];return(0,Q.jsx)(QV,{project:e,isActive:e.id===l&&!v,expanded:V,onSelect:()=>R(e.id),onRemove:()=>te(e),agentMode:w,hasTree:t.length>0,treeOpen:O.has(e.id),onToggleTree:()=>N(e.id),conversations:t,activeConversationId:C.active?.id??null,streamingConversationIds:C.streamingConversationIds,unreadConversationIds:C.unreadConversationIds,onSelectConversation:P,onToggleConversationFavorite:L,onDeleteConversation:F,onOpenProjectSettings:w?()=>{d(e.id),M(!0)}:void 0},e.id)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":o(`projects.addProject`),title:V?void 0:o(`projects.addProject`),children:[(0,Q.jsx)(pt,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`projects.addProject`)})]})]}),(0,Q.jsx)(`div`,{className:`border-t border-border py-2 px-1.5 space-y-0.5`,children:ee.map(({label:e,icon:t,action:n})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,`text-muted-foreground hover:text-foreground hover:bg-muted/50`,V?`px-2`:`px-0 justify-center`),"aria-label":e,title:V?void 0:e,children:[(0,Q.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:e})]},e))}),j&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(WV,{open:!0,onClose:()=>M(!1)})})]})}function tH({open:e,onClose:t,onCommitted:n,projectId:r,milestoneId:i,blueprint:a}){let{t:o}=I(`builder`),{registerHandler:s,unregisterHandler:c}=Et(),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=(0,Z.useRef)(r),D=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{T.current=l},[l]),(0,Z.useEffect)(()=>{E.current=r},[r]);let O=a.milestones.find(e=>e.id===i),k=i.toUpperCase(),A=(0,Z.useMemo)(()=>rV(_??h,{milestoneLabel:k,minSpecs:1,maxSpecs:10,requireScaffold:!1}),[h,_,k]);(0,Z.useEffect)(()=>{if(!e||l)return;let t=!1;return fetch(`${Ot()}/chat/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`milestone`,milestone:i})}).then(e=>e.json()).then(e=>{if(t||!e.conversation)return;u(e.conversation.id);let n=O?.plannedSpecs??[],r={label:k,title:O?.title??k,planned:n.join(`; `)},i=n.length>0?o(`prompts.milestoneSeedWithPlanned`,r):o(`prompts.milestoneSeed`,r);f([{role:`user`,content:i}]),S(!0),fetch(`${Ot()}/chat/conversations/${e.conversation.id}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:i})}).catch(()=>{S(!1),R.error(o(`errors.turnFailed`))})}).catch(()=>{t||R.error(o(`errors.startFailed`))}),()=>{t=!0}},[e,l,i,O,k,o]),(0,Z.useEffect)(()=>{if(!e)return;let t=`milestone-generate-${i}`;return s(t,e=>{let t=e;if(t.conversationId===T.current&&!(t.projectId&&t.projectId!==E.current))if(t.type===`chat_stream`)m(e=>(e??``)+String(t.delta??``));else if(t.type===`chat_done`){m(null),S(!1);let e=String(t.fullText??``),n=RB(e);f(t=>[...t,{role:`assistant`,content:n.stripped.trim()||e}]),n.blueprint&&(g(n.blueprint),v(n.rawBlueprint))}else t.type===`chat_error`&&(m(null),S(!1),R.error(o(`errors.turnFailed`),{description:String(t.error??``)}))}),()=>c(t)},[e,i,s,c,o]),(0,Z.useEffect)(()=>{D.current?.scrollTo?.({top:D.current.scrollHeight})},[d,p]);let j=(0,Z.useCallback)(e=>{let t=T.current,n=e.trim();!t||!n||x||(f(e=>[...e,{role:`user`,content:n}]),b(``),S(!0),fetch(`${Ot()}/chat/conversations/${t}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n})}).catch(()=>{S(!1),R.error(o(`errors.turnFailed`))}))},[x,o]),M=(0,Z.useCallback)(()=>{let e=_??h,r=e&&typeof e==`object`&&!Array.isArray(e)?e:null,a=Array.isArray(r?.m1Specs)?r.m1Specs:[];!A.valid||C||(w(!0),fetch(`${Ot()}/blueprint/commit-milestone`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({milestoneId:i,specsComplete:r?.specsComplete,specs:a})}).then(async e=>{if(e.status===201){let r=await e.json();R.success(o(`milestone.commitToast`,{count:r.insertedIds.length,label:k})),n?.(),t()}else{let t=await e.json().catch(()=>({}));R.error(o(`milestone.commitFailed`),{description:t.detail??t.error})}}).catch(()=>R.error(o(`milestone.commitFailed`))).finally(()=>w(!1)))},[h,_,A.valid,C,i,k,t,n,o]);if(!e)return null;let N=h?.m1Specs.length??0;return(0,Q.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-sm`,"data-testid":`milestone-shell`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/40 px-4 py-2.5`,children:[(0,Q.jsx)(dr,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsx)(`h1`,{className:`text-sm font-semibold`,children:o(`milestone.title`,{label:k})}),O&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O.title}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":o(`shell.close`),"data-testid":`milestone-close`,children:(0,Q.jsx)(yt,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col border-r border-border/40`,children:[(0,Q.jsxs)(`div`,{ref:D,className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[d.map((e,t)=>(0,Q.jsx)(`div`,{className:X(`max-w-[85%] whitespace-pre-wrap rounded-lg px-3 py-2 text-xs leading-relaxed`,e.role===`user`?`ml-auto bg-accent-primary/15`:`bg-surface/70`),children:e.content},t)),p!==null&&(0,Q.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-lg bg-surface/70 px-3 py-2 text-xs leading-relaxed`,children:[zB(p),(0,Q.jsx)(`span`,{className:`ml-0.5 inline-block h-3 w-1.5 animate-pulse bg-accent-primary/70 align-middle`})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-border/40 p-3`,children:[(0,Q.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),j(y))},rows:2,placeholder:o(`milestone.inputPlaceholder`),className:`min-h-[2.5rem] flex-1 resize-none rounded-md border border-border/40 bg-surface/50 px-3 py-2 text-xs focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`}),(0,Q.jsx)(Y,{size:`sm`,onClick:()=>j(y),disabled:x||!y.trim()||!l,children:x?(0,Q.jsx)(ut,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(ei,{className:`h-3.5 w-3.5`})})]})]}),(0,Q.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col lg:w-96`,children:[(0,Q.jsx)(mV,{blueprint:h,milestoneLabel:k}),(0,Q.jsxs)(`div`,{className:`border-t border-border/40 p-3`,children:[(0,Q.jsxs)(Y,{className:`w-full`,size:`sm`,disabled:!A.valid||C,onClick:M,"data-testid":`milestone-commit`,children:[C?(0,Q.jsx)(ut,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),o(`milestone.commit`,{count:N,label:k})]}),!A.valid&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,"data-testid":`milestone-quality-detail`,children:A.issues[0]?.message})]})]})]})]})}function nH(e,t=0){let[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(!e){r(null);return}let t=!1;return fetch(`/api/projects/${e}/blueprint`,{cache:`no-store`}).then(e=>e.ok?e.json():null).then(e=>{t||r(e?LB(e.blueprint):null)}).catch(()=>{t||r(null)}),()=>{t=!0}},[e,t]),n}function rH(e,t){return e.milestones.map((e,n)=>{let r=n+1,i=KB(r),a=t.filter(e=>Array.isArray(e.labels)&&e.labels.includes(i));return{id:e.id,title:e.title,status:e.status,n:r,done:a.filter(e=>e.status===`done`).length,total:a.length}})}function iH({expanded:e}){let{t}=I(`builder`),{activeProjectId:n}=At(),[r,i]=(0,Z.useState)(0),a=nH(n,r),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!o||!n)return;let e=!1;return fetch(`${Ot()}/tickets`,{cache:`no-store`}).then(e=>e.json()).then(t=>{e||l(Array.isArray(t)?t:t.tickets??[])}).catch(()=>{}),()=>{e=!0}},[o,n]),(0,Z.useEffect)(()=>{if(!o)return;let e=e=>{m.current&&!m.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let h=(0,Z.useCallback)(async()=>{if(!(!n||u)){d(!0);try{let e=await JB(n,1);e.ok?(R.success(t(`done.launchToast`,{count:e.ticketCount})),s(!1)):R.error(t(`done.launchFailed`),{description:e.detail??e.reason})}finally{d(!1)}}},[n,u,t]);if(!a||!n)return null;let g=rH(a,c),_=c.some(e=>e.status===`todo`&&e.labels?.includes(`M1`)),v=g.find(e=>e.status===`planned`&&e.n>1);return(0,Q.jsxs)(`div`,{ref:m,className:`relative`,"data-testid":`builder-sidebar-entry`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,e?`px-2`:`px-0 justify-center`,o?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:e?void 0:t(`sidebar.title`),"data-testid":`builder-sidebar-toggle`,children:[(0,Q.jsx)(dr,{className:`w-4 h-4 flex-shrink-0`}),e&&(0,Q.jsx)(`span`,{className:`text-xs truncate`,children:t(`sidebar.title`)})]}),o&&(0,Q.jsxs)(`div`,{className:`absolute top-0 right-full z-[60] mr-2 w-64 rounded-lg border border-border/50 bg-background p-3 shadow-xl`,"data-testid":`builder-sidebar-panel`,children:[(0,Q.jsx)(`h4`,{className:`text-xs font-semibold`,children:t(`sidebar.title`)}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:g.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/30 px-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] font-semibold text-accent-primary`,children:t(`sidebar.milestone`,{n:e.n})}),(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium`,children:e.title}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] tabular-nums text-muted-foreground`,children:t(`sidebar.progress`,{done:e.done,total:e.total})})]}),e.total>0&&(0,Q.jsx)(`div`,{className:`mt-1 h-1 overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent-success transition-all`,style:{width:`${Math.round(e.done/e.total*100)}%`}})})]},e.id||e.n))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[_&&(0,Q.jsxs)(`button`,{type:`button`,onClick:h,disabled:u,className:`inline-flex items-center justify-center gap-1.5 rounded-md bg-accent-primary/15 px-2 py-1.5 text-[11px] font-medium text-accent-primary transition-colors hover:bg-accent-primary/25 disabled:opacity-50`,"data-testid":`sidebar-launch-m1`,children:[u?(0,Q.jsx)(ut,{className:`h-3 w-3 animate-spin`}):(0,Q.jsx)(Yr,{className:`h-3 w-3`}),t(`sidebar.launchM1`)]}),v&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{p(v.id),s(!1)},className:`inline-flex items-center justify-center gap-1.5 rounded-md border border-accent-highlight/40 px-2 py-1.5 text-[11px] font-medium text-accent-highlight transition-colors hover:bg-accent-highlight/10`,title:t(`sidebar.generateHint`),"data-testid":`sidebar-generate-next`,children:[(0,Q.jsx)(gt,{className:`h-3 w-3`}),t(`sidebar.generateNext`,{n:v.n})]})]})]}),f&&(0,Q.jsx)(tH,{open:!0,onClose:()=>p(null),onCommitted:()=>i(e=>e+1),projectId:n,milestoneId:f,blueprint:a})]})}var aH={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function oH(){let{t:e}=I(`nav`),{rightMode:t,cycleRightMode:n}=fE(),{projects:r,activeProjectId:i}=At(),[a,o]=(0,Z.useState)(!1),s=t===`pinned-open`||t===`unpinned`&&a,c=t!==`unpinned`,l=e(aH[t]),u=r.find(e=>e.id===i),d=u?kt(u):[`claude`],f=nt&&vh(`agents`,d),p=[{to:`/`,end:!0,icon:Sr,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:Dn,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:kn,label:e(`rightSidebar.analytics`)},...f?[{to:`/agents`,end:!1,icon:wn,label:e(`rightSidebar.agents`)}]:[],...it?[{to:`/code`,end:!1,icon:zn,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:ni,label:e(`rightSidebar.settings`)}];return(0,Q.jsxs)(`div`,{className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0`,`transition-all duration-200 ease-in-out overflow-hidden`,s?`w-44`:`w-11`),onMouseEnter:()=>{t===`unpinned`&&o(!0)},onMouseLeave:()=>{t===`unpinned`&&o(!1)},children:[(0,Q.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,s?`px-3 justify-between`:`justify-center`),children:[s&&(0,Q.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`rightSidebar.projectTitle`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,c?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":l,title:e(`sidebarPin.withShortcut`,{label:l,shortcut:`⌘B`}),children:(0,Q.jsx)(Ir,{className:`w-4 h-4`})})]}),(0,Q.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,Q.jsx)(iH,{expanded:s}),p.map(({to:e,end:t,icon:n,label:r})=>(0,Q.jsxs)(h,{to:e,end:t,className:({isActive:e})=>X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,s?`px-2`:`px-0 justify-center`,e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:s?void 0:r,children:[(0,Q.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}),s&&(0,Q.jsx)(`span`,{className:`text-xs truncate`,children:r})]},e))]})]})}function sH(e){return{darwin:{title:`macOS`,intro:e(`setup:instructions.darwin.intro`),commands:[{label:e(`setup:instructions.darwin.installNodeGit`),command:`brew install node git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`},{label:`Homebrew`,url:`https://brew.sh`}]},win32:{title:`Windows`,intro:e(`setup:instructions.win32.intro`),commands:[{label:e(`setup:instructions.win32.installNode`),command:`winget install OpenJS.NodeJS.LTS`},{label:e(`setup:instructions.win32.installGit`),command:`winget install Git.Git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitWindows`),url:`https://git-scm.com/download/win`}],note:e(`setup:instructions.win32.note`)},linux:{title:`Linux`,intro:e(`setup:instructions.linux.intro`),commands:[{label:e(`setup:instructions.linux.debian`),command:`sudo apt install -y nodejs npm git`},{label:e(`setup:instructions.linux.fedora`),command:`sudo dnf install -y nodejs npm git`}],links:[{label:e(`setup:instructions.links.nodeOfficial`),url:`https://nodejs.org/en/download`},{label:e(`setup:instructions.links.gitOfficial`),url:`https://git-scm.com/downloads`}]}}}var cH=[`darwin`,`win32`,`linux`];async function lH(e){try{if(navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function uH({command:e}){let{t}=I(`setup`),[n,r]=(0,Z.useState)(!1);return(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await lH(e)&&(r(!0),window.setTimeout(()=>r(!1),1500))},className:`h-7 px-2 gap-1.5 text-[11px]`,"data-testid":`install-copy-button`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(be,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Un,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function dH({platform:e,primary:t}){let{t:n}=I(`setup`),r=sH(n)[e];return(0,Q.jsxs)(`section`,{"data-testid":`install-section-${e}`,className:X(`rounded-lg border px-3 py-3`,t?`border-border/40 bg-background/40`:`border-border/20 bg-background/20`),children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r.title}),r.intro&&(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r.intro}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-2`,children:r.commands.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/30 bg-background/60 px-2 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-1`,children:e.label}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`code`,{className:`text-xs text-foreground font-mono break-all`,children:e.command}),(0,Q.jsx)(uH,{command:e.command})]})]},e.command))}),r.links.length>0&&(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1`,children:r.links.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-accent-info hover:underline`,children:[e.label,(0,Q.jsx)(J,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function fH(){let{t:e}=I(`setup`),[t,n]=(0,Z.useState)(`idle`);return(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{n(`copying`);try{let e=await fetch(`${xt}/api/setup-prerequisites?diagnostic=1`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();await navigator.clipboard.writeText(JSON.stringify(t,null,2)),n(`copied`),setTimeout(()=>n(`idle`),1800)}catch{n(`error`),setTimeout(()=>n(`idle`),2400)}},disabled:t===`copying`,className:`gap-1.5 text-[11px]`,"data-testid":`copy-diagnostics-button`,children:[t===`copied`?(0,Q.jsx)(be,{className:`w-3 h-3 text-accent-success`}):(0,Q.jsx)(In,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function pH({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=I(`setup`),[o,s]=(0,Z.useState)(!1),c=n?.platform??`darwin`,l=cH.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,Q.jsx)(nn,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Zt,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:a(`instructions.corrupted.title`)}),(0,Q.jsx)(en,{children:a(`instructions.corrupted.description`)})]}),(0,Q.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`instructions.corrupted.body`)}),(0,Q.jsx)(`div`,{className:`flex justify-end mt-2`,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,"data-testid":`install-corrupted-close-button`,children:a(`common:actions.close`)})})]})}):(0,Q.jsx)(nn,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Zt,{movableResizable:!0,className:`max-w-xl`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsx)(Qt,{children:a(`instructions.title`)}),(0,Q.jsx)(en,{children:a(`instructions.description`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(dH,{platform:c,primary:!0}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground underline-offset-2 hover:underline`,"data-testid":`install-toggle-others`,children:a(o?`instructions.hideOtherPlatforms`:`instructions.showOtherPlatforms`)}),o&&(0,Q.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,Q.jsx)(dH,{platform:e,primary:!1},e))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,Q.jsx)(fH,{}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:a(`common:actions.close`)}),(0,Q.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,onClick:r,disabled:i,className:`gap-1.5`,"data-testid":`install-recheck-button`,children:[(0,Q.jsx)(qr,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var mH=typeof window<`u`&&`__TAURI_INTERNALS__`in window,hH=[`claude`,`codex`,`gemini`],gH={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`}};function _H(e){let t=hH.filter(t=>t in e),n=Object.keys(e).filter(e=>!hH.includes(e));return[...t,...n]}function vH({open:e,onClose:t,onOpenBuilder:n}){let r=Pe&&!!n,[i,a]=(0,Z.useState)(r?`choose`:`existing`),[o,s]=(0,Z.useState)(new Set([`claude`])),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)({claude:!0,codex:!1}),[_,v]=(0,Z.useState)(!1),{t:y}=I(`setup`),{addProject:b,startSetupWizard:x,setActiveProjectId:S}=At(),{status:C,isLoading:w,error:T,recheck:E}=sT(),D=(0,Z.useMemo)(()=>{if(!C||C.ok)return null;let e=C.missingRequired.map(e=>e.label);return e.length===0?null:y(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[C,y]),O=C!==null&&!C.ok&&!T;(0,Z.useEffect)(()=>{e&&fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n!==`tiers`&&(t[n]=!!r);g(t);let n=new Set;for(let e of _H(t))t[e]&&n.add(e);n.size===0&&n.add(`claude`),s(n)}).catch(()=>{})},[e]);function k(e){s(t=>{let n=new Set(t);if(n.has(e)){if(n.size===1)return t;n.delete(e)}else n.add(e);return n})}let A=_H(h).filter(e=>o.has(e)&&h[e]);async function j(){let e=l.trim();if(!e){R.error(y(`addProject.errors.pathRequired`));return}if(A.length===0){R.error(y(`addProject.errors.selectProvider`));return}m(!0);try{let t=await b(e,d.trim()||void 0,A);if(!t)return;let{project:n}=t;t.has_specrails===!1?(M(),S(n.id),x(n.id)):(R.success(y(`addProject.toasts.registered`,{name:n.name})),M())}catch(e){R.error(y(`addProject.errors.addFailed`),{description:e.message})}finally{m(!1)}}function M(){u(``),f(``),a(r?`choose`:`existing`),t()}function N(e){e||M()}let P=!Object.values(h).some(Boolean);return i===`choose`?(0,Q.jsx)(nn,{open:e,onOpenChange:N,children:(0,Q.jsxs)(Zt,{className:`max-w-md`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsxs)(Qt,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(rr,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,Q.jsx)(en,{children:y(`addProject.chooser.description`)})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 py-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`chooser-existing`,onClick:()=>a(`existing`),className:`flex flex-col items-start gap-2 rounded-lg border border-border/40 p-4 text-left transition-colors hover:border-accent-primary/50 hover:bg-accent-primary/5 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[(0,Q.jsx)(nr,{className:`h-5 w-5 text-accent-info`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.existingTitle`)}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.existingDescription`)})]}),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`chooser-new`,onClick:()=>{M(),n?.()},className:`flex flex-col items-start gap-2 rounded-lg border border-border/40 p-4 text-left transition-colors hover:border-accent-highlight/50 hover:bg-accent-highlight/5 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:[(0,Q.jsx)(gt,{className:`h-5 w-5 text-accent-highlight`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.newTitle`)}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.newDescription`)})]})]})]})}):(0,Q.jsx)(nn,{open:e,onOpenChange:N,children:(0,Q.jsxs)(Zt,{movableResizable:!0,className:`max-w-md`,children:[(0,Q.jsxs)(Vt,{children:[(0,Q.jsxs)(Qt,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(rr,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,Q.jsx)(en,{children:y(`addProject.description`)})]}),P&&(0,Q.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:y(`addProject.noProviderDetected`)}),(0,Q.jsx)(lT,{status:C,isLoading:w,error:T,onMoreInfo:()=>v(!0),onRefresh:E}),(0,Q.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.pathLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(ox,{placeholder:y(`addProject.pathPlaceholder`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&j()},autoFocus:!0,className:`flex-1`}),mH&&(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,title:y(`addProject.browseForFolder`),onClick:async()=>{try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-jwoXo0YD.js`);return{open:e}},[]),t=await e({directory:!0,multiple:!1,title:y(`addProject.selectProjectFolder`)});typeof t==`string`&&t&&(u(t),d||f(t.split(`/`).filter(Boolean).pop()??``))}catch{}},children:(0,Q.jsx)(rr,{className:`w-4 h-4`})})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.pathHint`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.nameLabel`),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:y(`addProject.optional`)})]}),(0,Q.jsx)(ox,{placeholder:y(`addProject.namePlaceholder`),value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&j()}}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.nameHint`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:y(`addProject.providersLabel`)}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:_H(h).map(e=>{let{icon:t,label:n}=gH[e]??{icon:`•`,label:e},r=h[e],i=o.has(e)&&r;return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":i,disabled:!r,onClick:()=>k(e),"data-testid":`provider-toggle-${e}`,className:X(`flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-left transition-colors text-xs`,`focus:outline-none focus-visible:ring-1 focus-visible:ring-ring`,i?`border-accent-primary/60 bg-accent-primary/10 text-foreground`:`border-border/30 text-muted-foreground hover:border-border/60`,!r&&`opacity-40 cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:X(`inline-flex h-3.5 w-3.5 items-center justify-center rounded-sm border text-[9px] leading-none`,i?`border-accent-primary bg-accent-primary text-background`:`border-border/50`),"aria-hidden":!0,children:i?`✓`:``}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n}),!r&&(0,Q.jsx)(`span`,{className:`text-[9px] text-muted-foreground/60`,children:y(`addProject.notFound`)})]},e)})}),(0,Q.jsx)(`p`,{className:`text-[9px] text-muted-foreground/70`,children:A.length>1?y(`addProject.multiProviderHint`):y(`addProject.singleProviderHint`)})]})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:t,disabled:p,children:y(`common:actions.cancel`)}),(0,Q.jsx)(Y,{size:`sm`,onClick:j,disabled:p||!l.trim()||P||A.length===0||O||w,title:O?D??void 0:void 0,"data-testid":`add-project-submit`,children:y(p?`addProject.adding`:`addProject.submit`)})]}),(0,Q.jsx)(pH,{open:_,onClose:()=>v(!1),status:C,onRecheck:E,isRechecking:w})]})})}var yH=1,bH=.9,xH=.8,SH=.17,CH=.1,wH=.999,TH=.9999,EH=.99,DH=/[\\\/_+.#"@\[\(\{&]/,OH=/[\\\/_+.#"@\[\(\{&]/g,kH=/[\s-]/,AH=/[\s-]/g;function jH(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?yH:EH;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=jH(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=yH:DH.test(e.charAt(l-1))?(d*=xH,p=e.slice(i,l-1).match(OH),p&&i>0&&(d*=wH**+p.length)):kH.test(e.charAt(l-1))?(d*=bH,m=e.slice(i,l-1).match(AH),m&&i>0&&(d*=wH**+m.length)):(d*=SH,i>0&&(d*=wH**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=TH)),(d<CH&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=jH(e,t,n,r,l+1,a+2,o),f*CH>d&&(d=f*CH)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function MH(e){return e.toLowerCase().replace(AH,` `)}function NH(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,jH(e,t,MH(e),MH(t),0,0,{})}var PH=`[cmdk-group=""]`,FH=`[cmdk-group-items=""]`,IH=`[cmdk-group-heading=""]`,LH=`[cmdk-item=""]`,RH=`${LH}:not([aria-disabled="true"])`,zH=`cmdk-item-select`,BH=`data-value`,VH=(e,t,n)=>NH(e,t,n),HH=Z.createContext(void 0),UH=()=>Z.useContext(HH),WH=Z.createContext(void 0),GH=()=>Z.useContext(WH),KH=Z.createContext(void 0),qH=Z.forwardRef((e,t)=>{let n=sU(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=sU(()=>new Set),i=sU(()=>new Map),a=sU(()=>new Map),o=sU(()=>new Set),s=aU(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=on(),y=on(),b=on(),x=Z.useRef(null),S=uU();oU(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),oU(()=>{S(6,k)},[]);let C=Z.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Z.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??VH;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(FH);t?t.appendChild(e.parentElement===t?e:e.closest(`${FH} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${FH} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${PH}[${BH}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(BH);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(PH)?.querySelector(IH))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${LH}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(RH)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(BH))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(BH))}function P(e){let t=A()?.closest(PH),n;for(;t&&!n;)t=e>0?rU(t,PH):iU(t,PH),n=t?.querySelector(RH);n?C.setState(`value`,n.getAttribute(BH)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Z.createElement(Rt.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(zH);t.dispatchEvent(e)}}}}},Z.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:pU},c),fU(e,e=>Z.createElement(WH.Provider,{value:C},Z.createElement(HH.Provider,{value:w},e))))}),JH=Z.forwardRef((e,t)=>{let n=on(),r=Z.useRef(null),i=Z.useContext(KH),a=UH(),o=aU(e),s=o.current?.forceMount??i?.forceMount;oU(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=lU(n,r,[e.value,e.children,r],e.keywords),l=GH(),u=cU(e=>e.value&&e.value===c.current),d=cU(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);Z.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(zH,f),()=>t.removeEventListener(zH,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Z.createElement(Rt.div,{ref:Nt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),YH=Z.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=on(),s=Z.useRef(null),c=Z.useRef(null),l=on(),u=UH(),d=cU(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));oU(()=>u.group(o),[]),lU(o,s,[e.value,e.heading,c]);let f=Z.useMemo(()=>({id:o,forceMount:i}),[i]);return Z.createElement(Rt.div,{ref:Nt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&Z.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),fU(e,e=>Z.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Z.createElement(KH.Provider,{value:f},e))))}),XH=Z.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Z.useRef(null),a=cU(e=>!e.search);return!n&&!a?null:Z.createElement(Rt.div,{ref:Nt(i,t),...r,"cmdk-separator":``,role:`separator`})}),ZH=Z.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=GH(),o=cU(e=>e.search),s=cU(e=>e.selectedItemId),c=UH();return Z.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Z.createElement(Rt.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),QH=Z.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Z.useRef(null),o=Z.useRef(null),s=cU(e=>e.selectedItemId),c=UH();return Z.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Z.createElement(Rt.div,{ref:Nt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},fU(e,e=>Z.createElement(`div`,{ref:Nt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),$H=Z.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Z.createElement(Gt,{open:n,onOpenChange:r},Z.createElement(Wt,{container:o},Z.createElement(rn,{"cmdk-overlay":``,className:i}),Z.createElement(Yt,{"aria-label":e.label,"cmdk-dialog":``,className:a},Z.createElement(qH,{ref:t,...s}))))}),eU=Z.forwardRef((e,t)=>cU(e=>e.filtered.count===0)?Z.createElement(Rt.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),tU=Z.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Z.createElement(Rt.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},fU(e,e=>Z.createElement(`div`,{"aria-hidden":!0},e)))}),nU=Object.assign(qH,{List:QH,Item:JH,Input:ZH,Group:YH,Separator:XH,Dialog:$H,Empty:eU,Loading:tU});function rU(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function iU(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function aU(e){let t=Z.useRef(e);return oU(()=>{t.current=e}),t}var oU=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function sU(e){let t=Z.useRef();return t.current===void 0&&(t.current=e()),t}function cU(e){let t=GH(),n=()=>e(t.snapshot());return Z.useSyncExternalStore(t.subscribe,n,n)}function lU(e,t,n,r=[]){let i=Z.useRef(),a=UH();return oU(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(BH,s),i.current=s}),i}var uU=()=>{let[e,t]=Z.useState(),n=sU(()=>new Map);return oU(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function dU(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function fU({asChild:e,children:t},n){return e&&Z.isValidElement(t)?Z.cloneElement(dU(t),{ref:t.ref},n(t.props.children)):n(t)}var pU={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function mU({onOpenSettings:e,onOpenAnalytics:t,onOpenDocs:n}){let{t:r}=I(`commands`),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),{projects:u,activeProjectId:d,setActiveProjectId:f}=At(),{leftMode:m,rightMode:h,cycleLeftMode:g,cycleRightMode:_}=fE(),v=r(m===`pinned-open`?`palette.sidebar.collapseLeftKeepPinned`:m===`pinned-collapsed`?`palette.sidebar.unpinLeft`:`palette.sidebar.pinLeftOpen`),y=r(h===`pinned-open`?`palette.sidebar.collapseRightKeepPinned`:h===`pinned-collapsed`?`palette.sidebar.unpinRight`:`palette.sidebar.pinRightOpen`),b=p(),x=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,Z.useEffect)(()=>{if(!i){x.current=!1;return}if(x.current)return;x.current=!0;async function e(){try{let[e,t]=await Promise.all([fetch(`${Ot()}/config`),fetch(`${Ot()}/jobs?limit=10`)]);if(e.ok){let t=await e.json();s(t.commands)}if(t.ok){let e=await t.json();l(e.jobs)}}catch{}}e()},[i]);let S=(0,Z.useCallback)(e=>{f(e),a(!1)},[f]),C=(0,Z.useCallback)(async e=>{a(!1);try{let t=await fetch(`${Ot()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:`/specrails:${e}`})}),n=await t.json();if(!t.ok)throw Error(n.error??r(`errors.spawnFailed`));R.success(r(`toasts.queued`,{name:e})),b(`/jobs/${n.jobId}`)}catch(e){R.error(e instanceof Error?e.message:r(`errors.spawnFailed`))}},[b,r]),w=(0,Z.useCallback)(e=>{a(!1),b(`/jobs/${e}`)},[b]),T=(0,Z.useCallback)(e=>{a(!1),b(e)},[b]),E=(0,Z.useCallback)(e=>{e&&(a(!1),e())},[]),D=`flex items-center gap-3 px-3 py-2 rounded-lg cursor-pointer text-sm data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground`;return(0,Q.jsxs)(nU.Dialog,{open:i,onOpenChange:a,label:r(`palette.label`),className:X(`fixed left-[50%] top-[50%] z-50 w-full max-w-lg translate-x-[-50%] translate-y-[-50%]`,`border border-border/30 bg-popover shadow-2xl backdrop-blur-md rounded-xl overflow-hidden`),children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:r(`palette.label`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border/30`,children:[(0,Q.jsx)(ht,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(nU.Input,{placeholder:r(`palette.searchPlaceholder`),className:`flex-1 h-11 bg-transparent text-sm outline-none placeholder:text-muted-foreground/50`}),(0,Q.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-0.5 rounded border border-border/50 bg-muted/30 px-1.5 py-0.5 text-[10px] text-muted-foreground font-mono`,children:`esc`})]}),(0,Q.jsxs)(nU.List,{className:`max-h-80 overflow-y-auto p-2`,children:[(0,Q.jsx)(nU.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`palette.noResults`)}),u.length>0&&(0,Q.jsx)(nU.Group,{heading:r(`palette.groups.projects`),children:u.map(e=>(0,Q.jsxs)(nU.Item,{value:e.name,keywords:[e.slug],onSelect:()=>S(e.id),className:X(D,e.id===d&&`text-accent-primary`),children:[(0,Q.jsx)(rr,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),e.id===d&&(0,Q.jsx)(`span`,{className:`text-[10px] text-accent-primary font-medium`,children:r(`palette.activeBadge`)})]},e.id))}),o.length>0&&(0,Q.jsx)(nU.Group,{heading:r(`palette.groups.spec`),children:o.map(e=>(0,Q.jsxs)(nU.Item,{value:e.name,keywords:[e.slug,e.description??``],onSelect:()=>C(e.slug),className:D,children:[(0,Q.jsx)(bt,{className:`w-4 h-4 text-accent-info shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),e.description&&(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60 ml-2 truncate`,children:e.description})]})]},e.id))}),c.length>0&&(0,Q.jsx)(nU.Group,{heading:r(`palette.groups.jobs`),children:c.map(e=>(0,Q.jsxs)(nU.Item,{value:`${e.command} ${e.id}`,keywords:[e.status],onSelect:()=>w(e.id),className:D,children:[(0,Q.jsx)(Dn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e.command}),(0,Q.jsx)(`span`,{className:X(`text-[10px] font-medium`,e.status===`completed`&&`text-accent-success`,e.status===`failed`&&`text-destructive`,e.status===`running`&&`text-accent-info`,e.status===`queued`&&`text-muted-foreground`),children:r(`common:status.${e.status}`,{defaultValue:e.status})})]},e.id))}),(0,Q.jsxs)(nU.Group,{heading:r(`palette.groups.navigation`),children:[(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.dashboard`),keywords:[`home`],onSelect:()=>T(`/`),className:D,children:[(0,Q.jsx)(Sr,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.dashboard`)})]}),t&&(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.desktopAnalytics`),keywords:[`cross-project`,`desktop`],onSelect:()=>E(t),className:D,children:[(0,Q.jsx)(jn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.desktopAnalytics`)})]}),(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.projectAnalytics`),keywords:[`metrics`],onSelect:()=>T(`/analytics`),className:D,children:[(0,Q.jsx)(kn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.projectAnalytics`)})]}),(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.activityFeed`),keywords:[`log`],onSelect:()=>T(`/activity`),className:D,children:[(0,Q.jsx)(vn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.activityFeed`)})]}),(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.desktopSettings`),keywords:[`configuration`],onSelect:()=>e?E(e):T(`/settings`),className:D,children:[(0,Q.jsx)(ni,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.desktopSettings`)})]}),(0,Q.jsxs)(nU.Item,{value:r(`palette.nav.docs`),keywords:[`documentation`],onSelect:()=>n?E(n):T(`/docs`),className:D,children:[(0,Q.jsx)(ct,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:r(`palette.nav.docs`)})]}),(0,Q.jsxs)(nU.Item,{value:v,keywords:[`sidebar`,`panel`,`left`,`pin`,`collapse`,`unpin`,`cycle`],onSelect:()=>{g(),a(!1)},className:D,children:[(0,Q.jsx)(Fr,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:v})]}),(0,Q.jsxs)(nU.Item,{value:y,keywords:[`sidebar`,`panel`,`right`,`nav`,`pin`,`collapse`,`unpin`,`cycle`],onSelect:()=>{_(),a(!1)},className:D,children:[(0,Q.jsx)(Ir,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{children:y})]})]})]}),(0,Q.jsx)(`div`,{className:`flex items-center justify-between px-3 py-2 border-t border-border/30 text-[10px] text-muted-foreground/50`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{className:`font-mono`,children:`↑↓`}),` `,r(`palette.footer.navigate`)]}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{className:`font-mono`,children:`↵`}),` `,r(`palette.footer.select`)]}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{className:`font-mono`,children:`esc`}),` `,r(`palette.footer.close`)]})]})})]})}var hU=`
|
|
64
64
|
|
|
65
65
|
---
|
|
66
66
|
|
|
@@ -73,4 +73,4 @@ Error generating stack: `+e.message+`
|
|
|
73
73
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh())),d.isLinux&&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)&&this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!(!n||!r)&&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=(0,f.getRangeLength)(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)}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=(0,a.getCoordsRelativeToElement)(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,-50),50),t/=50,t/Math.abs(t)+Math.round(14*t))}shouldForceSelection(e){return d.isMac?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()),50)}_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&&!(d.isMac&&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)return void this.refresh(!0);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<500&&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=(0,o.moveToCellSequence)(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!(!e||!t||e[0]===t[0]&&e[1]===t[1]);n?e&&t&&(this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,n)):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim((e=>this._handleTrim(e)))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;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&&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=(0,f.getRangeLength)(n,this._bufferService.cols)}};t.SelectionService=g=r([i(3,m.IBufferService),i(4,m.ICoreService),i(5,c.IMouseService),i(6,m.IOptionsService),i(7,c.IRenderService),i(8,c.ICoreBrowserService)],g)},4725:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ILinkProviderService=t.IThemeService=t.ICharacterJoinerService=t.ISelectionService=t.IRenderService=t.IMouseService=t.ICoreBrowserService=t.ICharSizeService=void 0;let r=n(8343);t.ICharSizeService=(0,r.createDecorator)(`CharSizeService`),t.ICoreBrowserService=(0,r.createDecorator)(`CoreBrowserService`),t.IMouseService=(0,r.createDecorator)(`MouseService`),t.IRenderService=(0,r.createDecorator)(`RenderService`),t.ISelectionService=(0,r.createDecorator)(`SelectionService`),t.ICharacterJoinerService=(0,r.createDecorator)(`CharacterJoinerService`),t.IThemeService=(0,r.createDecorator)(`ThemeService`),t.ILinkProviderService=(0,r.createDecorator)(`LinkProviderService`)},6731:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.ThemeService=t.DEFAULT_ANSI_COLORS=void 0;let a=n(7239),o=n(8055),s=n(8460),c=n(844),l=n(2585),u=o.css.toColor(`#ffffff`),d=o.css.toColor(`#000000`),f=o.css.toColor(`#ffffff`),p=o.css.toColor(`#000000`),m={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117};t.DEFAULT_ANSI_COLORS=Object.freeze((()=>{let e=[o.css.toColor(`#2e3436`),o.css.toColor(`#cc0000`),o.css.toColor(`#4e9a06`),o.css.toColor(`#c4a000`),o.css.toColor(`#3465a4`),o.css.toColor(`#75507b`),o.css.toColor(`#06989a`),o.css.toColor(`#d3d7cf`),o.css.toColor(`#555753`),o.css.toColor(`#ef2929`),o.css.toColor(`#8ae234`),o.css.toColor(`#fce94f`),o.css.toColor(`#729fcf`),o.css.toColor(`#ad7fa8`),o.css.toColor(`#34e2e2`),o.css.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:o.channels.toCss(r,i,a),rgba:o.channels.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+10*t;e.push({css:o.channels.toCss(n,n,n),rgba:o.channels.toRgba(n,n,n)})}return e})());let h=t.ThemeService=class extends c.Disposable{get colors(){return this._colors}constructor(e){super(),this._optionsService=e,this._contrastCache=new a.ColorContrastCache,this._halfContrastCache=new a.ColorContrastCache,this._onChangeColors=this.register(new s.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:u,background:d,cursor:f,cursorAccent:p,selectionForeground:void 0,selectionBackgroundTransparent:m,selectionBackgroundOpaque:o.color.blend(d,m),selectionInactiveBackgroundTransparent:m,selectionInactiveBackgroundOpaque:o.color.blend(d,m),ansi:t.DEFAULT_ANSI_COLORS.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))))}_setTheme(e={}){let n=this._colors;if(n.foreground=g(e.foreground,u),n.background=g(e.background,d),n.cursor=g(e.cursor,f),n.cursorAccent=g(e.cursorAccent,p),n.selectionBackgroundTransparent=g(e.selectionBackground,m),n.selectionBackgroundOpaque=o.color.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=g(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=o.color.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?g(e.selectionForeground,o.NULL_COLOR):void 0,n.selectionForeground===o.NULL_COLOR&&(n.selectionForeground=void 0),o.color.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=o.color.opacity(n.selectionBackgroundTransparent,.3)),o.color.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=o.color.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.ansi=t.DEFAULT_ANSI_COLORS.slice(),n.ansi[0]=g(e.black,t.DEFAULT_ANSI_COLORS[0]),n.ansi[1]=g(e.red,t.DEFAULT_ANSI_COLORS[1]),n.ansi[2]=g(e.green,t.DEFAULT_ANSI_COLORS[2]),n.ansi[3]=g(e.yellow,t.DEFAULT_ANSI_COLORS[3]),n.ansi[4]=g(e.blue,t.DEFAULT_ANSI_COLORS[4]),n.ansi[5]=g(e.magenta,t.DEFAULT_ANSI_COLORS[5]),n.ansi[6]=g(e.cyan,t.DEFAULT_ANSI_COLORS[6]),n.ansi[7]=g(e.white,t.DEFAULT_ANSI_COLORS[7]),n.ansi[8]=g(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),n.ansi[9]=g(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),n.ansi[10]=g(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),n.ansi[11]=g(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),n.ansi[12]=g(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),n.ansi[13]=g(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),n.ansi[14]=g(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),n.ansi[15]=g(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),e.extendedAnsi){let r=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<r;i++)n.ansi[i+16]=g(e.extendedAnsi[i],t.DEFAULT_ANSI_COLORS[i+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)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]}else for(let e=0;e<this._restoreColors.ansi.length;++e)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()}}};function g(e,t){if(e!==void 0)try{return o.css.toColor(e)}catch{}return t}t.ThemeService=h=r([i(0,l.IOptionsService)],h)},6349:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CircularList=void 0;let r=n(8460),i=n(844);class a extends i.Disposable{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this.register(new r.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new r.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new r.EventEmitter),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}}t.CircularList=a},1439:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clone=void 0,t.clone=function e(t,n=5){if(typeof t!=`object`)return t;let r=Array.isArray(t)?[]:{};for(let i in t)r[i]=n<=1?t[i]:t[i]&&e(t[i],n-1);return r}},8055:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.contrastRatio=t.toPaddedHex=t.rgba=t.rgb=t.css=t.color=t.channels=t.NULL_COLOR=void 0;let n=0,r=0,i=0,a=0;var o,s,c,l,u;function d(e){let t=e.toString(16);return t.length<2?`0`+t:t}function f(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}t.NULL_COLOR={css:`#00000000`,rgba:0},function(e){e.toCss=function(e,t,n,r){return r===void 0?`#${d(e)}${d(t)}${d(n)}`:`#${d(e)}${d(t)}${d(n)}${d(r)}`},e.toRgba=function(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0},e.toColor=function(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}}(o||(t.channels=o={})),function(e){function t(e,t){return a=Math.round(255*t),[n,r,i]=u.toChannels(e.rgba),{css:o.toCss(n,r,i,a),rgba:o.toRgba(n,r,i,a)}}e.blend=function(e,t){if(a=(255&t.rgba)/255,a===1)return{css:t.css,rgba:t.rgba};let s=t.rgba>>24&255,c=t.rgba>>16&255,l=t.rgba>>8&255,u=e.rgba>>24&255,d=e.rgba>>16&255,f=e.rgba>>8&255;return n=u+Math.round((s-u)*a),r=d+Math.round((c-d)*a),i=f+Math.round((l-f)*a),{css:o.toCss(n,r,i),rgba:o.toRgba(n,r,i)}},e.isOpaque=function(e){return(255&e.rgba)==255},e.ensureContrastRatio=function(e,t,n){let r=u.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return o.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[n,r,i]=u.toChannels(t),{css:o.toCss(n,r,i),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,n){return a=255&e.rgba,t(e,a*n/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}}(s||(t.color=s={})),function(e){let t,s;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let n=e.getContext(`2d`,{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation=`copy`,s=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return n=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),i=parseInt(e.slice(3,4).repeat(2),16),o.toColor(n,r,i);case 5:return n=parseInt(e.slice(1,2).repeat(2),16),r=parseInt(e.slice(2,3).repeat(2),16),i=parseInt(e.slice(3,4).repeat(2),16),a=parseInt(e.slice(4,5).repeat(2),16),o.toColor(n,r,i,a);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 c=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(c)return n=parseInt(c[1]),r=parseInt(c[2]),i=parseInt(c[3]),a=Math.round(255*(c[5]===void 0?1:parseFloat(c[5]))),o.toColor(n,r,i,a);if(!t||!s||(t.fillStyle=s,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[n,r,i,a]=t.getImageData(0,0,1,1).data,a!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:o.toRgba(n,r,i,a),css:e}}}(c||(t.css=c={})),function(e){function t(e,t,n){let r=e/255,i=t/255,a=n/255;return .2126*(r<=.03928?r/12.92:((r+.055)/1.055)**2.4)+.7152*(i<=.03928?i/12.92:((i+.055)/1.055)**2.4)+.0722*(a<=.03928?a/12.92:((a+.055)/1.055)**2.4)}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(l||(t.rgb=l={})),function(e){function t(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,u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));for(;u<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(.1*o)),s-=Math.max(0,Math.ceil(.1*s)),c-=Math.max(0,Math.ceil(.1*c)),u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}function s(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,u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));for(;u<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),s=Math.min(255,s+Math.ceil(.1*(255-s))),c=Math.min(255,c+Math.ceil(.1*(255-c))),u=f(l.relativeLuminance2(o,s,c),l.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.blend=function(e,t){if(a=(255&t)/255,a===1)return t;let s=t>>24&255,c=t>>16&255,l=t>>8&255,u=e>>24&255,d=e>>16&255,f=e>>8&255;return n=u+Math.round((s-u)*a),r=d+Math.round((c-d)*a),i=f+Math.round((l-f)*a),o.toRgba(n,r,i)},e.ensureContrastRatio=function(e,n,r){let i=l.relativeLuminance(e>>8),a=l.relativeLuminance(n>>8);if(f(i,a)<r){if(a<i){let a=t(e,n,r),o=f(i,l.relativeLuminance(a>>8));if(o<r){let t=s(e,n,r);return o>f(i,l.relativeLuminance(t>>8))?a:t}return a}let o=s(e,n,r),c=f(i,l.relativeLuminance(o>>8));if(c<r){let a=t(e,n,r);return c>f(i,l.relativeLuminance(a>>8))?o:a}return o}},e.reduceLuminance=t,e.increaseLuminance=s,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}}(u||(t.rgba=u={})),t.toPaddedHex=d,t.contrastRatio=f},8969:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreTerminal=void 0;let r=n(844),i=n(2585),a=n(4348),o=n(7866),s=n(744),c=n(7302),l=n(6975),u=n(8460),d=n(1753),f=n(1480),p=n(7994),m=n(9282),h=n(5435),g=n(5981),_=n(2660),v=!1;class y extends r.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new u.EventEmitter),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]}constructor(e){super(),this._windowsWrappingHeuristics=this.register(new r.MutableDisposable),this._onBinary=this.register(new u.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new u.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new u.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new u.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new u.EventEmitter),this._instantiationService=new a.InstantiationService,this.optionsService=this.register(new c.OptionsService(e)),this._instantiationService.setService(i.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(s.BufferService)),this._instantiationService.setService(i.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(o.LogService)),this._instantiationService.setService(i.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(l.CoreService)),this._instantiationService.setService(i.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(i.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(f.UnicodeService)),this._instantiationService.setService(i.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(p.CharsetService),this._instantiationService.setService(i.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_.OscLinkService),this._instantiationService.setService(i.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new h.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,u.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,u.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,u.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,u.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((e=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((e=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new g.WriteBuffer(((e,t)=>this._inputHandler.parse(e,t)))),this.register((0,u.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=i.LogLevelEnum.WARN&&!v&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),v=!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,s.MINIMUM_COLS),t=Math.max(t,s.MINIMUM_ROWS),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t,n){this._bufferService.scrollLines(e,t,n)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){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(m.updateWindowsModeWrappedState.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},(()=>((0,m.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,r.toDisposable)((()=>{for(let t of e)t.dispose()}))}}}t.CoreTerminal=y},8460:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},5435:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.InputHandler=t.WindowsOptionsReportType=void 0;let a=n(2584),o=n(7116),s=n(2015),c=n(844),l=n(482),u=n(8437),d=n(8460),f=n(643),p=n(511),m=n(3734),h=n(2585),g=n(1480),_=n(6242),v=n(6351),y=n(5941),b={"(":0,")":1,"*":2,"+":3,"-":1,".":2},x=131072;function S(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 C;(function(e){e[e.GET_WIN_SIZE_PIXELS=0]=`GET_WIN_SIZE_PIXELS`,e[e.GET_CELL_SIZE_PIXELS=1]=`GET_CELL_SIZE_PIXELS`})(C||(t.WindowsOptionsReportType=C={}));let w=0;class T extends c.Disposable{getAttrData(){return this._curAttrData}constructor(e,t,n,r,i,c,f,m,h=new s.EscapeSequenceParser){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=c,this._coreMouseService=f,this._unicodeService=m,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new l.StringToUtf32,this._utf8Decoder=new l.Utf8ToUtf32,this._workCell=new p.CellData,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=u.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.EventEmitter),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 E(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(a.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(a.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(a.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(a.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(a.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(a.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(a.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(a.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(a.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new _.OscHandler((e=>(this.setTitle(e),this.setIconName(e),!0)))),this._parser.registerOscHandler(1,new _.OscHandler((e=>this.setIconName(e)))),this._parser.registerOscHandler(2,new _.OscHandler((e=>this.setTitle(e)))),this._parser.registerOscHandler(4,new _.OscHandler((e=>this.setOrReportIndexedColor(e)))),this._parser.registerOscHandler(8,new _.OscHandler((e=>this.setHyperlink(e)))),this._parser.registerOscHandler(10,new _.OscHandler((e=>this.setOrReportFgColor(e)))),this._parser.registerOscHandler(11,new _.OscHandler((e=>this.setOrReportBgColor(e)))),this._parser.registerOscHandler(12,new _.OscHandler((e=>this.setOrReportCursorColor(e)))),this._parser.registerOscHandler(104,new _.OscHandler((e=>this.restoreIndexedColor(e)))),this._parser.registerOscHandler(110,new _.OscHandler((e=>this.restoreFgColor(e)))),this._parser.registerOscHandler(111,new _.OscHandler((e=>this.restoreBgColor(e)))),this._parser.registerOscHandler(112,new _.OscHandler((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 o.CHARSETS)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.DcsHandler(((e,t)=>this.requestStatusString(e,t))))}_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<=h.LogLevelEnum.WARN&&Promise.race([e,new Promise(((e,t)=>setTimeout((()=>t(`#SLOW_TIMEOUT`)),5e3)))]).catch((e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than 5000 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>x&&(a=this._parseStack.position+x)}if(this._logService.logLevel<=h.LogLevelEnum.DEBUG&&this._logService.debug(`parsing data`+(typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,(e=>String.fromCharCode(e))).join(``)}"`),typeof e==`string`?e.split(``).map((e=>e.charCodeAt(0))):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<x&&(this._parseBuffer=new Uint32Array(Math.min(e.length,x))),o||this._dirtyRowTracker.clearRange(),e.length>x)for(let t=a;t<e.length;t+=x){let a=t+x<e.length?t+x: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(Math.min(c,this._bufferService.rows-1),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,d=this._coreService.modes.insertMode,p=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,p);let h=this._parser.precedingJoinState;for(let _=t;_<n;++_){if(r=e[_],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,h);i=g.UnicodeService.extractWidth(t);let n=g.UnicodeService.extractShouldJoin(t),v=n?g.UnicodeService.extractWidth(h):0;if(h=t,o&&this._onA11yChar.fire((0,l.stringFromCodePoint)(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-v>s){if(c){let e=m,t=this._activeBuffer.x-v;for(this._activeBuffer.x=v,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),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof u.BufferLine&&m.copyCellsFrom(e,t,0,v,!1);t<s;)e.setCellFromCodepoint(t++,0,1,p)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-v;--e>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}else if(d&&(m.insertCells(this._activeBuffer.x,i-v,this._activeBuffer.getNullCell(p)),m.getWidth(s-1)===2&&m.setCellFromCodepoint(s-1,f.NULL_CELL_CODE,f.NULL_CELL_WIDTH,p)),m.setCellFromCodepoint(this._activeBuffer.x++,r,i,p),i>0)for(;--i;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}this._parser.precedingJoinState=h,this._activeBuffer.x<s&&n-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,p),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final!==`t`||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,t):this._parser.registerCsiHandler(e,(e=>!S(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)))}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new v.DcsHandler(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new _.OscHandler(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){let n;switch(this._restrictCursor(this._bufferService.cols),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:for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.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(u.DEFAULT_ATTR_DATA));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=g.UnicodeService.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(a.C0.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(a.C0.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(a.C0.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(a.C0.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(a.C0.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}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,o.DEFAULT_CHARSET),this._charsetService.setgCharset(1,o.DEFAULT_CHARSET),this._charsetService.setgCharset(2,o.DEFAULT_CHARSET),this._charsetService.setgCharset(3,o.DEFAULT_CHARSET);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(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}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}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:case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);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(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(e,t){let n=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:i}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=e=>e?1:2,p=e.params[0];return m=p,h=t?p===2?4:p===4?f(o.modes.insertMode):p===12?3:p===20?f(d.convertEol):0:p===1?f(n.applicationCursorKeys):p===3?d.windowOptions.setWinLines?c===80?2:+(c===132):0:p===6?f(n.origin):p===7?f(n.wraparound):p===8?3:p===9?f(r===`X10`):p===12?f(d.cursorBlink):p===25?f(!o.isCursorHidden):p===45?f(n.reverseWraparound):p===66?f(n.applicationKeypad):p===67?4:p===1e3?f(r===`VT200`):p===1002?f(r===`DRAG`):p===1003?f(r===`ANY`):p===1004?f(n.sendFocus):p===1005?4:p===1006?f(i===`SGR`):p===1015?4:p===1016?f(i===`SGR_PIXELS`):p===1048?1:p===47||p===1047||p===1049?f(l===u):p===2004?f(n.bracketedPasteMode):0,o.triggerDataEvent(`${a.C0.ESC}[${t?``:`?`}${m};${h}$y`),!0;var m,h}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=m.AttributeData.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|255&n),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=u.DEFAULT_ATTR_DATA.fg,e.bg=u.DEFAULT_ATTR_DATA.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|=16777224|n-90):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777224|n-100):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|=16777215&u.DEFAULT_ATTR_DATA.fg):n===49?(r.bg&=-67108864,r.bg|=16777215&u.DEFAULT_ATTR_DATA.bg):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|=16777215&u.DEFAULT_ATTR_DATA.fg,r.bg&=-67108864,r.bg|=16777215&u.DEFAULT_ATTR_DATA.bg):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${a.C0.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=u.DEFAULT_ATTR_DATA.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.params[0]||1;switch(t){case 1:case 2:this._optionsService.options.cursorStyle=`block`;break;case 3:case 4:this._optionsService.options.cursorStyle=`underline`;break;case 5:case 6:this._optionsService.options.cursorStyle=`bar`}let n=t%2==1;return this._optionsService.options.cursorBlink=n,!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(!S(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(C.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(C.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${a.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:t!==0&&t!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),t!==0&&t!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:t!==0&&t!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),t!==0&&t!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(D(n))if(r===`?`)t.push({type:0,index:n});else{let e=(0,y.parseColor)(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.split(`;`);return!(t.length<2)&&(t[1]?this._createHyperlink(t[0],t[1]):!t[0]&&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=(0,y.parseColor)(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]);D(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,o.DEFAULT_CHARSET),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(b[e[0]],o.CHARSETS[e[1]]||o.DEFAULT_CHARSET),!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=u.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=u.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new p.CellData;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=this._bufferService.buffer,r=this._optionsService.rawOptions;return(e=>(this._coreService.triggerDataEvent(`${a.C0.ESC}${e}${a.C0.ESC}\\`),!0))(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-+!!r.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}}t.InputHandler=T;let E=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&&(w=e,e=t,t=w),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function D(e){return 0<=e&&e<256}E=r([i(0,h.IBufferService)],E)},844:(e,t)=>{function n(e){for(let t of e)t.dispose();e.length=0}Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=n,t.getDisposeArrayDisposable=function(e){return{dispose:()=>n(e)}}},1505:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FourKeyMap=t.TwoKeyMap=void 0;class n{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={}}}t.TwoKeyMap=n,t.FourKeyMap=class{constructor(){this._data=new n}set(e,t,r,i,a){this._data.get(e,t)||this._data.set(e,t,new n),this._data.get(e,t).set(r,i,a)}get(e,t,n,r){return this._data.get(e,t)?.get(n,r)}clear(){this._data.clear()}}},6114:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isChromeOS=t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.getSafariVersion=t.isSafari=t.isLegacyEdge=t.isFirefox=t.isNode=void 0,t.isNode=typeof process<`u`&&`title`in process;let n=t.isNode?`node`:navigator.userAgent,r=t.isNode?`node`:navigator.platform;t.isFirefox=n.includes(`Firefox`),t.isLegacyEdge=n.includes(`Edge`),t.isSafari=/^((?!chrome|android).)*safari/i.test(n),t.getSafariVersion=function(){if(!t.isSafari)return 0;let e=n.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])},t.isMac=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(r),t.isIpad=r===`iPad`,t.isIphone=r===`iPhone`,t.isWindows=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(r),t.isLinux=r.indexOf(`Linux`)>=0,t.isChromeOS=/\bCrOS\b/.test(n)},6106:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SortedList=void 0;let n=0;t.SortedList=class{constructor(e){this._getKey=e,this._array=[]}clear(){this._array.length=0}insert(e){this._array.length===0?this._array.push(e):(n=this._search(this._getKey(e)),this._array.splice(n,0,e))}delete(e){if(this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(n=this._search(t),n===-1)||this._getKey(this._array[n])!==t)return!1;do if(this._array[n]===e)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===t);return!1}*getKeyIterator(e){if(this._array.length!==0&&(n=this._search(e),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===e))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===e)}forEachByKey(e,t){if(this._array.length!==0&&(n=this._search(e),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===e))do t(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===e)}values(){return[...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)){for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}t=r+1}}return t}}},7226:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DebouncedIdleTask=t.IdleTaskQueue=t.PriorityTaskQueue=void 0;let r=n(6114);class i{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=Date.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,Date.now()-t),n=Math.max(t,n),i=e.timeRemaining(),1.5*n>i)return r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),void this._start();r=i}this.clear()}}class a extends i{_requestCallback(e){return setTimeout((()=>e(this._createDeadline(16))))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=Date.now()+e;return{timeRemaining:()=>Math.max(0,t-Date.now())}}}t.PriorityTaskQueue=a,t.IdleTaskQueue=!r.isNode&&`requestIdleCallback`in window?class extends i{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:a,t.DebouncedIdleTask=class{constructor(){this._queue=new t.IdleTaskQueue}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}}},9282:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateWindowsModeWrappedState=void 0;let r=n(643);t.updateWindowsModeWrappedState=function(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[r.CHAR_DATA_CODE_INDEX]!==r.NULL_CELL_CODE&&t[r.CHAR_DATA_CODE_INDEX]!==r.WHITESPACE_CELL_CODE)}},3734:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new r}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let e=new n;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}t.AttributeData=n;class r{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}clone(){return new r(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}t.ExtendedAttrs=r},9092:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Buffer=t.MAX_BUFFER_SIZE=void 0;let r=n(6349),i=n(7226),a=n(3734),o=n(8437),s=n(4634),c=n(511),l=n(643),u=n(4863),d=n(7116);t.MAX_BUFFER_SIZE=4294967295,t.Buffer=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=o.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=c.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]),this._whitespaceCell=c.CellData.fromCharData([0,l.WHITESPACE_CELL_CHAR,l.WHITESPACE_CELL_WIDTH,l.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new i.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new r.CircularList(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 a.ExtendedAttrs),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 a.ExtendedAttrs),this._whitespaceCell}getBlankLine(e,t){return new o.BufferLine(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 n=e+this._optionsService.rawOptions.scrollback;return n>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:n}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=o.DEFAULT_ATTR_DATA);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 r.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(o.DEFAULT_ATTR_DATA),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 o.BufferLine(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 o.BufferLine(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=(0,s.reflowLargerGetLinesToRemove)(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(o.DEFAULT_ATTR_DATA));if(n.length>0){let r=(0,s.reflowLargerCreateNewLayout)(this.lines,n);(0,s.reflowLargerApplyNewLayout)(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(o.DEFAULT_ATTR_DATA),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new o.BufferLine(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this.getNullCell(o.DEFAULT_ATTR_DATA),r=[],i=0;for(let a=this.lines.length-1;a>=0;a--){let c=this.lines.get(a);if(!c||!c.isWrapped&&c.getTrimmedLength()<=e)continue;let l=[c];for(;c.isWrapped&&a>0;)c=this.lines.get(--a),l.unshift(c);let u=this.ybase+this.y;if(u>=a&&u<a+l.length)continue;let d=l[l.length-1].getTrimmedLength(),f=(0,s.reflowSmallerGetNewLineLengths)(l,this._cols,e),p=f.length-l.length,m;m=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+p):Math.max(0,this.lines.length-this.lines.maxLength+p);let h=[];for(let e=0;e<p;e++){let e=this.getBlankLine(o.DEFAULT_ATTR_DATA,!0);h.push(e)}h.length>0&&(r.push({start:a+l.length+i,newLines:h}),i+=h.length),l.push(...h);let g=f.length-1,_=f[g];_===0&&(g--,_=f[g]);let v=l.length-p-1,y=d;for(;v>=0;){let e=Math.min(y,_);if(l[g]===void 0)break;if(l[g].copyCellsFrom(l[v],y-e,_-e,e,!0),_-=e,_===0&&(g--,_=f[g]),y-=e,y===0){v--;let e=Math.max(v,0);y=(0,s.getWrappedLineTrimmedLength)(l,e,this._cols)}}for(let t=0;t<l.length;t++)f[t]<e&&l[t].setCell(f[t],n);let b=p-m;for(;b-->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+i)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,this.ybase+t-1)}if(r.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,a=n-1,o=0,s=r[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+i);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+i-1);l>=0;l--)if(s&&s.start>a+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:a+1,amount:s.newLines.length}),c+=s.newLines.length,s=r[++o]}else this.lines.set(l,t[a--]);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+i-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.splice(e--,1);this._isClearing=!1}addMarker(e){let t=new u.Marker(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)}}},8437:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLine=t.DEFAULT_ATTR_DATA=void 0;let r=n(3734),i=n(511),a=n(643),o=n(482);t.DEFAULT_ATTR_DATA=Object.freeze(new r.AttributeData);let s=0;class c{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let r=t||i.CellData.fromCharData([0,a.NULL_CELL_CHAR,a.NULL_CELL_WIDTH,a.NULL_CELL_CODE]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[3*e+0],n=2097151&t;return[this._data[3*e+1],2097152&t?this._combined[e]:n?(0,o.stringFromCodePoint)(n):``,t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[3*e+1]=t[a.CHAR_DATA_ATTR_INDEX],t[a.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[a.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e+0]=t[a.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[a.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 12582912&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?(0,o.stringFromCodePoint)(2097151&t):``}isProtected(e){return 536870912&this._data[3*e+2]}loadCell(e,t){return s=3*e,t.content=this._data[s+0],t.fg=this._data[s+1],t.bg=this._data[s+2],2097152&t.content&&(t.combinedData=this._combined[e]),268435456&t.bg&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[e]=t.extended),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg}setCellFromCodepoint(e,t,n,r){268435456&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=t|n<<22,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[3*e+0];2097152&r?this._combined[e]+=(0,o.stringFromCodePoint)(t):2097151&r?(this._combined[e]=(0,o.stringFromCodePoint)(2097151&r)+(0,o.stringFromCodePoint)(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[3*e+0]=r}insertCells(e,t,n){if((e%=this.length)&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new i.CellData;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 i.CellData;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++;else 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 4*this._data.length*2<this._data.buffer.byteLength;let n=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*n)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,4*n*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<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);else{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 e=new c(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let t in this._combined)e._combined[t]=this._combined[t];for(let t in this._extendedAttrs)e._extendedAttrs[t]=this._extendedAttrs[t];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||50331648&this._data[3*e+2])return e+(this._data[3*e+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<3;e++)this._data[3*(n+i)+e]=a[3*(t+i)+e];268435456&a[3*(t+i)+2]&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<3;e++)this._data[3*(n+i)+e]=a[3*(t+i)+e];268435456&a[3*(t+i)+2]&&(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[3*t+0],n=2097151&e,s=2097152&e?this._combined[t]:n?(0,o.stringFromCodePoint)(n):a.WHITESPACE_CELL_CHAR;if(i+=s,r)for(let e=0;e<s.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}}t.BufferLine=c},4841:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getRangeLength=void 0,t.getRangeLength=function(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)}},4634:(e,t)=>{function n(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}Object.defineProperty(t,"__esModule",{value:!0}),t.getWrappedLineTrimmedLength=t.reflowSmallerGetNewLineLengths=t.reflowLargerApplyNewLayout=t.reflowLargerCreateNewLayout=t.reflowLargerGetLinesToRemove=void 0,t.reflowLargerGetLinesToRemove=function(e,t,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(i>=s&&i<c){s+=u.length-1;continue}let d=0,f=n(u,d,t),p=1,m=0;for(;p<u.length;){let e=n(u,p,t),i=e-m,o=r-f,s=Math.min(i,o);u[d].copyCellsFrom(u[p],m,f,s,!1),f+=s,f===r&&(d++,f=0),m+=s,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(r-1)===2&&(u[d].copyCellsFrom(u[d-1],r-1,f++,1,!1),u[d-1].setCell(r-1,a))}u[d].replaceCells(f,r,a);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},t.reflowLargerCreateNewLayout=function(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}},t.reflowLargerApplyNewLayout=function(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},t.reflowSmallerGetNewLineLengths=function(e,t,r){let i=[],a=e.map(((r,i)=>n(e,i,t))).reduce(((e,t)=>e+t)),o=0,s=0,c=0;for(;c<a;){if(a-c<r){i.push(a-c);break}o+=r;let l=n(e,s,t);o>l&&(o-=l,s++);let u=e[s].getWidth(o-1)===2;u&&o--;let d=u?r-1:r;i.push(d),c+=d}return i},t.getWrappedLineTrimmedLength=n},5295:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferSet=void 0;let r=n(8460),i=n(844),a=n(9092);class o extends i.Disposable{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this.register(new r.EventEmitter),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 a.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a.Buffer(!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)}}t.BufferSet=o},511:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CellData=void 0;let r=n(482),i=n(643),a=n(3734);class o extends a.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new a.ExtendedAttrs,this.combinedData=``}static fromCharData(e){let t=new o;return t.setFromCharData(e),t}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,r.stringFromCodePoint)(2097151&this.content):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[i.CHAR_DATA_ATTR_INDEX],this.bg=0;let t=!1;if(e[i.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(e[i.CHAR_DATA_CHAR_INDEX].length===2){let n=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(n-55296)+r-56320+65536|e[i.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[i.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[i.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[i.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[i.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.CellData=o},643:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_EXT=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=0,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.DEFAULT_EXT=0,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR=``,t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=` `,t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},4863:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Marker=void 0;let r=n(8460),i=n(844);class a{get id(){return this._id}constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=a._nextId++,this._onDispose=this.register(new r.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,i.disposeArray)(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}}t.Marker=a,a._nextId=1},7116:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CHARSET=t.CHARSETS=void 0,t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},t.CHARSETS.A={"#":`£`},t.CHARSETS.B=void 0,t.CHARSETS[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},t.CHARSETS.C=t.CHARSETS[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},t.CHARSETS.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},t.CHARSETS.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},t.CHARSETS.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},t.CHARSETS.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},t.CHARSETS.E=t.CHARSETS[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},t.CHARSETS.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},t.CHARSETS.H=t.CHARSETS[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},t.CHARSETS[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`}},2584:(e,t)=>{var n,r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.C1_ESCAPED=t.C1=t.C0=void 0,function(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=`
|
|
74
74
|
`,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=``}(n||(t.C0=n={})),function(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=``}(r||(t.C1=r={})),function(e){e.ST=`${n.ESC}\\`}(i||(t.C1_ESCAPED=i={}))},7399:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateKeyboardEvent=void 0;let r=n(2584),i={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:[`'`,`"`]};t.evaluateKeyboardEvent=function(e,t,n,a){let o={type:0,cancel:!1,key:void 0},s=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?o.key=t?r.C0.ESC+`OA`:r.C0.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?o.key=t?r.C0.ESC+`OD`:r.C0.ESC+`[D`:e.key===`UIKeyInputRightArrow`?o.key=t?r.C0.ESC+`OC`:r.C0.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(o.key=t?r.C0.ESC+`OB`:r.C0.ESC+`[B`);break;case 8:o.key=e.ctrlKey?`\b`:r.C0.DEL,e.altKey&&(o.key=r.C0.ESC+o.key);break;case 9:if(e.shiftKey){o.key=r.C0.ESC+`[Z`;break}o.key=r.C0.HT,o.cancel=!0;break;case 13:o.key=e.altKey?r.C0.ESC+r.C0.CR:r.C0.CR,o.cancel=!0;break;case 27:o.key=r.C0.ESC,e.altKey&&(o.key=r.C0.ESC+r.C0.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`D`,o.key===r.C0.ESC+`[1;3D`&&(o.key=r.C0.ESC+(n?`b`:`[1;5D`))):o.key=t?r.C0.ESC+`OD`:r.C0.ESC+`[D`;break;case 39:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`C`,o.key===r.C0.ESC+`[1;3C`&&(o.key=r.C0.ESC+(n?`f`:`[1;5C`))):o.key=t?r.C0.ESC+`OC`:r.C0.ESC+`[C`;break;case 38:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`A`,n||o.key!==r.C0.ESC+`[1;3A`||(o.key=r.C0.ESC+`[1;5A`)):o.key=t?r.C0.ESC+`OA`:r.C0.ESC+`[A`;break;case 40:if(e.metaKey)break;s?(o.key=r.C0.ESC+`[1;`+(s+1)+`B`,n||o.key!==r.C0.ESC+`[1;3B`||(o.key=r.C0.ESC+`[1;5B`)):o.key=t?r.C0.ESC+`OB`:r.C0.ESC+`[B`;break;case 45:e.shiftKey||e.ctrlKey||(o.key=r.C0.ESC+`[2~`);break;case 46:o.key=s?r.C0.ESC+`[3;`+(s+1)+`~`:r.C0.ESC+`[3~`;break;case 36:o.key=s?r.C0.ESC+`[1;`+(s+1)+`H`:t?r.C0.ESC+`OH`:r.C0.ESC+`[H`;break;case 35:o.key=s?r.C0.ESC+`[1;`+(s+1)+`F`:t?r.C0.ESC+`OF`:r.C0.ESC+`[F`;break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=r.C0.ESC+`[5;`+(s+1)+`~`:o.key=r.C0.ESC+`[5~`;break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=r.C0.ESC+`[6;`+(s+1)+`~`:o.key=r.C0.ESC+`[6~`;break;case 112:o.key=s?r.C0.ESC+`[1;`+(s+1)+`P`:r.C0.ESC+`OP`;break;case 113:o.key=s?r.C0.ESC+`[1;`+(s+1)+`Q`:r.C0.ESC+`OQ`;break;case 114:o.key=s?r.C0.ESC+`[1;`+(s+1)+`R`:r.C0.ESC+`OR`;break;case 115:o.key=s?r.C0.ESC+`[1;`+(s+1)+`S`:r.C0.ESC+`OS`;break;case 116:o.key=s?r.C0.ESC+`[15;`+(s+1)+`~`:r.C0.ESC+`[15~`;break;case 117:o.key=s?r.C0.ESC+`[17;`+(s+1)+`~`:r.C0.ESC+`[17~`;break;case 118:o.key=s?r.C0.ESC+`[18;`+(s+1)+`~`:r.C0.ESC+`[18~`;break;case 119:o.key=s?r.C0.ESC+`[19;`+(s+1)+`~`:r.C0.ESC+`[19~`;break;case 120:o.key=s?r.C0.ESC+`[20;`+(s+1)+`~`:r.C0.ESC+`[20~`;break;case 121:o.key=s?r.C0.ESC+`[21;`+(s+1)+`~`:r.C0.ESC+`[21~`;break;case 122:o.key=s?r.C0.ESC+`[23;`+(s+1)+`~`:r.C0.ESC+`[23~`;break;case 123:o.key=s?r.C0.ESC+`[24;`+(s+1)+`~`:r.C0.ESC+`[24~`;break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(n&&!a||!e.altKey||e.metaKey)!n||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(o.key=r.C0.US),e.key===`@`&&(o.key=r.C0.NUL)):e.keyCode===65&&(o.type=1);else{let t=i[e.keyCode]?.[+!!e.shiftKey];if(t)o.key=r.C0.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()),o.key=r.C0.ESC+n}else if(e.keyCode===32)o.key=r.C0.ESC+(e.ctrlKey?r.C0.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),o.key=r.C0.ESC+t,o.cancel=!0}}else e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=r.C0.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=r.C0.DEL:e.keyCode===219?o.key=r.C0.ESC:e.keyCode===220?o.key=r.C0.FS:e.keyCode===221&&(o.key=r.C0.GS)}return o}},482:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=t.utf32ToString=t.stringFromCodePoint=void 0,t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(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(55296+(t>>10))+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r},t.StringToUtf32=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++]=1024*(this._interim-55296)+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++]=1024*(i-55296)+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},t.Utf8ToUtf32=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,i,a,o,s=0,c=0,l=0;if(this.interim[0]){let r=!1,i=this.interim[0];i&=(224&i)==192?31:(240&i)==224?15:7;let a,o=0;for(;(a=63&this.interim[++o])&&o<4;)i<<=6,i|=a;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(a=e[l++],(192&a)!=128){l--,r=!0;break}this.interim[o++]=a,i<<=6,i|=63&a}r||(c===2?i<128?l--:t[s++]=i:c===3?i<2048||i>=55296&&i<=57343||i===65279||(t[s++]=i):i<65536||i>1114111||(t[s++]=i)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;!(!(d<u)||128&(r=e[d])||128&(i=e[d+1])||128&(a=e[d+2])||128&(o=e[d+3]));)t[s++]=r,t[s++]=i,t[s++]=a,t[s++]=o,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((224&r)==192){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(c=(31&r)<<6|63&i,c<128){d--;continue}t[s++]=c}else if((240&r)==224){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(c=(15&r)<<12|(63&i)<<6|63&a,c<2048||c>=55296&&c<=57343||c===65279)continue;t[s++]=c}else if((248&r)==240){if(d>=n)return this.interim[0]=r,s;if(i=e[d++],(192&i)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,s;if(a=e[d++],(192&a)!=128){d--;continue}if(d>=n)return this.interim[0]=r,this.interim[1]=i,this.interim[2]=a,s;if(o=e[d++],(192&o)!=128){d--;continue}if(c=(7&r)<<18|(63&i)<<12|(63&a)<<6|63&o,c<65536||c>1114111)continue;t[s++]=c}}return s}}},225:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;let r=n(1480),i=[[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]],a=[[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]],o;t.UnicodeV6=class{constructor(){if(this.version=`6`,!o){o=new Uint8Array(65536),o.fill(1),o[0]=0,o.fill(0,1,32),o.fill(0,127,160),o.fill(2,4352,4448),o[9001]=2,o[9002]=2,o.fill(2,11904,42192),o[12351]=1,o.fill(2,44032,55204),o.fill(2,63744,64256),o.fill(2,65040,65050),o.fill(2,65072,65136),o.fill(2,65280,65377),o.fill(2,65504,65511);for(let e=0;e<i.length;++e)o.fill(0,i[e][0],i[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?o[e]:function(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}(e,a)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},5981:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WriteBuffer=void 0;let r=n(8460),i=n(844);class a extends i.Disposable{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 r.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t)return void(this._syncCalls=0);if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let n;for(this._isSyncWriting=!0;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>5e7)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||Date.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=>Date.now()-n>=12?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,Date.now()-n>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}}t.WriteBuffer=a},5941:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toRgbString=t.parseColor=void 0;let n=/^([\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})$/,r=/^[\da-f]+$/;function i(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}}t.parseColor=function(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=n.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),r.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}},t.toRgbString=function(e,t=16){let[n,r,a]=e;return`rgb:${i(n,t)}/${i(r,t)}/${i(a,t)}`}},5770:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},6351:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DcsHandler=t.DcsParser=void 0;let r=n(482),i=n(8742),a=n(5770),o=[];t.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=o,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}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=o,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||o,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t);else this._handlerFb(this._ident,`HOOK`,t)}put(e,t,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._ident,`PUT`,(0,r.utf32ToString)(e,t,n))}unhook(e,t=!0){if(this._active.length){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&&!1===n){for(;r>=0&&(n=this._active[r].unhook(e),!0!==n);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}else this._handlerFb(this._ident,`UNHOOK`,e);this._active=o,this._ident=0}};let s=new i.Params;s.addParam(0),t.DcsHandler=class{constructor(e){this._handler=e,this._data=``,this._params=s,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():s,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=(0,r.utf32ToString)(e,t,n),this._data.length>a.PAYLOAD_LIMIT&&(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=s,this._data=``,this._hitLimit=!1,e)));return this._params=s,this._data=``,this._hitLimit=!1,t}}},2015:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;let r=n(844),i=n(8742),a=n(6242),o=n(6351);class s{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}}t.TransitionTable=s,t.VT500_TRANSITION_TABLE=function(){let e=new s(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(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}();class c extends r.Disposable{constructor(e=t.VT500_TRANSITION_TABLE){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 i.Params,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((0,r.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new a.OscParser),this._dcsParser=this.register(new o.DcsParser),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(255&e)),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,i=0,a=0,o=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=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,a=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===n&&a>-1){for(;a>=0&&(r=t[a](this._params),!0!==r);a--)if(r instanceof Promise)return this._parseStack.handlerPos=a,r}this._parseStack.handlers=[];break;case 4:if(!1===n&&a>-1){for(;a>=0&&(r=t[a](),!0!==r);a--)if(r instanceof Promise)return this._parseStack.handlerPos=a,r}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],r=this._dcsParser.unhook(i!==24&&i!==26,n),r)return r;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],r=this._oscParser.end(i!==24&&i!==26,n),r)return r;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let n=o;n<t;++n){switch(i=e[n],a=this._transitions.table[this.currentState<<8|(i<160?i:160)],a>>4){case 2:for(let r=n+1;;++r){if(r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}if(++r>=t||(i=e[r])<32||i>126&&i<160){this._printHandler(e,n,r),n=r-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|i],s=o?o.length-1:-1;for(;s>=0&&(r=o[s](this._params),!0!==r);s--)if(r instanceof Promise)return this._preserveStack(3,o,s,a,n),r;s<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++n<t&&(i=e[n])>47&&i<60);n--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],l=c?c.length-1:-1;for(;l>=0&&(r=c[l](),!0!==r);l--)if(r instanceof Promise)return this._preserveStack(4,c,l,a,n),r;l<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let r=n+1;;++r)if(r>=t||(i=e[r])===24||i===26||i===27||i>127&&i<160){this._dcsParser.put(e,n,r),n=r-1;break}break;case 14:if(r=this._dcsParser.unhook(i!==24&&i!==26),r)return this._preserveStack(6,[],0,a,n),r;i===27&&(a|=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 r=n+1;;r++)if(r>=t||(i=e[r])<32||i>127&&i<160){this._oscParser.put(e,n,r),n=r-1;break}break;case 6:if(r=this._oscParser.end(i!==24&&i!==26),r)return this._preserveStack(5,[],0,a,n),r;i===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&a}}}t.EscapeSequenceParser=c},6242:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OscHandler=t.OscParser=void 0;let r=n(5770),i=n(482),a=[];t.OscParser=class{constructor(){this._state=0,this._active=a,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=a}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=a,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||a,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,`START`)}_put(e,t,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._id,`PUT`,(0,i.utf32ToString)(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)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+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){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&&!1===n){for(;r>=0&&(n=this._active[r].end(e),!0!==n);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}else this._handlerFb(this._id,`END`,e);this._active=a,this._id=-1,this._state=0}}},t.OscHandler=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+=(0,i.utf32ToString)(e,t,n),this._data.length>r.PAYLOAD_LIMIT&&(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}}},8742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Params=void 0;let n=2147483647;class r{static fromArray(e){let t=new r;if(!e.length)return t;for(let n=+!!Array.isArray(e[0]);n<e.length;++n){let r=e[n];if(Array.isArray(r))for(let e=0;e<r.length;++e)t.addSubParam(r[e]);else t.addParam(r)}return t}constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>256)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}clone(){let e=new r(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=255&this._subParamsIdx[t];r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>n?n:e}}addSubParam(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>n?n:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=255&this._subParamsIdx[e];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=255&this._subParamsIdx[t];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 r=this._digitIsSub?this._subParams:this.params,i=r[t-1];r[t-1]=~i?Math.min(10*i+e,n):e}}t.Params=r},5741:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AddonManager=void 0,t.AddonManager=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)}}},8771:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferApiView=void 0;let r=n(3785),i=n(511);t.BufferApiView=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 r.BufferLineApiView(t)}getNullCell(){return new i.CellData}}},3785:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLineApiView=void 0;let r=n(511);t.BufferLineApiView=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 r.CellData)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}}},8285:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferNamespaceApi=void 0;let r=n(8771),i=n(8460),a=n(844);class o extends a.Disposable{constructor(e){super(),this._core=e,this._onBufferChange=this.register(new i.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new r.BufferApiView(this._core.buffers.normal,`normal`),this._alternate=new r.BufferApiView(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)}}t.BufferNamespaceApi=o},7975:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ParserApi=void 0,t.ParserApi=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)}}},7090:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeApi=void 0,t.UnicodeApi=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}}},744:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;let a=n(8460),o=n(844),s=n(5295),c=n(2585);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;let l=t.BufferService=class extends o.Disposable{get buffer(){return this.buffers.active}constructor(e){super(),this.isUserScrolling=!1,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new a.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,t.MINIMUM_COLS),this.rows=Math.max(e.rawOptions.rows||0,t.MINIMUM_ROWS),this.buffers=this.register(new s.BufferSet(e,this))}resize(e,t){this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t})}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,n){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let i=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),i!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};t.BufferService=l=r([i(0,c.IOptionsService)],l)},7994:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CharsetService=void 0,t.CharsetService=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)}}},1753:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreMouseService=void 0;let a=n(2585),o=n(8460),s=n(844),c={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button!==4&&e.action===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 l(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|=3&e.button,4&e.button&&(n|=64),8&e.button&&(n|=128),e.action===32?n|=32:e.action!==0||t||(n|=3)),n}let u=String.fromCharCode,d={DEFAULT:e=>{let t=[l(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`[M${u(t[0])}${u(t[1])}${u(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`[<${l(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`[<${l(e,!0)};${e.x};${e.y}${t}`}},f=t.CoreMouseService=class extends s.Disposable{constructor(e,t){super(),this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._onProtocolChange=this.register(new o.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(c))this.addProtocol(e,c[e]);for(let e of Object.keys(d))this.addEncoding(e,d[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}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:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_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}};t.CoreMouseService=f=r([i(0,a.IBufferService),i(1,a.ICoreService)],f)},6975:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreService=void 0;let a=n(1439),o=n(8460),s=n(844),c=n(2585),l=Object.freeze({insertMode:!1}),u=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),d=t.CoreService=class extends s.Disposable{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 o.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new o.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new o.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,a.clone)(l),this.decPrivateModes=(0,a.clone)(u)}reset(){this.modes=(0,a.clone)(l),this.decPrivateModes=(0,a.clone)(u)}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}"`,(()=>e.split(``).map((e=>e.charCodeAt(0))))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`,(()=>e.split(``).map((e=>e.charCodeAt(0))))),this._onBinary.fire(e))}};t.CoreService=d=r([i(0,c.IBufferService),i(1,c.ILogService),i(2,c.IOptionsService)],d)},9074:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DecorationService=void 0;let r=n(8055),i=n(8460),a=n(844),o=n(6106),s=0,c=0;class l extends a.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new o.SortedList((e=>e?.marker.line)),this._onDecorationRegistered=this.register(new i.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new i.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,a.toDisposable)((()=>this.reset())))}registerDecoration(e){if(e.marker.isDisposed)return;let t=new u(e);if(t){let e=t.marker.onDispose((()=>t.dispose()));t.onDispose((()=>{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=>{s=t.options.x??0,c=s+(t.options.width??1),e>=s&&e<c&&(!n||(t.options.layer??`bottom`)===n)&&r(t)}))}}t.DecorationService=l;class u extends a.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=r.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=r.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(e){super(),this.options=e,this.onRenderEmitter=this.register(new i.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new i.EventEmitter),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`)}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InstantiationService=t.ServiceCollection=void 0;let r=n(2585),i=n(8343);class a{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)}}t.ServiceCollection=a,t.InstantiationService=class{constructor(){this._services=new a,this._services.set(r.IInstantiationService,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=(0,i.getServiceDependencies)(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}.`);r.push(n)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}}},7866:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.traceCall=t.setTraceLogger=t.LogService=void 0;let a=n(844),o=n(2585),s={trace:o.LogLevelEnum.TRACE,debug:o.LogLevelEnum.DEBUG,info:o.LogLevelEnum.INFO,warn:o.LogLevelEnum.WARN,error:o.LogLevelEnum.ERROR,off:o.LogLevelEnum.OFF},c,l=t.LogService=class extends a.Disposable{get logLevel(){return this._logLevel}constructor(e){super(),this._optionsService=e,this._logLevel=o.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange(`logLevel`,(()=>this._updateLogLevel()))),c=this}_updateLogLevel(){this._logLevel=s[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?``:`xterm.js: `)+t,...n)}trace(e,...t){this._logLevel<=o.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=o.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=o.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=o.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=o.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};t.LogService=l=r([i(0,o.IOptionsService)],l),t.setTraceLogger=function(e){c=e},t.traceCall=function(e,t,n){if(typeof n.value!=`function`)throw Error(`not supported`);let r=n.value;n.value=function(...e){if(c.logLevel!==o.LogLevelEnum.TRACE)return r.apply(this,e);c.trace(`GlyphRenderer#${r.name}(${e.map((e=>JSON.stringify(e))).join(`, `)})`);let t=r.apply(this,e);return c.trace(`GlyphRenderer#${r.name} return`,t),t}}},7302:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=void 0;let r=n(8460),i=n(844);t.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`courier-new, courier, monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:n(6114).isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRulerWidth:0};let a=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`];class o extends i.Disposable{constructor(e){super(),this._onOptionChange=this.register(new r.EventEmitter),this.onOptionChange=this._onOptionChange.event;let n={...t.DEFAULT_OPTIONS};for(let t in e)if(t in n)try{let r=e[t];n[t]=this._sanitizeAndValidateOption(t,r)}catch(e){console.error(e)}this.rawOptions=n,this.options={...n},this._setupOptions(),this.register((0,i.toDisposable)((()=>{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 t.DEFAULT_OPTIONS))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},n=(e,n)=>{if(!(e in t.DEFAULT_OPTIONS))throw Error(`No option with key "${e}"`);n=this._sanitizeAndValidateOption(e,n),this.rawOptions[e]!==n&&(this.rawOptions[e]=n,this._onOptionChange.fire(e))};for(let t in this.rawOptions){let r={get:e.bind(this,t),set:n.bind(this,t)};Object.defineProperty(this.options,t,r)}}_sanitizeAndValidateOption(e,n){switch(e){case`cursorStyle`:if(n||=t.DEFAULT_OPTIONS[e],!function(e){return e===`block`||e===`underline`||e===`bar`}(n))throw Error(`"${n}" is not a valid value for ${e}`);break;case`wordSeparator`:n||=t.DEFAULT_OPTIONS[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof n==`number`&&1<=n&&n<=1e3)break;n=a.includes(n)?n:t.DEFAULT_OPTIONS[e];break;case`cursorWidth`:n=Math.floor(n);case`lineHeight`:case`tabStopWidth`:if(n<1)throw Error(`${e} cannot be less than 1, value: ${n}`);break;case`minimumContrastRatio`:n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case`scrollback`:if((n=Math.min(n,4294967295))<0)throw Error(`${e} cannot be less than 0, value: ${n}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(n<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case`rows`:case`cols`:if(!n&&n!==0)throw Error(`${e} must be numeric, value: ${n}`);break;case`windowsPty`:n??={}}return n}}t.OptionsService=o},2660:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkService=void 0;let a=n(2585),o=t.OscLinkService=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)))}};t.OscLinkService=o=r([i(0,a.IBufferService)],o)},8343:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0;let n=`di$target`,r=`di$dependencies`;t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e[r]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);let i=function(e,t,a){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);(function(e,t,i){t[n]===t?t[r].push({id:e,index:i}):(t[r]=[{id:e,index:i}],t[n]=t)})(i,e,a)};return i.toString=()=>e,t.serviceRegistry.set(e,i),i}},2585:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;let r=n(8343);var i;t.IBufferService=(0,r.createDecorator)(`BufferService`),t.ICoreMouseService=(0,r.createDecorator)(`CoreMouseService`),t.ICoreService=(0,r.createDecorator)(`CoreService`),t.ICharsetService=(0,r.createDecorator)(`CharsetService`),t.IInstantiationService=(0,r.createDecorator)(`InstantiationService`),function(e){e[e.TRACE=0]=`TRACE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARN=3]=`WARN`,e[e.ERROR=4]=`ERROR`,e[e.OFF=5]=`OFF`}(i||(t.LogLevelEnum=i={})),t.ILogService=(0,r.createDecorator)(`LogService`),t.IOptionsService=(0,r.createDecorator)(`OptionsService`),t.IOscLinkService=(0,r.createDecorator)(`OscLinkService`),t.IUnicodeService=(0,r.createDecorator)(`UnicodeService`),t.IDecorationService=(0,r.createDecorator)(`DecorationService`)},1480:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;let r=n(8460),i=n(225);class a{static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(16777215&e)<<3|(3&t)<<1|!!n}constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new r.EventEmitter,this.onChange=this._onChange.event;let e=new i.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}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(e){let t=0,n=0,r=e.length;for(let i=0;i<r;++i){let o=e.charCodeAt(i);if(55296<=o&&o<=56319){if(++i>=r)return t+this.wcwidth(o);let n=e.charCodeAt(i);56320<=n&&n<=57343?o=1024*(o-55296)+n-56320+65536:t+=this.wcwidth(n)}let s=this.charProperties(o,n),c=a.extractWidth(s);a.extractShouldJoin(s)&&(c-=a.extractWidth(n)),t+=c,n=s}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}}t.UnicodeService=a}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.Terminal=void 0;let t=n(9042),i=n(3236),a=n(844),o=n(5741),s=n(8285),c=n(7975),l=n(7090),u=[`cols`,`rows`];class d extends a.Disposable{constructor(e){super(),this._core=this.register(new i.Terminal(e)),this._addonManager=this.register(new o.AddonManager),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(u.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 c.ParserApi(this._core),this._parser}get unicode(){return this._checkProposedApi(),new l.UnicodeApi(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 s.BufferNamespaceApi(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,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
|
|
75
75
|
`,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 t}_verifyIntegers(...e){for(let t of e)if(t===1/0||isNaN(t)||t%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(let t of e)if(t&&(t===1/0||isNaN(t)||t%1!=0||t<0))throw Error(`This API only accepts positive integers`)}}e.Terminal=d})(),r})()))})),EU=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.FitAddon=r():n.FitAddon=r()})(self,(()=>(()=>{var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=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,t=e._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let n=this._terminal.options.scrollback===0?0:e.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(r.getPropertyValue(`height`)),a=Math.max(0,parseInt(r.getPropertyValue(`width`))),o=window.getComputedStyle(this._terminal.element),s=i-(parseInt(o.getPropertyValue(`padding-top`))+parseInt(o.getPropertyValue(`padding-bottom`))),c=a-(parseInt(o.getPropertyValue(`padding-right`))+parseInt(o.getPropertyValue(`padding-left`)))-n;return{cols:Math.max(2,Math.floor(c/t.css.cell.width)),rows:Math.max(1,Math.floor(s/t.css.cell.height))}}}})(),e})()))})),DU=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.WebLinksAddon=r():n.WebLinksAddon=r()})(self,(()=>(()=>{var e={6:(e,t)=>{function n(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(t,"__esModule",{value:!0}),t.LinkComputer=t.WebLinkProvider=void 0,t.WebLinkProvider=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=r.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map((e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e)))}};class r{static computeLink(e,t,i,a){let o=new RegExp(t.source,(t.flags||``)+`g`),[s,c]=r._getWindowedLineStrings(e-1,i),l=s.join(``),u,d=[];for(;u=o.exec(l);){let e=u[0];if(!n(e))continue;let[t,o]=r._mapStrIdx(i,c,0,u.index),[s,l]=r._mapStrIdx(i,t,o,e.length);if(t===-1||o===-1||s===-1||l===-1)continue;let f={start:{x:o+1,y:t+1},end:{x:l,y:s+1}};d.push({range:f,text:e,activate:a})}return d}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}}t.LinkComputer=r}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.WebLinksAddon=void 0;let t=n(6),i=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function a(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}e.WebLinksAddon=class{constructor(e=a,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let n=this._options,r=n.urlRegex||i;this._linkProvider=this._terminal.registerLinkProvider(new t.WebLinkProvider(this._terminal,r,this._handler,n))}dispose(){this._linkProvider?.dispose()}}})(),r})()))})),OU=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.SearchAddon=r():n.SearchAddon=r()})(self,(()=>(()=>{var e={345:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},859:(e,t)=>{function n(e){for(let t of e)t.dispose();e.length=0}Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.toDisposable=t.MutableDisposable=t.Disposable=void 0,t.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},t.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},t.toDisposable=function(e){return{dispose:e}},t.disposeArray=n,t.getDisposeArrayDisposable=function(e){return{dispose:()=>n(e)}}}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.SearchAddon=void 0;let t=n(345),i=n(859),a=` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`;class o extends i.Disposable{constructor(e){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new i.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new i.MutableDisposable,this._onDidChangeResults=this.register(new t.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=e?.highlightLimit??1e3}activate(e){this._terminal=e,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,i.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{let e=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(e,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(e){this._selectedDecoration.clear(),(0,i.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),e||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let n=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||n)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);if(!e||e.length===0)return void this.clearDecorations();t||={},this.clearDecorations(!0);let n=[],r,i=this._find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);for(let e of n){let n=this._createResultDecoration(e,t.decorations);n&&(this._highlightedLines.add(n.marker.line),this._highlightDecorations.push({decoration:n,match:e,dispose(){n.dispose()}}))}}_find(e,t,n,r){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),void this.clearDecorations();if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);let i;this._initLinesCache();let a={startRow:t,startCol:n};if(i=this._findInLine(e,a,r),!i)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=n,a.startCol=0,i=this._findInLine(e,a,r),!i);n++);return i}_findNextAndSelect(e,t){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,i=0;n&&(this._cachedSearchTerm===e?(r=n.end.x,i=n.end.y):(r=n.start.x,i=n.start.y)),this._initLinesCache();let a={startRow:i,startCol:r},o=this._findInLine(e,a,t);if(!o)for(let n=i+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=n,a.startCol=0,o=this._findInLine(e,a,t),!o);n++);if(!o&&i!==0)for(let n=0;n<i&&(a.startRow=n,a.startCol=0,o=this._findInLine(e,a,t),!o);n++);return!o&&n&&(a.startRow=n.start.y,a.startCol=0,o=this._findInLine(e,a,t)),this._selectResult(o,t?.decorations,t?.noScroll)}findPrevious(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let n=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,t);this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||n)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,r}_didOptionsChange(e,t){return!!t&&(e.caseSensitive!==t.caseSensitive||e.regex!==t.regex||e.wholeWord!==t.wholeWord)}_fireResults(e){if(e?.decorations){let e=-1;if(this._selectedDecoration.value){let t=this._selectedDecoration.value.match;for(let n=0;n<this._highlightDecorations.length;n++){let r=this._highlightDecorations[n].match;if(r.row===t.row&&r.col===t.col&&r.size===t.size){e=n;break}}}this._onDidChangeResults.fire({resultIndex:e,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(e,t){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let n=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,i=this._terminal.cols;this._initLinesCache();let a={startRow:r,startCol:i},o;if(n&&(a.startRow=r=n.start.y,a.startCol=i=n.start.x,this._cachedSearchTerm!==e&&(o=this._findInLine(e,a,t,!1),o||(a.startRow=r=n.end.y,a.startCol=i=n.end.x))),o||=this._findInLine(e,a,t,!0),!o){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let n=r-1;n>=0&&(a.startRow=n,o=this._findInLine(e,a,t,!0),!o);n--);}if(!o&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=r&&(a.startRow=n,o=this._findInLine(e,a,t,!0),!o);n--);return this._selectResult(o,t?.decorations,t?.noScroll)}_initLinesCache(){let e=this._terminal;this._linesCache||(this._linesCache=Array(e.buffer.active.length),this._linesCacheDisposables.value=(0,i.getDisposeArrayDisposable)([e.onLineFeed((()=>this._destroyLinesCache())),e.onCursorMove((()=>this._destroyLinesCache())),e.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&=(window.clearTimeout(this._linesCacheTimeoutId),0)}_isWholeWord(e,t,n){return(e===0||a.includes(t[e-1]))&&(e+n.length===t.length||a.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=this._terminal,a=t.startRow,o=t.startCol;if(i.buffer.active.getLine(a)?.isWrapped)return r?void(t.startCol+=i.cols):(t.startRow--,t.startCol+=i.cols,this._findInLine(e,t,n));let s=this._linesCache?.[a];s||(s=this._translateBufferLineToStringWithWrap(a,!0),this._linesCache&&(this._linesCache[a]=s));let[c,l]=s,u=this._bufferColsToStringOffset(a,o),d=n.caseSensitive?e:e.toLowerCase(),f=n.caseSensitive?c:c.toLowerCase(),p=-1;if(n.regex){let t=RegExp(d,`g`),n;if(r)for(;n=t.exec(f.slice(0,u));)p=t.lastIndex-n[0].length,e=n[0],t.lastIndex-=e.length-1;else n=t.exec(f.slice(u)),n&&n[0].length>0&&(p=u+(t.lastIndex-n[0].length),e=n[0])}else r?u-d.length>=0&&(p=f.lastIndexOf(d,u-d.length)):p=f.indexOf(d,u);if(p>=0){if(n.wholeWord&&!this._isWholeWord(p,f,e))return;let t=0;for(;t<l.length-1&&p>=l[t+1];)t++;let r=t;for(;r<l.length-1&&p+e.length>=l[r+1];)r++;let o=p-l[t],s=p+e.length-l[r],c=this._stringLengthToBufferSize(a+t,o);return{term:e,col:c,row:a+t,size:this._stringLengthToBufferSize(a+r,s)-c+i.cols*(r-t)}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=this._terminal,r=e,i=0,a=n.buffer.active.getLine(r);for(;t>0&&a;){for(let e=0;e<t&&e<n.cols;e++){let t=a.getCell(e);if(!t)break;t.getWidth()&&(i+=t.getCode()===0?1:t.getChars().length)}if(r++,a=n.buffer.active.getLine(r),a&&!a.isWrapped)break;t-=n.cols}return i}_translateBufferLineToStringWithWrap(e,t){let n=this._terminal,r=[],i=[0],a=n.buffer.active.getLine(e);for(;a;){let o=n.buffer.active.getLine(e+1),s=!!o&&o.isWrapped,c=a.translateToString(!s&&t);if(s&&o){let e=a.getCell(a.length-1);e&&e.getCode()===0&&e.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(c=c.slice(0,-1))}if(r.push(c),!s)break;i.push(i[i.length-1]+c.length),e++,a=o}return[r.join(``),i]}_selectResult(e,t,n){let r=this._terminal;if(this._selectedDecoration.clear(),!e)return r.clearSelection(),!1;if(r.select(e.col,e.row,e.size),t){let n=r.registerMarker(-r.buffer.active.baseY-r.buffer.active.cursorY+e.row);if(n){let a=r.registerDecoration({marker:n,x:e.col,width:e.size,backgroundColor:t.activeMatchBackground,layer:`top`,overviewRulerOptions:{color:t.activeMatchColorOverviewRuler}});if(a){let r=[];r.push(n),r.push(a.onRender((e=>this._applyStyles(e,t.activeMatchBorder,!0)))),r.push(a.onDispose((()=>(0,i.disposeArray)(r)))),this._selectedDecoration.value={decoration:a,match:e,dispose(){a.dispose()}}}}}if(!n&&(e.row>=r.buffer.active.viewportY+r.rows||e.row<r.buffer.active.viewportY)){let t=e.row-r.buffer.active.viewportY;t-=Math.floor(r.rows/2),r.scrollLines(t)}return!0}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecoration(e,t){let n=this._terminal,r=n.registerMarker(-n.buffer.active.baseY-n.buffer.active.cursorY+e.row);if(!r)return;let a=n.registerDecoration({marker:r,x:e.col,width:e.size,backgroundColor:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:t.matchOverviewRuler,position:`center`}});if(a){let e=[];e.push(r),e.push(a.onRender((e=>this._applyStyles(e,t.matchBorder,!1)))),e.push(a.onDispose((()=>(0,i.disposeArray)(e))))}return a}}e.SearchAddon=o})(),r})()))})),kU=i(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.Unicode11Addon=r():n.Unicode11Addon=r()})(e,(()=>(()=>{var e={433:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV11=void 0;let r=n(938),i=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],a=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],o=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],s=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],c;function l(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}t.UnicodeV11=class{constructor(){if(this.version=`11`,!c){c=new Uint8Array(65536),c.fill(1),c[0]=0,c.fill(0,1,32),c.fill(0,127,160);for(let e=0;e<i.length;++e)c.fill(0,i[e][0],i[e][1]+1);for(let e=0;e<o.length;++e)c.fill(2,o[e][0],o[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?c[e]:l(e,a)?0:l(e,s)?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},345:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.runAndSubscribe=t.forwardEvent=t.EventEmitter=void 0,t.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||=e=>(this._listeners.push(e),{dispose:()=>{if(!this._disposed){for(let t=0;t<this._listeners.length;t++)if(this._listeners[t]===e)return void this._listeners.splice(t,1)}}}),this._event}fire(e,t){let n=[];for(let e=0;e<this._listeners.length;e++)n.push(this._listeners[e]);for(let r=0;r<n.length;r++)n[r].call(void 0,e,t)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},t.forwardEvent=function(e,t){return e((e=>t.fire(e)))},t.runAndSubscribe=function(e,t){return t(void 0),e((e=>t(e)))}},490:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;let r=n(938),i=[[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]],a=[[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]],o;t.UnicodeV6=class{constructor(){if(this.version=`6`,!o){o=new Uint8Array(65536),o.fill(1),o[0]=0,o.fill(0,1,32),o.fill(0,127,160),o.fill(2,4352,4448),o[9001]=2,o[9002]=2,o.fill(2,11904,42192),o[12351]=1,o.fill(2,44032,55204),o.fill(2,63744,64256),o.fill(2,65040,65050),o.fill(2,65072,65136),o.fill(2,65280,65377),o.fill(2,65504,65511);for(let e=0;e<i.length;++e)o.fill(0,i[e][0],i[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?o[e]:function(e,t){let n,r=0,i=t.length-1;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=r;)if(n=r+i>>1,e>t[n][1])r=n+1;else{if(!(e<t[n][0]))return!0;i=n-1}return!1}(e,a)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),i=n===0&&t!==0;if(i){let e=r.UnicodeService.extractWidth(t);e===0?i=!1:e>n&&(n=e)}return r.UnicodeService.createPropertyValue(0,n,i)}}},938:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;let r=n(345),i=n(490);class a{static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(16777215&e)<<3|(3&t)<<1|!!n}constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new r.EventEmitter,this.onChange=this._onChange.event;let e=new i.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}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(e){let t=0,n=0,r=e.length;for(let i=0;i<r;++i){let o=e.charCodeAt(i);if(55296<=o&&o<=56319){if(++i>=r)return t+this.wcwidth(o);let n=e.charCodeAt(i);56320<=n&&n<=57343?o=1024*(o-55296)+n-56320+65536:t+=this.wcwidth(n)}let s=this.charProperties(o,n),c=a.extractWidth(s);a.extractShouldJoin(s)&&(c-=a.extractWidth(n)),t+=c,n=s}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}}t.UnicodeService=a}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.Unicode11Addon=void 0;let t=n(433);e.Unicode11Addon=class{activate(e){e.unicode.register(new t.UnicodeV11)}dispose(){}}})(),r})()))})),AU=TU(),jU=EU(),MU=DU(),NU=OU(),PU=kU(),FU=new Map,IU=new Map;function LU(e){let t=FU.get(e);return t||(t={openPreExec:null,completed:[],cwd:null,promptRows:[]},FU.set(e,t)),t}function RU(e){let t=IU.get(e);if(!t)return;let n=LU(e);for(let e of t)try{e(n)}catch{}}function zU(e,t,n){let r=LU(e);switch(t.kind){case`prompt-start`:r.promptRows.push({ts:t.ts,row:n?.row??null,exitCode:null}),r.promptRows.length>1e3&&r.promptRows.shift();break;case`pre-exec`:r.openPreExec={startedAt:t.ts};break;case`post-exec`:{let e=t.payload?.exitCode??null,n=r.openPreExec?.startedAt??t.ts;r.completed.push({startedAt:n,finishedAt:t.ts,exitCode:e});let i=r.promptRows[r.promptRows.length-1];i&&(i.exitCode=e),r.openPreExec=null,r.completed.length>1e3&&r.completed.shift();break}case`cwd`:r.cwd=t.payload?.path??null;break}RU(e)}function BU(e,t){let n=IU.get(e);return n||(n=new Set,IU.set(e,n)),n.add(t),()=>{n.delete(t)}}function VU(e){return LU(e)}function HU(e){FU.delete(e),IU.delete(e)}var UU=new Map,WU=5e3;function GU(){return typeof document<`u`&&!document.hasFocus()}async function KU(e,t){let n=`${e}:${t.command??``}`,r=Date.now();if(r-(UU.get(n)??0)<WU)return;UU.set(n,r);let i=t.command?O.t(`terminal:notifications.commandFinishedNamed`,{command:qU(t.command,50)}):O.t(`terminal:notifications.commandFinished`),a=O.t(`terminal:notifications.finishedBody`,{code:t.exitCode??`?`,elapsed:JU(t.elapsedMs)});if(ze())try{let e=await $e(`@tauri-apps/plugin-notification`);if(e?.sendNotification){let t=await e.isPermissionGranted?.()??!0;if(t||=await e.requestPermission?.()===`granted`,t){await e.sendNotification({title:i,body:a});return}}}catch{}try{if(typeof Notification>`u`||Notification.permission==="default"&&await Notification.requestPermission().catch(()=>`denied`)!==`granted`||Notification.permission!==`granted`)return;new Notification(i,{body:a})}catch{}}function qU(e,t){return e.length<=t?e:e.slice(0,t-1)+`…`}function JU(e){if(e<6e4)return O.t(`terminal:duration.seconds`,{seconds:(e/1e3).toFixed(1)});let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return O.t(`terminal:duration.minutesSeconds`,{minutes:t,seconds:n})}async function YU(e,t){await $(`plugin:clipboard-manager|write_text`,{label:t?.label,text:e})}async function XU(){return await $(`plugin:clipboard-manager|read_text`)}async function ZU(){if(ze())try{let e=await XU();return typeof e==`string`?e:null}catch{return null}try{if(typeof navigator<`u`&&navigator.clipboard?.readText)return await navigator.clipboard.readText()||null}catch{}return null}async function QU(e){if(ze())try{return await YU(e),!0}catch{return!1}try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return!1}var $U=(0,Z.createContext)(null);function eW(e){return`specrails-desktop:terminal-panel:${e}`}function tW(e){try{let t=localStorage.getItem(eW(e));if(!t)return null;let n=JSON.parse(t);if(!n)return null;let r=n.visibility,i=n.userHeight;return r!==`hidden`&&r!==`restored`&&r!==`maximized`||typeof i!=`number`||!Number.isFinite(i)?null:{visibility:r,userHeight:i}}catch{return null}}function nW(e,t){try{localStorage.setItem(eW(e),JSON.stringify(t))}catch{}}function rW(e){return{visibility:e?.visibility??`hidden`,userHeight:e?.userHeight??320,sessions:[],activeId:null}}function iW(){let e=document.getElementById(`specrails-terminal-host`);return e||(e=document.createElement(`div`),e.id=`specrails-terminal-host`,e.style.position=`fixed`,e.style.left=`0`,e.style.top=`0`,e.style.width=`0`,e.style.height=`0`,e.style.overflow=`hidden`,e.style.visibility=`hidden`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),document.body.appendChild(e),e)}function aW({children:e,activeProjectId:t}){let[n,r]=(0,Z.useState)({}),i=(0,Z.useRef)(n);i.current=n;let a=(0,Z.useRef)(new Map),o=(0,Z.useRef)(new Map),s=(0,Z.useRef)(null);(0,Z.useEffect)(()=>(s.current=iW(),()=>{for(let e of a.current.values())gW(e);a.current.clear(),o.current.clear()}),[]);let c=Ob()?.theme??null;(0,Z.useEffect)(()=>{if(c)for(let e of a.current.values())try{e.term.options.theme=c.xterm}catch{}},[c]);let l=(0,Z.useCallback)((e,t)=>{r(n=>{let r=n[e]??rW(tW(e)),i=t(r);return i===r?n:((i.visibility!==r.visibility||i.userHeight!==r.userHeight)&&nW(e,{visibility:i.visibility,userHeight:i.userHeight}),{...n,[e]:i})})},[]),u=(0,Z.useCallback)(e=>{r(t=>t[e]?t:{...t,[e]:rW(tW(e))})},[]),d=(0,Z.useCallback)(e=>i.current[e]??rW(tW(e)),[]),f=(0,Z.useCallback)((e,t)=>{l(e,e=>e.visibility===t?e:{...e,visibility:t})},[l]),p=(0,Z.useCallback)(e=>{l(e,e=>({...e,visibility:e.visibility===`hidden`?`restored`:`hidden`}))},[l]),m=(0,Z.useCallback)((e,t)=>{l(e,e=>e.userHeight===t?e:{...e,userHeight:t})},[l]),h=(0,Z.useCallback)((e,t)=>{l(e,e=>e.activeId===t?e:{...e,activeId:t})},[l]),g=(0,Z.useRef)(t);g.current=t,(0,Z.useEffect)(()=>{if(!t)return;u(t);let e=!1;return(async()=>{try{let n=await fetch(`${xt}/api/projects/${t}/terminals`);if(!n.ok)return;let r=await n.json();if(e)return;l(t,e=>{let t=new Set(r.sessions.map(e=>e.id));for(let n of e.sessions.map(e=>e.id))if(!t.has(n)){let e=a.current.get(n);e&&(gW(e),a.current.delete(n),o.current.delete(n),HU(n))}let n=r.sessions.map(t=>{let n=e.sessions.find(e=>e.id===t.id);return n?{...n,...t}:t}),i=n.find(t=>t.id===e.activeId)?.id??n[0]?.id??null;for(let e of n)a.current.has(e.id)||dW(e.projectId,e.id,e.cols,e.rows,a.current,o.current,s.current);return{...e,sessions:n,activeId:i}})}catch{}})(),()=>{e=!0}},[t,u,l]);let _=(0,Z.useCallback)(async(e,t)=>{let n=t?.cols??80,r=t?.rows??24;try{let i=await fetch(`${xt}/api/projects/${e}/terminals`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:n,rows:r,name:t?.name})});if(!i.ok){let e=``;try{e=(await i.json())?.error??``}catch{}return R.error(e===`terminal_limit_exceeded`?O.t(`terminal:errors.limitReached`,{max:10}):e===`terminal_spawn_failed`?O.t(`terminal:errors.spawnFailed`):e===`terminal_name_invalid`?O.t(`terminal:errors.invalidName`):O.t(`terminal:errors.openFailed`)),null}let c=(await i.json()).session;return dW(e,c.id,c.cols,c.rows,a.current,o.current,s.current,sx,void 0,void 0,!0),l(e,e=>({...e,sessions:[...e.sessions,c],activeId:c.id})),c}catch{return R.error(O.t(`terminal:errors.serverUnreachable`)),null}},[l]),v=(0,Z.useCallback)(async(e,t,n)=>{let r=await _(e,n);if(!r)return null;let i=a.current.get(r.id);if(!i)return r;let o=()=>{let e=i.ws;if(e)try{e.send(new TextEncoder().encode(t))}catch{}};return i.ws&&i.ws.readyState===WebSocket.OPEN?setTimeout(o,50):i.ws&&i.ws.addEventListener(`open`,()=>setTimeout(o,50),{once:!0}),r},[]),y=(0,Z.useCallback)((e,t)=>{let n=a.current.get(e);if(!n?.ws||n.ws.readyState!==WebSocket.OPEN)return!1;try{n.ws.send(new TextEncoder().encode(t));try{n.term.focus()}catch{}return!0}catch{return!1}},[]),b=(0,Z.useCallback)(async(e,t,n)=>{try{let r=await fetch(`${xt}/api/projects/${e}/terminals/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok)return!1;let i=await r.json();return l(e,e=>({...e,sessions:e.sessions.map(e=>e.id===t?{...e,name:i.session.name}:e)})),!0}catch{return!1}},[l]),x=(0,Z.useCallback)(async(e,t)=>{let n=a.current.get(t);n&&(gW(n),a.current.delete(t),o.current.delete(t),HU(t)),l(e,e=>{let n=e.sessions.filter(e=>e.id!==t),r=e.activeId===t?n[0]?.id??null:e.activeId;return{...e,sessions:n,activeId:r}});try{await fetch(`${xt}/api/projects/${e}/terminals/${t}`,{method:`DELETE`})}catch{}},[l]),S=(0,Z.useCallback)(e=>{let t=i.current[e];if(!t?.activeId)return;let n=a.current.get(t.activeId);if(n?.attached)try{n.term.focus()}catch{}},[]),C=(0,Z.useCallback)(e=>{for(let[t,n]of o.current.entries()){if(n!==e)continue;let r=a.current.get(t);r&&(gW(r),a.current.delete(t)),o.current.delete(t)}r(t=>{if(!t[e])return t;let{[e]:n,...r}=t;return r});try{localStorage.removeItem(eW(e))}catch{}},[]),w=(0,Z.useCallback)(e=>a.current.get(e)?.container??null,[]),T=(0,Z.useCallback)(e=>{let t=a.current.get(e);if(!t)return;let n=!t.term.element||t.term.element.parentElement!==t.container;if(t.attached=!0,n){try{t.term.open(t.container)}catch{}let e=t.settings.renderMode;(e===`webgl`||e===`auto`&&hW())&&!t.webgl&&mW(t.term).then(e=>{e&&(t.webgl=e)})}try{t.fit.fit()}catch{}try{t.term.focus()}catch{}let r=t.term.cols,i=t.term.rows;if(t.ws&&t.ws.readyState===WebSocket.OPEN)try{t.ws.send(JSON.stringify({type:`resize`,cols:r,rows:i}))}catch{}},[]),E=(0,Z.useCallback)(e=>{let t=a.current.get(e);if(!(!t||!t.attached)){try{t.fit.fit()}catch{}if(t.ws&&t.ws.readyState===WebSocket.OPEN)try{t.ws.send(JSON.stringify({type:`resize`,cols:t.term.cols,rows:t.term.rows}))}catch{}}},[]),D=(0,Z.useCallback)((e,t)=>{let n=a.current.get(e);return n?(n.markListeners.add(t),()=>{n.markListeners.delete(t)}):()=>{}},[]),k=(0,Z.useCallback)(e=>a.current.get(e)?.currentCwd??null,[]),A=(0,Z.useCallback)(e=>a.current.get(e)?.search??null,[]),j=(0,Z.useCallback)(e=>a.current.get(e)?.term??null,[]),M=(0,Z.useCallback)((e,t)=>{let n=a.current.get(e);return n?(n.openSearchListeners.add(t),()=>{n.openSearchListeners.delete(t)}):()=>{}},[]),N=(0,Z.useMemo)(()=>({states:n,getState:d,ensureProject:u,setVisibility:f,togglePanel:p,setUserHeight:m,setActive:h,create:_,createAndType:v,writeToSession:y,rename:b,kill:x,focusActive:S,disposeProject:C,getContainer:w,notifyAdopted:T,refitActive:E,subscribeMarks:D,getCwd:k,getSearchAddon:A,subscribeOpenSearch:M,getTerminalInstance:j}),[n,d,u,f,p,m,h,_,v,y,b,x,S,C,w,T,E,D,k,A,M,j]);return(0,Q.jsx)($U.Provider,{value:N,children:e})}var oW={states:{},getState:e=>rW(null),ensureProject:()=>{},setVisibility:()=>{},togglePanel:()=>{},setUserHeight:()=>{},setActive:()=>{},create:async()=>null,createAndType:async()=>null,writeToSession:()=>!1,rename:async()=>!1,kill:async()=>{},focusActive:()=>{},disposeProject:()=>{},getContainer:()=>null,notifyAdopted:()=>{},refitActive:()=>{},subscribeMarks:()=>()=>{},getCwd:()=>null,getSearchAddon:()=>null,subscribeOpenSearch:()=>()=>{},getTerminalInstance:()=>null};function sW(){return(0,Z.useContext)($U)??oW}function cW(e){let t=sW();return e?t.states[e]??rW(tW(e)):rW(null)}function lW(e,t,n,r,i){let a=e.get(t);if(!a)return;let o=a.term.options.fontSize??sx.fontSize,s;if(r===`reset`)s=a.settings.fontSize,i&&i(n,{fontSize:null});else{let e=o+r;if(e<8||e>32)return;s=cx(e),i&&i(n,{fontSize:s})}if(s!==o)try{a.term.options.fontSize=s,a.fit.fit()}catch{}}function uW(e,t,n){let r=e.get(t);if(!r)return;let{promptRows:i}=VU(t);if(i.length===0)return;let a=r.term.buffer.active.viewportY,o=null;if(n===`prev`)for(let e=i.length-1;e>=0;e--){let t=i[e].row;if(t!=null&&t<a){o=t;break}}else for(let e of i){let t=e.row;if(t!=null&&t>a){o=t;break}}if(o!=null)try{r.term.scrollToLine(o)}catch{}}function dW(e,t,n,r,i,a,o,s=sx,c,l,u=!1){let d=i.get(t);if(d)return d;let f=document.createElement(`div`);f.style.width=`100%`,f.style.height=`100%`,f.className=`specrails-xterm-container`;let p=new AU.Terminal({cols:n,rows:r,fontFamily:s.fontFamily,fontSize:s.fontSize,theme:yb().xterm,cursorBlink:!0,scrollback:1e4,allowProposedApi:!0}),m=new jU.FitAddon,h=new MU.WebLinksAddon,g=new NU.SearchAddon;p.loadAddon(m),p.loadAddon(h),p.loadAddon(g),p.attachCustomKeyEventHandler(n=>{if(n.type!==`keydown`||!(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?n.metaKey:n.ctrlKey))return!0;let r=n.key;if(r===`c`||r===`C`){let e=p.getSelection();return e.length===0?!0:(QU(e),n.preventDefault(),!1)}if(r===`v`||r===`V`)return ZU().then(e=>{if(e)try{p.paste(e)}catch{}}),n.preventDefault(),!1;if(r===`k`||r===`K`){try{p.clear()}catch{}return n.preventDefault(),!1}if(r===`f`||r===`F`){n.preventDefault();let e=i.get(t);if(e)for(let t of e.openSearchListeners)try{t()}catch{}return!1}return r===`=`||r===`+`?(n.preventDefault(),lW(i,t,e,1,l),!1):r===`-`||r===`_`?(n.preventDefault(),lW(i,t,e,-1,l),!1):r===`0`?(n.preventDefault(),lW(i,t,e,`reset`,l),!1):r===`ArrowUp`||r===`ArrowDown`?(n.preventDefault(),uW(i,t,r===`ArrowUp`?`prev`:`next`),!1):!0});try{let e=new PU.Unicode11Addon;p.loadAddon(e),p.unicode.activeVersion=`11`}catch{}s.imageRendering&&fW(p),pW(p),o&&o.appendChild(f);let _=`${ae||(typeof window<`u`?`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`:`ws://localhost:4200`)}/ws/terminal/${t}?projectId=${encodeURIComponent(e)}`,v=Ct(),y=v?new WebSocket(_,[`specrails-desktop`,v]):new WebSocket(_);y.binaryType=`arraybuffer`;let b=[];y.onmessage=e=>{if(typeof e.data==`string`){try{let n=JSON.parse(e.data);if(n?.type===`ready`)return;if(n?.type===`exit`){let e=i.get(t);e&&x(e,n.code??null,!!n.early);return}if(n?.type===`mark`&&typeof n.kind==`string`&&typeof n.ts==`number`){let e=i.get(t);if(e){n.kind===`cwd`&&n.payload?.path&&(e.currentCwd=n.payload.path);let r={type:`mark`,kind:n.kind,payload:n.payload,ts:n.ts,sessionId:t},i=e.term.buffer.active,a=n.kind===`prompt-start`?i.cursorY+i.viewportY:null,o=n.kind===`post-exec`?VU(t).openPreExec?.startedAt??null:null;if(zU(t,n,{row:a}),n.kind===`post-exec`&&o!=null&&GU()){let r=n.ts-o,i=e.settings.longCommandThresholdMs;e.settings.notifyOnCompletion&&r>=i&&KU(t,{command:null,exitCode:n.payload?.exitCode??null,elapsedMs:r})}for(let t of e.markListeners)try{t(r)}catch{}c&&c(r)}}}catch{}return}let n=i.get(t);n&&(n.gotData=!0);let r=new Uint8Array(e.data);try{p.write(r)}catch{}};let x=(e,t,n)=>{if(!e.exitShown){e.exitShown=!0;try{let n=t===null?O.t(`terminal:session.processExited`):O.t(`terminal:session.processExitedWithCode`,{code:t});e.term.write(`\r\n\x1b[2m${n}\x1b[0m\r\n`)}catch{}n&&!e.gotUserInput&&R.error(O.t(`terminal:errors.exitedImmediately`))}};y.onclose=e=>{let n=i.get(t);if(!n||n.disposing||n.exitShown)return;let r=(typeof e?.reason==`string`?e.reason:``)===`pty_exit_early`,a=n.openedAt>0&&Date.now()-n.openedAt<3e3&&!n.gotData&&!n.gotUserInput;x(n,null,r||a)};let S=p.onData(e=>{let n=i.get(t);if(n&&(n.gotUserInput=!0),y.readyState===WebSocket.OPEN)try{y.send(new TextEncoder().encode(e))}catch{}});b.push(()=>S.dispose());let C=null,w=()=>{if(f.isConnected){try{m.fit()}catch{return}if(y.readyState===WebSocket.OPEN)try{y.send(JSON.stringify({type:`resize`,cols:p.cols,rows:p.rows}))}catch{}}},T=()=>{C&&clearTimeout(C),C=setTimeout(()=>{C=null,w()},120)};y.onopen=()=>{let e=i.get(t);e&&(e.openedAt=Date.now()),w()};let E=new ResizeObserver(T);E.observe(f),b.push(()=>{C&&clearTimeout(C),E.disconnect()});let D={term:p,fit:m,webLinks:h,search:g,webgl:null,settings:s,container:f,ws:y,attached:!1,disposers:b,openedAt:0,gotData:!1,gotUserInput:!1,disposing:!1,exitShown:!1,currentCwd:null,markListeners:new Set,openSearchListeners:new Set};return i.set(t,D),a.set(t,e),D}async function fW(t){try{let n=(await c(()=>import(`./addon-image-BRmmRHgQ.js`).then(t=>e(t.default,1)),__vite__mapDeps([79,1]))).ImageAddon,r=new n({pixelLimit:8e6});t.loadAddon(r)}catch{}}async function pW(t){try{let n=(await c(()=>import(`./addon-ligatures-qIZUPvRV.js`).then(t=>e(t.default,1)),__vite__mapDeps([80,1]))).LigaturesAddon;t.loadAddon(new n)}catch{}}async function mW(t){try{let n=(await c(()=>import(`./addon-webgl-C2d7lriQ.js`).then(t=>e(t.default,1)),__vite__mapDeps([81,1]))).WebglAddon,r=new n;return r.onContextLoss(()=>{try{r.dispose()}catch{}}),t.loadAddon(r),r}catch{return null}}function hW(){try{let e=document.createElement(`canvas`);return!!(e.getContext(`webgl2`)||e.getContext(`experimental-webgl2`))}catch{return!1}}function gW(e){e.disposing=!0;for(let t of e.disposers)try{t()}catch{}e.disposers=[],e.markListeners.clear(),e.openSearchListeners.clear();try{e.ws?.close(1e3,`client_dispose`)}catch{}e.ws=null;try{e.webgl?.dispose()}catch{}e.webgl=null;try{e.term.dispose()}catch{}try{e.container.remove()}catch{}}var _W={jobs:[],activeJobId:null,paused:!1};function vW(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)({}),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(_W),p=(0,Z.useRef)(e);p.current=e;let m=(0,Z.useRef)(new Map),h=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{if(h.current&&h.current,h.current=e,e){let t=m.current.get(e);t?(n(t.phaseDefinitions),i(t.phases),o(t.projectName),u(t.recentJobs),f(t.queueState)):(n([]),i({}),o(``),u([]),f(_W))}c([])},[e]);let g=(0,Z.useCallback)(e=>{let t=e,r=p.current;if(!(r&&t.projectId&&t.projectId!==r))if(t.type===`init`){let e=t.projectName??``,a=t.phaseDefinitions??[],s={};for(let e of a)s[e.key]=t.phases?.[e.key]??`idle`;let l=t.recentJobs??[],d=t.queue??_W;o(e),n(a),i(s),c(t.logBuffer??[]),u(l),f(d),r&&m.current.set(r,{phaseDefinitions:a,phases:s,projectName:e,recentJobs:l,queueState:d})}else t.type===`phase`?i(e=>({...e,[t.phase]:t.state})):t.type===`log`?c(e=>[...e,{source:t.source,line:t.line,timestamp:t.timestamp,processId:t.processId}]):t.type===`queue`&&f({jobs:t.jobs??[],activeJobId:t.activeJobId??null,paused:t.paused??!1})},[]),{registerHandler:_,unregisterHandler:v,connectionStatus:y}=Et();return(0,Z.useLayoutEffect)(()=>(_(`pipeline`,g),()=>v(`pipeline`)),[g,_,v]),(0,Z.useEffect)(()=>{if(!e)return;let t=!1;async function r(){try{let e=await fetch(`${Ot()}/state`);if(t||!e.ok)return;let r=await e.json();if(t)return;if(r.projectName&&o(r.projectName),r.phaseDefinitions){n(r.phaseDefinitions);let e={};for(let t of r.phaseDefinitions)e[t.key]=r.phases?.[t.key]??`idle`;i(e)}r.recentJobs&&u(r.recentJobs),r.queue&&f(r.queue)}catch{}}return r(),()=>{t=!0}},[e]),{phases:r,phaseDefinitions:t,projectName:a,logLines:s,connectionStatus:y,recentJobs:l,queueState:d}}function yW(){return new SW(WC(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function bW(){return $(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new SW(new qC(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var xW=[`tauri://created`,`tauri://error`],SW=class{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),n?.skip||$(`plugin:webview|create_webview`,{windowLabel:e.label,options:{...n,label:t}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await bW()).find(t=>t.label===e)??null}static getCurrent(){return yW()}static async getAll(){return bW()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:LC(e,t,{target:{kind:`Webview`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:RC(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(xW.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return zC(e,t)}async emitTo(e,t,n){if(xW.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return BC(e,t,n)}_handleTauriEvent(e,t){return xW.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return $(`plugin:webview|webview_position`,{label:this.label}).then(e=>new NC(e))}async size(){return $(`plugin:webview|webview_size`,{label:this.label}).then(e=>new AC(e))}async close(){return $(`plugin:webview|webview_close`,{label:this.label})}async setSize(e){return $(`plugin:webview|set_webview_size`,{label:this.label,value:e instanceof jC?e:new jC(e)})}async setPosition(e){return $(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof PC?e:new PC(e)})}async setFocus(){return $(`plugin:webview|set_webview_focus`,{label:this.label})}async setAutoResize(e){return $(`plugin:webview|set_webview_auto_resize`,{label:this.label,value:e})}async hide(){return $(`plugin:webview|webview_hide`,{label:this.label})}async show(){return $(`plugin:webview|webview_show`,{label:this.label})}async setZoom(e){return $(`plugin:webview|set_webview_zoom`,{label:this.label,value:e})}async reparent(e){return $(`plugin:webview|reparent`,{label:this.label,window:typeof e==`string`?e:e.label})}async clearAllBrowsingData(){return $(`plugin:webview|clear_all_browsing_data`)}async setBackgroundColor(e){return $(`plugin:webview|set_webview_background_color`,{color:e})}async onDragDropEvent(e){let t=await this.listen(FC.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new NC(t.payload.position)}})}),n=await this.listen(FC.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new NC(t.payload.position)}})}),r=await this.listen(FC.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new NC(t.payload.position)}})}),i=await this.listen(FC.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function CW(e){return`'${e.replace(/'/g,`'\\''`)}'`}function wW(e){return`"${e.replace(/\^/g,`^^`).replace(/%/g,`^%`).replace(/"/g,`""`)}"`}function TW(e){return`'${e.replace(/'/g,`''`)}'`}function EW(e,t,n=`powershell`){return t?n===`cmd`?wW(e):TW(e):CW(e)}function DW(e,t,n=`powershell`){return e.map(e=>EW(e,t,n)).join(` `)}async function OW(e){if(!ze())return{dispose:()=>{}};try{let t=[],n=``,r=0,i=typeof navigator<`u`&&/Win/i.test(navigator.platform||``),a=t=>{let a=t.payload;if(!a||a.type!==`drop`)return;let o=a.paths;if(!o||o.length===0)return;let s=a.position;if(!s)return;let c=`${o.join(`\0`)}@${s.x},${s.y}`,l=Date.now();if(c===n&&l-r<250)return;n=c,r=l;let u=e();if(!u||!AW(s,u.viewportEl.getBoundingClientRect(),window.devicePixelRatio||1))return;let d=DW(o,i);try{u.writeText(d)}catch{}},o=kW((()=>{try{return yW()}catch{return null}})());o&&t.push(await o(a));let s=kW((()=>{try{return WC()}catch{return null}})());return s&&t.push(await s(a)),t.length===0?{dispose:()=>{}}:{dispose:()=>{for(let e of t)try{e()}catch{}}}}catch{return{dispose:()=>{}}}}function kW(e){let t=e?.onDragDropEvent;return typeof t==`function`?t.bind(e):null}function AW(e,t,n){if(jW(e.x,e.y,t))return!0;let r=Number.isFinite(n)&&n>0?n:1;return jW(e.x/r,e.y/r,t)}function jW(e,t,n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function MW({x:e,y:t,label:n,onSelect:r,onClose:i}){let a=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i()},t=e=>{e.key===`Escape`&&i()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]),(0,Q.jsx)(`div`,{ref:a,role:`menu`,"data-shortcut-context-menu":!0,style:{position:`fixed`,left:typeof window<`u`&&e+220>window.innerWidth?e-220:e,top:typeof window<`u`&&t+60>window.innerHeight?t-60:t,minWidth:200},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:(0,Q.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(),i()},className:`w-full text-left px-3 py-1.5 text-[#f8f8f2] hover:bg-[#44475a]`,children:n})})}function NW({x:e,y:t,providers:n,onSelect:r,onClose:i}){let{t:a}=I(`terminal`),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&i()},t=e=>{e.key===`Escape`&&i()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=typeof window<`u`&&e+200>window.innerWidth?e-200:e,c=8+n.length*32;return(0,Q.jsx)(`div`,{ref:o,role:`menu`,"data-cli-launch-menu":!0,style:{position:`fixed`,left:s,top:typeof window<`u`&&t+c>window.innerHeight?t-c:t,minWidth:180},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:n.map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(e),i()},className:`w-full text-left px-3 py-1.5 text-[#f8f8f2] hover:bg-[#44475a]`,children:a(`cliMenu.open`,{name:yh(e)})},e))})}var PW=(0,Z.forwardRef)(function({isOpen:e,className:t,...n},r){let{t:i}=I(`terminal`);return(0,Q.jsx)(`button`,{ref:r,type:`button`,"aria-label":i(e?`panelChevron.collapse`:`panelChevron.expand`),"aria-expanded":e,className:X(`panel-chevron`,`inline-flex items-center justify-center`,`h-5 w-6 mr-1.5`,`rounded text-muted-foreground`,`hover:bg-border/40 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/60`,`transition-colors duration-120`,t),...n,children:(0,Q.jsxs)(`svg`,{width:`14`,height:`10`,viewBox:`0 0 14 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,Q.jsx)(`rect`,{x:`1`,y:`1`,width:`12`,height:`8`,rx:`1.5`}),e?(0,Q.jsx)(`path`,{d:`M5 3.5 L7 5.5 L9 3.5`}):(0,Q.jsx)(`path`,{d:`M5 6.5 L7 4.5 L9 6.5`})]})})});function FW({visibility:e,canCreate:t,hasActive:n,provider:r=`claude`,providers:i,onCreate:a,onOpenCli:o,onOpenBrowser:s,onPasteScript:c,pasteScriptDisabled:l,onConfigureBrowser:u,onConfigureScript:d,onKillActive:f,onToggleMaximize:p,onCollapse:m}){let{t:h}=I(`terminal`),g=!!i&&i.length>1,_=yh(r),v=h(`topBar.maxTerminals`,{max:10}),y=t?g?h(`topBar.openCliMulti`):h(`topBar.openCli`,{cli:_}):v;return(0,Q.jsxs)(`div`,{className:X(`flex items-center justify-between h-7 px-2 shrink-0`,`bg-background/95 backdrop-blur-sm`,`border-b border-border/40`,`text-[10px] uppercase tracking-wide text-muted-foreground select-none`),children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2 pl-1`,children:(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:h(`topBar.title`)})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(IW,{label:y,disabled:!t,onClick:e=>o(e?{x:e.clientX,y:e.clientY}:void 0),children:(0,Q.jsx)(gt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(IW,{label:h(`topBar.openInBrowser`),onClick:s,onContextMenu:e=>{e.preventDefault(),u({x:e.clientX,y:e.clientY})},children:(0,Q.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(IW,{label:h(l?`topBar.pasteScriptNoActive`:`topBar.pasteScript`),disabled:l,onClick:c,onContextMenu:e=>{e.preventDefault(),d({x:e.clientX,y:e.clientY})},children:(0,Q.jsx)(zn,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(IW,{label:t?h(`topBar.newTerminal`):v,disabled:!t,onClick:a,children:(0,Q.jsx)(pt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(IW,{label:h(`topBar.killActive`),disabled:!n,onClick:f,children:(0,Q.jsx)(_t,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(IW,{label:h(e===`maximized`?`topBar.restorePanel`:`topBar.maximizePanel`),onClick:p,children:e===`maximized`?(0,Q.jsx)(Or,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Dr,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(PW,{isOpen:!0,onClick:m})]})]})}function IW({label:e,disabled:t,onClick:n,onContextMenu:r,children:i}){return(0,Q.jsx)(`button`,{type:`button`,onClick:e=>n(e),onContextMenu:r,disabled:t,title:e,"aria-label":e,className:X(`inline-flex items-center justify-center h-5 w-6 rounded`,`text-muted-foreground transition-colors duration-120`,t?`opacity-40 cursor-not-allowed`:`hover:bg-border/40 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/60`),children:i})}function LW({sessions:e,activeId:t,onActivate:n,onRename:r,onKill:i}){return(0,Q.jsx)(`aside`,{className:X(`w-44 shrink-0 border-l border-border/40 bg-background/70`,`overflow-y-auto`),children:(0,Q.jsx)(`ul`,{className:`py-1`,children:e.map(e=>(0,Q.jsx)(RW,{session:e,active:e.id===t,onActivate:()=>n(e.id),onRename:t=>r(e.id,t),onKill:()=>i(e.id)},e.id))})})}function RW({session:e,active:t,onActivate:n,onRename:r,onKill:i}){let{t:a}=I(`terminal`),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(e.name),u=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{o&&(l(e.name),queueMicrotask(()=>{u.current?.focus(),u.current?.select()}))},[o,e.name]);function d(){let t=c.trim();t&&t!==e.name&&r(t),s(!1)}function f(){s(!0)}function p(){s(!1),l(e.name)}return(0,Q.jsx)(`li`,{className:`relative group px-1`,children:(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":t,onClick:()=>{o||n()},onKeyDown:e=>{o||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},onDoubleClick:f,className:X(`flex items-center gap-2 px-2 py-1.5 rounded-md text-xs cursor-pointer select-none`,`transition-colors duration-120`,t?`bg-border/40 text-foreground border-l-2 border-accent-primary/70 pl-[calc(0.5rem-2px)]`:`text-muted-foreground hover:bg-border/20 hover:text-foreground`),children:[(0,Q.jsx)(fi,{className:`h-3 w-3 shrink-0`}),o?(0,Q.jsx)(`input`,{ref:u,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d()),e.key===`Escape`&&(e.preventDefault(),p())},onBlur:d,onClick:e=>e.stopPropagation(),maxLength:64,className:X(`flex-1 min-w-0 bg-background/60 border border-border/40 rounded px-1`,`text-xs text-foreground outline-none focus:ring-1 focus:ring-accent-primary/60`)}):(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),!o&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":a(`sidebar.rename`,{name:e.name}),title:a(`sidebar.rename`,{name:e.name}),onClick:e=>{e.stopPropagation(),f()},className:X(`inline-flex items-center justify-center h-4 w-4 rounded`,`text-muted-foreground opacity-0 group-hover:opacity-100`,`hover:bg-border/40 hover:text-foreground`,`transition-opacity duration-120`,t&&`opacity-70`),children:(0,Q.jsx)(dt,{className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":a(`sidebar.close`,{name:e.name}),title:a(`sidebar.close`,{name:e.name}),onClick:e=>{e.stopPropagation(),i()},className:X(`inline-flex items-center justify-center h-4 w-4 rounded`,`text-muted-foreground opacity-0 group-hover:opacity-100`,`hover:bg-destructive/20 hover:text-destructive`,`transition-opacity duration-120`,t&&`opacity-70`),children:(0,Q.jsx)(yt,{className:`h-3 w-3`})})]})})}function zW({search:e,onClose:t}){let{t:n}=I(`terminal`),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null);(0,Z.useEffect)(()=>(r.current?.focus(),()=>{try{e.clearDecorations()}catch{}}),[e]),(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);function m(){return{caseSensitive:o,regex:c,wholeWord:u,decorations:{matchBackground:`#bd93f9`,matchOverviewRuler:`#bd93f9`,activeMatchBackground:`#ff79c6`,activeMatchColorOverviewRuler:`#ff79c6`}}}function h(){if(i)try{e.findNext(i,m())}catch{}}function g(){if(i)try{e.findPrevious(i,m())}catch{}}return(0,Z.useEffect)(()=>{let t=()=>{};try{let n=e.onDidChangeResults(e=>{if(!e){p(null);return}p({current:e.resultIndex+1,total:e.resultCount})});t=()=>{try{n.dispose()}catch{}}}catch{}return t},[e]),(0,Q.jsxs)(`div`,{className:`absolute top-2 right-2 flex items-center gap-1 bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg px-2 py-1 z-30`,role:`search`,"data-terminal-search-overlay":!0,children:[(0,Q.jsx)(`input`,{ref:r,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.shiftKey?g():h())},placeholder:n(`search.placeholder`),className:`bg-transparent text-sm outline-none text-[#f8f8f2] placeholder:text-[#6272a4] w-48`}),f&&(0,Q.jsxs)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:[f.current,`/`,f.total]}),(0,Q.jsx)(`button`,{type:`button`,title:n(`search.previous`),onClick:g,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,Q.jsx)(de,{size:14})}),(0,Q.jsx)(`button`,{type:`button`,title:n(`search.next`),onClick:h,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,Q.jsx)(pe,{size:14})}),(0,Q.jsx)(BW,{label:`Aa`,title:n(`search.matchCase`),active:o,onToggle:()=>s(e=>!e)}),(0,Q.jsx)(BW,{label:`.*`,title:n(`search.regex`),active:c,onToggle:()=>l(e=>!e)}),(0,Q.jsx)(BW,{label:`W`,title:n(`search.wholeWord`),active:u,onToggle:()=>d(e=>!e)}),(0,Q.jsx)(`button`,{type:`button`,title:n(`search.close`),onClick:t,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,Q.jsx)(yt,{size:14})})]})}function BW({label:e,title:t,active:n,onToggle:r}){return(0,Q.jsx)(`button`,{type:`button`,title:t,onClick:r,className:`text-xs px-1.5 py-0.5 rounded font-mono ${n?`bg-[#6272a4] text-white`:`text-[#f8f8f2] hover:bg-[#44475a]`}`,children:e})}function VW({x:e,y:t,term:n,cwd:r,hasReveal:i,onClose:a,onOpenSearch:o,onReveal:s,onSaveScrollback:c}){let{t:l}=I(`terminal`),u=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&a()},t=e=>{e.key===`Escape`&&a()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let d=typeof window<`u`&&e+220>window.innerWidth?e-220:e,f=typeof window<`u`&&t+260>window.innerHeight?t-260:t,p=n.getSelection(),m=p.length>0;function h(){m&&(QU(p),a())}function g(){ZU().then(e=>{if(e)try{n.paste(e)}catch{}}),a()}function _(){try{n.selectAll()}catch{}a()}function v(){try{n.clear()}catch{}a()}function y(){o(),a()}function b(){c(),a()}function x(){r&&s(r),a()}return(0,Q.jsxs)(`div`,{ref:u,role:`menu`,"data-terminal-context-menu":!0,style:{position:`fixed`,left:d,top:f,minWidth:200},className:`bg-[#1f1f29] border border-[#44475a] rounded-md shadow-lg py-1 z-50 text-sm`,children:[(0,Q.jsx)(HW,{onClick:h,disabled:!m,label:l(`common:actions.copy`),shortcut:`⌘C`}),(0,Q.jsx)(HW,{onClick:g,label:l(`contextMenu.paste`),shortcut:`⌘V`}),(0,Q.jsx)(HW,{onClick:_,label:l(`contextMenu.selectAll`),shortcut:`⌘A`}),(0,Q.jsx)(UW,{}),(0,Q.jsx)(HW,{onClick:v,label:l(`contextMenu.clear`),shortcut:`⌘K`}),(0,Q.jsx)(HW,{onClick:y,label:l(`contextMenu.search`),shortcut:`⌘F`}),(0,Q.jsx)(HW,{onClick:b,label:l(`contextMenu.saveScrollback`)}),r&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(UW,{}),(0,Q.jsx)(HW,{onClick:x,label:l(`contextMenu.openPath`,{path:WW(r,40)})})]})]})}function HW({onClick:e,label:t,shortcut:n,disabled:r}){return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r||e()},disabled:r,className:`w-full text-left px-3 py-1.5 flex justify-between items-center ${r?`text-[#6272a4] cursor-not-allowed`:`text-[#f8f8f2] hover:bg-[#44475a]`}`,children:[(0,Q.jsx)(`span`,{children:t}),n&&(0,Q.jsx)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:n})]})}function UW(){return(0,Q.jsx)(`div`,{className:`my-1 border-t border-[#44475a]`})}function WW(e,t){return e.length<=t?e:`…`+e.slice(e.length-t+1)}async function GW(e,t=`terminal-scrollback.txt`){let n=e.buffer.active,r=[];for(let e=0;e<n.length;e++){let t=n.getLine(e);t&&r.push(t.translateToString(!0))}let i=r.join(`
|
|
76
|
-
`);if(ze())try{let e=await(await c(()=>import(`./dist-js-Bt2zW2YG.js`),[])).save({defaultPath:t});if(!e)return;try{let t=await $e(`@tauri-apps/plugin-fs`);if(t?.writeTextFile){await t.writeTextFile(e,i);return}}catch{}try{await(await $e(`@tauri-apps/api/fs`))?.writeTextFile?.({path:e,contents:i})}catch{}return}catch{}try{let e=new Blob([i],{type:`text/plain;charset=utf-8`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{}}function KW({sessionId:e}){let[t,n]=(0,Z.useState)(()=>VU(e));return(0,Z.useEffect)(()=>BU(e,n),[e]),t.promptRows.length===0?null:(0,Q.jsx)(`div`,{"aria-hidden":`true`,"data-prompt-gutter":!0,className:`absolute left-0 top-0 bottom-0 w-1 pointer-events-none z-10`,children:(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 bottom-0 w-full`,style:{backgroundImage:`linear-gradient(to bottom, rgba(189,147,249,0.2), rgba(189,147,249,0.05))`}})})}function qW({sessionId:e}){let{t}=I(`terminal`),[n,r]=(0,Z.useState)(VU(e).openPreExec?.startedAt??null),[i,a]=(0,Z.useState)(Date.now());if((0,Z.useEffect)(()=>BU(e,e=>r(e.openPreExec?.startedAt??null)),[e]),(0,Z.useEffect)(()=>{if(n==null)return;let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[n]),n==null)return null;let o=i-n;return o<500?null:(0,Q.jsx)(`div`,{className:`absolute top-2 left-2 px-2 py-0.5 rounded text-xs font-mono bg-[#44475a] text-[#f8f8f2] z-10 pointer-events-none`,children:JW(o,t)})}function JW(e,t){return e<6e4?t(`terminal:duration.seconds`,{seconds:(e/1e3).toFixed(1)}):t(`terminal:duration.minutesSeconds`,{minutes:Math.floor(e/6e4),seconds:Math.floor(e%6e4/1e3)})}function YW({activeId:e}){let t=(0,Z.useRef)(null),n=sW(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=ze();(0,Z.useEffect)(()=>{if(e)return n.subscribeOpenSearch(e,()=>i(!0))},[e,n]),(0,Z.useEffect)(()=>{i(!1),o(null)},[e]);let c=e?n.getSearchAddon(e):null,l=e?n.getTerminalInstance(e):null,u=e?n.getCwd(e):null,[d,f]=(0,Z.useState)(!1),p=(0,Z.useCallback)(t=>{if(!t)return!1;if(e&&n.writeToSession(e,t))return!0;if(!l)return!1;try{return l.paste(t),!0}catch{return!1}},[e,n,l]),m=(0,Z.useCallback)(e=>{if(!l||!e||e.length===0)return!1;let t=Array.from(e).map(e=>XW(e)).filter(e=>!!e);if(t.length===0)return!1;let n=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);return p(DW(t,n))},[l,p]),h=(0,Z.useCallback)(e=>{if(e.preventDefault(),!e.shiftKey&&l){let e=l.modes?.mouseTrackingMode;if(e&&e!==`none`)return}o({x:e.clientX,y:e.clientY})},[l]),g=(0,Z.useCallback)(e=>{if(!l)return;if(e.clipboardData.files&&e.clipboardData.files.length>0){let t=Array.from(e.clipboardData.files).map(e=>XW(e)).filter(e=>!!e);if(t.length>0){e.preventDefault(),e.stopPropagation();let n=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);p(DW(t,n));return}}let t=e.clipboardData.getData(`text/plain`);t&&(e.preventDefault(),e.stopPropagation(),p(t))},[l,p]),_=(0,Z.useCallback)(e=>{if(!l)return;let t=l.getSelection();t&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault(),e.stopPropagation())},[l]),v=(0,Z.useCallback)(e=>{if(l&&(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?e.metaKey:e.ctrlKey)&&(e.key===`c`||e.key===`C`)){let t=l.getSelection();if(!t)return;e.preventDefault(),e.stopPropagation(),QU(t)}},[l]);return(0,Z.useEffect)(()=>{let r=t.current;if(!r||!e)return;let i=n.getContainer(e);if(i)return r.appendChild(i),n.notifyAdopted(e),()=>{let e=document.getElementById(`specrails-terminal-host`);e&&i.parentElement===r&&e.appendChild(i)}},[e,n]),(0,Z.useEffect)(()=>{let r=t.current;if(!r||!e)return;let i=[],a=r.parentElement;for(;a&&a!==document.body;)(a.tagName.toLowerCase()===`aside`||a.matches(`[data-sidebar]`))&&i.push(a),a=a.parentElement;if(i.length===0)return;let o=t=>{let r=t;r.propertyName!==`width`&&r.propertyName!==`height`||n.refitActive(e)};return i.forEach(e=>e.addEventListener(`transitionend`,o)),()=>{i.forEach(e=>e.removeEventListener(`transitionend`,o))}},[e,n]),(0,Q.jsxs)(`div`,{ref:t,className:`flex-1 min-w-0 bg-background px-2 py-1 relative ${d?`outline outline-2 outline-accent-primary outline-offset-[-2px]`:``}`,role:`presentation`,"data-terminal-viewport":!0,onContextMenu:h,onPasteCapture:g,onCopyCapture:_,onKeyDownCapture:v,tabIndex:-1,onDragEnter:e=>{ZW(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),f(!0))},onDragOver:e=>{ZW(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),f(!0))},onDragLeave:()=>f(!1),onDrop:e=>{ZW(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),m(e.dataTransfer.files)),f(!1)},children:[e&&(0,Q.jsx)(KW,{sessionId:e}),e&&(0,Q.jsx)(qW,{sessionId:e}),r&&c&&(0,Q.jsx)(zW,{search:c,onClose:()=>i(!1)}),a&&l&&(0,Q.jsx)(VW,{x:a.x,y:a.y,term:l,cwd:u,hasReveal:s,onClose:()=>o(null),onOpenSearch:()=>i(!0),onReveal:e=>{tt(e)},onSaveScrollback:()=>{l&&GW(l)}})]})}function XW(e){let t=e.path;return typeof t==`string`&&t.length>0?t:null}function ZW(e){return e?Array.from(e.types).includes(`Files`):!1}function QW({height:e,maxHeight:t,onHeightCommit:n,onHeightPreview:r,minHeight:i=120}){let{t:a}=I(`terminal`),o=(0,Z.useRef)(!1),s=(0,Z.useRef)(0),c=(0,Z.useRef)(e),l=(0,Z.useRef)(!1),u=(0,Z.useRef)(e),d=(0,Z.useCallback)(e=>e<i?i:e>t?t:Math.round(e),[i,t]);(0,Z.useEffect)(()=>{function e(e){if(!o.current)return;let t=s.current-e.clientY,n=d(c.current+t);u.current=n,l.current||(l.current=!0,requestAnimationFrame(()=>{l.current=!1,r?.(u.current)}))}function t(){o.current&&(o.current=!1,document.body.style.userSelect=``,document.body.style.cursor=``,n(u.current))}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[d,n,r]);function f(t){o.current=!0,s.current=t.clientY,c.current=e,u.current=e,document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`;let n=t.target;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(t.pointerId)}catch{}}return(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`dragHandle.resize`),onPointerDown:f,className:X(`absolute top-0 left-0 right-0 h-1`,`cursor-row-resize`,`bg-transparent hover:bg-accent-primary/40`,`transition-colors duration-120`,`z-10`)})}function $W({onCreate:e}){let{t}=I(`terminal`);return(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-center px-6 bg-background-deep`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,Q.jsx)(fi,{className:`h-8 w-8 opacity-50`}),(0,Q.jsx)(`p`,{className:`text-xs`,children:t(`emptyState.noTerminals`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs bg-border/30 hover:bg-border/50 hover:text-foreground transition-colors`,children:[(0,Q.jsx)(pt,{className:`h-3 w-3`}),` `,t(`emptyState.newTerminal`)]})]})})}var eG=300;function tG({projectId:e,provider:t=`claude`,providers:n,state:r,viewportHeight:i,statusBarHeight:a}){let o=sW(),{t:s}=I(`terminal`),c=p(),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(null),[f,m]=(0,Z.useState)(sx),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=(0,Z.useRef)(a===0&&r.visibility!==`hidden`),[b,x]=(0,Z.useState)(()=>r.visibility===`hidden`?`hidden`:y.current?`opening`:`open`),S=(0,Z.useRef)(!1),C=n&&n.length>0?n:[t],w=C.length>1,T=(0,Z.useCallback)(async(t=()=>!1)=>{try{let n=await fetch(`/api/projects/${e}/terminal-settings`);if(!n.ok)return;let r=await n.json();!t()&&r?.resolved&&m(r.resolved)}catch{}},[e]);(0,Z.useEffect)(()=>{let e=!1;return T(()=>e),()=>{e=!0}},[T]),(0,Z.useEffect)(()=>{let t=t=>{let n=t.detail;n?.mode===`project`&&n.projectId!==e||T()};return window.addEventListener(lx,t),()=>window.removeEventListener(lx,t)},[T,e]);let E=Math.max(120,i-a-40),D=Math.min(Math.max(r.userHeight||320,120),E),O=r.visibility===`maximized`?Math.max(120,i-a):u??D,k=b===`open`,A=k?O:0,j=a===0,M=r.sessions.length<10,N=r.activeId!==null;(0,Z.useEffect)(()=>{let e=null,t=null,n=null,i=()=>{x(`opening`),t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>x(`open`))})};return S.current?(r.visibility===`hidden`?(x(`closing`),e=setTimeout(()=>x(`hidden`),eG)):i(),()=>{e&&clearTimeout(e),t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)}):(S.current=!0,y.current&&i(),()=>{t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)})},[r.visibility]),(0,Z.useEffect)(()=>{let e=!1,t=null;return OW(()=>{let e=l.current,t=r.activeId;return!e||!t||r.visibility===`hidden`?null:{viewportEl:e,writeText:e=>{if(o.writeToSession(t,e))return!0;let n=o.getTerminalInstance(t);try{return n?.paste(e),!!n}catch{return!1}}}}).then(n=>{e?n.dispose():t=n}),()=>{e=!0,t?.dispose()}},[r.activeId,r.visibility,o]);let P=(0,Z.useCallback)(()=>{M&&o.create(e)},[M,e,o]),F=(0,Z.useCallback)(t=>{if(!M)return;let n=t||`claude`,i=RegExp(`^${n} \\(\\d+\\)$`),a=r.sessions.filter(e=>e.name===n||i.test(e.name)),s=a.length===0?n:`${n} (${a.length+1})`;o.createAndType(e,`${n}\n`,{name:s})},[M,e,r.sessions,o]),L=(0,Z.useCallback)(e=>{if(M){if(w&&e){v(e);return}F(t)}},[M,w,t,F]),R=(0,Z.useCallback)(()=>{qe(f.browserShortcutUrl)},[f.browserShortcutUrl]),z=(0,Z.useCallback)(()=>{r.activeId&&f.quickScript&&o.writeToSession(r.activeId,f.quickScript)},[f.quickScript,r.activeId,o]),B=(0,Z.useCallback)(e=>{g({...e,kind:`browser`})},[]),V=(0,Z.useCallback)(e=>{g({...e,kind:`script`})},[]),H=(0,Z.useCallback)(e=>{c(`/settings${e===`browser`?`#terminal-browser-shortcut-url`:`#terminal-quick-script`}`)},[c]),U=(0,Z.useCallback)(()=>{r.activeId&&o.kill(e,r.activeId)},[e,r.activeId,o]),W=(0,Z.useCallback)(()=>{o.setVisibility(e,r.visibility===`maximized`?`restored`:`maximized`)},[e,r.visibility,o]),ee=(0,Z.useCallback)(()=>{o.setVisibility(e,`hidden`)},[e,o]);return(0,Z.useEffect)(()=>{d(null)},[r.visibility]),b===`hidden`?null:(0,Q.jsxs)(`div`,{ref:l,className:X(`relative flex flex-col shrink-0 overflow-hidden origin-bottom transform-gpu bg-background/95`,`border-t border-border/40`,`transition-[height,opacity,transform,clip-path] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`),style:{height:A,opacity:+!!k,transform:k?`translateY(0) scaleY(1)`:`translateY(${j?14:8}px) scaleY(${j?.96:.985})`,clipPath:k?`inset(0 0 0 0)`:`inset(100% 0 0 0)`},"data-testid":`terminal-bottom-panel`,children:[(0,Q.jsx)(QW,{height:D,maxHeight:E,onHeightPreview:e=>d(e),onHeightCommit:t=>{d(null),o.setUserHeight(e,t),r.visibility===`maximized`&&o.setVisibility(e,`restored`)}}),(0,Q.jsx)(FW,{visibility:r.visibility,canCreate:M,hasActive:N,provider:t,providers:C,onCreate:P,onOpenCli:L,onOpenBrowser:R,onPasteScript:z,pasteScriptDisabled:!N||!f.quickScript,onConfigureBrowser:B,onConfigureScript:V,onKillActive:U,onToggleMaximize:W,onCollapse:ee}),h&&(0,Q.jsx)(MW,{x:h.x,y:h.y,label:h.kind===`browser`?s(`shortcutMenu.configureBrowserUrl`):s(`shortcutMenu.editQuickScript`),onSelect:()=>H(h.kind),onClose:()=>g(null)}),_&&(0,Q.jsx)(NW,{x:_.x,y:_.y,providers:C,onSelect:e=>F(e),onClose:()=>v(null)}),(0,Q.jsx)(`div`,{className:`flex-1 flex min-h-0`,children:r.sessions.length===0?(0,Q.jsx)($W,{onCreate:P}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(YW,{activeId:r.activeId}),(0,Q.jsx)(LW,{sessions:r.sessions,activeId:r.activeId,onActivate:t=>o.setActive(e,t),onRename:(t,n)=>void o.rename(e,t,n),onKill:t=>void o.kill(e,t)})]})})]})}function nG({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=I(`nav`),{t:i}=I(`analytics`),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(`connecting`),u=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>{let t=l.current;if(e===`connected`&&!u.current&&t!==`connected`){R.success(r(`statusBar.connectionRestored`)),c(!0);let e=setTimeout(()=>c(!1),2e3);return()=>clearTimeout(e)}u.current&&e===`connected`&&(u.current=!1),l.current=e},[e]),(0,Z.useEffect)(()=>{u.current&&=!1},[]),(0,Z.useEffect)(()=>{if(n)return;async function e(){try{let e=await fetch(`${Ot()}/stats`);if(e.ok){let t=await e.json();o(t)}}catch{}}e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[e,n]);let d=!n||e!==`connected`||s;return(0,Q.jsxs)(`footer`,{className:`h-7 flex items-center justify-between px-4 border-t border-border/30 bg-background/80 backdrop-blur-sm text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`div`,{className:X(`flex items-center gap-1.5 transition-opacity duration-300`,!d&&`opacity-0`),"aria-hidden":!d||void 0,children:[(0,Q.jsx)(`span`,{className:X(`w-1.5 h-1.5 rounded-full transition-colors`,e===`connected`&&!s&&`bg-accent-success`,e===`connected`&&s&&`bg-accent-info animate-pulse`,e===`connecting`&&`bg-accent-warning animate-[pulse_0.75s_ease-in-out_infinite]`,e===`disconnected`&&`bg-destructive`)}),(0,Q.jsxs)(`span`,{className:X(`transition-colors`,e===`connected`&&!s&&`text-accent-success`,e===`connected`&&s&&`text-accent-info`,e===`connecting`&&`text-accent-warning`,e===`disconnected`&&`text-destructive`),children:[e===`connected`&&!s&&r(`statusBar.connected`),e===`connected`&&s&&r(`statusBar.syncing`),e===`connecting`&&r(`statusBar.reconnecting`),e===`disconnected`&&r(`statusBar.disconnected`)]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!n&&a&&a.totalCostUsd>0&&(()=>{let e=a.includesEstimated??((a.estimatedCostUsd??0)>0||(a.estimatedCostToday??0)>0);return(0,Q.jsxs)(`span`,{"data-estimated":e?`true`:void 0,title:e?i(`desktop.statusBarEstimatedTooltip`):void 0,children:[e?`~`:``,`$`,a.totalCostUsd.toFixed(2)]})})(),t]})]})}var rG={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function iG(){let{t:e}=I(`agent`),{t}=I(`nav`),{t:n}=I(`builder`),{rightMode:r,cycleRightMode:i}=fE(),{activeProjectId:a}=At(),o=sW(),s=zR(),{active:c,builderMode:l}=UV(),[u,d]=(0,Z.useState)(!1),f=l.active||r===`pinned-open`||r===`unpinned`&&u,p=ZT(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:f}),m=r!==`unpinned`,h=t(rG[r]),g=!a,_=[{key:`jobs`,icon:Dn,label:e(`workspace.jobs`),onClick:()=>s.toggleJobsPane(),disabled:g,disabledTitle:e(`workspace.requiresProject`)},...ie()?[{key:`browser`,icon:te,label:e(`workspace.browser`),onClick:()=>s.openBrowser(),disabled:g||!c,disabledTitle:e(g?`workspace.requiresProject`:`workspace.requiresConversation`)}]:[],...Ee?[{key:`terminal`,icon:si,label:e(`workspace.terminal`),onClick:()=>a&&o.togglePanel(a),disabled:g,disabledTitle:e(`workspace.requiresProject`)}]:[],...it?[{key:`files`,icon:Zn,label:e(`workspace.files`),onClick:()=>s.toggleCodePane(),disabled:g,disabledTitle:e(`workspace.requiresProject`)}]:[]];return(0,Q.jsxs)(`div`,{ref:p.panelRef,className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{r===`unpinned`&&d(!0)},onMouseLeave:()=>{r===`unpinned`&&!p.dragging&&d(!1)},children:[f&&(0,Q.jsx)(QT,{side:`right`,dragging:p.dragging,width:p.width,min:180,max:460,label:t(`sidebarPin.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:p.onGripPointerDown,onKeyDown:p.onGripKeyDown}),(0,Q.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,f?`px-3 justify-between`:`justify-center`),children:[f&&(0,Q.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`workspace.title`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:i,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,m?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":h,title:t(`sidebarPin.withShortcut`,{label:h,shortcut:`⌘B`}),children:(0,Q.jsx)(Ir,{className:`w-4 h-4`})})]}),l.active?(0,Q.jsx)(MF,{mode:`wait`,initial:!1,children:(0,Q.jsxs)(ML.div,{initial:{opacity:0,x:24},animate:{opacity:1,x:0},exit:{opacity:0,x:24},transition:{duration:.22,ease:`easeOut`},className:`flex min-h-0 flex-1 flex-col`,"data-testid":`workspace-blueprint-panel`,children:[(0,Q.jsx)(mV,{blueprint:l.session.blueprint}),l.session.phase===`chat`&&(0,Q.jsxs)(`div`,{className:`border-t border-border/40 p-3`,children:[(0,Q.jsxs)(Y,{className:`w-full`,size:`sm`,disabled:!l.session.canProposeCommit,onClick:l.session.goToCommit,"data-testid":`builder-create-specs`,children:[(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),n(`shell.createSpecs`)]}),!l.session.canProposeCommit&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,children:l.session.specQualityDetail??n(`shell.createSpecsHint`)})]})]},`builder-blueprint`)}):(0,Q.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,Q.jsx)(iH,{expanded:f}),_.map(({key:e,icon:t,label:n,onClick:r,disabled:i,disabledTitle:a})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,f?`px-2`:`px-0 justify-center`,i?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:i?a:f?void 0:n,children:[(0,Q.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),f&&(0,Q.jsx)(`span`,{className:`text-xs truncate`,children:n})]},e))]})]})}var aG=(0,Z.lazy)(()=>c(()=>import(`./AgentModeCodePane-BqOVg15n.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([82,1,2,5,6,42]))),oG=(0,Z.lazy)(()=>c(()=>import(`./AgentModeJobsPane-4SG6FF27.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([83,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,55,42,43,36,37,44,34,3,67,66,71,72,75,0,35,38,39,40,41,45,46,47,48,49,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,68,69,70,73,74,84]))),sG=(0,Z.lazy)(()=>c(()=>import(`./AgentBrowserCapture-I7a0usG7.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([85,1,2,6,34,3])));function cG(){let{t:e}=I(`agent`),{active:t,refreshConversations:n,builderMode:r}=UV(),{codePaneOpen:i,jobsPaneOpen:a,browserOpen:o}=zR(),{activeProjectId:s}=At(),c=kb(),l=c.id===`galaxy`,u=c.id===`code-rain`?e(`emptyTitleCodeRain`):e(`emptyTitle`);(0,Z.useEffect)(()=>{n()},[n]);let d=i&&!!s,f=a&&!!s;return(0,Q.jsx)(qF,{reducedMotion:`user`,children:(0,Q.jsxs)(`div`,{"data-agent-mode-surface":!0,className:`relative z-0 flex h-full w-full overflow-hidden bg-background`,children:[l&&(0,Q.jsx)(Lb,{}),(0,Q.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsx)(ML.div,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 z-0`,animate:{opacity:+(t===null)},transition:{duration:.5,ease:`easeOut`},style:{background:`radial-gradient(60% 55% at 50% 45%, color-mix(in srgb, var(--color-accent-primary) 13%, transparent), transparent 70%)`}}),r.active?(0,Q.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Q.jsx)(lV,{variant:`inline`})}):t===null?(0,Q.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,Q.jsxs)(ML.div,{layoutId:`agent-composer-dock`,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.34,1.56,.64,1],layout:{type:`spring`,stiffness:350,damping:34}},className:`w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-4 shadow-2xl backdrop-blur-xl`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,Q.jsx)(wn,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:u})]}),(0,Q.jsx)(Rz,{autoFocus:!0})]})}):(0,Q.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Q.jsx)(bB,{variant:`inline`})})]}),f&&(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,Q.jsx)(oG,{projectId:s})}),d&&(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,Q.jsx)(aG,{projectId:s,conversationId:t?.id??`__home__`})}),o&&s&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(sG,{projectId:s,conversationId:t?.id??null})})]})})}function lG(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=Xe(),{tickets:i}=Ge(),a=u(),o=p(),s=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(s.current||i.length===0||new URLSearchParams(a.search).get(`compare`)&&typeof window<`u`&&window.innerWidth<900)return;s.current=!0;let e=new URLSearchParams(a.search),c=e.get(`compare`),l=e.get(`compareSide`);if(!c)return;let u=Number.parseInt(c,10),d=l===`right`?`right`:`left`;if(!i.some(e=>e.id===u)){let e=new URLSearchParams(a.search);e.delete(`compare`),e.delete(`compareSide`);let t=e.toString();o({pathname:a.pathname,search:t?`?${t}`:``},{replace:!0});return}let f=e.get(`compareOrigin`);if(f){let e=Number.parseInt(f,10);if(i.some(t=>t.id===e)){t(e),n(d),r(u,d===`left`?`right`:`left`);return}}t(u)},[i,a.search,a.pathname,o,t,n,r]),(0,Z.useEffect)(()=>{if(!s.current)return;let t=new URLSearchParams(a.search),n=t.has(`compare`);if(e.originSide===null){if(n){t.delete(`compare`),t.delete(`compareSide`),t.delete(`compareOrigin`);let e=t.toString();o({pathname:a.pathname,search:e?`?${e}`:``},{replace:!0})}return}let r=e.originSide===`left`?e.leftId:e.rightId,i=e.originSide===`left`?e.rightId:e.leftId;if(r==null||e.originSide==null)return;let c=new URLSearchParams(a.search);c.set(`compareSide`,e.originSide),c.set(`compareOrigin`,String(r)),i==null?c.delete(`compare`):c.set(`compare`,String(i));let l=c.toString();l!==(a.search.startsWith(`?`)?a.search.slice(1):a.search)&&o({pathname:a.pathname,search:l?`?${l}`:``},{replace:!0})},[e,a.search,a.pathname,o])}function uG(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:null}function dG({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r}){if(e===`agent`){let e=uG(t);return e?{kind:`modalize`,surface:e,backgroundPath:`/`}:null}return n?{kind:`route`,surface:`loops`,path:`/loops`}:r?{kind:`route`,surface:`plugins`,path:`/plugins`}:null}var fG=(0,Z.lazy)(()=>c(()=>import(`./JobDetailPage-DM-6zYpA.js`),__vite__mapDeps([86,1,2,40,5,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,3,39,41,42,43,36,44,37,47,38,35,45,46,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,84]))),pG=(0,Z.lazy)(()=>c(()=>import(`./JobsPage-1dkjPk1k.js`),__vite__mapDeps([87,1,2,40,5,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,3,51,61,62,42,36,37,44,43,64,65,66,67,68,70,71,72,75,84,88,52]))),mG=(0,Z.lazy)(()=>c(()=>import(`./AnalyticsPage-BcMNByW5.js`),__vite__mapDeps([89,1,2,40,5,49,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,90,43,36,37,44,34,3,66,73,88,52,91,92]))),hG=(0,Z.lazy)(()=>c(()=>import(`./ActivityFeedPage-AQgpr9qG.js`),__vite__mapDeps([93,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,51,55,63,43,36,37,44,34,3]))),gG=(0,Z.lazy)(()=>c(()=>import(`./AgentsPage-C3FgYlEi.js`),__vite__mapDeps([94,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,49,34,3,50,39,40,41,42,43,36,44,37,46,47,53,55,56,58,59,60,61,62,64,65,66,67,68]))),_G=(0,Z.lazy)(()=>c(()=>import(`./CodePage-CgdDkXp-.js`),__vite__mapDeps([95,1,2,3,5,40,6,34,35,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,36,37,39,41,42,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73]))),vG=(0,Z.lazy)(()=>c(()=>import(`./IntegrationsPage-Bs00_tl4.js`),__vite__mapDeps([96,2,1,40,5]))),yG=(0,Z.lazy)(()=>c(()=>import(`./PluginsPage-CwFfFBzW.js`),__vite__mapDeps([97,1,2,6,34,3,52,55,60,61,62,36,43,44,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,37,64,65,66,67,68,42,69]))),bG=(0,Z.lazy)(()=>c(()=>import(`./DesktopAnalyticsPage-DPMcS88n.js`),__vite__mapDeps([98,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,43,36,66,67,91,3,92]))),xG=(0,Z.lazy)(()=>c(()=>import(`./DocsPage-Dd9yilUg.js`),__vite__mapDeps([99,1,2,40,5,6,47,53,55,67,66,70,74,100,101]))),SG=(0,Z.lazy)(()=>c(()=>import(`./DocsDialog-BC7574Zi.js`),__vite__mapDeps([102,1,2,6,47,53,55,67,66,68,3,42,65,70,74,100,101]))),CG=(0,Z.lazy)(()=>c(()=>import(`./LoopsPage-nZfgiaK8.js`),__vite__mapDeps([103,1,2,40,5,6,34,3,52,56,57,58,41,61,104,44,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,36,43,37,64,65,66,67,68,42,77,45,54]))),wG=(0,Z.lazy)(()=>c(()=>import(`./LoopBuilderPage-BPeqz6cG.js`),__vite__mapDeps([105,1,2,3,40,5,6,34,50,45,54,57,58,59,61,62,104,64,65,66,67,68,42,92,106]))),TG=28;function EG({surface:e,onClose:t}){let{t:n}=I(`nav`),r=n(e===`loops`?`arcSidebar.loops`:`arcSidebar.plugins`);return(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-border bg-popover/95 px-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`grid h-7 w-7 shrink-0 place-items-center rounded-md border border-accent-primary/20 bg-accent-primary/10 text-accent-primary`,children:(0,Q.jsx)(e===`loops`?vi:Hr,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`truncate text-xs font-medium text-foreground`,children:r})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-popover`,"aria-label":n(`common:actions.close`),children:(0,Q.jsx)(yt,{className:`h-4 w-4`})})})]})}var DG=new Set([`/settings`,`/loops`,`/plugins`]);function OG(e){return DG.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var kG=`specrails-desktop:routeMemory`;try{localStorage.removeItem(kG)}catch{}function AG(e){let t=u(),n=p(),r=(0,Z.useRef)(new Map),i=(0,Z.useRef)(null),a=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{bi((e,t)=>{r.current.set(e,t)})},[]),(0,Z.useEffect)(()=>{a.current||(a.current=!0,t.pathname!==`/`&&n(`/`,{replace:!0}))},[]),(0,Z.useEffect)(()=>{if(i.current&&i.current!==e&&!OG(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!OG(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,Z.useEffect)(()=>{e&&t.pathname!==`/`&&!OG(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function jG(){let{t:e}=I(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setupProjectIds:a,completeSetupWizard:o,setActiveProjectId:s}=At(),{cycleLeftMode:c,cycleRightMode:l}=fE(),d=p(),h=u(),_=sW(),v=UV(),{startNewConversation:y}=v,{uiMode:b}=iw();lG();let[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),N=(0,Z.useCallback)(()=>M(!1),[]),[P,F]=(0,Z.useState)(()=>!NT());AG(n),bU();let{cheatsheetOpen:L,setCheatsheetOpen:R,openCheatsheet:z}=CC(),B=[`/`,`/jobs`,`/analytics`,...nt?[`/agents`]:[],...it?[`/code`]:[],`/integrations`,`/settings`];SC({onOpenCheatsheet:z,onToggleLeftSidebar:c,onToggleRightSidebar:l,onSwitchProject:e=>{let n=t[e-1];n&&s(n.id)},onSwitchProjectPage:e=>{let t=B[e-1];t&&d(t)},onToggleTerminalPanel:Ee?()=>{n&&(_.togglePanel(n),_.getState(n).visibility===`hidden`?queueMicrotask(()=>_.focusActive(n)):_.focusActive(n))}:void 0,onToggleAgentChat:at&&b!==`agent`?()=>v.toggle():void 0}),pC({setActiveProjectId:s,projectsById:(0,Z.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])});let V=t.find(e=>e.id===n),H=n!==null&&a.has(n),U=h.pathname.startsWith(`/loops`),W=h.pathname.startsWith(`/plugins`),ee=h.pathname.startsWith(`/docs`)||b!==`agent`&&(U||W);(0,Z.useLayoutEffect)(()=>{let e=dG({uiMode:b,pathname:h.pathname,loopsOpen:D,pluginsOpen:k});if(e){if(e.kind===`modalize`){e.surface===`loops`?(A(!1),O(!0)):(O(!1),A(!0)),y(n),h.pathname!==e.backgroundPath&&d(e.backgroundPath,{replace:!0});return}O(!1),A(!1),h.pathname!==e.path&&d(e.path,{replace:!0})}},[n,h.pathname,D,d,k,y,b]);let{connectionStatus:te}=vW(),G=cW(n),K=b===`agent`?0:TG,ne=(0,Z.useRef)(null),[re,ie]=(0,Z.useState)(typeof window<`u`?window.innerHeight:820);(0,Z.useLayoutEffect)(()=>{if(!Ee)return;let e=ne.current;if(!e)return;let t=()=>ie(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,Z.useEffect)(()=>{!Ee||!n||_.ensureProject(n)},[n,_]);let ae=Ee&&b===`kanban`&&G.visibility===`hidden`?(0,Q.jsx)(PW,{isOpen:!1,onClick:()=>n&&_.setVisibility(n,`restored`)}):null;return r?(0,Q.jsxs)(`div`,{className:`flex h-full`,children:[(0,Q.jsx)(`div`,{className:`w-11 border-r border-border bg-card/50 animate-pulse flex-shrink-0`}),(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})})]}):(0,Q.jsxs)(`div`,{className:`flex h-full overflow-hidden font-sans`,children:[(0,Q.jsx)(eH,{onAddProject:()=>S(!0),onOpenLoops:()=>{b===`agent`?O(!0):d(`/loops`)},onOpenPlugins:()=>{b===`agent`?A(!0):d(`/plugins`)},onOpenAnalytics:()=>E(!0),onOpenDocs:()=>M(!0),onOpenSettings:()=>w(!0)}),(0,Q.jsxs)(`div`,{ref:ne,className:`flex flex-col flex-1 overflow-hidden`,children:[i&&(0,Q.jsx)(`div`,{className:`h-0.5 w-full bg-accent-primary/70 animate-pulse shrink-0`,"data-testid":`project-switching-bar`}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:H&&V?(0,Q.jsx)(AT,{project:V,onComplete:()=>o(V.id),onSkip:()=>o(V.id)},V.id):b===`agent`&&!ee?(0,Q.jsx)(cG,{}):(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Q.jsxs)(g,{children:[(0,Q.jsx)(m,{path:`/docs`,element:(0,Q.jsx)(xG,{})}),(0,Q.jsx)(m,{path:`/docs/:category/:slug`,element:(0,Q.jsx)(xG,{})}),we&&(0,Q.jsx)(m,{path:`/loops`,element:(0,Q.jsx)(CG,{})}),we&&(0,Q.jsx)(m,{path:`/loops/:id/edit`,element:(0,Q.jsx)(wG,{})}),(0,Q.jsx)(m,{path:`/plugins`,element:(0,Q.jsx)(yG,{})}),t.length===0?(0,Q.jsx)(m,{path:`*`,element:(0,Q.jsx)(Bw,{onAddProject:()=>S(!0)})}):V?(0,Q.jsxs)(m,{element:(0,Q.jsx)(zw,{projectName:V.name,children:(0,Q.jsx)(Lw,{project:V})},V.id),children:[(0,Q.jsx)(m,{path:`/`,element:(0,Q.jsx)($b,{})}),(0,Q.jsx)(m,{path:`/jobs`,element:(0,Q.jsx)(pG,{})}),(0,Q.jsx)(m,{path:`/jobs/:id`,element:(0,Q.jsx)(fG,{})}),(0,Q.jsx)(m,{path:`/analytics`,element:(0,Q.jsx)(mG,{})}),(0,Q.jsx)(m,{path:`/activity`,element:(0,Q.jsx)(hG,{})}),(0,Q.jsx)(m,{path:`/agents`,element:(0,Q.jsx)(gG,{})}),(0,Q.jsx)(m,{path:`/code`,element:it?(0,Q.jsx)(_G,{}):(0,Q.jsx)(f,{to:`/`,replace:!0})}),(0,Q.jsx)(m,{path:`/integrations`,element:(0,Q.jsx)(vG,{})}),(0,Q.jsx)(m,{path:`/settings`,element:(0,Q.jsx)(Tx,{})}),(0,Q.jsx)(m,{path:`*`,element:(0,Q.jsx)(f,{to:`/`,replace:!0})})]}):(0,Q.jsx)(m,{path:`*`,element:(0,Q.jsx)(Bw,{onAddProject:()=>S(!0)})})]})})}),Ee&&n&&V&&(0,Q.jsx)(tG,{projectId:n,provider:V.provider,providers:kt(V),state:G,viewportHeight:re,statusBarHeight:K}),b!==`agent`&&(0,Q.jsx)(nG,{connectionStatus:te,rightSlot:ae})]}),b===`agent`?!H&&!ee&&(0,Q.jsx)(iG,{}):V&&!H&&!ee&&(0,Q.jsx)(oH,{}),(0,Q.jsx)(vH,{open:x,onClose:()=>S(!1),onOpenBuilder:()=>v.builderMode.enter()}),(0,Q.jsx)(_C,{open:C,onClose:()=>w(!1),onOpenOnboarding:()=>{w(!1),F(!0)}}),(0,Q.jsx)(nn,{open:T,onOpenChange:E,children:(0,Q.jsx)(Zt,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Q.jsx)(bG,{})})})})}),(0,Q.jsx)(nn,{open:D,onOpenChange:O,children:(0,Q.jsxs)(Zt,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,Q.jsx)(Qt,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,Q.jsx)(en,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,Q.jsx)(EG,{surface:`loops`,onClose:()=>O(!1)}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Q.jsx)(CG,{})})})]})}),(0,Q.jsx)(nn,{open:k,onOpenChange:A,children:(0,Q.jsxs)(Zt,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,Q.jsx)(Qt,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,Q.jsx)(en,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,Q.jsx)(EG,{surface:`plugins`,onClose:()=>A(!1)}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Q.jsx)(yG,{})})})]})}),(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(SG,{open:j,onClose:N})}),(0,Q.jsx)(mU,{onOpenSettings:()=>w(!0),onOpenAnalytics:()=>E(!0),onOpenDocs:()=>M(!0)}),(0,Q.jsx)(OC,{open:L,onOpenChange:R}),(0,Q.jsx)(JT,{open:P,onClose:()=>F(!1)})]})}function MG({children:e}){let{activeProjectId:t}=At();return(0,Q.jsx)(aW,{activeProjectId:t,children:e})}function NG({children:e}){let{activeProjectId:t}=At();return(0,Q.jsx)(Zv,{activeProjectId:t,children:e})}function PG({children:e}){let{activeProjectId:t}=At();return(0,Q.jsx)(iy,{activeProjectId:t,children:e})}function FG(){return(0,Q.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function IG(){let{theme:e}=Db(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,Q.jsx)(z,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,Q.jsx)(FG,{})},style:{"--accent":t,"--toast-success-border":`color-mix(in srgb, ${n} 38%, transparent)`,"--toast-error-border":`color-mix(in srgb, ${r} 38%, transparent)`,"--toast-warning-border":`color-mix(in srgb, ${i} 38%, transparent)`,"--toast-info-border":`color-mix(in srgb, ${a} 38%, transparent)`},toastOptions:{unstyled:!0,classNames:{toast:`glass-card border border-border/30 text-foreground text-xs p-3 rounded-lg flex items-start gap-2 w-[356px] max-w-[356px] overflow-hidden shadow-lg`,content:`flex-1 min-w-0 flex flex-col gap-0.5`,icon:`shrink-0 mt-[2px] flex items-center justify-center`,title:`font-medium text-sm`,description:`text-muted-foreground mt-0.5`,actionButton:`text-[11px] px-2.5 py-1 rounded-md bg-accent-primary text-white hover:bg-accent-primary/90 whitespace-nowrap shrink-0 self-start`,cancelButton:`text-[11px] px-2.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/50 whitespace-nowrap shrink-0 self-start`,closeButton:`text-muted-foreground hover:text-foreground rounded-md p-0.5`,success:`border-l-4 border-l-[var(--toast-success-border)]`,error:`border-l-4 border-l-[var(--toast-error-border)]`,warning:`border-l-4 border-l-[var(--toast-warning-border)]`,info:`border-l-4 border-l-[var(--toast-info-border)]`,loading:``}}})}function LG(){return yS(),wU(),(0,Q.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:(0,Q.jsx)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:(0,Q.jsx)(Dt,{url:ae,children:(0,Q.jsx)(Eb,{children:(0,Q.jsxs)(Mx,{children:[(0,Q.jsx)(Iw,{}),(0,Q.jsx)(jt,{children:(0,Q.jsxs)(nw,{children:[(0,Q.jsx)(lw,{}),(0,Q.jsx)(eh,{children:(0,Q.jsx)(vU,{children:(0,Q.jsx)(Ye,{children:(0,Q.jsx)(dE,{children:(0,Q.jsx)(MG,{children:(0,Q.jsx)(NG,{children:(0,Q.jsx)(PG,{children:(0,Q.jsx)(ve,{children:(0,Q.jsx)(VV,{children:(0,Q.jsx)(UR,{children:(0,Q.jsx)(LR,{children:(0,Q.jsx)(Le,{children:(0,Q.jsxs)(Qe,{children:[(0,Q.jsx)(jG,{}),(0,Q.jsx)(IG,{})]})})})})})})})})})})})})})]})})]})})})})})}async function RG(){await wt(),St(),await j(),(0,_n.createRoot)(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(_,{children:(0,Q.jsx)(LG,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}RG();export{di as $,og as A,Nn as At,rc as B,Jv as C,er as Ct,Y_ as D,Ln as Dt,nv as E,Un as Et,_m as F,vn as Ft,go as G,Vs as H,ym as I,ua as J,ya as K,sc as L,hh as M,Dn as Mt,vm as N,Cn as Nt,$_ as O,In as Ot,bm as P,bn as Pt,fi as Q,Gs as R,Hv as S,rr as St,kv as T,Xn as Tt,ps as U,$s as V,uo as W,vi as X,Ji as Y,gi as Z,xx as _,_r as _t,rR as a,ti as at,kb as b,ur as bt,FL as c,Jr as ct,qx as d,zr as dt,ci as et,$ as f,kr as ft,gx as g,Cr as gt,Cx as h,Er as ht,zR as i,ni as it,yh as j,kn as jt,D_ as k,Pn as kt,SE as l,qr as lt,_x as m,Dr as mt,qz as n,ai as nt,iR as o,ei as ot,wx as p,Or as pt,la as q,Wz as r,ii as rt,vR as s,Xr as st,vW as t,si as tt,fT as u,Hr as ut,fx as v,hr as vt,Av as w,$n as wt,Yy as x,ir as xt,ox as y,mr as yt,Ps as z};
|
|
76
|
+
`);if(ze())try{let e=await(await c(()=>import(`./dist-js-jwoXo0YD.js`),[])).save({defaultPath:t});if(!e)return;try{let t=await $e(`@tauri-apps/plugin-fs`);if(t?.writeTextFile){await t.writeTextFile(e,i);return}}catch{}try{await(await $e(`@tauri-apps/api/fs`))?.writeTextFile?.({path:e,contents:i})}catch{}return}catch{}try{let e=new Blob([i],{type:`text/plain;charset=utf-8`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{}}function KW({sessionId:e}){let[t,n]=(0,Z.useState)(()=>VU(e));return(0,Z.useEffect)(()=>BU(e,n),[e]),t.promptRows.length===0?null:(0,Q.jsx)(`div`,{"aria-hidden":`true`,"data-prompt-gutter":!0,className:`absolute left-0 top-0 bottom-0 w-1 pointer-events-none z-10`,children:(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 bottom-0 w-full`,style:{backgroundImage:`linear-gradient(to bottom, rgba(189,147,249,0.2), rgba(189,147,249,0.05))`}})})}function qW({sessionId:e}){let{t}=I(`terminal`),[n,r]=(0,Z.useState)(VU(e).openPreExec?.startedAt??null),[i,a]=(0,Z.useState)(Date.now());if((0,Z.useEffect)(()=>BU(e,e=>r(e.openPreExec?.startedAt??null)),[e]),(0,Z.useEffect)(()=>{if(n==null)return;let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[n]),n==null)return null;let o=i-n;return o<500?null:(0,Q.jsx)(`div`,{className:`absolute top-2 left-2 px-2 py-0.5 rounded text-xs font-mono bg-[#44475a] text-[#f8f8f2] z-10 pointer-events-none`,children:JW(o,t)})}function JW(e,t){return e<6e4?t(`terminal:duration.seconds`,{seconds:(e/1e3).toFixed(1)}):t(`terminal:duration.minutesSeconds`,{minutes:Math.floor(e/6e4),seconds:Math.floor(e%6e4/1e3)})}function YW({activeId:e}){let t=(0,Z.useRef)(null),n=sW(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=ze();(0,Z.useEffect)(()=>{if(e)return n.subscribeOpenSearch(e,()=>i(!0))},[e,n]),(0,Z.useEffect)(()=>{i(!1),o(null)},[e]);let c=e?n.getSearchAddon(e):null,l=e?n.getTerminalInstance(e):null,u=e?n.getCwd(e):null,[d,f]=(0,Z.useState)(!1),p=(0,Z.useCallback)(t=>{if(!t)return!1;if(e&&n.writeToSession(e,t))return!0;if(!l)return!1;try{return l.paste(t),!0}catch{return!1}},[e,n,l]),m=(0,Z.useCallback)(e=>{if(!l||!e||e.length===0)return!1;let t=Array.from(e).map(e=>XW(e)).filter(e=>!!e);if(t.length===0)return!1;let n=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);return p(DW(t,n))},[l,p]),h=(0,Z.useCallback)(e=>{if(e.preventDefault(),!e.shiftKey&&l){let e=l.modes?.mouseTrackingMode;if(e&&e!==`none`)return}o({x:e.clientX,y:e.clientY})},[l]),g=(0,Z.useCallback)(e=>{if(!l)return;if(e.clipboardData.files&&e.clipboardData.files.length>0){let t=Array.from(e.clipboardData.files).map(e=>XW(e)).filter(e=>!!e);if(t.length>0){e.preventDefault(),e.stopPropagation();let n=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);p(DW(t,n));return}}let t=e.clipboardData.getData(`text/plain`);t&&(e.preventDefault(),e.stopPropagation(),p(t))},[l,p]),_=(0,Z.useCallback)(e=>{if(!l)return;let t=l.getSelection();t&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault(),e.stopPropagation())},[l]),v=(0,Z.useCallback)(e=>{if(l&&(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?e.metaKey:e.ctrlKey)&&(e.key===`c`||e.key===`C`)){let t=l.getSelection();if(!t)return;e.preventDefault(),e.stopPropagation(),QU(t)}},[l]);return(0,Z.useEffect)(()=>{let r=t.current;if(!r||!e)return;let i=n.getContainer(e);if(i)return r.appendChild(i),n.notifyAdopted(e),()=>{let e=document.getElementById(`specrails-terminal-host`);e&&i.parentElement===r&&e.appendChild(i)}},[e,n]),(0,Z.useEffect)(()=>{let r=t.current;if(!r||!e)return;let i=[],a=r.parentElement;for(;a&&a!==document.body;)(a.tagName.toLowerCase()===`aside`||a.matches(`[data-sidebar]`))&&i.push(a),a=a.parentElement;if(i.length===0)return;let o=t=>{let r=t;r.propertyName!==`width`&&r.propertyName!==`height`||n.refitActive(e)};return i.forEach(e=>e.addEventListener(`transitionend`,o)),()=>{i.forEach(e=>e.removeEventListener(`transitionend`,o))}},[e,n]),(0,Q.jsxs)(`div`,{ref:t,className:`flex-1 min-w-0 bg-background px-2 py-1 relative ${d?`outline outline-2 outline-accent-primary outline-offset-[-2px]`:``}`,role:`presentation`,"data-terminal-viewport":!0,onContextMenu:h,onPasteCapture:g,onCopyCapture:_,onKeyDownCapture:v,tabIndex:-1,onDragEnter:e=>{ZW(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),f(!0))},onDragOver:e=>{ZW(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),f(!0))},onDragLeave:()=>f(!1),onDrop:e=>{ZW(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),m(e.dataTransfer.files)),f(!1)},children:[e&&(0,Q.jsx)(KW,{sessionId:e}),e&&(0,Q.jsx)(qW,{sessionId:e}),r&&c&&(0,Q.jsx)(zW,{search:c,onClose:()=>i(!1)}),a&&l&&(0,Q.jsx)(VW,{x:a.x,y:a.y,term:l,cwd:u,hasReveal:s,onClose:()=>o(null),onOpenSearch:()=>i(!0),onReveal:e=>{tt(e)},onSaveScrollback:()=>{l&&GW(l)}})]})}function XW(e){let t=e.path;return typeof t==`string`&&t.length>0?t:null}function ZW(e){return e?Array.from(e.types).includes(`Files`):!1}function QW({height:e,maxHeight:t,onHeightCommit:n,onHeightPreview:r,minHeight:i=120}){let{t:a}=I(`terminal`),o=(0,Z.useRef)(!1),s=(0,Z.useRef)(0),c=(0,Z.useRef)(e),l=(0,Z.useRef)(!1),u=(0,Z.useRef)(e),d=(0,Z.useCallback)(e=>e<i?i:e>t?t:Math.round(e),[i,t]);(0,Z.useEffect)(()=>{function e(e){if(!o.current)return;let t=s.current-e.clientY,n=d(c.current+t);u.current=n,l.current||(l.current=!0,requestAnimationFrame(()=>{l.current=!1,r?.(u.current)}))}function t(){o.current&&(o.current=!1,document.body.style.userSelect=``,document.body.style.cursor=``,n(u.current))}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[d,n,r]);function f(t){o.current=!0,s.current=t.clientY,c.current=e,u.current=e,document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`;let n=t.target;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(t.pointerId)}catch{}}return(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`dragHandle.resize`),onPointerDown:f,className:X(`absolute top-0 left-0 right-0 h-1`,`cursor-row-resize`,`bg-transparent hover:bg-accent-primary/40`,`transition-colors duration-120`,`z-10`)})}function $W({onCreate:e}){let{t}=I(`terminal`);return(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-center px-6 bg-background-deep`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,Q.jsx)(fi,{className:`h-8 w-8 opacity-50`}),(0,Q.jsx)(`p`,{className:`text-xs`,children:t(`emptyState.noTerminals`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs bg-border/30 hover:bg-border/50 hover:text-foreground transition-colors`,children:[(0,Q.jsx)(pt,{className:`h-3 w-3`}),` `,t(`emptyState.newTerminal`)]})]})})}var eG=300;function tG({projectId:e,provider:t=`claude`,providers:n,state:r,viewportHeight:i,statusBarHeight:a}){let o=sW(),{t:s}=I(`terminal`),c=p(),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(null),[f,m]=(0,Z.useState)(sx),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=(0,Z.useRef)(a===0&&r.visibility!==`hidden`),[b,x]=(0,Z.useState)(()=>r.visibility===`hidden`?`hidden`:y.current?`opening`:`open`),S=(0,Z.useRef)(!1),C=n&&n.length>0?n:[t],w=C.length>1,T=(0,Z.useCallback)(async(t=()=>!1)=>{try{let n=await fetch(`/api/projects/${e}/terminal-settings`);if(!n.ok)return;let r=await n.json();!t()&&r?.resolved&&m(r.resolved)}catch{}},[e]);(0,Z.useEffect)(()=>{let e=!1;return T(()=>e),()=>{e=!0}},[T]),(0,Z.useEffect)(()=>{let t=t=>{let n=t.detail;n?.mode===`project`&&n.projectId!==e||T()};return window.addEventListener(lx,t),()=>window.removeEventListener(lx,t)},[T,e]);let E=Math.max(120,i-a-40),D=Math.min(Math.max(r.userHeight||320,120),E),O=r.visibility===`maximized`?Math.max(120,i-a):u??D,k=b===`open`,A=k?O:0,j=a===0,M=r.sessions.length<10,N=r.activeId!==null;(0,Z.useEffect)(()=>{let e=null,t=null,n=null,i=()=>{x(`opening`),t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>x(`open`))})};return S.current?(r.visibility===`hidden`?(x(`closing`),e=setTimeout(()=>x(`hidden`),eG)):i(),()=>{e&&clearTimeout(e),t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)}):(S.current=!0,y.current&&i(),()=>{t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)})},[r.visibility]),(0,Z.useEffect)(()=>{let e=!1,t=null;return OW(()=>{let e=l.current,t=r.activeId;return!e||!t||r.visibility===`hidden`?null:{viewportEl:e,writeText:e=>{if(o.writeToSession(t,e))return!0;let n=o.getTerminalInstance(t);try{return n?.paste(e),!!n}catch{return!1}}}}).then(n=>{e?n.dispose():t=n}),()=>{e=!0,t?.dispose()}},[r.activeId,r.visibility,o]);let P=(0,Z.useCallback)(()=>{M&&o.create(e)},[M,e,o]),F=(0,Z.useCallback)(t=>{if(!M)return;let n=t||`claude`,i=RegExp(`^${n} \\(\\d+\\)$`),a=r.sessions.filter(e=>e.name===n||i.test(e.name)),s=a.length===0?n:`${n} (${a.length+1})`;o.createAndType(e,`${n}\n`,{name:s})},[M,e,r.sessions,o]),L=(0,Z.useCallback)(e=>{if(M){if(w&&e){v(e);return}F(t)}},[M,w,t,F]),R=(0,Z.useCallback)(()=>{qe(f.browserShortcutUrl)},[f.browserShortcutUrl]),z=(0,Z.useCallback)(()=>{r.activeId&&f.quickScript&&o.writeToSession(r.activeId,f.quickScript)},[f.quickScript,r.activeId,o]),B=(0,Z.useCallback)(e=>{g({...e,kind:`browser`})},[]),V=(0,Z.useCallback)(e=>{g({...e,kind:`script`})},[]),H=(0,Z.useCallback)(e=>{c(`/settings${e===`browser`?`#terminal-browser-shortcut-url`:`#terminal-quick-script`}`)},[c]),U=(0,Z.useCallback)(()=>{r.activeId&&o.kill(e,r.activeId)},[e,r.activeId,o]),W=(0,Z.useCallback)(()=>{o.setVisibility(e,r.visibility===`maximized`?`restored`:`maximized`)},[e,r.visibility,o]),ee=(0,Z.useCallback)(()=>{o.setVisibility(e,`hidden`)},[e,o]);return(0,Z.useEffect)(()=>{d(null)},[r.visibility]),b===`hidden`?null:(0,Q.jsxs)(`div`,{ref:l,className:X(`relative flex flex-col shrink-0 overflow-hidden origin-bottom transform-gpu bg-background/95`,`border-t border-border/40`,`transition-[height,opacity,transform,clip-path] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`),style:{height:A,opacity:+!!k,transform:k?`translateY(0) scaleY(1)`:`translateY(${j?14:8}px) scaleY(${j?.96:.985})`,clipPath:k?`inset(0 0 0 0)`:`inset(100% 0 0 0)`},"data-testid":`terminal-bottom-panel`,children:[(0,Q.jsx)(QW,{height:D,maxHeight:E,onHeightPreview:e=>d(e),onHeightCommit:t=>{d(null),o.setUserHeight(e,t),r.visibility===`maximized`&&o.setVisibility(e,`restored`)}}),(0,Q.jsx)(FW,{visibility:r.visibility,canCreate:M,hasActive:N,provider:t,providers:C,onCreate:P,onOpenCli:L,onOpenBrowser:R,onPasteScript:z,pasteScriptDisabled:!N||!f.quickScript,onConfigureBrowser:B,onConfigureScript:V,onKillActive:U,onToggleMaximize:W,onCollapse:ee}),h&&(0,Q.jsx)(MW,{x:h.x,y:h.y,label:h.kind===`browser`?s(`shortcutMenu.configureBrowserUrl`):s(`shortcutMenu.editQuickScript`),onSelect:()=>H(h.kind),onClose:()=>g(null)}),_&&(0,Q.jsx)(NW,{x:_.x,y:_.y,providers:C,onSelect:e=>F(e),onClose:()=>v(null)}),(0,Q.jsx)(`div`,{className:`flex-1 flex min-h-0`,children:r.sessions.length===0?(0,Q.jsx)($W,{onCreate:P}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(YW,{activeId:r.activeId}),(0,Q.jsx)(LW,{sessions:r.sessions,activeId:r.activeId,onActivate:t=>o.setActive(e,t),onRename:(t,n)=>void o.rename(e,t,n),onKill:t=>void o.kill(e,t)})]})})]})}function nG({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=I(`nav`),{t:i}=I(`analytics`),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(`connecting`),u=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>{let t=l.current;if(e===`connected`&&!u.current&&t!==`connected`){R.success(r(`statusBar.connectionRestored`)),c(!0);let e=setTimeout(()=>c(!1),2e3);return()=>clearTimeout(e)}u.current&&e===`connected`&&(u.current=!1),l.current=e},[e]),(0,Z.useEffect)(()=>{u.current&&=!1},[]),(0,Z.useEffect)(()=>{if(n)return;async function e(){try{let e=await fetch(`${Ot()}/stats`);if(e.ok){let t=await e.json();o(t)}}catch{}}e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[e,n]);let d=!n||e!==`connected`||s;return(0,Q.jsxs)(`footer`,{className:`h-7 flex items-center justify-between px-4 border-t border-border/30 bg-background/80 backdrop-blur-sm text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`div`,{className:X(`flex items-center gap-1.5 transition-opacity duration-300`,!d&&`opacity-0`),"aria-hidden":!d||void 0,children:[(0,Q.jsx)(`span`,{className:X(`w-1.5 h-1.5 rounded-full transition-colors`,e===`connected`&&!s&&`bg-accent-success`,e===`connected`&&s&&`bg-accent-info animate-pulse`,e===`connecting`&&`bg-accent-warning animate-[pulse_0.75s_ease-in-out_infinite]`,e===`disconnected`&&`bg-destructive`)}),(0,Q.jsxs)(`span`,{className:X(`transition-colors`,e===`connected`&&!s&&`text-accent-success`,e===`connected`&&s&&`text-accent-info`,e===`connecting`&&`text-accent-warning`,e===`disconnected`&&`text-destructive`),children:[e===`connected`&&!s&&r(`statusBar.connected`),e===`connected`&&s&&r(`statusBar.syncing`),e===`connecting`&&r(`statusBar.reconnecting`),e===`disconnected`&&r(`statusBar.disconnected`)]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!n&&a&&a.totalCostUsd>0&&(()=>{let e=a.includesEstimated??((a.estimatedCostUsd??0)>0||(a.estimatedCostToday??0)>0);return(0,Q.jsxs)(`span`,{"data-estimated":e?`true`:void 0,title:e?i(`desktop.statusBarEstimatedTooltip`):void 0,children:[e?`~`:``,`$`,a.totalCostUsd.toFixed(2)]})})(),t]})]})}var rG={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function iG(){let{t:e}=I(`agent`),{t}=I(`nav`),{t:n}=I(`builder`),{rightMode:r,cycleRightMode:i}=fE(),{activeProjectId:a}=At(),o=sW(),s=zR(),{active:c,builderMode:l}=UV(),[u,d]=(0,Z.useState)(!1),f=l.active||r===`pinned-open`||r===`unpinned`&&u,p=ZT(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:f}),m=r!==`unpinned`,h=t(rG[r]),g=!a,_=[{key:`jobs`,icon:Dn,label:e(`workspace.jobs`),onClick:()=>s.toggleJobsPane(),disabled:g,disabledTitle:e(`workspace.requiresProject`)},...ie()?[{key:`browser`,icon:te,label:e(`workspace.browser`),onClick:()=>s.openBrowser(),disabled:g||!c,disabledTitle:e(g?`workspace.requiresProject`:`workspace.requiresConversation`)}]:[],...Ee?[{key:`terminal`,icon:si,label:e(`workspace.terminal`),onClick:()=>a&&o.togglePanel(a),disabled:g,disabledTitle:e(`workspace.requiresProject`)}]:[],...it?[{key:`files`,icon:Zn,label:e(`workspace.files`),onClick:()=>s.toggleCodePane(),disabled:g,disabledTitle:e(`workspace.requiresProject`)}]:[]];return(0,Q.jsxs)(`div`,{ref:p.panelRef,className:X(`relative flex flex-col h-full border-l border-border bg-background flex-shrink-0 overflow-hidden`,`transition-[width] duration-200 ease-in-out`),onMouseEnter:()=>{r===`unpinned`&&d(!0)},onMouseLeave:()=>{r===`unpinned`&&!p.dragging&&d(!1)},children:[f&&(0,Q.jsx)(QT,{side:`right`,dragging:p.dragging,width:p.width,min:180,max:460,label:t(`sidebarPin.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:p.onGripPointerDown,onKeyDown:p.onGripKeyDown}),(0,Q.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,f?`px-3 justify-between`:`justify-center`),children:[f&&(0,Q.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`workspace.title`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:i,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,m?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":h,title:t(`sidebarPin.withShortcut`,{label:h,shortcut:`⌘B`}),children:(0,Q.jsx)(Ir,{className:`w-4 h-4`})})]}),l.active?(0,Q.jsx)(MF,{mode:`wait`,initial:!1,children:(0,Q.jsxs)(ML.div,{initial:{opacity:0,x:24},animate:{opacity:1,x:0},exit:{opacity:0,x:24},transition:{duration:.22,ease:`easeOut`},className:`flex min-h-0 flex-1 flex-col`,"data-testid":`workspace-blueprint-panel`,children:[(0,Q.jsx)(mV,{blueprint:l.session.blueprint}),l.session.phase===`chat`&&(0,Q.jsxs)(`div`,{className:`border-t border-border/40 p-3`,children:[(0,Q.jsxs)(Y,{className:`w-full`,size:`sm`,disabled:!l.session.canProposeCommit,onClick:l.session.goToCommit,"data-testid":`builder-create-specs`,children:[(0,Q.jsx)(Yr,{className:`mr-1.5 h-3.5 w-3.5`}),n(`shell.createSpecs`)]}),!l.session.canProposeCommit&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,children:l.session.specQualityDetail??n(`shell.createSpecsHint`)})]})]},`builder-blueprint`)}):(0,Q.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,Q.jsx)(iH,{expanded:f}),_.map(({key:e,icon:t,label:n,onClick:r,disabled:i,disabledTitle:a})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,f?`px-2`:`px-0 justify-center`,i?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:i?a:f?void 0:n,children:[(0,Q.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),f&&(0,Q.jsx)(`span`,{className:`text-xs truncate`,children:n})]},e))]})]})}var aG=(0,Z.lazy)(()=>c(()=>import(`./AgentModeCodePane-BAYyFRmY.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([82,1,2,5,6,42]))),oG=(0,Z.lazy)(()=>c(()=>import(`./AgentModeJobsPane-CTIHMUKN.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([83,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,55,42,43,36,37,44,34,3,67,66,71,72,75,0,35,38,39,40,41,45,46,47,48,49,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,68,69,70,73,74,84]))),sG=(0,Z.lazy)(()=>c(()=>import(`./AgentBrowserCapture-DqyHbzk7.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([85,1,2,6,34,3])));function cG(){let{t:e}=I(`agent`),{active:t,refreshConversations:n,builderMode:r}=UV(),{codePaneOpen:i,jobsPaneOpen:a,browserOpen:o}=zR(),{activeProjectId:s}=At(),c=kb(),l=c.id===`galaxy`,u=c.id===`code-rain`?e(`emptyTitleCodeRain`):e(`emptyTitle`);(0,Z.useEffect)(()=>{n()},[n]);let d=i&&!!s,f=a&&!!s;return(0,Q.jsx)(qF,{reducedMotion:`user`,children:(0,Q.jsxs)(`div`,{"data-agent-mode-surface":!0,className:`relative z-0 flex h-full w-full overflow-hidden bg-background`,children:[l&&(0,Q.jsx)(Lb,{}),(0,Q.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsx)(ML.div,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 z-0`,animate:{opacity:+(t===null)},transition:{duration:.5,ease:`easeOut`},style:{background:`radial-gradient(60% 55% at 50% 45%, color-mix(in srgb, var(--color-accent-primary) 13%, transparent), transparent 70%)`}}),r.active?(0,Q.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Q.jsx)(lV,{variant:`inline`})}):t===null?(0,Q.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,Q.jsxs)(ML.div,{layoutId:`agent-composer-dock`,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.28,ease:[.34,1.56,.64,1],layout:{type:`spring`,stiffness:350,damping:34}},className:`w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-4 shadow-2xl backdrop-blur-xl`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,Q.jsx)(wn,{className:`h-4 w-4 text-accent-primary`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:u})]}),(0,Q.jsx)(Rz,{autoFocus:!0})]})}):(0,Q.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Q.jsx)(bB,{variant:`inline`})})]}),f&&(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,Q.jsx)(oG,{projectId:s})}),d&&(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,Q.jsx)(aG,{projectId:s,conversationId:t?.id??`__home__`})}),o&&s&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(sG,{projectId:s,conversationId:t?.id??null})})]})})}function lG(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=Xe(),{tickets:i}=Ge(),a=u(),o=p(),s=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(s.current||i.length===0||new URLSearchParams(a.search).get(`compare`)&&typeof window<`u`&&window.innerWidth<900)return;s.current=!0;let e=new URLSearchParams(a.search),c=e.get(`compare`),l=e.get(`compareSide`);if(!c)return;let u=Number.parseInt(c,10),d=l===`right`?`right`:`left`;if(!i.some(e=>e.id===u)){let e=new URLSearchParams(a.search);e.delete(`compare`),e.delete(`compareSide`);let t=e.toString();o({pathname:a.pathname,search:t?`?${t}`:``},{replace:!0});return}let f=e.get(`compareOrigin`);if(f){let e=Number.parseInt(f,10);if(i.some(t=>t.id===e)){t(e),n(d),r(u,d===`left`?`right`:`left`);return}}t(u)},[i,a.search,a.pathname,o,t,n,r]),(0,Z.useEffect)(()=>{if(!s.current)return;let t=new URLSearchParams(a.search),n=t.has(`compare`);if(e.originSide===null){if(n){t.delete(`compare`),t.delete(`compareSide`),t.delete(`compareOrigin`);let e=t.toString();o({pathname:a.pathname,search:e?`?${e}`:``},{replace:!0})}return}let r=e.originSide===`left`?e.leftId:e.rightId,i=e.originSide===`left`?e.rightId:e.leftId;if(r==null||e.originSide==null)return;let c=new URLSearchParams(a.search);c.set(`compareSide`,e.originSide),c.set(`compareOrigin`,String(r)),i==null?c.delete(`compare`):c.set(`compare`,String(i));let l=c.toString();l!==(a.search.startsWith(`?`)?a.search.slice(1):a.search)&&o({pathname:a.pathname,search:l?`?${l}`:``},{replace:!0})},[e,a.search,a.pathname,o])}function uG(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:null}function dG({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r}){if(e===`agent`){let e=uG(t);return e?{kind:`modalize`,surface:e,backgroundPath:`/`}:null}return n?{kind:`route`,surface:`loops`,path:`/loops`}:r?{kind:`route`,surface:`plugins`,path:`/plugins`}:null}var fG=(0,Z.lazy)(()=>c(()=>import(`./JobDetailPage-CU4FEnUC.js`),__vite__mapDeps([86,1,2,40,5,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,3,39,41,42,43,36,44,37,47,38,35,45,46,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,84]))),pG=(0,Z.lazy)(()=>c(()=>import(`./JobsPage-DcllM4Ip.js`),__vite__mapDeps([87,1,2,40,5,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,3,51,61,62,42,36,37,44,43,64,65,66,67,68,70,71,72,75,84,88,52]))),mG=(0,Z.lazy)(()=>c(()=>import(`./AnalyticsPage-BY7gtCx6.js`),__vite__mapDeps([89,1,2,40,5,49,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,90,43,36,37,44,34,3,66,73,88,52,91,92]))),hG=(0,Z.lazy)(()=>c(()=>import(`./ActivityFeedPage-9DZOvIcY.js`),__vite__mapDeps([93,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,51,55,63,43,36,37,44,34,3]))),gG=(0,Z.lazy)(()=>c(()=>import(`./AgentsPage-DuyJuaFs.js`),__vite__mapDeps([94,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,49,34,3,50,39,40,41,42,43,36,44,37,46,47,53,55,56,58,59,60,61,62,64,65,66,67,68]))),_G=(0,Z.lazy)(()=>c(()=>import(`./CodePage-vyQr40Vl.js`),__vite__mapDeps([95,1,2,3,5,40,6,34,35,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,36,37,39,41,42,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73]))),vG=(0,Z.lazy)(()=>c(()=>import(`./IntegrationsPage-Bs00_tl4.js`),__vite__mapDeps([96,2,1,40,5]))),yG=(0,Z.lazy)(()=>c(()=>import(`./PluginsPage-B89S8o1a.js`),__vite__mapDeps([97,1,2,6,34,3,52,55,60,61,62,36,43,44,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,37,64,65,66,67,68,42,69]))),bG=(0,Z.lazy)(()=>c(()=>import(`./DesktopAnalyticsPage-CkXUFj3F.js`),__vite__mapDeps([98,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,43,36,66,67,91,3,92]))),xG=(0,Z.lazy)(()=>c(()=>import(`./DocsPage-BY-wDthx.js`),__vite__mapDeps([99,1,2,40,5,6,47,53,55,67,66,70,74,100,101]))),SG=(0,Z.lazy)(()=>c(()=>import(`./DocsDialog-PhdCJNVj.js`),__vite__mapDeps([102,1,2,6,47,53,55,67,66,68,3,42,65,70,74,100,101]))),CG=(0,Z.lazy)(()=>c(()=>import(`./LoopsPage-SqglnXlp.js`),__vite__mapDeps([103,1,2,40,5,6,34,3,52,56,57,58,41,61,104,44,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,36,43,37,64,65,66,67,68,42,77,45,54]))),wG=(0,Z.lazy)(()=>c(()=>import(`./LoopBuilderPage-DGm_iuff.js`),__vite__mapDeps([105,1,2,3,40,5,6,34,50,45,54,57,58,59,61,62,104,64,65,66,67,68,42,92,106]))),TG=28;function EG({surface:e,onClose:t}){let{t:n}=I(`nav`),r=n(e===`loops`?`arcSidebar.loops`:`arcSidebar.plugins`);return(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-border bg-popover/95 px-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`grid h-7 w-7 shrink-0 place-items-center rounded-md border border-accent-primary/20 bg-accent-primary/10 text-accent-primary`,children:(0,Q.jsx)(e===`loops`?vi:Hr,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`truncate text-xs font-medium text-foreground`,children:r})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-popover`,"aria-label":n(`common:actions.close`),children:(0,Q.jsx)(yt,{className:`h-4 w-4`})})})]})}var DG=new Set([`/settings`,`/loops`,`/plugins`]);function OG(e){return DG.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var kG=`specrails-desktop:routeMemory`;try{localStorage.removeItem(kG)}catch{}function AG(e){let t=u(),n=p(),r=(0,Z.useRef)(new Map),i=(0,Z.useRef)(null),a=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{bi((e,t)=>{r.current.set(e,t)})},[]),(0,Z.useEffect)(()=>{a.current||(a.current=!0,t.pathname!==`/`&&n(`/`,{replace:!0}))},[]),(0,Z.useEffect)(()=>{if(i.current&&i.current!==e&&!OG(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!OG(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,Z.useEffect)(()=>{e&&t.pathname!==`/`&&!OG(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function jG(){let{t:e}=I(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setupProjectIds:a,completeSetupWizard:o,setActiveProjectId:s}=At(),{cycleLeftMode:c,cycleRightMode:l}=fE(),d=p(),h=u(),_=sW(),v=UV(),{startNewConversation:y}=v,{uiMode:b}=iw();lG();let[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),N=(0,Z.useCallback)(()=>M(!1),[]),[P,F]=(0,Z.useState)(()=>!NT());AG(n),bU();let{cheatsheetOpen:L,setCheatsheetOpen:R,openCheatsheet:z}=CC(),B=[`/`,`/jobs`,`/analytics`,...nt?[`/agents`]:[],...it?[`/code`]:[],`/integrations`,`/settings`];SC({onOpenCheatsheet:z,onToggleLeftSidebar:c,onToggleRightSidebar:l,onSwitchProject:e=>{let n=t[e-1];n&&s(n.id)},onSwitchProjectPage:e=>{let t=B[e-1];t&&d(t)},onToggleTerminalPanel:Ee?()=>{n&&(_.togglePanel(n),_.getState(n).visibility===`hidden`?queueMicrotask(()=>_.focusActive(n)):_.focusActive(n))}:void 0,onToggleAgentChat:at&&b!==`agent`?()=>v.toggle():void 0}),pC({setActiveProjectId:s,projectsById:(0,Z.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])});let V=t.find(e=>e.id===n),H=n!==null&&a.has(n),U=h.pathname.startsWith(`/loops`),W=h.pathname.startsWith(`/plugins`),ee=h.pathname.startsWith(`/docs`)||b!==`agent`&&(U||W);(0,Z.useLayoutEffect)(()=>{let e=dG({uiMode:b,pathname:h.pathname,loopsOpen:D,pluginsOpen:k});if(e){if(e.kind===`modalize`){e.surface===`loops`?(A(!1),O(!0)):(O(!1),A(!0)),y(n),h.pathname!==e.backgroundPath&&d(e.backgroundPath,{replace:!0});return}O(!1),A(!1),h.pathname!==e.path&&d(e.path,{replace:!0})}},[n,h.pathname,D,d,k,y,b]);let{connectionStatus:te}=vW(),G=cW(n),K=b===`agent`?0:TG,ne=(0,Z.useRef)(null),[re,ie]=(0,Z.useState)(typeof window<`u`?window.innerHeight:820);(0,Z.useLayoutEffect)(()=>{if(!Ee)return;let e=ne.current;if(!e)return;let t=()=>ie(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,Z.useEffect)(()=>{!Ee||!n||_.ensureProject(n)},[n,_]);let ae=Ee&&b===`kanban`&&G.visibility===`hidden`?(0,Q.jsx)(PW,{isOpen:!1,onClick:()=>n&&_.setVisibility(n,`restored`)}):null;return r?(0,Q.jsxs)(`div`,{className:`flex h-full`,children:[(0,Q.jsx)(`div`,{className:`w-11 border-r border-border bg-card/50 animate-pulse flex-shrink-0`}),(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})})]}):(0,Q.jsxs)(`div`,{className:`flex h-full overflow-hidden font-sans`,children:[(0,Q.jsx)(eH,{onAddProject:()=>S(!0),onOpenLoops:()=>{b===`agent`?O(!0):d(`/loops`)},onOpenPlugins:()=>{b===`agent`?A(!0):d(`/plugins`)},onOpenAnalytics:()=>E(!0),onOpenDocs:()=>M(!0),onOpenSettings:()=>w(!0)}),(0,Q.jsxs)(`div`,{ref:ne,className:`flex flex-col flex-1 overflow-hidden`,children:[i&&(0,Q.jsx)(`div`,{className:`h-0.5 w-full bg-accent-primary/70 animate-pulse shrink-0`,"data-testid":`project-switching-bar`}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:H&&V?(0,Q.jsx)(AT,{project:V,onComplete:()=>o(V.id),onSkip:()=>o(V.id)},V.id):b===`agent`&&!ee?(0,Q.jsx)(cG,{}):(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Q.jsxs)(g,{children:[(0,Q.jsx)(m,{path:`/docs`,element:(0,Q.jsx)(xG,{})}),(0,Q.jsx)(m,{path:`/docs/:category/:slug`,element:(0,Q.jsx)(xG,{})}),we&&(0,Q.jsx)(m,{path:`/loops`,element:(0,Q.jsx)(CG,{})}),we&&(0,Q.jsx)(m,{path:`/loops/:id/edit`,element:(0,Q.jsx)(wG,{})}),(0,Q.jsx)(m,{path:`/plugins`,element:(0,Q.jsx)(yG,{})}),t.length===0?(0,Q.jsx)(m,{path:`*`,element:(0,Q.jsx)(Bw,{onAddProject:()=>S(!0)})}):V?(0,Q.jsxs)(m,{element:(0,Q.jsx)(zw,{projectName:V.name,children:(0,Q.jsx)(Lw,{project:V})},V.id),children:[(0,Q.jsx)(m,{path:`/`,element:(0,Q.jsx)($b,{})}),(0,Q.jsx)(m,{path:`/jobs`,element:(0,Q.jsx)(pG,{})}),(0,Q.jsx)(m,{path:`/jobs/:id`,element:(0,Q.jsx)(fG,{})}),(0,Q.jsx)(m,{path:`/analytics`,element:(0,Q.jsx)(mG,{})}),(0,Q.jsx)(m,{path:`/activity`,element:(0,Q.jsx)(hG,{})}),(0,Q.jsx)(m,{path:`/agents`,element:(0,Q.jsx)(gG,{})}),(0,Q.jsx)(m,{path:`/code`,element:it?(0,Q.jsx)(_G,{}):(0,Q.jsx)(f,{to:`/`,replace:!0})}),(0,Q.jsx)(m,{path:`/integrations`,element:(0,Q.jsx)(vG,{})}),(0,Q.jsx)(m,{path:`/settings`,element:(0,Q.jsx)(Tx,{})}),(0,Q.jsx)(m,{path:`*`,element:(0,Q.jsx)(f,{to:`/`,replace:!0})})]}):(0,Q.jsx)(m,{path:`*`,element:(0,Q.jsx)(Bw,{onAddProject:()=>S(!0)})})]})})}),Ee&&n&&V&&(0,Q.jsx)(tG,{projectId:n,provider:V.provider,providers:kt(V),state:G,viewportHeight:re,statusBarHeight:K}),b!==`agent`&&(0,Q.jsx)(nG,{connectionStatus:te,rightSlot:ae})]}),b===`agent`?!H&&!ee&&(0,Q.jsx)(iG,{}):V&&!H&&!ee&&(0,Q.jsx)(oH,{}),(0,Q.jsx)(vH,{open:x,onClose:()=>S(!1),onOpenBuilder:()=>v.builderMode.enter()}),(0,Q.jsx)(_C,{open:C,onClose:()=>w(!1),onOpenOnboarding:()=>{w(!1),F(!0)}}),(0,Q.jsx)(nn,{open:T,onOpenChange:E,children:(0,Q.jsx)(Zt,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Q.jsx)(bG,{})})})})}),(0,Q.jsx)(nn,{open:D,onOpenChange:O,children:(0,Q.jsxs)(Zt,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,Q.jsx)(Qt,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,Q.jsx)(en,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,Q.jsx)(EG,{surface:`loops`,onClose:()=>O(!1)}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Q.jsx)(CG,{})})})]})}),(0,Q.jsx)(nn,{open:k,onOpenChange:A,children:(0,Q.jsxs)(Zt,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,Q.jsx)(Qt,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,Q.jsx)(en,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,Q.jsx)(EG,{surface:`plugins`,onClose:()=>A(!1)}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,Q.jsx)(yG,{})})})]})}),(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(SG,{open:j,onClose:N})}),(0,Q.jsx)(mU,{onOpenSettings:()=>w(!0),onOpenAnalytics:()=>E(!0),onOpenDocs:()=>M(!0)}),(0,Q.jsx)(OC,{open:L,onOpenChange:R}),(0,Q.jsx)(JT,{open:P,onClose:()=>F(!1)})]})}function MG({children:e}){let{activeProjectId:t}=At();return(0,Q.jsx)(aW,{activeProjectId:t,children:e})}function NG({children:e}){let{activeProjectId:t}=At();return(0,Q.jsx)(Zv,{activeProjectId:t,children:e})}function PG({children:e}){let{activeProjectId:t}=At();return(0,Q.jsx)(iy,{activeProjectId:t,children:e})}function FG(){return(0,Q.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function IG(){let{theme:e}=Db(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,Q.jsx)(z,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,Q.jsx)(FG,{})},style:{"--accent":t,"--toast-success-border":`color-mix(in srgb, ${n} 38%, transparent)`,"--toast-error-border":`color-mix(in srgb, ${r} 38%, transparent)`,"--toast-warning-border":`color-mix(in srgb, ${i} 38%, transparent)`,"--toast-info-border":`color-mix(in srgb, ${a} 38%, transparent)`},toastOptions:{unstyled:!0,classNames:{toast:`glass-card border border-border/30 text-foreground text-xs p-3 rounded-lg flex items-start gap-2 w-[356px] max-w-[356px] overflow-hidden shadow-lg`,content:`flex-1 min-w-0 flex flex-col gap-0.5`,icon:`shrink-0 mt-[2px] flex items-center justify-center`,title:`font-medium text-sm`,description:`text-muted-foreground mt-0.5`,actionButton:`text-[11px] px-2.5 py-1 rounded-md bg-accent-primary text-white hover:bg-accent-primary/90 whitespace-nowrap shrink-0 self-start`,cancelButton:`text-[11px] px-2.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/50 whitespace-nowrap shrink-0 self-start`,closeButton:`text-muted-foreground hover:text-foreground rounded-md p-0.5`,success:`border-l-4 border-l-[var(--toast-success-border)]`,error:`border-l-4 border-l-[var(--toast-error-border)]`,warning:`border-l-4 border-l-[var(--toast-warning-border)]`,info:`border-l-4 border-l-[var(--toast-info-border)]`,loading:``}}})}function LG(){return yS(),wU(),(0,Q.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:(0,Q.jsx)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:(0,Q.jsx)(Dt,{url:ae,children:(0,Q.jsx)(Eb,{children:(0,Q.jsxs)(Mx,{children:[(0,Q.jsx)(Iw,{}),(0,Q.jsx)(jt,{children:(0,Q.jsxs)(nw,{children:[(0,Q.jsx)(lw,{}),(0,Q.jsx)(eh,{children:(0,Q.jsx)(vU,{children:(0,Q.jsx)(Ye,{children:(0,Q.jsx)(dE,{children:(0,Q.jsx)(MG,{children:(0,Q.jsx)(NG,{children:(0,Q.jsx)(PG,{children:(0,Q.jsx)(ve,{children:(0,Q.jsx)(VV,{children:(0,Q.jsx)(UR,{children:(0,Q.jsx)(LR,{children:(0,Q.jsx)(Le,{children:(0,Q.jsxs)(Qe,{children:[(0,Q.jsx)(jG,{}),(0,Q.jsx)(IG,{})]})})})})})})})})})})})})})]})})]})})})})})}async function RG(){await wt(),St(),await j(),(0,_n.createRoot)(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(_,{children:(0,Q.jsx)(LG,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}RG();export{di as $,og as A,Nn as At,rc as B,Jv as C,er as Ct,Y_ as D,Ln as Dt,nv as E,Un as Et,_m as F,vn as Ft,go as G,Vs as H,ym as I,ua as J,ya as K,sc as L,hh as M,Dn as Mt,vm as N,Cn as Nt,$_ as O,In as Ot,bm as P,bn as Pt,fi as Q,Gs as R,Hv as S,rr as St,kv as T,Xn as Tt,ps as U,$s as V,uo as W,vi as X,Ji as Y,gi as Z,xx as _,_r as _t,rR as a,ti as at,kb as b,ur as bt,FL as c,Jr as ct,qx as d,zr as dt,ci as et,$ as f,kr as ft,gx as g,Cr as gt,Cx as h,Er as ht,zR as i,ni as it,yh as j,kn as jt,D_ as k,Pn as kt,SE as l,qr as lt,_x as m,Dr as mt,qz as n,ai as nt,iR as o,ei as ot,wx as p,Or as pt,la as q,Wz as r,ii as rt,vR as s,Xr as st,vW as t,si as tt,fT as u,Hr as ut,fx as v,hr as vt,Av as w,$n as wt,Yy as x,ir as xt,ox as y,mr as yt,Ps as z};
|