specrails-desktop 2.44.0 → 2.44.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-CG2fhd_k.js → ActivityFeedPage-CL1BUXoj.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-C6BVsTfo.js → AgentBrowserCapture-BQem50z4.js} +1 -1
- package/client/dist/assets/{AgentModeAnalyticsPane-90q1FOYY.js → AgentModeAnalyticsPane-BC_xbT_l.js} +2 -2
- package/client/dist/assets/{AgentModeCodePane-CzNPXJND.js → AgentModeCodePane-DK-q3K6Y.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-CS4XPM5K.js → AgentModeJobsPane-C7ELTPC1.js} +1 -1
- package/client/dist/assets/{AgentsPage-DgF8yxlz.js → AgentsPage-DbLezyI6.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-BZRZpWTe.js → AnalyticsPage-DTsg-N5z.js} +1 -1
- package/client/dist/assets/{CodePage-CobZpY2J.js → CodePage-DwgbeqQ_.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-B75I8Hyl.js → DesktopAnalyticsPage-Y0Z1ryQr.js} +1 -1
- package/client/dist/assets/{DocsDialog-AEU1MV8y.js → DocsDialog-KeCOxvGH.js} +1 -1
- package/client/dist/assets/{DocsPage-Dn2j2nSl.js → DocsPage-Bt1PgYPO.js} +1 -1
- package/client/dist/assets/{ExportDropdown-Xvbax18F.js → ExportDropdown-DczgU4at.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-COH-v0lE.js → InteractiveJobComposer-BcR6xlHU.js} +1 -1
- package/client/dist/assets/{JobDetailModal-CyFzkOM-.js → JobDetailModal-DKA_DUHe.js} +1 -1
- package/client/dist/assets/{JobDetailPage-CAILeuTY.js → JobDetailPage-vaOcE-cI.js} +1 -1
- package/client/dist/assets/{JobsPage-CzOmMhkp.js → JobsPage-Bwoe-Fb0.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-_Snk4Cv7.js → LoopBuilderPage-CqC4hbXb.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-C2yekwCg.js → LoopPreviewModal-T0zuFv6y.js} +1 -1
- package/client/dist/assets/{LoopsPage-C4GXI81g.js → LoopsPage-DrQGcZv2.js} +1 -1
- package/client/dist/assets/{MinimizedChatsContext-0mMk-eoH.js → MinimizedChatsContext-C843Y13h.js} +1 -1
- package/client/dist/assets/{PluginsPage-pPmHG9nI.js → PluginsPage-CTUHX_Lu.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-Bcsq5o0U.js → ProjectSettingsDialog-DeL8md1s.js} +1 -1
- package/client/dist/assets/{RepositoryDeliveries-DJTjRht9.js → RepositoryDeliveries-bgIHE8ep.js} +1 -1
- package/client/dist/assets/{RepositoryScopeSelector-CvOfpd2g.js → RepositoryScopeSelector-CZ_U_R3U.js} +1 -1
- package/client/dist/assets/{ReviewPacketPage-BPG3cVpM.js → ReviewPacketPage-DbKO6pT8.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-Dx_3cTQN.js → TemplatePreviewModal-_CgCCV7L.js} +1 -1
- package/client/dist/assets/{TicketDetailModalContext-0sPSvSmT.js → TicketDetailModalContext-BbRA6cb7.js} +1 -1
- package/client/dist/assets/{Trans-BrG0crRZ.js → Trans-mjFZpHw1.js} +1 -1
- package/client/dist/assets/{formatDistanceToNow-CEH5-6MR.js → formatDistanceToNow-BIL-HxGy.js} +1 -1
- package/client/dist/assets/{getTimezoneOffsetInMilliseconds-C4NbLIYo.js → getTimezoneOffsetInMilliseconds-Cs9z2sdO.js} +1 -1
- package/client/dist/assets/{index-BIEV2BG8.js → index-UnaJTMIy.js} +6 -6
- package/client/dist/assets/{jira-api-BuMzFZx1.js → jira-api-B2BBZQTx.js} +1 -1
- package/client/dist/assets/{project-repositories-CAW6v3SO.js → project-repositories-xSqimlaj.js} +1 -1
- package/client/dist/assets/settings-2Yx_9yJM.js +1 -0
- package/client/dist/assets/settings-BLOsrXEw.js +1 -0
- package/client/dist/assets/settings-C6s9PtRD.js +1 -0
- package/client/dist/assets/settings-CCNZN5Q-.js +1 -0
- package/client/dist/assets/{settings-Deupji9c.js → settings-CpKwTew1.js} +1 -1
- package/client/dist/assets/settings-DPjNiUsS.js +1 -0
- package/client/dist/assets/settings-FIqwhTup.js +1 -0
- package/client/dist/assets/{settings-CrMi3kSi.js → settings-NSWQjY5B.js} +1 -1
- package/client/dist/assets/{spending-DI73ic0T.js → spending-DXOcv1tn.js} +1 -1
- package/client/dist/assets/{useDesktop-DA-nfO01.js → useDesktop-gVGoWWiY.js} +1 -1
- package/client/dist/assets/{useSharedWebSocket-D-czsPTl.js → useSharedWebSocket-DbGL_YOt.js} +2 -2
- package/client/dist/index.html +14 -14
- package/docs/guide/de/settings/3-pipeline-telemetry-and-diagnostics.md +1 -1
- package/docs/guide/en/settings/3-pipeline-telemetry-and-diagnostics.md +1 -1
- package/docs/guide/es/settings/3-pipeline-telemetry-and-diagnostics.md +1 -1
- package/docs/guide/fr/settings/3-pipeline-telemetry-and-diagnostics.md +1 -1
- package/docs/guide/it/settings/3-pipeline-telemetry-and-diagnostics.md +1 -1
- package/docs/guide/ja/settings/3-pipeline-telemetry-and-diagnostics.md +1 -1
- package/docs/guide/pt/settings/3-pipeline-telemetry-and-diagnostics.md +1 -1
- package/docs/guide/zh/settings/3-pipeline-telemetry-and-diagnostics.md +1 -1
- package/docs/internals/verification-handoff-regression.md +70 -0
- package/package.json +1 -1
- package/server/dist/background-windows-bootstrap.js +6 -3
- package/server/dist/core-execution.js +45 -0
- package/server/dist/db.js +1 -1
- package/server/dist/framework-manager.js +23 -4
- package/server/dist/loop-executors.js +6 -0
- package/server/dist/loop-run-manager.js +18 -3
- package/client/dist/assets/settings-BBt2xtDQ.js +0 -1
- package/client/dist/assets/settings-BJB9RKJj.js +0 -1
- package/client/dist/assets/settings-CHwQR2rB.js +0 -1
- package/client/dist/assets/settings-DKyhDGD1.js +0 -1
- package/client/dist/assets/settings-DqRMmwAM.js +0 -1
- package/client/dist/assets/settings-J4rj6vo-.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-B3mKBIh5.js","assets/rolldown-runtime-CNC7AqOf.js","assets/event-Bt7f3wXe.js","assets/addon-image-BRmmRHgQ.js","assets/addon-ligatures-qIZUPvRV.js","assets/addon-webgl-C2d7lriQ.js","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,f as d,i as f,l as p,o as m,r as h,s as g,t as _,u as v}from"./chunk-KS7C4IRE-DEKu087k.js";import{$ as y,A as b,B as x,C as S,D as C,E as w,F as T,H as E,I as D,J as O,L as k,M as A,N as j,O as M,P as N,Q as P,R as F,S as I,T as L,U as R,V as z,X as B,Y as ee,Z as V,_ as H,a as te,at as ne,b as re,c as ie,ct as ae,dt as oe,et as se,g as ce,h as le,i as ue,j as de,k as fe,l as pe,lt as me,n as he,nt as ge,o as _e,ot as ve,p as ye,q as U,r as be,rt as xe,s as Se,st as Ce,t as W,tt as we,ut as Te,v as Ee,w as De,x as Oe,y as ke,z as Ae}from"./TicketDetailModalContext-0sPSvSmT.js";import{C as je,O as Me,S as Ne,T as Pe,_ as Fe,a as Ie,b as Le,d as Re,f as ze,g as Be,h as G,i as Ve,l as He,m as Ue,n as We,o as Ge,p as Ke,r as qe,s as Je,t as Ye,u as Xe,v as Ze,w as Qe,x as $e,y as et}from"./useSharedWebSocket-D-czsPTl.js";import{t as tt}from"./Trans-BrG0crRZ.js";import{n as K,t as q}from"./createLucideIcon-Bjbbp_KS.js";import{a as nt,n as rt,o as it,r as at,s as J,t as ot}from"./useDesktop-DA-nfO01.js";import{a as Y,n as st,r as ct,t as lt}from"./core-B3mKBIh5.js";import{C as ut,D as dt,E as ft,O as pt,S as mt,T as ht,_ as gt,a as _t,b as vt,c as yt,d as bt,f as xt,g as St,h as Ct,i as wt,l as Tt,m as Et,n as Dt,o as Ot,p as kt,r as At,s as jt,t as Mt,u as Nt,v as Pt,w as Ft,x as It,y as Lt}from"./RepositoryDeliveries-DJTjRht9.js";import{n as Rt,t as zt}from"./save-B6wGWwBR.js";import{a as Bt,c as Vt,d as Ht,f as Ut,i as Wt,l as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./MinimizedChatsContext-0mMk-eoH.js";import{n as Qt,t as $t}from"./file-text-BcLCfcWZ.js";import{t as en}from"./circle-x-CMYsN4ZH.js";import{t as tn}from"./download-CFHyyHcw.js";import{t as nn}from"./git-branch-BRM0F5GN.js";import{t as rn}from"./loader-circle-DcygOQpC.js";import{t as an}from"./pencil-C9RkrIPZ.js";import{n as on,t as sn}from"./square-Ci-PFcFe.js";import{t as cn}from"./plus-CsnjfkmX.js";import{t as ln}from"./search-Cq_gE3Ik.js";import{t as un}from"./sparkles-DrY8hb0X.js";import{t as dn}from"./trash-2-BOU3WdZZ.js";import{t as fn}from"./triangle-alert-H9T4jAmh.js";import{n as pn}from"./jira-api-BuMzFZx1.js";import{t as mn}from"./x-CBMI9ejn.js";import{t as hn}from"./zap-CHo3aCD1.js";import{A as gn,C as _n,D as vn,E as yn,M as bn,O as xn,S as Sn,T as Cn,_ as wn,a as Tn,b as En,c as Dn,d as On,f as kn,g as An,h as jn,i as Mn,j as Nn,k as Pn,l as Fn,m as In,n as Ln,o as Rn,p as zn,r as Bn,s as Vn,t as Hn,u as Un,v as Wn,w as Gn,x as Kn,y as qn}from"./dialog-xXB2q5HJ.js";import{t as X}from"./utils-BC4DHlz2.js";import{n as Jn,t as Yn}from"./lib-CGdyxIWg.js";import{t as Xn}from"./getTimezoneOffsetInMilliseconds-C4NbLIYo.js";import{t as Zn}from"./formatDistanceToNow-CEH5-6MR.js";import{n as Qn,t as Z}from"./button-Ccc9Dc-D.js";import{n as $n,t as er}from"./project-repositories-CAW6v3SO.js";import{t as tr}from"./RepositoryScopeSelector-CvOfpd2g.js";import{a as nr,c as rr,d as ir,f as ar,l as or,n as sr,o as cr,p as lr,r as ur,s as dr,t as fr,u as pr}from"./provider-capabilities-B-wOHfLP.js";import{a as mr,n as hr,o as gr,r as _r,t as vr}from"./event-Bt7f3wXe.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 yr=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}}}})),br=i(((e,t)=>{t.exports=yr()})),xr=i((e=>{var t=br(),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 ee(e){0>z||(e.current=R[z],R[z]=null,z--)}function V(e,t){z++,R[z]=e.current,e.current=t}var H=B(null),te=B(null),ne=B(null),re=B(null);function ie(e,t){switch(V(ne,t),V(te,e),V(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ee(H),V(H,e)}function ae(){ee(H),ee(te),ee(ne)}function oe(e){e.memoizedState!==null&&V(re,e);var t=H.current,n=Hd(t,e.type);t!==n&&(V(te,e),V(H,n))}function se(e){te.current===e&&(ee(H),ee(te)),re.current===e&&(ee(re),Qf._currentValue=L)}var ce,le;function ue(e){if(ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ce=t&&t[1]||``,le=-1<e.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-B3mKBIh5.js","assets/rolldown-runtime-CNC7AqOf.js","assets/event-Bt7f3wXe.js","assets/addon-image-BRmmRHgQ.js","assets/addon-ligatures-qIZUPvRV.js","assets/addon-webgl-C2d7lriQ.js","assets/JobDetailModal-DKA_DUHe.js","assets/jsx-runtime-zu2_FqZY.js","assets/react-dom-DiWzBDP9.js","assets/TicketDetailModalContext-BbRA6cb7.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-DEKu087k.js","assets/useSharedWebSocket-DbGL_YOt.js","assets/activity-DiyjsgQV.js","assets/addspec-D2YIQ0GU.js","assets/agent-Bh9K7iEt.js","assets/agents-ms7TwG16.js","assets/agentstudio-CN2pokQu.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-BMzCvrCU.js","assets/attachments-B53PG733.js","assets/browser-CG0PE1j_.js","assets/builder-BTiGnPT0.js","assets/chat-BGD7MXAy.js","assets/code-DaZ-ZwCT.js","assets/commands-BAWSYHjQ.js","assets/common-BrlwEnL7.js","assets/dashboard-BfBir_6o.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CKJg3HZd.js","assets/jobs-DMPU64ms.js","assets/loops-B7YpGizO.js","assets/mcp-CUAN6ORK.js","assets/narration-B-ynWTpn.js","assets/nav-Ch-zHBG5.js","assets/packet-Cx-zRuWn.js","assets/settings-CCNZN5Q-.js","assets/setup-Ba11l2JA.js","assets/specs-DII0C8gw.js","assets/terminal-BAzpHtpY.js","assets/tickets-W6pBmbrX.js","assets/createLucideIcon-Bjbbp_KS.js","assets/Trans-mjFZpHw1.js","assets/useDesktop-gVGoWWiY.js","assets/save-B6wGWwBR.js","assets/spending-DXOcv1tn.js","assets/MinimizedChatsContext-C843Y13h.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/file-text-BcLCfcWZ.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/git-branch-BRM0F5GN.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/square-Ci-PFcFe.js","assets/plus-CsnjfkmX.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/jira-api-B2BBZQTx.js","assets/zap-CHo3aCD1.js","assets/dialog-xXB2q5HJ.js","assets/utils-BC4DHlz2.js","assets/clsx-CjueKrWZ.js","assets/lib-CGdyxIWg.js","assets/formatDistanceToNow-BIL-HxGy.js","assets/getTimezoneOffsetInMilliseconds-Cs9z2sdO.js","assets/button-Ccc9Dc-D.js","assets/RepositoryScopeSelector-CZ_U_R3U.js","assets/project-repositories-xSqimlaj.js","assets/provider-capabilities-B-wOHfLP.js","assets/InteractiveJobComposer-BcR6xlHU.js","assets/brain-DI9lHkKY.js","assets/lib-C7Mhm-gT.js","assets/job-time-BCL7wee9.js","assets/LoopPreviewModal-T0zuFv6y.js","assets/TemplatePreviewModal-_CgCCV7L.js","assets/AgentModeCodePane-DK-q3K6Y.js","assets/AgentModeJobsPane-C7ELTPC1.js","assets/format-command-C0D9IPmV.js","assets/AgentModeAnalyticsPane-BC_xbT_l.js","assets/dist-js-CJ_2XX1Y.js","assets/ProjectSettingsDialog-DeL8md1s.js","assets/AgentBrowserCapture-BQem50z4.js","assets/JobDetailPage-vaOcE-cI.js","assets/ReviewPacketPage-DbKO6pT8.js","assets/RepositoryDeliveries-bgIHE8ep.js","assets/JobsPage-Bwoe-Fb0.js","assets/ExportDropdown-DczgU4at.js","assets/AnalyticsPage-DTsg-N5z.js","assets/BarChart-nBOMNfiy.js","assets/value-s-gzBeyF.js","assets/ActivityFeedPage-CL1BUXoj.js","assets/AgentsPage-DbLezyI6.js","assets/CodePage-DwgbeqQ_.js","assets/IntegrationsPage-Bhy58lnQ.js","assets/PluginsPage-CTUHX_Lu.js","assets/DesktopAnalyticsPage-Y0Z1ryQr.js","assets/DocsPage-Bt1PgYPO.js","assets/atom-one-dark-qiGhVQxg.js","assets/atom-one-dark-B-oHczHB.css","assets/DocsDialog-KeCOxvGH.js","assets/LoopsPage-DrQGcZv2.js","assets/upload-DYMjAQ6M.js","assets/LoopBuilderPage-CqC4hbXb.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,f as d,i as f,l as p,o as m,r as h,s as g,t as _,u as v}from"./chunk-KS7C4IRE-DEKu087k.js";import{$ as y,A as b,B as x,C as S,D as C,E as w,F as T,H as E,I as D,J as O,L as k,M as A,N as j,O as M,P as N,Q as P,R as F,S as I,T as L,U as R,V as z,X as B,Y as ee,Z as V,_ as H,a as te,at as ne,b as re,c as ie,ct as ae,dt as oe,et as se,g as ce,h as le,i as ue,j as de,k as fe,l as pe,lt as me,n as he,nt as ge,o as _e,ot as ve,p as ye,q as U,r as be,rt as xe,s as Se,st as Ce,t as W,tt as we,ut as Te,v as Ee,w as De,x as Oe,y as ke,z as Ae}from"./TicketDetailModalContext-BbRA6cb7.js";import{C as je,O as Me,S as Ne,T as Pe,_ as Fe,a as Ie,b as Le,d as Re,f as ze,g as Be,h as G,i as Ve,l as He,m as Ue,n as We,o as Ge,p as Ke,r as qe,s as Je,t as Ye,u as Xe,v as Ze,w as Qe,x as $e,y as et}from"./useSharedWebSocket-DbGL_YOt.js";import{t as tt}from"./Trans-mjFZpHw1.js";import{n as K,t as q}from"./createLucideIcon-Bjbbp_KS.js";import{a as nt,n as rt,o as it,r as at,s as J,t as ot}from"./useDesktop-gVGoWWiY.js";import{a as Y,n as st,r as ct,t as lt}from"./core-B3mKBIh5.js";import{C as ut,D as dt,E as ft,O as pt,S as mt,T as ht,_ as gt,a as _t,b as vt,c as yt,d as bt,f as xt,g as St,h as Ct,i as wt,l as Tt,m as Et,n as Dt,o as Ot,p as kt,r as At,s as jt,t as Mt,u as Nt,v as Pt,w as Ft,x as It,y as Lt}from"./RepositoryDeliveries-bgIHE8ep.js";import{n as Rt,t as zt}from"./save-B6wGWwBR.js";import{a as Bt,c as Vt,d as Ht,f as Ut,i as Wt,l as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./MinimizedChatsContext-C843Y13h.js";import{n as Qt,t as $t}from"./file-text-BcLCfcWZ.js";import{t as en}from"./circle-x-CMYsN4ZH.js";import{t as tn}from"./download-CFHyyHcw.js";import{t as nn}from"./git-branch-BRM0F5GN.js";import{t as rn}from"./loader-circle-DcygOQpC.js";import{t as an}from"./pencil-C9RkrIPZ.js";import{n as on,t as sn}from"./square-Ci-PFcFe.js";import{t as cn}from"./plus-CsnjfkmX.js";import{t as ln}from"./search-Cq_gE3Ik.js";import{t as un}from"./sparkles-DrY8hb0X.js";import{t as dn}from"./trash-2-BOU3WdZZ.js";import{t as fn}from"./triangle-alert-H9T4jAmh.js";import{n as pn}from"./jira-api-B2BBZQTx.js";import{t as mn}from"./x-CBMI9ejn.js";import{t as hn}from"./zap-CHo3aCD1.js";import{A as gn,C as _n,D as vn,E as yn,M as bn,O as xn,S as Sn,T as Cn,_ as wn,a as Tn,b as En,c as Dn,d as On,f as kn,g as An,h as jn,i as Mn,j as Nn,k as Pn,l as Fn,m as In,n as Ln,o as Rn,p as zn,r as Bn,s as Vn,t as Hn,u as Un,v as Wn,w as Gn,x as Kn,y as qn}from"./dialog-xXB2q5HJ.js";import{t as X}from"./utils-BC4DHlz2.js";import{n as Jn,t as Yn}from"./lib-CGdyxIWg.js";import{t as Xn}from"./getTimezoneOffsetInMilliseconds-Cs9z2sdO.js";import{t as Zn}from"./formatDistanceToNow-BIL-HxGy.js";import{n as Qn,t as Z}from"./button-Ccc9Dc-D.js";import{n as $n,t as er}from"./project-repositories-xSqimlaj.js";import{t as tr}from"./RepositoryScopeSelector-CZ_U_R3U.js";import{a as nr,c as rr,d as ir,f as ar,l as or,n as sr,o as cr,p as lr,r as ur,s as dr,t as fr,u as pr}from"./provider-capabilities-B-wOHfLP.js";import{a as mr,n as hr,o as gr,r as _r,t as vr}from"./event-Bt7f3wXe.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 yr=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}}}})),br=i(((e,t)=>{t.exports=yr()})),xr=i((e=>{var t=br(),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 ee(e){0>z||(e.current=R[z],R[z]=null,z--)}function V(e,t){z++,R[z]=e.current,e.current=t}var H=B(null),te=B(null),ne=B(null),re=B(null);function ie(e,t){switch(V(ne,t),V(te,e),V(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ee(H),V(H,e)}function ae(){ee(H),ee(te),ee(ne)}function oe(e){e.memoizedState!==null&&V(re,e);var t=H.current,n=Hd(t,e.type);t!==n&&(V(te,e),V(H,n))}function se(e){te.current===e&&(ee(H),ee(te)),re.current===e&&(ee(re),Qf._currentValue=L)}var ce,le;function ue(e){if(ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ce=t&&t[1]||``,le=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ce+e+le}var de=!1;function fe(e,t){if(!e||de)return``;de=!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(`
|
|
@@ -36,11 +36,11 @@ Error generating stack: `+e.message+`
|
|
|
36
36
|
`),l[r]=n.length,a(t),l.push(n.length)}),i.set(e,{start:o,end:n.length,boundaries:l})};return a(e),{value:n,references:r,positions:i}}function AD(e,t,n){let r=e.positions.get(t);if(r)return r.boundaries?r.boundaries[Math.min(n,r.boundaries.length-1)]:r.atomic?n===0?r.start:r.end:Math.min(r.end,r.start+n);let i=t.parentNode;for(;i;){let t=e.positions.get(i);if(t?.atomic)return n===0?t.start:t.end;i=i.parentNode}return e.value.length}function jD(e,t){let n=e.ownerDocument.getSelection();if(!n?.anchorNode||!n.focusNode||!e.contains(n.anchorNode)||!e.contains(n.focusNode))return null;let r=AD(t,n.anchorNode,n.anchorOffset),i=AD(t,n.focusNode,n.focusOffset);return[Math.min(r,i),Math.max(r,i)]}function MD(e,t,n){let r=Math.max(0,Math.min(n,t.value.length));for(let[n,i]of t.positions)if(!(r<i.start||r>i.end)){if(n.nodeType===Node.TEXT_NODE)return[n,i.boundaries?.lastIndexOf(r)??r-i.start];if(i.atomic&&n.parentNode){let e=Array.prototype.indexOf.call(n.parentNode.childNodes,n);return r===i.end&&n.nextSibling?.nodeType===Node.TEXT_NODE&&n.nextSibling.textContent?.startsWith(OD)?[n.nextSibling,1]:[n.parentNode,e+ +(r-i.start>(i.end-i.start)/2)]}if(n!==e&&n instanceof HTMLElement&&n.tagName===`BR`&&n.parentNode){let e=Array.prototype.indexOf.call(n.parentNode.childNodes,n);return[n.parentNode,e+ +(r>i.start)]}}return[e,e.childNodes.length]}function ND(e,t,n,r){let[i,a]=MD(e,t,n),[o,s]=MD(e,t,Math.max(n,r)),c=e.ownerDocument.createRange();c.setStart(i,a),c.setEnd(o,s);let l=e.ownerDocument.getSelection();l?.removeAllRanges(),l?.addRange(c)}function PD(e,t){let n=0,r=new Set;return[...t].sort((e,t)=>e.start-t.start).filter(t=>!t.key||!Number.isInteger(t.start)||!Number.isInteger(t.end)||r.has(t.key)||t.start<n||t.end<=t.start||e.slice(t.start,t.end)!==t.chip.token?!1:(n=t.end,r.add(t.key),!0))}function FD(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.key===r.key&&e.start===r.start&&e.end===r.end&&JSON.stringify(e.chip)===JSON.stringify(r.chip)})}function ID(e){return e===`spec`||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===`project`||e===`alias`?`border-accent-primary/30 bg-accent-primary/10 text-accent-primary`:`border-border/60 bg-surface/70 text-foreground/80`}function LD(e,t,n,r,i){let a=e.createDocumentFragment(),o=0;for(let s of n){a.append(e.createTextNode(`${o>0?OD:``}${t.slice(o,s.start)}${OD}`));let n=e.createElement(`span`);n.setAttribute(`contenteditable`,`false`),n.dataset.inlineReference=s.key,n.dataset.token=s.chip.token,n.className=`mx-0.5 inline-flex max-w-[240px] items-center gap-1 align-middle rounded-full border px-2 py-0.5 text-[11px] select-none ${ID(s.chip.kind)}`,n.title=[s.chip.label,s.chip.detail,s.chip.projectName,s.chip.status].filter(Boolean).join(` · `);let c=e.createElement(`span`);c.textContent=/^[#@/]/.test(s.chip.token)?s.chip.token[0]:`@`,c.setAttribute(`aria-hidden`,`true`);let l=e.createElement(`span`);if(l.className=`truncate font-medium`,l.textContent=s.chip.label,n.append(c,l),s.chip.status){let t=e.createElement(`span`);t.className=`text-foreground/40`,t.textContent=s.chip.status,n.append(t)}let u=e.createElement(`button`);u.type=`button`,u.tabIndex=-1,u.disabled=r??!1,u.dataset.removeReference=s.key,u.setAttribute(`aria-label`,i(s.chip.label)),u.className=`rounded-sm px-0.5 text-foreground/45 hover:bg-background/60 hover:text-foreground`,u.textContent=`×`,n.append(u),a.append(n),o=s.end}return a.append(e.createTextNode(`${n.length?OD:``}${t.slice(o)}`)),a}var RD=(0,Q.forwardRef)(function(e,t){let{t:n}=K(`agent`),r=(0,Q.useRef)(null),i=(0,Q.useRef)(e);i.current=e;let a=(0,Q.useRef)(new Map),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)([e.value.length,e.value.length]),l=(0,Q.useRef)([]),u=(0,Q.useRef)(``),d=(0,Q.useRef)(null),f=(0,Q.useRef)({entries:[{value:e.value,references:PD(e.value,e.references),selection:[e.value.length,e.value.length]}],index:0,typing:null}),p=()=>kD(r.current,a.current),m=e=>{c.current=e,f.current.entries[f.current.index].selection=e},h=(e,t)=>{let n=f.current,r=n.entries[n.index];if(r.value===e.value&&FD(r.references,e.references)){r.selection=e.selection;return}r.selection=c.current;let i=Date.now(),a=t===`insertText`&&n.typing!==null&&i-n.typing.at<1e3&&r.selection[0]===r.selection[1]&&r.selection[0]===n.typing.caret&&e.selection[0]===e.selection[1]&&e.selection[0]>=r.selection[0]&&r.references.length===e.references.length&&r.references.every((t,n)=>t.key===e.references[n].key);n.entries.splice(n.index+1),a&&n.index>0?n.entries[n.index]=e:(n.entries.push(e),n.entries.length>64&&n.entries.shift(),n.index=n.entries.length-1),n.typing=t===`insertText`?{at:i,caret:e.selection[0]}:null},g=(e,t,o)=>{let s=r.current;for(let e of t)a.current.set(e.key,e.chip);s.replaceChildren(LD(s.ownerDocument,e,t,i.current.disabled??!1,e=>n(`palette.remove`,{label:e}))),s.dataset.empty=String(e.length===0),l.current=t,u.current=b,o&&(ND(s,p(),...o),m(jD(s,p())??o))},_=e=>{let t=r.current;if(!t||i.current.disabled)return;let n=f.current;n.index=Math.max(0,Math.min(n.entries.length-1,n.index+e)),n.typing=null;let a=n.entries[n.index];t.focus(),g(a.value,a.references,a.selection),i.current.onChange(a.value,a.references,a.selection[0])},v=()=>{let e=r.current;if(!e)return;let t=jD(e,p());t&&(t[0]!==c.current[0]||t[1]!==c.current[1])&&(m(t),i.current.onSelect(...t))},y=(e=`insertText`)=>{let t=r.current;if(!t||o.current)return;if(e===`historyUndo`||e===`historyRedo`){_(e===`historyUndo`?-1:1);return}let n=p(),a=jD(t,n)??[n.value.length,n.value.length];h({value:n.value,references:n.references,selection:a},d.current??e),m(a),l.current=n.references,t.dataset.empty=String(n.value.length===0),i.current.onChange(n.value,n.references,a[0])};(0,Q.useImperativeHandle)(t,()=>({focus:()=>r.current?.focus(),setSelectionRange:(e,t)=>{r.current&&(ND(r.current,p(),e,t),m(jD(r.current,p())??[e,t]))},get selectionStart(){return r.current?(jD(r.current,p())??c.current)[0]:0},get selectionEnd(){return r.current?(jD(r.current,p())??c.current)[1]:0},get value(){return r.current?p().value:i.current.value}}));let b=n(`palette.remove`,{label:`{{label}}`});(0,Q.useLayoutEffect)(()=>{let t=r.current;if(!t||o.current)return;let n=PD(e.value,e.references),i=p();for(let e of n)a.current.set(e.key,e.chip);t.querySelectorAll(`[data-remove-reference]`).forEach(t=>{t.disabled=e.disabled??!1});let s=t.ownerDocument.activeElement===t,d=jD(t,i)??c.current;i.value===e.value&&FD(i.references,n)&&FD(l.current,n)&&u.current===b||(h({value:e.value,references:n,selection:d},`external`),g(e.value,n,s?d:null))}),(0,Q.useEffect)(()=>{let t=r.current;if(!t)return;t.ownerDocument.addEventListener(`selectionchange`,v);let n=e=>{e.inputType!==`historyUndo`&&e.inputType!==`historyRedo`||(e.preventDefault(),e.cancelable&&_(e.inputType===`historyUndo`?-1:1))};return t.addEventListener(`beforeinput`,n),e.autoFocus&&t.focus(),()=>{t.ownerDocument.removeEventListener(`selectionchange`,v),t.removeEventListener(`beforeinput`,n)}},[]);let x=(e,t)=>{let n=r.current,i=n?.ownerDocument.getSelection();if(!n||!i?.rangeCount||!i.anchorNode||!i.focusNode||!n.contains(i.anchorNode)||!n.contains(i.focusNode))return;m(jD(n,p())??c.current),d.current=t;let a=!1;try{a=n.ownerDocument.execCommand?.(e?`insertText`:`delete`,!1,e)??!1}catch{}if(!a){let t=i.getRangeAt(0);if(t.deleteContents(),e){let r=n.ownerDocument.createTextNode(e);t.insertNode(r),t.setStartAfter(r)}t.collapse(!0),i.removeAllRanges(),i.addRange(t)}y(t),d.current=null},S=e=>{let t=r.current;if(!t||i.current.disabled)return;let n=p(),a=n.references.find(t=>t.key===e);a&&(t.focus(),ND(t,n,a.start,a.end),x(``,`deleteAtomic`))},C=(e,t)=>{let n=r.current;if(!n)return;let a=p(),o=jD(n,a);!o||o[0]===o[1]||(e.preventDefault(),e.clipboardData.setData(`text/plain`,a.value.slice(...o)),t&&!i.current.disabled&&x(``,`deleteByCut`))};return(0,$.jsx)(`div`,{ref:r,role:`textbox`,"aria-label":e.ariaLabel??e.placeholder,"aria-multiline":`true`,"aria-disabled":e.disabled||void 0,"data-agent-interactive":!0,contentEditable:!e.disabled,suppressContentEditableWarning:!0,"data-placeholder":e.placeholder,"data-empty":e.value.length===0,title:e.title,className:`whitespace-pre-wrap break-words outline-none data-[empty=true]:before:pointer-events-none data-[empty=true]:before:text-foreground/35 data-[empty=true]:before:content-[attr(data-placeholder)] ${e.className??``}`,onInput:e=>y(e.nativeEvent.inputType||`insertText`),onCompositionStart:()=>{o.current=!0,s.current={value:i.current.value,references:i.current.references}},onCompositionEnd:()=>{o.current=!1;let e=s.current;s.current=null;let t=i.current;if(e&&(e.value!==t.value||!FD(e.references,t.references))){let e=PD(t.value,t.references),n=[t.value.length,t.value.length];h({value:t.value,references:e,selection:n},`external`),g(t.value,e,r.current?.ownerDocument.activeElement===r.current?n:null);return}y(`insertCompositionText`)},onKeyUp:v,onMouseUp:v,onMouseDown:e=>{e.target.closest(`[data-remove-reference]`)&&e.preventDefault()},onClick:e=>{let t=e.target.closest(`[data-remove-reference]`);t?.dataset.removeReference&&S(t.dataset.removeReference)},onKeyDown:e=>{if(!(i.current.disabled||o.current||e.nativeEvent.isComposing||e.keyCode===229)){if((e.metaKey||e.ctrlKey)&&!e.altKey&&(e.key.toLowerCase()===`z`||!e.metaKey&&e.key.toLowerCase()===`y`)){e.preventDefault(),_(e.shiftKey||e.key.toLowerCase()===`y`?1:-1);return}if(m(jD(r.current,p())??c.current),i.current.onKeyDown(e),!(e.defaultPrevented||i.current.disabled)){if(e.key===`Enter`)e.preventDefault(),x(`
|
|
37
37
|
`,`insertLineBreak`);else if(e.key===`Backspace`||e.key===`Delete`){let t=r.current,n=p(),i=jD(t,n);if(!i||i[0]!==i[1])return;let a=n.references.find(t=>e.key===`Backspace`?t.end===i[0]:t.start===i[0]);a&&(e.preventDefault(),S(a.key))}}}},onPaste:e=>{i.current.onPaste(e),!(e.defaultPrevented||i.current.disabled)&&(e.preventDefault(),x(e.clipboardData.getData(`text/plain`).replace(/\r\n?/g,`
|
|
38
38
|
`),`insertFromPaste`))},onCopy:e=>C(e,!1),onCut:e=>C(e,!0)})}),zD=Symbol(`radix.slottable`);function BD(e){let t=({children:e})=>(0,$.jsx)($.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=zD,t}var[VD,HD]=vn(`Tooltip`,[rT]),UD=rT(),WD=`TooltipProvider`,GD=700,KD=`tooltip.open`,[qD,JD]=VD(WD),YD=e=>{let{__scopeTooltip:t,delayDuration:n=GD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=Q.useRef(!0),s=Q.useRef(!1),c=Q.useRef(0);return Q.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,$.jsx)(qD,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:Q.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:Q.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:Q.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};YD.displayName=WD;var XD=`Tooltip`,[ZD,QD]=VD(XD),$D=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=JD(XD,e.__scopeTooltip),l=UD(t),[u,d]=Q.useState(null),f=Cn(),p=Q.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=Q.useRef(!1),[_,v]=Gn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(KD))):c.onClose(),a?.(e)},caller:XD}),y=Q.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=Q.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=Q.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=Q.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return Q.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,$.jsx)(yT,{...l,children:(0,$.jsx)(ZD,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:Q.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:Q.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};$D.displayName=XD;var eO=`TooltipTrigger`,tO=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=QD(eO,n),a=JD(eO,n),o=UD(n),s=gn(t,Q.useRef(null),i.onTriggerChange),c=Q.useRef(!1),l=Q.useRef(!1),u=Q.useCallback(()=>c.current=!1,[]);return Q.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,$.jsx)(bT,{asChild:!0,...o,children:(0,$.jsx)(_n.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:xn(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:xn(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:xn(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:xn(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:xn(e.onBlur,i.onClose),onClick:xn(e.onClick,i.onClose)})})});tO.displayName=eO;var nO=`TooltipPortal`,[rO,iO]=VD(nO,{forceMount:void 0}),aO=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=QD(nO,t);return(0,$.jsx)(rO,{scope:t,forceMount:n,children:(0,$.jsx)(Wn,{present:n||a.open,children:(0,$.jsx)(qn,{asChild:!0,container:i,children:r})})})};aO.displayName=nO;var oO=`TooltipContent`,sO=Q.forwardRef((e,t)=>{let n=iO(oO,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=QD(oO,e.__scopeTooltip);return(0,$.jsx)(Wn,{present:r||o.open,children:o.disableHoverableContent?(0,$.jsx)(fO,{side:i,...a,ref:t}):(0,$.jsx)(cO,{side:i,...a,ref:t})})}),cO=Q.forwardRef((e,t)=>{let n=QD(oO,e.__scopeTooltip),r=JD(oO,e.__scopeTooltip),i=Q.useRef(null),a=gn(t,i),[o,s]=Q.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=Q.useCallback(()=>{s(null),d(!1)},[d]),p=Q.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=gO(r,hO(r,n.getBoundingClientRect())),a=_O(t.getBoundingClientRect()),o=yO([...i,...a]);s(o),d(!0)},[d]);return Q.useEffect(()=>()=>f(),[f]),Q.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),Q.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!vO(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,$.jsx)(fO,{...e,ref:a})}),[lO,uO]=VD(XD,{isInside:!1}),dO=BD(`TooltipContent`),fO=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=QD(oO,n),l=UD(n),{onClose:u}=c;return Q.useEffect(()=>(document.addEventListener(KD,u),()=>document.removeEventListener(KD,u)),[u]),Q.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,$.jsx)(Kn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,$.jsxs)(xT,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,$.jsx)(dO,{children:r}),(0,$.jsx)(lO,{scope:n,isInside:!0,children:(0,$.jsx)(NT,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});sO.displayName=oO;var pO=`TooltipArrow`,mO=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=UD(n);return uO(pO,n).isInside?null:(0,$.jsx)(ST,{...i,...r,ref:t})});mO.displayName=pO;function hO(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function gO(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function _O(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function vO(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function yO(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),bO(t)}function bO(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xO=YD,SO=$D,CO=tO,wO=sO,TO=xO,EO=SO,DO=CO,OO=Q.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,$.jsx)(wO,{ref:r,sideOffset:t,className:X(`z-50 overflow-hidden rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n}));OO.displayName=wO.displayName;function kO(e){if(!Number.isFinite(e)||e<0)return`0s`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}var AO={"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 jO({process:e,accentVariant:t,onKill:n,onOpen:r}){let{t:i}=K(`agent`),a=NO(e),o=MO(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=s||e.status===`stopping`&&!e.stopError&&!e.error,f=l||!!e.stopError||e.status===`stopping`&&!!e.error,p=async()=>{if(!(d||o)){c(!0),u(!1);try{await n(e)}catch{u(!0)}finally{c(!1)}}};return(0,$.jsx)(TO,{delayDuration:150,children:(0,$.jsxs)(`span`,{"data-testid":`background-process-chip`,className:`inline-flex max-w-full items-center rounded-lg border text-[11px] ${AO[t]}`,children:[(0,$.jsxs)(EO,{children:[(0,$.jsx)(DO,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"aria-label":i(`backgroundProcess.open`,{command:e.command}),className:`inline-flex min-w-0 max-w-[340px] items-center gap-1.5 rounded-l-lg px-2 py-1 transition-colors hover:bg-background/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(dc,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`shrink-0 ${e.status===`failed`?`text-destructive`:`text-foreground/70`}`,children:i(`backgroundProcess.status.${d?`stopping`:e.status}`)}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.command}),(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground`,children:a})]})}),(0,$.jsxs)(OO,{children:[i(`backgroundProcess.open`,{command:e.command}),` · `,a]})]}),f&&(0,$.jsxs)(`span`,{role:`alert`,title:i(`backgroundProcess.stopFailed`),className:`flex shrink-0 items-center px-1 text-destructive`,children:[(0,$.jsx)(jo,{className:`h-3 w-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i(`backgroundProcess.stopFailed`)})]}),!o&&(0,$.jsx)(`button`,{type:`button`,disabled:d,"aria-label":i(`backgroundProcess.stopCommand`,{command:e.command}),title:i(`backgroundProcess.stopCommand`,{command:e.command}),onClick:e=>{e.preventDefault(),e.stopPropagation(),p()},className:`mr-1 rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive disabled:opacity-50`,children:d?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(mn,{className:`h-3 w-3`,"aria-hidden":!0})})]})})}function MO(e){return e.status===`exited`||e.status===`failed`||e.status===`killed`||e.status===`interrupted`}function NO(e){let[t,n]=(0,Q.useState)(Date.now()),r=MO(e);return(0,Q.useEffect)(()=>{if(n(Date.now()),r)return;let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[r,e.startedAt]),kO(Math.max(0,(e.endedAt??e.recoveredAt??t)-e.startedAt))}var PO=2e3,FO=512*1024,IO=1e3;function LO(e){return e.replace(/\x1b\][\s\S]*?(?:\x07|\x1b\\|$)/g,``).replace(/\x1b[PX^_][\s\S]*?(?:\x1b\\|$)/g,``).replace(/(?:\x1b\[|\x9b)[0-?]*[ -/]*[@-~]/g,``).replace(/\x1b[()][0-2A-Z]/g,``).replace(/\x1b[@-_]/g,``).replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g,``)}function RO(e){let t=[],n=0,r=e.length>PO;for(let i=e.length-1;i>=0&&t.length<PO;i--){let a=e[i],o=LO(a.line),s=o.slice(-4e3);if(o.length>s.length&&(r=!0),n+s.length>FO){r=!0;break}n+=s.length,t.push({...a,line:s})}return{lines:t.reverse(),truncated:r}}function zO(e){let t=new Date(e.at);return`[${Number.isNaN(t.getTime())?`—`:t.toLocaleTimeString(void 0,{hour12:!1})}] [${e.source}] ${e.line}`}function BO({process:e,onClose:t,onKill:n,onBack:r}){return(0,$.jsx)(VO,{process:e,onClose:t,onKill:n,onBack:r},Gx(e))}function VO({process:e,onClose:t,onKill:n,onBack:r}){let{t:i}=K(`agent`),a=Gx(e),o=(0,Q.useRef)(e);o.current=e;let[s,c]=(0,Q.useState)(e),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(!0),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(`all`),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),N=(0,Q.useRef)(null),P=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(P.current=!0,()=>{P.current=!1}),[]);let F=MO(e)?e:MO(s)?s:e.status===`stopping`&&s.status!==`stopping`?e:s,I=MO(F);(0,Q.useEffect)(()=>{I&&v(!1)},[I]);let L=D||F.status===`stopping`&&!F.error&&!e.stopError,R=NO(F);(0,Q.useEffect)(()=>{if(_){f(!1);return}let e=new AbortController,t,n=async()=>{try{let r=await Qx(o.current,{limit:PO,signal:e.signal});if(e.signal.aborted)return;if(Gx(r.process)!==a)throw Error(`Unexpected process identity`);let i=RO(r.lines);c(e=>JSON.stringify(e)===JSON.stringify(r.process)?e:r.process),u(e=>e.length===i.lines.length&&e.every((e,t)=>{let n=i.lines[t];return e.sequence===n.sequence&&e.line===n.line&&e.source===n.source&&e.at===n.at&&e.partial===n.partial})?e:i.lines),g(r.truncated||i.truncated),m(!1),f(!1),MO(r.process)||(t=setTimeout(()=>{n()},IO))}catch{if(e.signal.aborted)return;f(!1),m(!0)}};return f(!0),m(!1),n(),()=>{e.abort(),clearTimeout(t)}},[a,_,T]),(0,Q.useEffect)(()=>{if(!j)return;let e=setTimeout(()=>M(null),2500);return()=>clearTimeout(e)},[j]);let z=(0,Q.useMemo)(()=>{let e=x.toLocaleLowerCase();return l.filter(t=>(C===`all`||C===t.source)&&(!e||t.line.toLocaleLowerCase().includes(e)))},[l,x,C]),B=(0,Q.useMemo)(()=>z.map(zO).join(`
|
|
39
|
-
`),[z]);(0,Q.useEffect)(()=>{y&&!_&&N.current&&(N.current.scrollTop=N.current.scrollHeight)},[z,y,_]);let ee=async()=>{if(!(L||I)){O(!0),A(!1);try{await n(o.current)}catch{P.current&&A(!0)}finally{P.current&&O(!1)}}},V=async()=>{try{await navigator.clipboard.writeText(B),P.current&&M(`copied`)}catch{P.current&&M(`failed`)}},H=()=>{let t;try{t=URL.createObjectURL(new Blob([B],{type:`text/plain;charset=utf-8`}));let n=document.createElement(`a`);n.href=t,n.download=`process-${e.pid}-${e.startedAt}.log`,document.body.appendChild(n),n.click(),n.remove()}catch{M(`failed`)}finally{t&&URL.revokeObjectURL(t)}},te=`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-border/60 px-2 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary disabled:cursor-not-allowed disabled:opacity-40`;return(0,$.jsx)(Hn,{open:!0,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Dn,{children:[(0,$.jsx)(Vn,{className:`z-[80]`}),(0,$.jsxs)(Un,{"data-testid":`background-process-logs-modal`,className:`fixed left-1/2 top-1/2 z-[81] flex h-[min(780px,88vh)] w-[calc(100vw-2rem)] max-w-5xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/50 bg-popover text-foreground shadow-2xl focus:outline-none`,children:[(0,$.jsxs)(`header`,{className:`flex items-start gap-3 border-b border-border/50 px-4 py-3`,children:[r&&(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(`backgroundProcess.history.back`),title:i(`backgroundProcess.history.back`),className:`rounded-md p-1 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:(0,$.jsx)(Rt,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsx)(dc,{className:`mt-0.5 h-5 w-5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(Fn,{className:`text-sm font-semibold`,children:i(`backgroundProcess.logsTitle`)}),(0,$.jsx)(`span`,{"data-testid":`background-process-status`,className:`rounded-full px-2 py-0.5 text-[11px] ${F.status===`failed`?`bg-destructive/10 text-destructive`:I?`bg-muted text-muted-foreground`:`bg-accent-info/10 text-accent-info`}`,children:i(`backgroundProcess.status.${L?`stopping`:F.status}`)}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:R})]}),(0,$.jsx)(Mn,{className:`mt-1 text-xs text-muted-foreground`,children:i(`backgroundProcess.logsDescription`)})]}),(0,$.jsx)(Ln,{className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,"aria-label":i(`backgroundProcess.close`),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 border-b border-border/50 px-4 py-3 text-xs`,children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.command`)}),(0,$.jsx)(`dd`,{className:`break-all font-mono`,children:LO(F.command)}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.directory`)}),(0,$.jsx)(`dd`,{className:`break-all font-mono text-muted-foreground`,children:LO(F.cwd)}),(F.repositoryName||F.repositoryId)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.repository`)}),(0,$.jsx)(`dd`,{className:`break-all text-muted-foreground`,children:LO(F.repositoryName??F.repositoryId??``)})]}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`PID`}),(0,$.jsxs)(`dd`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:F.pid}),F.exitCode!=null&&(0,$.jsx)(`span`,{children:i(`backgroundProcess.exitCode`,{code:F.exitCode})}),F.signal&&(0,$.jsx)(`span`,{children:i(`backgroundProcess.signal`,{signal:F.signal})})]})]}),F.error&&(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:LO(F.error).slice(0,1e3)}),F.status===`interrupted`&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-700 dark:text-amber-300`,children:i(`backgroundProcess.interruptedHint`)}),F.persistenceError&&(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-700 dark:text-amber-300`,children:i(`backgroundProcess.persistenceFailed`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-2.5`,children:[(0,$.jsxs)(`label`,{className:`relative min-w-[150px] flex-1`,children:[(0,$.jsx)(ln,{className:`pointer-events-none absolute left-2.5 top-2 h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:x,onChange:e=>S(e.target.value),placeholder:i(`backgroundProcess.search`),"aria-label":i(`backgroundProcess.search`),className:`h-8 w-full rounded-md border border-border/60 bg-background/50 pl-8 pr-2 text-xs outline-none focus:border-accent-primary/60`})]}),(0,$.jsxs)(`select`,{"aria-label":i(`backgroundProcess.source`),value:C,onChange:e=>w(e.target.value),className:`h-8 rounded-md border border-border/60 bg-background px-2 text-xs outline-none focus:border-accent-primary/60`,children:[(0,$.jsx)(`option`,{value:`all`,children:i(`backgroundProcess.allSources`)}),(0,$.jsx)(`option`,{value:`stdout`,children:`stdout`}),(0,$.jsx)(`option`,{value:`stderr`,children:`stderr`})]}),!I&&(0,$.jsxs)(`button`,{type:`button`,className:te,"aria-pressed":_,onClick:()=>v(e=>!e),children:[_?(0,$.jsx)(on,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,$.jsx)(zs,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(_?`backgroundProcess.resume`:`backgroundProcess.pause`)]}),(0,$.jsxs)(`button`,{type:`button`,className:`${te} ${y?`border-accent-info/40 text-accent-info`:``}`,"aria-pressed":y,onClick:()=>b(e=>!e),children:[(0,$.jsx)(go,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`backgroundProcess.follow`)]}),(0,$.jsx)(`button`,{type:`button`,className:te,disabled:!z.length,onClick:()=>void V(),"aria-label":i(`backgroundProcess.copy`),title:i(`backgroundProcess.copy`),children:j===`copied`?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:te,disabled:!z.length,onClick:H,"aria-label":i(`backgroundProcess.download`),title:i(`backgroundProcess.download`),children:(0,$.jsx)(tn,{className:`h-3.5 w-3.5`})}),!I&&(0,$.jsxs)(`button`,{type:`button`,className:`${te} text-destructive`,disabled:L,onClick:()=>void ee(),children:[L?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(sn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(L?`backgroundProcess.status.stopping`:`backgroundProcess.stop`)]})]}),h&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-600 dark:text-amber-400`,children:i(`backgroundProcess.truncated`)}),_&&!I&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-muted/20 px-4 py-2 text-xs text-muted-foreground`,children:i(`backgroundProcess.paused`)}),p&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,$.jsx)(jo,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`backgroundProcess.loadFailed`)}),(0,$.jsx)(`button`,{type:`button`,className:te,onClick:()=>{v(!1),E(e=>e+1)},children:i(`backgroundProcess.retry`)})]}),(k||e.stopError)&&(0,$.jsx)(`p`,{role:`alert`,className:`bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:i(`backgroundProcess.stopFailed`)}),j&&(0,$.jsx)(`p`,{role:j===`failed`?`alert`:`status`,className:`px-4 py-1 text-xs text-muted-foreground`,children:i(j===`copied`?`backgroundProcess.copied`:`backgroundProcess.exportFailed`)}),(0,$.jsx)(`div`,{ref:N,"data-testid":`background-process-log-output`,"aria-label":i(`backgroundProcess.output`),role:`region`,tabIndex:0,onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.clientHeight-t.scrollTop>40&&b(!1)},className:`min-h-0 flex-1 overflow-auto bg-background/80 px-3 py-3 font-mono text-[11px] leading-5 outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent-primary/50`,children:d&&!l.length?(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 py-12 text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),i(`backgroundProcess.loading`)]}):z.length?z.map(e=>(0,$.jsxs)(`div`,{"data-log-source":e.source,className:`grid grid-cols-[auto_auto_minmax(0,1fr)] items-start gap-x-2 hover:bg-muted/20`,children:[(0,$.jsx)(`span`,{className:`select-none whitespace-nowrap text-[10px] text-muted-foreground/70`,children:new Date(e.at).toLocaleTimeString(void 0,{hour12:!1})}),(0,$.jsx)(`span`,{className:`select-none text-[10px] ${e.source===`stderr`?`text-amber-600 dark:text-amber-400`:`text-muted-foreground/60`}`,children:e.source}),(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${e.source===`stderr`?`text-amber-700 dark:text-amber-200`:`text-foreground/90`}`,children:e.line||`\xA0`})]},e.sequence)):!p&&(0,$.jsx)(`p`,{className:`py-12 text-center font-sans text-xs text-muted-foreground`,children:i(l.length?`backgroundProcess.noMatches`:`backgroundProcess.empty`)})}),(0,$.jsxs)(`footer`,{className:`flex flex-wrap justify-between gap-1 border-t border-border/50 px-4 py-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:i(`backgroundProcess.lineCount`,{count:z.length,total:l.length})}),(0,$.jsx)(`span`,{children:i(`backgroundProcess.exportHint`)})]})]})]})})}function HO({processes:e,loading:t,error:n,onRefresh:r,onClose:i,onKill:a}){let{t:o}=K(`agent`),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(100),[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{r()},[r]);let p=(0,Q.useMemo)(()=>{let t=s.trim().toLocaleLowerCase();return e.filter(e=>!t||[e.command,e.cwd,e.repositoryName,e.repositoryId,e.pid,o(`backgroundProcess.status.${e.status}`)].join(` `).toLocaleLowerCase().includes(t)).sort((e,t)=>Number(MO(e))-Number(MO(t))||t.startedAt-e.startedAt)},[e,s,o]);if(d)return(0,$.jsx)(BO,{process:e.find(e=>Gx(e)===Gx(d))??d,onClose:i,onBack:()=>f(null),onKill:a});let m=`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-border/60 px-2 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary disabled:opacity-40`;return(0,$.jsx)(Hn,{open:!0,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(Dn,{children:[(0,$.jsx)(Vn,{className:`z-[80]`}),(0,$.jsxs)(Un,{"data-testid":`background-process-history-modal`,className:`fixed left-1/2 top-1/2 z-[81] flex max-h-[85vh] w-[calc(100vw-2rem)] max-w-3xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/50 bg-popover text-foreground shadow-2xl focus:outline-none`,children:[(0,$.jsxs)(`header`,{className:`flex items-start gap-3 border-b border-border/50 px-4 py-3`,children:[(0,$.jsx)(dc,{className:`mt-0.5 h-5 w-5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(Fn,{className:`text-sm font-semibold`,children:o(`backgroundProcess.history.title`)}),(0,$.jsx)(Mn,{className:`mt-1 text-xs text-muted-foreground`,children:o(`backgroundProcess.history.description`)})]}),(0,$.jsx)(Ln,{className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,"aria-label":o(`backgroundProcess.history.close`),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 border-b border-border/50 px-4 py-3`,children:[(0,$.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,$.jsx)(ln,{className:`pointer-events-none absolute left-2.5 top-2 h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:s,onChange:e=>{c(e.target.value),u(100)},placeholder:o(`backgroundProcess.history.search`),"aria-label":o(`backgroundProcess.history.search`),className:`h-8 w-full rounded-md border border-border/60 bg-background/50 pl-8 pr-2 text-xs outline-none focus:border-accent-primary/60`})]}),(0,$.jsx)(`button`,{type:`button`,className:m,disabled:t,onClick:()=>void r(),"aria-label":o(`backgroundProcess.history.refresh`),title:o(`backgroundProcess.history.refresh`),children:(0,$.jsx)(Js,{className:`h-3.5 w-3.5 ${t?`animate-spin`:``}`,"aria-hidden":!0})})]}),n&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,$.jsx)(jo,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:o(`backgroundProcess.history.loadFailed`)}),(0,$.jsx)(`button`,{type:`button`,className:m,onClick:()=>void r(),children:o(`backgroundProcess.retry`)})]}),(0,$.jsxs)(`div`,{className:`min-h-[160px] overflow-y-auto p-2`,children:[p.slice(0,l).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>f(e),"aria-label":o(`backgroundProcess.open`,{command:e.command}),className:`flex w-full items-center gap-3 rounded-lg px-3 py-3 text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent-primary`,children:[(0,$.jsx)(dc,{className:`h-4 w-4 shrink-0 ${MO(e)?`text-muted-foreground`:`text-accent-info`}`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-mono text-xs text-foreground`,children:LO(e.command)}),(0,$.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:[LO(e.repositoryName??e.cwd),` · `,new Date(e.startedAt).toLocaleString(),` · PID `,e.pid]})]}),(0,$.jsx)(`span`,{className:`max-w-[35%] shrink-0 rounded-full px-2 py-0.5 text-[10px] ${e.status===`failed`?`bg-destructive/10 text-destructive`:MO(e)?`bg-muted text-muted-foreground`:`bg-accent-info/10 text-accent-info`}`,children:o(`backgroundProcess.status.${e.status}`)}),(0,$.jsx)(Qt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]},Gx(e))),t&&!e.length?(0,$.jsxs)(`p`,{role:`status`,className:`flex justify-center gap-2 py-12 text-xs text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),o(`backgroundProcess.history.loading`)]}):!n&&!p.length&&(0,$.jsx)(`p`,{className:`px-4 py-12 text-center text-xs text-muted-foreground`,children:o(s.trim()?`backgroundProcess.history.noMatches`:`backgroundProcess.history.empty`)}),p.length>l&&(0,$.jsx)(`div`,{className:`py-2 text-center`,children:(0,$.jsx)(`button`,{type:`button`,className:m,onClick:()=>u(e=>e+100),children:o(`backgroundProcess.history.showMore`)})})]}),(0,$.jsx)(`footer`,{className:`border-t border-border/50 px-4 py-2 text-[10px] text-muted-foreground`,children:o(`backgroundProcess.history.count`,{count:p.length})})]})]})})}function UO(){let[e,t]=(0,Q.useState)({available:{},availableIds:[],issues:{},launchDescriptors:{},loading:!0});return(0,Q.useEffect)(()=>{let e=!0;return fetch(`${He}/api/available-providers`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(n=>{if(!e)return;let r={};for(let[e,t]of Object.entries(n))e===`tiers`||e===`providerIssues`||e===`launchDescriptors`||typeof t==`boolean`&&(r[e]=t);let i=n.providerIssues&&typeof n.providerIssues==`object`?n.providerIssues:{},a=n.launchDescriptors&&typeof n.launchDescriptors==`object`?n.launchDescriptors:{};t({available:r,availableIds:Object.keys(r).filter(e=>r[e]),issues:i,launchDescriptors:a,loading:!1})}).catch(()=>{e&&t(e=>({...e,loading:!1}))}),()=>{e=!1}},[]),e}function WO(e,t,n,r,i){let a=i.length-(r-n);return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,references:t.flatMap(e=>e.end<=n?[e]:e.start>=r?[{...e,start:e.start+a,end:e.end+a}]:[])}}var GO=[],KO=[];function qO({autoFocus:e=!1,hideProjectSelector:t=!1,queueEditRequest:n}){let{t:r}=K(`agent`),{active:i,messages:a,conversations:o,isStreaming:s,providersReady:c,draftPinnedProjectId:l,draftProvider:u,draftModel:d,draftTierLevel:f,draftEffort:p,setEffort:m,send:h,abort:g,cycleTier:_,setProvider:v,setModel:y,setPinnedProject:b,materializeDraftConversation:x,queuedMessages:S,editQueuedMessage:C,wasQueueConsumed:w}=lM(),T=(0,Q.useMemo)(()=>S.filter(e=>e.deliveryMode!==`steer`),[S]),{pendingCaptures:E,consumePendingCaptures:D,openBrowser:O}=Ux(),{processes:k,history:A=k,historyLoading:j=!1,historyError:M=null,refreshHistory:N,kill:P}=iS(),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),z=(0,Q.useMemo)(()=>[...k].sort((e,t)=>Number(MO(e))-Number(MO(t))||t.startedAt-e.startedAt).slice(0,4),[k]),{projects:B,activeProjectId:ee}=at(),V=i?.pinned_project_id??l??ee,H=i?.id??`__new-mission__`,te=si(),ne=(0,Q.useRef)(null);ne.current!==H&&(Yr(H),ne.current=H),Pr(H);let[re,ie]=(0,Q.useState)(null),ae=re&&re.key===H?re:null,oe=ae?ae.text:Tr.get(H)??``,se=ae?GO:Dr.get(H)??GO,ce=Er.get(H)??KO,le=(e,t=[])=>Fr(H,e,t),[ue,de]=(0,Q.useState)(null),fe=(e,t)=>{let n=Er.get(e)??KO;Ir(e,typeof t==`function`?t(n):t)},[pe,me]=(0,Q.useState)(!1),[he,ge]=(0,Q.useState)(!1),_e=(0,Q.useRef)(!1),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),U=(0,Q.useMemo)(()=>[...new Map(se.map(({chip:e})=>[JSON.stringify([e.projectId,dS(e)]),e])).values()],[se]),[be,xe]=(0,Q.useState)(null),[Se,Ce]=(0,Q.useState)(0),[W,we]=(0,Q.useState)(!1),[Te,Ee]=(0,Q.useState)([]),[De,Oe]=(0,Q.useState)([]),Ae=ue!==null,je=(0,Q.useMemo)(()=>a.filter(e=>e.role===`user`).map(e=>e.content),[a]),Me=ae?.queueId??null,Ne=(0,Q.useRef)(``),Pe=Me===null?-1:T.findIndex(e=>e.queueId===Me),Fe=Pe>=0?T[Pe]:null,Ie=ae!==null;(0,Q.useEffect)(()=>{if(pe||he||Ie)return wy(H)},[H,pe,he,Ie]);let Le=c===!1||(i?!te.isEditable(i.id):!!te.current),Re=!Le&&!Ie,ze=i?.provider??u,{availableIds:Be}=UO(),G=(0,Q.useMemo)(()=>[ze,...Be].filter((e,t,n)=>n.indexOf(e)===t),[ze,Be]),Ve=i?i.pinned_project_id:l,Ue=Ve,We=be?.mode===`reference`?be.query.trim():``,Ge=`${Ue??``}:${We}`,[Ke,qe]=(0,Q.useState)({key:``,items:[]});(0,Q.useEffect)(()=>{let e=B.find(e=>e.id===Ue);if(!e||We.length<2)return;let t=new AbortController,n=setTimeout(()=>{let n=new URLSearchParams({kind:`find`,q:We,limit:`20`});fetch(`${He}/api/projects/${encodeURIComponent(e.id)}/code/discover?${n}`,{signal:t.signal}).then(async n=>{if(!n.ok)return;let r=await n.json();t.signal.aborted||qe({key:Ge,items:sS(e,r.matches??[])})}).catch(()=>{})},180);return()=>{clearTimeout(n),t.abort()}},[Ue,B,We,Ge]);let Je=(0,Q.useMemo)(()=>({projects:B,conversations:o,activeConversation:i,pinnedProjectId:Ue,activeProjectId:ee,tickets:Te,jobs:De,chips:U}),[B,o,i,Ue,ee,Te,De,U]),Ye=(0,Q.useMemo)(()=>be?[...ES(be.mode,Je),...be.mode===`reference`&&We.length>=2&&Ke.key===Ge?Ke.items:[]]:[],[be,Je,Ke,Ge,We]),Xe=(0,Q.useMemo)(()=>{if(!be)return[];let e=bS(Ye,be.query);return e.length>0?e:DS(be.mode,be.query)},[Ye,be]),Ze=be!==null&&!Ie,Qe=oe.trim().length>0||U.length>0,$e=[`accent-primary`,`accent-info`,`accent-highlight`],et=i?.id??null;(0,Q.useEffect)(()=>{I(null),R(null)},[et,V]),(0,Q.useEffect)(()=>{de(null),xe(null),we(!1),ie(null)},[et]),(0,Q.useEffect)(()=>{if(!Ue){Ee([]),Oe([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${He}/api/projects/${encodeURIComponent(Ue)}/tickets`),fetch(`${He}/api/projects/${encodeURIComponent(Ue)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;Ee(Array.isArray(r.tickets)?r.tickets:[]),Oe(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;Ee([]),Oe([])}})(),()=>{e=!1}},[Ue]),(0,Q.useEffect)(()=>{Ce(0)},[be?.mode,be?.query]),(0,Q.useEffect)(()=>{Se>=Xe.length&&Ce(Math.max(0,Xe.length-1))},[Se,Xe.length]),(0,Q.useEffect)(()=>{if(E.length===0)return;let e=D();e.length&&fe(H,t=>[...t,...e])},[E,D,H]);let tt=bD(ze),{models:q,efforts:nt,supportsImageInput:rt,customModelAliases:it}=tt,ot=(i?i.model:d)??q.find(e=>e.default)?.value??q[0]?.value??``,Y=lr(ze,ot),st=nt.filter(e=>Y.includes(e)),ct=i?i.reasoning_effort:p,lt=ct&&st.includes(ct)?ct:fr(ze,ot)??``,ut=e=>{Zr(e)},dt=async e=>{if(e.length===0)return;me(!0);let t=i;if(!t)try{t=await x(),ut(t.id)}catch(e){J.error(e instanceof Error?e.message:r(`workspace.uploadFailed`)),me(!1);return}for(let n of e){if(!rt&&n.type.startsWith(`image/`)){J.error(r(`imagesUnsupported`));continue}try{let e=await Ka(t.id,n);fe(t.id,t=>[...t,e])}catch(e){J.error(e instanceof Error?e.message:r(`workspace.uploadFailed`))}}me(!1)},ft=async e=>{try{i&&await Xa(i.id,e),fe(H,t=>t.filter(t=>t.id!==e))}catch(e){J.error(e instanceof Error?e.message:`Failed to remove attachment.`)}},pt=(e,t,n=se)=>{if(n.some(e=>t>e.start&&t<=e.end)){xe(null);return}let r=uS(e,t);xe(r),r&&we(!1)},ht=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,gt=e=>{requestAnimationFrame(()=>{ye.current?.focus(),ye.current?.setSelectionRange(e,e)})},_t=e=>{if(Ie)return;let t=ht(e),n=ye.current,r=n?.selectionStart??oe.length,i=n?.selectionEnd??r,a=WO(oe,se,r,i,t);le(a.text,a.references),de(null),we(!1),xe({mode:e,trigger:t,query:``,start:r,end:r+1}),gt(r+1)},vt=e=>{ye.current?.focus();let t=OS(oe,be,e),n=be?.start??oe.length,r=be?.end??n,i=t.text.slice(n,t.caret),{references:a}=WO(oe,se,n,r,i);if(e.chip){let t=n+i.indexOf(e.chip.token);a.push({key:crypto.randomUUID(),start:t,end:t+e.chip.token.length,chip:e.chip}),a.sort((e,t)=>e.start-t.start)}le(t.text,a),de(null),xe(null),we(!1),gt(t.caret)},yt=e=>{let t=T[e];t&&(Ne.current=t.text,ie({key:H,queueId:t.queueId,text:t.text}))},bt=e=>{Ae&&le(``),de(null),yt(e)};(0,Q.useEffect)(()=>{if(!n||n.conversationId!==i?.id)return;let e=T.findIndex(e=>e.queueId===n.queueId);e<0||(Ie?yt(e):bt(e),gt(T[e].text.length))},[n]);let xt=(e,t)=>{let n=t??oe;ie(null),e===`keep`&&le(n)},St=async()=>{let e=Fe,t=oe.trim();if(!(!e||!t))try{await C(e.queueId,t)===`saved`?xt(`restore`):(J.info(r(`queueEdit.dispatched`)),xt(`keep`))}catch{J.error(r(`queueEdit.saveFailed`))}};(0,Q.useEffect)(()=>{if(!ae||T.some(e=>e.queueId===ae.queueId))return;let e=oe!==Ne.current;w(ae.queueId)&&J.info(r(`queueEdit.dispatched`)),xt(e?`keep`:`restore`)},[Me,T,Ie]);let Ct=async()=>{if(Le||!Qe||_e.current)return;let e=oe.trim()||U.map(e=>e.token).join(` `),t={...ce.length?{attachmentIds:ce.map(e=>e.id)}:{},...U.length?{contextRefs:U.map(fS)}:{}},n=JSON.stringify([e,t]),i=Or.get(H),a=i?.signature===n?i:{signature:n,queueId:`q-${crypto.randomUUID()}`},o={text:oe,references:se,attachments:ce,submission:a};Lr(H,a),Br(H,o),xe(null),we(!1),de(null),_e.current=!0,ge(!0);try{let n=await h(e,{...t,queueId:a.queueId}),r=n.conversationId??H;if(!n.accepted){Lr(r,a),Vr(r,o);return}Lr(H,null),Lr(r,null)}catch(e){Vr(H,o),J.error(e instanceof Error?e.message:r(`queueEdit.saveFailed`))}finally{_e.current=!1,ge(!1)}},wt=e=>{if(je[e]===void 0){de(null);return}de(e),le(je[e])};return(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[i===null&&!t&&(0,$.jsx)(dD,{pinnedProjectId:l,onSelect:e=>void b(e)}),(0,$.jsx)(uD,{label:r(`provider.label`),value:ze,options:G.map(e=>({value:e,label:r(`provider.${e}`,{defaultValue:e})})),icon:So,onSelect:e=>{v(e).catch(()=>J.error(r(`error.generic`)))},testId:`agent-provider-selector`}),(0,$.jsx)(vD,{models:q,model:i?i.model:d,status:tt.status,customModelAliases:it,onSelect:e=>{y(e).catch(()=>J.error(r(`error.generic`)))}}),st.length>0&&(0,$.jsx)(uD,{label:r(`effort.label`),value:lt,options:st.map(e=>({value:e,label:r(`effort.${e}`)})),icon:ss,onSelect:e=>{m(e).catch(()=>J.error(r(`error.generic`)))},testId:`agent-effort-selector`}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(mD,{level:i?.tier_level??f,onCycle:()=>void _()})})]}),Ie&&Fe&&(0,$.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,$.jsx)(an,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:r(`queueEdit.editing`,{n:Pe+1,m:T.length})}),(0,$.jsx)(`span`,{className:`truncate text-foreground/45`,children:r(`queueEdit.hint`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>xt(`restore`),"aria-label":r(`queueEdit.cancel`),title:r(`queueEdit.cancel`),className:`ml-auto rounded-sm p-0.5 text-foreground/50 hover:bg-muted hover:text-foreground`,children:(0,$.jsx)(mn,{className:`h-3 w-3`})})]}),Ae&&(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,$.jsx)(hs,{className:`h-3 w-3`}),r(`history.hint`)]}),ce.length>0&&(0,$.jsx)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:ce.map(e=>(0,$.jsx)(oS,{conversationId:et,attachment:e,removeLabel:r(`close`),onRemove:()=>ft(e.id)},e.id))}),(k.length>0||et&&V)&&(0,$.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:[et&&V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>R({chatId:et,projectId:V}),"aria-label":r(`backgroundProcess.history.open`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border/50 px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(dc,{className:`h-3 w-3`,"aria-hidden":!0}),r(`backgroundProcess.history.button`),A.length>0&&(0,$.jsx)(`span`,{className:`font-mono text-[10px]`,children:A.length})]}),z.map((e,t)=>(0,$.jsx)(jO,{process:e,accentVariant:$e[t%$e.length],onKill:P,onOpen:I},Gx(e)))]}),(0,$.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border bg-background/60 px-3 py-2 ${Ie?`border-accent-highlight/50`:Ae?`border-accent-info/40`:`border-border/60`}`,onDragOver:e=>{Re&&e.preventDefault()},onDrop:e=>{if(!Re)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&dt(t)},children:[Ze&&(0,$.jsx)(TD,{items:Xe,mode:be.mode,query:be.query,activeIndex:Se,onActiveIndexChange:Ce,onSelect:vt}),Re&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`input`,{ref:ve,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&&dt(t),e.target.value=``}})}),!Ie&&(0,$.jsx)(ED,{open:W,canAttach:Re,uploading:pe,onToggle:()=>{we(e=>!e),xe(null)},onClose:()=>we(!1),onOpenMode:_t,onAttachFile:()=>{we(!1),ve.current?.click()},canBrowserCapture:ke()&&!!(Ue??ee),onOpenBrowser:()=>{we(!1),O()}}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(RD,{ref:ye,value:oe,references:Ie?[]:se,autoFocus:e,onChange:(e,t,n)=>{if(Ie){ie(t=>t&&{...t,text:e});return}Ae&&de(null),le(e,t),pt(e,n,t)},onSelect:e=>{Ie||pt(ye.current?.value??oe,e)},onKeyDown:e=>{if(e.nativeEvent.isComposing)return;if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),_();return}if(Ze){if(e.key===`ArrowDown`){e.preventDefault(),Xe.length>0&&Ce(e=>Math.min(Xe.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Xe.length>0&&Ce(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=Xe[Se]??Xe[0];t&&vt(t);return}if(e.key===`Escape`){e.preventDefault(),xe(null);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),Ie?St():Ct();return}if(e.key===`Escape`&&Ie){e.preventDefault(),e.stopPropagation(),xt(`restore`);return}let t=ye.current,n=t?.selectionStart===0&&t?.selectionEnd===0,r=t?.selectionStart===oe.length&&t?.selectionEnd===oe.length;if(e.key===`ArrowUp`){if(Ie){Fe!==null&&oe===Fe.text&&n&&Pe>0&&(e.preventDefault(),yt(Pe-1));return}if(T.length>0){n&&(e.preventDefault(),bt(T.length-1));return}!Ae&&oe===``&&je.length>0?(e.preventDefault(),wt(je.length-1)):Ae&&(e.preventDefault(),wt(Math.max(0,ue-1)));return}if(e.key===`ArrowDown`){if(Ie){Fe!==null&&oe===Fe.text&&r&&(e.preventDefault(),Pe<T.length-1?yt(Pe+1):xt(`restore`));return}if(T.length>0)return;Ae&&(e.preventDefault(),ue<je.length-1?wt(ue+1):(de(null),le(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&Ae&&de(null)},onPaste:e=>{if(!Re)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),dt(t))},disabled:Le,placeholder:r(Le?`noProvider.placeholder`:s?`queue.placeholder`:`composerPlaceholder`),title:Ie?r(`queueEdit.hint`):Ae?r(`history.hint`):void 0,className:`min-h-[3.25rem] max-h-64 min-w-0 w-full resize-y overflow-y-auto bg-transparent text-sm outline-none ${Ae?`italic text-foreground/50`:`text-foreground`}`},H)}),s&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":r(`stop`),title:r(`stop`),className:`rounded-lg bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(sn,{className:`h-4 w-4`,fill:`currentColor`})}),Ie?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void St(),disabled:Le||!oe.trim(),"aria-label":r(`queueEdit.save`),title:r(`queueEdit.save`),className:`rounded-lg bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,$.jsx)(Ht,{className:`h-4 w-4`})}):s?(0,$.jsx)(`button`,{type:`button`,onClick:Ct,disabled:Le||!Qe||he,"aria-label":r(`queue.send`),title:r(`queue.sendHint`),className:`relative rounded-lg bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(mt,{className:`h-4 w-4`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Ct,disabled:Le||!Qe||he,"aria-label":r(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,$.jsx)(mt,{className:`h-4 w-4`})})]}),Ve&&(0,$.jsx)(xD,{projectId:Ve}),F&&F.chatId===et&&F.projectId===V&&(0,$.jsx)(BO,{process:A.find(e=>Gx(e)===Gx(F))??F,onClose:()=>I(null),onKill:P}),L&&L.chatId===et&&L.projectId===V&&(0,$.jsx)(HO,{processes:A,loading:j,error:M,onRefresh:N,onClose:()=>R(null),onKill:P})]})}function JO({active:e,inset:t=-4,radius:n=`9999px`,className:r,fadeInMs:i=350,fadeOutMs:a=350}){let o=dy();return(0,$.jsx)(f_,{children:e&&(0,$.jsxs)(fy.span,{"aria-hidden":!0,"data-testid":`builder-halo`,"data-reduced-motion":o?`true`:void 0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{duration:i/1e3,ease:`easeOut`}},exit:{opacity:0,scale:1.15,transition:{duration:a/1e3,ease:`easeInOut`}},style:{inset:t},className:`pointer-events-none absolute ${r??``}`,children:[(0,$.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,$.jsx)(`span`,{className:`absolute left-1/2 top-1/2 aspect-square w-[250%] -translate-x-1/2 -translate-y-1/2 ${o?``:`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,$.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 YO=`specrails-desktop:effects`,XO=`specrails:effects-changed`,ZO={agentThinkingHalo:!0},QO=null;function $O(){try{let e=localStorage.getItem(YO);if(!e)return ZO;let t=JSON.parse(e);return{...ZO,...typeof t.agentThinkingHalo==`boolean`?{agentThinkingHalo:t.agentThinkingHalo}:{}}}catch{return ZO}}function ek(){return QO||=$O(),QO}function tk(e){let t={...ek(),...e};QO=t;try{localStorage.setItem(YO,JSON.stringify(t))}catch{}try{window.dispatchEvent(new CustomEvent(XO))}catch{}return t}function nk(e){let t=()=>{QO=null,e()};return window.addEventListener(XO,t),window.addEventListener(`storage`,t),()=>{window.removeEventListener(XO,t),window.removeEventListener(`storage`,t)}}function rk(){return(0,Q.useSyncExternalStore)(nk,ek,()=>ZO)}function ik({active:e,radius:t=`0.75rem`,inset:n=-3}){let{agentThinkingHalo:r}=rk();return r?(0,$.jsx)(`span`,{"data-testid":`agent-thinking-halo`,"data-active":e,className:`contents`,children:(0,$.jsx)(JO,{active:e,radius:t,inset:n,fadeInMs:450,fadeOutMs:800})}):null}var ak=e=>e===`running`||e===`queued`;function ok(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 sk(){try{return qe()}catch{return null}}var ck=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function lk(e,t,n){let{live:r}=n,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(()=>Date.now());(0,Q.useEffect)(()=>{let n=!1;return fetch(`${He}/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(ck(t.started_at)),d(ck(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=ak(o)&&u===null,C=sk(),w=(0,Q.useId)();return(0,Q.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(ck(n.timestamp)??Date.now())))}),()=>C.unregisterHandler(e)},[C,r,t,w]),(0,Q.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 uk(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var dk=15e3;function fk(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function pk(e){let{projectId:t,jobId:n,timeoutMs:r=dk}=e,i=t?`${He}/api/projects/${t}`:nt(),a;try{a=await fetch(`${i}/jobs/${n}/cancel`,{method:`POST`,signal:fk(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 mk=null;function hk(e){mk=e}function gk(e,t){mk?.(e,t)}var _k=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-CyFzkOM-.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([6,1,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,76]))),vk={building:nn,on_review:nn,pr_draft:R,pr_ready:R,no_changes:Mo,completed:Mo,pr_closed:en,superseded:R,implementation_failed:fn,pr_failed:fn,merged:ls,discarded:en},yk={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 bk({envelope:e}){let{t}=K(`agent`),n=ht(e);return n.units.length===0&&!n.partial?null:(0,$.jsxs)(`div`,{className:`mt-2 space-y-1.5`,"data-testid":`agent-pr-unit-evidence`,children:[n.partial&&(0,$.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,$.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,$.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 xk({prDeliveryId:e,projectId:t}){let{t:n}=K(`agent`),r=v(),{activeProjectId:i,setActiveProjectId:a}=at();return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let n=`/review/${e}`;i!==t&&(gk(t,n),a(t)),r(n)},"data-testid":`agent-pr-open-packet`,"data-agent-interactive":!0,title:n(`prCard.openReviewTooltip`),className:`inline-flex items-center gap-1 rounded-md border border-accent-primary/40 bg-accent-primary/10 px-2 py-1 text-[11px] font-medium text-accent-primary transition-colors hover:bg-accent-primary/20`,children:[(0,$.jsx)(Qo,{className:`h-3 w-3`}),n(`prCard.openReview`)]})}function Sk(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function Ck({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=K(`agent`),s=lk(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:ok(s.elapsedMs),u=s.costUsd!=null&&s.costUsd>0,d=(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-40`,children:`·`});return(0,Q.useEffect)(()=>{a?.(t,{paused:s.paused,pausedReason:s.pausedReason})},[a,t,s.paused,s.pausedReason]),(0,$.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,$.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,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:c}),d,(0,$.jsx)($s,{className:`h-3 w-3 shrink-0 opacity-70`}),l&&(0,$.jsxs)($.Fragment,{children:[d,(0,$.jsx)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runElapsedAria`,{elapsed:l}),children:l})]}),u&&(0,$.jsxs)($.Fragment,{children:[d,(0,$.jsxs)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runCostAria`,{cost:`$${s.costUsd.toFixed(2)}`}),children:[`$`,s.costUsd.toFixed(2)]})]})]})}function wk({envelope:e}){let{t}=K(`agent`),n=u(),{projects:r}=at(),{applyPrDecisionSnapshot:i}=lM(),{openWebView:a,canOpenWebView:o}=Se(),{openRef:s}=_b(),[c,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),k=D??e,A=At(k.projectId).has(k.prDeliveryId),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)({}),[I,L]=(0,Q.useState)(null),{decision:z,prUrl:B,prState:ee}=k,V=!!k.repositoryDeliveries?.length,H=ht(k),te=ft(k.statusCode,k.statusDetail),ne=k.operation==null&&te,re=r.find(e=>e.id===k.projectId)?.name??k.projectId,ie=z===`pr_draft`&&!B,ae=z===`building`&&ee===`pr-created`&&!!k.branch,se=k.prNumber?`#${k.prNumber}`:B?Sk(B):null,ce=H.terminal,le=dt(k.statusCode)?t(`common:prDeliveryStatus.${k.statusCode}`):null,ue=H.partial&&H.deliverableCount>0&&(z===`on_review`||z===`pr_draft`&&!B);(0,Q.useEffect)(()=>{O(null)},[e]),(0,Q.useEffect)(()=>{l(null),m(!1),g(!1),v(!1),b(!1),S(!1),w(!1),E(!1)},[z,B,k.prDeliveryId]);let de=(0,Q.useCallback)((e,t)=>{P(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),fe=async e=>{if(!I){L(e);try{let n=await pk({projectId:k.projectId,jobId:e,kind:`loop-run`});n.ok?J.info(t(`prCard.stopExecutionSent`)):J.error(t(`prCard.stopExecutionFailed`),{description:n.error})}finally{L(null)}}},pe=async(e,n)=>{if(d||c||k.operation||V&&!n&&[`create-pr`,`merge-local`,`publish`,`poll-merge`,`reopen`,`acknowledge-no-changes`].includes(e))return;let r=k.repositoryDeliveries?.find(e=>e.repositoryId===n),a=r?.integrationBranch??r?.baseBranch??k.baseBranch;l(e);try{let r=await oo(k.projectId,{prDeliveryId:k.prDeliveryId,action:e,expectedDecision:z,...n?{repositoryId:n}:{}}),o=null;if(r.snapshot){let e=so(k,r.snapshot);o=i(e),o!==`stale`&&O(e)}if(o===`stale`){J.info(t(`prCard.alreadyResolved`));return}if(r.kind===`recovering`)J.info(t(`common:prRecovery.inProgress`));else if(r.kind===`busy`)J.info(t(`prCard.operation.${r.operation??`inProgress`}`));else if(r.kind===`stale`)J.info(t(`prCard.alreadyResolved`));else if(r.kind===`blocked`)J.warning(r.reason===`dirty`?t(`prCard.mergeLocalBlockedDirty`,{base:r.base||a}):t(`prCard.mergeLocalBlockedBranch`,{base:r.base||a,current:r.current??`?`}));else if(r.kind===`failed`)J.error(t(`prCard.actionFailed`),{description:r.detail});else if(r.kind===`ok`&&e===`recover-and-retry`)if(r.deliveryVerified){let e=(r.verifiedSha??r.snapshot?.deliverySha??``).slice(0,8);J.success(t(`prCard.recoverAndRetryVerified`,{sha:e}))}else r.recoveryUnavailable||r.snapshot?.statusCode===`recovery_unavailable`?J.info(t(`prCard.recoveryUnavailable`),{description:t(`prCard.recoveryUnavailableBody`)}):J.warning(t(`prCard.recoveryStillBlocked`),{description:r.detail??void 0});else if(r.kind===`ok`&&e===`create-pr`&&H.retryablePush&&r.deliveryVerified){let e=(r.verifiedSha??r.snapshot?.deliverySha??k.deliverySha??``).slice(0,8);J.success(t(r.pushed?`prCard.retryPushVerified`:`prCard.commitAlreadyVerified`,{sha:e}))}else if(r.kind===`ok`&&e===`create-pr`&&r.detail)J.error(t(`prCard.deliveryNeedsAttention`),{description:r.detail});else if(r.kind===`ok`&&e===`poll-merge`&&r.deliveryVerified===!1)J.warning(t(`prCard.commitMissingRetry`));else if(r.kind===`ok`&&e===`poll-merge`&&r.deliveryVerified&&!r.merged){let e=(r.verifiedSha??r.snapshot?.deliverySha??k.deliverySha??``).slice(0,8);J.success(t(`prCard.prVerifiedWaiting`,{sha:e}))}else e===`poll-merge`&&!r.merged&&r.decision!==`pr_closed`?J.info(t(`prCard.notMergedYet`)):e===`merge-local`&&r.kind===`ok`&&r.decision===`merged`&&J.success(t(`prCard.mergedLocally`,{base:a}));r.kind===`ok`&&(e===`create-pr`||e===`discard`||e===`merge-local`||e===`recover-and-retry`)&&vt(k.projectId)}catch(e){J.error(t(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{l(null)}},he=async e=>{if(!(V&&!e)&&!(c||d||k.operation)){f(!0);try{let n=await(e?co(k.projectId,k.prDeliveryId,e):co(k.projectId,k.prDeliveryId));n.kind===`ok`?(J.success(t(`prCard.checkoutSuccess`,{branch:n.branch??pt(k)??``})),n.cleanupWarnings.length>0&&J.warning(t(`prCard.cleanupIncomplete`,{count:n.cleanupWarnings.length}),{description:n.cleanupWarnings.join(`
|
|
39
|
+
`),[z]);(0,Q.useEffect)(()=>{y&&!_&&N.current&&(N.current.scrollTop=N.current.scrollHeight)},[z,y,_]);let ee=async()=>{if(!(L||I)){O(!0),A(!1);try{await n(o.current)}catch{P.current&&A(!0)}finally{P.current&&O(!1)}}},V=async()=>{try{await navigator.clipboard.writeText(B),P.current&&M(`copied`)}catch{P.current&&M(`failed`)}},H=()=>{let t;try{t=URL.createObjectURL(new Blob([B],{type:`text/plain;charset=utf-8`}));let n=document.createElement(`a`);n.href=t,n.download=`process-${e.pid}-${e.startedAt}.log`,document.body.appendChild(n),n.click(),n.remove()}catch{M(`failed`)}finally{t&&URL.revokeObjectURL(t)}},te=`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-border/60 px-2 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary disabled:cursor-not-allowed disabled:opacity-40`;return(0,$.jsx)(Hn,{open:!0,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Dn,{children:[(0,$.jsx)(Vn,{className:`z-[80]`}),(0,$.jsxs)(Un,{"data-testid":`background-process-logs-modal`,className:`fixed left-1/2 top-1/2 z-[81] flex h-[min(780px,88vh)] w-[calc(100vw-2rem)] max-w-5xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/50 bg-popover text-foreground shadow-2xl focus:outline-none`,children:[(0,$.jsxs)(`header`,{className:`flex items-start gap-3 border-b border-border/50 px-4 py-3`,children:[r&&(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(`backgroundProcess.history.back`),title:i(`backgroundProcess.history.back`),className:`rounded-md p-1 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:(0,$.jsx)(Rt,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsx)(dc,{className:`mt-0.5 h-5 w-5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(Fn,{className:`text-sm font-semibold`,children:i(`backgroundProcess.logsTitle`)}),(0,$.jsx)(`span`,{"data-testid":`background-process-status`,className:`rounded-full px-2 py-0.5 text-[11px] ${F.status===`failed`?`bg-destructive/10 text-destructive`:I?`bg-muted text-muted-foreground`:`bg-accent-info/10 text-accent-info`}`,children:i(`backgroundProcess.status.${L?`stopping`:F.status}`)}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:R})]}),(0,$.jsx)(Mn,{className:`mt-1 text-xs text-muted-foreground`,children:i(`backgroundProcess.logsDescription`)})]}),(0,$.jsx)(Ln,{className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,"aria-label":i(`backgroundProcess.close`),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 border-b border-border/50 px-4 py-3 text-xs`,children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.command`)}),(0,$.jsx)(`dd`,{className:`break-all font-mono`,children:LO(F.command)}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.directory`)}),(0,$.jsx)(`dd`,{className:`break-all font-mono text-muted-foreground`,children:LO(F.cwd)}),(F.repositoryName||F.repositoryId)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:i(`backgroundProcess.repository`)}),(0,$.jsx)(`dd`,{className:`break-all text-muted-foreground`,children:LO(F.repositoryName??F.repositoryId??``)})]}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`PID`}),(0,$.jsxs)(`dd`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:F.pid}),F.exitCode!=null&&(0,$.jsx)(`span`,{children:i(`backgroundProcess.exitCode`,{code:F.exitCode})}),F.signal&&(0,$.jsx)(`span`,{children:i(`backgroundProcess.signal`,{signal:F.signal})})]})]}),F.error&&(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:LO(F.error).slice(0,1e3)}),F.status===`interrupted`&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-700 dark:text-amber-300`,children:i(`backgroundProcess.interruptedHint`)}),F.persistenceError&&(0,$.jsx)(`p`,{role:`alert`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-700 dark:text-amber-300`,children:i(`backgroundProcess.persistenceFailed`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-2.5`,children:[(0,$.jsxs)(`label`,{className:`relative min-w-[150px] flex-1`,children:[(0,$.jsx)(ln,{className:`pointer-events-none absolute left-2.5 top-2 h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:x,onChange:e=>S(e.target.value),placeholder:i(`backgroundProcess.search`),"aria-label":i(`backgroundProcess.search`),className:`h-8 w-full rounded-md border border-border/60 bg-background/50 pl-8 pr-2 text-xs outline-none focus:border-accent-primary/60`})]}),(0,$.jsxs)(`select`,{"aria-label":i(`backgroundProcess.source`),value:C,onChange:e=>w(e.target.value),className:`h-8 rounded-md border border-border/60 bg-background px-2 text-xs outline-none focus:border-accent-primary/60`,children:[(0,$.jsx)(`option`,{value:`all`,children:i(`backgroundProcess.allSources`)}),(0,$.jsx)(`option`,{value:`stdout`,children:`stdout`}),(0,$.jsx)(`option`,{value:`stderr`,children:`stderr`})]}),!I&&(0,$.jsxs)(`button`,{type:`button`,className:te,"aria-pressed":_,onClick:()=>v(e=>!e),children:[_?(0,$.jsx)(on,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,$.jsx)(zs,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(_?`backgroundProcess.resume`:`backgroundProcess.pause`)]}),(0,$.jsxs)(`button`,{type:`button`,className:`${te} ${y?`border-accent-info/40 text-accent-info`:``}`,"aria-pressed":y,onClick:()=>b(e=>!e),children:[(0,$.jsx)(go,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`backgroundProcess.follow`)]}),(0,$.jsx)(`button`,{type:`button`,className:te,disabled:!z.length,onClick:()=>void V(),"aria-label":i(`backgroundProcess.copy`),title:i(`backgroundProcess.copy`),children:j===`copied`?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:te,disabled:!z.length,onClick:H,"aria-label":i(`backgroundProcess.download`),title:i(`backgroundProcess.download`),children:(0,$.jsx)(tn,{className:`h-3.5 w-3.5`})}),!I&&(0,$.jsxs)(`button`,{type:`button`,className:`${te} text-destructive`,disabled:L,onClick:()=>void ee(),children:[L?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(sn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(L?`backgroundProcess.status.stopping`:`backgroundProcess.stop`)]})]}),h&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-amber-500/5 px-4 py-2 text-xs text-amber-600 dark:text-amber-400`,children:i(`backgroundProcess.truncated`)}),_&&!I&&(0,$.jsx)(`p`,{role:`status`,className:`border-b border-border/40 bg-muted/20 px-4 py-2 text-xs text-muted-foreground`,children:i(`backgroundProcess.paused`)}),p&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,$.jsx)(jo,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`backgroundProcess.loadFailed`)}),(0,$.jsx)(`button`,{type:`button`,className:te,onClick:()=>{v(!1),E(e=>e+1)},children:i(`backgroundProcess.retry`)})]}),(k||e.stopError)&&(0,$.jsx)(`p`,{role:`alert`,className:`bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:i(`backgroundProcess.stopFailed`)}),j&&(0,$.jsx)(`p`,{role:j===`failed`?`alert`:`status`,className:`px-4 py-1 text-xs text-muted-foreground`,children:i(j===`copied`?`backgroundProcess.copied`:`backgroundProcess.exportFailed`)}),(0,$.jsx)(`div`,{ref:N,"data-testid":`background-process-log-output`,"aria-label":i(`backgroundProcess.output`),role:`region`,tabIndex:0,onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.clientHeight-t.scrollTop>40&&b(!1)},className:`min-h-0 flex-1 overflow-auto bg-background/80 px-3 py-3 font-mono text-[11px] leading-5 outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent-primary/50`,children:d&&!l.length?(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center justify-center gap-2 py-12 text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),i(`backgroundProcess.loading`)]}):z.length?z.map(e=>(0,$.jsxs)(`div`,{"data-log-source":e.source,className:`grid grid-cols-[auto_auto_minmax(0,1fr)] items-start gap-x-2 hover:bg-muted/20`,children:[(0,$.jsx)(`span`,{className:`select-none whitespace-nowrap text-[10px] text-muted-foreground/70`,children:new Date(e.at).toLocaleTimeString(void 0,{hour12:!1})}),(0,$.jsx)(`span`,{className:`select-none text-[10px] ${e.source===`stderr`?`text-amber-600 dark:text-amber-400`:`text-muted-foreground/60`}`,children:e.source}),(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${e.source===`stderr`?`text-amber-700 dark:text-amber-200`:`text-foreground/90`}`,children:e.line||`\xA0`})]},e.sequence)):!p&&(0,$.jsx)(`p`,{className:`py-12 text-center font-sans text-xs text-muted-foreground`,children:i(l.length?`backgroundProcess.noMatches`:`backgroundProcess.empty`)})}),(0,$.jsxs)(`footer`,{className:`flex flex-wrap justify-between gap-1 border-t border-border/50 px-4 py-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:i(`backgroundProcess.lineCount`,{count:z.length,total:l.length})}),(0,$.jsx)(`span`,{children:i(`backgroundProcess.exportHint`)})]})]})]})})}function HO({processes:e,loading:t,error:n,onRefresh:r,onClose:i,onKill:a}){let{t:o}=K(`agent`),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(100),[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{r()},[r]);let p=(0,Q.useMemo)(()=>{let t=s.trim().toLocaleLowerCase();return e.filter(e=>!t||[e.command,e.cwd,e.repositoryName,e.repositoryId,e.pid,o(`backgroundProcess.status.${e.status}`)].join(` `).toLocaleLowerCase().includes(t)).sort((e,t)=>Number(MO(e))-Number(MO(t))||t.startedAt-e.startedAt)},[e,s,o]);if(d)return(0,$.jsx)(BO,{process:e.find(e=>Gx(e)===Gx(d))??d,onClose:i,onBack:()=>f(null),onKill:a});let m=`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-border/60 px-2 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary disabled:opacity-40`;return(0,$.jsx)(Hn,{open:!0,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(Dn,{children:[(0,$.jsx)(Vn,{className:`z-[80]`}),(0,$.jsxs)(Un,{"data-testid":`background-process-history-modal`,className:`fixed left-1/2 top-1/2 z-[81] flex max-h-[85vh] w-[calc(100vw-2rem)] max-w-3xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/50 bg-popover text-foreground shadow-2xl focus:outline-none`,children:[(0,$.jsxs)(`header`,{className:`flex items-start gap-3 border-b border-border/50 px-4 py-3`,children:[(0,$.jsx)(dc,{className:`mt-0.5 h-5 w-5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(Fn,{className:`text-sm font-semibold`,children:o(`backgroundProcess.history.title`)}),(0,$.jsx)(Mn,{className:`mt-1 text-xs text-muted-foreground`,children:o(`backgroundProcess.history.description`)})]}),(0,$.jsx)(Ln,{className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,"aria-label":o(`backgroundProcess.history.close`),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 border-b border-border/50 px-4 py-3`,children:[(0,$.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,$.jsx)(ln,{className:`pointer-events-none absolute left-2.5 top-2 h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:s,onChange:e=>{c(e.target.value),u(100)},placeholder:o(`backgroundProcess.history.search`),"aria-label":o(`backgroundProcess.history.search`),className:`h-8 w-full rounded-md border border-border/60 bg-background/50 pl-8 pr-2 text-xs outline-none focus:border-accent-primary/60`})]}),(0,$.jsx)(`button`,{type:`button`,className:m,disabled:t,onClick:()=>void r(),"aria-label":o(`backgroundProcess.history.refresh`),title:o(`backgroundProcess.history.refresh`),children:(0,$.jsx)(Js,{className:`h-3.5 w-3.5 ${t?`animate-spin`:``}`,"aria-hidden":!0})})]}),n&&(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 border-b border-border/40 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,$.jsx)(jo,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:o(`backgroundProcess.history.loadFailed`)}),(0,$.jsx)(`button`,{type:`button`,className:m,onClick:()=>void r(),children:o(`backgroundProcess.retry`)})]}),(0,$.jsxs)(`div`,{className:`min-h-[160px] overflow-y-auto p-2`,children:[p.slice(0,l).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>f(e),"aria-label":o(`backgroundProcess.open`,{command:e.command}),className:`flex w-full items-center gap-3 rounded-lg px-3 py-3 text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent-primary`,children:[(0,$.jsx)(dc,{className:`h-4 w-4 shrink-0 ${MO(e)?`text-muted-foreground`:`text-accent-info`}`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-mono text-xs text-foreground`,children:LO(e.command)}),(0,$.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:[LO(e.repositoryName??e.cwd),` · `,new Date(e.startedAt).toLocaleString(),` · PID `,e.pid]})]}),(0,$.jsx)(`span`,{className:`max-w-[35%] shrink-0 rounded-full px-2 py-0.5 text-[10px] ${e.status===`failed`?`bg-destructive/10 text-destructive`:MO(e)?`bg-muted text-muted-foreground`:`bg-accent-info/10 text-accent-info`}`,children:o(`backgroundProcess.status.${e.status}`)}),(0,$.jsx)(Qt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]},Gx(e))),t&&!e.length?(0,$.jsxs)(`p`,{role:`status`,className:`flex justify-center gap-2 py-12 text-xs text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),o(`backgroundProcess.history.loading`)]}):!n&&!p.length&&(0,$.jsx)(`p`,{className:`px-4 py-12 text-center text-xs text-muted-foreground`,children:o(s.trim()?`backgroundProcess.history.noMatches`:`backgroundProcess.history.empty`)}),p.length>l&&(0,$.jsx)(`div`,{className:`py-2 text-center`,children:(0,$.jsx)(`button`,{type:`button`,className:m,onClick:()=>u(e=>e+100),children:o(`backgroundProcess.history.showMore`)})})]}),(0,$.jsx)(`footer`,{className:`border-t border-border/50 px-4 py-2 text-[10px] text-muted-foreground`,children:o(`backgroundProcess.history.count`,{count:p.length})})]})]})})}function UO(){let[e,t]=(0,Q.useState)({available:{},availableIds:[],issues:{},launchDescriptors:{},loading:!0});return(0,Q.useEffect)(()=>{let e=!0;return fetch(`${He}/api/available-providers`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(n=>{if(!e)return;let r={};for(let[e,t]of Object.entries(n))e===`tiers`||e===`providerIssues`||e===`launchDescriptors`||typeof t==`boolean`&&(r[e]=t);let i=n.providerIssues&&typeof n.providerIssues==`object`?n.providerIssues:{},a=n.launchDescriptors&&typeof n.launchDescriptors==`object`?n.launchDescriptors:{};t({available:r,availableIds:Object.keys(r).filter(e=>r[e]),issues:i,launchDescriptors:a,loading:!1})}).catch(()=>{e&&t(e=>({...e,loading:!1}))}),()=>{e=!1}},[]),e}function WO(e,t,n,r,i){let a=i.length-(r-n);return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,references:t.flatMap(e=>e.end<=n?[e]:e.start>=r?[{...e,start:e.start+a,end:e.end+a}]:[])}}var GO=[],KO=[];function qO({autoFocus:e=!1,hideProjectSelector:t=!1,queueEditRequest:n}){let{t:r}=K(`agent`),{active:i,messages:a,conversations:o,isStreaming:s,providersReady:c,draftPinnedProjectId:l,draftProvider:u,draftModel:d,draftTierLevel:f,draftEffort:p,setEffort:m,send:h,abort:g,cycleTier:_,setProvider:v,setModel:y,setPinnedProject:b,materializeDraftConversation:x,queuedMessages:S,editQueuedMessage:C,wasQueueConsumed:w}=lM(),T=(0,Q.useMemo)(()=>S.filter(e=>e.deliveryMode!==`steer`),[S]),{pendingCaptures:E,consumePendingCaptures:D,openBrowser:O}=Ux(),{processes:k,history:A=k,historyLoading:j=!1,historyError:M=null,refreshHistory:N,kill:P}=iS(),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),z=(0,Q.useMemo)(()=>[...k].sort((e,t)=>Number(MO(e))-Number(MO(t))||t.startedAt-e.startedAt).slice(0,4),[k]),{projects:B,activeProjectId:ee}=at(),V=i?.pinned_project_id??l??ee,H=i?.id??`__new-mission__`,te=si(),ne=(0,Q.useRef)(null);ne.current!==H&&(Yr(H),ne.current=H),Pr(H);let[re,ie]=(0,Q.useState)(null),ae=re&&re.key===H?re:null,oe=ae?ae.text:Tr.get(H)??``,se=ae?GO:Dr.get(H)??GO,ce=Er.get(H)??KO,le=(e,t=[])=>Fr(H,e,t),[ue,de]=(0,Q.useState)(null),fe=(e,t)=>{let n=Er.get(e)??KO;Ir(e,typeof t==`function`?t(n):t)},[pe,me]=(0,Q.useState)(!1),[he,ge]=(0,Q.useState)(!1),_e=(0,Q.useRef)(!1),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),U=(0,Q.useMemo)(()=>[...new Map(se.map(({chip:e})=>[JSON.stringify([e.projectId,dS(e)]),e])).values()],[se]),[be,xe]=(0,Q.useState)(null),[Se,Ce]=(0,Q.useState)(0),[W,we]=(0,Q.useState)(!1),[Te,Ee]=(0,Q.useState)([]),[De,Oe]=(0,Q.useState)([]),Ae=ue!==null,je=(0,Q.useMemo)(()=>a.filter(e=>e.role===`user`).map(e=>e.content),[a]),Me=ae?.queueId??null,Ne=(0,Q.useRef)(``),Pe=Me===null?-1:T.findIndex(e=>e.queueId===Me),Fe=Pe>=0?T[Pe]:null,Ie=ae!==null;(0,Q.useEffect)(()=>{if(pe||he||Ie)return wy(H)},[H,pe,he,Ie]);let Le=c===!1||(i?!te.isEditable(i.id):!!te.current),Re=!Le&&!Ie,ze=i?.provider??u,{availableIds:Be}=UO(),G=(0,Q.useMemo)(()=>[ze,...Be].filter((e,t,n)=>n.indexOf(e)===t),[ze,Be]),Ve=i?i.pinned_project_id:l,Ue=Ve,We=be?.mode===`reference`?be.query.trim():``,Ge=`${Ue??``}:${We}`,[Ke,qe]=(0,Q.useState)({key:``,items:[]});(0,Q.useEffect)(()=>{let e=B.find(e=>e.id===Ue);if(!e||We.length<2)return;let t=new AbortController,n=setTimeout(()=>{let n=new URLSearchParams({kind:`find`,q:We,limit:`20`});fetch(`${He}/api/projects/${encodeURIComponent(e.id)}/code/discover?${n}`,{signal:t.signal}).then(async n=>{if(!n.ok)return;let r=await n.json();t.signal.aborted||qe({key:Ge,items:sS(e,r.matches??[])})}).catch(()=>{})},180);return()=>{clearTimeout(n),t.abort()}},[Ue,B,We,Ge]);let Je=(0,Q.useMemo)(()=>({projects:B,conversations:o,activeConversation:i,pinnedProjectId:Ue,activeProjectId:ee,tickets:Te,jobs:De,chips:U}),[B,o,i,Ue,ee,Te,De,U]),Ye=(0,Q.useMemo)(()=>be?[...ES(be.mode,Je),...be.mode===`reference`&&We.length>=2&&Ke.key===Ge?Ke.items:[]]:[],[be,Je,Ke,Ge,We]),Xe=(0,Q.useMemo)(()=>{if(!be)return[];let e=bS(Ye,be.query);return e.length>0?e:DS(be.mode,be.query)},[Ye,be]),Ze=be!==null&&!Ie,Qe=oe.trim().length>0||U.length>0,$e=[`accent-primary`,`accent-info`,`accent-highlight`],et=i?.id??null;(0,Q.useEffect)(()=>{I(null),R(null)},[et,V]),(0,Q.useEffect)(()=>{de(null),xe(null),we(!1),ie(null)},[et]),(0,Q.useEffect)(()=>{if(!Ue){Ee([]),Oe([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${He}/api/projects/${encodeURIComponent(Ue)}/tickets`),fetch(`${He}/api/projects/${encodeURIComponent(Ue)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;Ee(Array.isArray(r.tickets)?r.tickets:[]),Oe(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;Ee([]),Oe([])}})(),()=>{e=!1}},[Ue]),(0,Q.useEffect)(()=>{Ce(0)},[be?.mode,be?.query]),(0,Q.useEffect)(()=>{Se>=Xe.length&&Ce(Math.max(0,Xe.length-1))},[Se,Xe.length]),(0,Q.useEffect)(()=>{if(E.length===0)return;let e=D();e.length&&fe(H,t=>[...t,...e])},[E,D,H]);let tt=bD(ze),{models:q,efforts:nt,supportsImageInput:rt,customModelAliases:it}=tt,ot=(i?i.model:d)??q.find(e=>e.default)?.value??q[0]?.value??``,Y=lr(ze,ot),st=nt.filter(e=>Y.includes(e)),ct=i?i.reasoning_effort:p,lt=ct&&st.includes(ct)?ct:fr(ze,ot)??``,ut=e=>{Zr(e)},dt=async e=>{if(e.length===0)return;me(!0);let t=i;if(!t)try{t=await x(),ut(t.id)}catch(e){J.error(e instanceof Error?e.message:r(`workspace.uploadFailed`)),me(!1);return}for(let n of e){if(!rt&&n.type.startsWith(`image/`)){J.error(r(`imagesUnsupported`));continue}try{let e=await Ka(t.id,n);fe(t.id,t=>[...t,e])}catch(e){J.error(e instanceof Error?e.message:r(`workspace.uploadFailed`))}}me(!1)},ft=async e=>{try{i&&await Xa(i.id,e),fe(H,t=>t.filter(t=>t.id!==e))}catch(e){J.error(e instanceof Error?e.message:`Failed to remove attachment.`)}},pt=(e,t,n=se)=>{if(n.some(e=>t>e.start&&t<=e.end)){xe(null);return}let r=uS(e,t);xe(r),r&&we(!1)},ht=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,gt=e=>{requestAnimationFrame(()=>{ye.current?.focus(),ye.current?.setSelectionRange(e,e)})},_t=e=>{if(Ie)return;let t=ht(e),n=ye.current,r=n?.selectionStart??oe.length,i=n?.selectionEnd??r,a=WO(oe,se,r,i,t);le(a.text,a.references),de(null),we(!1),xe({mode:e,trigger:t,query:``,start:r,end:r+1}),gt(r+1)},vt=e=>{ye.current?.focus();let t=OS(oe,be,e),n=be?.start??oe.length,r=be?.end??n,i=t.text.slice(n,t.caret),{references:a}=WO(oe,se,n,r,i);if(e.chip){let t=n+i.indexOf(e.chip.token);a.push({key:crypto.randomUUID(),start:t,end:t+e.chip.token.length,chip:e.chip}),a.sort((e,t)=>e.start-t.start)}le(t.text,a),de(null),xe(null),we(!1),gt(t.caret)},yt=e=>{let t=T[e];t&&(Ne.current=t.text,ie({key:H,queueId:t.queueId,text:t.text}))},bt=e=>{Ae&&le(``),de(null),yt(e)};(0,Q.useEffect)(()=>{if(!n||n.conversationId!==i?.id)return;let e=T.findIndex(e=>e.queueId===n.queueId);e<0||(Ie?yt(e):bt(e),gt(T[e].text.length))},[n]);let xt=(e,t)=>{let n=t??oe;ie(null),e===`keep`&&le(n)},St=async()=>{let e=Fe,t=oe.trim();if(!(!e||!t))try{await C(e.queueId,t)===`saved`?xt(`restore`):(J.info(r(`queueEdit.dispatched`)),xt(`keep`))}catch{J.error(r(`queueEdit.saveFailed`))}};(0,Q.useEffect)(()=>{if(!ae||T.some(e=>e.queueId===ae.queueId))return;let e=oe!==Ne.current;w(ae.queueId)&&J.info(r(`queueEdit.dispatched`)),xt(e?`keep`:`restore`)},[Me,T,Ie]);let Ct=async()=>{if(Le||!Qe||_e.current)return;let e=oe.trim()||U.map(e=>e.token).join(` `),t={...ce.length?{attachmentIds:ce.map(e=>e.id)}:{},...U.length?{contextRefs:U.map(fS)}:{}},n=JSON.stringify([e,t]),i=Or.get(H),a=i?.signature===n?i:{signature:n,queueId:`q-${crypto.randomUUID()}`},o={text:oe,references:se,attachments:ce,submission:a};Lr(H,a),Br(H,o),xe(null),we(!1),de(null),_e.current=!0,ge(!0);try{let n=await h(e,{...t,queueId:a.queueId}),r=n.conversationId??H;if(!n.accepted){Lr(r,a),Vr(r,o);return}Lr(H,null),Lr(r,null)}catch(e){Vr(H,o),J.error(e instanceof Error?e.message:r(`queueEdit.saveFailed`))}finally{_e.current=!1,ge(!1)}},wt=e=>{if(je[e]===void 0){de(null);return}de(e),le(je[e])};return(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[i===null&&!t&&(0,$.jsx)(dD,{pinnedProjectId:l,onSelect:e=>void b(e)}),(0,$.jsx)(uD,{label:r(`provider.label`),value:ze,options:G.map(e=>({value:e,label:r(`provider.${e}`,{defaultValue:e})})),icon:So,onSelect:e=>{v(e).catch(()=>J.error(r(`error.generic`)))},testId:`agent-provider-selector`}),(0,$.jsx)(vD,{models:q,model:i?i.model:d,status:tt.status,customModelAliases:it,onSelect:e=>{y(e).catch(()=>J.error(r(`error.generic`)))}}),st.length>0&&(0,$.jsx)(uD,{label:r(`effort.label`),value:lt,options:st.map(e=>({value:e,label:r(`effort.${e}`)})),icon:ss,onSelect:e=>{m(e).catch(()=>J.error(r(`error.generic`)))},testId:`agent-effort-selector`}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(mD,{level:i?.tier_level??f,onCycle:()=>void _()})})]}),Ie&&Fe&&(0,$.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,$.jsx)(an,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:r(`queueEdit.editing`,{n:Pe+1,m:T.length})}),(0,$.jsx)(`span`,{className:`truncate text-foreground/45`,children:r(`queueEdit.hint`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>xt(`restore`),"aria-label":r(`queueEdit.cancel`),title:r(`queueEdit.cancel`),className:`ml-auto rounded-sm p-0.5 text-foreground/50 hover:bg-muted hover:text-foreground`,children:(0,$.jsx)(mn,{className:`h-3 w-3`})})]}),Ae&&(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,$.jsx)(hs,{className:`h-3 w-3`}),r(`history.hint`)]}),ce.length>0&&(0,$.jsx)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:ce.map(e=>(0,$.jsx)(oS,{conversationId:et,attachment:e,removeLabel:r(`close`),onRemove:()=>ft(e.id)},e.id))}),(k.length>0||et&&V)&&(0,$.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:[et&&V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>R({chatId:et,projectId:V}),"aria-label":r(`backgroundProcess.history.open`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border/50 px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(dc,{className:`h-3 w-3`,"aria-hidden":!0}),r(`backgroundProcess.history.button`),A.length>0&&(0,$.jsx)(`span`,{className:`font-mono text-[10px]`,children:A.length})]}),z.map((e,t)=>(0,$.jsx)(jO,{process:e,accentVariant:$e[t%$e.length],onKill:P,onOpen:I},Gx(e)))]}),(0,$.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border bg-background/60 px-3 py-2 ${Ie?`border-accent-highlight/50`:Ae?`border-accent-info/40`:`border-border/60`}`,onDragOver:e=>{Re&&e.preventDefault()},onDrop:e=>{if(!Re)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&dt(t)},children:[Ze&&(0,$.jsx)(TD,{items:Xe,mode:be.mode,query:be.query,activeIndex:Se,onActiveIndexChange:Ce,onSelect:vt}),Re&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`input`,{ref:ve,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&&dt(t),e.target.value=``}})}),!Ie&&(0,$.jsx)(ED,{open:W,canAttach:Re,uploading:pe,onToggle:()=>{we(e=>!e),xe(null)},onClose:()=>we(!1),onOpenMode:_t,onAttachFile:()=>{we(!1),ve.current?.click()},canBrowserCapture:ke()&&!!(Ue??ee),onOpenBrowser:()=>{we(!1),O()}}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(RD,{ref:ye,value:oe,references:Ie?[]:se,autoFocus:e,onChange:(e,t,n)=>{if(Ie){ie(t=>t&&{...t,text:e});return}Ae&&de(null),le(e,t),pt(e,n,t)},onSelect:e=>{Ie||pt(ye.current?.value??oe,e)},onKeyDown:e=>{if(e.nativeEvent.isComposing)return;if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),_();return}if(Ze){if(e.key===`ArrowDown`){e.preventDefault(),Xe.length>0&&Ce(e=>Math.min(Xe.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Xe.length>0&&Ce(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=Xe[Se]??Xe[0];t&&vt(t);return}if(e.key===`Escape`){e.preventDefault(),xe(null);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),Ie?St():Ct();return}if(e.key===`Escape`&&Ie){e.preventDefault(),e.stopPropagation(),xt(`restore`);return}let t=ye.current,n=t?.selectionStart===0&&t?.selectionEnd===0,r=t?.selectionStart===oe.length&&t?.selectionEnd===oe.length;if(e.key===`ArrowUp`){if(Ie){Fe!==null&&oe===Fe.text&&n&&Pe>0&&(e.preventDefault(),yt(Pe-1));return}if(T.length>0){n&&(e.preventDefault(),bt(T.length-1));return}!Ae&&oe===``&&je.length>0?(e.preventDefault(),wt(je.length-1)):Ae&&(e.preventDefault(),wt(Math.max(0,ue-1)));return}if(e.key===`ArrowDown`){if(Ie){Fe!==null&&oe===Fe.text&&r&&(e.preventDefault(),Pe<T.length-1?yt(Pe+1):xt(`restore`));return}if(T.length>0)return;Ae&&(e.preventDefault(),ue<je.length-1?wt(ue+1):(de(null),le(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&Ae&&de(null)},onPaste:e=>{if(!Re)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),dt(t))},disabled:Le,placeholder:r(Le?`noProvider.placeholder`:s?`queue.placeholder`:`composerPlaceholder`),title:Ie?r(`queueEdit.hint`):Ae?r(`history.hint`):void 0,className:`min-h-[3.25rem] max-h-64 min-w-0 w-full resize-y overflow-y-auto bg-transparent text-sm outline-none ${Ae?`italic text-foreground/50`:`text-foreground`}`},H)}),s&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":r(`stop`),title:r(`stop`),className:`rounded-lg bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(sn,{className:`h-4 w-4`,fill:`currentColor`})}),Ie?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void St(),disabled:Le||!oe.trim(),"aria-label":r(`queueEdit.save`),title:r(`queueEdit.save`),className:`rounded-lg bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,$.jsx)(Ht,{className:`h-4 w-4`})}):s?(0,$.jsx)(`button`,{type:`button`,onClick:Ct,disabled:Le||!Qe||he,"aria-label":r(`queue.send`),title:r(`queue.sendHint`),className:`relative rounded-lg bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(mt,{className:`h-4 w-4`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Ct,disabled:Le||!Qe||he,"aria-label":r(`send`),className:`rounded-lg bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,$.jsx)(mt,{className:`h-4 w-4`})})]}),Ve&&(0,$.jsx)(xD,{projectId:Ve}),F&&F.chatId===et&&F.projectId===V&&(0,$.jsx)(BO,{process:A.find(e=>Gx(e)===Gx(F))??F,onClose:()=>I(null),onKill:P}),L&&L.chatId===et&&L.projectId===V&&(0,$.jsx)(HO,{processes:A,loading:j,error:M,onRefresh:N,onClose:()=>R(null),onKill:P})]})}function JO({active:e,inset:t=-4,radius:n=`9999px`,className:r,fadeInMs:i=350,fadeOutMs:a=350}){let o=dy();return(0,$.jsx)(f_,{children:e&&(0,$.jsxs)(fy.span,{"aria-hidden":!0,"data-testid":`builder-halo`,"data-reduced-motion":o?`true`:void 0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{duration:i/1e3,ease:`easeOut`}},exit:{opacity:0,scale:1.15,transition:{duration:a/1e3,ease:`easeInOut`}},style:{inset:t},className:`pointer-events-none absolute ${r??``}`,children:[(0,$.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,$.jsx)(`span`,{className:`absolute left-1/2 top-1/2 aspect-square w-[250%] -translate-x-1/2 -translate-y-1/2 ${o?``:`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,$.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 YO=`specrails-desktop:effects`,XO=`specrails:effects-changed`,ZO={agentThinkingHalo:!0},QO=null;function $O(){try{let e=localStorage.getItem(YO);if(!e)return ZO;let t=JSON.parse(e);return{...ZO,...typeof t.agentThinkingHalo==`boolean`?{agentThinkingHalo:t.agentThinkingHalo}:{}}}catch{return ZO}}function ek(){return QO||=$O(),QO}function tk(e){let t={...ek(),...e};QO=t;try{localStorage.setItem(YO,JSON.stringify(t))}catch{}try{window.dispatchEvent(new CustomEvent(XO))}catch{}return t}function nk(e){let t=()=>{QO=null,e()};return window.addEventListener(XO,t),window.addEventListener(`storage`,t),()=>{window.removeEventListener(XO,t),window.removeEventListener(`storage`,t)}}function rk(){return(0,Q.useSyncExternalStore)(nk,ek,()=>ZO)}function ik({active:e,radius:t=`0.75rem`,inset:n=-3}){let{agentThinkingHalo:r}=rk();return r?(0,$.jsx)(`span`,{"data-testid":`agent-thinking-halo`,"data-active":e,className:`contents`,children:(0,$.jsx)(JO,{active:e,radius:t,inset:n,fadeInMs:450,fadeOutMs:800})}):null}var ak=e=>e===`running`||e===`queued`;function ok(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 sk(){try{return qe()}catch{return null}}var ck=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function lk(e,t,n){let{live:r}=n,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(()=>Date.now());(0,Q.useEffect)(()=>{let n=!1;return fetch(`${He}/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(ck(t.started_at)),d(ck(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=ak(o)&&u===null,C=sk(),w=(0,Q.useId)();return(0,Q.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(ck(n.timestamp)??Date.now())))}),()=>C.unregisterHandler(e)},[C,r,t,w]),(0,Q.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 uk(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var dk=15e3;function fk(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function pk(e){let{projectId:t,jobId:n,timeoutMs:r=dk}=e,i=t?`${He}/api/projects/${t}`:nt(),a;try{a=await fetch(`${i}/jobs/${n}/cancel`,{method:`POST`,signal:fk(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 mk=null;function hk(e){mk=e}function gk(e,t){mk?.(e,t)}var _k=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-DKA_DUHe.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([6,1,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,76]))),vk={building:nn,on_review:nn,pr_draft:R,pr_ready:R,no_changes:Mo,completed:Mo,pr_closed:en,superseded:R,implementation_failed:fn,pr_failed:fn,merged:ls,discarded:en},yk={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 bk({envelope:e}){let{t}=K(`agent`),n=ht(e);return n.units.length===0&&!n.partial?null:(0,$.jsxs)(`div`,{className:`mt-2 space-y-1.5`,"data-testid":`agent-pr-unit-evidence`,children:[n.partial&&(0,$.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,$.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,$.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 xk({prDeliveryId:e,projectId:t}){let{t:n}=K(`agent`),r=v(),{activeProjectId:i,setActiveProjectId:a}=at();return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let n=`/review/${e}`;i!==t&&(gk(t,n),a(t)),r(n)},"data-testid":`agent-pr-open-packet`,"data-agent-interactive":!0,title:n(`prCard.openReviewTooltip`),className:`inline-flex items-center gap-1 rounded-md border border-accent-primary/40 bg-accent-primary/10 px-2 py-1 text-[11px] font-medium text-accent-primary transition-colors hover:bg-accent-primary/20`,children:[(0,$.jsx)(Qo,{className:`h-3 w-3`}),n(`prCard.openReview`)]})}function Sk(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function Ck({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=K(`agent`),s=lk(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:ok(s.elapsedMs),u=s.costUsd!=null&&s.costUsd>0,d=(0,$.jsx)(`span`,{"aria-hidden":!0,className:`opacity-40`,children:`·`});return(0,Q.useEffect)(()=>{a?.(t,{paused:s.paused,pausedReason:s.pausedReason})},[a,t,s.paused,s.pausedReason]),(0,$.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,$.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,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:c}),d,(0,$.jsx)($s,{className:`h-3 w-3 shrink-0 opacity-70`}),l&&(0,$.jsxs)($.Fragment,{children:[d,(0,$.jsx)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runElapsedAria`,{elapsed:l}),children:l})]}),u&&(0,$.jsxs)($.Fragment,{children:[d,(0,$.jsxs)(`span`,{className:`tabular-nums`,"aria-label":o(`prCard.runCostAria`,{cost:`$${s.costUsd.toFixed(2)}`}),children:[`$`,s.costUsd.toFixed(2)]})]})]})}function wk({envelope:e}){let{t}=K(`agent`),n=u(),{projects:r}=at(),{applyPrDecisionSnapshot:i}=lM(),{openWebView:a,canOpenWebView:o}=Se(),{openRef:s}=_b(),[c,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),k=D??e,A=At(k.projectId).has(k.prDeliveryId),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)({}),[I,L]=(0,Q.useState)(null),{decision:z,prUrl:B,prState:ee}=k,V=!!k.repositoryDeliveries?.length,H=ht(k),te=ft(k.statusCode,k.statusDetail),ne=k.operation==null&&te,re=r.find(e=>e.id===k.projectId)?.name??k.projectId,ie=z===`pr_draft`&&!B,ae=z===`building`&&ee===`pr-created`&&!!k.branch,se=k.prNumber?`#${k.prNumber}`:B?Sk(B):null,ce=H.terminal,le=dt(k.statusCode)?t(`common:prDeliveryStatus.${k.statusCode}`):null,ue=H.partial&&H.deliverableCount>0&&(z===`on_review`||z===`pr_draft`&&!B);(0,Q.useEffect)(()=>{O(null)},[e]),(0,Q.useEffect)(()=>{l(null),m(!1),g(!1),v(!1),b(!1),S(!1),w(!1),E(!1)},[z,B,k.prDeliveryId]);let de=(0,Q.useCallback)((e,t)=>{P(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),fe=async e=>{if(!I){L(e);try{let n=await pk({projectId:k.projectId,jobId:e,kind:`loop-run`});n.ok?J.info(t(`prCard.stopExecutionSent`)):J.error(t(`prCard.stopExecutionFailed`),{description:n.error})}finally{L(null)}}},pe=async(e,n)=>{if(d||c||k.operation||V&&!n&&[`create-pr`,`merge-local`,`publish`,`poll-merge`,`reopen`,`acknowledge-no-changes`].includes(e))return;let r=k.repositoryDeliveries?.find(e=>e.repositoryId===n),a=r?.integrationBranch??r?.baseBranch??k.baseBranch;l(e);try{let r=await oo(k.projectId,{prDeliveryId:k.prDeliveryId,action:e,expectedDecision:z,...n?{repositoryId:n}:{}}),o=null;if(r.snapshot){let e=so(k,r.snapshot);o=i(e),o!==`stale`&&O(e)}if(o===`stale`){J.info(t(`prCard.alreadyResolved`));return}if(r.kind===`recovering`)J.info(t(`common:prRecovery.inProgress`));else if(r.kind===`busy`)J.info(t(`prCard.operation.${r.operation??`inProgress`}`));else if(r.kind===`stale`)J.info(t(`prCard.alreadyResolved`));else if(r.kind===`blocked`)J.warning(r.reason===`dirty`?t(`prCard.mergeLocalBlockedDirty`,{base:r.base||a}):t(`prCard.mergeLocalBlockedBranch`,{base:r.base||a,current:r.current??`?`}));else if(r.kind===`failed`)J.error(t(`prCard.actionFailed`),{description:r.detail});else if(r.kind===`ok`&&e===`recover-and-retry`)if(r.deliveryVerified){let e=(r.verifiedSha??r.snapshot?.deliverySha??``).slice(0,8);J.success(t(`prCard.recoverAndRetryVerified`,{sha:e}))}else r.recoveryUnavailable||r.snapshot?.statusCode===`recovery_unavailable`?J.info(t(`prCard.recoveryUnavailable`),{description:t(`prCard.recoveryUnavailableBody`)}):J.warning(t(`prCard.recoveryStillBlocked`),{description:r.detail??void 0});else if(r.kind===`ok`&&e===`create-pr`&&H.retryablePush&&r.deliveryVerified){let e=(r.verifiedSha??r.snapshot?.deliverySha??k.deliverySha??``).slice(0,8);J.success(t(r.pushed?`prCard.retryPushVerified`:`prCard.commitAlreadyVerified`,{sha:e}))}else if(r.kind===`ok`&&e===`create-pr`&&r.detail)J.error(t(`prCard.deliveryNeedsAttention`),{description:r.detail});else if(r.kind===`ok`&&e===`poll-merge`&&r.deliveryVerified===!1)J.warning(t(`prCard.commitMissingRetry`));else if(r.kind===`ok`&&e===`poll-merge`&&r.deliveryVerified&&!r.merged){let e=(r.verifiedSha??r.snapshot?.deliverySha??k.deliverySha??``).slice(0,8);J.success(t(`prCard.prVerifiedWaiting`,{sha:e}))}else e===`poll-merge`&&!r.merged&&r.decision!==`pr_closed`?J.info(t(`prCard.notMergedYet`)):e===`merge-local`&&r.kind===`ok`&&r.decision===`merged`&&J.success(t(`prCard.mergedLocally`,{base:a}));r.kind===`ok`&&(e===`create-pr`||e===`discard`||e===`merge-local`||e===`recover-and-retry`)&&vt(k.projectId)}catch(e){J.error(t(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{l(null)}},he=async e=>{if(!(V&&!e)&&!(c||d||k.operation)){f(!0);try{let n=await(e?co(k.projectId,k.prDeliveryId,e):co(k.projectId,k.prDeliveryId));n.kind===`ok`?(J.success(t(`prCard.checkoutSuccess`,{branch:n.branch??pt(k)??``})),n.cleanupWarnings.length>0&&J.warning(t(`prCard.cleanupIncomplete`,{count:n.cleanupWarnings.length}),{description:n.cleanupWarnings.join(`
|
|
40
40
|
`)}),vt(k.projectId)):n.kind===`recovering`?J.info(t(`common:prRecovery.inProgress`)):n.error===`checkout_dirty`?J.warning(t(`prCard.checkoutDirtyTitle`),{description:t(`prCard.checkoutDirtyBody`)}):n.error===`checkout_not_deliverable`?J.warning(t(`prCard.checkoutNotDeliverableTitle`),{description:t(`prCard.checkoutNotDeliverableBody`)}):n.error===`checkout_safety_unknown`?J.warning(t(`prCard.checkoutSafetyUnknownTitle`),{description:t(`prCard.checkoutSafetyUnknownBody`)}):J.warning(t(`prCard.checkoutFailed`),{description:n.detail})}catch(e){J.error(t(`prCard.checkoutFailed`),{description:e instanceof Error?e.message:void 0})}finally{f(!1)}}},ge=async()=>{let e=H.recoveryWorktreePaths;if(e.length===0){J.info(t(`prCard.localResultUnavailableHere`));return}let n=e.join(`
|
|
41
41
|
`),r=!1;try{await navigator.clipboard.writeText(n),r=!0}catch{}try{me()&&await oe(e[0])}catch{}r?J.success(t(`prCard.localResultPathCopied`),{description:n}):J.info(t(`prCard.localResultPath`),{description:n})},_e=(e,t)=>{o&&(e.preventDefault(),e.stopPropagation(),a(t))},ye=k.ticketIds.length>0&&(0,$.jsx)($.Fragment,{children:k.ticketIds.map(e=>(0,$.jsxs)(Tx,{refTarget:{kind:`ticket`,ticketId:e},onOpen:e=>void s(k.projectId,e),children:[`#`,e]},e))}),U=k.runIds??[],be=e=>U.length===1&&k.ticketIds.length>1?k.ticketIds.map(e=>`#${e}`).join(` `):k.ticketIds[e]==null?null:`#${k.ticketIds[e]}`,xe=U.find(e=>N[e]?.paused)??null,Ce=xe?N[xe]?.pausedReason??null:null,W=U.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,"data-testid":`pr-run-log-chips`,children:U.map((e,t)=>(0,$.jsx)(Ck,{projectId:k.projectId,runId:e,ticketLabel:be(t),live:z===`building`,onOpen:M,onVitals:de},e))}),we=z===`building`&&xe!==null,Te=xe?be(U.indexOf(xe))??xe.slice(0,8):null,Ee=j&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(_k,{jobId:j,projectId:k.projectId,onClose:()=>M(null)})});if(z===`building`)return(0,$.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,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[we?(0,$.jsx)(fn,{className:`h-3.5 w-3.5 text-accent-warning`}):ae?(0,$.jsx)(R,{className:`h-3.5 w-3.5 text-accent-info`}):(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin text-accent-primary/70`}),(0,$.jsx)(`span`,{className:X(!ae&&!we&&`animate-pulse`,we&&`text-accent-warning`),children:t(we?`prCard.title.paused`:ae?`prCard.title.buildingExistingPr`:`prCard.title.building`)})]}),ye&&(0,$.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:ye}),ae&&(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:[B?(0,$.jsxs)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,onClick:e=>_e(e,B),title:B,"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,$.jsx)(R,{className:`h-3 w-3`}),se??t(`prCard.openPr`),(0,$.jsx)(Vt,{className:`h-2.5 w-2.5 opacity-60`})]}):(0,$.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,$.jsx)(R,{className:`h-3 w-3`}),se??t(`prCard.existingPr`)]}),(0,$.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,$.jsx)(nn,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`truncate`,children:k.branch})]})]}),we&&xe&&(0,$.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,$.jsx)(fn,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:Ce??void 0,children:[Te?t(`prCard.pausedForRun`,{ref:Te}):t(`prCard.paused`),Ce?`: ${Ce}`:``]}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:e=>{e.stopPropagation(),M(xe)},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,$.jsx)(on,{className:`h-3 w-3`}),t(`prCard.resume`)]}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:I===xe,onClick:e=>{e.stopPropagation(),fe(xe)},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:[I===xe?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(sn,{className:`h-3 w-3`}),t(`prCard.stopExecution`)]})]}),W&&(0,$.jsx)(`div`,{className:`pl-[22px]`,children:W}),(0,$.jsx)(`p`,{className:`mt-1 pl-[22px] text-[11px] leading-4 text-foreground/40`,children:t(ae?`prCard.buildingExistingPrHint`:`prCard.buildingHint`)}),Ee]});let De=vk[z],Oe=H.superseded?t(`prCard.title.superseded`):H.noChanges?t(`prCard.title.no_changes`):H.deliveryBlocked?t(`prCard.title.delivery_blocked`):H.retryablePush?t(`prCard.title.update_failed`):H.closed?t(`prCard.title.pr_closed`):H.partial?t(`prCard.title.partial`):k.statusCode===`existing_pr_updated`?t(`prCard.title.existing_pr_updated`):t(ie?`prCard.title.pr_draft_degraded`:`prCard.title.${z}`),ke=`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`,Ae=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`),je=c!==null||d||k.operation!=null,Me=!!k.operation||ne||H.partial||H.deliveryBlocked||H.retryablePush||H.retryablePrCreation||H.closed||H.implementationFailed,Ne=(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`}),Pe=(e,t)=>!V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void pe(e),disabled:je,"data-agent-interactive":!0,className:ke,children:[c===e&&Ne,t]}),Fe=ve&&n&&!H.terminal?(0,$.jsx)(xk,{prDeliveryId:k.prDeliveryId,projectId:k.projectId}):null,Ie=pt(k),Le=Ie&&!V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void he(),disabled:je,"data-testid":`agent-pr-checkout`,"data-agent-interactive":!0,title:t(`prCard.checkoutTooltip`,{branch:Ie}),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:[d?Ne:(0,$.jsx)(nn,{className:`h-3 w-3`}),t(`prCard.checkout`)]}),Re=H.recoveryWorktreePaths.length>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void ge(),disabled:je,"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,$.jsx)(as,{className:`h-3 w-3`,"aria-hidden":!0}),t(`prCard.inspectLocalResult`)]}),ze=H.recoveryRecheck,Be=(H.manualRecovery||ze)&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!0),disabled:je,"data-testid":ze?`agent-pr-recheck-recovery`:`agent-pr-recover-and-retry`,"data-agent-interactive":!0,className:ze?`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`:ke,children:[c===`recover-and-retry`?Ne:(0,$.jsx)(Zs,{className:`h-3 w-3`,"aria-hidden":!0}),t(ze?`prCard.recheckRecovery`:`prCard.recoverAndRetry`)]}),G=!V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),disabled:je,"data-testid":`agent-pr-merge-local`,"data-agent-interactive":!0,title:t(`prCard.mergeLocalTooltip`,{base:k.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:[c===`merge-local`&&Ne,t(`prCard.mergeLocal`)]}),Ve=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>m(!0),disabled:je,"data-agent-interactive":!0,className:Ae,children:[c===`discard`&&Ne,t(`prCard.discard`)]}),He=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),disabled:je,"data-agent-interactive":!0,className:Ae,children:[c===`dismiss`&&Ne,t(`prCard.dismiss`)]}),Ue=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(!0),disabled:je,"data-agent-interactive":!0,className:Ae,children:[c===`discard`&&Ne,t(`prCard.discardLocalResult`)]}),We=!V&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>S(!0),disabled:je,"data-agent-interactive":!0,className:ke,children:[c===`acknowledge-no-changes`&&Ne,t(`prCard.markDone`)]}),Ge=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),disabled:je,"data-agent-interactive":!0,className:Ae,children:[c===`discard`&&Ne,t(`prCard.refine`)]}),Ke=B&&(0,$.jsxs)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,onClick:e=>_e(e,B),title:B,"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,$.jsx)(R,{className:`h-3 w-3`}),se??t(`prCard.openPr`),(0,$.jsx)(Vt,{className:`h-2.5 w-2.5 opacity-60`})]});return(0,$.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`,z===`merged`&&`border-accent-success/30`,z===`completed`&&`border-accent-success/30`,z===`discarded`&&`opacity-70`),children:[Me&&(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-label":k.operation?t(`prCard.operation.${k.operation}`):ne?t(`common:prRecovery.interrupted`):Oe,className:`sr-only`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(De,{className:X(`h-4 w-4 shrink-0`,yk[z])}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:Oe}),(0,$.jsx)(`span`,{className:`max-w-[140px] shrink-0 truncate text-[11px] text-foreground/50`,title:re,children:re}),(0,$.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:k.railIndex+1})})]}),(0,$.jsx)(Mt,{deliveryId:k.prDeliveryId,repositories:k.repositoryDeliveries,busy:!!c||d||!!k.operation,onAct:pe,onCheckout:he}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[!V&&(0,$.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,$.jsx)(nn,{className:`h-3 w-3 text-accent-primary/70`}),`→ `,k.baseBranch]}),(0,$.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,$.jsx)(F,{className:`h-3 w-3 text-accent-secondary/80`}),t(`prCard.specCount`,{count:k.ticketIds.length})]}),ye,Ke,k.deliverySha&&(0,$.jsxs)(`span`,{"data-testid":`agent-pr-delivery-sha`,title:k.deliverySha,className:X(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,k.deliveryOutcome===`delivered`?`border-accent-success/35 bg-accent-success/10 text-accent-success`:`border-border/60 bg-surface/60 text-foreground/65`),children:[(0,$.jsx)(Mo,{className:`h-3 w-3`}),t(`prCard.deliveryCommit`,{sha:k.deliverySha.slice(0,8)})]})]}),W,k.operation&&(0,$.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,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),t(`prCard.operation.${k.operation}`)]}),ne&&(0,$.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,$.jsx)(Zs,{className:`mt-px h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t(`common:prRecovery.interrupted`)})]}),(0,$.jsx)(bk,{envelope:k}),le&&(0,$.jsx)(`p`,{className:`mt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,"data-testid":`agent-pr-status-code`,children:le}),!ce&&H.deliveryBlocked&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[H.recoveryUnavailable?t(`prCard.recoveryUnavailableBody`):t(H.partial?`prCard.partialDeliveryBlockedNote`:`prCard.deliveryBlockedNote`),k.statusDetail&&!te&&!H.recoveryUnavailable?(0,$.jsx)(`span`,{className:`mt-0.5 block text-foreground/50`,children:k.statusDetail}):null]})]}),!ce&&H.recoveryUnavailable&&k.statusDetail&&!te&&(0,$.jsxs)(`details`,{className:`mt-1.5 text-[10px] leading-4 text-foreground/55`,"data-testid":`agent-pr-recovery-technical-detail`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground/65`,children:t(`prCard.recoveryDetailSummary`)}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:k.statusDetail})]}),!ce&&H.retryablePush&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[t(`prCard.retryPushNote`),k.statusDetail&&!te?(0,$.jsx)(`span`,{className:`mt-0.5 block text-foreground/50`,children:k.statusDetail}):null]})]}),k.statusDetail&&!te&&!H.deliveryBlocked&&!H.retryablePush&&(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/45`,"data-testid":`agent-pr-status-detail`,children:k.statusDetail}),!ce&&!B&&(ee===`pushed`||ee===`local-only`)&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3 w-3 shrink-0`}),t(ee===`local-only`?`prCard.degraded.localOnly`:`prCard.degraded.pushed`)]}),H.cleanupWarnings.length>0&&(0,$.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,$.jsx)(`p`,{className:`font-medium`,children:t(`prCard.cleanupIncomplete`,{count:H.cleanupWarnings.length})}),(0,$.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4 text-foreground/60`,children:H.cleanupWarnings.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}-${e}`))})]}),H.safetyArchives.length>0&&(0,$.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,$.jsx)(`summary`,{className:`cursor-pointer font-medium text-accent-info`,children:t(`prCard.safetyArchiveTitle`,{count:H.safetyArchives.length})}),(0,$.jsx)(`p`,{className:`mt-1 leading-4`,children:t(`prCard.safetyArchiveHint`)}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[10px] text-foreground/50`,children:H.safetyArchives.map(e=>(0,$.jsx)(`li`,{className:`break-all`,children:e},e))})]}),(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:`easeOut`},className:`mt-2.5`,children:[H.noChanges&&!ce&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,$.jsx)(Mo,{className:`h-3.5 w-3.5`}),H.continuation?t(`prCard.noChangesExisting`):t(`prCard.noChangesNote`)]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:H.continuation?He:(0,$.jsxs)($.Fragment,{children:[We,Ge]})})]}),!ce&&H.deliveryBlocked&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[Re,Be,H.continuation?H.hasDiscardableRecoveryResult?Ue:He:Ve]}),!ce&&H.retryablePush&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.retryPush`)),H.continuation?He:Ve]}),!ce&&H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.retryPr`)),G,H.continuation?He:Ve]}),!ce&&H.closed&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`reopen`,t(`prCard.reopen`)),H.continuation?He:Ve]}),!ce&&ue&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.createPartialPr`,{count:H.deliverableCount})),H.continuation?He:Ve]}),z===`on_review`&&!H.noChanges&&!H.partial&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Fe,Le,Pe(`create-pr`,t(`prCard.createPr`)),G,H.continuation?He:Ve]}),z===`pr_draft`&&!ie&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`publish`,t(`prCard.publish`)),H.continuation?He:Ve]}),ie&&!ue&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.retryPr`)),G,H.continuation?He:Ve]}),z===`pr_ready`&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`poll-merge`,t(`prCard.verifyPr`)),H.continuation?He:Ve]}),z===`pr_failed`&&!H.deliveryBlocked&&!H.retryablePush&&!H.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Le,Pe(`create-pr`,t(`prCard.retry`)),!B&&G,H.continuation?He:Ve]}),z===`implementation_failed`&&H.implementationFailed&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] leading-4 text-destructive`,children:[(0,$.jsx)(fn,{className:`mt-px h-3 w-3 shrink-0`}),t(`prCard.implementationFailedNote`)]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:H.continuation?He:Ve})]}),z===`merged`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,$.jsx)(Mo,{className:`h-3.5 w-3.5`}),t(`prCard.mergedNote`)]}),z===`discarded`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,$.jsx)(en,{className:`h-3.5 w-3.5`}),t(`prCard.discardedNote`)]}),z===`completed`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,$.jsx)(Mo,{className:`h-3.5 w-3.5`}),t(`prCard.completedNote`)]}),z===`superseded`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5`}),t(`prCard.supersededNote`)]})]},`${z}-${B??``}`),(0,$.jsx)(Hn,{open:!V&&y,onOpenChange:b,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-merge-local-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.mergeLocalTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.mergeLocalBody`,{base:k.baseBranch})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>b(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:je,"data-testid":`agent-pr-merge-local-confirm-btn`,onClick:()=>{b(!1),pe(`merge-local`)},children:t(`prCard.mergeLocal`)})]})]})}),(0,$.jsx)(Hn,{open:T,onOpenChange:E,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-recover-and-retry-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(ze?`prCard.confirm.recheckRecoveryTitle`:`prCard.confirm.recoverAndRetryTitle`)}),(0,$.jsx)(Mn,{children:t(ze?`prCard.confirm.recheckRecoveryBody`:`prCard.confirm.recoverAndRetryBody`,{branch:k.branch??``})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>E(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:je,"data-testid":`agent-pr-recover-and-retry-confirm-btn`,onClick:()=>{E(!1),pe(`recover-and-retry`)},children:t(ze?`prCard.recheckRecovery`:`prCard.recoverAndRetry`)})]})]})}),(0,$.jsx)(Hn,{open:p,onOpenChange:m,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-discard-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(z===`implementation_failed`?`prCard.confirm.implementationFailedDiscardTitle`:`prCard.confirm.freshDiscardTitle`)}),(0,$.jsx)(Mn,{children:t(z===`implementation_failed`?`prCard.confirm.implementationFailedDiscardBody`:`prCard.confirm.freshDiscardBody`)}),A&&(0,$.jsx)(`p`,{className:`mt-2 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-2 py-1.5 text-xs text-accent-warning`,"data-testid":`agent-pr-discard-stacked-note`,children:t(`prCard.discardStackedNote`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>m(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:je,"data-testid":`agent-pr-discard-confirm-btn`,onClick:()=>{m(!1),pe(`discard`)},children:t(`prCard.discard`)})]})]})}),(0,$.jsx)(Hn,{open:h,onOpenChange:g,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-dismiss-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.dismissTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.dismissBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>g(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:je,"data-testid":`agent-pr-dismiss-confirm-btn`,onClick:()=>{g(!1),pe(`dismiss`)},children:t(`prCard.dismiss`)})]})]})}),(0,$.jsx)(Hn,{open:_,onOpenChange:v,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-discard-local-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.discardLocalTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.discardLocalBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>v(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:je,"data-testid":`agent-pr-discard-local-confirm-btn`,onClick:()=>{v(!1),pe(`discard`)},children:t(`prCard.discardLocalResult`)})]})]})}),(0,$.jsx)(Hn,{open:!V&&x,onOpenChange:S,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-no-changes-done-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.noChangesDoneTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.noChangesDoneBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>S(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:je,"data-testid":`agent-pr-no-changes-done-confirm-btn`,onClick:()=>{S(!1),pe(`acknowledge-no-changes`)},children:t(`prCard.markDone`)})]})]})}),(0,$.jsx)(Hn,{open:C,onOpenChange:w,children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`agent-pr-refine-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:t(`prCard.confirm.refineTitle`)}),(0,$.jsx)(Mn,{children:t(`prCard.confirm.refineBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>w(!1),children:t(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:je,"data-testid":`agent-pr-refine-confirm-btn`,onClick:()=>{w(!1),pe(`discard`)},children:t(`prCard.refine`)})]})]})}),Ee]})}var Tk={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 Ek({decision:e}){let{t}=K(`agent`);return(0,$.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`,Tk[e]),children:t(`prCard.pinned.state.${e}`)})}var Dk=e=>`specrails-desktop:agent-pr-dock-collapsed:${e}`,Ok=e=>`specrails-desktop:agent-pr-dock-card-collapsed:${e}`;function kk(e){try{return sessionStorage.getItem(Dk(e))===`1`}catch{return!1}}function Ak(e,t){try{t?sessionStorage.setItem(Dk(e),`1`):sessionStorage.removeItem(Dk(e))}catch{}}function jk(e){try{let t=sessionStorage.getItem(Ok(e)),n=t?JSON.parse(t):[];return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Mk(e,t){try{t.size===0?sessionStorage.removeItem(Ok(e)):sessionStorage.setItem(Ok(e),JSON.stringify([...t]))}catch{}}function Nk({pinned:e,conversationId:t,inline:n}){let{t:r}=K(`agent`),[i,a]=(0,Q.useState)(()=>kk(t)),[o,s]=(0,Q.useState)(()=>jk(t));if((0,Q.useEffect)(()=>{a(kk(t)),s(jk(t))},[t]),e.length===0)return null;let c=e[e.length-1],l=e=>{Ak(t,e),a(e)},u=e=>{s(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),Mk(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,$.jsx)(fy.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,$.jsx)(`div`,{className:X(n&&`mx-auto w-full max-w-[680px]`),children:i?(0,$.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,$.jsx)(Vs,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:r(`prCard.pinned.collapsed`,{count:e.length})}),(0,$.jsx)(Ek,{decision:c.envelope.decision}),(0,$.jsx)(Gt,{className:`h-3.5 w-3.5 shrink-0 opacity-60`})]}):(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,children:[(0,$.jsx)(Vs,{className:`h-3 w-3 text-accent-primary/60`}),r(`prCard.pinned.label`),e.length>1&&(0,$.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,$.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,$.jsx)(Zt,{className:`h-3.5 w-3.5`})})]}),(0,$.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,$.jsxs)(`div`,{"data-testid":`agent-pr-dock-card`,className:`space-y-1`,children:[(0,$.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,$.jsx)(R,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium`,children:d(e.envelope)}),(0,$.jsx)(Ek,{decision:e.envelope.decision}),n?(0,$.jsx)(Gt,{className:`h-3 w-3 shrink-0 opacity-60`}):(0,$.jsx)(Zt,{className:`h-3 w-3 shrink-0 opacity-60`})]}),!n&&(0,$.jsx)(wk,{envelope:e.envelope})]},e.messageId)})})]})})})}function Pk(e){return e?e.charAt(0).toUpperCase()+e.slice(1):`Unknown`}function Fk(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(`
|
|
42
42
|
`)):(t.forEach((e,t)=>{t>0&&o.push(``),o.push(`[${e.created_at}] ${Pk(e.role)}`,e.content)}),o.join(`
|
|
43
|
-
`))}function Ik(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 Lk(){let{t:e}=K(`agent`),{active:t,messages:n,renameConversation:r,deleteConversation:i,startNewConversation:a,favoriteConversationIds:o,toggleFavoriteConversation:s}=lM(),{projects:c}=at(),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=(0,Q.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,Q.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,Q.useEffect)(()=>{l||v(!1)},[l]),(0,Q.useEffect)(()=>{d&&(b.current?.focus(),b.current?.select())},[d]);let w=(0,Q.useCallback)(()=>{m(t?.title??``),f(!0),u(!1)},[t?.title]),T=(0,Q.useCallback)(async()=>{if(t&&(f(!1),(t.title??``)!==p.trim()))try{await r(t.id,p)}catch{J.error(e(`header.renameFailed`))}},[t,p,r,e]),E=(0,Q.useCallback)(async(t,n)=>{u(!1);try{await navigator.clipboard.writeText(t),g(n),setTimeout(()=>g(e=>e===n?null:e),1400)}catch{J.error(e(`header.copyFailed`))}},[e]),D=(0,Q.useCallback)(async()=>{if(t){u(!1);try{await navigator.clipboard.writeText(Fk(t,n,x)),g(`transcript`),J.success(e(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>g(e=>e===`transcript`?null:e),1400)}catch{J.error(e(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[t,n,x,e]),O=(0,Q.useCallback)(()=>{if(t){u(!1);try{let r=Fk(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=Ik(t.title,t.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),J.success(e(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{J.error(e(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[t,n,x,e]),k=(0,Q.useCallback)(async()=>{if(t){u(!1),v(!1);try{await i(t.id),a(t.pinned_project_id)}catch{J.error(e(`header.deleteFailed`))}}},[t,i,a,e]),A=(0,Q.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,$.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,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm`,children:[x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:x.path,children:x.path}),(0,$.jsx)(Qt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),d?(0,$.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,$.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,$.jsx)(_c,{}),(0,$.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,$.jsx)(Xo,{className:`h-4 w-4`})}),(0,$.jsx)(f_,{children:l&&(0,$.jsx)(fy.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,$.jsxs)(`div`,{className:`p-2`,"data-testid":`agent-conv-delete-confirm`,children:[(0,$.jsx)(`p`,{className:`px-1 pb-2.5 text-xs leading-relaxed text-foreground/70`,children:e(`header.deleteConfirm`)}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.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,$.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,$.jsxs)($.Fragment,{children:[(0,$.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,$.jsx)(an,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),e(`header.rename`)]}),(0,$.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,$.jsx)(ms,{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,$.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,$.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),e(`header.delete`)]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border/50`}),(0,$.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,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,$.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,$.jsx)(tn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.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,$.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,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]},e.id))]})})})]})}var Rk=new Set([`building`,`on_review`,`pr_draft`,`no_changes`,`pr_closed`,`implementation_failed`,`pr_failed`]);function zk(e){return Rk.has(e)}function Bk(e){let t=[];for(let[n,r]of e.entries()){if(r.role!==`system`)continue;let e=io(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=Ft(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=Ft(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))Ft(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),zk(e.envelope.decision)&&u.push(e)}return{byMessageId:c,duplicateMessageIds:l,pinned:u}}var Vk=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-CyFzkOM-.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([6,1,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,76]))),Hk=(0,Q.lazy)(()=>c(()=>import(`./LoopPreviewModal-C2yekwCg.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([77,1,7,8,11,10,42,74,55,56,64,65,69,63,49,78,52,53]))),Uk=new Set,Wk=new Set([`spec-framing.committed`]);function Gk(e){if(!e.startsWith(`{`))return!1;try{let t=JSON.parse(e);return typeof t?.kind==`string`&&Wk.has(t.kind)}catch{return!1}}function Kk({variant:e}){let{t}=K(`agent`),{active:n}=lM(),r=si(),i=Cy(n?.id??`__new-mission__`),a=r.transfers.find(e=>e.conversationId===n?.id);if(n&&!r.current&&a?.state===`detached`)return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[e===`inline`&&(0,$.jsx)(Lk,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,$.jsx)(Vt,{className:`h-8 w-8 text-accent-primary`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`window.detached`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{r.focus(n.id)},className:`rounded-md bg-accent-primary px-4 py-2 text-sm text-white`,children:t(`window.focus`)})]})]});let o=!!n&&!r.isEditable(n.id);return(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 flex-col`,inert:o||void 0,"aria-busy":o||void 0,children:(0,$.jsx)(qk,{variant:e},`${n?.id??`__new-mission__`}:${i}`)})}function qk({variant:e}){let{t}=K(`agent`),{active:n,messages:r,streamingText:i,isStreaming:a,liveTools:o,turnTools:s,queuedMessages:c,mcpEnabled:l,enablingMcp:u,enableMcpServer:d,providersReady:f,cycleTier:p,send:m}=lM(),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=o.length>0?o:s,b=(0,Q.useRef)(null),x=jy(i,a),{openRef:S,jobRef:C,closeJobRef:w,loopRef:T,closeLoopRef:E}=_b(),D=n?.pinned_project_id??null,[O,k]=(0,Q.useState)(new Map),A=(0,Q.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.attachment_ids??[])e.add(n);for(let t of c)for(let n of t.attachmentIds??[])e.add(n);return[...e].sort()},[r,c]).join(`\0`);(0,Q.useEffect)(()=>{let e=A?A.split(`\0`):[];if(!n?.id||e.length===0){k(new Map);return}let t=!1,r=new Set(e);return qa(n.id).then(e=>{t||k(new Map(e.filter(e=>r.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||k(new Map)}),()=>{t=!0}},[n?.id,A]);let j=(0,Q.useMemo)(()=>D?e=>{S(D,e)}:void 0,[D,S]),M=ca().id===`code-rain`?t(`emptyTitleCodeRain`):t(`emptyTitle`),N=(0,Q.useMemo)(()=>Bk(r),[r]),P=n?xy(n.id):null,F=(0,Q.useRef)(P?.atBottom??!0);(0,Q.useLayoutEffect)(()=>{let e=b.current;return e&&P&&(e.scrollTop=P.atBottom?e.scrollHeight:P.top),()=>{e&&n&&by(n.id,{top:e.scrollTop,atBottom:F.current})}},[n?.id]);let I=()=>{let e=b.current;e&&(F.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,n&&by(n.id,{top:e.scrollTop,atBottom:F.current}))};(0,Q.useEffect)(()=>{F.current&&b.current?.scrollTo?.({top:b.current.scrollHeight,behavior:`auto`})},[r.length,x,o.length,c.length]);let L=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),p())},R=e===`inline`,z=R?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden `,onKeyDown:L,children:[f===!1&&(0,$.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,$.jsx)(Ns,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-warning`}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:t(`noProvider.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:t(`noProvider.body`)})]})]}),f!==!1&&!l&&(0,$.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,$.jsx)(rc,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,$.jsx)(`span`,{className:`flex-1`,children:t(`degraded.body`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void d(),disabled:u,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:t(u?`degraded.enabling`:`degraded.enable`)})]}),R&&n&&(0,$.jsx)(Lk,{}),(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsxs)(fy.div,{ref:b,onScroll:I,initial:R?{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,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,$.jsx)(So,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:M}),(0,$.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:t(`emptyHint`)})]}),r.map((e,n)=>{if(e.role===`system`){if(Gk(e.content))return null;let n=N.byMessageId.get(e.id);return n?zk(n.decision)?(0,$.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,$.jsx)(Vs,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(`prCard.pinned.marker`)}),(0,$.jsx)(Ek,{decision:n.decision})]},e.id):(0,$.jsx)(wk,{envelope:n},e.id):(N.duplicateMessageIds.has(e.id)||Uk.has(e.id)||(Uk.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}return(0,$.jsx)(Rx,{role:e.role,content:e.content,createdAt:e.created_at,isLast:!a&&n===r.length-1,isLatest:n===r.length-1,isStreaming:a,onPickOption:e=>void m(e),refsProjectId:D,onOpenRef:j,contextRefs:e.context_refs,deliveryStatus:e.delivery_status,deliveryReceipt:e.delivery_receipt,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>O.get(e)).filter(e=>!!e)},e.id)}),a&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[x&&(0,$.jsx)(Rx,{role:`assistant`,content:x,streaming:!0}),(0,$.jsx)(bb,{tool:o.length?o[o.length-1].tool:null,onClick:()=>g(!0)})]}),c.length>0&&(0,$.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:c.map(e=>(0,$.jsx)(zx,{item:e,conversationId:n?.id,onEdit:e=>{n&&v(t=>({conversationId:n.id,queueId:e,revision:(t?.revision??0)+1}))},attachments:(e.attachmentIds??[]).map(e=>O.get(e)).filter(e=>!!e)},`${n?.id}:${e.queueId}`))})]}),(0,$.jsx)(f_,{initial:!1,children:n&&N.pinned.length>0&&(0,$.jsx)(Nk,{pinned:N.pinned,conversationId:n.id,inline:R},`agent-pr-pinned-dock`)}),R?(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsxs)(fy.div,{layoutId:`agent-composer-dock`,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`relative mx-auto w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`,"data-testid":`agent-composer-dock`,children:[(0,$.jsx)(ik,{active:a,radius:`1rem`,inset:-3}),(0,$.jsx)(qO,{queueEditRequest:_})]})}):(0,$.jsxs)(`div`,{className:`relative shrink-0 border-t border-border/50 bg-surface/30 p-3`,"data-testid":`agent-composer-dock`,children:[(0,$.jsx)(ik,{active:a,radius:`0.75rem`,inset:-2}),(0,$.jsx)(qO,{hideProjectSelector:!0,queueEditRequest:_})]})]}),C&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Vk,{jobId:C.jobId,projectId:C.projectId,onClose:w})}),T&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Hk,{loop:T,onClose:E})}),h&&(0,$.jsx)(Sb,{tools:y,streaming:a,onClose:()=>g(!1)})]})}var Jk=8,Yk=3e3;function Xk(){let{t:e}=K(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=lM(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(0),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y=(0,Q.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>Jk,x=(0,Q.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,Q.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=null,h(null)},[]);(0,Q.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]),(0,Q.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},Yk)},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{J.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,$.jsxs)(`div`,{className:`relative min-w-0`,ref:_,"data-agent-interactive":!0,onKeyDown:j,children:[(0,$.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,$.jsx)(Yt,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:M}),(0,$.jsx)(Zt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,$.jsx)(f_,{children:c&&(0,$.jsxs)(fy.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,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(ln,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,$.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,$.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,$.jsxs)(fy.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,$.jsx)(cn,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),x.length>0&&(0,$.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),x.length===0&&u.trim()!==``&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),x.map((e,t)=>(0,$.jsx)(Zk,{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 Zk({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}=K(`agent`),p=e.title?.trim()||f(`mission.untitled`),m=e.id===r;return o?(0,$.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,$.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-destructive`,children:f(i?`mission.deleteLiveConfirm`:`mission.deleteConfirm`)}),(0,$.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,$.jsx)(Ht,{className:`h-3.5 w-3.5`})}),(0,$.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,$.jsx)(mn,{className:`h-3.5 w-3.5`})})]}):(0,$.jsxs)(fy.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,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-foreground/40`,title:Ob(e.updated_at),children:Db(e.updated_at)}),i&&(0,$.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,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),a>0&&(0,$.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,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.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,$.jsx)(dn,{className:`h-3.5 w-3.5`})})]})}var Qk=Q.forwardRef(({className:e,type:t,...n},r)=>(0,$.jsx)(`input`,{type:t,className:X(`flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-xs ring-offset-background file:border-0 file:bg-transparent file:text-xs file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Qk.displayName=`Input`;var $k=6e4,eA={data:null,fetchedAt:0,inFlight:null,error:null},tA=new Set;function nA(){tA.forEach(e=>{try{e()}catch{}})}function rA(){return eA.data!==null&&Date.now()-eA.fetchedAt<$k}async function iA(e){if(eA.inFlight)return eA.inFlight;let t=(async()=>{let t=await fetch(`${He}/api/setup-prerequisites`,{signal:e});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(typeof n?.ok!=`boolean`||!Array.isArray(n?.prerequisites)||!Array.isArray(n?.missingRequired))throw Error(`Malformed prerequisites response`);return eA.data=n,eA.fetchedAt=Date.now(),eA.error=null,eA.inFlight=null,nA(),eA.data})().catch(t=>{throw eA.inFlight=null,e?.aborted?t:(eA.error=t instanceof Error?t:Error(String(t)),nA(),eA.error)});return eA.inFlight=t,t}var aA=!1;function oA(){aA||typeof window>`u`||(window.addEventListener(`focus`,()=>{eA.fetchedAt=0,eA.data=null,iA().catch(()=>{})}),aA=!0)}function sA(){let[,e]=(0,Q.useState)(0),[t,n]=(0,Q.useState)(()=>!rA()),[r,i]=(0,Q.useState)(eA.error);(0,Q.useEffect)(()=>{oA();let t=()=>{e(e=>e+1),i(eA.error),n(!1)};tA.add(t);let r=new AbortController;return!rA()&&!eA.inFlight?(n(!0),iA(r.signal).catch(e=>{r.signal.aborted||i(e instanceof Error?e:Error(String(e)))}).finally(()=>{r.signal.aborted||n(!1)})):eA.inFlight&&eA.inFlight.catch(()=>{}).finally(()=>{r.signal.aborted||n(!1)}),()=>{r.abort(),tA.delete(t)}},[]);let a=(0,Q.useCallback)(async()=>{eA.fetchedAt=0,eA.data=null,eA.error=null,n(!0);try{await iA()}catch(e){i(e instanceof Error?e:Error(String(e)))}finally{n(!1)}},[]);return{status:eA.data,isLoading:t,error:r,recheck:a}}var cA={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`},kimi:{icon:`🌙`,label:`Kimi`}};function lA(e){return e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`project`}function uA({blueprint:e,onSubmit:t,onBack:n,submitting:r,error:i,errorDetail:a}){let{t:o}=K(`builder`),{status:s}=sA(),[c,l]=(0,Q.useState)(e.product.name||``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(new Set([`claude`])),[g,_]=(0,Q.useState)({claude:!0}),[v,y]=(0,Q.useState)(!1),b=(0,Q.useMemo)(()=>`~/projects/${lA(c)}`,[c]),x=u?f:b;(0,Q.useEffect)(()=>{fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n===`tiers`||n===`providerIssues`||n===`launchDescriptors`||typeof r==`boolean`&&(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`,`kimi`,...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,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col gap-4 p-6`,"data-testid":`commit-form`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:o(`commit.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`commit.description`)})]}),i&&(0,$.jsxs)(`div`,{className:`rounded-md bg-destructive/10 p-2 text-xs text-destructive`,"data-testid":`commit-error`,children:[(0,$.jsx)(`p`,{children:o(`commit.errors.${i}`,{defaultValue:o(`commit.errors.generic`)})}),a&&(0,$.jsx)(`p`,{className:`mt-1 opacity-80`,children:a})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.nameLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsx)(Qk,{value:c,onChange:e=>l(e.target.value),"data-testid":`commit-name`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.locationLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsx)(Qk,{value:x,onChange:e=>{d(!0),p(e.target.value)},"data-testid":`commit-location`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:o(`commit.locationHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:o(`commit.providersLabel`)}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:Object.keys(g).map(e=>{let{icon:t,label:n}=cA[e]??{icon:`•`,label:e},r=g[e],i=m.has(e)&&r;return(0,$.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,$.jsx)(`span`,{children:t}),(0,$.jsx)(`span`,{className:`font-medium`,children:n})]},e)})})]}),C&&(0,$.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,$.jsx)(`input`,{type:`checkbox`,checked:v&&w,disabled:!w,onChange:e=>y(e.target.checked),"data-testid":`commit-github`}),(0,$.jsx)(us,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:o(`commit.githubLabel`)}),!w&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:o(`commit.githubAuthHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between pt-2`,children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:n,disabled:r,children:o(`commit.back`)}),(0,$.jsxs)(Z,{size:`sm`,disabled:!E,"data-testid":`commit-submit`,onClick:()=>t({name:c.trim(),location:x.trim(),providers:T,createGithubRepo:v&&w}),children:[(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`}),o(r?`commit.creating`:`commit.submit`)]})]})]})}function dA({session:e,autoFocus:t=!1}){let{t:n}=K(`builder`),{t:r}=K(`agent`),{availableIds:i}=UO(),a=rr(e.provider),o=[e.provider,...i].filter((e,t,n)=>n.indexOf(e)===t).filter(rr),s=()=>{!a||!e.draft.trim()||e.busy||!e.conversationReady||(e.send(e.draft),e.setDraft(``))};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:n(`mode.title`)})]}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(uD,{label:r(`provider.label`),value:e.provider,options:o.map(e=>({value:e,label:r(`provider.${e}`,{defaultValue:e})})),icon:So,onSelect:e.setProvider,disabled:!a||e.busy||!e.conversationReady,testId:`builder-provider-selector`}),(0,$.jsx)(vD,{models:e.models,model:e.model,onSelect:e.setModel,disabled:!a||e.busy||!e.conversationReady,testId:`builder-model-selector`}),e.efforts.length>0&&(0,$.jsx)(uD,{label:r(`effort.label`),value:e.effort,options:e.efforts.map(e=>({value:e,label:r(`effort.${e}`)})),icon:ss,onSelect:e.setEffort,disabled:!a||e.busy||!e.conversationReady,testId:`builder-effort-selector`}),e.showSurpriseMe&&(0,$.jsxs)(`button`,{type:`button`,onClick:e.surpriseMe,disabled:!a||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,$.jsx)(un,{className:`h-3 w-3`}),n(`shell.surpriseMe`)]})]}),!a&&(0,$.jsx)(`p`,{className:`mb-2 rounded-md border border-accent-warning/30 bg-accent-warning/10 px-2.5 py-2 text-xs text-accent-warning`,"data-testid":`builder-provider-unavailable`,children:n(`shell.providerUnavailable`)}),(0,$.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border border-border/60 bg-background/60 px-3 py-2`,children:[(0,$.jsx)(`textarea`,{value:e.draft,disabled:!a,autoFocus:t,onChange:t=>e.setDraft(t.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),s())},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,$.jsx)(`button`,{type:`button`,onClick:s,disabled:!a||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,$.jsx)(mt,{className:`h-4 w-4`})})]})]})}function fA(e){let t=Date.parse(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`);return Number.isFinite(t)?Zn(new Date(t),{addSuffix:!0,locale:Ue()}):``}function pA({items:e,loading:t,disabled:n=!1,onResume:r,onDiscard:i}){let{t:a}=K(`builder`),[o,s]=(0,Q.useState)(null);return!t&&e.length===0?null:(0,$.jsxs)(fy.section,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.24,ease:`easeOut`,delay:.08},className:`mt-4 w-full rounded-2xl border border-border/50 bg-card/70 p-3 shadow-lg backdrop-blur-xl`,"data-testid":`builder-recent`,"aria-label":a(`recent.title`),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 px-1`,children:[(0,$.jsx)(hs,{className:`h-3.5 w-3.5 text-accent-secondary`,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:a(`recent.title`)}),t&&(0,$.jsx)(rn,{className:`ml-auto h-3 w-3 animate-spin text-muted-foreground/60`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`space-y-1`,children:(0,$.jsx)(f_,{initial:!1,children:e.map(e=>{let t=e.productName||e.title||a(`recent.untitled`),c=o===e.id;return(0,$.jsxs)(fy.li,{layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,height:0},className:X(`group flex items-center gap-2 rounded-xl border border-transparent px-2.5 py-2 transition-colors`,`hover:border-border/60 hover:bg-surface/60`),"data-testid":`builder-recent-${e.id}`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>r(e.id),className:`flex min-w-0 flex-1 items-center gap-2.5 text-left disabled:opacity-50`,"data-testid":`builder-recent-resume-${e.id}`,children:[(0,$.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-accent-primary/10 text-accent-primary`,children:(0,$.jsx)(on,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:t}),(0,$.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground`,children:[e.platform&&(0,$.jsx)(`span`,{children:e.platform}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(xs,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),e.specCount>0?e.specsComplete?a(`recent.specsComplete`,{count:e.specCount}):a(`recent.specsInProgress`,{count:e.specCount}):a(`recent.dimensions`,{filled:e.dimensionsFilled,total:5})]}),e.pendingIssue&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-warning`,"data-testid":`builder-recent-pending-issue`,children:[(0,$.jsx)(fn,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),a(`recent.pendingIssue`)]}),e.updatedAt&&(0,$.jsx)(`span`,{className:`opacity-80`,children:fA(e.updatedAt)})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>{s(null),i(e.id)},"aria-label":a(`recent.discardConfirm`),title:a(`recent.discardConfirm`),className:`rounded-md p-1 text-destructive hover:bg-destructive/10`,"data-testid":`builder-recent-discard-confirm-${e.id}`,children:(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(null),"aria-label":a(`recent.discardCancel`),title:a(`recent.discardCancel`),className:`rounded-md p-1 text-muted-foreground hover:bg-surface`,"data-testid":`builder-recent-discard-cancel-${e.id}`,children:(0,$.jsx)(mn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),"aria-label":a(`recent.discard`),title:a(`recent.discard`),className:`rounded-md p-1 text-muted-foreground/40 opacity-0 transition-opacity hover:bg-surface hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100`,"data-testid":`builder-recent-discard-${e.id}`,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})})]},e.id)})})})]})}function mA({specsStarted:e,snapshot:t,maxSpecs:n=10}){let{t:r}=K(`builder`),i=t.status===`repairing`,a=t.status===`generating`?t.generation:null,o=(a&&a.total>0?a.phase===`audit`?.95:Math.min(.95,Math.max(.06,Math.max(0,a.from-1)/a.total)):null)??Math.min(.95,Math.max(.06,e/n)),s=i?pn:un,c=i?r(`snapshot.repairing.${t.kind}`):a?r(`generation.phase.${a.phase}`,{from:a.from,to:a.to,total:a.total}):r(`generation.writing`);return(0,$.jsxs)(`div`,{className:`inline-flex max-w-full flex-col gap-1.5 rounded-xl border border-border/50 bg-surface/60 px-3 py-2 text-xs text-foreground/80`,"data-testid":`builder-generation-progress`,"data-phase":i?`repairing`:a?`generation-${a.phase}`:`generating`,role:`status`,"aria-live":`polite`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 shrink-0 animate-spin text-accent-info`,"aria-hidden":!0}),(0,$.jsx)(s,{className:`h-3 w-3 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsx)(fy.span,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:`easeOut`},className:`font-medium`,children:c},c)}),a&&a.totalTurns>0&&(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-2 py-px font-mono text-[10px] text-muted-foreground`,"data-testid":`builder-generation-turn`,children:r(`generation.turn`,{turn:a.turn,total:a.totalTurns})}),e>0&&(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsx)(fy.span,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.14},className:`rounded-full bg-accent-primary/10 px-2 py-px font-mono text-[10px] text-accent-primary`,"data-testid":`builder-generation-count`,children:r(`generation.specCount`,{n:e})},e)})]}),(0,$.jsx)(`div`,{className:`h-1 w-56 max-w-full overflow-hidden rounded-full bg-border/40`,"aria-hidden":!0,children:(0,$.jsx)(fy.div,{className:`h-full rounded-full bg-gradient-to-r from-accent-primary/70 to-accent-highlight/80`,initial:{width:`6%`},animate:{width:`${Math.round(o*100)}%`},transition:{type:`spring`,stiffness:120,damping:20}})})]})}var hA=`specrails-desktop:milestone-launch-mode`,gA=`specrails-desktop:milestone-sequential-plans`;function _A(){try{return localStorage.getItem(`specrails-desktop:milestone-launch-mode`)===`parallel`?`parallel`:`sequential`}catch{return`sequential`}}function vA(e){try{localStorage.setItem(hA,e)}catch{}}var yA=`specrails-desktop:milestone-auto-advance`;function bA(){try{return localStorage.getItem(yA)===`true`}catch{return!1}}function xA(e){try{localStorage.setItem(yA,e?`true`:`false`)}catch{}}function SA(){try{return localStorage.getItem(`specrails-desktop:milestone-sequential-plans`)===null?!1:(localStorage.removeItem(gA),!0)}catch{return!1}}function CA(e){return`M${e}`}function wA(e,t){return t===`chain_active`?`chain_active`:t===`no_tickets`?`no_tickets`:t===`milestone_not_found`?`milestone_not_found`:e===503?`unavailable`:`launch_rejected`}async function TA(e){try{let t=await e.json();return t&&typeof t==`object`?t:{}}catch{return{}}}async function EA(e,t,n=_A(),r={}){let i=typeof r==`function`?{fetchImpl:r}:r,a=i.fetchImpl??fetch,o=i.autoAdvance??bA(),s;try{s=await a(`/api/projects/${e}/blueprint/milestones/${t}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:n,autoAdvance:o})})}catch(e){return{ok:!1,reason:`network`,error:`network`,detail:e instanceof Error?e.message:String(e)}}let c=await TA(s);if(!s.ok){let e=typeof c.error==`string`?c.error:`http_${s.status}`;return{ok:!1,reason:wA(s.status,e),error:e,...typeof c.detail==`string`?{detail:c.detail}:{},...typeof c.chainId==`string`?{chainId:c.chainId}:{}}}let l=Array.isArray(c.launched)?c.launched.filter(e=>!!e&&typeof e==`object`&&typeof e.chunk==`number`):[],u=Array.isArray(c.pending)?c.pending.filter(e=>Array.isArray(e)):[];return{ok:!0,chainId:typeof c.chainId==`string`?c.chainId:null,launched:l,pending:u,ticketCount:l.reduce((e,t)=>e+(Array.isArray(t.ticketIds)?t.ticketIds.length:0),0),skippedCount:u.reduce((e,t)=>e+t.length,0)}}async function DA(e,t,n,r){let i;try{i=await r(`/api/projects/${e}/blueprint/chains/${t}/${n}`,{method:`POST`})}catch(e){return{ok:!1,error:`network`,detail:e instanceof Error?e.message:String(e)}}let a=await TA(i);return i.ok?{ok:!0,chain:yt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}function OA(e,t,n=fetch){return DA(e,t,`resume`,n)}function kA(e,t,n=fetch){return DA(e,t,`cancel`,n)}async function AA(e,t,n,r=fetch){let i;try{i=await r(`/api/projects/${e}/blueprint/chains/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({autoAdvance:n})})}catch(e){return{ok:!1,error:`network`,detail:e instanceof Error?e.message:String(e)}}let a=await TA(i);return i.ok?{ok:!0,chain:yt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}var jA=[`Problem Statement`,`Proposed Solution`,`Out of Scope`,`Technical Considerations`,`Estimated Complexity`],MA={problemMinChars:200,solutionMinChars:500,outOfScopeMinBullets:3,technicalMinBullets:5,criteriaMin:6,criteriaMax:10,criterionMinChars:20},NA=new Set([`scaffold`,`feature`,`verification`]),PA=new Set([`critical`,`high`,`medium`,`low`]),FA=/^(?:todo|tbd|n\/?a|works?|test(?: it)?|criterion|acceptance criterion)$/i;function IA(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function LA(e){return e.trim().toLocaleLowerCase(`en-US`)}function RA(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 zA(e){return e.split(/\r?\n/).filter(e=>/^\s*[-*+]\s+\S/.test(e)).length}function BA(e,t){let n=[],r=IA(e),i=Array.isArray(r?.m1Specs)?r.m1Specs:[],a=t.milestoneLabel.trim().toUpperCase(),o=(e,t,r,i,a={})=>{n.push({specIndex:e,field:t,code:r,message:i,params:e===null?a:{n:e+1,...a}})};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.`,{min:t.minSpecs,max:t.maxSpecs,count:i.length});let s=new Map;return i.forEach((e,n)=>{let r=IA(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:``;NA.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=LA(l),t=s.get(e);t===void 0?s.set(e,n):o(n,`title`,`duplicate`,`Spec ${i} duplicates spec ${t+1}.`,{other: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:``;PA.has(d)||o(n,`priority`,`invalid_priority`,`Spec ${i} needs a valid priority.`);let f=typeof r.description==`string`?r.description.trim():``,p=RA(f);(!/^## Problem Statement(?:\r?\n|$)/.test(f)||p.headings.length!==jA.length||p.headings.some((e,t)=>e!==jA[t]))&&o(n,`description`,`canonical_sections`,`Spec ${i} is missing the canonical sections.`);for(let e of jA)(p.bodies.get(e)??``).trim()||o(n,`description`,`empty_section`,`Spec ${i} has an empty ${e} section.`,{heading:e});for(let[e,t]of[[`Problem Statement`,MA.problemMinChars],[`Proposed Solution`,MA.solutionMinChars]]){let r=(p.bodies.get(e)??``).trim();r&&r.length<t&&o(n,`description`,`section_depth`,`Spec ${i} ${e} is too thin.`,{heading:e,min:t})}for(let[e,t]of[[`Out of Scope`,MA.outOfScopeMinBullets],[`Technical Considerations`,MA.technicalMinBullets]]){let r=p.bodies.get(e)??``;r&&zA(r)<t&&o(n,`description`,`section_bullets`,`Spec ${i} needs ${t} ${e} bullets.`,{heading:e,min:t})}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<MA.criteriaMin||h.length>MA.criteriaMax)&&o(n,`acceptanceCriteria`,`criteria_count`,`Spec ${i} needs ${MA.criteriaMin}-${MA.criteriaMax} acceptance criteria.`,{count:h.length,min:MA.criteriaMin,max:MA.criteriaMax});let g=new Set;h.forEach((e,t)=>{let r=typeof e==`string`?e.trim():``;if(r.length<MA.criterionMinChars||FA.test(r)){o(n,`acceptanceCriteria`,`criterion_quality`,`Spec ${i} criterion ${t+1} is not concrete.`,{criterion:t+1});return}let a=LA(r);g.has(a)&&o(n,`acceptanceCriteria`,`duplicate_criterion`,`Spec ${i} repeats an acceptance criterion.`,{criterion:t+1}),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.`,{label:a}),_.every(e=>e.toUpperCase()===a)&&o(n,`labels`,`domain_label`,`Spec ${i} needs a domain label.`,{label:a});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 VA=new Set([`batch_incomplete`,`spec_count`]);function HA(e,t,n,r,i={}){let a=gt(e),o=Object.values(a).filter(Boolean).length,s=Object.keys(a).length,c=t&&typeof t==`object`&&!Array.isArray(t)?t:null,l=Array.isArray(c?.m1Specs)?c.m1Specs.length:e?.m1Specs.length??0,u=Array.isArray(c?.m1Specs)?c.m1Specs:e?.m1Specs??[],d=new Set;u.forEach((e,t)=>{let n=e&&typeof e==`object`?e:null,r=typeof n?.description==`string`?n.description.trim():``,i=Array.isArray(n?.acceptanceCriteria)?n.acceptanceCriteria:[];(r.length>0||i.length>0)&&d.add(t)});let f=d.size,p=c?c.specsComplete===!0:e?.specsComplete===!0,m=i.generating===!0&&l>0,h=!m&&l>0&&f<l&&!p,g=m?[]:n.issues.filter(e=>!VA.has(e.code)&&(!h||e.specIndex===null||d.has(e.specIndex))),_={key:`blueprint`,state:o===s?`done`:`pending`,params:{filled:o,total:s}},v;v=m?`writing`:l===0?`pending`:l<r.minSpecs||l>r.maxSpecs?`blocked`:p?`done`:`pending`;let y={key:`specs`,state:v,params:{count:l,written:f,min:r.minSpecs,max:r.maxSpecs}},b={key:`audit`,state:m?`writing`:l===0||h&&g.length===0?`pending`:g.length===0?`done`:`blocked`,params:{count:g.length}};return{ready:n.valid,steps:[_,y,b],issues:g}}function UA(e){return e.field===`shortSummary`?`quality.summary`:e.field===`title`&&e.code===`required`?`quality.title_required`:e.field===`title`&&e.code===`duplicate`?`quality.title_duplicate`:`quality.${e.code}`}function WA(e,t){let n={n:t.specIndex===null?``:t.specIndex+1,...t.params??{}};return e(UA(t),{...n,defaultValue:t.message})}var GA=new Set([`gh_not_installed`,`gh_not_authenticated`,`gh_scope`,`gh_repo_exists`,`gh_network`]);function KA(e){return`progress.githubErrors.${e&&GA.has(e)?e:`generic`}`}var qA=[`create-dir`,`git-init`,`assemble`,`blueprint`,`tickets`,`register`,`github`],JA={minSpecs:5,maxSpecs:10};function YA(e){let t=e&&typeof e==`object`?e:null;if(!t)return null;let n=t.phase;if(n!==`outline`&&n!==`details`&&n!==`audit`&&n!==`repair`)return null;let r=e=>typeof e==`number`&&Number.isFinite(e)?e:0;return{phase:n,from:r(t.from),to:r(t.to),total:r(t.total),turn:r(t.turn),totalTurns:r(t.totalTurns)}}function XA(e,t){let n=e&&typeof e==`object`?e:{},r=new Date().toISOString();if(n.continuing){let e=YA(n.generation);return e?{status:`generating`,generation:e}:t}return n.status===`accepted`?{status:`accepted`,repaired:n.repaired===!0,repairAttempted:n.repairAttempted===!0,at:r,...n.generationHalted===!0?{generationHalted:!0}:{}}:n.status===`rejected`?{status:`rejected`,reason:n.reason??`invalid_json`,detail:n.detail??``,repairAttempted:n.repairAttempted===!0,at:r}:t.status===`repairing`||t.status===`generating`?{status:`idle`}:t}function ZA(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`).map(e=>({id:String(e.id),title:typeof e.title==`string`?e.title:null,productName:typeof e.productName==`string`?e.productName:null,platform:typeof e.platform==`string`?e.platform:null,provider:typeof e.provider==`string`?e.provider:`claude`,model:typeof e.model==`string`?e.model:null,updatedAt:typeof e.updated_at==`string`?e.updated_at:``,messageCount:typeof e.messageCount==`number`?e.messageCount:0,specCount:typeof e.specCount==`number`?e.specCount:0,specsComplete:e.specsComplete===!0,dimensionsFilled:typeof e.dimensionsFilled==`number`?e.dimensionsFilled:0,hasSnapshot:e.hasSnapshot===!0,pendingIssue:e.pendingIssue===`invalid_json`||e.pendingIssue===`truncated`||e.pendingIssue===`missing_version`?e.pendingIssue:null})):[]}function QA(e,t){let{t:n}=K(`builder`),{registerHandler:r,unregisterHandler:i}=qe(),{setActiveProjectId:a}=at(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(`chat`),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(`claude`),[R,z]=(0,Q.useState)(null),[B,ee]=(0,Q.useState)([]),[V,H]=(0,Q.useState)(``),[te,ne]=(0,Q.useState)([]),[re,ie]=(0,Q.useState)(`medium`),[ae,oe]=(0,Q.useState)(``),[se,ce]=(0,Q.useState)({status:`idle`}),[le,ue]=(0,Q.useState)([]),[de,fe]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)(!1),he=R??V,ge=(0,Q.useMemo)(()=>{let e=lr(I,he);return te.filter(t=>e.includes(t))},[he,I,te]),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(I),U=(0,Q.useRef)(null),be=(0,Q.useRef)(!1),xe=(0,Q.useRef)(re),Se=(0,Q.useRef)(ge),Ce=(0,Q.useRef)(R),W=(0,Q.useRef)(!1),we=(0,Q.useRef)(t.onFinished);(0,Q.useEffect)(()=>{_e.current=o},[o]),(0,Q.useEffect)(()=>{ye.current=I},[I]),(0,Q.useEffect)(()=>{U.current=w},[w]),(0,Q.useEffect)(()=>{xe.current=re},[re]),(0,Q.useEffect)(()=>{Se.current=ge},[ge]),(0,Q.useEffect)(()=>{Ce.current=R},[R]),(0,Q.useEffect)(()=>{we.current=t.onFinished},[t.onFinished]);let Te=(0,Q.useCallback)(async()=>{let e=_e.current;if(e)return e;if(ve.current)return ve.current;let t=fetch(`/api/blueprint/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:ye.current,...Ce.current?{model:Ce.current}:{}})}).then(e=>e.json()).then(e=>e.conversation?(_e.current=e.conversation.id,s(e.conversation.id),e.conversation.id):null).catch(()=>null).finally(()=>{ve.current=null});return ve.current=t,t},[]),Ee=(0,Q.useCallback)(async()=>{fe(!0);try{let e=await(await fetch(`/api/blueprint/conversations?resumable=1`)).json();ue(ZA(e.conversations))}catch{ue([])}finally{fe(!1)}},[]);(0,Q.useEffect)(()=>{e&&Ee()},[e,Ee]),(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return ee([]),H(``),ne([]),ie(``),fetch(`/api/blueprint/models?provider=${encodeURIComponent(I)}`).then(e=>e.json()).then(e=>{if(t)return;ee(e.models??[]);let n=e.defaultModel??e.models?.[0]?.value??``,r=e.efforts??[],i=lr(I,n),a=r.filter(e=>i.includes(e));H(n),ne(r),ie(e=>a.includes(e)?e:fr(I,n)??``)}).catch(()=>{}),()=>{t=!0}},[e,I]);let De=(0,Q.useCallback)(e=>{L(e),z(null);let t=_e.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).catch(()=>{})},[]),Oe=(0,Q.useCallback)(e=>{z(e);let t=lr(I,e),n=te.filter(e=>t.includes(e));ie(t=>n.includes(t)?t:fr(I,e)??``);let r=_e.current;r&&fetch(`/api/blueprint/conversations/${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:e})}).catch(()=>{})},[I,te]);(0,Q.useEffect)(()=>{if(!e)return;let t=`builder-session`;return r(t,e=>{let t=e,r=_e.current!==null&&t.conversationId===_e.current,i=U.current!==null&&t.commitId===U.current;if(t.type===`blueprint.stream`&&r)d(e=>(e??``)+String(t.delta??``));else if(t.type===`blueprint.repairing`&&r){let e=t.kind===`truncated`||t.kind===`quality`?t.kind:`invalid_json`;_(!0),ce({status:`repairing`,kind:e,manual:t.manual===!0,attempt:typeof t.attempt==`number`?t.attempt:1})}else if(t.type===`blueprint.generating`&&r){let e=YA(t);d(null),_(!0),e&&ce({status:`generating`,generation:e})}else if(t.type===`blueprint.done`&&r){let e=t.continuing===!0;d(null),_(e);let n=String(t.fullText??``);n.trim()&&!e&&l(e=>[...e,{role:`assistant`,content:n,createdAt:new Date().toISOString()}]);let r=Ct(t.blueprint),i=t.rawBlueprint===void 0?t.blueprint:t.rawBlueprint;if(!r&&t.snapshot===void 0){let e=Lt(n);r=e.blueprint,i=e.rawBlueprint}r&&(p(r),h(i)),ce(e=>t.snapshot===void 0?r?{status:`accepted`,repaired:!1,repairAttempted:!1,at:new Date().toISOString()}:e:XA(t.snapshot,e))}else if(t.type===`blueprint.error`&&r)d(null),_(!1),ce(e=>e.status===`repairing`||e.status===`generating`?{status:`idle`}:e),J.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`&&!be.current&&(be.current=!0,J.warning(n(KA(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&&(W.current=!1,F(!1),J.error(n(`errors.commitFailed`),{description:String(t.error??``)}),y(`commit`),x(`commit_failed`),C(String(t.error??``)))}),()=>i(t)},[e,r,i,n]);let ke=(0,Q.useCallback)((e,t={})=>{let r=e.trim();if(!r||g||pe)return;l(e=>[...e,{role:`user`,content:r,createdAt:new Date().toISOString(),...t.intent?{intent:t.intent}:{}}]),_(!0);let i=xe.current,a=Se.current.includes(i);Te().then(e=>{if(!e){_(!1),J.error(n(`errors.startFailed`));return}return fetch(`/api/blueprint/conversations/${e}/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:r,...Ce.current?{model:Ce.current}:{},...a?{reasoning_effort:i}:{},...t.intent?{intent:t.intent}:{}})}).then(e=>{!e.ok&&e.status!==202&&(_(!1),J.error(n(`errors.turnFailed`)))}).catch(()=>{_(!1),J.error(n(`errors.turnFailed`))})})},[g,pe,Te,n]),Ae=(0,Q.useCallback)(async e=>{if(!g){me(!0);try{let t=await fetch(`/api/blueprint/conversations/${e}`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(!n.conversation)throw Error(`missing conversation`);_e.current=n.conversation.id,s(n.conversation.id),n.conversation.provider&&L(n.conversation.provider),z(n.conversation.model??null),l((n.messages??[]).filter(e=>typeof e.content==`string`&&e.content.trim()!==``).map(e=>({role:e.role,content:e.content,createdAt:e.created_at??new Date().toISOString(),...e.intent===`surprise`||e.intent===`approve`?{intent:e.intent}:{}})));let r=Ct(n.blueprint);p(r),h(r?n.rawBlueprint??n.blueprint:null),ce(XA(n.snapshot,{status:`idle`})),d(null),_(!1),y(`chat`),x(null),C(null),D([]),oe(``)}catch{J.error(n(`recent.resumeFailed`))}finally{me(!1)}}},[g,n]),je=(0,Q.useCallback)(async e=>{try{let t=await fetch(`/api/blueprint/conversations/${e}`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(`HTTP ${t.status}`);ue(t=>t.filter(t=>t.id!==e))}catch{J.error(n(`recent.discardFailed`))}},[n]),Me=(0,Q.useCallback)(async()=>{let e=_e.current;if(!(!e||g)){_(!0);try{let t=await fetch(`/api/blueprint/conversations/${e}/repair-snapshot`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(re?{reasoningEffort:re}:{})});if(t.status===202)return;let r=await t.json().catch(()=>({}));_(!1),r.error===`nothing_to_repair`?J.info(n(`snapshot.nothingToRepair`)):r.error===`no_session`?J.error(n(`snapshot.noSession`)):r.error===`streaming`?J.info(n(`snapshot.alreadyStreaming`)):J.error(n(`errors.turnFailed`))}catch{_(!1),J.error(n(`errors.turnFailed`))}}},[g,re,n]),Ne=(0,Q.useCallback)(()=>ke(n(`prompts.surpriseMe`),{intent:`surprise`}),[ke,n]),Pe=(0,Q.useCallback)(()=>ke(n(`prompts.approve`),{intent:`approve`}),[ke,n]),Fe=(0,Q.useCallback)(e=>{!f||W.current||(W.current=!0,F(!0),x(null),C(null),D([]),be.current=!1,fetch(`/api/blueprint/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({blueprint:m??f,...e,..._e.current?{conversationId:_e.current}:{}})}).then(async e=>{let t=await e.json().catch(()=>({}));e.status===202&&t.commitId?(T(t.commitId),U.current=t.commitId,y(`progress`)):(x(t.error??`generic`),C(t.detail??null)),W.current=!1,F(!1)}).catch(()=>{W.current=!1,F(!1),x(`generic`),C(null)}))},[f,m]),Ie=(0,Q.useCallback)(async()=>{if(!(!O||A)){j(!0);try{let e=_A(),t=bA(),r=await EA(O,1,e,{autoAdvance:t}),i=CA(1);if(r.ok){let o=r.launched.length+r.pending.length;e===`sequential`&&r.pending.length>0?J.success(n(t?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:i,count:r.ticketCount,n:o})):r.skippedCount>0?J.warning(n(`milestoneProgress.toast.launchedPartial`,{milestone:i,count:r.ticketCount,skipped:r.skippedCount})):J.success(n(`milestoneProgress.toast.launchedAll`,{milestone:i,count:r.ticketCount,n:o})),a(O),N(!0)}else r.reason===`chain_active`?(J.info(n(`milestoneProgress.toast.chainActive`,{milestone:i})),a(O),N(!0)):J.error(n(`done.launchFailed`),{description:r.detail??r.error})}finally{j(!1)}}},[O,A,a,n]),Le=(0,Q.useCallback)(()=>{O&&a(O),we.current()},[O,a]),Re=(0,Q.useCallback)(()=>{let e=_e.current;e&&fetch(`/api/blueprint/conversations/${e}/abort`,{method:`POST`}).catch(()=>{}),s(null),_e.current=null,ve.current=null,l([]),d(null),p(null),h(null),ce({status:`idle`}),ue([]),me(!1),_(!1),y(`chat`),x(null),C(null),T(null),D([]),be.current=!1,k(null),N(!1),j(!1),W.current=!1,F(!1),L(`claude`),z(null),ee([]),H(``),ne([]),ie(`medium`),oe(``)},[]),ze=gt(f),Be=Object.values(ze).some(Boolean)||c.length>0||ae.trim().length>0,G=(0,Q.useMemo)(()=>BA(m??f,{milestoneLabel:`M1`,minSpecs:JA.minSpecs,maxSpecs:JA.maxSpecs,requireScaffold:!0}),[f,m]),Ve=se.status===`generating`,He=(0,Q.useMemo)(()=>HA(f,m??f,G,JA,{generating:Ve}),[f,m,G,Ve]),Ue=(0,Q.useMemo)(()=>{if(G.valid)return null;let e=G.issues[0];return e?WA(n,e):null},[G,n]),We=(0,Q.useMemo)(()=>Pt(u),[u]);return{phase:v,messages:c,streamBuffer:u,blueprint:f,busy:g,commitError:b,commitErrorDetail:S,commitSteps:E,createdProjectId:O,launching:A,launched:M,submitting:P,conversationReady:e&&!pe,conversationId:o,dirty:Be,canProposeCommit:G.valid,specQualityDetail:Ue,readiness:He,snapshot:se,generation:We,recent:le,recentLoading:de,resume:Ae,discardRecent:je,repairSnapshot:Me,showSurpriseMe:c.length<=1&&v===`chat`,provider:I,model:R,models:B,efforts:ge,effort:re,draft:ae,setDraft:oe,setEffort:ie,setProvider:De,setModel:Oe,send:ke,surpriseMe:Ne,approveBlueprint:Pe,goToCommit:()=>y(`commit`),backToChat:()=>y(`chat`),submitCommit:Fe,launchM1:Ie,openProject:Le,abortAndReset:Re}}var $A={done:`bg-accent-success`,onReview:`bg-accent-warning`,inProgress:`bg-accent-info animate-pulse`,failed:`bg-destructive`,todo:`bg-muted-foreground/25`},ej={planned:`border-border/60 bg-surface/60 text-foreground/60`,committed:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,running:`border-accent-info/40 bg-accent-info/10 text-accent-info`,delivered:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,done:`border-accent-success/40 bg-accent-success/10 text-accent-success`};function tj({counts:e,className:t}){let{t:n}=K(`builder`),r=kt(e);return(0,$.jsx)(`div`,{className:X(`flex h-1.5 w-full overflow-hidden rounded-full bg-muted`,t),role:`img`,"aria-label":n(`milestoneProgress.counts`,{delivered:Nt(e),total:e.total,done:e.done}),"data-testid":`milestone-progress-bar`,children:r.map(e=>(0,$.jsx)(`div`,{"data-segment":e.key,className:X(`h-full transition-all duration-500`,$A[e.key]),style:{width:`${e.pct}%`},title:`${n(`milestoneProgress.legend.${e.key}`)} · ${e.count}`},e.key))})}function nj({state:e}){let{t}=K(`builder`);return(0,$.jsx)(`span`,{"data-testid":`milestone-state-pill`,"data-state":e,className:X(`inline-flex shrink-0 items-center rounded-full border px-1.5 py-px text-[9px] font-semibold uppercase tracking-wide`,ej[e]),children:t(`milestoneProgress.state.${e}`)})}function rj(e){let[t,n]=(0,Q.useState)(()=>Date.now());return(0,Q.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function ij({rail:e,now:t,onReview:n,onOpenRail:r}){let{t:i}=K(`builder`),a=e.name??i(`milestoneProgress.rail.fallbackName`,{n:e.railIndex+1}),o=e.active&&e.startedAt?Math.max(0,t-Date.parse(e.startedAt)):null,s=e.delivery?.decision??null,c=s!==null&&wt.has(s)&&e.delivery!==null;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/30 bg-surface/40 px-2 py-1.5`,"data-testid":`milestone-rail-row`,"data-rail-index":e.railIndex,children:[e.chunkIndex!=null&&(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-muted/70 px-1 py-px text-[9px] font-mono tabular-nums text-muted-foreground`,title:i(`milestoneProgress.rail.chunk`,{k:e.chunkIndex}),children:e.chunkIndex}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>r?.(e.railIndex),className:`min-w-0 flex-1 truncate text-left text-[11px] font-medium hover:underline`,title:i(`milestoneProgress.rail.open`),children:a}),e.active?(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-accent-info`,"data-testid":`milestone-rail-running`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),o==null?i(`milestoneProgress.state.running`):i(`milestoneProgress.rail.running`,{elapsed:kO(o)})]}):s?(0,$.jsx)(Ek,{decision:s}):(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`milestoneProgress.rail.noDelivery`)}),c&&e.delivery&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n?.(e.delivery.id),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-accent-primary/40 bg-accent-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-primary hover:bg-accent-primary/20`,"data-testid":`milestone-rail-review`,children:[(0,$.jsx)(Qo,{className:`h-3 w-3`,"aria-hidden":!0}),i(`milestoneProgress.rail.review`)]})]})}function aj({checked:e,onChange:t,disabled:n=!1,compact:r=!1,testId:i=`milestone-auto-advance`}){let{t:a}=K(`builder`),o=a(e?`milestoneProgress.chain.autoAdvanceHint`:`milestoneProgress.chain.checkpointHint`);return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":a(`milestoneProgress.chain.autoAdvance`),disabled:n,onClick:()=>t(!e),title:o,className:X(`group inline-flex items-center gap-1.5 rounded-md border px-1.5 py-1 text-left text-[10px] transition-colors disabled:opacity-50`,e?`border-accent-success/40 bg-accent-success/10 text-accent-success`:`border-border/50 text-muted-foreground hover:text-foreground`,r?`py-0.5`:`w-full`),"data-testid":i,"data-checked":e,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`relative inline-flex h-3 w-5 shrink-0 items-center rounded-full transition-colors`,e?`bg-accent-success/70`:`bg-muted-foreground/30`),children:(0,$.jsx)(`span`,{className:X(`absolute h-2 w-2 rounded-full bg-background shadow transition-transform`,e?`translate-x-2.5`:`translate-x-0.5`)})}),e?(0,$.jsx)(hn,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}):(0,$.jsx)(ns,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:a(`milestoneProgress.chain.autoAdvance`)}),!r&&(0,$.jsx)(`span`,{className:`hidden truncate text-[9px] font-normal text-muted-foreground group-hover:inline`,children:o})]})}function oj({chain:e,busy:t=!1,onResume:n,onCancel:r,onSetAutoAdvance:i}){let{t:a}=K(`builder`),o=Ot(e),s=e.status===`paused`,c=_t(e),l=jt(e.pauseReason),u=s?a(`milestoneProgress.chain.reasons.${l.key}`,{detail:l.detail,defaultValue:e.pauseReason??``}):null,d=e.mode===`sequential`&&(o||s||c)&&!!i;return(0,$.jsxs)(`div`,{className:X(`rounded-md border px-2 py-1.5 text-[10px]`,s?`border-accent-warning/40 bg-accent-warning/5`:c?`border-accent-success/40 bg-accent-success/5`:o?`border-accent-info/30 bg-accent-info/5`:`border-border/30 bg-surface/40`),"data-testid":`milestone-chain-row`,"data-status":e.status,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(xs,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.mode===`parallel`?a(`milestoneProgress.chain.parallelTitle`):a(`milestoneProgress.chain.title`)}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,a(`milestoneProgress.chain.progress`,{k:Math.min(e.nextChunk,e.totalChunks),n:e.totalChunks})]}),(0,$.jsx)(`span`,{className:`flex-1`}),c&&n&&(0,$.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>n(e.id),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 font-medium text-accent-success hover:bg-accent-success/20 disabled:opacity-50`,"data-testid":`milestone-chain-launch-next`,children:[t?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(on,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.launchNext`)]}),s&&n&&(0,$.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>n(e.id),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 font-medium text-accent-success hover:bg-accent-success/20 disabled:opacity-50`,"data-testid":`milestone-chain-resume`,children:[t?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(on,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.resume`)]}),(o||s||c)&&r&&(0,$.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r(e.id),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-1.5 py-0.5 text-muted-foreground hover:text-foreground disabled:opacity-50`,title:a(`milestoneProgress.chain.cancel`),"data-testid":`milestone-chain-cancel`,children:(0,$.jsx)(mn,{className:`h-3 w-3`,"aria-hidden":!0})})]}),(0,$.jsx)(`div`,{className:`mt-0.5 flex items-center gap-1 text-muted-foreground`,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zs,{className:`h-3 w-3 shrink-0 text-accent-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-accent-warning`,children:a(`milestoneProgress.chain.paused`,{reason:u})})]}):c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ns,{className:`h-3 w-3 shrink-0 text-accent-success`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-accent-success`,"data-testid":`milestone-chain-checkpoint`,children:a(`milestoneProgress.chain.checkpoint`,{k:e.nextChunk,next:e.nextChunk+1,n:e.totalChunks})}),e.headBranch&&(0,$.jsxs)(`span`,{className:`truncate font-mono`,title:e.headBranch,children:[` · `,a(`milestoneProgress.chain.stackedOn`,{branch:e.headBranch})]})]}):e.status===`running`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.waiting`,{k:e.nextChunk})}),e.headBranch&&e.mode===`sequential`&&(0,$.jsxs)(`span`,{className:`truncate font-mono`,title:e.headBranch,children:[` · `,a(`milestoneProgress.chain.stackedOn`,{branch:e.headBranch})]}),e.mode===`sequential`&&!e.autoAdvance&&e.nextChunk<e.totalChunks&&(0,$.jsxs)(`span`,{className:`shrink-0`,"data-testid":`milestone-chain-checkpoint-note`,children:[` · `,a(`milestoneProgress.chain.checkpointNote`)]})]}):e.status===`completed`?(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.completed`)}):e.status===`cancelled`?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(yo,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.cancelled`)]}):(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.waiting`,{k:e.nextChunk})})}),d&&i&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(aj,{checked:e.autoAdvance,disabled:t,onChange:t=>i(e.id,t),testId:`milestone-chain-auto-advance`})})]})}function sj({progress:e,actions:t,chainBusy:n,onReview:r,onOpenRail:i,onResume:a,onCancel:o,onSetAutoAdvance:s,className:c}){let{t:l}=K(`builder`),u=e.rails.some(e=>e.active),d=rj(u),{counts:f}=e,p=e.chain!==null&&e.chain.status!==`completed`&&e.chain.status!==`cancelled`||e.chain&&e.chain.status===`completed`&&e.rails.length>0&&u?e.chain:null;return(0,$.jsxs)(`div`,{className:X(`rounded-md border border-border/30 px-2 py-1.5`,c),"data-testid":`milestone-card`,"data-milestone":e.n,"data-state":e.state,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] font-semibold text-accent-primary`,children:xt(e.n)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium`,children:e.title}),(0,$.jsx)(nj,{state:e.state})]}),f.total>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tj,{counts:f,className:`mt-1.5`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-[10px] tabular-nums text-muted-foreground`,children:[(0,$.jsx)(`span`,{"data-testid":`milestone-counts`,children:l(`milestoneProgress.counts`,{delivered:Nt(f),total:f.total,done:f.done})}),f.inProgress>0&&(0,$.jsxs)(`span`,{className:`text-accent-info`,children:[l(`milestoneProgress.legend.inProgress`),` · `,f.inProgress]})]}),f.failed>0&&(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-destructive`,"data-testid":`milestone-failed-note`,children:l(`milestoneProgress.failedNote`,{count:f.failed})})]}),t&&(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:t}),p&&(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(oj,{chain:p,busy:n,onResume:a,onCancel:o,onSetAutoAdvance:s})}),e.rails.length>0&&(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`milestone-rails`,children:e.rails.map(e=>(0,$.jsx)(ij,{rail:e,now:d,onReview:r,onOpenRail:i},e.railIndex))})]})}function cj({projectId:e}){let{t}=K(`builder`),n=v(),{setActiveProjectId:r}=at(),{progress:i,hasBlueprint:a}=Dt(e),[o,s]=(0,Q.useState)(!1),c=i.find(e=>e.n===1)??null,l=(0,Q.useCallback)(t=>{r(e),setTimeout(()=>n(t),50)},[n,e,r]),u=(0,Q.useCallback)(async n=>{s(!0);try{let r=await OA(e,n);r.ok?J.success(t(`milestoneProgress.chain.resumed`)):J.error(t(`milestoneProgress.chain.resumeFailed`),{description:r.detail??r.error})}finally{s(!1)}},[e,t]),d=(0,Q.useCallback)(async(n,r)=>{s(!0);try{let i=await AA(e,n,r);i.ok?(xA(r),J.success(t(r?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):J.error(t(`milestoneProgress.chain.autoFailed`),{description:i.detail??i.error})}finally{s(!1)}},[e,t]),f=(0,Q.useCallback)(async n=>{s(!0);try{let r=await kA(e,n);r.ok?J.success(t(`milestoneProgress.chain.cancelledToast`)):J.error(r.detail??r.error)}finally{s(!1)}},[e,t]);return a===null&&!c?(0,$.jsx)(`div`,{className:`mt-4 flex items-center justify-center gap-2 text-xs text-muted-foreground`,"data-testid":`builder-done-milestone-loading`,children:(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0})}):c?(0,$.jsx)(`div`,{className:`mt-4 text-left`,"data-testid":`builder-done-milestone`,children:(0,$.jsx)(sj,{progress:c,chainBusy:o,onReview:e=>l(ve?`/review/${e}`:`/`),onOpenRail:()=>l(`/`),onResume:u,onCancel:f,onSetAutoAdvance:d,className:`bg-card/60`})}):null}var lj={surprise:mc,approve:Xs};function uj({kind:e,mode:t,onAction:n,disabled:r=!1,createdAt:i,className:a}){let{t:o}=K(`builder`),s=dy(),c=t===`settled`,l=c?Ht:lj[e],u=i?dj(i):null,d=X(`group relative my-1 w-full max-w-lg overflow-hidden rounded-xl border text-left shadow-lg backdrop-blur`,c?`border-accent-success/25 bg-card/60`:`border-accent-primary/25 bg-card/80 transition-colors hover:border-accent-primary/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 disabled:cursor-not-allowed disabled:opacity-60`,a),f=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-0 bg-gradient-to-br via-transparent transition-opacity`,c?`from-accent-success/[0.06] to-accent-success/[0.03] opacity-100`:`from-accent-primary/[0.08] to-accent-highlight/[0.08] opacity-70 group-hover:opacity-100`)}),(0,$.jsxs)(`div`,{className:X(`relative flex items-center justify-between gap-2 border-b border-border/40 px-3.5 py-2`,c?`bg-accent-success/[0.05]`:`bg-accent-primary/[0.06]`),children:[(0,$.jsxs)(`span`,{className:X(`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest`,c?`text-accent-success/90`:`text-accent-primary/90`),children:[c?(0,$.jsx)(Ht,{className:`h-3 w-3`,"aria-hidden":!0}):(0,$.jsx)(un,{className:`h-3 w-3`,"aria-hidden":!0}),o(c?`decisionCard.settledLabel`:`decisionCard.${e}.label`)]}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`builder-decision-card-meta`,children:c?u:o(`decisionCard.${e}.hint`)})]}),(0,$.jsxs)(`div`,{className:`relative flex items-center gap-3.5 px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:X(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full shadow-inner`,c?`bg-accent-success/15 text-accent-success`:`bg-gradient-to-br from-accent-primary/25 to-accent-highlight/25 text-accent-primary`),children:(0,$.jsx)(l,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold leading-snug text-foreground`,children:o(c?`decisionCard.${e}.settledTitle`:`decisionCard.${e}.title`)}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-muted-foreground`,children:o(c?`decisionCard.${e}.settledDescription`:`decisionCard.${e}.description`)})]}),!c&&(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-accent-primary/15 px-2.5 py-1 text-[11px] font-medium text-accent-primary transition-colors group-hover:bg-accent-primary/25`,children:[o(`decisionCard.${e}.cta`),(0,$.jsx)(B,{className:`h-3 w-3 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})]})]});return c?(0,$.jsx)(`div`,{className:d,"data-testid":`builder-decision-card`,"data-kind":e,"data-mode":`settled`,children:f}):(0,$.jsx)(fy.button,{type:`button`,onClick:n,disabled:r,initial:s?{opacity:0}:{opacity:0,y:8},animate:{opacity:1,y:0},exit:s?{opacity:0}:{opacity:0,y:-6},transition:{duration:.22,ease:`easeOut`},whileHover:r||s?void 0:{y:-2},whileTap:r?void 0:{scale:.99},className:d,"data-testid":`builder-decision-card`,"data-kind":e,"data-mode":`offer`,"aria-label":o(`decisionCard.${e}.cta`),children:f})}function dj(e){let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return pb(t,`p`,{locale:Ue()})}catch{return null}}var fj=`w-full rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`;function pj({variant:e}){let{t}=K(`builder`),{builderMode:n}=lM(),r=n.session,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(()=>bA()),c=(0,Q.useRef)(null),l=r.messages[r.messages.length-1],u=r.readiness.steps.find(e=>e.key===`blueprint`),d=r.readiness.steps.find(e=>e.key===`specs`),f=r.phase===`chat`&&!r.busy&&r.streamBuffer===null&&l?.role===`assistant`&&r.snapshot.status!==`generating`,p=f&&u?.state!==`done`,m=f&&u?.state===`done`&&(d===void 0||d.state===`pending`&&Number(d.params.count??0)===0)&&(r.blueprint?.m1Specs.length??0)===0;(0,Q.useEffect)(()=>{c.current?.scrollTo?.({top:c.current.scrollHeight})},[r.messages,r.streamBuffer]);let h=(0,Q.useCallback)(()=>{r.dirty&&r.phase!==`done`?a(!0):n.exit()},[r.dirty,r.phase,n]),g=(0,Q.useCallback)(e=>{e.key===`Escape`&&(e.stopPropagation(),i?a(!1):r.phase===`commit`&&!r.submitting?r.backToChat():r.phase===`chat`&&h())},[i,r,h]),_=r.messages.length===0&&r.streamBuffer===null&&!r.busy,v=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,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,onKeyDown:g,"data-testid":`builder-conversation`,children:[r.phase===`chat`&&(_?(0,$.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,$.jsxs)(fy.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,$.jsxs)(`div`,{className:`mb-4 text-center`,children:[(0,$.jsx)(un,{className:`mx-auto h-7 w-7 text-accent-primary/60`}),(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium`,children:t(`shell.emptyTitle`)}),(0,$.jsx)(`p`,{className:`mx-auto mt-1 max-w-sm text-xs text-muted-foreground`,children:t(`shell.emptyHint`)})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(JO,{active:!0,inset:-3,radius:`1rem`}),(0,$.jsx)(fy.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:fj,children:(0,$.jsx)(dA,{session:r,autoFocus:!0})})]}),(0,$.jsx)(pA,{items:r.recent,loading:r.recentLoading,disabled:!r.conversationReady,onResume:e=>void r.resume(e),onDiscard:e=>void r.discardRecent(e)})]})}):(0,$.jsxs)(`div`,{className:v,children:[(0,$.jsxs)(`div`,{ref:c,className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,"data-testid":`builder-messages`,children:[r.messages.map((e,t)=>e.role===`user`&&e.intent?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(uj,{kind:e.intent,mode:`settled`,createdAt:e.createdAt})},`${t}-${e.createdAt}`):(0,$.jsx)(Rx,{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}`)),(0,$.jsxs)(f_,{initial:!1,children:[p&&(0,$.jsx)(uj,{kind:`surprise`,mode:`offer`,onAction:r.surpriseMe,disabled:!r.conversationReady},`surprise`),m&&(0,$.jsx)(uj,{kind:`approve`,mode:`offer`,onAction:r.approveBlueprint,disabled:!r.conversationReady},`approve`)]}),(r.busy||r.streamBuffer!==null)&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r.streamBuffer!==null&&St(r.streamBuffer)&&(0,$.jsx)(Rx,{role:`assistant`,content:St(r.streamBuffer),streaming:!0}),r.generation.generating||r.snapshot.status===`repairing`||r.snapshot.status===`generating`?(0,$.jsx)(mA,{specsStarted:r.generation.specsStarted,snapshot:r.snapshot}):(0,$.jsx)(bb,{tool:null})]})]}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsx)(fy.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(fj,e===`inline`&&`mx-auto max-w-[680px]`),children:(0,$.jsx)(dA,{session:r})})})]})),r.phase===`commit`&&r.blueprint&&(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto`,children:(0,$.jsx)(uA,{blueprint:r.blueprint,onSubmit:r.submitCommit,onBack:r.backToChat,submitting:r.submitting,error:r.commitError,errorDetail:r.commitErrorDetail})}),r.phase===`progress`&&(0,$.jsxs)(`div`,{className:`mx-auto mt-10 w-full max-w-md p-6`,"data-testid":`commit-progress`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:t(`progress.title`)}),(0,$.jsx)(`ul`,{className:`mt-4 space-y-2`,children:qA.map(e=>{let n=r.commitSteps.find(t=>t.step===e);return!n&&e===`github`?null:(0,$.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[!n&&(0,$.jsx)(No,{className:`h-3.5 w-3.5 text-muted-foreground/40`}),n?.status===`running`&&(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin text-accent-info`}),n?.status===`done`&&(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 text-accent-success`}),n?.status===`warning`&&(0,$.jsx)(fn,{className:`h-3.5 w-3.5 text-accent-warning`}),n?.status===`failed`&&(0,$.jsx)(mn,{className:`h-3.5 w-3.5 text-destructive`}),(0,$.jsx)(`span`,{className:X(!n&&`text-muted-foreground/50`),children:t(`progress.steps.${e}`)}),n?.status===`warning`&&e===`github`?(0,$.jsx)(`span`,{className:`truncate text-[10px] text-accent-warning`,title:n.detail,children:t(KA(n.code))}):n?.detail&&(0,$.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,title:n.detail,children:n.detail})]},e)})})]}),r.phase===`done`&&(0,$.jsxs)(`div`,{className:`mx-auto mt-12 w-full max-w-md p-6 text-center`,"data-testid":`commit-done`,children:[(0,$.jsx)(Ht,{className:`mx-auto h-10 w-10 rounded-full bg-accent-success/15 p-2 text-accent-success`}),(0,$.jsx)(`h2`,{className:`mt-3 text-sm font-semibold`,children:t(`done.title`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`done.description`)}),r.launched&&r.createdProjectId&&(0,$.jsx)(cj,{projectId:r.createdProjectId}),(0,$.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2`,children:[!r.launched&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{onClick:()=>void r.launchM1(),disabled:r.launching,"data-testid":`launch-m1`,children:[r.launching?(0,$.jsx)(rn,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`}),t(`done.launchM1`)]}),_A()===`sequential`&&(0,$.jsx)(aj,{checked:o,onChange:e=>{s(e),xA(e)},disabled:r.launching,testId:`done-auto-advance`})]}),(0,$.jsx)(Z,{variant:`outline`,onClick:r.openProject,"data-testid":`open-project`,children:t(`done.openProject`)})]})]}),i&&(0,$.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,$.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,$.jsx)(`p`,{id:`builder-exit-confirm-title`,className:`text-sm font-medium`,children:t(`mode.exitConfirmTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`mode.exitConfirmBody`)}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>a(!1),"data-testid":`builder-exit-cancel`,children:t(`mode.exitConfirmCancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,onClick:()=>{a(!1),n.exit()},"data-testid":`builder-exit-confirm-btn`,children:t(`mode.exitConfirmDiscard`)})]})]})})]})}var mj=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`),hj={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 gj({spec:e,index:t,milestoneLabel:n=`M1`,onClose:r}){let{t:i}=K(`builder`),{t:a}=K(`tickets`),o=`blueprint-spec-summary-${t}`;return(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,xb.createPortal)((0,$.jsxs)(`div`,{"data-testid":`blueprint-spec-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:r,"aria-hidden":!0}),(0,$.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,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border/40 px-5 py-4`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-primary`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:i(`specModal.eyebrow`,{milestone:n,index:t+1})}),(0,$.jsx)(`h2`,{className:`mt-0.5 text-base font-semibold text-foreground`,children:e.title}),e.shortSummary.trim()&&(0,$.jsxs)(`p`,{id:o,className:`mt-1 text-xs leading-5 text-muted-foreground`,"data-testid":`blueprint-spec-summary`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[i(`specModal.summary`),`: `]}),e.shortSummary]}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[(0,$.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,hj[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,$.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,$.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,$.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,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`section`,{"aria-label":i(`specModal.description`),"data-testid":`blueprint-spec-description`,children:e.description.trim()?(0,$.jsx)(`div`,{className:mj,children:(0,$.jsx)(Jn,{remarkPlugins:[Yn],children:e.description})}):(0,$.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.empty`)})}),(0,$.jsxs)(`section`,{"aria-labelledby":`blueprint-spec-criteria-heading`,"data-testid":`blueprint-spec-acceptance-criteria`,children:[(0,$.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,$.jsx)(`span`,{children:i(`specModal.acceptanceCriteria`)}),(0,$.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,$.jsx)(`ol`,{className:`space-y-2`,children:e.acceptanceCriteria.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2 text-sm leading-6 text-foreground/85`,"data-testid":`blueprint-spec-criterion-${t}`,children:[(0,$.jsx)(Mo,{className:`mt-1 h-4 w-4 shrink-0 text-accent-success`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:e})]},`${t}-${e}`))}):(0,$.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.criteriaEmpty`)})]})]})]})]}),document.body)}var _j={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 vj({blueprint:e,milestoneLabel:t=`M1`,snapshot:n}){let{t:r}=K(`builder`),{t:i}=K(`tickets`),a=gt(e),[o,s]=(0,Q.useState)(null),c=[{key:`product`,label:r(`panel.product`),value:e?.product.name??``},{key:`coreFlow`,label:r(`panel.coreFlow`),value:e?.coreFlow??``},{key:`platform`,label:r(`panel.platform`),value:e?.platform??``},{key:`stack`,label:r(`panel.stack`),value:e?[e.stack.language,e.stack.framework,e.stack.db].filter(Boolean).join(` · `):``},{key:`milestones`,label:r(`panel.milestones`),value:e&&e.milestones.length>0?r(`panel.milestonesValue`,{count:e.milestones.length}):``}];return(0,$.jsxs)(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`blueprint-panel`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[r(`panel.title`),n?.status===`repairing`&&(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin text-accent-info`,"aria-hidden":!0,"data-testid":`panel-repairing`})]}),(0,$.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>(0,$.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-xs transition-colors`,a[e.key]?`border-accent-success/30 bg-accent-success/5`:`border-border/30`),"data-testid":`dimension-${e.key}`,children:[a[e.key]?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-label":`✓`}):(0,$.jsx)(mn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/40`,"aria-label":`✗`}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.value&&(0,$.jsx)(`span`,{className:`ml-auto truncate text-muted-foreground`,title:e.value,children:e.value})]},e.key))})]}),e&&e.assumptions.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`panel.assumptions`)}),(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:e.assumptions.map((e,t)=>(0,$.jsx)(`li`,{className:`text-[11px] text-muted-foreground before:mr-1.5 before:content-['·']`,children:e},t))})]}),e&&e.m1Specs.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`h4`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,$.jsx)(xs,{className:`h-3 w-3`}),r(`panel.m1Specs`,{count:e.m1Specs.length}),(0,$.jsx)(`span`,{className:X(`ml-auto rounded-full border px-1.5 py-px text-[9px] font-medium normal-case tracking-normal`,e.specsComplete?`border-accent-success/35 bg-accent-success/10 text-accent-success`:`border-accent-warning/35 bg-accent-warning/10 text-accent-warning`),"data-testid":`m1-specs-completeness`,children:e.specsComplete?r(`panel.specsComplete`):r(`panel.specsInProgress`)})]}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.m1Specs.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(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:r(`specModal.open`),children:(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium leading-tight`,children:e.title}),e.shortSummary.trim()&&(0,$.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,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,_j[e.priority]),"data-testid":`m1-spec-priority-${t}`,children:i(`priority.${e.priority}`)}),!e.description.trim()&&e.acceptanceCriteria.length===0?(0,$.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 rounded-full border px-1.5 py-px text-[9px]`,n?.status===`generating`?`border-accent-info/35 bg-accent-info/10 text-accent-info`:`border-border/50 bg-surface/70 text-muted-foreground`),"data-testid":`m1-spec-unwritten-${t}`,children:[n?.status===`generating`?(0,$.jsx)(rn,{className:`h-2.5 w-2.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ts,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),r(n?.status===`generating`?`panel.specWriting`:`panel.specPendingBody`)]}):(0,$.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,$.jsx)(Ts,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),r(`panel.criteriaCount`,{count:e.acceptanceCriteria.length})]}),e.labels.map(e=>(0,$.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,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-[9px] text-muted-foreground`,children:r(`panel.dependsOn`,{index:e.dependsOnIndex+1})})]})]})]})},`${t}-${e.title}`))})]}),e&&e.milestones.length>1&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`panel.laterMilestones`)}),e.milestones.slice(1).map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-border/20 px-2.5 py-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium`,children:e.title}),e.plannedSpecs.length>0&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e.plannedSpecs.join(` · `)})]},e.id||e.title))]}),!e&&(0,$.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground/60`,children:r(`panel.empty`)}),e&&o!==null&&e.m1Specs[o]&&(0,$.jsx)(gj,{spec:e.m1Specs[o],index:o,milestoneLabel:t,onClose:()=>s(null)})]})}var yj={done:Ht,pending:No,blocked:fn,writing:rn},bj={done:`text-accent-success`,pending:`text-muted-foreground/50`,blocked:`text-accent-warning`,writing:`text-accent-info animate-spin`};function xj({readiness:e,snapshot:t,busy:n,primaryLabel:r,onPrimary:i,onRepair:a,primaryTestId:o=`builder-create-specs`,showPrimary:s=!0}){let{t:c}=K(`builder`),[l,u]=(0,Q.useState)(!1),d=t.status===`repairing`,f=t.status===`rejected`,p=t.status===`accepted`&&t.generationHalted===!0&&!n,m=e.steps.find(e=>e.key===`specs`),h=m?.state===`done`,g=!!a&&h&&e.issues.length>0,_=e.steps.find(e=>e.state!==`done`);return(0,$.jsxs)(`div`,{className:`space-y-2.5 border-t border-border/40 p-3`,"data-testid":`blueprint-readiness`,children:[(0,$.jsx)(`ol`,{className:`space-y-1`,"aria-label":c(`readiness.title`),children:e.steps.map(e=>{let t=yj[e.state];return(0,$.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4`,"data-testid":`readiness-step-${e.key}`,"data-state":e.state,children:[(0,$.jsx)(t,{className:X(`mt-px h-3.5 w-3.5 shrink-0`,bj[e.state]),"aria-hidden":!0}),(0,$.jsx)(`span`,{className:X(`font-medium`,e.state===`pending`&&`text-muted-foreground`,e.state===`writing`&&`text-accent-info`),children:c(`readiness.steps.${e.key}`)}),(0,$.jsx)(`span`,{className:`ml-auto max-w-[60%] truncate text-right text-muted-foreground`,title:c(`readiness.details.${e.key}.${e.state}`,e.params),children:c(`readiness.details.${e.key}.${e.state}`,e.params)})]},e.key)})}),(0,$.jsxs)(f_,{initial:!1,mode:`wait`,children:[d&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`flex items-center gap-2 rounded-md border border-accent-info/30 bg-accent-info/10 px-2.5 py-1.5 text-[11px] text-accent-info`,"data-testid":`snapshot-repairing`,children:[(0,$.jsx)(rn,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c(`snapshot.repairing.${t.kind}`),t.manual?``:` · ${c(`snapshot.repairing.automatic`)}`]})]},`repairing`),f&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`space-y-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 p-2.5`,"data-testid":`snapshot-rejected`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:c(`snapshot.rejected.title`)}),(0,$.jsx)(`p`,{className:`text-accent-warning/90`,children:c(`snapshot.rejected.${t.reason}`)}),t.repairAttempted&&(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-accent-warning/80`,children:c(`snapshot.rejected.autoRepairFailed`)})]})]}),t.detail&&(0,$.jsx)(`p`,{className:`line-clamp-2 break-all font-mono text-[10px] leading-4 text-foreground/60`,title:t.detail,"data-testid":`snapshot-rejected-detail`,children:t.detail}),a&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`snapshot-retry`,children:[(0,$.jsx)(Js,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.rejected.retry`)]})]},`rejected`),p&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`space-y-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 p-2.5`,"data-testid":`snapshot-halted`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:c(`snapshot.halted.title`)}),(0,$.jsx)(`p`,{className:`text-accent-warning/90`,children:c(`snapshot.halted.detail`,{written:m?.params?.written??0,total:m?.params?.count??0})})]})]}),a&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`snapshot-resume`,children:[(0,$.jsx)(un,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.halted.resume`)]})]},`halted`),t.status===`accepted`&&t.repaired&&!p&&(0,$.jsxs)(fy.p,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,"data-testid":`snapshot-repaired`,children:[(0,$.jsx)(un,{className:`h-3 w-3 text-accent-success`,"aria-hidden":!0}),c(`snapshot.repairedNote`)]},`repaired`)]}),e.issues.length>0&&(0,$.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-surface/40`,"data-testid":`readiness-issues`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-expanded":l,className:`flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px] font-medium text-foreground/80 hover:bg-surface/70`,"data-testid":`readiness-issues-toggle`,children:[(0,$.jsx)(pn,{className:`h-3 w-3 text-accent-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`readiness.issuesCount`,{count:e.issues.length})}),(0,$.jsx)(Zt,{className:X(`h-3.5 w-3.5 transition-transform`,l&&`rotate-180`),"aria-hidden":!0})]}),l&&(0,$.jsx)(`ul`,{className:`max-h-40 space-y-1 overflow-y-auto border-t border-border/30 px-2.5 py-2`,children:e.issues.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[10px] leading-4 text-muted-foreground`,children:[e.specIndex!==null&&(0,$.jsxs)(`span`,{className:`shrink-0 rounded bg-accent-primary/10 px-1 font-mono text-[9px] text-accent-primary`,children:[`#`,e.specIndex+1]}),(0,$.jsx)(`span`,{children:WA(c,e)})]},`${e.specIndex}-${e.field}-${e.code}-${t}`))}),g&&(0,$.jsx)(`div`,{className:`border-t border-border/30 p-2`,children:(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`readiness-ask-fix`,children:[(0,$.jsx)(pn,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`readiness.askFix`)]})})]}),s&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(Z,{className:`w-full`,size:`sm`,disabled:!e.ready||n,onClick:i,"data-testid":o,children:[(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`,"aria-hidden":!0}),r]}),!e.ready&&_&&!d&&!f&&!p&&(0,$.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,"data-testid":`readiness-hint`,children:c(`readiness.hints.${_.key}.${_.state}`,_.params)})]})]})}function Sj(){let{t:e}=K(`agent`),{t}=K(`builder`),{minimize:n,startNewConversation:r,cycleTier:i,active:a,draftPinnedProjectId:o,setPinnedProject:s,builderMode:c}=lM(),[l,u]=(0,Q.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}=bn({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(fy.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,$.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,$.jsxs)(`span`,{className:`relative flex h-5 w-5 shrink-0 items-center justify-center`,children:[(0,$.jsx)(JO,{active:d&&c.session.messages.length===0&&c.session.phase===`chat`,inset:-3}),(0,$.jsx)(So,{className:`h-4 w-4 shrink-0 text-accent-primary`})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/80`,children:d?t(`mode.title`):e(`title`)}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dD,{pinnedProjectId:a?a.pinned_project_id:o,onSelect:e=>void s(e)}),(0,$.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border/60`,"aria-hidden":!0}),(0,$.jsx)(Xk,{})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[!d&&(0,$.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,$.jsx)(cn,{className:`h-4 w-4`})}),(0,$.jsx)(_c,{}),(0,$.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,$.jsx)(ks,{className:`h-4 w-4`}):(0,$.jsx)(Os,{className:`h-4 w-4`})}),(0,$.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,$.jsx)(mn,{className:`h-4 w-4`})})]})]}),d?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsx)(pj,{variant:`floating`}),(0,$.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border/40 lg:w-80`,children:[(0,$.jsx)(vj,{blueprint:c.session.blueprint,snapshot:c.session.snapshot}),c.session.phase===`chat`&&(0,$.jsx)(xj,{readiness:c.session.readiness,snapshot:c.session.snapshot,busy:c.session.busy,primaryLabel:t(`shell.createSpecs`),onPrimary:c.session.goToCommit,onRepair:()=>void c.session.repairSnapshot()})]})]}):(0,$.jsx)(Kk,{variant:`floating`})]}),!l&&(0,$.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,$.jsx)(Nn,{handles:g})})]})}var Cj=`specrails-desktop:agent-bubble-pos`,wj=56,Tj=12;function Ej(){try{let e=localStorage.getItem(Cj);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function Dj(e){let t=Math.max(Tj,window.innerWidth-wj-Tj),n=Math.max(Tj,window.innerHeight-wj-Tj);return{left:Math.min(Math.max(Tj,e.left),t),top:Math.min(Math.max(Tj,e.top),n)}}function Oj(){return{left:Math.round(window.innerWidth/2-wj/2),top:window.innerHeight-wj-20}}function kj(){let{t:e}=K(`agent`),{t}=K(`builder`),{open:n,isStreaming:r,active:i,builderMode:a}=lM(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(()=>Dj(Ej()??Oj())),u=uy(0),d=uy(0),f=(0,Q.useRef)(!1),p=a.active?a.session.busy:r;(0,Q.useEffect)(()=>{let e=()=>l(e=>Dj(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,Q.useCallback)(e=>{try{localStorage.setItem(Cj,JSON.stringify(e))}catch{}},[]);return(0,$.jsxs)(fy.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=Dj({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,$.jsxs)(`span`,{className:`relative flex h-9 w-9 items-center justify-center rounded-full bg-accent-primary/15`,children:[(0,$.jsx)(JO,{active:a.active&&a.session.messages.length===0&&a.session.phase===`chat`,inset:-4}),(0,$.jsx)(So,{className:`h-5 w-5 text-accent-primary`}),p&&(0,$.jsx)(fy.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,$.jsx)(f_,{initial:!1,children:(o||p)&&(0,$.jsx)(fy.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 Aj=`specrails-desktop:uiMode`;function jj(){if(!y)return`kanban`;try{return localStorage.getItem(Aj)===`kanban`?`kanban`:`agent`}catch{return`agent`}}function Mj(e){try{localStorage.setItem(Aj,e)}catch{}}var Nj=(0,Q.createContext)(null);function Pj({children:e,initialMode:t,persist:n=!0}){let[r,i]=(0,Q.useState)(()=>t??jj()),a=(0,Q.useCallback)(e=>{y&&(i(e),n&&Mj(e))},[n]),o=(0,Q.useCallback)(()=>{i(e=>{if(!y)return`kanban`;let t=e===`kanban`?`agent`:`kanban`;return n&&Mj(t),t})},[n]),s=(0,Q.useMemo)(()=>({uiMode:r,setUiMode:a,toggleUiMode:o}),[r,a,o]);return(0,$.jsx)(Nj.Provider,{value:s,children:e})}var Fj={uiMode:`kanban`,setUiMode:()=>{},toggleUiMode:()=>{}};function Ij(){return(0,Q.useContext)(Nj)??Fj}var Lj={streamingText:``,isStreaming:!1,liveTools:[],turnTools:[],queued:[]},Rj=`specrails-desktop:favorite-agent-conversations`;function zj(){try{let e=localStorage.getItem(Rj);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 Bj(e){try{localStorage.setItem(Rj,JSON.stringify([...e]))}catch{}}function Vj(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var Hj=`specrails-desktop:agent-tier-last`;function Uj(){try{let e=localStorage.getItem(Hj),t=e===null?0:Number.parseInt(e,10);return t===0||t===1||t===2||t===3?t:0}catch{return 0}}function Wj(e){try{localStorage.setItem(Hj,String(e))}catch{}}var Gj=new Set([`completed`,`merged`,`discarded`,`superseded`]);function Kj(e,t){return JSON.stringify(e)===JSON.stringify(t)}function qj(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 Jj(e,t){if(t.supersedesDeliveryId===e.prDeliveryId)return 1;if(e.supersedesDeliveryId===t.prDeliveryId)return-1;let n=qj(e),r=qj(t);return n==null||r==null?null:r<n?-1:+(r>n)}function Yj(e,t){let n=null;for(let r of e){if(r.supersedesDeliveryId!==t)continue;if(!n){n=r;continue}let e=qj(n),i=qj(r);(e==null||i==null||i>=e)&&(n=r)}return n}function Xj(e,t){let n=t.restoredFromDeliveryId;if(!n)return!1;let r=Yj(e,t.prDeliveryId);return!r||r.prDeliveryId===n}function Zj(e,t){let n=e.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null),r=[...n].reverse().find(e=>e.prDeliveryId===t.prDeliveryId),i=Xj(n,t);if(r){let e=Gj.has(r.decision),n=Gj.has(t.decision),a=Ft(r.updatedAt,t.updatedAt);if(a===-1||a===0&&!Kj(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=Jj(e,t);if(n===-1||(n===0||n===null)&&!Gj.has(e.decision)&&t.supersedesDeliveryId!==e.prDeliveryId)return!0}return!1}function Qj(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=io(e.content);return!t||t.prDeliveryId!==n||Gj.has(t.decision)?e:(r=!0,{...e,content:JSON.stringify({...t,decision:`discarded`})})});return r?i:e}function $j(e,t){let n=e.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null);if(n.some(e=>e.restoredFromDeliveryId===t.prDeliveryId&&Xj(n,e)))return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let n=io(e.content);return!n||n.railIndex!==t.railIndex||n.prDeliveryId===t.prDeliveryId||Gj.has(n.decision)||Jj(n,t)!==1?e:(r=!0,{...e,content:JSON.stringify({...n,decision:`superseded`})})});return r?i:e}function eM(e,t,n){if(Zj(e,n))return e;let r=$j(Qj(e,n),n),i=JSON.stringify(n),a=r.flatMap((e,t)=>e.role===`system`&&io(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 tM=(0,Q.createContext)(null),nM=0,rM=0,iM={sent:0,received:1,read:2};function aM(e,t){return e&&(!t||iM[e]>=iM[t])?e:t}function oM(e,t){let n=[...e];for(let[e,r]of t.entries()){let i=n.findIndex(e=>e.id===r.id);if(i>=0){let e=aM(n[i].delivery_receipt,r.delivery_receipt);n[i]={...r,...e?{delivery_receipt:e}:{}}}else{let i=new Set(t.slice(e+1).map(e=>e.id)),a=n.findIndex(e=>i.has(e.id));a>=0?n.splice(a,0,r):n.push(r)}}return n}function sM({children:e}){let{registerHandler:t,unregisterHandler:n,connectionStatus:r}=qe(),{uiMode:i}=Ij(),{setActiveProjectId:a,activeProjectId:o}=at(),s=si(),c=(0,Q.useRef)(s);c.current=s;let l=$r(),u=e=>e?c.current.isEditable(e):!l,[d,f]=(0,Q.useState)(`hidden`),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),y=(0,Q.useRef)(new Map),b=(0,Q.useRef)(_);b.current=_;let[x,S]=(0,Q.useState)(zj);(0,Q.useEffect)(()=>{let e=e=>{(e.key===Rj||e.key===null)&&S(zj())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let[C,w]=(0,Q.useState)(new Set),[T,E]=(0,Q.useState)(new Map),[D,O]=(0,Q.useState)(!0),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,F]=(0,Q.useState)(null),I=(0,Q.useRef)(null);I.current=N;let[L,R]=(0,Q.useState)(`claude`),[z,B]=(0,Q.useState)(null),[ee,V]=(0,Q.useState)(()=>Uj()),[H,te]=(0,Q.useState)(null),ne=(0,Q.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});ne.current={provider:L,model:z,tierLevel:ee,effort:H};let re=(0,Q.useRef)(null);re.current=h?.id??null;let ie=(0,Q.useRef)(T);ie.current=T;let ae=(0,Q.useRef)(new Set),oe=(0,Q.useRef)(new Set),se=(0,Q.useRef)(new Map),ce=(0,Q.useRef)(new Map),le=e=>{let t=aM(e.delivery_receipt,se.current.get(`${e.conversation_id}:m:${e.id}`));return t?{...e,delivery_receipt:t}:e},ue=(e,t)=>{let n=aM(t.deliveryReceipt,se.current.get(`${e}:q:${t.queueId}`));return n?{...t,deliveryReceipt:n}:t},de=(0,Q.useRef)(new Set),fe=(0,Q.useRef)(new Map),pe=(0,Q.useRef)(new Map),me=(0,Q.useRef)(new Map),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(0),_e=(0,Q.useRef)(0),ve=(0,Q.useRef)(new Map),ye=(0,Q.useCallback)(e=>{let t=re.current;if(!t)return`untracked`;if(Zj(b.current,e))return`stale`;if(!b.current.some(t=>t.role===`system`&&io(t.content)?.prDeliveryId===e.prDeliveryId))return`untracked`;ge.current++;let n=eM(b.current,t,e);return b.current=n,v(n=>{if(!n.some(t=>t.role===`system`&&io(t.content)?.prDeliveryId===e.prDeliveryId))return b.current=n,n;let r=eM(n,t,e);return b.current=r,r}),`accepted`},[]),U=(0,Q.useCallback)((e,t)=>{E(n=>{let r=t(n.get(e)??Lj),i=new Map(n);return r===null||!r.isStreaming&&!r.streamingText&&r.liveTools.length===0&&r.turnTools.length===0&&r.queued.length===0?i.delete(e):i.set(e,r),i})},[]),be=(0,Q.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===re.current&&!t||w(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),xe=(0,Q.useCallback)(e=>{w(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,Q.useEffect)(()=>{if(!P||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=re.current;e&&xe(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[xe]);let Se=(h?T.get(h.id):void 0)??Lj,Ce=Se.streamingText,W=Se.isStreaming,we=Se.liveTools,Te=Se.turnTools,Ee=Se.queued,De=(0,Q.useMemo)(()=>{let e=new Set;for(let[t,n]of T)n.isStreaming&&e.add(t);return e},[T]),Oe=(0,Q.useCallback)(async()=>{try{let e=await Ra();m(e),S(t=>{let n=Vj(zj(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(Bj(n),n)})}catch{}},[]),ke=(0,Q.useCallback)(async()=>{try{let e=await uo();O(e.enabled)}catch{O(!1)}},[]),Ae=(0,Q.useCallback)(async()=>{try{M((await lo()).any)}catch{M(!0)}},[]),[je,Me]=(0,Q.useState)(0);(0,Q.useEffect)(()=>P?(t(`agent-chat`,e=>{let t=e;if(!t)return;if(t.type===`desktop.project_recovered`){Me(e=>e+1);return}if(typeof t.type!=`string`||!t.type.startsWith(`agent_`))return;if(t.type===`agent_title`&&t.conversationId){let e=t.title??null;m(n=>n.map(n=>n.id===t.conversationId?{...n,title:e}:n)),g(n=>n&&n.id===t.conversationId?{...n,title:e}:n);return}let n=t.conversationId;if(!n)return;fe.current.set(n,(fe.current.get(n)??0)+1);let r=n===re.current,i=e=>{me.current.set(n,oM(me.current.get(n)??[],e).slice(-500)),r&&(b.current=oM(b.current,e),v(t=>oM(t,e)))};if(t.type===`agent_input_receipt`){if(t.receipt!==`received`&&t.receipt!==`read`)return;let e=`${n}:q:${t.queueId}`,a=t.messageId??ce.current.get(e);if(t.queueId&&se.current.set(e,aM(se.current.get(e),t.receipt)),a){let e=`${n}:m:${a}`;se.current.set(e,aM(se.current.get(e),t.receipt));let o=(r?b.current:me.current.get(n)??[]).find(e=>e.id===a);o&&i([le(o)])}U(n,e=>({...e,queued:e.queued.map(e=>e.queueId===t.queueId?{...e,deliveryReceipt:aM(e.deliveryReceipt,t.receipt)}:e)}))}else if(t.type===`agent_stream`)be(n),U(n,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(t.delta??``)}));else if(t.type===`agent_tool`)U(n,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${nM++}`,tool:t.tool??`tool`,...t.input?{input:t.input}:{},...t.toolId?{toolId:t.toolId}:{},...t.timestamp?{at:t.timestamp}:{}}].slice(-200)}));else if(t.type===`agent_tool_result`)U(n,e=>{let n=[...e.liveTools],r=t.toolId?n.findIndex(e=>e.toolId===t.toolId):-1;if(r===-1){for(let e=n.length-1;e>=0;e--)if(n[e].output===void 0){r=e;break}}return r===-1?e:(n[r]={...n[r],output:t.output??``,...t.isError?{isError:!0}:{}},{...e,liveTools:n})});else if(t.type===`agent_partial`){let e=t.fullText??``;e&&i([{id:t.messageId??`partial-${n}-${t.timestamp??Date.now()}`,conversation_id:n,role:`assistant`,content:e,created_at:t.timestamp??new Date().toISOString()}])}else if(t.type===`agent_done`){ve.current.delete(n),be(n);let e=t.fullText??``;t.messageId&&e?i([{id:t.messageId,conversation_id:n,role:`assistant`,content:e,created_at:t.timestamp??new Date().toISOString()}]):r&&e&&v(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()}]}),U(n,e=>({...Lj,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}))}else if(t.type===`agent_error`){ve.current.delete(n),be(n),U(n,e=>({...Lj,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}));let e=t.error||`The agent turn failed.`;J.error(e),r&&v(t=>[...t,{id:`err-${Date.now()}`,conversation_id:n,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(t.type===`agent_queued`){if(t.queueId&&ae.current.has(t.queueId))return;U(n,e=>{let r=aM(t.deliveryReceipt??t.delivery_receipt,se.current.get(`${n}:q:${t.queueId}`)),i={queueId:t.queueId??`srv-${rM++}`,text:t.text??``,contextRefs:t.contextRefs,attachmentIds:t.attachmentIds,deliveryMode:t.deliveryMode,...r?{deliveryReceipt:r}:{},timestamp:t.timestamp};return t.queueId&&e.queued.some(e=>e.queueId===t.queueId)?{...e,queued:e.queued.map(e=>e.queueId===t.queueId?{...e,...i,deliveryReceipt:aM(e.deliveryReceipt,i.deliveryReceipt),deliveryMode:e.deliveryMode===`steer`?`steer`:i.deliveryMode??e.deliveryMode,attachmentIds:i.attachmentIds??e.attachmentIds,contextRefs:i.contextRefs??e.contextRefs}:e)}:{...e,queued:[...e.queued,i]}})}else if(t.type===`agent_steered`){if(!t.messageId)return;if(de.current.has(t.messageId)){t.queueId&&ae.current.add(t.queueId),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId)}));return}de.current.add(t.messageId),t.queueId&&ae.current.add(t.queueId),ce.current.set(`${n}:q:${t.queueId}`,t.messageId);let e=aM(t.delivery_receipt??t.deliveryReceipt,se.current.get(`${n}:q:${t.queueId}`)),r=[];t.assistantSegment&&r.push({...t.assistantSegment,conversation_id:n,role:`assistant`}),r.push(le({id:t.messageId,conversation_id:n,role:`user`,content:t.text??``,context_refs:t.contextRefs??[],attachment_ids:t.attachmentIds??[],delivery_status:t.deliveryStatus??`delivered`,...e?{delivery_receipt:e}:{},created_at:t.timestamp??new Date().toISOString()})),i(r),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId),streamingText:t.assistantSegment?``:e.streamingText}))}else if(t.type===`agent_dequeued`){if(t.queueId&&ae.current.has(t.queueId))return;if(t.queueId&&ae.current.add(t.queueId),U(n,e=>({...e,queued:t.queueId?e.queued.filter(e=>e.queueId!==t.queueId):e.queued.slice(1),isStreaming:!0,streamingText:``,liveTools:[]})),t.text){t.messageId&&ce.current.set(`${n}:q:${t.queueId}`,t.messageId);let e=aM(t.delivery_receipt??t.deliveryReceipt,se.current.get(`${n}:q:${t.queueId}`));i([le({id:t.messageId??`local-u-${Date.now()}`,conversation_id:n,role:`user`,content:t.text,context_refs:t.contextRefs??[],attachment_ids:t.attachmentIds??[],...t.messageId?{delivery_status:`delivered`}:{},...e?{delivery_receipt:e}:{},created_at:t.timestamp??new Date().toISOString()})])}}else if(t.type===`agent_queue_cleared`)pe.current.set(n,(pe.current.get(n)??0)+1),t.messages?.length&&i(t.messages),U(n,e=>({...e,queued:[]}));else if(t.type===`agent_queue_removed`){if(!t.queueId)return;ae.current.add(t.queueId),oe.current.add(t.queueId),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId)}))}else if(t.type===`agent_queue_edited`)U(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,deliveryMode:t.deliveryMode??e.deliveryMode}:e)}));else if(t.type===`agent_pr_decision`&&(be(n),r)){let t=ro(e);if(t){ge.current++;let e=eM(b.current,n,t);b.current=e,v(e=>{let r=eM(e,n,t);return b.current=r,r})}}}),()=>n(`agent-chat`)):void 0,[t,n,U,be]);let Ne=(0,Q.useCallback)(async(e,t)=>{let n=++_e.current,r=fe.current.get(e)??0;ge.current++;let{conversation:i,messages:a,pendingMessages:o,live:s}=await Ha(e);if(t?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);if(n!==_e.current){if(t)throw new DOMException(`The mission changed during restoration`,`AbortError`);return}ge.current++;let c=oM(a,me.current.get(e)??[]).map(le);for(let e of c)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&de.current.add(e.id);g(i),b.current=c,v(c),xe(e),r===(fe.current.get(e)??0)&&(o!==void 0||s)&&U(e,t=>({...t,...s?{isStreaming:s.isStreaming,streamingText:s.streamingText}:{},queued:o?.filter(e=>!ae.current.has(e.queueId)).map(t=>ue(e,t))??t.queued}))},[xe,U]),Pe=(0,Q.useCallback)(async()=>{let e=re.current;if(!e)return;let t=ge.current,n=fe.current.get(e)??0,r=y.current.get(e)??0;try{let i=await Ha(e);if(re.current!==e||ge.current!==t)return;if(r===(y.current.get(e)??0)&&(g(t=>t?.id===e?i.conversation:t),m(t=>t.map(t=>t.id===e?i.conversation:t))),(i.pendingMessages!==void 0||i.live)&&n===(fe.current.get(e)??0)){let t=oM(i.messages,me.current.get(e)??[]).map(le);for(let e of t)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&de.current.add(e.id);v(e=>oM(t,e.filter(e=>e.id.startsWith(`local-u-`)&&!t.some(t=>t.role===`user`&&t.content===e.content)))),U(e,t=>({...t,...i.live?{isStreaming:i.live.isStreaming,streamingText:i.live.streamingText}:{},queued:i.pendingMessages?.filter(e=>!ae.current.has(e.queueId)).map(t=>ue(e,t))??t.queued}))}let a=i.messages.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null);if(a.length===0)return;v(t=>{let n=a.reduce((t,n)=>eM(t,e,n),t);return b.current=n,n})}catch{}},[U]),Fe=(0,Q.useCallback)(async()=>{try{let e=new Map(fe.current),t=await Ba(),n=new Set(t.turns.map(e=>e.conversationId)),r=Date.parse(t.capturedAt),i=[...ie.current].flatMap(([t,i])=>{if(!i.isStreaming||n.has(t)||(e.get(t)??0)!==(fe.current.get(t)??0))return[];let a=ve.current.get(t);return a&&Date.parse(a)>r?[]:[t]});E(i=>{let a=new Map(i);for(let[t,o]of i){if(!o.isStreaming||n.has(t)||(e.get(t)??0)!==(fe.current.get(t)??0))continue;let i=ve.current.get(t);i&&Date.parse(i)>r||a.set(t,{...Lj,queued:o.queued,turnTools:o.liveTools.length?o.liveTools:o.turnTools})}for(let n of t.turns){let t=n.conversationId;if((e.get(t)??0)!==(fe.current.get(t)??0))continue;let r=a.get(t)??Lj;a.set(t,{...r,isStreaming:!0,streamingText:n.streamingText??r.streamingText,queued:n.pendingMessages?.filter(e=>!ae.current.has(e.queueId)).map(e=>ue(t,e))??r.queued})}return a});for(let e of i)ve.current.delete(e);let a=re.current;if(a&&i.includes(a)){let e=`interrupted-${a}-${t.snapshotVersion}`;v(n=>n.some(t=>t.id===e)?n:[...n,{id:e,conversation_id:a,role:`assistant`,content:`⚠️ The agent turn was interrupted when the Specrails server reconnected. It was not retried.`,created_at:t.capturedAt}])}console.info(`[agent-chat] reconciled active turns`,{snapshotVersion:t.snapshotVersion,active:n.size,interrupted:i.length})}catch{}},[]);(0,Q.useEffect)(()=>{let e=()=>{Oe(),Pe()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Pe,Oe]),(0,Q.useEffect)(()=>{je&&(Oe(),Pe())},[je,Oe,Pe]);let Ie=(0,Q.useRef)(r);(0,Q.useEffect)(()=>{let e=Ie.current;Ie.current=r,r===`connected`&&e!==`connected`&&(Oe(),ke(),Ae(),Pe(),Fe())},[r,Oe,ke,Ae,Pe,Fe]);let Le=(0,Q.useCallback)(async()=>{if(h)return h;if(l)throw Error(`This window is reserved for its mission.`);let e=await Ra();if(m(e),S(t=>{let n=Vj(zj(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(Bj(n),n)}),e.length>0)return await Ne(e[0].id),e[0];let t=await Va({});return m(e=>[t,...e]),g(t),v([]),t},[h,Ne]),Re=(0,Q.useCallback)(()=>{f(`open`),Oe(),ke(),Ae(),Le()},[Oe,ke,Ae,Le]),ze=(0,Q.useCallback)(()=>f(`hidden`),[]),Be=(0,Q.useCallback)(()=>f(`minimized`),[]),[G,Ve]=(0,Q.useState)(!1),He=(0,Q.useRef)(null),Ue=(0,Q.useCallback)(()=>{He.current?.abortAndReset(),Ve(!1)},[]),We=QA(G,{onFinished:Ue});He.current=We;let Ge=(0,Q.useCallback)(()=>{l||(Ve(!0),i!==`agent`&&Re())},[i,Re]),Ke=(0,Q.useCallback)(()=>{f(e=>e===`open`?`minimized`:`open`),d!==`open`&&(Oe(),ke(),Ae(),Le())},[d,Oe,ke,Ae,Le]),Je=(0,Q.useCallback)(async()=>{if(!u(h?.id))throw Error(`This mission is active in another window.`);if(h)return h;if(he.current)return he.current;let e=Va({pinnedProjectId:I.current,provider:ne.current.provider,model:ne.current.model,tierLevel:ne.current.tierLevel,reasoningEffort:ne.current.effort}).then(e=>(Zr(e.id),m(t=>[e,...t]),g(e),v([]),e)).finally(()=>{he.current=null});return he.current=e,e},[h]),Ye=(0,Q.useCallback)(async(e,t)=>{if(!u(h?.id))return{accepted:!1};let n=e.trim();if(!n)return{accepted:!1};let r=h??await Je();fe.current.set(r.id,(fe.current.get(r.id)??0)+1);let i=fe.current.get(r.id),a=pe.current.get(r.id)??0,o=t?.queueId??`q-${Date.now()}-${rM++}`,s=new Date().toISOString();ve.current.set(r.id,s),m(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:s},...e.filter(e=>e.id!==r.id)]),g(e=>e&&e.id===r.id?{...e,updated_at:s}:e);let c={id:`local-u-${Date.now()}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],delivery_receipt:`sent`,created_at:s},l=ie.current.get(r.id)?.isStreaming===!0,d={queueId:o,text:n,contextRefs:t?.contextRefs,attachmentIds:t?.attachmentIds,deliveryMode:`queue`,deliveryReceipt:`sent`,timestamp:s};l?U(r.id,e=>({...e,queued:e.queued.some(e=>e.queueId===o)?e.queued.map(e=>e.queueId===o?{...d,deliveryReceipt:aM(e.deliveryReceipt,d.deliveryReceipt),deliveryMode:e.deliveryMode??d.deliveryMode,timestamp:e.timestamp??d.timestamp}:e):[...e.queued,d]})):(v(e=>[...e,c]),U(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let f=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,s=await Ga(r.id,n,{tierLevel:r.tier_level,attachments:f,queueId:o,contextRefs:e});if(s.removed){ae.current.add(o),oe.current.add(o);let e=!l&&i===fe.current.get(r.id);return re.current===r.id&&v(e=>e.filter(e=>e.id!==c.id)),U(r.id,t=>({...t,queued:t.queued.filter(e=>e.queueId!==o),...e?{isStreaming:!1}:{}})),e&&ve.current.delete(r.id),{accepted:!0,conversationId:r.id}}if(s.message){ce.current.set(`${r.id}:q:${o}`,s.message.id);let e=aM(s.message.delivery_receipt,se.current.get(`${r.id}:q:${o}`)),t=le({...s.message,...e?{delivery_receipt:e}:{}});return ae.current.add(o),me.current.set(r.id,oM(me.current.get(r.id)??[],[t]).slice(-500)),re.current===r.id&&v(e=>oM(e.filter(e=>e.id!==c.id),[t])),U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})),s.duplicate&&Fe(),{accepted:!0,conversationId:r.id}}if(a!==(pe.current.get(r.id)??0))return v(e=>e.filter(e=>e.id!==c.id)),{accepted:!0,conversationId:r.id};let u=s?.queued===!0;return u&&!l?(v(e=>e.filter(e=>e.id!==c.id)),ae.current.has(o)||U(r.id,e=>e.queued.some(e=>e.queueId===o)?e:{...e,queued:[...e.queued,{...d,deliveryMode:s.deliveryMode??d.deliveryMode}]})):!u&&l&&!ae.current.has(o)&&(U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o),isStreaming:!0})),v(e=>[...e,c])),{accepted:!0,conversationId:r.id}}catch(e){return ae.current.has(o)||a!==(pe.current.get(r.id)??0)?{accepted:!0,conversationId:r.id}:(ve.current.delete(r.id),l?U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})):(U(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),v(e=>e.filter(e=>e.id!==c.id))),J.error(e instanceof Error?e.message:`Failed to send message.`),{accepted:!1,conversationId:r.id})}},[h,Je,U,Fe]),Xe=(0,Q.useCallback)(async()=>{if(!(!h||!u(h.id)))try{await Za(h.id),pe.current.set(h.id,(pe.current.get(h.id)??0)+1),fe.current.set(h.id,(fe.current.get(h.id)??0)+1),U(h.id,()=>null)}catch(e){J.error(e instanceof Error?e.message:`Failed to stop the agent.`)}},[h,U]),Ze=(0,Q.useCallback)(async(e,t)=>{let n=h;if(!n||!u(n.id)||ie.current.get(n.id)?.queued.find(t=>t.queueId===e)?.deliveryMode===`steer`)return`conflict`;let r=await Qa(n.id,e,t);return r===`saved`&&U(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[h,U]),Qe=(0,Q.useCallback)(async e=>{let t=h,n=t&&ie.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!u(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await $a(t.id,e);return r===`saved`?(fe.current.set(t.id,(fe.current.get(t.id)??0)+1),U(t.id,t=>({...t,queued:t.queued.map(t=>t.queueId===e?{...t,deliveryMode:`steer`}:t)}))):re.current===t.id&&Pe(),r},[h,U,Pe]),$e=(0,Q.useCallback)(async e=>{let t=h,n=t&&ie.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!u(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await eo(t.id,e);return r===`saved`?(ae.current.add(e),oe.current.add(e),fe.current.set(t.id,(fe.current.get(t.id)??0)+1),U(t.id,t=>({...t,queued:t.queued.filter(t=>t.queueId!==e)}))):re.current===t.id&&Pe(),r},[h,U,Pe]),et=(0,Q.useCallback)(e=>ae.current.has(e)&&!oe.current.has(e),[]),tt=(0,Q.useCallback)(async e=>{if(!h||!u(h.id))return;let t=(y.current.get(h.id)??0)+1;y.current.set(h.id,t);let n=await Ua(h.id,e);y.current.get(h.id)===t&&(g(e=>e?.id===n.id?n:e),m(e=>e.map(e=>e.id===n.id?n:e)))},[h]),K=(0,Q.useCallback)(async e=>{u(h?.id)&&(Wj(e),h?await tt({tierLevel:e}):V(e))},[h,tt]),q=(0,Q.useCallback)(async()=>{let e=((h?.tier_level??ee)+1)%4;await K(e)},[h,ee,K]),nt=(0,Q.useCallback)(async e=>{h?await tt({provider:e}):(R(e),B(null),te(null))},[h,tt]),rt=(0,Q.useCallback)(async e=>{h?await tt({model:e}):(B(e),te(null))},[h,tt]),it=(0,Q.useCallback)(async e=>{h?await tt({reasoningEffort:e}):te(e)},[h,tt]),ot=(0,Q.useCallback)(async e=>{l||!u(h?.id)||(h?await tt({pinnedProjectId:e}):F(e),!h&&e&&i===`agent`&&a(e))},[h,tt,i,a]),Y=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let e=Y.current;if(Y.current=o,!(e===void 0||e===o)&&!(l||i!==`agent`||!o)){if(!h){F(o);return}b.current.length>0||h.pinned_project_id!==o&&tt({pinnedProjectId:o})}},[o,i,h,tt]);let st=(0,Q.useCallback)(e=>{l||(Ue(),g(null),v([]),F(e??null),R(`claude`),B(null),V(Uj()),te(null))},[Ue]),ct=(0,Q.useCallback)(async e=>{if(l)return;Ue();let t=await Va({pinnedProjectId:e===void 0?h?.pinned_project_id??null:e,tierLevel:Uj()});m(e=>[t,...e]),g(t),v([])},[h,Ue]),lt=(0,Q.useCallback)(async(e,t)=>{if(!(l&&!t?.windowRestore&&c.current.current?.conversationId!==e)&&!(!l&&!t?.windowRestore&&await c.current.focus(e))){if(t?.signal?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);Ue(),await Ne(e,t?.signal),t?.windowRestore&&i!==`agent`&&f(`open`)}},[Ne,Ue,l,i]),ut=(0,Q.useCallback)(async e=>{u(e)&&(await Wa(e),await c.current.discard(e),m(t=>t.filter(t=>t.id!==e)),S(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),Bj(n),n}),U(e,()=>null),re.current===e&&(g(null),v([])))},[U]),dt=(0,Q.useCallback)(async(e,t)=>{if(!u(e))return;let n=t.trim()||null;y.current.set(e,(y.current.get(e)??0)+1);let r;m(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),g(t=>t&&t.id===e?{...t,title:n}:t);try{await Ua(e,{title:n})}catch(t){throw m(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),g(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),ft=(0,Q.useCallback)(e=>{S(()=>{let t=new Set(zj());return t.has(e)?t.delete(e):t.add(e),Bj(t),t})},[]),pt=(0,Q.useCallback)(async()=>{A(!0);try{await fo(),await ke()}catch(e){J.error(e instanceof Error?e.message:`Failed to enable MCP.`)}finally{A(!1)}},[ke]),mt=(0,Q.useMemo)(()=>({visibility:d,open:Re,close:ze,minimize:Be,toggle:Ke,conversations:p,active:h,messages:_,streamingText:Ce,isStreaming:W,liveTools:we,turnTools:Te,queuedMessages:Ee,streamingConversationIds:De,liveByConversation:T,unreadConversationIds:C,favoriteConversationIds:x,mcpEnabled:D,enablingMcp:k,enableMcpServer:pt,providersReady:j,send:Ye,abort:Xe,editQueuedMessage:Ze,steerQueuedMessage:Qe,removeQueuedMessage:$e,wasQueueConsumed:et,cycleTier:q,setTier:K,setProvider:nt,setModel:rt,setPinnedProject:ot,newConversation:ct,startNewConversation:st,materializeDraftConversation:Je,draftPinnedProjectId:N,draftProvider:L,draftModel:z,draftTierLevel:ee,draftEffort:H,setEffort:it,selectConversation:lt,deleteConversation:ut,renameConversation:dt,toggleFavoriteConversation:ft,refreshConversations:Oe,applyPrDecisionSnapshot:ye,builderMode:{active:G,enter:Ge,exit:Ue,session:We}}),[d,Re,ze,Be,Ke,G,Ge,Ue,We,p,h,_,Ce,W,we,Te,Ee,De,T,C,x,D,k,pt,j,Ye,Xe,Ze,Qe,$e,et,q,K,nt,rt,ot,ct,st,Je,N,L,z,ee,H,it,lt,ut,dt,ft,Oe,ye]),ht=P&&i!==`agent`;return(0,$.jsxs)(tM.Provider,{value:mt,children:[e,ht&&d===`open`&&(0,$.jsx)(Sj,{}),ht&&d!==`open`&&(0,$.jsx)(kj,{})]})}var cM={visibility:`hidden`,open:()=>{},close:()=>{},minimize:()=>{},toggle:()=>{},conversations:[],active:null,messages:[],streamingText:``,isStreaming:!1,liveTools:[],turnTools:[],queuedMessages:[],streamingConversationIds:new Set,unreadConversationIds:new Set,liveByConversation:new Map,favoriteConversationIds:new Set,mcpEnabled:!0,enablingMcp:!1,enableMcpServer:async()=>{},providersReady:!0,send:async()=>({accepted:!1}),abort:async()=>{},editQueuedMessage:async()=>`conflict`,steerQueuedMessage:async()=>`conflict`,removeQueuedMessage: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,launched:!1,submitting:!1,conversationReady:!1,conversationId:null,dirty:!1,canProposeCommit:!1,specQualityDetail:null,readiness:{ready:!1,steps:[],issues:[]},snapshot:{status:`idle`},generation:{generating:!1,specsStarted:0},recent:[],recentLoading:!1,resume:async()=>{},discardRecent:async()=>{},repairSnapshot:async()=>{},showSurpriseMe:!0,provider:`claude`,model:null,models:[],efforts:[],effort:`medium`,draft:``,setDraft:()=>{},setEffort:()=>{},setProvider:()=>{},setModel:()=>{},send:()=>{},surpriseMe:()=>{},approveBlueprint:()=>{},goToCommit:()=>{},backToChat:()=>{},submitCommit:()=>{},launchM1:async()=>{},openProject:()=>{},abortAndReset:()=>{}}}};function lM(){return(0,Q.useContext)(tM)??cM}var uM=new Map;function dM(){let e=lM(),t=Ux(),n=at(),r=Ca(),{registerHandlers:i}=si(),{t:a}=K(`agent`),o=(0,Q.useRef)({chat:e,workspace:t,desktop:n,terminals:r,t:a});o.current={chat:e,workspace:t,desktop:n,terminals:r,t:a};let s=(0,Q.useRef)(null),c=(0,Q.useRef)(!1);(0,Q.useLayoutEffect)(()=>{let n=e.active?.id??`__new-mission__`,r=s.current;if(c.current||r===n)return;s.current=n,r&&uM.set(r,t.captureWorkspace());let i=uM.get(n);i?t.restoreWorkspace(i):r&&t.restoreWorkspace({...t.captureWorkspace(),browserOpen:!1,browserOwnerId:null,browserUrl:null,pendingCaptures:[]})},[e.active?.id]);let[l,u]=(0,Q.useState)(null);return(0,Q.useLayoutEffect)(()=>{l&&!l.signal.aborted&&e.active?.id===l.target.conversationId&&n.activeProjectId===l.target.projectId&&(l.resolve(),u(e=>e===l?null:e))},[l,e.active?.id,n.activeProjectId]),(0,Q.useEffect)(()=>i({recover(e,t){Sy(t.conversationId,e.scroll)},capture(e){let{chat:t,workspace:n,terminals:r,t:i}=o.current;if(t.active?.id!==e.conversationId)throw Error(i(`window.wrongMission`));if(Ty(e.conversationId))throw Error(i(`window.finishPending`));return{version:1,...e,capturedAt:Date.now(),composer:Gr(e.conversationId),scroll:xy(e.conversationId),workspace:{...n.captureWorkspace(),...e.projectId?{codeSelection:my(e.projectId,e.conversationId),terminal:(({activeId:e,visibility:t,userHeight:n})=>({activeId:e,visibility:t,userHeight:n}))(r.getState(e.projectId))}:{}}}},async restore(e,t,n){let r=()=>new DOMException(`Window transfer cancelled`,`AbortError`);if(n.aborted)throw r();let i=o.current.chat.active?.id;i&&uM.set(i,o.current.workspace.captureWorkspace()),c.current=!0;try{if(await o.current.chat.selectConversation(t.conversationId,{windowRestore:!0,signal:n}),n.aborted)throw r();if(s.current=t.conversationId,uM.set(t.conversationId,e.workspace),qr(t.conversationId,e.composer),t.projectId&&(e.workspace.codeSelection&&hy(t.projectId,t.conversationId,e.workspace.codeSelection),e.workspace.terminal)){let n=e.workspace.terminal,r=o.current.terminals;r.ensureProject(t.projectId),r.setVisibility(t.projectId,n.visibility),r.setUserHeight(t.projectId,n.userHeight),n.activeId&&r.setActive(t.projectId,n.activeId)}o.current.workspace.restoreWorkspace(e.workspace),o.current.desktop.setActiveProjectId(t.projectId),Sy(t.conversationId,e.scroll),await new Promise((e,i)=>{let a=()=>{u(e=>e?.signal===n?null:e),i(r())};n.addEventListener(`abort`,a,{once:!0}),u({target:t,signal:n,resolve:()=>{n.removeEventListener(`abort`,a),e()}})})}finally{c.current=!1}}}),[i]),null}var fM=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new pM(this.width*e,this.height*e)}[ct](){return{width:this.width,height:this.height}}toJSON(){return this[ct]()}},pM=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new fM(this.width/e,this.height/e)}[ct](){return{width:this.width,height:this.height}}toJSON(){return this[ct]()}},mM=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof fM?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof pM?this.size:this.size.toPhysical(e)}[ct](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[ct]()}},hM=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new gM(this.x*e,this.y*e)}[ct](){return{x:this.x,y:this.y}}toJSON(){return this[ct]()}},gM=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new hM(this.x/e,this.y/e)}[ct](){return{x:this.x,y:this.y}}toJSON(){return this[ct]()}},_M=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof hM?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof gM?this.position:this.position.toPhysical(e)}[ct](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[ct]()}},vM;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(vM||={});var yM=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},bM;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(bM||={});function xM(){return new wM(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function SM(){return Y(`plugin:window|get_all_windows`).then(e=>e.map(e=>new wM(e,{skip:!0})))}var CM=[`tauri://created`,`tauri://error`],wM=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||Y(`plugin:window|create`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await SM()).find(t=>t.label===e)??null}static getCurrent(){return xM()}static async getAll(){return SM()}static async getFocusedWindow(){for(let e of await SM())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:mr(e,t,{target:{kind:`Window`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:gr(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(CM.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return hr(e,t)}async emitTo(e,t,n){if(CM.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return _r(e,t,n)}_handleTauriEvent(e,t){return CM.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return Y(`plugin:window|scale_factor`,{label:this.label})}async innerPosition(){return Y(`plugin:window|inner_position`,{label:this.label}).then(e=>new gM(e))}async outerPosition(){return Y(`plugin:window|outer_position`,{label:this.label}).then(e=>new gM(e))}async innerSize(){return Y(`plugin:window|inner_size`,{label:this.label}).then(e=>new pM(e))}async outerSize(){return Y(`plugin:window|outer_size`,{label:this.label}).then(e=>new pM(e))}async isFullscreen(){return Y(`plugin:window|is_fullscreen`,{label:this.label})}async isMinimized(){return Y(`plugin:window|is_minimized`,{label:this.label})}async isMaximized(){return Y(`plugin:window|is_maximized`,{label:this.label})}async isFocused(){return Y(`plugin:window|is_focused`,{label:this.label})}async isDecorated(){return Y(`plugin:window|is_decorated`,{label:this.label})}async isResizable(){return Y(`plugin:window|is_resizable`,{label:this.label})}async isMaximizable(){return Y(`plugin:window|is_maximizable`,{label:this.label})}async isMinimizable(){return Y(`plugin:window|is_minimizable`,{label:this.label})}async isClosable(){return Y(`plugin:window|is_closable`,{label:this.label})}async isVisible(){return Y(`plugin:window|is_visible`,{label:this.label})}async title(){return Y(`plugin:window|title`,{label:this.label})}async theme(){return Y(`plugin:window|theme`,{label:this.label})}async isAlwaysOnTop(){return Y(`plugin:window|is_always_on_top`,{label:this.label})}async center(){return Y(`plugin:window|center`,{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===vM.Critical?{type:`Critical`}:{type:`Informational`}),Y(`plugin:window|request_user_attention`,{label:this.label,value:t})}async setResizable(e){return Y(`plugin:window|set_resizable`,{label:this.label,value:e})}async setEnabled(e){return Y(`plugin:window|set_enabled`,{label:this.label,value:e})}async isEnabled(){return Y(`plugin:window|is_enabled`,{label:this.label})}async setMaximizable(e){return Y(`plugin:window|set_maximizable`,{label:this.label,value:e})}async setMinimizable(e){return Y(`plugin:window|set_minimizable`,{label:this.label,value:e})}async setClosable(e){return Y(`plugin:window|set_closable`,{label:this.label,value:e})}async setTitle(e){return Y(`plugin:window|set_title`,{label:this.label,value:e})}async maximize(){return Y(`plugin:window|maximize`,{label:this.label})}async unmaximize(){return Y(`plugin:window|unmaximize`,{label:this.label})}async toggleMaximize(){return Y(`plugin:window|toggle_maximize`,{label:this.label})}async minimize(){return Y(`plugin:window|minimize`,{label:this.label})}async unminimize(){return Y(`plugin:window|unminimize`,{label:this.label})}async show(){return Y(`plugin:window|show`,{label:this.label})}async hide(){return Y(`plugin:window|hide`,{label:this.label})}async close(){return Y(`plugin:window|close`,{label:this.label})}async destroy(){return Y(`plugin:window|destroy`,{label:this.label})}async setDecorations(e){return Y(`plugin:window|set_decorations`,{label:this.label,value:e})}async setShadow(e){return Y(`plugin:window|set_shadow`,{label:this.label,value:e})}async setEffects(e){return Y(`plugin:window|set_effects`,{label:this.label,value:e})}async clearEffects(){return Y(`plugin:window|set_effects`,{label:this.label,value:null})}async setAlwaysOnTop(e){return Y(`plugin:window|set_always_on_top`,{label:this.label,value:e})}async setAlwaysOnBottom(e){return Y(`plugin:window|set_always_on_bottom`,{label:this.label,value:e})}async setContentProtected(e){return Y(`plugin:window|set_content_protected`,{label:this.label,value:e})}async setSize(e){return Y(`plugin:window|set_size`,{label:this.label,value:e instanceof mM?e:new mM(e)})}async setMinSize(e){return Y(`plugin:window|set_min_size`,{label:this.label,value:e instanceof mM?e:e?new mM(e):null})}async setMaxSize(e){return Y(`plugin:window|set_max_size`,{label:this.label,value:e instanceof mM?e:e?new mM(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return Y(`plugin:window|set_size_constraints`,{label:this.label,value:{minWidth:t(e?.minWidth),minHeight:t(e?.minHeight),maxWidth:t(e?.maxWidth),maxHeight:t(e?.maxHeight)}})}async setPosition(e){return Y(`plugin:window|set_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setFullscreen(e){return Y(`plugin:window|set_fullscreen`,{label:this.label,value:e})}async setSimpleFullscreen(e){return Y(`plugin:window|set_simple_fullscreen`,{label:this.label,value:e})}async setFocus(){return Y(`plugin:window|set_focus`,{label:this.label})}async setFocusable(e){return Y(`plugin:window|set_focusable`,{label:this.label,value:e})}async setIcon(e){return Y(`plugin:window|set_icon`,{label:this.label,value:ua(e)})}async setSkipTaskbar(e){return Y(`plugin:window|set_skip_taskbar`,{label:this.label,value:e})}async setCursorGrab(e){return Y(`plugin:window|set_cursor_grab`,{label:this.label,value:e})}async setCursorVisible(e){return Y(`plugin:window|set_cursor_visible`,{label:this.label,value:e})}async setCursorIcon(e){return Y(`plugin:window|set_cursor_icon`,{label:this.label,value:e})}async setBackgroundColor(e){return Y(`plugin:window|set_background_color`,{color:e})}async setCursorPosition(e){return Y(`plugin:window|set_cursor_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setIgnoreCursorEvents(e){return Y(`plugin:window|set_ignore_cursor_events`,{label:this.label,value:e})}async startDragging(){return Y(`plugin:window|start_dragging`,{label:this.label})}async startResizeDragging(e){return Y(`plugin:window|start_resize_dragging`,{label:this.label,value:e})}async setBadgeCount(e){return Y(`plugin:window|set_badge_count`,{label:this.label,value:e})}async setBadgeLabel(e){return Y(`plugin:window|set_badge_label`,{label:this.label,value:e})}async setOverlayIcon(e){return Y(`plugin:window|set_overlay_icon`,{label:this.label,value:e?ua(e):void 0})}async setProgressBar(e){return Y(`plugin:window|set_progress_bar`,{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return Y(`plugin:window|set_visible_on_all_workspaces`,{label:this.label,value:e})}async setTitleBarStyle(e){return Y(`plugin:window|set_title_bar_style`,{label:this.label,value:e})}async setTheme(e){return Y(`plugin:window|set_theme`,{label:this.label,value:e})}async onResized(e){return this.listen(vr.WINDOW_RESIZED,t=>{t.payload=new pM(t.payload),e(t)})}async onMoved(e){return this.listen(vr.WINDOW_MOVED,t=>{t.payload=new gM(t.payload),e(t)})}async onCloseRequested(e){return this.listen(vr.WINDOW_CLOSE_REQUESTED,async t=>{let n=new yM(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(vr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),n=await this.listen(vr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new gM(t.payload.position)}})}),r=await this.listen(vr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),i=await this.listen(vr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(vr.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(vr.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(vr.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(vr.WINDOW_THEME_CHANGED,e)}},TM;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(TM||={});var EM;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(EM||={});var DM;(function(e){e.AppearanceBased=`appearanceBased`,e.Light=`light`,e.Dark=`dark`,e.MediumLight=`mediumLight`,e.UltraDark=`ultraDark`,e.Titlebar=`titlebar`,e.Selection=`selection`,e.Menu=`menu`,e.Popover=`popover`,e.Sidebar=`sidebar`,e.HeaderView=`headerView`,e.Sheet=`sheet`,e.WindowBackground=`windowBackground`,e.HudWindow=`hudWindow`,e.FullScreenUI=`fullScreenUI`,e.Tooltip=`tooltip`,e.ContentBackground=`contentBackground`,e.UnderWindowBackground=`underWindowBackground`,e.UnderPageBackground=`underPageBackground`,e.Mica=`mica`,e.Blur=`blur`,e.Acrylic=`acrylic`,e.Tabbed=`tabbed`,e.TabbedDark=`tabbedDark`,e.TabbedLight=`tabbedLight`})(DM||={});var OM;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(OM||={});var kM=12e-5,AM=36,jM=140,MM=1.5,NM=6;function PM(e,t){return{x:Math.random()*e,y:Math.random()*t,radius:.35+Math.random()*1.25,alpha:.22+Math.random()*.5,drift:MM+Math.random()*(NM-MM)}}function FM(e){let t=e.getBoundingClientRect(),n=t.width||e.parentElement?.clientWidth||window.innerWidth,r=t.height||e.parentElement?.clientHeight||window.innerHeight;return{width:Math.max(1,Math.floor(n)),height:Math.max(1,Math.floor(r))}}function IM(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=0,s=0,c=0,l=0,u=0,d=!document.hidden;function f(){let e=FM(r),t=window.devicePixelRatio||1;if(e.width===o&&e.height===s&&t===c)return;let n=e.width!==o||e.height!==s;if(o=e.width,s=e.height,c=t,r.width=Math.max(1,Math.round(o*t)),r.height=Math.max(1,Math.round(s*t)),r.style.width=`100%`,r.style.height=`100%`,i.setTransform(t,0,0,t,0,0),n||a.length===0){let e=Math.min(jM,Math.max(AM,Math.floor(o*s*kM)));a=Array.from({length:e},()=>PM(o,s))}}function p(e){i.clearRect(0,0,o,s);for(let t of a)t.x+=t.drift*e,t.x>o+t.radius&&(t.x=-t.radius,t.y=Math.random()*s),i.globalAlpha=t.alpha,i.fillStyle=`hsl(213 100% 92%)`,i.beginPath(),i.arc(t.x,t.y,t.radius,0,Math.PI*2),i.fill();i.globalAlpha=1}function m(e){if(!d)return;let t=u===0?.016:Math.min(.05,(e-u)/1e3);u=e,p(t),l=requestAnimationFrame(m)}function h(){d=!document.hidden,d?(u=0,l=requestAnimationFrame(m)):cancelAnimationFrame(l)}let g=null;function _(){g&&g.removeEventListener(`change`,_),f(),v()}function v(){let e=window.devicePixelRatio||1;g=window.matchMedia(`(resolution: ${e}dppx)`),g.addEventListener(`change`,_)}f();let y=null,b=r.parentElement;return typeof ResizeObserver<`u`&&b&&(y=new ResizeObserver(()=>f()),y.observe(b)),window.addEventListener(`resize`,f),v(),document.addEventListener(`visibilitychange`,h),d&&(l=requestAnimationFrame(m)),()=>{cancelAnimationFrame(l),y&&y.disconnect(),g&&g.removeEventListener(`change`,_),window.removeEventListener(`resize`,f),document.removeEventListener(`visibilitychange`,h)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`absolute inset-0 pointer-events-none`,style:{zIndex:-1}})}var LM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeCodePane-CzNPXJND.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([79,1,7,10,42,49]))),RM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeJobsPane-CS4XPM5K.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([80,1,7,12,10,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,44,8,54,49,64,65,67,68,76,6,9,11,43,45,46,47,48,50,51,52,53,55,56,57,58,59,60,61,62,63,66,69,70,71,72,73,74,75,81]))),zM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeAnalyticsPane-90q1FOYY.js`).then(e=>({default:e.AgentModeAnalyticsPane})),__vite__mapDeps([82,1,7,10,42,54,49,64,65])));function BM(){let{t:e}=K(`agent`),{active:t,refreshConversations:n,builderMode:r}=lM(),{codePaneOpen:i,jobsPaneOpen:a,analyticsPaneOpen:o}=Ux(),{activeProjectId:s}=at(),c=si(),l=Cy(t?.id??`__new-mission__`),u=!c.current&&c.transfers.some(e=>e.conversationId===t?.id&&e.state===`detached`),d=ca(),f=d.id===`galaxy`,p=d.id===`code-rain`?e(`emptyTitleCodeRain`):e(`emptyTitle`);(0,Q.useEffect)(()=>{n()},[n]);let m=i&&!!s&&!u,h=a&&!!s&&!u,g=o&&!!s&&!u;return(0,$.jsx)(D_,{reducedMotion:`user`,children:(0,$.jsxs)(`div`,{"data-agent-mode-surface":!0,className:`relative z-0 flex h-full w-full overflow-hidden bg-background`,children:[f&&(0,$.jsx)(IM,{}),(0,$.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(fy.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,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(pj,{variant:`inline`})}):t===null?(0,$.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,$.jsxs)(fy.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,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(So,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:p})]}),(0,$.jsx)(qO,{autoFocus:!0})]})}):(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(Kk,{variant:`inline`})})]}),h&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,$.jsx)(RM,{projectId:s})}),m&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,$.jsx)(LM,{projectId:s,conversationId:t?.id??`__home__`},`${t?.id}:${l}`)}),g&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[560px] border-l border-border`}),children:(0,$.jsx)(zM,{})})]})})}var VM=(e,t,n)=>Math.min(n,Math.max(t,e)),HM=e=>`specrails-desktop:sidebar-width:${e}`;function UM(e,t){let n=HM(e),[r,i]=(0,Q.useState)(()=>{try{let e=localStorage.getItem(n),r=e?Number.parseInt(e,10):NaN;if(Number.isFinite(r))return VM(r,t.min,t.max)}catch{}return t.defaultWidth}),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(r);c.current=r;let l=(0,Q.useRef)(!1),u=(0,Q.useRef)(t);return u.current=t,(0,Q.useLayoutEffect)(()=>{let e=s.current;!e||l.current||(e.style.width=`${t.expanded?r:t.collapsedWidth}px`)},[r,t.expanded,t.collapsedWidth]),{width:r,dragging:a,panelRef:s,onGripPointerDown:(0,Q.useCallback)(e=>{if(e.button!==0||!u.current.expanded)return;e.preventDefault();let t=s.current;if(!t)return;let r=e.clientX,a=c.current,d=a;l.current=!0,o(!0),t.style.transition=`none`;let f=document.body.style.cursor,p=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;try{e.target.setPointerCapture?.(e.pointerId)}catch{}let m=e=>{let n=u.current,i=e.clientX-r,o=n.side===`left`?i:-i;d=VM(a+o,n.min,n.max),t.style.width=`${d}px`},h=()=>{window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,h),window.removeEventListener(`pointercancel`,h),t.style.transition=``,document.body.style.cursor=f,document.body.style.userSelect=p,l.current=!1,o(!1),i(d);try{localStorage.setItem(n,String(Math.round(d)))}catch{}};window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,h),window.addEventListener(`pointercancel`,h)},[n]),onGripKeyDown:(0,Q.useCallback)(e=>{let t=u.current,r=e.shiftKey?24:8,a=t.side===`left`?`ArrowRight`:`ArrowLeft`,o=t.side===`left`?`ArrowLeft`:`ArrowRight`,s=null;if(e.key===a?s=VM(c.current+r,t.min,t.max):e.key===o?s=VM(c.current-r,t.min,t.max):e.key===`Home`&&(s=t.defaultWidth),s!==null){e.preventDefault(),i(s);try{localStorage.setItem(n,String(Math.round(s)))}catch{}}},[n])}}function WM({side:e,dragging:t,width:n,min:r,max:i,label:a,onPointerDown:o,onKeyDown:s}){return(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":a,"aria-valuenow":Math.round(n),"aria-valuemin":r,"aria-valuemax":i,tabIndex:0,"data-testid":`sidebar-resize-grip-${e}`,onPointerDown:o,onKeyDown:s,className:X(`group absolute inset-y-0 z-20 w-1.5 cursor-col-resize outline-none`,e===`left`?`-right-0.5`:`-left-0.5`),children:(0,$.jsx)(`div`,{className:X(`absolute inset-y-0 w-px transition-colors duration-150`,e===`left`?`right-0`:`left-0`,t?`bg-accent-primary`:`bg-transparent group-hover:bg-accent-primary/50 group-focus-visible:bg-accent-primary/70`)})})}var GM=[`pinned-open`,`pinned-collapsed`,`unpinned`],KM=`specrails-desktop:sidebar-mode:left`,qM=`specrails-desktop:sidebar-mode:right`;function JM(e){return typeof e==`string`&&GM.includes(e)}function YM(e){try{let t=window.localStorage.getItem(e);if(JM(t))return t}catch{}return`unpinned`}function XM(e,t){try{window.localStorage.setItem(e,t)}catch{}}function ZM(e){switch(e){case`pinned-open`:return`pinned-collapsed`;case`pinned-collapsed`:return`unpinned`;case`unpinned`:return`pinned-open`}}var QM=(0,Q.createContext)({leftMode:`unpinned`,rightMode:`unpinned`,setLeftMode:()=>{},setRightMode:()=>{},cycleLeftMode:()=>{},cycleRightMode:()=>{}});function $M({children:e}){let[t,n]=(0,Q.useState)(()=>YM(KM)),[r,i]=(0,Q.useState)(()=>YM(qM));(0,Q.useEffect)(()=>{XM(KM,t)},[t]),(0,Q.useEffect)(()=>{XM(qM,r)},[r]);let a=(0,Q.useCallback)(e=>n(e),[]),o=(0,Q.useCallback)(e=>i(e),[]),s=(0,Q.useCallback)(()=>n(e=>ZM(e)),[]),c=(0,Q.useCallback)(()=>i(e=>ZM(e)),[]),l=(0,Q.useMemo)(()=>({leftMode:t,rightMode:r,setLeftMode:a,setRightMode:o,cycleLeftMode:s,cycleRightMode:c}),[t,r,a,o,s,c]);return(0,$.jsx)(QM.Provider,{value:l,children:e})}function eN(){return(0,Q.useContext)(QM)}function tN({open:e,onClose:t,onCommitted:n,projectId:r,milestoneId:i,blueprint:a,provider:o=`claude`}){let{t:s}=K(`builder`),{registerHandler:c,unregisterHandler:l}=qe(),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)({status:`idle`}),O=(0,Q.useRef)(null),k=(0,Q.useRef)(r),A=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{O.current=u},[u]),(0,Q.useEffect)(()=>{k.current=r},[r]);let j=a.milestones.find(e=>e.id===i),M=i.toUpperCase(),N=ir(o,`read-only`),P=(0,Q.useMemo)(()=>BA(v??g,{milestoneLabel:M,minSpecs:1,maxSpecs:10,requireScaffold:!1}),[g,v,M]),F=(0,Q.useMemo)(()=>HA(g,v??g,P,{minSpecs:1,maxSpecs:10}),[g,v,P]),I=(0,Q.useMemo)(()=>Pt(m),[m]);(0,Q.useEffect)(()=>{if(!e||u||!N)return;let t=!1;return fetch(`${nt()}/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;O.current=e.conversation.id,d(e.conversation.id);let n=j?.plannedSpecs??[],r={label:M,title:j?.title??M,planned:n.join(`; `)},i=n.length>0?s(`prompts.milestoneSeedWithPlanned`,r):s(`prompts.milestoneSeed`,r);p([{role:`user`,content:i}]),C(!0),fetch(`${nt()}/chat/conversations/${e.conversation.id}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:i})}).catch(()=>{C(!1),J.error(s(`errors.turnFailed`))})}).catch(()=>{t||J.error(s(`errors.startFailed`))}),()=>{t=!0}},[e,u,i,j,M,N,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=`milestone-generate-${i}`;return c(t,e=>{let t=e;if(t.conversationId===O.current&&!(t.projectId&&t.projectId!==k.current))if(t.type===`chat_stream`)h(e=>(e??``)+String(t.delta??``));else if(t.type===`chat_done`){h(null),C(!1);let e=String(t.fullText??``),n=Lt(e),r=n.stripped.trim()||(n.hadBlocks?``:e);if(r&&p(e=>[...e,{role:`assistant`,content:r}]),n.blueprint)_(n.blueprint),y(n.rawBlueprint),D({status:`accepted`,repaired:n.repaired,repairAttempted:!1,at:new Date().toISOString()});else if(n.rejected.length>0){let e=n.rejected[n.rejected.length-1];D({status:`rejected`,reason:e.reason,detail:e.detail,repairAttempted:!1,at:new Date().toISOString()})}}else t.type===`chat_error`&&(h(null),C(!1),J.error(s(`errors.turnFailed`),{description:String(t.error??``)}))}),()=>l(t)},[e,i,c,l,s]),(0,Q.useEffect)(()=>{A.current?.scrollTo?.({top:A.current.scrollHeight})},[f,m]);let L=(0,Q.useCallback)(e=>{let t=O.current,n=e.trim();!t||!n||S||(p(e=>[...e,{role:`user`,content:n}]),x(``),C(!0),fetch(`${nt()}/chat/conversations/${t}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n})}).catch(()=>{C(!1),J.error(s(`errors.turnFailed`))}))},[S,s]),R=(0,Q.useCallback)(()=>{let e=E.status===`rejected`?s(`snapshot.rejected.${E.reason}`):s(`readiness.issuesCount`,{count:F.issues.length});L(s(`prompts.repairSnapshot`,{reason:e}))},[E,F.issues.length,L,s]),z=(0,Q.useCallback)(()=>{let e=v??g,r=e&&typeof e==`object`&&!Array.isArray(e)?e:null,a=Array.isArray(r?.m1Specs)?r.m1Specs:[];!P.valid||w||(T(!0),fetch(`${nt()}/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();J.success(s(`milestone.commitToast`,{count:r.insertedIds.length,label:M})),n?.(),t()}else{let t=await e.json().catch(()=>({}));J.error(s(`milestone.commitFailed`),{description:t.detail??t.error})}}).catch(()=>J.error(s(`milestone.commitFailed`))).finally(()=>T(!1)))},[g,v,P.valid,w,i,M,t,n,s]);if(!e)return null;let B=g?.m1Specs.length??0;return N?(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-sm`,"data-testid":`milestone-shell`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/40 px-4 py-2.5`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:s(`milestone.title`,{label:M})}),j&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:j.title}),(0,$.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":s(`shell.close`),"data-testid":`milestone-close`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col border-r border-border/40`,children:[(0,$.jsxs)(`div`,{ref:A,className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[f.map((e,t)=>(0,$.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)),m!==null&&(0,$.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-lg bg-surface/70 px-3 py-2 text-xs leading-relaxed`,children:[St(m),(0,$.jsx)(`span`,{className:`ml-0.5 inline-block h-3 w-1.5 animate-pulse bg-accent-primary/70 align-middle`})]}),I.generating&&(0,$.jsx)(mA,{specsStarted:I.specsStarted,snapshot:E})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-border/40 p-3`,children:[(0,$.jsx)(`textarea`,{value:b,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),L(b))},rows:2,placeholder:s(`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,$.jsx)(Z,{size:`sm`,onClick:()=>L(b),disabled:S||!b.trim()||!u,children:S?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(tc,{className:`h-3.5 w-3.5`})})]})]}),(0,$.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col lg:w-96`,children:[(0,$.jsx)(vj,{blueprint:g,milestoneLabel:M,snapshot:E}),(0,$.jsx)(xj,{readiness:F,snapshot:E,busy:S||w,primaryLabel:w?s(`commit.creating`):s(`milestone.commit`,{count:B,label:M}),onPrimary:z,onRepair:R,primaryTestId:`milestone-commit`})]})]})]}):(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-sm`,"data-testid":`milestone-shell`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/40 px-4 py-2.5`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:s(`milestone.title`,{label:M})}),(0,$.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":s(`shell.close`),"data-testid":`milestone-close`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsx)(`p`,{className:`m-4 rounded-md border border-accent-warning/30 bg-accent-warning/10 p-3 text-sm text-accent-warning`,"data-testid":`milestone-provider-unavailable`,children:s(`milestone.providerUnavailable`)})]})}function nN({expanded:e}){let{t}=K(`builder`),n=v(),{activeProjectId:r,projects:i}=at(),{blueprint:a,progress:o,hasBlueprint:s,refresh:c}=Dt(r),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(()=>_A()),[_,y]=(0,Q.useState)(()=>bA()),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),[w,T]=(0,Q.useState)(null);(0,Q.useLayoutEffect)(()=>{if(!l){T(null);return}let e=()=>{let e=S.current?.getBoundingClientRect();if(!e)return;let t=Math.max(8,e.left-320-8),n=Math.min(Math.max(8,e.top),Math.max(8,window.innerHeight-240));T({top:n,left:t})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[l]),(0,Q.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;S.current?.contains(t)||C.current?.contains(t)||u(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let E=(0,Q.useCallback)(async()=>{if(!(!r||d)){f(!0);try{let e=await EA(r,1,h,{autoAdvance:_}),n=CA(1);if(e.ok){let r=e.launched.length+e.pending.length;h===`sequential`&&e.pending.length>0?J.success(t(_?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:n,count:e.ticketCount,n:r})):e.skippedCount>0?J.warning(t(`milestoneProgress.toast.launchedPartial`,{milestone:n,count:e.ticketCount,skipped:e.skippedCount})):J.success(t(`milestoneProgress.toast.launchedAll`,{milestone:n,count:e.ticketCount,n:r})),u(!1)}else e.reason===`chain_active`?J.info(t(`milestoneProgress.toast.chainActive`,{milestone:n})):J.error(t(`done.launchFailed`),{description:e.detail??e.error})}finally{f(!1)}}},[r,_,d,h,t]),D=(0,Q.useCallback)(async(e,n)=>{if(!(!r||p)){m(!0);try{let i=await AA(r,e,n);i.ok?(y(n),xA(n),J.success(t(n?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):J.error(t(`milestoneProgress.chain.autoFailed`),{description:i.detail??i.error})}finally{m(!1)}}},[r,p,t]),O=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await OA(r,e);n.ok?J.success(t(`milestoneProgress.chain.resumed`)):J.error(t(`milestoneProgress.chain.resumeFailed`),{description:n.detail??n.error})}finally{m(!1)}}},[r,p,t]),k=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await kA(r,e);n.ok?J.success(t(`milestoneProgress.chain.cancelledToast`)):J.error(n.detail??n.error)}finally{m(!1)}}},[r,p,t]),A=(0,Q.useCallback)(e=>{u(!1),n(ve?`/review/${e}`:`/`)},[n]),j=(0,Q.useCallback)(()=>{u(!1),n(`/`)},[n]);if(!r||s===!1||!a)return null;let M=o.find(e=>e.n===1)??null,N=M!==null&&bt(M),P=o.find(e=>e.state===`planned`&&e.n>1)??null,F=i.find(e=>e.id===r),I=F?.provider??F?.providers?.[0]??`claude`,L=ir(I,`read-only`),R=N?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex rounded-md border border-border/40 p-0.5 text-[10px]`,role:`radiogroup`,"aria-label":t(`sequential.modeLabel`),title:t(h===`sequential`?`milestoneProgress.sequentialHint`:`milestoneProgress.parallelHint`),"data-testid":`milestone-launch-mode`,children:[`sequential`,`parallel`].map(e=>(0,$.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":h===e,onClick:()=>{g(e),vA(e)},className:X(`flex-1 rounded px-1.5 py-1 font-medium transition-colors`,h===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:text-foreground`),children:t(`sequential.mode.${e}`)},e))}),h===`sequential`&&(0,$.jsx)(aj,{checked:_,onChange:e=>{y(e),xA(e)},testId:`sidebar-auto-advance`}),(0,$.jsxs)(`button`,{type:`button`,onClick:E,disabled:d,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:[d?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Xs,{className:`h-3 w-3`}),t(`sidebar.launchM1`)]})]}):null;return(0,$.jsxs)(`div`,{ref:S,className:`relative`,"data-testid":`builder-sidebar-entry`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,e?`px-2`:`px-0 justify-center`,l?`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,$.jsx)(ps,{className:`w-4 h-4 flex-shrink-0`}),e&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:t(`sidebar.title`)})]}),l&&w&&(0,xb.createPortal)((0,$.jsxs)(`div`,{ref:C,className:`fixed z-[72] w-80 max-h-[80vh] overflow-y-auto rounded-lg border border-border/50 bg-background p-3 shadow-xl`,style:{top:w.top,left:w.left},"data-testid":`builder-sidebar-panel`,children:[(0,$.jsx)(`h4`,{className:`text-xs font-semibold`,children:t(`sidebar.title`)}),(0,$.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:o.map(e=>(0,$.jsx)(sj,{progress:e,actions:e.n===1?R:void 0,chainBusy:p,onReview:A,onOpenRail:j,onResume:O,onCancel:k,onSetAutoAdvance:D},e.id||e.n))}),P&&(0,$.jsx)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{L&&(x(P.id),u(!1))},disabled:!L,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(L?`sidebar.generateHint`:`sidebar.generateUnavailable`),"data-testid":`sidebar-generate-next`,children:[(0,$.jsx)(un,{className:`h-3 w-3`}),t(`sidebar.generateNext`,{n:P.n})]})})]}),document.body),b&&(0,$.jsx)(tN,{open:!0,onClose:()=>x(null),onCommitted:()=>{c()},projectId:r,milestoneId:b,blueprint:a,provider:I})]})}var rN={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function iN({missionOnly:e=!1}={}){let{t}=K(`agent`),{t:n}=K(`nav`),{t:r}=K(`builder`),{rightMode:i,cycleRightMode:a}=eN(),{activeProjectId:o}=at(),s=Ca(),c=Ux(),{builderMode:l}=lM(),[u,d]=(0,Q.useState)(!1),f=l.active||i===`pinned-open`||i===`unpinned`&&u,p=UM(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:f}),m=i!==`unpinned`,h=n(rN[i]),g=!o,_=[{key:`jobs`,icon:Eo,label:t(`workspace.jobs`),onClick:()=>c.toggleJobsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},{key:`analytics`,icon:Do,label:t(`workspace.analytics`),onClick:()=>c.toggleAnalyticsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},...ke()?[{key:`browser`,icon:E,label:t(`workspace.browser`),onClick:()=>c.openBrowser(),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...Ce?[{key:`terminal`,icon:sc,label:t(`workspace.terminal`),onClick:()=>o&&s.togglePanel(o),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...se?[{key:`files`,icon:$o,label:t(`workspace.files`),onClick:()=>c.toggleCodePane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[]];return(0,$.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:()=>{i===`unpinned`&&d(!0)},onMouseLeave:()=>{i===`unpinned`&&!p.dragging&&d(!1)},children:[f&&(0,$.jsx)(WM,{side:`right`,dragging:p.dragging,width:p.width,min:180,max:460,label:n(`sidebarPin.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:p.onGripPointerDown,onKeyDown:p.onGripKeyDown}),(0,$.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,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:t(`workspace.title`)}),(0,$.jsx)(`button`,{type:`button`,onClick:a,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:n(`sidebarPin.withShortcut`,{label:h,shortcut:`⌘B`}),children:(0,$.jsx)(Ls,{className:`w-4 h-4`})})]}),l.active?(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsxs)(fy.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,$.jsx)(vj,{blueprint:l.session.blueprint,snapshot:l.session.snapshot}),l.session.phase===`chat`&&(0,$.jsx)(xj,{readiness:l.session.readiness,snapshot:l.session.snapshot,busy:l.session.busy,primaryLabel:r(`shell.createSpecs`),onPrimary:l.session.goToCommit,onRepair:()=>void l.session.repairSnapshot()})]},`builder-blueprint`)}):(0,$.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[!e&&(0,$.jsx)(nN,{expanded:f}),_.map(({key:e,icon:t,label:n,onClick:r,disabled:i,disabledTitle:a})=>(0,$.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,$.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),f&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:n})]},e))]})]})}var aN=`specrails:terminal-settings-updated`;function oN(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(aN,{detail:e}))}function sN(){return new uN(xM(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function cN(){return Y(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new uN(new wM(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var lN=[`tauri://created`,`tauri://error`],uN=class{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),n?.skip||Y(`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 cN()).find(t=>t.label===e)??null}static getCurrent(){return sN()}static async getAll(){return cN()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:mr(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)}:gr(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(lN.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return hr(e,t)}async emitTo(e,t,n){if(lN.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return _r(e,t,n)}_handleTauriEvent(e,t){return lN.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return Y(`plugin:webview|webview_position`,{label:this.label}).then(e=>new gM(e))}async size(){return Y(`plugin:webview|webview_size`,{label:this.label}).then(e=>new pM(e))}async close(){return Y(`plugin:webview|webview_close`,{label:this.label})}async setSize(e){return Y(`plugin:webview|set_webview_size`,{label:this.label,value:e instanceof mM?e:new mM(e)})}async setPosition(e){return Y(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setFocus(){return Y(`plugin:webview|set_webview_focus`,{label:this.label})}async setAutoResize(e){return Y(`plugin:webview|set_webview_auto_resize`,{label:this.label,value:e})}async hide(){return Y(`plugin:webview|webview_hide`,{label:this.label})}async show(){return Y(`plugin:webview|webview_show`,{label:this.label})}async setZoom(e){return Y(`plugin:webview|set_webview_zoom`,{label:this.label,value:e})}async reparent(e){return Y(`plugin:webview|reparent`,{label:this.label,window:typeof e==`string`?e:e.label})}async clearAllBrowsingData(){return Y(`plugin:webview|clear_all_browsing_data`)}async setBackgroundColor(e){return Y(`plugin:webview|set_webview_background_color`,{color:e})}async onDragDropEvent(e){let t=await this.listen(vr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),n=await this.listen(vr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new gM(t.payload.position)}})}),r=await this.listen(vr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),i=await this.listen(vr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function dN(e){return`'${e.replace(/'/g,`'\\''`)}'`}function fN(e){if(/[\x00-\x1f"%!]/.test(e))throw Error(`unsafe-cmd-path`);return`"`+e+`"`}function pN(e){return`'${e.replace(/'/g,`''`)}'`}function mN(e,t,n=`powershell`){return t?n===`cmd`?fN(e):pN(e):dN(e)}function hN(e,t,n=`powershell`){return e.map(e=>mN(e,t,n)).join(` `)}function gN(e){return/(?:^|[\\/])cmd(?:\.exe)?$/i.test(e??``)?`cmd`:`powershell`}async function _N(e){if(!me())return{dispose:()=>{}};let t=[];try{let 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&&yN(s,u.viewportEl.getBoundingClientRect(),window.devicePixelRatio||1))try{u.writeText(hN(o,i,gN(u.shell)))}catch{J.error(G.t(`terminal:errors.pathPasteUnsafe`))}},o=vN((()=>{try{return sN()}catch{return null}})());o&&t.push(await o(a));let s=vN((()=>{try{return xM()}catch{return null}})());return s&&t.push(await s(a)),t.length===0?{dispose:()=>{}}:{dispose:()=>{for(let e of t)try{e()}catch{}}}}catch{for(let e of t)try{e()}catch{}return{dispose:()=>{}}}}function vN(e){let t=e?.onDragDropEvent;return typeof t==`function`?t.bind(e):null}function yN(e,t,n){let r=Number.isFinite(n)&&n>0?n:1;return bN(e.x/r,e.y/r,t)}function bN(e,t,n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function xN({x:e,y:t,label:n,onSelect:r,onClose:i}){let a=(0,Q.useRef)(null);return(0,Q.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,$.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,$.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 SN({x:e,y:t,providers:n,onSelect:r,onClose:i}){let{t:a}=K(`terminal`),o=(0,Q.useRef)(null);(0,Q.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,$.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,$.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:ur(e)})},e))})}var CN=(0,Q.forwardRef)(function({isOpen:e,className:t,...n},r){let{t:i}=K(`terminal`);return(0,$.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,$.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,$.jsx)(`rect`,{x:`1`,y:`1`,width:`12`,height:`8`,rx:`1.5`}),e?(0,$.jsx)(`path`,{d:`M5 3.5 L7 5.5 L9 3.5`}):(0,$.jsx)(`path`,{d:`M5 6.5 L7 4.5 L9 6.5`})]})})});function wN({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}=K(`terminal`),g=!!i&&i.length>1,_=ur(r),v=h(`topBar.maxTerminals`,{max:10}),y=t?g?h(`topBar.openCliMulti`):h(`topBar.openCli`,{cli:_}):v;return(0,$.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,$.jsx)(`div`,{className:`flex items-center gap-2 pl-1`,children:(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:h(`topBar.title`)})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(TN,{label:y,disabled:!t,onClick:e=>o(e?{x:e.clientX,y:e.clientY}:void 0),children:(0,$.jsx)(un,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(`topBar.openInBrowser`),onClick:s,onContextMenu:e=>{e.preventDefault(),u({x:e.clientX,y:e.clientY})},children:(0,$.jsx)(E,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(l?`topBar.pasteScriptNoActive`:`topBar.pasteScript`),disabled:l,onClick:c,onContextMenu:e=>{e.preventDefault(),d({x:e.clientX,y:e.clientY})},children:(0,$.jsx)(Lo,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:t?h(`topBar.newTerminal`):v,disabled:!t,onClick:a,children:(0,$.jsx)(cn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(`topBar.killActive`),disabled:!n,onClick:f,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(e===`maximized`?`topBar.restorePanel`:`topBar.maximizePanel`),onClick:p,children:e===`maximized`?(0,$.jsx)(ks,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Os,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(CN,{isOpen:!0,onClick:m})]})]})}function TN({label:e,disabled:t,onClick:n,onContextMenu:r,children:i}){return(0,$.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 EN({sessions:e,activeId:t,onActivate:n,onRename:r,onKill:i}){return(0,$.jsx)(`aside`,{className:X(`w-44 shrink-0 border-l border-border/40 bg-background/70`,`overflow-y-auto`),children:(0,$.jsx)(`ul`,{className:`py-1`,children:e.map(e=>(0,$.jsx)(DN,{session:e,active:e.id===t,onActivate:()=>n(e.id),onRename:t=>r(e.id,t),onKill:()=>i(e.id)},e.id))})})}function DN({session:e,active:t,onActivate:n,onRename:r,onKill:i}){let{t:a}=K(`terminal`),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(e.name),u=(0,Q.useRef)(null);(0,Q.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,$.jsx)(`li`,{className:`relative group px-1`,children:(0,$.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,$.jsx)(dc,{className:`h-3 w-3 shrink-0`}),o?(0,$.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,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),!o&&(0,$.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,$.jsx)(an,{className:`h-3 w-3`})}),(0,$.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,$.jsx)(mn,{className:`h-3 w-3`})})]})})}function ON({search:e,onClose:t}){let{t:n}=K(`terminal`),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(r.current?.focus(),()=>{try{e.clearDecorations()}catch{}}),[e]),(0,Q.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,Q.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,$.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,$.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,$.jsxs)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:[f.current,`/`,f.total]}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.previous`),onClick:g,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(Gt,{size:14})}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.next`),onClick:h,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(Zt,{size:14})}),(0,$.jsx)(kN,{label:`Aa`,title:n(`search.matchCase`),active:o,onToggle:()=>s(e=>!e)}),(0,$.jsx)(kN,{label:`.*`,title:n(`search.regex`),active:c,onToggle:()=>l(e=>!e)}),(0,$.jsx)(kN,{label:`W`,title:n(`search.wholeWord`),active:u,onToggle:()=>d(e=>!e)}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.close`),onClick:t,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(mn,{size:14})})]})}function kN({label:e,title:t,active:n,onToggle:r}){return(0,$.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 AN({x:e,y:t,term:n,cwd:r,hasReveal:i,onClose:a,onOpenSearch:o,onReveal:s,onSaveScrollback:c}){let{t:l}=K(`terminal`),u=(0,Q.useRef)(null);(0,Q.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=/Mac/i.test(navigator.platform||``)?`⌘`:`Ctrl+`,m=n.getSelection(),h=m.length>0;function g(){h&&(ma(m),a())}function _(){pa().then(e=>{if(e)try{n.paste(e)}catch{}}),a()}function v(){try{n.selectAll()}catch{}a()}function y(){try{n.clear()}catch{}a()}function b(){o(),a()}function x(){c(),a()}function S(){r&&s(r),a()}return(0,$.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,$.jsx)(jN,{onClick:g,disabled:!h,label:l(`common:actions.copy`),shortcut:p+`C`}),(0,$.jsx)(jN,{onClick:_,label:l(`contextMenu.paste`),shortcut:p+`V`}),(0,$.jsx)(jN,{onClick:v,label:l(`contextMenu.selectAll`),shortcut:p+`A`}),(0,$.jsx)(MN,{}),(0,$.jsx)(jN,{onClick:y,label:l(`contextMenu.clear`),shortcut:p+`K`}),(0,$.jsx)(jN,{onClick:b,label:l(`contextMenu.search`),shortcut:p+`F`}),(0,$.jsx)(jN,{onClick:x,label:l(`contextMenu.saveScrollback`)}),r&&i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(MN,{}),(0,$.jsx)(jN,{onClick:S,label:l(`contextMenu.openPath`,{path:NN(r,40)})})]})]})}function jN({onClick:e,label:t,shortcut:n,disabled:r}){return(0,$.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,$.jsx)(`span`,{children:t}),n&&(0,$.jsx)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:n})]})}function MN(){return(0,$.jsx)(`div`,{className:`my-1 border-t border-[#44475a]`})}function NN(e,t){return e.length<=t?e:`…`+e.slice(e.length-t+1)}async function PN(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(`
|
|
43
|
+
`))}function Ik(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 Lk(){let{t:e}=K(`agent`),{active:t,messages:n,renameConversation:r,deleteConversation:i,startNewConversation:a,favoriteConversationIds:o,toggleFavoriteConversation:s}=lM(),{projects:c}=at(),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=(0,Q.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,Q.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,Q.useEffect)(()=>{l||v(!1)},[l]),(0,Q.useEffect)(()=>{d&&(b.current?.focus(),b.current?.select())},[d]);let w=(0,Q.useCallback)(()=>{m(t?.title??``),f(!0),u(!1)},[t?.title]),T=(0,Q.useCallback)(async()=>{if(t&&(f(!1),(t.title??``)!==p.trim()))try{await r(t.id,p)}catch{J.error(e(`header.renameFailed`))}},[t,p,r,e]),E=(0,Q.useCallback)(async(t,n)=>{u(!1);try{await navigator.clipboard.writeText(t),g(n),setTimeout(()=>g(e=>e===n?null:e),1400)}catch{J.error(e(`header.copyFailed`))}},[e]),D=(0,Q.useCallback)(async()=>{if(t){u(!1);try{await navigator.clipboard.writeText(Fk(t,n,x)),g(`transcript`),J.success(e(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>g(e=>e===`transcript`?null:e),1400)}catch{J.error(e(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[t,n,x,e]),O=(0,Q.useCallback)(()=>{if(t){u(!1);try{let r=Fk(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=Ik(t.title,t.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),J.success(e(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{J.error(e(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[t,n,x,e]),k=(0,Q.useCallback)(async()=>{if(t){u(!1),v(!1);try{await i(t.id),a(t.pinned_project_id)}catch{J.error(e(`header.deleteFailed`))}}},[t,i,a,e]),A=(0,Q.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,$.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,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm`,children:[x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:x.path,children:x.path}),(0,$.jsx)(Qt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),d?(0,$.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,$.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,$.jsx)(_c,{}),(0,$.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,$.jsx)(Xo,{className:`h-4 w-4`})}),(0,$.jsx)(f_,{children:l&&(0,$.jsx)(fy.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,$.jsxs)(`div`,{className:`p-2`,"data-testid":`agent-conv-delete-confirm`,children:[(0,$.jsx)(`p`,{className:`px-1 pb-2.5 text-xs leading-relaxed text-foreground/70`,children:e(`header.deleteConfirm`)}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.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,$.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,$.jsxs)($.Fragment,{children:[(0,$.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,$.jsx)(an,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),e(`header.rename`)]}),(0,$.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,$.jsx)(ms,{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,$.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,$.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),e(`header.delete`)]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border/50`}),(0,$.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,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,$.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,$.jsx)(tn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.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,$.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,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(Ho,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]},e.id))]})})})]})}var Rk=new Set([`building`,`on_review`,`pr_draft`,`no_changes`,`pr_closed`,`implementation_failed`,`pr_failed`]);function zk(e){return Rk.has(e)}function Bk(e){let t=[];for(let[n,r]of e.entries()){if(r.role!==`system`)continue;let e=io(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=Ft(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=Ft(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))Ft(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),zk(e.envelope.decision)&&u.push(e)}return{byMessageId:c,duplicateMessageIds:l,pinned:u}}var Vk=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-DKA_DUHe.js`).then(e=>({default:e.JobDetailModal})),__vite__mapDeps([6,1,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,76]))),Hk=(0,Q.lazy)(()=>c(()=>import(`./LoopPreviewModal-T0zuFv6y.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([77,1,7,8,11,10,42,74,55,56,64,65,69,63,49,78,52,53]))),Uk=new Set,Wk=new Set([`spec-framing.committed`]);function Gk(e){if(!e.startsWith(`{`))return!1;try{let t=JSON.parse(e);return typeof t?.kind==`string`&&Wk.has(t.kind)}catch{return!1}}function Kk({variant:e}){let{t}=K(`agent`),{active:n}=lM(),r=si(),i=Cy(n?.id??`__new-mission__`),a=r.transfers.find(e=>e.conversationId===n?.id);if(n&&!r.current&&a?.state===`detached`)return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[e===`inline`&&(0,$.jsx)(Lk,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,$.jsx)(Vt,{className:`h-8 w-8 text-accent-primary`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`window.detached`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{r.focus(n.id)},className:`rounded-md bg-accent-primary px-4 py-2 text-sm text-white`,children:t(`window.focus`)})]})]});let o=!!n&&!r.isEditable(n.id);return(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 flex-col`,inert:o||void 0,"aria-busy":o||void 0,children:(0,$.jsx)(qk,{variant:e},`${n?.id??`__new-mission__`}:${i}`)})}function qk({variant:e}){let{t}=K(`agent`),{active:n,messages:r,streamingText:i,isStreaming:a,liveTools:o,turnTools:s,queuedMessages:c,mcpEnabled:l,enablingMcp:u,enableMcpServer:d,providersReady:f,cycleTier:p,send:m}=lM(),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=o.length>0?o:s,b=(0,Q.useRef)(null),x=jy(i,a),{openRef:S,jobRef:C,closeJobRef:w,loopRef:T,closeLoopRef:E}=_b(),D=n?.pinned_project_id??null,[O,k]=(0,Q.useState)(new Map),A=(0,Q.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.attachment_ids??[])e.add(n);for(let t of c)for(let n of t.attachmentIds??[])e.add(n);return[...e].sort()},[r,c]).join(`\0`);(0,Q.useEffect)(()=>{let e=A?A.split(`\0`):[];if(!n?.id||e.length===0){k(new Map);return}let t=!1,r=new Set(e);return qa(n.id).then(e=>{t||k(new Map(e.filter(e=>r.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||k(new Map)}),()=>{t=!0}},[n?.id,A]);let j=(0,Q.useMemo)(()=>D?e=>{S(D,e)}:void 0,[D,S]),M=ca().id===`code-rain`?t(`emptyTitleCodeRain`):t(`emptyTitle`),N=(0,Q.useMemo)(()=>Bk(r),[r]),P=n?xy(n.id):null,F=(0,Q.useRef)(P?.atBottom??!0);(0,Q.useLayoutEffect)(()=>{let e=b.current;return e&&P&&(e.scrollTop=P.atBottom?e.scrollHeight:P.top),()=>{e&&n&&by(n.id,{top:e.scrollTop,atBottom:F.current})}},[n?.id]);let I=()=>{let e=b.current;e&&(F.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,n&&by(n.id,{top:e.scrollTop,atBottom:F.current}))};(0,Q.useEffect)(()=>{F.current&&b.current?.scrollTo?.({top:b.current.scrollHeight,behavior:`auto`})},[r.length,x,o.length,c.length]);let L=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),p())},R=e===`inline`,z=R?`mx-auto flex w-full max-w-[820px] flex-1 flex-col overflow-hidden`:`flex flex-1 flex-col overflow-hidden`;return(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden `,onKeyDown:L,children:[f===!1&&(0,$.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,$.jsx)(Ns,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-warning`}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:t(`noProvider.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:t(`noProvider.body`)})]})]}),f!==!1&&!l&&(0,$.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,$.jsx)(rc,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,$.jsx)(`span`,{className:`flex-1`,children:t(`degraded.body`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void d(),disabled:u,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:t(u?`degraded.enabling`:`degraded.enable`)})]}),R&&n&&(0,$.jsx)(Lk,{}),(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsxs)(fy.div,{ref:b,onScroll:I,initial:R?{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,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,$.jsx)(So,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:M}),(0,$.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:t(`emptyHint`)})]}),r.map((e,n)=>{if(e.role===`system`){if(Gk(e.content))return null;let n=N.byMessageId.get(e.id);return n?zk(n.decision)?(0,$.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,$.jsx)(Vs,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(`prCard.pinned.marker`)}),(0,$.jsx)(Ek,{decision:n.decision})]},e.id):(0,$.jsx)(wk,{envelope:n},e.id):(N.duplicateMessageIds.has(e.id)||Uk.has(e.id)||(Uk.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}return(0,$.jsx)(Rx,{role:e.role,content:e.content,createdAt:e.created_at,isLast:!a&&n===r.length-1,isLatest:n===r.length-1,isStreaming:a,onPickOption:e=>void m(e),refsProjectId:D,onOpenRef:j,contextRefs:e.context_refs,deliveryStatus:e.delivery_status,deliveryReceipt:e.delivery_receipt,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>O.get(e)).filter(e=>!!e)},e.id)}),a&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[x&&(0,$.jsx)(Rx,{role:`assistant`,content:x,streaming:!0}),(0,$.jsx)(bb,{tool:o.length?o[o.length-1].tool:null,onClick:()=>g(!0)})]}),c.length>0&&(0,$.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:c.map(e=>(0,$.jsx)(zx,{item:e,conversationId:n?.id,onEdit:e=>{n&&v(t=>({conversationId:n.id,queueId:e,revision:(t?.revision??0)+1}))},attachments:(e.attachmentIds??[]).map(e=>O.get(e)).filter(e=>!!e)},`${n?.id}:${e.queueId}`))})]}),(0,$.jsx)(f_,{initial:!1,children:n&&N.pinned.length>0&&(0,$.jsx)(Nk,{pinned:N.pinned,conversationId:n.id,inline:R},`agent-pr-pinned-dock`)}),R?(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsxs)(fy.div,{layoutId:`agent-composer-dock`,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`relative mx-auto w-full max-w-[680px] rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`,"data-testid":`agent-composer-dock`,children:[(0,$.jsx)(ik,{active:a,radius:`1rem`,inset:-3}),(0,$.jsx)(qO,{queueEditRequest:_})]})}):(0,$.jsxs)(`div`,{className:`relative shrink-0 border-t border-border/50 bg-surface/30 p-3`,"data-testid":`agent-composer-dock`,children:[(0,$.jsx)(ik,{active:a,radius:`0.75rem`,inset:-2}),(0,$.jsx)(qO,{hideProjectSelector:!0,queueEditRequest:_})]})]}),C&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Vk,{jobId:C.jobId,projectId:C.projectId,onClose:w})}),T&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Hk,{loop:T,onClose:E})}),h&&(0,$.jsx)(Sb,{tools:y,streaming:a,onClose:()=>g(!1)})]})}var Jk=8,Yk=3e3;function Xk(){let{t:e}=K(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=lM(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(0),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y=(0,Q.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>Jk,x=(0,Q.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,Q.useCallback)(()=>{g.current&&clearTimeout(g.current),g.current=null,h(null)},[]);(0,Q.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]),(0,Q.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},Yk)},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{J.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,$.jsxs)(`div`,{className:`relative min-w-0`,ref:_,"data-agent-interactive":!0,onKeyDown:j,children:[(0,$.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,$.jsx)(Yt,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:M}),(0,$.jsx)(Zt,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,$.jsx)(f_,{children:c&&(0,$.jsxs)(fy.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,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(ln,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,$.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,$.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,$.jsxs)(fy.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,$.jsx)(cn,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),x.length>0&&(0,$.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),x.length===0&&u.trim()!==``&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),x.map((e,t)=>(0,$.jsx)(Zk,{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 Zk({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}=K(`agent`),p=e.title?.trim()||f(`mission.untitled`),m=e.id===r;return o?(0,$.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,$.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-destructive`,children:f(i?`mission.deleteLiveConfirm`:`mission.deleteConfirm`)}),(0,$.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,$.jsx)(Ht,{className:`h-3.5 w-3.5`})}),(0,$.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,$.jsx)(mn,{className:`h-3.5 w-3.5`})})]}):(0,$.jsxs)(fy.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,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs text-foreground/40`,title:Ob(e.updated_at),children:Db(e.updated_at)}),i&&(0,$.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,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),a>0&&(0,$.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,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.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,$.jsx)(dn,{className:`h-3.5 w-3.5`})})]})}var Qk=Q.forwardRef(({className:e,type:t,...n},r)=>(0,$.jsx)(`input`,{type:t,className:X(`flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-xs ring-offset-background file:border-0 file:bg-transparent file:text-xs file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Qk.displayName=`Input`;var $k=6e4,eA={data:null,fetchedAt:0,inFlight:null,error:null},tA=new Set;function nA(){tA.forEach(e=>{try{e()}catch{}})}function rA(){return eA.data!==null&&Date.now()-eA.fetchedAt<$k}async function iA(e){if(eA.inFlight)return eA.inFlight;let t=(async()=>{let t=await fetch(`${He}/api/setup-prerequisites`,{signal:e});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(typeof n?.ok!=`boolean`||!Array.isArray(n?.prerequisites)||!Array.isArray(n?.missingRequired))throw Error(`Malformed prerequisites response`);return eA.data=n,eA.fetchedAt=Date.now(),eA.error=null,eA.inFlight=null,nA(),eA.data})().catch(t=>{throw eA.inFlight=null,e?.aborted?t:(eA.error=t instanceof Error?t:Error(String(t)),nA(),eA.error)});return eA.inFlight=t,t}var aA=!1;function oA(){aA||typeof window>`u`||(window.addEventListener(`focus`,()=>{eA.fetchedAt=0,eA.data=null,iA().catch(()=>{})}),aA=!0)}function sA(){let[,e]=(0,Q.useState)(0),[t,n]=(0,Q.useState)(()=>!rA()),[r,i]=(0,Q.useState)(eA.error);(0,Q.useEffect)(()=>{oA();let t=()=>{e(e=>e+1),i(eA.error),n(!1)};tA.add(t);let r=new AbortController;return!rA()&&!eA.inFlight?(n(!0),iA(r.signal).catch(e=>{r.signal.aborted||i(e instanceof Error?e:Error(String(e)))}).finally(()=>{r.signal.aborted||n(!1)})):eA.inFlight&&eA.inFlight.catch(()=>{}).finally(()=>{r.signal.aborted||n(!1)}),()=>{r.abort(),tA.delete(t)}},[]);let a=(0,Q.useCallback)(async()=>{eA.fetchedAt=0,eA.data=null,eA.error=null,n(!0);try{await iA()}catch(e){i(e instanceof Error?e:Error(String(e)))}finally{n(!1)}},[]);return{status:eA.data,isLoading:t,error:r,recheck:a}}var cA={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`},kimi:{icon:`🌙`,label:`Kimi`}};function lA(e){return e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`project`}function uA({blueprint:e,onSubmit:t,onBack:n,submitting:r,error:i,errorDetail:a}){let{t:o}=K(`builder`),{status:s}=sA(),[c,l]=(0,Q.useState)(e.product.name||``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(new Set([`claude`])),[g,_]=(0,Q.useState)({claude:!0}),[v,y]=(0,Q.useState)(!1),b=(0,Q.useMemo)(()=>`~/projects/${lA(c)}`,[c]),x=u?f:b;(0,Q.useEffect)(()=>{fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n===`tiers`||n===`providerIssues`||n===`launchDescriptors`||typeof r==`boolean`&&(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`,`kimi`,...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,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col gap-4 p-6`,"data-testid":`commit-form`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:o(`commit.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`commit.description`)})]}),i&&(0,$.jsxs)(`div`,{className:`rounded-md bg-destructive/10 p-2 text-xs text-destructive`,"data-testid":`commit-error`,children:[(0,$.jsx)(`p`,{children:o(`commit.errors.${i}`,{defaultValue:o(`commit.errors.generic`)})}),a&&(0,$.jsx)(`p`,{className:`mt-1 opacity-80`,children:a})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.nameLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsx)(Qk,{value:c,onChange:e=>l(e.target.value),"data-testid":`commit-name`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[o(`commit.locationLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsx)(Qk,{value:x,onChange:e=>{d(!0),p(e.target.value)},"data-testid":`commit-location`}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:o(`commit.locationHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:o(`commit.providersLabel`)}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:Object.keys(g).map(e=>{let{icon:t,label:n}=cA[e]??{icon:`•`,label:e},r=g[e],i=m.has(e)&&r;return(0,$.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,$.jsx)(`span`,{children:t}),(0,$.jsx)(`span`,{className:`font-medium`,children:n})]},e)})})]}),C&&(0,$.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,$.jsx)(`input`,{type:`checkbox`,checked:v&&w,disabled:!w,onChange:e=>y(e.target.checked),"data-testid":`commit-github`}),(0,$.jsx)(us,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:o(`commit.githubLabel`)}),!w&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:o(`commit.githubAuthHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between pt-2`,children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:n,disabled:r,children:o(`commit.back`)}),(0,$.jsxs)(Z,{size:`sm`,disabled:!E,"data-testid":`commit-submit`,onClick:()=>t({name:c.trim(),location:x.trim(),providers:T,createGithubRepo:v&&w}),children:[(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`}),o(r?`commit.creating`:`commit.submit`)]})]})]})}function dA({session:e,autoFocus:t=!1}){let{t:n}=K(`builder`),{t:r}=K(`agent`),{availableIds:i}=UO(),a=rr(e.provider),o=[e.provider,...i].filter((e,t,n)=>n.indexOf(e)===t).filter(rr),s=()=>{!a||!e.draft.trim()||e.busy||!e.conversationReady||(e.send(e.draft),e.setDraft(``))};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:n(`mode.title`)})]}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(uD,{label:r(`provider.label`),value:e.provider,options:o.map(e=>({value:e,label:r(`provider.${e}`,{defaultValue:e})})),icon:So,onSelect:e.setProvider,disabled:!a||e.busy||!e.conversationReady,testId:`builder-provider-selector`}),(0,$.jsx)(vD,{models:e.models,model:e.model,onSelect:e.setModel,disabled:!a||e.busy||!e.conversationReady,testId:`builder-model-selector`}),e.efforts.length>0&&(0,$.jsx)(uD,{label:r(`effort.label`),value:e.effort,options:e.efforts.map(e=>({value:e,label:r(`effort.${e}`)})),icon:ss,onSelect:e.setEffort,disabled:!a||e.busy||!e.conversationReady,testId:`builder-effort-selector`}),e.showSurpriseMe&&(0,$.jsxs)(`button`,{type:`button`,onClick:e.surpriseMe,disabled:!a||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,$.jsx)(un,{className:`h-3 w-3`}),n(`shell.surpriseMe`)]})]}),!a&&(0,$.jsx)(`p`,{className:`mb-2 rounded-md border border-accent-warning/30 bg-accent-warning/10 px-2.5 py-2 text-xs text-accent-warning`,"data-testid":`builder-provider-unavailable`,children:n(`shell.providerUnavailable`)}),(0,$.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl border border-border/60 bg-background/60 px-3 py-2`,children:[(0,$.jsx)(`textarea`,{value:e.draft,disabled:!a,autoFocus:t,onChange:t=>e.setDraft(t.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),s())},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,$.jsx)(`button`,{type:`button`,onClick:s,disabled:!a||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,$.jsx)(mt,{className:`h-4 w-4`})})]})]})}function fA(e){let t=Date.parse(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`);return Number.isFinite(t)?Zn(new Date(t),{addSuffix:!0,locale:Ue()}):``}function pA({items:e,loading:t,disabled:n=!1,onResume:r,onDiscard:i}){let{t:a}=K(`builder`),[o,s]=(0,Q.useState)(null);return!t&&e.length===0?null:(0,$.jsxs)(fy.section,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.24,ease:`easeOut`,delay:.08},className:`mt-4 w-full rounded-2xl border border-border/50 bg-card/70 p-3 shadow-lg backdrop-blur-xl`,"data-testid":`builder-recent`,"aria-label":a(`recent.title`),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 px-1`,children:[(0,$.jsx)(hs,{className:`h-3.5 w-3.5 text-accent-secondary`,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:a(`recent.title`)}),t&&(0,$.jsx)(rn,{className:`ml-auto h-3 w-3 animate-spin text-muted-foreground/60`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`space-y-1`,children:(0,$.jsx)(f_,{initial:!1,children:e.map(e=>{let t=e.productName||e.title||a(`recent.untitled`),c=o===e.id;return(0,$.jsxs)(fy.li,{layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,height:0},className:X(`group flex items-center gap-2 rounded-xl border border-transparent px-2.5 py-2 transition-colors`,`hover:border-border/60 hover:bg-surface/60`),"data-testid":`builder-recent-${e.id}`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>r(e.id),className:`flex min-w-0 flex-1 items-center gap-2.5 text-left disabled:opacity-50`,"data-testid":`builder-recent-resume-${e.id}`,children:[(0,$.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-accent-primary/10 text-accent-primary`,children:(0,$.jsx)(on,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:t}),(0,$.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground`,children:[e.platform&&(0,$.jsx)(`span`,{children:e.platform}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(xs,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),e.specCount>0?e.specsComplete?a(`recent.specsComplete`,{count:e.specCount}):a(`recent.specsInProgress`,{count:e.specCount}):a(`recent.dimensions`,{filled:e.dimensionsFilled,total:5})]}),e.pendingIssue&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-warning`,"data-testid":`builder-recent-pending-issue`,children:[(0,$.jsx)(fn,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),a(`recent.pendingIssue`)]}),e.updatedAt&&(0,$.jsx)(`span`,{className:`opacity-80`,children:fA(e.updatedAt)})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>{s(null),i(e.id)},"aria-label":a(`recent.discardConfirm`),title:a(`recent.discardConfirm`),className:`rounded-md p-1 text-destructive hover:bg-destructive/10`,"data-testid":`builder-recent-discard-confirm-${e.id}`,children:(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(null),"aria-label":a(`recent.discardCancel`),title:a(`recent.discardCancel`),className:`rounded-md p-1 text-muted-foreground hover:bg-surface`,"data-testid":`builder-recent-discard-cancel-${e.id}`,children:(0,$.jsx)(mn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),"aria-label":a(`recent.discard`),title:a(`recent.discard`),className:`rounded-md p-1 text-muted-foreground/40 opacity-0 transition-opacity hover:bg-surface hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100`,"data-testid":`builder-recent-discard-${e.id}`,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})})]},e.id)})})})]})}function mA({specsStarted:e,snapshot:t,maxSpecs:n=10}){let{t:r}=K(`builder`),i=t.status===`repairing`,a=t.status===`generating`?t.generation:null,o=(a&&a.total>0?a.phase===`audit`?.95:Math.min(.95,Math.max(.06,Math.max(0,a.from-1)/a.total)):null)??Math.min(.95,Math.max(.06,e/n)),s=i?pn:un,c=i?r(`snapshot.repairing.${t.kind}`):a?r(`generation.phase.${a.phase}`,{from:a.from,to:a.to,total:a.total}):r(`generation.writing`);return(0,$.jsxs)(`div`,{className:`inline-flex max-w-full flex-col gap-1.5 rounded-xl border border-border/50 bg-surface/60 px-3 py-2 text-xs text-foreground/80`,"data-testid":`builder-generation-progress`,"data-phase":i?`repairing`:a?`generation-${a.phase}`:`generating`,role:`status`,"aria-live":`polite`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 shrink-0 animate-spin text-accent-info`,"aria-hidden":!0}),(0,$.jsx)(s,{className:`h-3 w-3 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsx)(fy.span,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:`easeOut`},className:`font-medium`,children:c},c)}),a&&a.totalTurns>0&&(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-2 py-px font-mono text-[10px] text-muted-foreground`,"data-testid":`builder-generation-turn`,children:r(`generation.turn`,{turn:a.turn,total:a.totalTurns})}),e>0&&(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsx)(fy.span,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.14},className:`rounded-full bg-accent-primary/10 px-2 py-px font-mono text-[10px] text-accent-primary`,"data-testid":`builder-generation-count`,children:r(`generation.specCount`,{n:e})},e)})]}),(0,$.jsx)(`div`,{className:`h-1 w-56 max-w-full overflow-hidden rounded-full bg-border/40`,"aria-hidden":!0,children:(0,$.jsx)(fy.div,{className:`h-full rounded-full bg-gradient-to-r from-accent-primary/70 to-accent-highlight/80`,initial:{width:`6%`},animate:{width:`${Math.round(o*100)}%`},transition:{type:`spring`,stiffness:120,damping:20}})})]})}var hA=`specrails-desktop:milestone-launch-mode`,gA=`specrails-desktop:milestone-sequential-plans`;function _A(){try{return localStorage.getItem(`specrails-desktop:milestone-launch-mode`)===`parallel`?`parallel`:`sequential`}catch{return`sequential`}}function vA(e){try{localStorage.setItem(hA,e)}catch{}}var yA=`specrails-desktop:milestone-auto-advance`;function bA(){try{return localStorage.getItem(yA)===`true`}catch{return!1}}function xA(e){try{localStorage.setItem(yA,e?`true`:`false`)}catch{}}function SA(){try{return localStorage.getItem(`specrails-desktop:milestone-sequential-plans`)===null?!1:(localStorage.removeItem(gA),!0)}catch{return!1}}function CA(e){return`M${e}`}function wA(e,t){return t===`chain_active`?`chain_active`:t===`no_tickets`?`no_tickets`:t===`milestone_not_found`?`milestone_not_found`:e===503?`unavailable`:`launch_rejected`}async function TA(e){try{let t=await e.json();return t&&typeof t==`object`?t:{}}catch{return{}}}async function EA(e,t,n=_A(),r={}){let i=typeof r==`function`?{fetchImpl:r}:r,a=i.fetchImpl??fetch,o=i.autoAdvance??bA(),s;try{s=await a(`/api/projects/${e}/blueprint/milestones/${t}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:n,autoAdvance:o})})}catch(e){return{ok:!1,reason:`network`,error:`network`,detail:e instanceof Error?e.message:String(e)}}let c=await TA(s);if(!s.ok){let e=typeof c.error==`string`?c.error:`http_${s.status}`;return{ok:!1,reason:wA(s.status,e),error:e,...typeof c.detail==`string`?{detail:c.detail}:{},...typeof c.chainId==`string`?{chainId:c.chainId}:{}}}let l=Array.isArray(c.launched)?c.launched.filter(e=>!!e&&typeof e==`object`&&typeof e.chunk==`number`):[],u=Array.isArray(c.pending)?c.pending.filter(e=>Array.isArray(e)):[];return{ok:!0,chainId:typeof c.chainId==`string`?c.chainId:null,launched:l,pending:u,ticketCount:l.reduce((e,t)=>e+(Array.isArray(t.ticketIds)?t.ticketIds.length:0),0),skippedCount:u.reduce((e,t)=>e+t.length,0)}}async function DA(e,t,n,r){let i;try{i=await r(`/api/projects/${e}/blueprint/chains/${t}/${n}`,{method:`POST`})}catch(e){return{ok:!1,error:`network`,detail:e instanceof Error?e.message:String(e)}}let a=await TA(i);return i.ok?{ok:!0,chain:yt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}function OA(e,t,n=fetch){return DA(e,t,`resume`,n)}function kA(e,t,n=fetch){return DA(e,t,`cancel`,n)}async function AA(e,t,n,r=fetch){let i;try{i=await r(`/api/projects/${e}/blueprint/chains/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({autoAdvance:n})})}catch(e){return{ok:!1,error:`network`,detail:e instanceof Error?e.message:String(e)}}let a=await TA(i);return i.ok?{ok:!0,chain:yt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}var jA=[`Problem Statement`,`Proposed Solution`,`Out of Scope`,`Technical Considerations`,`Estimated Complexity`],MA={problemMinChars:200,solutionMinChars:500,outOfScopeMinBullets:3,technicalMinBullets:5,criteriaMin:6,criteriaMax:10,criterionMinChars:20},NA=new Set([`scaffold`,`feature`,`verification`]),PA=new Set([`critical`,`high`,`medium`,`low`]),FA=/^(?:todo|tbd|n\/?a|works?|test(?: it)?|criterion|acceptance criterion)$/i;function IA(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function LA(e){return e.trim().toLocaleLowerCase(`en-US`)}function RA(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 zA(e){return e.split(/\r?\n/).filter(e=>/^\s*[-*+]\s+\S/.test(e)).length}function BA(e,t){let n=[],r=IA(e),i=Array.isArray(r?.m1Specs)?r.m1Specs:[],a=t.milestoneLabel.trim().toUpperCase(),o=(e,t,r,i,a={})=>{n.push({specIndex:e,field:t,code:r,message:i,params:e===null?a:{n:e+1,...a}})};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.`,{min:t.minSpecs,max:t.maxSpecs,count:i.length});let s=new Map;return i.forEach((e,n)=>{let r=IA(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:``;NA.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=LA(l),t=s.get(e);t===void 0?s.set(e,n):o(n,`title`,`duplicate`,`Spec ${i} duplicates spec ${t+1}.`,{other: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:``;PA.has(d)||o(n,`priority`,`invalid_priority`,`Spec ${i} needs a valid priority.`);let f=typeof r.description==`string`?r.description.trim():``,p=RA(f);(!/^## Problem Statement(?:\r?\n|$)/.test(f)||p.headings.length!==jA.length||p.headings.some((e,t)=>e!==jA[t]))&&o(n,`description`,`canonical_sections`,`Spec ${i} is missing the canonical sections.`);for(let e of jA)(p.bodies.get(e)??``).trim()||o(n,`description`,`empty_section`,`Spec ${i} has an empty ${e} section.`,{heading:e});for(let[e,t]of[[`Problem Statement`,MA.problemMinChars],[`Proposed Solution`,MA.solutionMinChars]]){let r=(p.bodies.get(e)??``).trim();r&&r.length<t&&o(n,`description`,`section_depth`,`Spec ${i} ${e} is too thin.`,{heading:e,min:t})}for(let[e,t]of[[`Out of Scope`,MA.outOfScopeMinBullets],[`Technical Considerations`,MA.technicalMinBullets]]){let r=p.bodies.get(e)??``;r&&zA(r)<t&&o(n,`description`,`section_bullets`,`Spec ${i} needs ${t} ${e} bullets.`,{heading:e,min:t})}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<MA.criteriaMin||h.length>MA.criteriaMax)&&o(n,`acceptanceCriteria`,`criteria_count`,`Spec ${i} needs ${MA.criteriaMin}-${MA.criteriaMax} acceptance criteria.`,{count:h.length,min:MA.criteriaMin,max:MA.criteriaMax});let g=new Set;h.forEach((e,t)=>{let r=typeof e==`string`?e.trim():``;if(r.length<MA.criterionMinChars||FA.test(r)){o(n,`acceptanceCriteria`,`criterion_quality`,`Spec ${i} criterion ${t+1} is not concrete.`,{criterion:t+1});return}let a=LA(r);g.has(a)&&o(n,`acceptanceCriteria`,`duplicate_criterion`,`Spec ${i} repeats an acceptance criterion.`,{criterion:t+1}),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.`,{label:a}),_.every(e=>e.toUpperCase()===a)&&o(n,`labels`,`domain_label`,`Spec ${i} needs a domain label.`,{label:a});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 VA=new Set([`batch_incomplete`,`spec_count`]);function HA(e,t,n,r,i={}){let a=gt(e),o=Object.values(a).filter(Boolean).length,s=Object.keys(a).length,c=t&&typeof t==`object`&&!Array.isArray(t)?t:null,l=Array.isArray(c?.m1Specs)?c.m1Specs.length:e?.m1Specs.length??0,u=Array.isArray(c?.m1Specs)?c.m1Specs:e?.m1Specs??[],d=new Set;u.forEach((e,t)=>{let n=e&&typeof e==`object`?e:null,r=typeof n?.description==`string`?n.description.trim():``,i=Array.isArray(n?.acceptanceCriteria)?n.acceptanceCriteria:[];(r.length>0||i.length>0)&&d.add(t)});let f=d.size,p=c?c.specsComplete===!0:e?.specsComplete===!0,m=i.generating===!0&&l>0,h=!m&&l>0&&f<l&&!p,g=m?[]:n.issues.filter(e=>!VA.has(e.code)&&(!h||e.specIndex===null||d.has(e.specIndex))),_={key:`blueprint`,state:o===s?`done`:`pending`,params:{filled:o,total:s}},v;v=m?`writing`:l===0?`pending`:l<r.minSpecs||l>r.maxSpecs?`blocked`:p?`done`:`pending`;let y={key:`specs`,state:v,params:{count:l,written:f,min:r.minSpecs,max:r.maxSpecs}},b={key:`audit`,state:m?`writing`:l===0||h&&g.length===0?`pending`:g.length===0?`done`:`blocked`,params:{count:g.length}};return{ready:n.valid,steps:[_,y,b],issues:g}}function UA(e){return e.field===`shortSummary`?`quality.summary`:e.field===`title`&&e.code===`required`?`quality.title_required`:e.field===`title`&&e.code===`duplicate`?`quality.title_duplicate`:`quality.${e.code}`}function WA(e,t){let n={n:t.specIndex===null?``:t.specIndex+1,...t.params??{}};return e(UA(t),{...n,defaultValue:t.message})}var GA=new Set([`gh_not_installed`,`gh_not_authenticated`,`gh_scope`,`gh_repo_exists`,`gh_network`]);function KA(e){return`progress.githubErrors.${e&&GA.has(e)?e:`generic`}`}var qA=[`create-dir`,`git-init`,`assemble`,`blueprint`,`tickets`,`register`,`github`],JA={minSpecs:5,maxSpecs:10};function YA(e){let t=e&&typeof e==`object`?e:null;if(!t)return null;let n=t.phase;if(n!==`outline`&&n!==`details`&&n!==`audit`&&n!==`repair`)return null;let r=e=>typeof e==`number`&&Number.isFinite(e)?e:0;return{phase:n,from:r(t.from),to:r(t.to),total:r(t.total),turn:r(t.turn),totalTurns:r(t.totalTurns)}}function XA(e,t){let n=e&&typeof e==`object`?e:{},r=new Date().toISOString();if(n.continuing){let e=YA(n.generation);return e?{status:`generating`,generation:e}:t}return n.status===`accepted`?{status:`accepted`,repaired:n.repaired===!0,repairAttempted:n.repairAttempted===!0,at:r,...n.generationHalted===!0?{generationHalted:!0}:{}}:n.status===`rejected`?{status:`rejected`,reason:n.reason??`invalid_json`,detail:n.detail??``,repairAttempted:n.repairAttempted===!0,at:r}:t.status===`repairing`||t.status===`generating`?{status:`idle`}:t}function ZA(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`).map(e=>({id:String(e.id),title:typeof e.title==`string`?e.title:null,productName:typeof e.productName==`string`?e.productName:null,platform:typeof e.platform==`string`?e.platform:null,provider:typeof e.provider==`string`?e.provider:`claude`,model:typeof e.model==`string`?e.model:null,updatedAt:typeof e.updated_at==`string`?e.updated_at:``,messageCount:typeof e.messageCount==`number`?e.messageCount:0,specCount:typeof e.specCount==`number`?e.specCount:0,specsComplete:e.specsComplete===!0,dimensionsFilled:typeof e.dimensionsFilled==`number`?e.dimensionsFilled:0,hasSnapshot:e.hasSnapshot===!0,pendingIssue:e.pendingIssue===`invalid_json`||e.pendingIssue===`truncated`||e.pendingIssue===`missing_version`?e.pendingIssue:null})):[]}function QA(e,t){let{t:n}=K(`builder`),{registerHandler:r,unregisterHandler:i}=qe(),{setActiveProjectId:a}=at(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(`chat`),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(`claude`),[R,z]=(0,Q.useState)(null),[B,ee]=(0,Q.useState)([]),[V,H]=(0,Q.useState)(``),[te,ne]=(0,Q.useState)([]),[re,ie]=(0,Q.useState)(`medium`),[ae,oe]=(0,Q.useState)(``),[se,ce]=(0,Q.useState)({status:`idle`}),[le,ue]=(0,Q.useState)([]),[de,fe]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)(!1),he=R??V,ge=(0,Q.useMemo)(()=>{let e=lr(I,he);return te.filter(t=>e.includes(t))},[he,I,te]),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(I),U=(0,Q.useRef)(null),be=(0,Q.useRef)(!1),xe=(0,Q.useRef)(re),Se=(0,Q.useRef)(ge),Ce=(0,Q.useRef)(R),W=(0,Q.useRef)(!1),we=(0,Q.useRef)(t.onFinished);(0,Q.useEffect)(()=>{_e.current=o},[o]),(0,Q.useEffect)(()=>{ye.current=I},[I]),(0,Q.useEffect)(()=>{U.current=w},[w]),(0,Q.useEffect)(()=>{xe.current=re},[re]),(0,Q.useEffect)(()=>{Se.current=ge},[ge]),(0,Q.useEffect)(()=>{Ce.current=R},[R]),(0,Q.useEffect)(()=>{we.current=t.onFinished},[t.onFinished]);let Te=(0,Q.useCallback)(async()=>{let e=_e.current;if(e)return e;if(ve.current)return ve.current;let t=fetch(`/api/blueprint/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:ye.current,...Ce.current?{model:Ce.current}:{}})}).then(e=>e.json()).then(e=>e.conversation?(_e.current=e.conversation.id,s(e.conversation.id),e.conversation.id):null).catch(()=>null).finally(()=>{ve.current=null});return ve.current=t,t},[]),Ee=(0,Q.useCallback)(async()=>{fe(!0);try{let e=await(await fetch(`/api/blueprint/conversations?resumable=1`)).json();ue(ZA(e.conversations))}catch{ue([])}finally{fe(!1)}},[]);(0,Q.useEffect)(()=>{e&&Ee()},[e,Ee]),(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return ee([]),H(``),ne([]),ie(``),fetch(`/api/blueprint/models?provider=${encodeURIComponent(I)}`).then(e=>e.json()).then(e=>{if(t)return;ee(e.models??[]);let n=e.defaultModel??e.models?.[0]?.value??``,r=e.efforts??[],i=lr(I,n),a=r.filter(e=>i.includes(e));H(n),ne(r),ie(e=>a.includes(e)?e:fr(I,n)??``)}).catch(()=>{}),()=>{t=!0}},[e,I]);let De=(0,Q.useCallback)(e=>{L(e),z(null);let t=_e.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).catch(()=>{})},[]),Oe=(0,Q.useCallback)(e=>{z(e);let t=lr(I,e),n=te.filter(e=>t.includes(e));ie(t=>n.includes(t)?t:fr(I,e)??``);let r=_e.current;r&&fetch(`/api/blueprint/conversations/${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:e})}).catch(()=>{})},[I,te]);(0,Q.useEffect)(()=>{if(!e)return;let t=`builder-session`;return r(t,e=>{let t=e,r=_e.current!==null&&t.conversationId===_e.current,i=U.current!==null&&t.commitId===U.current;if(t.type===`blueprint.stream`&&r)d(e=>(e??``)+String(t.delta??``));else if(t.type===`blueprint.repairing`&&r){let e=t.kind===`truncated`||t.kind===`quality`?t.kind:`invalid_json`;_(!0),ce({status:`repairing`,kind:e,manual:t.manual===!0,attempt:typeof t.attempt==`number`?t.attempt:1})}else if(t.type===`blueprint.generating`&&r){let e=YA(t);d(null),_(!0),e&&ce({status:`generating`,generation:e})}else if(t.type===`blueprint.done`&&r){let e=t.continuing===!0;d(null),_(e);let n=String(t.fullText??``);n.trim()&&!e&&l(e=>[...e,{role:`assistant`,content:n,createdAt:new Date().toISOString()}]);let r=Ct(t.blueprint),i=t.rawBlueprint===void 0?t.blueprint:t.rawBlueprint;if(!r&&t.snapshot===void 0){let e=Lt(n);r=e.blueprint,i=e.rawBlueprint}r&&(p(r),h(i)),ce(e=>t.snapshot===void 0?r?{status:`accepted`,repaired:!1,repairAttempted:!1,at:new Date().toISOString()}:e:XA(t.snapshot,e))}else if(t.type===`blueprint.error`&&r)d(null),_(!1),ce(e=>e.status===`repairing`||e.status===`generating`?{status:`idle`}:e),J.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`&&!be.current&&(be.current=!0,J.warning(n(KA(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&&(W.current=!1,F(!1),J.error(n(`errors.commitFailed`),{description:String(t.error??``)}),y(`commit`),x(`commit_failed`),C(String(t.error??``)))}),()=>i(t)},[e,r,i,n]);let ke=(0,Q.useCallback)((e,t={})=>{let r=e.trim();if(!r||g||pe)return;l(e=>[...e,{role:`user`,content:r,createdAt:new Date().toISOString(),...t.intent?{intent:t.intent}:{}}]),_(!0);let i=xe.current,a=Se.current.includes(i);Te().then(e=>{if(!e){_(!1),J.error(n(`errors.startFailed`));return}return fetch(`/api/blueprint/conversations/${e}/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:r,...Ce.current?{model:Ce.current}:{},...a?{reasoning_effort:i}:{},...t.intent?{intent:t.intent}:{}})}).then(e=>{!e.ok&&e.status!==202&&(_(!1),J.error(n(`errors.turnFailed`)))}).catch(()=>{_(!1),J.error(n(`errors.turnFailed`))})})},[g,pe,Te,n]),Ae=(0,Q.useCallback)(async e=>{if(!g){me(!0);try{let t=await fetch(`/api/blueprint/conversations/${e}`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(!n.conversation)throw Error(`missing conversation`);_e.current=n.conversation.id,s(n.conversation.id),n.conversation.provider&&L(n.conversation.provider),z(n.conversation.model??null),l((n.messages??[]).filter(e=>typeof e.content==`string`&&e.content.trim()!==``).map(e=>({role:e.role,content:e.content,createdAt:e.created_at??new Date().toISOString(),...e.intent===`surprise`||e.intent===`approve`?{intent:e.intent}:{}})));let r=Ct(n.blueprint);p(r),h(r?n.rawBlueprint??n.blueprint:null),ce(XA(n.snapshot,{status:`idle`})),d(null),_(!1),y(`chat`),x(null),C(null),D([]),oe(``)}catch{J.error(n(`recent.resumeFailed`))}finally{me(!1)}}},[g,n]),je=(0,Q.useCallback)(async e=>{try{let t=await fetch(`/api/blueprint/conversations/${e}`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(`HTTP ${t.status}`);ue(t=>t.filter(t=>t.id!==e))}catch{J.error(n(`recent.discardFailed`))}},[n]),Me=(0,Q.useCallback)(async()=>{let e=_e.current;if(!(!e||g)){_(!0);try{let t=await fetch(`/api/blueprint/conversations/${e}/repair-snapshot`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(re?{reasoningEffort:re}:{})});if(t.status===202)return;let r=await t.json().catch(()=>({}));_(!1),r.error===`nothing_to_repair`?J.info(n(`snapshot.nothingToRepair`)):r.error===`no_session`?J.error(n(`snapshot.noSession`)):r.error===`streaming`?J.info(n(`snapshot.alreadyStreaming`)):J.error(n(`errors.turnFailed`))}catch{_(!1),J.error(n(`errors.turnFailed`))}}},[g,re,n]),Ne=(0,Q.useCallback)(()=>ke(n(`prompts.surpriseMe`),{intent:`surprise`}),[ke,n]),Pe=(0,Q.useCallback)(()=>ke(n(`prompts.approve`),{intent:`approve`}),[ke,n]),Fe=(0,Q.useCallback)(e=>{!f||W.current||(W.current=!0,F(!0),x(null),C(null),D([]),be.current=!1,fetch(`/api/blueprint/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({blueprint:m??f,...e,..._e.current?{conversationId:_e.current}:{}})}).then(async e=>{let t=await e.json().catch(()=>({}));e.status===202&&t.commitId?(T(t.commitId),U.current=t.commitId,y(`progress`)):(x(t.error??`generic`),C(t.detail??null)),W.current=!1,F(!1)}).catch(()=>{W.current=!1,F(!1),x(`generic`),C(null)}))},[f,m]),Ie=(0,Q.useCallback)(async()=>{if(!(!O||A)){j(!0);try{let e=_A(),t=bA(),r=await EA(O,1,e,{autoAdvance:t}),i=CA(1);if(r.ok){let o=r.launched.length+r.pending.length;e===`sequential`&&r.pending.length>0?J.success(n(t?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:i,count:r.ticketCount,n:o})):r.skippedCount>0?J.warning(n(`milestoneProgress.toast.launchedPartial`,{milestone:i,count:r.ticketCount,skipped:r.skippedCount})):J.success(n(`milestoneProgress.toast.launchedAll`,{milestone:i,count:r.ticketCount,n:o})),a(O),N(!0)}else r.reason===`chain_active`?(J.info(n(`milestoneProgress.toast.chainActive`,{milestone:i})),a(O),N(!0)):J.error(n(`done.launchFailed`),{description:r.detail??r.error})}finally{j(!1)}}},[O,A,a,n]),Le=(0,Q.useCallback)(()=>{O&&a(O),we.current()},[O,a]),Re=(0,Q.useCallback)(()=>{let e=_e.current;e&&fetch(`/api/blueprint/conversations/${e}/abort`,{method:`POST`}).catch(()=>{}),s(null),_e.current=null,ve.current=null,l([]),d(null),p(null),h(null),ce({status:`idle`}),ue([]),me(!1),_(!1),y(`chat`),x(null),C(null),T(null),D([]),be.current=!1,k(null),N(!1),j(!1),W.current=!1,F(!1),L(`claude`),z(null),ee([]),H(``),ne([]),ie(`medium`),oe(``)},[]),ze=gt(f),Be=Object.values(ze).some(Boolean)||c.length>0||ae.trim().length>0,G=(0,Q.useMemo)(()=>BA(m??f,{milestoneLabel:`M1`,minSpecs:JA.minSpecs,maxSpecs:JA.maxSpecs,requireScaffold:!0}),[f,m]),Ve=se.status===`generating`,He=(0,Q.useMemo)(()=>HA(f,m??f,G,JA,{generating:Ve}),[f,m,G,Ve]),Ue=(0,Q.useMemo)(()=>{if(G.valid)return null;let e=G.issues[0];return e?WA(n,e):null},[G,n]),We=(0,Q.useMemo)(()=>Pt(u),[u]);return{phase:v,messages:c,streamBuffer:u,blueprint:f,busy:g,commitError:b,commitErrorDetail:S,commitSteps:E,createdProjectId:O,launching:A,launched:M,submitting:P,conversationReady:e&&!pe,conversationId:o,dirty:Be,canProposeCommit:G.valid,specQualityDetail:Ue,readiness:He,snapshot:se,generation:We,recent:le,recentLoading:de,resume:Ae,discardRecent:je,repairSnapshot:Me,showSurpriseMe:c.length<=1&&v===`chat`,provider:I,model:R,models:B,efforts:ge,effort:re,draft:ae,setDraft:oe,setEffort:ie,setProvider:De,setModel:Oe,send:ke,surpriseMe:Ne,approveBlueprint:Pe,goToCommit:()=>y(`commit`),backToChat:()=>y(`chat`),submitCommit:Fe,launchM1:Ie,openProject:Le,abortAndReset:Re}}var $A={done:`bg-accent-success`,onReview:`bg-accent-warning`,inProgress:`bg-accent-info animate-pulse`,failed:`bg-destructive`,todo:`bg-muted-foreground/25`},ej={planned:`border-border/60 bg-surface/60 text-foreground/60`,committed:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,running:`border-accent-info/40 bg-accent-info/10 text-accent-info`,delivered:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,done:`border-accent-success/40 bg-accent-success/10 text-accent-success`};function tj({counts:e,className:t}){let{t:n}=K(`builder`),r=kt(e);return(0,$.jsx)(`div`,{className:X(`flex h-1.5 w-full overflow-hidden rounded-full bg-muted`,t),role:`img`,"aria-label":n(`milestoneProgress.counts`,{delivered:Nt(e),total:e.total,done:e.done}),"data-testid":`milestone-progress-bar`,children:r.map(e=>(0,$.jsx)(`div`,{"data-segment":e.key,className:X(`h-full transition-all duration-500`,$A[e.key]),style:{width:`${e.pct}%`},title:`${n(`milestoneProgress.legend.${e.key}`)} · ${e.count}`},e.key))})}function nj({state:e}){let{t}=K(`builder`);return(0,$.jsx)(`span`,{"data-testid":`milestone-state-pill`,"data-state":e,className:X(`inline-flex shrink-0 items-center rounded-full border px-1.5 py-px text-[9px] font-semibold uppercase tracking-wide`,ej[e]),children:t(`milestoneProgress.state.${e}`)})}function rj(e){let[t,n]=(0,Q.useState)(()=>Date.now());return(0,Q.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function ij({rail:e,now:t,onReview:n,onOpenRail:r}){let{t:i}=K(`builder`),a=e.name??i(`milestoneProgress.rail.fallbackName`,{n:e.railIndex+1}),o=e.active&&e.startedAt?Math.max(0,t-Date.parse(e.startedAt)):null,s=e.delivery?.decision??null,c=s!==null&&wt.has(s)&&e.delivery!==null;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/30 bg-surface/40 px-2 py-1.5`,"data-testid":`milestone-rail-row`,"data-rail-index":e.railIndex,children:[e.chunkIndex!=null&&(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-muted/70 px-1 py-px text-[9px] font-mono tabular-nums text-muted-foreground`,title:i(`milestoneProgress.rail.chunk`,{k:e.chunkIndex}),children:e.chunkIndex}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>r?.(e.railIndex),className:`min-w-0 flex-1 truncate text-left text-[11px] font-medium hover:underline`,title:i(`milestoneProgress.rail.open`),children:a}),e.active?(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-accent-info`,"data-testid":`milestone-rail-running`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),o==null?i(`milestoneProgress.state.running`):i(`milestoneProgress.rail.running`,{elapsed:kO(o)})]}):s?(0,$.jsx)(Ek,{decision:s}):(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`milestoneProgress.rail.noDelivery`)}),c&&e.delivery&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n?.(e.delivery.id),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-accent-primary/40 bg-accent-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-primary hover:bg-accent-primary/20`,"data-testid":`milestone-rail-review`,children:[(0,$.jsx)(Qo,{className:`h-3 w-3`,"aria-hidden":!0}),i(`milestoneProgress.rail.review`)]})]})}function aj({checked:e,onChange:t,disabled:n=!1,compact:r=!1,testId:i=`milestone-auto-advance`}){let{t:a}=K(`builder`),o=a(e?`milestoneProgress.chain.autoAdvanceHint`:`milestoneProgress.chain.checkpointHint`);return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":a(`milestoneProgress.chain.autoAdvance`),disabled:n,onClick:()=>t(!e),title:o,className:X(`group inline-flex items-center gap-1.5 rounded-md border px-1.5 py-1 text-left text-[10px] transition-colors disabled:opacity-50`,e?`border-accent-success/40 bg-accent-success/10 text-accent-success`:`border-border/50 text-muted-foreground hover:text-foreground`,r?`py-0.5`:`w-full`),"data-testid":i,"data-checked":e,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`relative inline-flex h-3 w-5 shrink-0 items-center rounded-full transition-colors`,e?`bg-accent-success/70`:`bg-muted-foreground/30`),children:(0,$.jsx)(`span`,{className:X(`absolute h-2 w-2 rounded-full bg-background shadow transition-transform`,e?`translate-x-2.5`:`translate-x-0.5`)})}),e?(0,$.jsx)(hn,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}):(0,$.jsx)(ns,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:a(`milestoneProgress.chain.autoAdvance`)}),!r&&(0,$.jsx)(`span`,{className:`hidden truncate text-[9px] font-normal text-muted-foreground group-hover:inline`,children:o})]})}function oj({chain:e,busy:t=!1,onResume:n,onCancel:r,onSetAutoAdvance:i}){let{t:a}=K(`builder`),o=Ot(e),s=e.status===`paused`,c=_t(e),l=jt(e.pauseReason),u=s?a(`milestoneProgress.chain.reasons.${l.key}`,{detail:l.detail,defaultValue:e.pauseReason??``}):null,d=e.mode===`sequential`&&(o||s||c)&&!!i;return(0,$.jsxs)(`div`,{className:X(`rounded-md border px-2 py-1.5 text-[10px]`,s?`border-accent-warning/40 bg-accent-warning/5`:c?`border-accent-success/40 bg-accent-success/5`:o?`border-accent-info/30 bg-accent-info/5`:`border-border/30 bg-surface/40`),"data-testid":`milestone-chain-row`,"data-status":e.status,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(xs,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.mode===`parallel`?a(`milestoneProgress.chain.parallelTitle`):a(`milestoneProgress.chain.title`)}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,a(`milestoneProgress.chain.progress`,{k:Math.min(e.nextChunk,e.totalChunks),n:e.totalChunks})]}),(0,$.jsx)(`span`,{className:`flex-1`}),c&&n&&(0,$.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>n(e.id),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 font-medium text-accent-success hover:bg-accent-success/20 disabled:opacity-50`,"data-testid":`milestone-chain-launch-next`,children:[t?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(on,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.launchNext`)]}),s&&n&&(0,$.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>n(e.id),className:`inline-flex items-center gap-1 rounded-md border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 font-medium text-accent-success hover:bg-accent-success/20 disabled:opacity-50`,"data-testid":`milestone-chain-resume`,children:[t?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(on,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.resume`)]}),(o||s||c)&&r&&(0,$.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r(e.id),className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-1.5 py-0.5 text-muted-foreground hover:text-foreground disabled:opacity-50`,title:a(`milestoneProgress.chain.cancel`),"data-testid":`milestone-chain-cancel`,children:(0,$.jsx)(mn,{className:`h-3 w-3`,"aria-hidden":!0})})]}),(0,$.jsx)(`div`,{className:`mt-0.5 flex items-center gap-1 text-muted-foreground`,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zs,{className:`h-3 w-3 shrink-0 text-accent-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-accent-warning`,children:a(`milestoneProgress.chain.paused`,{reason:u})})]}):c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ns,{className:`h-3 w-3 shrink-0 text-accent-success`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-accent-success`,"data-testid":`milestone-chain-checkpoint`,children:a(`milestoneProgress.chain.checkpoint`,{k:e.nextChunk,next:e.nextChunk+1,n:e.totalChunks})}),e.headBranch&&(0,$.jsxs)(`span`,{className:`truncate font-mono`,title:e.headBranch,children:[` · `,a(`milestoneProgress.chain.stackedOn`,{branch:e.headBranch})]})]}):e.status===`running`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.waiting`,{k:e.nextChunk})}),e.headBranch&&e.mode===`sequential`&&(0,$.jsxs)(`span`,{className:`truncate font-mono`,title:e.headBranch,children:[` · `,a(`milestoneProgress.chain.stackedOn`,{branch:e.headBranch})]}),e.mode===`sequential`&&!e.autoAdvance&&e.nextChunk<e.totalChunks&&(0,$.jsxs)(`span`,{className:`shrink-0`,"data-testid":`milestone-chain-checkpoint-note`,children:[` · `,a(`milestoneProgress.chain.checkpointNote`)]})]}):e.status===`completed`?(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.completed`)}):e.status===`cancelled`?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(yo,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.cancelled`)]}):(0,$.jsx)(`span`,{children:a(`milestoneProgress.chain.waiting`,{k:e.nextChunk})})}),d&&i&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(aj,{checked:e.autoAdvance,disabled:t,onChange:t=>i(e.id,t),testId:`milestone-chain-auto-advance`})})]})}function sj({progress:e,actions:t,chainBusy:n,onReview:r,onOpenRail:i,onResume:a,onCancel:o,onSetAutoAdvance:s,className:c}){let{t:l}=K(`builder`),u=e.rails.some(e=>e.active),d=rj(u),{counts:f}=e,p=e.chain!==null&&e.chain.status!==`completed`&&e.chain.status!==`cancelled`||e.chain&&e.chain.status===`completed`&&e.rails.length>0&&u?e.chain:null;return(0,$.jsxs)(`div`,{className:X(`rounded-md border border-border/30 px-2 py-1.5`,c),"data-testid":`milestone-card`,"data-milestone":e.n,"data-state":e.state,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-px text-[9px] font-semibold text-accent-primary`,children:xt(e.n)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium`,children:e.title}),(0,$.jsx)(nj,{state:e.state})]}),f.total>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tj,{counts:f,className:`mt-1.5`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-[10px] tabular-nums text-muted-foreground`,children:[(0,$.jsx)(`span`,{"data-testid":`milestone-counts`,children:l(`milestoneProgress.counts`,{delivered:Nt(f),total:f.total,done:f.done})}),f.inProgress>0&&(0,$.jsxs)(`span`,{className:`text-accent-info`,children:[l(`milestoneProgress.legend.inProgress`),` · `,f.inProgress]})]}),f.failed>0&&(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-destructive`,"data-testid":`milestone-failed-note`,children:l(`milestoneProgress.failedNote`,{count:f.failed})})]}),t&&(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:t}),p&&(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(oj,{chain:p,busy:n,onResume:a,onCancel:o,onSetAutoAdvance:s})}),e.rails.length>0&&(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`milestone-rails`,children:e.rails.map(e=>(0,$.jsx)(ij,{rail:e,now:d,onReview:r,onOpenRail:i},e.railIndex))})]})}function cj({projectId:e}){let{t}=K(`builder`),n=v(),{setActiveProjectId:r}=at(),{progress:i,hasBlueprint:a}=Dt(e),[o,s]=(0,Q.useState)(!1),c=i.find(e=>e.n===1)??null,l=(0,Q.useCallback)(t=>{r(e),setTimeout(()=>n(t),50)},[n,e,r]),u=(0,Q.useCallback)(async n=>{s(!0);try{let r=await OA(e,n);r.ok?J.success(t(`milestoneProgress.chain.resumed`)):J.error(t(`milestoneProgress.chain.resumeFailed`),{description:r.detail??r.error})}finally{s(!1)}},[e,t]),d=(0,Q.useCallback)(async(n,r)=>{s(!0);try{let i=await AA(e,n,r);i.ok?(xA(r),J.success(t(r?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):J.error(t(`milestoneProgress.chain.autoFailed`),{description:i.detail??i.error})}finally{s(!1)}},[e,t]),f=(0,Q.useCallback)(async n=>{s(!0);try{let r=await kA(e,n);r.ok?J.success(t(`milestoneProgress.chain.cancelledToast`)):J.error(r.detail??r.error)}finally{s(!1)}},[e,t]);return a===null&&!c?(0,$.jsx)(`div`,{className:`mt-4 flex items-center justify-center gap-2 text-xs text-muted-foreground`,"data-testid":`builder-done-milestone-loading`,children:(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0})}):c?(0,$.jsx)(`div`,{className:`mt-4 text-left`,"data-testid":`builder-done-milestone`,children:(0,$.jsx)(sj,{progress:c,chainBusy:o,onReview:e=>l(ve?`/review/${e}`:`/`),onOpenRail:()=>l(`/`),onResume:u,onCancel:f,onSetAutoAdvance:d,className:`bg-card/60`})}):null}var lj={surprise:mc,approve:Xs};function uj({kind:e,mode:t,onAction:n,disabled:r=!1,createdAt:i,className:a}){let{t:o}=K(`builder`),s=dy(),c=t===`settled`,l=c?Ht:lj[e],u=i?dj(i):null,d=X(`group relative my-1 w-full max-w-lg overflow-hidden rounded-xl border text-left shadow-lg backdrop-blur`,c?`border-accent-success/25 bg-card/60`:`border-accent-primary/25 bg-card/80 transition-colors hover:border-accent-primary/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 disabled:cursor-not-allowed disabled:opacity-60`,a),f=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-0 bg-gradient-to-br via-transparent transition-opacity`,c?`from-accent-success/[0.06] to-accent-success/[0.03] opacity-100`:`from-accent-primary/[0.08] to-accent-highlight/[0.08] opacity-70 group-hover:opacity-100`)}),(0,$.jsxs)(`div`,{className:X(`relative flex items-center justify-between gap-2 border-b border-border/40 px-3.5 py-2`,c?`bg-accent-success/[0.05]`:`bg-accent-primary/[0.06]`),children:[(0,$.jsxs)(`span`,{className:X(`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest`,c?`text-accent-success/90`:`text-accent-primary/90`),children:[c?(0,$.jsx)(Ht,{className:`h-3 w-3`,"aria-hidden":!0}):(0,$.jsx)(un,{className:`h-3 w-3`,"aria-hidden":!0}),o(c?`decisionCard.settledLabel`:`decisionCard.${e}.label`)]}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`builder-decision-card-meta`,children:c?u:o(`decisionCard.${e}.hint`)})]}),(0,$.jsxs)(`div`,{className:`relative flex items-center gap-3.5 px-3.5 py-3`,children:[(0,$.jsx)(`span`,{className:X(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full shadow-inner`,c?`bg-accent-success/15 text-accent-success`:`bg-gradient-to-br from-accent-primary/25 to-accent-highlight/25 text-accent-primary`),children:(0,$.jsx)(l,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold leading-snug text-foreground`,children:o(c?`decisionCard.${e}.settledTitle`:`decisionCard.${e}.title`)}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-muted-foreground`,children:o(c?`decisionCard.${e}.settledDescription`:`decisionCard.${e}.description`)})]}),!c&&(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-accent-primary/15 px-2.5 py-1 text-[11px] font-medium text-accent-primary transition-colors group-hover:bg-accent-primary/25`,children:[o(`decisionCard.${e}.cta`),(0,$.jsx)(B,{className:`h-3 w-3 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})]})]});return c?(0,$.jsx)(`div`,{className:d,"data-testid":`builder-decision-card`,"data-kind":e,"data-mode":`settled`,children:f}):(0,$.jsx)(fy.button,{type:`button`,onClick:n,disabled:r,initial:s?{opacity:0}:{opacity:0,y:8},animate:{opacity:1,y:0},exit:s?{opacity:0}:{opacity:0,y:-6},transition:{duration:.22,ease:`easeOut`},whileHover:r||s?void 0:{y:-2},whileTap:r?void 0:{scale:.99},className:d,"data-testid":`builder-decision-card`,"data-kind":e,"data-mode":`offer`,"aria-label":o(`decisionCard.${e}.cta`),children:f})}function dj(e){let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return pb(t,`p`,{locale:Ue()})}catch{return null}}var fj=`w-full rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`;function pj({variant:e}){let{t}=K(`builder`),{builderMode:n}=lM(),r=n.session,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(()=>bA()),c=(0,Q.useRef)(null),l=r.messages[r.messages.length-1],u=r.readiness.steps.find(e=>e.key===`blueprint`),d=r.readiness.steps.find(e=>e.key===`specs`),f=r.phase===`chat`&&!r.busy&&r.streamBuffer===null&&l?.role===`assistant`&&r.snapshot.status!==`generating`,p=f&&u?.state!==`done`,m=f&&u?.state===`done`&&(d===void 0||d.state===`pending`&&Number(d.params.count??0)===0)&&(r.blueprint?.m1Specs.length??0)===0;(0,Q.useEffect)(()=>{c.current?.scrollTo?.({top:c.current.scrollHeight})},[r.messages,r.streamBuffer]);let h=(0,Q.useCallback)(()=>{r.dirty&&r.phase!==`done`?a(!0):n.exit()},[r.dirty,r.phase,n]),g=(0,Q.useCallback)(e=>{e.key===`Escape`&&(e.stopPropagation(),i?a(!1):r.phase===`commit`&&!r.submitting?r.backToChat():r.phase===`chat`&&h())},[i,r,h]),_=r.messages.length===0&&r.streamBuffer===null&&!r.busy,v=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,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,onKeyDown:g,"data-testid":`builder-conversation`,children:[r.phase===`chat`&&(_?(0,$.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,$.jsxs)(fy.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,$.jsxs)(`div`,{className:`mb-4 text-center`,children:[(0,$.jsx)(un,{className:`mx-auto h-7 w-7 text-accent-primary/60`}),(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium`,children:t(`shell.emptyTitle`)}),(0,$.jsx)(`p`,{className:`mx-auto mt-1 max-w-sm text-xs text-muted-foreground`,children:t(`shell.emptyHint`)})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(JO,{active:!0,inset:-3,radius:`1rem`}),(0,$.jsx)(fy.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:fj,children:(0,$.jsx)(dA,{session:r,autoFocus:!0})})]}),(0,$.jsx)(pA,{items:r.recent,loading:r.recentLoading,disabled:!r.conversationReady,onResume:e=>void r.resume(e),onDiscard:e=>void r.discardRecent(e)})]})}):(0,$.jsxs)(`div`,{className:v,children:[(0,$.jsxs)(`div`,{ref:c,className:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,"data-testid":`builder-messages`,children:[r.messages.map((e,t)=>e.role===`user`&&e.intent?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(uj,{kind:e.intent,mode:`settled`,createdAt:e.createdAt})},`${t}-${e.createdAt}`):(0,$.jsx)(Rx,{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}`)),(0,$.jsxs)(f_,{initial:!1,children:[p&&(0,$.jsx)(uj,{kind:`surprise`,mode:`offer`,onAction:r.surpriseMe,disabled:!r.conversationReady},`surprise`),m&&(0,$.jsx)(uj,{kind:`approve`,mode:`offer`,onAction:r.approveBlueprint,disabled:!r.conversationReady},`approve`)]}),(r.busy||r.streamBuffer!==null)&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r.streamBuffer!==null&&St(r.streamBuffer)&&(0,$.jsx)(Rx,{role:`assistant`,content:St(r.streamBuffer),streaming:!0}),r.generation.generating||r.snapshot.status===`repairing`||r.snapshot.status===`generating`?(0,$.jsx)(mA,{specsStarted:r.generation.specsStarted,snapshot:r.snapshot}):(0,$.jsx)(bb,{tool:null})]})]}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsx)(fy.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(fj,e===`inline`&&`mx-auto max-w-[680px]`),children:(0,$.jsx)(dA,{session:r})})})]})),r.phase===`commit`&&r.blueprint&&(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto`,children:(0,$.jsx)(uA,{blueprint:r.blueprint,onSubmit:r.submitCommit,onBack:r.backToChat,submitting:r.submitting,error:r.commitError,errorDetail:r.commitErrorDetail})}),r.phase===`progress`&&(0,$.jsxs)(`div`,{className:`mx-auto mt-10 w-full max-w-md p-6`,"data-testid":`commit-progress`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:t(`progress.title`)}),(0,$.jsx)(`ul`,{className:`mt-4 space-y-2`,children:qA.map(e=>{let n=r.commitSteps.find(t=>t.step===e);return!n&&e===`github`?null:(0,$.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[!n&&(0,$.jsx)(No,{className:`h-3.5 w-3.5 text-muted-foreground/40`}),n?.status===`running`&&(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin text-accent-info`}),n?.status===`done`&&(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 text-accent-success`}),n?.status===`warning`&&(0,$.jsx)(fn,{className:`h-3.5 w-3.5 text-accent-warning`}),n?.status===`failed`&&(0,$.jsx)(mn,{className:`h-3.5 w-3.5 text-destructive`}),(0,$.jsx)(`span`,{className:X(!n&&`text-muted-foreground/50`),children:t(`progress.steps.${e}`)}),n?.status===`warning`&&e===`github`?(0,$.jsx)(`span`,{className:`truncate text-[10px] text-accent-warning`,title:n.detail,children:t(KA(n.code))}):n?.detail&&(0,$.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,title:n.detail,children:n.detail})]},e)})})]}),r.phase===`done`&&(0,$.jsxs)(`div`,{className:`mx-auto mt-12 w-full max-w-md p-6 text-center`,"data-testid":`commit-done`,children:[(0,$.jsx)(Ht,{className:`mx-auto h-10 w-10 rounded-full bg-accent-success/15 p-2 text-accent-success`}),(0,$.jsx)(`h2`,{className:`mt-3 text-sm font-semibold`,children:t(`done.title`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`done.description`)}),r.launched&&r.createdProjectId&&(0,$.jsx)(cj,{projectId:r.createdProjectId}),(0,$.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2`,children:[!r.launched&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{onClick:()=>void r.launchM1(),disabled:r.launching,"data-testid":`launch-m1`,children:[r.launching?(0,$.jsx)(rn,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`}),t(`done.launchM1`)]}),_A()===`sequential`&&(0,$.jsx)(aj,{checked:o,onChange:e=>{s(e),xA(e)},disabled:r.launching,testId:`done-auto-advance`})]}),(0,$.jsx)(Z,{variant:`outline`,onClick:r.openProject,"data-testid":`open-project`,children:t(`done.openProject`)})]})]}),i&&(0,$.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,$.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,$.jsx)(`p`,{id:`builder-exit-confirm-title`,className:`text-sm font-medium`,children:t(`mode.exitConfirmTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t(`mode.exitConfirmBody`)}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>a(!1),"data-testid":`builder-exit-cancel`,children:t(`mode.exitConfirmCancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,onClick:()=>{a(!1),n.exit()},"data-testid":`builder-exit-confirm-btn`,children:t(`mode.exitConfirmDiscard`)})]})]})})]})}var mj=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`),hj={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 gj({spec:e,index:t,milestoneLabel:n=`M1`,onClose:r}){let{t:i}=K(`builder`),{t:a}=K(`tickets`),o=`blueprint-spec-summary-${t}`;return(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,xb.createPortal)((0,$.jsxs)(`div`,{"data-testid":`blueprint-spec-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:r,"aria-hidden":!0}),(0,$.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,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border/40 px-5 py-4`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-4 w-4 shrink-0 text-accent-primary`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:i(`specModal.eyebrow`,{milestone:n,index:t+1})}),(0,$.jsx)(`h2`,{className:`mt-0.5 text-base font-semibold text-foreground`,children:e.title}),e.shortSummary.trim()&&(0,$.jsxs)(`p`,{id:o,className:`mt-1 text-xs leading-5 text-muted-foreground`,"data-testid":`blueprint-spec-summary`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[i(`specModal.summary`),`: `]}),e.shortSummary]}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[(0,$.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,hj[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,$.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,$.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,$.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,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`section`,{"aria-label":i(`specModal.description`),"data-testid":`blueprint-spec-description`,children:e.description.trim()?(0,$.jsx)(`div`,{className:mj,children:(0,$.jsx)(Jn,{remarkPlugins:[Yn],children:e.description})}):(0,$.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.empty`)})}),(0,$.jsxs)(`section`,{"aria-labelledby":`blueprint-spec-criteria-heading`,"data-testid":`blueprint-spec-acceptance-criteria`,children:[(0,$.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,$.jsx)(`span`,{children:i(`specModal.acceptanceCriteria`)}),(0,$.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,$.jsx)(`ol`,{className:`space-y-2`,children:e.acceptanceCriteria.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2 text-sm leading-6 text-foreground/85`,"data-testid":`blueprint-spec-criterion-${t}`,children:[(0,$.jsx)(Mo,{className:`mt-1 h-4 w-4 shrink-0 text-accent-success`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:e})]},`${t}-${e}`))}):(0,$.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:i(`specModal.criteriaEmpty`)})]})]})]})]}),document.body)}var _j={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 vj({blueprint:e,milestoneLabel:t=`M1`,snapshot:n}){let{t:r}=K(`builder`),{t:i}=K(`tickets`),a=gt(e),[o,s]=(0,Q.useState)(null),c=[{key:`product`,label:r(`panel.product`),value:e?.product.name??``},{key:`coreFlow`,label:r(`panel.coreFlow`),value:e?.coreFlow??``},{key:`platform`,label:r(`panel.platform`),value:e?.platform??``},{key:`stack`,label:r(`panel.stack`),value:e?[e.stack.language,e.stack.framework,e.stack.db].filter(Boolean).join(` · `):``},{key:`milestones`,label:r(`panel.milestones`),value:e&&e.milestones.length>0?r(`panel.milestonesValue`,{count:e.milestones.length}):``}];return(0,$.jsxs)(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`blueprint-panel`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[r(`panel.title`),n?.status===`repairing`&&(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin text-accent-info`,"aria-hidden":!0,"data-testid":`panel-repairing`})]}),(0,$.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>(0,$.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-xs transition-colors`,a[e.key]?`border-accent-success/30 bg-accent-success/5`:`border-border/30`),"data-testid":`dimension-${e.key}`,children:[a[e.key]?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-label":`✓`}):(0,$.jsx)(mn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/40`,"aria-label":`✗`}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.value&&(0,$.jsx)(`span`,{className:`ml-auto truncate text-muted-foreground`,title:e.value,children:e.value})]},e.key))})]}),e&&e.assumptions.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`panel.assumptions`)}),(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:e.assumptions.map((e,t)=>(0,$.jsx)(`li`,{className:`text-[11px] text-muted-foreground before:mr-1.5 before:content-['·']`,children:e},t))})]}),e&&e.m1Specs.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`h4`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,$.jsx)(xs,{className:`h-3 w-3`}),r(`panel.m1Specs`,{count:e.m1Specs.length}),(0,$.jsx)(`span`,{className:X(`ml-auto rounded-full border px-1.5 py-px text-[9px] font-medium normal-case tracking-normal`,e.specsComplete?`border-accent-success/35 bg-accent-success/10 text-accent-success`:`border-accent-warning/35 bg-accent-warning/10 text-accent-warning`),"data-testid":`m1-specs-completeness`,children:e.specsComplete?r(`panel.specsComplete`):r(`panel.specsInProgress`)})]}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.m1Specs.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(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:r(`specModal.open`),children:(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium leading-tight`,children:e.title}),e.shortSummary.trim()&&(0,$.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,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[9px] font-medium uppercase tracking-wide`,_j[e.priority]),"data-testid":`m1-spec-priority-${t}`,children:i(`priority.${e.priority}`)}),!e.description.trim()&&e.acceptanceCriteria.length===0?(0,$.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 rounded-full border px-1.5 py-px text-[9px]`,n?.status===`generating`?`border-accent-info/35 bg-accent-info/10 text-accent-info`:`border-border/50 bg-surface/70 text-muted-foreground`),"data-testid":`m1-spec-unwritten-${t}`,children:[n?.status===`generating`?(0,$.jsx)(rn,{className:`h-2.5 w-2.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ts,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),r(n?.status===`generating`?`panel.specWriting`:`panel.specPendingBody`)]}):(0,$.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,$.jsx)(Ts,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),r(`panel.criteriaCount`,{count:e.acceptanceCriteria.length})]}),e.labels.map(e=>(0,$.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,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-[9px] text-muted-foreground`,children:r(`panel.dependsOn`,{index:e.dependsOnIndex+1})})]})]})]})},`${t}-${e.title}`))})]}),e&&e.milestones.length>1&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:r(`panel.laterMilestones`)}),e.milestones.slice(1).map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-border/20 px-2.5 py-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-medium`,children:e.title}),e.plannedSpecs.length>0&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e.plannedSpecs.join(` · `)})]},e.id||e.title))]}),!e&&(0,$.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground/60`,children:r(`panel.empty`)}),e&&o!==null&&e.m1Specs[o]&&(0,$.jsx)(gj,{spec:e.m1Specs[o],index:o,milestoneLabel:t,onClose:()=>s(null)})]})}var yj={done:Ht,pending:No,blocked:fn,writing:rn},bj={done:`text-accent-success`,pending:`text-muted-foreground/50`,blocked:`text-accent-warning`,writing:`text-accent-info animate-spin`};function xj({readiness:e,snapshot:t,busy:n,primaryLabel:r,onPrimary:i,onRepair:a,primaryTestId:o=`builder-create-specs`,showPrimary:s=!0}){let{t:c}=K(`builder`),[l,u]=(0,Q.useState)(!1),d=t.status===`repairing`,f=t.status===`rejected`,p=t.status===`accepted`&&t.generationHalted===!0&&!n,m=e.steps.find(e=>e.key===`specs`),h=m?.state===`done`,g=!!a&&h&&e.issues.length>0,_=e.steps.find(e=>e.state!==`done`);return(0,$.jsxs)(`div`,{className:`space-y-2.5 border-t border-border/40 p-3`,"data-testid":`blueprint-readiness`,children:[(0,$.jsx)(`ol`,{className:`space-y-1`,"aria-label":c(`readiness.title`),children:e.steps.map(e=>{let t=yj[e.state];return(0,$.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4`,"data-testid":`readiness-step-${e.key}`,"data-state":e.state,children:[(0,$.jsx)(t,{className:X(`mt-px h-3.5 w-3.5 shrink-0`,bj[e.state]),"aria-hidden":!0}),(0,$.jsx)(`span`,{className:X(`font-medium`,e.state===`pending`&&`text-muted-foreground`,e.state===`writing`&&`text-accent-info`),children:c(`readiness.steps.${e.key}`)}),(0,$.jsx)(`span`,{className:`ml-auto max-w-[60%] truncate text-right text-muted-foreground`,title:c(`readiness.details.${e.key}.${e.state}`,e.params),children:c(`readiness.details.${e.key}.${e.state}`,e.params)})]},e.key)})}),(0,$.jsxs)(f_,{initial:!1,mode:`wait`,children:[d&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`flex items-center gap-2 rounded-md border border-accent-info/30 bg-accent-info/10 px-2.5 py-1.5 text-[11px] text-accent-info`,"data-testid":`snapshot-repairing`,children:[(0,$.jsx)(rn,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c(`snapshot.repairing.${t.kind}`),t.manual?``:` · ${c(`snapshot.repairing.automatic`)}`]})]},`repairing`),f&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`space-y-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 p-2.5`,"data-testid":`snapshot-rejected`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:c(`snapshot.rejected.title`)}),(0,$.jsx)(`p`,{className:`text-accent-warning/90`,children:c(`snapshot.rejected.${t.reason}`)}),t.repairAttempted&&(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-accent-warning/80`,children:c(`snapshot.rejected.autoRepairFailed`)})]})]}),t.detail&&(0,$.jsx)(`p`,{className:`line-clamp-2 break-all font-mono text-[10px] leading-4 text-foreground/60`,title:t.detail,"data-testid":`snapshot-rejected-detail`,children:t.detail}),a&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`snapshot-retry`,children:[(0,$.jsx)(Js,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.rejected.retry`)]})]},`rejected`),p&&(0,$.jsxs)(fy.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:`space-y-1.5 rounded-md border border-accent-warning/35 bg-accent-warning/10 p-2.5`,"data-testid":`snapshot-halted`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(fn,{className:`mt-px h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:c(`snapshot.halted.title`)}),(0,$.jsx)(`p`,{className:`text-accent-warning/90`,children:c(`snapshot.halted.detail`,{written:m?.params?.written??0,total:m?.params?.count??0})})]})]}),a&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`snapshot-resume`,children:[(0,$.jsx)(un,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.halted.resume`)]})]},`halted`),t.status===`accepted`&&t.repaired&&!p&&(0,$.jsxs)(fy.p,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,"data-testid":`snapshot-repaired`,children:[(0,$.jsx)(un,{className:`h-3 w-3 text-accent-success`,"aria-hidden":!0}),c(`snapshot.repairedNote`)]},`repaired`)]}),e.issues.length>0&&(0,$.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-surface/40`,"data-testid":`readiness-issues`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-expanded":l,className:`flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px] font-medium text-foreground/80 hover:bg-surface/70`,"data-testid":`readiness-issues-toggle`,children:[(0,$.jsx)(pn,{className:`h-3 w-3 text-accent-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`readiness.issuesCount`,{count:e.issues.length})}),(0,$.jsx)(Zt,{className:X(`h-3.5 w-3.5 transition-transform`,l&&`rotate-180`),"aria-hidden":!0})]}),l&&(0,$.jsx)(`ul`,{className:`max-h-40 space-y-1 overflow-y-auto border-t border-border/30 px-2.5 py-2`,children:e.issues.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[10px] leading-4 text-muted-foreground`,children:[e.specIndex!==null&&(0,$.jsxs)(`span`,{className:`shrink-0 rounded bg-accent-primary/10 px-1 font-mono text-[9px] text-accent-primary`,children:[`#`,e.specIndex+1]}),(0,$.jsx)(`span`,{children:WA(c,e)})]},`${e.specIndex}-${e.field}-${e.code}-${t}`))}),g&&(0,$.jsx)(`div`,{className:`border-t border-border/30 p-2`,children:(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`w-full`,disabled:n,onClick:a,"data-testid":`readiness-ask-fix`,children:[(0,$.jsx)(pn,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`readiness.askFix`)]})})]}),s&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(Z,{className:`w-full`,size:`sm`,disabled:!e.ready||n,onClick:i,"data-testid":o,children:[(0,$.jsx)(Xs,{className:`mr-1.5 h-3.5 w-3.5`,"aria-hidden":!0}),r]}),!e.ready&&_&&!d&&!f&&!p&&(0,$.jsx)(`p`,{className:`mt-1.5 text-center text-[10px] text-muted-foreground`,"data-testid":`readiness-hint`,children:c(`readiness.hints.${_.key}.${_.state}`,_.params)})]})]})}function Sj(){let{t:e}=K(`agent`),{t}=K(`builder`),{minimize:n,startNewConversation:r,cycleTier:i,active:a,draftPinnedProjectId:o,setPinnedProject:s,builderMode:c}=lM(),[l,u]=(0,Q.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}=bn({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(fy.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,$.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,$.jsxs)(`span`,{className:`relative flex h-5 w-5 shrink-0 items-center justify-center`,children:[(0,$.jsx)(JO,{active:d&&c.session.messages.length===0&&c.session.phase===`chat`,inset:-3}),(0,$.jsx)(So,{className:`h-4 w-4 shrink-0 text-accent-primary`})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm font-medium text-foreground/80`,children:d?t(`mode.title`):e(`title`)}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dD,{pinnedProjectId:a?a.pinned_project_id:o,onSelect:e=>void s(e)}),(0,$.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border/60`,"aria-hidden":!0}),(0,$.jsx)(Xk,{})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[!d&&(0,$.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,$.jsx)(cn,{className:`h-4 w-4`})}),(0,$.jsx)(_c,{}),(0,$.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,$.jsx)(ks,{className:`h-4 w-4`}):(0,$.jsx)(Os,{className:`h-4 w-4`})}),(0,$.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,$.jsx)(mn,{className:`h-4 w-4`})})]})]}),d?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsx)(pj,{variant:`floating`}),(0,$.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border/40 lg:w-80`,children:[(0,$.jsx)(vj,{blueprint:c.session.blueprint,snapshot:c.session.snapshot}),c.session.phase===`chat`&&(0,$.jsx)(xj,{readiness:c.session.readiness,snapshot:c.session.snapshot,busy:c.session.busy,primaryLabel:t(`shell.createSpecs`),onPrimary:c.session.goToCommit,onRepair:()=>void c.session.repairSnapshot()})]})]}):(0,$.jsx)(Kk,{variant:`floating`})]}),!l&&(0,$.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,$.jsx)(Nn,{handles:g})})]})}var Cj=`specrails-desktop:agent-bubble-pos`,wj=56,Tj=12;function Ej(){try{let e=localStorage.getItem(Cj);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function Dj(e){let t=Math.max(Tj,window.innerWidth-wj-Tj),n=Math.max(Tj,window.innerHeight-wj-Tj);return{left:Math.min(Math.max(Tj,e.left),t),top:Math.min(Math.max(Tj,e.top),n)}}function Oj(){return{left:Math.round(window.innerWidth/2-wj/2),top:window.innerHeight-wj-20}}function kj(){let{t:e}=K(`agent`),{t}=K(`builder`),{open:n,isStreaming:r,active:i,builderMode:a}=lM(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(()=>Dj(Ej()??Oj())),u=uy(0),d=uy(0),f=(0,Q.useRef)(!1),p=a.active?a.session.busy:r;(0,Q.useEffect)(()=>{let e=()=>l(e=>Dj(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,Q.useCallback)(e=>{try{localStorage.setItem(Cj,JSON.stringify(e))}catch{}},[]);return(0,$.jsxs)(fy.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=Dj({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,$.jsxs)(`span`,{className:`relative flex h-9 w-9 items-center justify-center rounded-full bg-accent-primary/15`,children:[(0,$.jsx)(JO,{active:a.active&&a.session.messages.length===0&&a.session.phase===`chat`,inset:-4}),(0,$.jsx)(So,{className:`h-5 w-5 text-accent-primary`}),p&&(0,$.jsx)(fy.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,$.jsx)(f_,{initial:!1,children:(o||p)&&(0,$.jsx)(fy.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 Aj=`specrails-desktop:uiMode`;function jj(){if(!y)return`kanban`;try{return localStorage.getItem(Aj)===`kanban`?`kanban`:`agent`}catch{return`agent`}}function Mj(e){try{localStorage.setItem(Aj,e)}catch{}}var Nj=(0,Q.createContext)(null);function Pj({children:e,initialMode:t,persist:n=!0}){let[r,i]=(0,Q.useState)(()=>t??jj()),a=(0,Q.useCallback)(e=>{y&&(i(e),n&&Mj(e))},[n]),o=(0,Q.useCallback)(()=>{i(e=>{if(!y)return`kanban`;let t=e===`kanban`?`agent`:`kanban`;return n&&Mj(t),t})},[n]),s=(0,Q.useMemo)(()=>({uiMode:r,setUiMode:a,toggleUiMode:o}),[r,a,o]);return(0,$.jsx)(Nj.Provider,{value:s,children:e})}var Fj={uiMode:`kanban`,setUiMode:()=>{},toggleUiMode:()=>{}};function Ij(){return(0,Q.useContext)(Nj)??Fj}var Lj={streamingText:``,isStreaming:!1,liveTools:[],turnTools:[],queued:[]},Rj=`specrails-desktop:favorite-agent-conversations`;function zj(){try{let e=localStorage.getItem(Rj);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 Bj(e){try{localStorage.setItem(Rj,JSON.stringify([...e]))}catch{}}function Vj(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var Hj=`specrails-desktop:agent-tier-last`;function Uj(){try{let e=localStorage.getItem(Hj),t=e===null?0:Number.parseInt(e,10);return t===0||t===1||t===2||t===3?t:0}catch{return 0}}function Wj(e){try{localStorage.setItem(Hj,String(e))}catch{}}var Gj=new Set([`completed`,`merged`,`discarded`,`superseded`]);function Kj(e,t){return JSON.stringify(e)===JSON.stringify(t)}function qj(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 Jj(e,t){if(t.supersedesDeliveryId===e.prDeliveryId)return 1;if(e.supersedesDeliveryId===t.prDeliveryId)return-1;let n=qj(e),r=qj(t);return n==null||r==null?null:r<n?-1:+(r>n)}function Yj(e,t){let n=null;for(let r of e){if(r.supersedesDeliveryId!==t)continue;if(!n){n=r;continue}let e=qj(n),i=qj(r);(e==null||i==null||i>=e)&&(n=r)}return n}function Xj(e,t){let n=t.restoredFromDeliveryId;if(!n)return!1;let r=Yj(e,t.prDeliveryId);return!r||r.prDeliveryId===n}function Zj(e,t){let n=e.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null),r=[...n].reverse().find(e=>e.prDeliveryId===t.prDeliveryId),i=Xj(n,t);if(r){let e=Gj.has(r.decision),n=Gj.has(t.decision),a=Ft(r.updatedAt,t.updatedAt);if(a===-1||a===0&&!Kj(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=Jj(e,t);if(n===-1||(n===0||n===null)&&!Gj.has(e.decision)&&t.supersedesDeliveryId!==e.prDeliveryId)return!0}return!1}function Qj(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=io(e.content);return!t||t.prDeliveryId!==n||Gj.has(t.decision)?e:(r=!0,{...e,content:JSON.stringify({...t,decision:`discarded`})})});return r?i:e}function $j(e,t){let n=e.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null);if(n.some(e=>e.restoredFromDeliveryId===t.prDeliveryId&&Xj(n,e)))return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let n=io(e.content);return!n||n.railIndex!==t.railIndex||n.prDeliveryId===t.prDeliveryId||Gj.has(n.decision)||Jj(n,t)!==1?e:(r=!0,{...e,content:JSON.stringify({...n,decision:`superseded`})})});return r?i:e}function eM(e,t,n){if(Zj(e,n))return e;let r=$j(Qj(e,n),n),i=JSON.stringify(n),a=r.flatMap((e,t)=>e.role===`system`&&io(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 tM=(0,Q.createContext)(null),nM=0,rM=0,iM={sent:0,received:1,read:2};function aM(e,t){return e&&(!t||iM[e]>=iM[t])?e:t}function oM(e,t){let n=[...e];for(let[e,r]of t.entries()){let i=n.findIndex(e=>e.id===r.id);if(i>=0){let e=aM(n[i].delivery_receipt,r.delivery_receipt);n[i]={...r,...e?{delivery_receipt:e}:{}}}else{let i=new Set(t.slice(e+1).map(e=>e.id)),a=n.findIndex(e=>i.has(e.id));a>=0?n.splice(a,0,r):n.push(r)}}return n}function sM({children:e}){let{registerHandler:t,unregisterHandler:n,connectionStatus:r}=qe(),{uiMode:i}=Ij(),{setActiveProjectId:a,activeProjectId:o}=at(),s=si(),c=(0,Q.useRef)(s);c.current=s;let l=$r(),u=e=>e?c.current.isEditable(e):!l,[d,f]=(0,Q.useState)(`hidden`),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),y=(0,Q.useRef)(new Map),b=(0,Q.useRef)(_);b.current=_;let[x,S]=(0,Q.useState)(zj);(0,Q.useEffect)(()=>{let e=e=>{(e.key===Rj||e.key===null)&&S(zj())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let[C,w]=(0,Q.useState)(new Set),[T,E]=(0,Q.useState)(new Map),[D,O]=(0,Q.useState)(!0),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,F]=(0,Q.useState)(null),I=(0,Q.useRef)(null);I.current=N;let[L,R]=(0,Q.useState)(`claude`),[z,B]=(0,Q.useState)(null),[ee,V]=(0,Q.useState)(()=>Uj()),[H,te]=(0,Q.useState)(null),ne=(0,Q.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});ne.current={provider:L,model:z,tierLevel:ee,effort:H};let re=(0,Q.useRef)(null);re.current=h?.id??null;let ie=(0,Q.useRef)(T);ie.current=T;let ae=(0,Q.useRef)(new Set),oe=(0,Q.useRef)(new Set),se=(0,Q.useRef)(new Map),ce=(0,Q.useRef)(new Map),le=e=>{let t=aM(e.delivery_receipt,se.current.get(`${e.conversation_id}:m:${e.id}`));return t?{...e,delivery_receipt:t}:e},ue=(e,t)=>{let n=aM(t.deliveryReceipt,se.current.get(`${e}:q:${t.queueId}`));return n?{...t,deliveryReceipt:n}:t},de=(0,Q.useRef)(new Set),fe=(0,Q.useRef)(new Map),pe=(0,Q.useRef)(new Map),me=(0,Q.useRef)(new Map),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(0),_e=(0,Q.useRef)(0),ve=(0,Q.useRef)(new Map),ye=(0,Q.useCallback)(e=>{let t=re.current;if(!t)return`untracked`;if(Zj(b.current,e))return`stale`;if(!b.current.some(t=>t.role===`system`&&io(t.content)?.prDeliveryId===e.prDeliveryId))return`untracked`;ge.current++;let n=eM(b.current,t,e);return b.current=n,v(n=>{if(!n.some(t=>t.role===`system`&&io(t.content)?.prDeliveryId===e.prDeliveryId))return b.current=n,n;let r=eM(n,t,e);return b.current=r,r}),`accepted`},[]),U=(0,Q.useCallback)((e,t)=>{E(n=>{let r=t(n.get(e)??Lj),i=new Map(n);return r===null||!r.isStreaming&&!r.streamingText&&r.liveTools.length===0&&r.turnTools.length===0&&r.queued.length===0?i.delete(e):i.set(e,r),i})},[]),be=(0,Q.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===re.current&&!t||w(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),xe=(0,Q.useCallback)(e=>{w(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,Q.useEffect)(()=>{if(!P||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=re.current;e&&xe(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[xe]);let Se=(h?T.get(h.id):void 0)??Lj,Ce=Se.streamingText,W=Se.isStreaming,we=Se.liveTools,Te=Se.turnTools,Ee=Se.queued,De=(0,Q.useMemo)(()=>{let e=new Set;for(let[t,n]of T)n.isStreaming&&e.add(t);return e},[T]),Oe=(0,Q.useCallback)(async()=>{try{let e=await Ra();m(e),S(t=>{let n=Vj(zj(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(Bj(n),n)})}catch{}},[]),ke=(0,Q.useCallback)(async()=>{try{let e=await uo();O(e.enabled)}catch{O(!1)}},[]),Ae=(0,Q.useCallback)(async()=>{try{M((await lo()).any)}catch{M(!0)}},[]),[je,Me]=(0,Q.useState)(0);(0,Q.useEffect)(()=>P?(t(`agent-chat`,e=>{let t=e;if(!t)return;if(t.type===`desktop.project_recovered`){Me(e=>e+1);return}if(typeof t.type!=`string`||!t.type.startsWith(`agent_`))return;if(t.type===`agent_title`&&t.conversationId){let e=t.title??null;m(n=>n.map(n=>n.id===t.conversationId?{...n,title:e}:n)),g(n=>n&&n.id===t.conversationId?{...n,title:e}:n);return}let n=t.conversationId;if(!n)return;fe.current.set(n,(fe.current.get(n)??0)+1);let r=n===re.current,i=e=>{me.current.set(n,oM(me.current.get(n)??[],e).slice(-500)),r&&(b.current=oM(b.current,e),v(t=>oM(t,e)))};if(t.type===`agent_input_receipt`){if(t.receipt!==`received`&&t.receipt!==`read`)return;let e=`${n}:q:${t.queueId}`,a=t.messageId??ce.current.get(e);if(t.queueId&&se.current.set(e,aM(se.current.get(e),t.receipt)),a){let e=`${n}:m:${a}`;se.current.set(e,aM(se.current.get(e),t.receipt));let o=(r?b.current:me.current.get(n)??[]).find(e=>e.id===a);o&&i([le(o)])}U(n,e=>({...e,queued:e.queued.map(e=>e.queueId===t.queueId?{...e,deliveryReceipt:aM(e.deliveryReceipt,t.receipt)}:e)}))}else if(t.type===`agent_stream`)be(n),U(n,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(t.delta??``)}));else if(t.type===`agent_tool`)U(n,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${nM++}`,tool:t.tool??`tool`,...t.input?{input:t.input}:{},...t.toolId?{toolId:t.toolId}:{},...t.timestamp?{at:t.timestamp}:{}}].slice(-200)}));else if(t.type===`agent_tool_result`)U(n,e=>{let n=[...e.liveTools],r=t.toolId?n.findIndex(e=>e.toolId===t.toolId):-1;if(r===-1){for(let e=n.length-1;e>=0;e--)if(n[e].output===void 0){r=e;break}}return r===-1?e:(n[r]={...n[r],output:t.output??``,...t.isError?{isError:!0}:{}},{...e,liveTools:n})});else if(t.type===`agent_partial`){let e=t.fullText??``;e&&i([{id:t.messageId??`partial-${n}-${t.timestamp??Date.now()}`,conversation_id:n,role:`assistant`,content:e,created_at:t.timestamp??new Date().toISOString()}])}else if(t.type===`agent_done`){ve.current.delete(n),be(n);let e=t.fullText??``;t.messageId&&e?i([{id:t.messageId,conversation_id:n,role:`assistant`,content:e,created_at:t.timestamp??new Date().toISOString()}]):r&&e&&v(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()}]}),U(n,e=>({...Lj,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}))}else if(t.type===`agent_error`){ve.current.delete(n),be(n),U(n,e=>({...Lj,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}));let e=t.error||`The agent turn failed.`;J.error(e),r&&v(t=>[...t,{id:`err-${Date.now()}`,conversation_id:n,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(t.type===`agent_queued`){if(t.queueId&&ae.current.has(t.queueId))return;U(n,e=>{let r=aM(t.deliveryReceipt??t.delivery_receipt,se.current.get(`${n}:q:${t.queueId}`)),i={queueId:t.queueId??`srv-${rM++}`,text:t.text??``,contextRefs:t.contextRefs,attachmentIds:t.attachmentIds,deliveryMode:t.deliveryMode,...r?{deliveryReceipt:r}:{},timestamp:t.timestamp};return t.queueId&&e.queued.some(e=>e.queueId===t.queueId)?{...e,queued:e.queued.map(e=>e.queueId===t.queueId?{...e,...i,deliveryReceipt:aM(e.deliveryReceipt,i.deliveryReceipt),deliveryMode:e.deliveryMode===`steer`?`steer`:i.deliveryMode??e.deliveryMode,attachmentIds:i.attachmentIds??e.attachmentIds,contextRefs:i.contextRefs??e.contextRefs}:e)}:{...e,queued:[...e.queued,i]}})}else if(t.type===`agent_steered`){if(!t.messageId)return;if(de.current.has(t.messageId)){t.queueId&&ae.current.add(t.queueId),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId)}));return}de.current.add(t.messageId),t.queueId&&ae.current.add(t.queueId),ce.current.set(`${n}:q:${t.queueId}`,t.messageId);let e=aM(t.delivery_receipt??t.deliveryReceipt,se.current.get(`${n}:q:${t.queueId}`)),r=[];t.assistantSegment&&r.push({...t.assistantSegment,conversation_id:n,role:`assistant`}),r.push(le({id:t.messageId,conversation_id:n,role:`user`,content:t.text??``,context_refs:t.contextRefs??[],attachment_ids:t.attachmentIds??[],delivery_status:t.deliveryStatus??`delivered`,...e?{delivery_receipt:e}:{},created_at:t.timestamp??new Date().toISOString()})),i(r),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId),streamingText:t.assistantSegment?``:e.streamingText}))}else if(t.type===`agent_dequeued`){if(t.queueId&&ae.current.has(t.queueId))return;if(t.queueId&&ae.current.add(t.queueId),U(n,e=>({...e,queued:t.queueId?e.queued.filter(e=>e.queueId!==t.queueId):e.queued.slice(1),isStreaming:!0,streamingText:``,liveTools:[]})),t.text){t.messageId&&ce.current.set(`${n}:q:${t.queueId}`,t.messageId);let e=aM(t.delivery_receipt??t.deliveryReceipt,se.current.get(`${n}:q:${t.queueId}`));i([le({id:t.messageId??`local-u-${Date.now()}`,conversation_id:n,role:`user`,content:t.text,context_refs:t.contextRefs??[],attachment_ids:t.attachmentIds??[],...t.messageId?{delivery_status:`delivered`}:{},...e?{delivery_receipt:e}:{},created_at:t.timestamp??new Date().toISOString()})])}}else if(t.type===`agent_queue_cleared`)pe.current.set(n,(pe.current.get(n)??0)+1),t.messages?.length&&i(t.messages),U(n,e=>({...e,queued:[]}));else if(t.type===`agent_queue_removed`){if(!t.queueId)return;ae.current.add(t.queueId),oe.current.add(t.queueId),U(n,e=>({...e,queued:e.queued.filter(e=>e.queueId!==t.queueId)}))}else if(t.type===`agent_queue_edited`)U(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,deliveryMode:t.deliveryMode??e.deliveryMode}:e)}));else if(t.type===`agent_pr_decision`&&(be(n),r)){let t=ro(e);if(t){ge.current++;let e=eM(b.current,n,t);b.current=e,v(e=>{let r=eM(e,n,t);return b.current=r,r})}}}),()=>n(`agent-chat`)):void 0,[t,n,U,be]);let Ne=(0,Q.useCallback)(async(e,t)=>{let n=++_e.current,r=fe.current.get(e)??0;ge.current++;let{conversation:i,messages:a,pendingMessages:o,live:s}=await Ha(e);if(t?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);if(n!==_e.current){if(t)throw new DOMException(`The mission changed during restoration`,`AbortError`);return}ge.current++;let c=oM(a,me.current.get(e)??[]).map(le);for(let e of c)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&de.current.add(e.id);g(i),b.current=c,v(c),xe(e),r===(fe.current.get(e)??0)&&(o!==void 0||s)&&U(e,t=>({...t,...s?{isStreaming:s.isStreaming,streamingText:s.streamingText}:{},queued:o?.filter(e=>!ae.current.has(e.queueId)).map(t=>ue(e,t))??t.queued}))},[xe,U]),Pe=(0,Q.useCallback)(async()=>{let e=re.current;if(!e)return;let t=ge.current,n=fe.current.get(e)??0,r=y.current.get(e)??0;try{let i=await Ha(e);if(re.current!==e||ge.current!==t)return;if(r===(y.current.get(e)??0)&&(g(t=>t?.id===e?i.conversation:t),m(t=>t.map(t=>t.id===e?i.conversation:t))),(i.pendingMessages!==void 0||i.live)&&n===(fe.current.get(e)??0)){let t=oM(i.messages,me.current.get(e)??[]).map(le);for(let e of t)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&de.current.add(e.id);v(e=>oM(t,e.filter(e=>e.id.startsWith(`local-u-`)&&!t.some(t=>t.role===`user`&&t.content===e.content)))),U(e,t=>({...t,...i.live?{isStreaming:i.live.isStreaming,streamingText:i.live.streamingText}:{},queued:i.pendingMessages?.filter(e=>!ae.current.has(e.queueId)).map(t=>ue(e,t))??t.queued}))}let a=i.messages.filter(e=>e.role===`system`).map(e=>io(e.content)).filter(e=>e!==null);if(a.length===0)return;v(t=>{let n=a.reduce((t,n)=>eM(t,e,n),t);return b.current=n,n})}catch{}},[U]),Fe=(0,Q.useCallback)(async()=>{try{let e=new Map(fe.current),t=await Ba(),n=new Set(t.turns.map(e=>e.conversationId)),r=Date.parse(t.capturedAt),i=[...ie.current].flatMap(([t,i])=>{if(!i.isStreaming||n.has(t)||(e.get(t)??0)!==(fe.current.get(t)??0))return[];let a=ve.current.get(t);return a&&Date.parse(a)>r?[]:[t]});E(i=>{let a=new Map(i);for(let[t,o]of i){if(!o.isStreaming||n.has(t)||(e.get(t)??0)!==(fe.current.get(t)??0))continue;let i=ve.current.get(t);i&&Date.parse(i)>r||a.set(t,{...Lj,queued:o.queued,turnTools:o.liveTools.length?o.liveTools:o.turnTools})}for(let n of t.turns){let t=n.conversationId;if((e.get(t)??0)!==(fe.current.get(t)??0))continue;let r=a.get(t)??Lj;a.set(t,{...r,isStreaming:!0,streamingText:n.streamingText??r.streamingText,queued:n.pendingMessages?.filter(e=>!ae.current.has(e.queueId)).map(e=>ue(t,e))??r.queued})}return a});for(let e of i)ve.current.delete(e);let a=re.current;if(a&&i.includes(a)){let e=`interrupted-${a}-${t.snapshotVersion}`;v(n=>n.some(t=>t.id===e)?n:[...n,{id:e,conversation_id:a,role:`assistant`,content:`⚠️ The agent turn was interrupted when the Specrails server reconnected. It was not retried.`,created_at:t.capturedAt}])}console.info(`[agent-chat] reconciled active turns`,{snapshotVersion:t.snapshotVersion,active:n.size,interrupted:i.length})}catch{}},[]);(0,Q.useEffect)(()=>{let e=()=>{Oe(),Pe()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Pe,Oe]),(0,Q.useEffect)(()=>{je&&(Oe(),Pe())},[je,Oe,Pe]);let Ie=(0,Q.useRef)(r);(0,Q.useEffect)(()=>{let e=Ie.current;Ie.current=r,r===`connected`&&e!==`connected`&&(Oe(),ke(),Ae(),Pe(),Fe())},[r,Oe,ke,Ae,Pe,Fe]);let Le=(0,Q.useCallback)(async()=>{if(h)return h;if(l)throw Error(`This window is reserved for its mission.`);let e=await Ra();if(m(e),S(t=>{let n=Vj(zj(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(Bj(n),n)}),e.length>0)return await Ne(e[0].id),e[0];let t=await Va({});return m(e=>[t,...e]),g(t),v([]),t},[h,Ne]),Re=(0,Q.useCallback)(()=>{f(`open`),Oe(),ke(),Ae(),Le()},[Oe,ke,Ae,Le]),ze=(0,Q.useCallback)(()=>f(`hidden`),[]),Be=(0,Q.useCallback)(()=>f(`minimized`),[]),[G,Ve]=(0,Q.useState)(!1),He=(0,Q.useRef)(null),Ue=(0,Q.useCallback)(()=>{He.current?.abortAndReset(),Ve(!1)},[]),We=QA(G,{onFinished:Ue});He.current=We;let Ge=(0,Q.useCallback)(()=>{l||(Ve(!0),i!==`agent`&&Re())},[i,Re]),Ke=(0,Q.useCallback)(()=>{f(e=>e===`open`?`minimized`:`open`),d!==`open`&&(Oe(),ke(),Ae(),Le())},[d,Oe,ke,Ae,Le]),Je=(0,Q.useCallback)(async()=>{if(!u(h?.id))throw Error(`This mission is active in another window.`);if(h)return h;if(he.current)return he.current;let e=Va({pinnedProjectId:I.current,provider:ne.current.provider,model:ne.current.model,tierLevel:ne.current.tierLevel,reasoningEffort:ne.current.effort}).then(e=>(Zr(e.id),m(t=>[e,...t]),g(e),v([]),e)).finally(()=>{he.current=null});return he.current=e,e},[h]),Ye=(0,Q.useCallback)(async(e,t)=>{if(!u(h?.id))return{accepted:!1};let n=e.trim();if(!n)return{accepted:!1};let r=h??await Je();fe.current.set(r.id,(fe.current.get(r.id)??0)+1);let i=fe.current.get(r.id),a=pe.current.get(r.id)??0,o=t?.queueId??`q-${Date.now()}-${rM++}`,s=new Date().toISOString();ve.current.set(r.id,s),m(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:s},...e.filter(e=>e.id!==r.id)]),g(e=>e&&e.id===r.id?{...e,updated_at:s}:e);let c={id:`local-u-${Date.now()}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],delivery_receipt:`sent`,created_at:s},l=ie.current.get(r.id)?.isStreaming===!0,d={queueId:o,text:n,contextRefs:t?.contextRefs,attachmentIds:t?.attachmentIds,deliveryMode:`queue`,deliveryReceipt:`sent`,timestamp:s};l?U(r.id,e=>({...e,queued:e.queued.some(e=>e.queueId===o)?e.queued.map(e=>e.queueId===o?{...d,deliveryReceipt:aM(e.deliveryReceipt,d.deliveryReceipt),deliveryMode:e.deliveryMode??d.deliveryMode,timestamp:e.timestamp??d.timestamp}:e):[...e.queued,d]})):(v(e=>[...e,c]),U(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let f=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,s=await Ga(r.id,n,{tierLevel:r.tier_level,attachments:f,queueId:o,contextRefs:e});if(s.removed){ae.current.add(o),oe.current.add(o);let e=!l&&i===fe.current.get(r.id);return re.current===r.id&&v(e=>e.filter(e=>e.id!==c.id)),U(r.id,t=>({...t,queued:t.queued.filter(e=>e.queueId!==o),...e?{isStreaming:!1}:{}})),e&&ve.current.delete(r.id),{accepted:!0,conversationId:r.id}}if(s.message){ce.current.set(`${r.id}:q:${o}`,s.message.id);let e=aM(s.message.delivery_receipt,se.current.get(`${r.id}:q:${o}`)),t=le({...s.message,...e?{delivery_receipt:e}:{}});return ae.current.add(o),me.current.set(r.id,oM(me.current.get(r.id)??[],[t]).slice(-500)),re.current===r.id&&v(e=>oM(e.filter(e=>e.id!==c.id),[t])),U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})),s.duplicate&&Fe(),{accepted:!0,conversationId:r.id}}if(a!==(pe.current.get(r.id)??0))return v(e=>e.filter(e=>e.id!==c.id)),{accepted:!0,conversationId:r.id};let u=s?.queued===!0;return u&&!l?(v(e=>e.filter(e=>e.id!==c.id)),ae.current.has(o)||U(r.id,e=>e.queued.some(e=>e.queueId===o)?e:{...e,queued:[...e.queued,{...d,deliveryMode:s.deliveryMode??d.deliveryMode}]})):!u&&l&&!ae.current.has(o)&&(U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o),isStreaming:!0})),v(e=>[...e,c])),{accepted:!0,conversationId:r.id}}catch(e){return ae.current.has(o)||a!==(pe.current.get(r.id)??0)?{accepted:!0,conversationId:r.id}:(ve.current.delete(r.id),l?U(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})):(U(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),v(e=>e.filter(e=>e.id!==c.id))),J.error(e instanceof Error?e.message:`Failed to send message.`),{accepted:!1,conversationId:r.id})}},[h,Je,U,Fe]),Xe=(0,Q.useCallback)(async()=>{if(!(!h||!u(h.id)))try{await Za(h.id),pe.current.set(h.id,(pe.current.get(h.id)??0)+1),fe.current.set(h.id,(fe.current.get(h.id)??0)+1),U(h.id,()=>null)}catch(e){J.error(e instanceof Error?e.message:`Failed to stop the agent.`)}},[h,U]),Ze=(0,Q.useCallback)(async(e,t)=>{let n=h;if(!n||!u(n.id)||ie.current.get(n.id)?.queued.find(t=>t.queueId===e)?.deliveryMode===`steer`)return`conflict`;let r=await Qa(n.id,e,t);return r===`saved`&&U(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[h,U]),Qe=(0,Q.useCallback)(async e=>{let t=h,n=t&&ie.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!u(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await $a(t.id,e);return r===`saved`?(fe.current.set(t.id,(fe.current.get(t.id)??0)+1),U(t.id,t=>({...t,queued:t.queued.map(t=>t.queueId===e?{...t,deliveryMode:`steer`}:t)}))):re.current===t.id&&Pe(),r},[h,U,Pe]),$e=(0,Q.useCallback)(async e=>{let t=h,n=t&&ie.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!u(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await eo(t.id,e);return r===`saved`?(ae.current.add(e),oe.current.add(e),fe.current.set(t.id,(fe.current.get(t.id)??0)+1),U(t.id,t=>({...t,queued:t.queued.filter(t=>t.queueId!==e)}))):re.current===t.id&&Pe(),r},[h,U,Pe]),et=(0,Q.useCallback)(e=>ae.current.has(e)&&!oe.current.has(e),[]),tt=(0,Q.useCallback)(async e=>{if(!h||!u(h.id))return;let t=(y.current.get(h.id)??0)+1;y.current.set(h.id,t);let n=await Ua(h.id,e);y.current.get(h.id)===t&&(g(e=>e?.id===n.id?n:e),m(e=>e.map(e=>e.id===n.id?n:e)))},[h]),K=(0,Q.useCallback)(async e=>{u(h?.id)&&(Wj(e),h?await tt({tierLevel:e}):V(e))},[h,tt]),q=(0,Q.useCallback)(async()=>{let e=((h?.tier_level??ee)+1)%4;await K(e)},[h,ee,K]),nt=(0,Q.useCallback)(async e=>{h?await tt({provider:e}):(R(e),B(null),te(null))},[h,tt]),rt=(0,Q.useCallback)(async e=>{h?await tt({model:e}):(B(e),te(null))},[h,tt]),it=(0,Q.useCallback)(async e=>{h?await tt({reasoningEffort:e}):te(e)},[h,tt]),ot=(0,Q.useCallback)(async e=>{l||!u(h?.id)||(h?await tt({pinnedProjectId:e}):F(e),!h&&e&&i===`agent`&&a(e))},[h,tt,i,a]),Y=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let e=Y.current;if(Y.current=o,!(e===void 0||e===o)&&!(l||i!==`agent`||!o)){if(!h){F(o);return}b.current.length>0||h.pinned_project_id!==o&&tt({pinnedProjectId:o})}},[o,i,h,tt]);let st=(0,Q.useCallback)(e=>{l||(Ue(),g(null),v([]),F(e??null),R(`claude`),B(null),V(Uj()),te(null))},[Ue]),ct=(0,Q.useCallback)(async e=>{if(l)return;Ue();let t=await Va({pinnedProjectId:e===void 0?h?.pinned_project_id??null:e,tierLevel:Uj()});m(e=>[t,...e]),g(t),v([])},[h,Ue]),lt=(0,Q.useCallback)(async(e,t)=>{if(!(l&&!t?.windowRestore&&c.current.current?.conversationId!==e)&&!(!l&&!t?.windowRestore&&await c.current.focus(e))){if(t?.signal?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);Ue(),await Ne(e,t?.signal),t?.windowRestore&&i!==`agent`&&f(`open`)}},[Ne,Ue,l,i]),ut=(0,Q.useCallback)(async e=>{u(e)&&(await Wa(e),await c.current.discard(e),m(t=>t.filter(t=>t.id!==e)),S(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),Bj(n),n}),U(e,()=>null),re.current===e&&(g(null),v([])))},[U]),dt=(0,Q.useCallback)(async(e,t)=>{if(!u(e))return;let n=t.trim()||null;y.current.set(e,(y.current.get(e)??0)+1);let r;m(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),g(t=>t&&t.id===e?{...t,title:n}:t);try{await Ua(e,{title:n})}catch(t){throw m(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),g(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),ft=(0,Q.useCallback)(e=>{S(()=>{let t=new Set(zj());return t.has(e)?t.delete(e):t.add(e),Bj(t),t})},[]),pt=(0,Q.useCallback)(async()=>{A(!0);try{await fo(),await ke()}catch(e){J.error(e instanceof Error?e.message:`Failed to enable MCP.`)}finally{A(!1)}},[ke]),mt=(0,Q.useMemo)(()=>({visibility:d,open:Re,close:ze,minimize:Be,toggle:Ke,conversations:p,active:h,messages:_,streamingText:Ce,isStreaming:W,liveTools:we,turnTools:Te,queuedMessages:Ee,streamingConversationIds:De,liveByConversation:T,unreadConversationIds:C,favoriteConversationIds:x,mcpEnabled:D,enablingMcp:k,enableMcpServer:pt,providersReady:j,send:Ye,abort:Xe,editQueuedMessage:Ze,steerQueuedMessage:Qe,removeQueuedMessage:$e,wasQueueConsumed:et,cycleTier:q,setTier:K,setProvider:nt,setModel:rt,setPinnedProject:ot,newConversation:ct,startNewConversation:st,materializeDraftConversation:Je,draftPinnedProjectId:N,draftProvider:L,draftModel:z,draftTierLevel:ee,draftEffort:H,setEffort:it,selectConversation:lt,deleteConversation:ut,renameConversation:dt,toggleFavoriteConversation:ft,refreshConversations:Oe,applyPrDecisionSnapshot:ye,builderMode:{active:G,enter:Ge,exit:Ue,session:We}}),[d,Re,ze,Be,Ke,G,Ge,Ue,We,p,h,_,Ce,W,we,Te,Ee,De,T,C,x,D,k,pt,j,Ye,Xe,Ze,Qe,$e,et,q,K,nt,rt,ot,ct,st,Je,N,L,z,ee,H,it,lt,ut,dt,ft,Oe,ye]),ht=P&&i!==`agent`;return(0,$.jsxs)(tM.Provider,{value:mt,children:[e,ht&&d===`open`&&(0,$.jsx)(Sj,{}),ht&&d!==`open`&&(0,$.jsx)(kj,{})]})}var cM={visibility:`hidden`,open:()=>{},close:()=>{},minimize:()=>{},toggle:()=>{},conversations:[],active:null,messages:[],streamingText:``,isStreaming:!1,liveTools:[],turnTools:[],queuedMessages:[],streamingConversationIds:new Set,unreadConversationIds:new Set,liveByConversation:new Map,favoriteConversationIds:new Set,mcpEnabled:!0,enablingMcp:!1,enableMcpServer:async()=>{},providersReady:!0,send:async()=>({accepted:!1}),abort:async()=>{},editQueuedMessage:async()=>`conflict`,steerQueuedMessage:async()=>`conflict`,removeQueuedMessage: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,launched:!1,submitting:!1,conversationReady:!1,conversationId:null,dirty:!1,canProposeCommit:!1,specQualityDetail:null,readiness:{ready:!1,steps:[],issues:[]},snapshot:{status:`idle`},generation:{generating:!1,specsStarted:0},recent:[],recentLoading:!1,resume:async()=>{},discardRecent:async()=>{},repairSnapshot:async()=>{},showSurpriseMe:!0,provider:`claude`,model:null,models:[],efforts:[],effort:`medium`,draft:``,setDraft:()=>{},setEffort:()=>{},setProvider:()=>{},setModel:()=>{},send:()=>{},surpriseMe:()=>{},approveBlueprint:()=>{},goToCommit:()=>{},backToChat:()=>{},submitCommit:()=>{},launchM1:async()=>{},openProject:()=>{},abortAndReset:()=>{}}}};function lM(){return(0,Q.useContext)(tM)??cM}var uM=new Map;function dM(){let e=lM(),t=Ux(),n=at(),r=Ca(),{registerHandlers:i}=si(),{t:a}=K(`agent`),o=(0,Q.useRef)({chat:e,workspace:t,desktop:n,terminals:r,t:a});o.current={chat:e,workspace:t,desktop:n,terminals:r,t:a};let s=(0,Q.useRef)(null),c=(0,Q.useRef)(!1);(0,Q.useLayoutEffect)(()=>{let n=e.active?.id??`__new-mission__`,r=s.current;if(c.current||r===n)return;s.current=n,r&&uM.set(r,t.captureWorkspace());let i=uM.get(n);i?t.restoreWorkspace(i):r&&t.restoreWorkspace({...t.captureWorkspace(),browserOpen:!1,browserOwnerId:null,browserUrl:null,pendingCaptures:[]})},[e.active?.id]);let[l,u]=(0,Q.useState)(null);return(0,Q.useLayoutEffect)(()=>{l&&!l.signal.aborted&&e.active?.id===l.target.conversationId&&n.activeProjectId===l.target.projectId&&(l.resolve(),u(e=>e===l?null:e))},[l,e.active?.id,n.activeProjectId]),(0,Q.useEffect)(()=>i({recover(e,t){Sy(t.conversationId,e.scroll)},capture(e){let{chat:t,workspace:n,terminals:r,t:i}=o.current;if(t.active?.id!==e.conversationId)throw Error(i(`window.wrongMission`));if(Ty(e.conversationId))throw Error(i(`window.finishPending`));return{version:1,...e,capturedAt:Date.now(),composer:Gr(e.conversationId),scroll:xy(e.conversationId),workspace:{...n.captureWorkspace(),...e.projectId?{codeSelection:my(e.projectId,e.conversationId),terminal:(({activeId:e,visibility:t,userHeight:n})=>({activeId:e,visibility:t,userHeight:n}))(r.getState(e.projectId))}:{}}}},async restore(e,t,n){let r=()=>new DOMException(`Window transfer cancelled`,`AbortError`);if(n.aborted)throw r();let i=o.current.chat.active?.id;i&&uM.set(i,o.current.workspace.captureWorkspace()),c.current=!0;try{if(await o.current.chat.selectConversation(t.conversationId,{windowRestore:!0,signal:n}),n.aborted)throw r();if(s.current=t.conversationId,uM.set(t.conversationId,e.workspace),qr(t.conversationId,e.composer),t.projectId&&(e.workspace.codeSelection&&hy(t.projectId,t.conversationId,e.workspace.codeSelection),e.workspace.terminal)){let n=e.workspace.terminal,r=o.current.terminals;r.ensureProject(t.projectId),r.setVisibility(t.projectId,n.visibility),r.setUserHeight(t.projectId,n.userHeight),n.activeId&&r.setActive(t.projectId,n.activeId)}o.current.workspace.restoreWorkspace(e.workspace),o.current.desktop.setActiveProjectId(t.projectId),Sy(t.conversationId,e.scroll),await new Promise((e,i)=>{let a=()=>{u(e=>e?.signal===n?null:e),i(r())};n.addEventListener(`abort`,a,{once:!0}),u({target:t,signal:n,resolve:()=>{n.removeEventListener(`abort`,a),e()}})})}finally{c.current=!1}}}),[i]),null}var fM=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new pM(this.width*e,this.height*e)}[ct](){return{width:this.width,height:this.height}}toJSON(){return this[ct]()}},pM=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new fM(this.width/e,this.height/e)}[ct](){return{width:this.width,height:this.height}}toJSON(){return this[ct]()}},mM=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof fM?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof pM?this.size:this.size.toPhysical(e)}[ct](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[ct]()}},hM=class{constructor(...e){this.type=`Logical`,e.length===1?`Logical`in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new gM(this.x*e,this.y*e)}[ct](){return{x:this.x,y:this.y}}toJSON(){return this[ct]()}},gM=class{constructor(...e){this.type=`Physical`,e.length===1?`Physical`in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new hM(this.x/e,this.y/e)}[ct](){return{x:this.x,y:this.y}}toJSON(){return this[ct]()}},_M=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof hM?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof gM?this.position:this.position.toPhysical(e)}[ct](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[ct]()}},vM;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(vM||={});var yM=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},bM;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(bM||={});function xM(){return new wM(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function SM(){return Y(`plugin:window|get_all_windows`).then(e=>e.map(e=>new wM(e,{skip:!0})))}var CM=[`tauri://created`,`tauri://error`],wM=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t?.skip||Y(`plugin:window|create`,{options:{...t,parent:typeof t.parent==`string`?t.parent:t.parent?.label,label:e}}).then(async()=>this.emit(`tauri://created`)).catch(async e=>this.emit(`tauri://error`,e))}static async getByLabel(e){return(await SM()).find(t=>t.label===e)??null}static getCurrent(){return xM()}static async getAll(){return SM()}static async getFocusedWindow(){for(let e of await SM())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:mr(e,t,{target:{kind:`Window`,label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:gr(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(CM.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return hr(e,t)}async emitTo(e,t,n){if(CM.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return _r(e,t,n)}_handleTauriEvent(e,t){return CM.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return Y(`plugin:window|scale_factor`,{label:this.label})}async innerPosition(){return Y(`plugin:window|inner_position`,{label:this.label}).then(e=>new gM(e))}async outerPosition(){return Y(`plugin:window|outer_position`,{label:this.label}).then(e=>new gM(e))}async innerSize(){return Y(`plugin:window|inner_size`,{label:this.label}).then(e=>new pM(e))}async outerSize(){return Y(`plugin:window|outer_size`,{label:this.label}).then(e=>new pM(e))}async isFullscreen(){return Y(`plugin:window|is_fullscreen`,{label:this.label})}async isMinimized(){return Y(`plugin:window|is_minimized`,{label:this.label})}async isMaximized(){return Y(`plugin:window|is_maximized`,{label:this.label})}async isFocused(){return Y(`plugin:window|is_focused`,{label:this.label})}async isDecorated(){return Y(`plugin:window|is_decorated`,{label:this.label})}async isResizable(){return Y(`plugin:window|is_resizable`,{label:this.label})}async isMaximizable(){return Y(`plugin:window|is_maximizable`,{label:this.label})}async isMinimizable(){return Y(`plugin:window|is_minimizable`,{label:this.label})}async isClosable(){return Y(`plugin:window|is_closable`,{label:this.label})}async isVisible(){return Y(`plugin:window|is_visible`,{label:this.label})}async title(){return Y(`plugin:window|title`,{label:this.label})}async theme(){return Y(`plugin:window|theme`,{label:this.label})}async isAlwaysOnTop(){return Y(`plugin:window|is_always_on_top`,{label:this.label})}async center(){return Y(`plugin:window|center`,{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===vM.Critical?{type:`Critical`}:{type:`Informational`}),Y(`plugin:window|request_user_attention`,{label:this.label,value:t})}async setResizable(e){return Y(`plugin:window|set_resizable`,{label:this.label,value:e})}async setEnabled(e){return Y(`plugin:window|set_enabled`,{label:this.label,value:e})}async isEnabled(){return Y(`plugin:window|is_enabled`,{label:this.label})}async setMaximizable(e){return Y(`plugin:window|set_maximizable`,{label:this.label,value:e})}async setMinimizable(e){return Y(`plugin:window|set_minimizable`,{label:this.label,value:e})}async setClosable(e){return Y(`plugin:window|set_closable`,{label:this.label,value:e})}async setTitle(e){return Y(`plugin:window|set_title`,{label:this.label,value:e})}async maximize(){return Y(`plugin:window|maximize`,{label:this.label})}async unmaximize(){return Y(`plugin:window|unmaximize`,{label:this.label})}async toggleMaximize(){return Y(`plugin:window|toggle_maximize`,{label:this.label})}async minimize(){return Y(`plugin:window|minimize`,{label:this.label})}async unminimize(){return Y(`plugin:window|unminimize`,{label:this.label})}async show(){return Y(`plugin:window|show`,{label:this.label})}async hide(){return Y(`plugin:window|hide`,{label:this.label})}async close(){return Y(`plugin:window|close`,{label:this.label})}async destroy(){return Y(`plugin:window|destroy`,{label:this.label})}async setDecorations(e){return Y(`plugin:window|set_decorations`,{label:this.label,value:e})}async setShadow(e){return Y(`plugin:window|set_shadow`,{label:this.label,value:e})}async setEffects(e){return Y(`plugin:window|set_effects`,{label:this.label,value:e})}async clearEffects(){return Y(`plugin:window|set_effects`,{label:this.label,value:null})}async setAlwaysOnTop(e){return Y(`plugin:window|set_always_on_top`,{label:this.label,value:e})}async setAlwaysOnBottom(e){return Y(`plugin:window|set_always_on_bottom`,{label:this.label,value:e})}async setContentProtected(e){return Y(`plugin:window|set_content_protected`,{label:this.label,value:e})}async setSize(e){return Y(`plugin:window|set_size`,{label:this.label,value:e instanceof mM?e:new mM(e)})}async setMinSize(e){return Y(`plugin:window|set_min_size`,{label:this.label,value:e instanceof mM?e:e?new mM(e):null})}async setMaxSize(e){return Y(`plugin:window|set_max_size`,{label:this.label,value:e instanceof mM?e:e?new mM(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return Y(`plugin:window|set_size_constraints`,{label:this.label,value:{minWidth:t(e?.minWidth),minHeight:t(e?.minHeight),maxWidth:t(e?.maxWidth),maxHeight:t(e?.maxHeight)}})}async setPosition(e){return Y(`plugin:window|set_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setFullscreen(e){return Y(`plugin:window|set_fullscreen`,{label:this.label,value:e})}async setSimpleFullscreen(e){return Y(`plugin:window|set_simple_fullscreen`,{label:this.label,value:e})}async setFocus(){return Y(`plugin:window|set_focus`,{label:this.label})}async setFocusable(e){return Y(`plugin:window|set_focusable`,{label:this.label,value:e})}async setIcon(e){return Y(`plugin:window|set_icon`,{label:this.label,value:ua(e)})}async setSkipTaskbar(e){return Y(`plugin:window|set_skip_taskbar`,{label:this.label,value:e})}async setCursorGrab(e){return Y(`plugin:window|set_cursor_grab`,{label:this.label,value:e})}async setCursorVisible(e){return Y(`plugin:window|set_cursor_visible`,{label:this.label,value:e})}async setCursorIcon(e){return Y(`plugin:window|set_cursor_icon`,{label:this.label,value:e})}async setBackgroundColor(e){return Y(`plugin:window|set_background_color`,{color:e})}async setCursorPosition(e){return Y(`plugin:window|set_cursor_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setIgnoreCursorEvents(e){return Y(`plugin:window|set_ignore_cursor_events`,{label:this.label,value:e})}async startDragging(){return Y(`plugin:window|start_dragging`,{label:this.label})}async startResizeDragging(e){return Y(`plugin:window|start_resize_dragging`,{label:this.label,value:e})}async setBadgeCount(e){return Y(`plugin:window|set_badge_count`,{label:this.label,value:e})}async setBadgeLabel(e){return Y(`plugin:window|set_badge_label`,{label:this.label,value:e})}async setOverlayIcon(e){return Y(`plugin:window|set_overlay_icon`,{label:this.label,value:e?ua(e):void 0})}async setProgressBar(e){return Y(`plugin:window|set_progress_bar`,{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return Y(`plugin:window|set_visible_on_all_workspaces`,{label:this.label,value:e})}async setTitleBarStyle(e){return Y(`plugin:window|set_title_bar_style`,{label:this.label,value:e})}async setTheme(e){return Y(`plugin:window|set_theme`,{label:this.label,value:e})}async onResized(e){return this.listen(vr.WINDOW_RESIZED,t=>{t.payload=new pM(t.payload),e(t)})}async onMoved(e){return this.listen(vr.WINDOW_MOVED,t=>{t.payload=new gM(t.payload),e(t)})}async onCloseRequested(e){return this.listen(vr.WINDOW_CLOSE_REQUESTED,async t=>{let n=new yM(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(vr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),n=await this.listen(vr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new gM(t.payload.position)}})}),r=await this.listen(vr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),i=await this.listen(vr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(vr.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(vr.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(vr.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(vr.WINDOW_THEME_CHANGED,e)}},TM;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(TM||={});var EM;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(EM||={});var DM;(function(e){e.AppearanceBased=`appearanceBased`,e.Light=`light`,e.Dark=`dark`,e.MediumLight=`mediumLight`,e.UltraDark=`ultraDark`,e.Titlebar=`titlebar`,e.Selection=`selection`,e.Menu=`menu`,e.Popover=`popover`,e.Sidebar=`sidebar`,e.HeaderView=`headerView`,e.Sheet=`sheet`,e.WindowBackground=`windowBackground`,e.HudWindow=`hudWindow`,e.FullScreenUI=`fullScreenUI`,e.Tooltip=`tooltip`,e.ContentBackground=`contentBackground`,e.UnderWindowBackground=`underWindowBackground`,e.UnderPageBackground=`underPageBackground`,e.Mica=`mica`,e.Blur=`blur`,e.Acrylic=`acrylic`,e.Tabbed=`tabbed`,e.TabbedDark=`tabbedDark`,e.TabbedLight=`tabbedLight`})(DM||={});var OM;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(OM||={});var kM=12e-5,AM=36,jM=140,MM=1.5,NM=6;function PM(e,t){return{x:Math.random()*e,y:Math.random()*t,radius:.35+Math.random()*1.25,alpha:.22+Math.random()*.5,drift:MM+Math.random()*(NM-MM)}}function FM(e){let t=e.getBoundingClientRect(),n=t.width||e.parentElement?.clientWidth||window.innerWidth,r=t.height||e.parentElement?.clientHeight||window.innerHeight;return{width:Math.max(1,Math.floor(n)),height:Math.max(1,Math.floor(r))}}function IM(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=0,s=0,c=0,l=0,u=0,d=!document.hidden;function f(){let e=FM(r),t=window.devicePixelRatio||1;if(e.width===o&&e.height===s&&t===c)return;let n=e.width!==o||e.height!==s;if(o=e.width,s=e.height,c=t,r.width=Math.max(1,Math.round(o*t)),r.height=Math.max(1,Math.round(s*t)),r.style.width=`100%`,r.style.height=`100%`,i.setTransform(t,0,0,t,0,0),n||a.length===0){let e=Math.min(jM,Math.max(AM,Math.floor(o*s*kM)));a=Array.from({length:e},()=>PM(o,s))}}function p(e){i.clearRect(0,0,o,s);for(let t of a)t.x+=t.drift*e,t.x>o+t.radius&&(t.x=-t.radius,t.y=Math.random()*s),i.globalAlpha=t.alpha,i.fillStyle=`hsl(213 100% 92%)`,i.beginPath(),i.arc(t.x,t.y,t.radius,0,Math.PI*2),i.fill();i.globalAlpha=1}function m(e){if(!d)return;let t=u===0?.016:Math.min(.05,(e-u)/1e3);u=e,p(t),l=requestAnimationFrame(m)}function h(){d=!document.hidden,d?(u=0,l=requestAnimationFrame(m)):cancelAnimationFrame(l)}let g=null;function _(){g&&g.removeEventListener(`change`,_),f(),v()}function v(){let e=window.devicePixelRatio||1;g=window.matchMedia(`(resolution: ${e}dppx)`),g.addEventListener(`change`,_)}f();let y=null,b=r.parentElement;return typeof ResizeObserver<`u`&&b&&(y=new ResizeObserver(()=>f()),y.observe(b)),window.addEventListener(`resize`,f),v(),document.addEventListener(`visibilitychange`,h),d&&(l=requestAnimationFrame(m)),()=>{cancelAnimationFrame(l),y&&y.disconnect(),g&&g.removeEventListener(`change`,_),window.removeEventListener(`resize`,f),document.removeEventListener(`visibilitychange`,h)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`absolute inset-0 pointer-events-none`,style:{zIndex:-1}})}var LM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeCodePane-DK-q3K6Y.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([79,1,7,10,42,49]))),RM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeJobsPane-C7ELTPC1.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([80,1,7,12,10,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,44,8,54,49,64,65,67,68,76,6,9,11,43,45,46,47,48,50,51,52,53,55,56,57,58,59,60,61,62,63,66,69,70,71,72,73,74,75,81]))),zM=(0,Q.lazy)(()=>c(()=>import(`./AgentModeAnalyticsPane-BC_xbT_l.js`).then(e=>({default:e.AgentModeAnalyticsPane})),__vite__mapDeps([82,1,7,10,42,54,49,64,65])));function BM(){let{t:e}=K(`agent`),{active:t,refreshConversations:n,builderMode:r}=lM(),{codePaneOpen:i,jobsPaneOpen:a,analyticsPaneOpen:o}=Ux(),{activeProjectId:s}=at(),c=si(),l=Cy(t?.id??`__new-mission__`),u=!c.current&&c.transfers.some(e=>e.conversationId===t?.id&&e.state===`detached`),d=ca(),f=d.id===`galaxy`,p=d.id===`code-rain`?e(`emptyTitleCodeRain`):e(`emptyTitle`);(0,Q.useEffect)(()=>{n()},[n]);let m=i&&!!s&&!u,h=a&&!!s&&!u,g=o&&!!s&&!u;return(0,$.jsx)(D_,{reducedMotion:`user`,children:(0,$.jsxs)(`div`,{"data-agent-mode-surface":!0,className:`relative z-0 flex h-full w-full overflow-hidden bg-background`,children:[f&&(0,$.jsx)(IM,{}),(0,$.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(fy.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,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(pj,{variant:`inline`})}):t===null?(0,$.jsx)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-6`,children:(0,$.jsxs)(fy.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,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(So,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80`,children:p})]}),(0,$.jsx)(qO,{autoFocus:!0})]})}):(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(Kk,{variant:`inline`})})]}),h&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,$.jsx)(RM,{projectId:s})}),m&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,$.jsx)(LM,{projectId:s,conversationId:t?.id??`__home__`},`${t?.id}:${l}`)}),g&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[560px] border-l border-border`}),children:(0,$.jsx)(zM,{})})]})})}var VM=(e,t,n)=>Math.min(n,Math.max(t,e)),HM=e=>`specrails-desktop:sidebar-width:${e}`;function UM(e,t){let n=HM(e),[r,i]=(0,Q.useState)(()=>{try{let e=localStorage.getItem(n),r=e?Number.parseInt(e,10):NaN;if(Number.isFinite(r))return VM(r,t.min,t.max)}catch{}return t.defaultWidth}),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(r);c.current=r;let l=(0,Q.useRef)(!1),u=(0,Q.useRef)(t);return u.current=t,(0,Q.useLayoutEffect)(()=>{let e=s.current;!e||l.current||(e.style.width=`${t.expanded?r:t.collapsedWidth}px`)},[r,t.expanded,t.collapsedWidth]),{width:r,dragging:a,panelRef:s,onGripPointerDown:(0,Q.useCallback)(e=>{if(e.button!==0||!u.current.expanded)return;e.preventDefault();let t=s.current;if(!t)return;let r=e.clientX,a=c.current,d=a;l.current=!0,o(!0),t.style.transition=`none`;let f=document.body.style.cursor,p=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;try{e.target.setPointerCapture?.(e.pointerId)}catch{}let m=e=>{let n=u.current,i=e.clientX-r,o=n.side===`left`?i:-i;d=VM(a+o,n.min,n.max),t.style.width=`${d}px`},h=()=>{window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,h),window.removeEventListener(`pointercancel`,h),t.style.transition=``,document.body.style.cursor=f,document.body.style.userSelect=p,l.current=!1,o(!1),i(d);try{localStorage.setItem(n,String(Math.round(d)))}catch{}};window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,h),window.addEventListener(`pointercancel`,h)},[n]),onGripKeyDown:(0,Q.useCallback)(e=>{let t=u.current,r=e.shiftKey?24:8,a=t.side===`left`?`ArrowRight`:`ArrowLeft`,o=t.side===`left`?`ArrowLeft`:`ArrowRight`,s=null;if(e.key===a?s=VM(c.current+r,t.min,t.max):e.key===o?s=VM(c.current-r,t.min,t.max):e.key===`Home`&&(s=t.defaultWidth),s!==null){e.preventDefault(),i(s);try{localStorage.setItem(n,String(Math.round(s)))}catch{}}},[n])}}function WM({side:e,dragging:t,width:n,min:r,max:i,label:a,onPointerDown:o,onKeyDown:s}){return(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":a,"aria-valuenow":Math.round(n),"aria-valuemin":r,"aria-valuemax":i,tabIndex:0,"data-testid":`sidebar-resize-grip-${e}`,onPointerDown:o,onKeyDown:s,className:X(`group absolute inset-y-0 z-20 w-1.5 cursor-col-resize outline-none`,e===`left`?`-right-0.5`:`-left-0.5`),children:(0,$.jsx)(`div`,{className:X(`absolute inset-y-0 w-px transition-colors duration-150`,e===`left`?`right-0`:`left-0`,t?`bg-accent-primary`:`bg-transparent group-hover:bg-accent-primary/50 group-focus-visible:bg-accent-primary/70`)})})}var GM=[`pinned-open`,`pinned-collapsed`,`unpinned`],KM=`specrails-desktop:sidebar-mode:left`,qM=`specrails-desktop:sidebar-mode:right`;function JM(e){return typeof e==`string`&&GM.includes(e)}function YM(e){try{let t=window.localStorage.getItem(e);if(JM(t))return t}catch{}return`unpinned`}function XM(e,t){try{window.localStorage.setItem(e,t)}catch{}}function ZM(e){switch(e){case`pinned-open`:return`pinned-collapsed`;case`pinned-collapsed`:return`unpinned`;case`unpinned`:return`pinned-open`}}var QM=(0,Q.createContext)({leftMode:`unpinned`,rightMode:`unpinned`,setLeftMode:()=>{},setRightMode:()=>{},cycleLeftMode:()=>{},cycleRightMode:()=>{}});function $M({children:e}){let[t,n]=(0,Q.useState)(()=>YM(KM)),[r,i]=(0,Q.useState)(()=>YM(qM));(0,Q.useEffect)(()=>{XM(KM,t)},[t]),(0,Q.useEffect)(()=>{XM(qM,r)},[r]);let a=(0,Q.useCallback)(e=>n(e),[]),o=(0,Q.useCallback)(e=>i(e),[]),s=(0,Q.useCallback)(()=>n(e=>ZM(e)),[]),c=(0,Q.useCallback)(()=>i(e=>ZM(e)),[]),l=(0,Q.useMemo)(()=>({leftMode:t,rightMode:r,setLeftMode:a,setRightMode:o,cycleLeftMode:s,cycleRightMode:c}),[t,r,a,o,s,c]);return(0,$.jsx)(QM.Provider,{value:l,children:e})}function eN(){return(0,Q.useContext)(QM)}function tN({open:e,onClose:t,onCommitted:n,projectId:r,milestoneId:i,blueprint:a,provider:o=`claude`}){let{t:s}=K(`builder`),{registerHandler:c,unregisterHandler:l}=qe(),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)({status:`idle`}),O=(0,Q.useRef)(null),k=(0,Q.useRef)(r),A=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{O.current=u},[u]),(0,Q.useEffect)(()=>{k.current=r},[r]);let j=a.milestones.find(e=>e.id===i),M=i.toUpperCase(),N=ir(o,`read-only`),P=(0,Q.useMemo)(()=>BA(v??g,{milestoneLabel:M,minSpecs:1,maxSpecs:10,requireScaffold:!1}),[g,v,M]),F=(0,Q.useMemo)(()=>HA(g,v??g,P,{minSpecs:1,maxSpecs:10}),[g,v,P]),I=(0,Q.useMemo)(()=>Pt(m),[m]);(0,Q.useEffect)(()=>{if(!e||u||!N)return;let t=!1;return fetch(`${nt()}/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;O.current=e.conversation.id,d(e.conversation.id);let n=j?.plannedSpecs??[],r={label:M,title:j?.title??M,planned:n.join(`; `)},i=n.length>0?s(`prompts.milestoneSeedWithPlanned`,r):s(`prompts.milestoneSeed`,r);p([{role:`user`,content:i}]),C(!0),fetch(`${nt()}/chat/conversations/${e.conversation.id}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:i})}).catch(()=>{C(!1),J.error(s(`errors.turnFailed`))})}).catch(()=>{t||J.error(s(`errors.startFailed`))}),()=>{t=!0}},[e,u,i,j,M,N,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=`milestone-generate-${i}`;return c(t,e=>{let t=e;if(t.conversationId===O.current&&!(t.projectId&&t.projectId!==k.current))if(t.type===`chat_stream`)h(e=>(e??``)+String(t.delta??``));else if(t.type===`chat_done`){h(null),C(!1);let e=String(t.fullText??``),n=Lt(e),r=n.stripped.trim()||(n.hadBlocks?``:e);if(r&&p(e=>[...e,{role:`assistant`,content:r}]),n.blueprint)_(n.blueprint),y(n.rawBlueprint),D({status:`accepted`,repaired:n.repaired,repairAttempted:!1,at:new Date().toISOString()});else if(n.rejected.length>0){let e=n.rejected[n.rejected.length-1];D({status:`rejected`,reason:e.reason,detail:e.detail,repairAttempted:!1,at:new Date().toISOString()})}}else t.type===`chat_error`&&(h(null),C(!1),J.error(s(`errors.turnFailed`),{description:String(t.error??``)}))}),()=>l(t)},[e,i,c,l,s]),(0,Q.useEffect)(()=>{A.current?.scrollTo?.({top:A.current.scrollHeight})},[f,m]);let L=(0,Q.useCallback)(e=>{let t=O.current,n=e.trim();!t||!n||S||(p(e=>[...e,{role:`user`,content:n}]),x(``),C(!0),fetch(`${nt()}/chat/conversations/${t}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n})}).catch(()=>{C(!1),J.error(s(`errors.turnFailed`))}))},[S,s]),R=(0,Q.useCallback)(()=>{let e=E.status===`rejected`?s(`snapshot.rejected.${E.reason}`):s(`readiness.issuesCount`,{count:F.issues.length});L(s(`prompts.repairSnapshot`,{reason:e}))},[E,F.issues.length,L,s]),z=(0,Q.useCallback)(()=>{let e=v??g,r=e&&typeof e==`object`&&!Array.isArray(e)?e:null,a=Array.isArray(r?.m1Specs)?r.m1Specs:[];!P.valid||w||(T(!0),fetch(`${nt()}/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();J.success(s(`milestone.commitToast`,{count:r.insertedIds.length,label:M})),n?.(),t()}else{let t=await e.json().catch(()=>({}));J.error(s(`milestone.commitFailed`),{description:t.detail??t.error})}}).catch(()=>J.error(s(`milestone.commitFailed`))).finally(()=>T(!1)))},[g,v,P.valid,w,i,M,t,n,s]);if(!e)return null;let B=g?.m1Specs.length??0;return N?(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-sm`,"data-testid":`milestone-shell`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/40 px-4 py-2.5`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:s(`milestone.title`,{label:M})}),j&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:j.title}),(0,$.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":s(`shell.close`),"data-testid":`milestone-close`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col border-r border-border/40`,children:[(0,$.jsxs)(`div`,{ref:A,className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[f.map((e,t)=>(0,$.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)),m!==null&&(0,$.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-lg bg-surface/70 px-3 py-2 text-xs leading-relaxed`,children:[St(m),(0,$.jsx)(`span`,{className:`ml-0.5 inline-block h-3 w-1.5 animate-pulse bg-accent-primary/70 align-middle`})]}),I.generating&&(0,$.jsx)(mA,{specsStarted:I.specsStarted,snapshot:E})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-border/40 p-3`,children:[(0,$.jsx)(`textarea`,{value:b,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),L(b))},rows:2,placeholder:s(`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,$.jsx)(Z,{size:`sm`,onClick:()=>L(b),disabled:S||!b.trim()||!u,children:S?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(tc,{className:`h-3.5 w-3.5`})})]})]}),(0,$.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col lg:w-96`,children:[(0,$.jsx)(vj,{blueprint:g,milestoneLabel:M,snapshot:E}),(0,$.jsx)(xj,{readiness:F,snapshot:E,busy:S||w,primaryLabel:w?s(`commit.creating`):s(`milestone.commit`,{count:B,label:M}),onPrimary:z,onRepair:R,primaryTestId:`milestone-commit`})]})]})]}):(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-sm`,"data-testid":`milestone-shell`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/40 px-4 py-2.5`,children:[(0,$.jsx)(ps,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:s(`milestone.title`,{label:M})}),(0,$.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":s(`shell.close`),"data-testid":`milestone-close`,children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]}),(0,$.jsx)(`p`,{className:`m-4 rounded-md border border-accent-warning/30 bg-accent-warning/10 p-3 text-sm text-accent-warning`,"data-testid":`milestone-provider-unavailable`,children:s(`milestone.providerUnavailable`)})]})}function nN({expanded:e}){let{t}=K(`builder`),n=v(),{activeProjectId:r,projects:i}=at(),{blueprint:a,progress:o,hasBlueprint:s,refresh:c}=Dt(r),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(()=>_A()),[_,y]=(0,Q.useState)(()=>bA()),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),[w,T]=(0,Q.useState)(null);(0,Q.useLayoutEffect)(()=>{if(!l){T(null);return}let e=()=>{let e=S.current?.getBoundingClientRect();if(!e)return;let t=Math.max(8,e.left-320-8),n=Math.min(Math.max(8,e.top),Math.max(8,window.innerHeight-240));T({top:n,left:t})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[l]),(0,Q.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;S.current?.contains(t)||C.current?.contains(t)||u(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let E=(0,Q.useCallback)(async()=>{if(!(!r||d)){f(!0);try{let e=await EA(r,1,h,{autoAdvance:_}),n=CA(1);if(e.ok){let r=e.launched.length+e.pending.length;h===`sequential`&&e.pending.length>0?J.success(t(_?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:n,count:e.ticketCount,n:r})):e.skippedCount>0?J.warning(t(`milestoneProgress.toast.launchedPartial`,{milestone:n,count:e.ticketCount,skipped:e.skippedCount})):J.success(t(`milestoneProgress.toast.launchedAll`,{milestone:n,count:e.ticketCount,n:r})),u(!1)}else e.reason===`chain_active`?J.info(t(`milestoneProgress.toast.chainActive`,{milestone:n})):J.error(t(`done.launchFailed`),{description:e.detail??e.error})}finally{f(!1)}}},[r,_,d,h,t]),D=(0,Q.useCallback)(async(e,n)=>{if(!(!r||p)){m(!0);try{let i=await AA(r,e,n);i.ok?(y(n),xA(n),J.success(t(n?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):J.error(t(`milestoneProgress.chain.autoFailed`),{description:i.detail??i.error})}finally{m(!1)}}},[r,p,t]),O=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await OA(r,e);n.ok?J.success(t(`milestoneProgress.chain.resumed`)):J.error(t(`milestoneProgress.chain.resumeFailed`),{description:n.detail??n.error})}finally{m(!1)}}},[r,p,t]),k=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await kA(r,e);n.ok?J.success(t(`milestoneProgress.chain.cancelledToast`)):J.error(n.detail??n.error)}finally{m(!1)}}},[r,p,t]),A=(0,Q.useCallback)(e=>{u(!1),n(ve?`/review/${e}`:`/`)},[n]),j=(0,Q.useCallback)(()=>{u(!1),n(`/`)},[n]);if(!r||s===!1||!a)return null;let M=o.find(e=>e.n===1)??null,N=M!==null&&bt(M),P=o.find(e=>e.state===`planned`&&e.n>1)??null,F=i.find(e=>e.id===r),I=F?.provider??F?.providers?.[0]??`claude`,L=ir(I,`read-only`),R=N?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex rounded-md border border-border/40 p-0.5 text-[10px]`,role:`radiogroup`,"aria-label":t(`sequential.modeLabel`),title:t(h===`sequential`?`milestoneProgress.sequentialHint`:`milestoneProgress.parallelHint`),"data-testid":`milestone-launch-mode`,children:[`sequential`,`parallel`].map(e=>(0,$.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":h===e,onClick:()=>{g(e),vA(e)},className:X(`flex-1 rounded px-1.5 py-1 font-medium transition-colors`,h===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:text-foreground`),children:t(`sequential.mode.${e}`)},e))}),h===`sequential`&&(0,$.jsx)(aj,{checked:_,onChange:e=>{y(e),xA(e)},testId:`sidebar-auto-advance`}),(0,$.jsxs)(`button`,{type:`button`,onClick:E,disabled:d,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:[d?(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Xs,{className:`h-3 w-3`}),t(`sidebar.launchM1`)]})]}):null;return(0,$.jsxs)(`div`,{ref:S,className:`relative`,"data-testid":`builder-sidebar-entry`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,e?`px-2`:`px-0 justify-center`,l?`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,$.jsx)(ps,{className:`w-4 h-4 flex-shrink-0`}),e&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:t(`sidebar.title`)})]}),l&&w&&(0,xb.createPortal)((0,$.jsxs)(`div`,{ref:C,className:`fixed z-[72] w-80 max-h-[80vh] overflow-y-auto rounded-lg border border-border/50 bg-background p-3 shadow-xl`,style:{top:w.top,left:w.left},"data-testid":`builder-sidebar-panel`,children:[(0,$.jsx)(`h4`,{className:`text-xs font-semibold`,children:t(`sidebar.title`)}),(0,$.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:o.map(e=>(0,$.jsx)(sj,{progress:e,actions:e.n===1?R:void 0,chainBusy:p,onReview:A,onOpenRail:j,onResume:O,onCancel:k,onSetAutoAdvance:D},e.id||e.n))}),P&&(0,$.jsx)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{L&&(x(P.id),u(!1))},disabled:!L,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(L?`sidebar.generateHint`:`sidebar.generateUnavailable`),"data-testid":`sidebar-generate-next`,children:[(0,$.jsx)(un,{className:`h-3 w-3`}),t(`sidebar.generateNext`,{n:P.n})]})})]}),document.body),b&&(0,$.jsx)(tN,{open:!0,onClose:()=>x(null),onCommitted:()=>{c()},projectId:r,milestoneId:b,blueprint:a,provider:I})]})}var rN={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function iN({missionOnly:e=!1}={}){let{t}=K(`agent`),{t:n}=K(`nav`),{t:r}=K(`builder`),{rightMode:i,cycleRightMode:a}=eN(),{activeProjectId:o}=at(),s=Ca(),c=Ux(),{builderMode:l}=lM(),[u,d]=(0,Q.useState)(!1),f=l.active||i===`pinned-open`||i===`unpinned`&&u,p=UM(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:f}),m=i!==`unpinned`,h=n(rN[i]),g=!o,_=[{key:`jobs`,icon:Eo,label:t(`workspace.jobs`),onClick:()=>c.toggleJobsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},{key:`analytics`,icon:Do,label:t(`workspace.analytics`),onClick:()=>c.toggleAnalyticsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},...ke()?[{key:`browser`,icon:E,label:t(`workspace.browser`),onClick:()=>c.openBrowser(),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...Ce?[{key:`terminal`,icon:sc,label:t(`workspace.terminal`),onClick:()=>o&&s.togglePanel(o),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...se?[{key:`files`,icon:$o,label:t(`workspace.files`),onClick:()=>c.toggleCodePane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[]];return(0,$.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:()=>{i===`unpinned`&&d(!0)},onMouseLeave:()=>{i===`unpinned`&&!p.dragging&&d(!1)},children:[f&&(0,$.jsx)(WM,{side:`right`,dragging:p.dragging,width:p.width,min:180,max:460,label:n(`sidebarPin.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:p.onGripPointerDown,onKeyDown:p.onGripKeyDown}),(0,$.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,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:t(`workspace.title`)}),(0,$.jsx)(`button`,{type:`button`,onClick:a,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:n(`sidebarPin.withShortcut`,{label:h,shortcut:`⌘B`}),children:(0,$.jsx)(Ls,{className:`w-4 h-4`})})]}),l.active?(0,$.jsx)(f_,{mode:`wait`,initial:!1,children:(0,$.jsxs)(fy.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,$.jsx)(vj,{blueprint:l.session.blueprint,snapshot:l.session.snapshot}),l.session.phase===`chat`&&(0,$.jsx)(xj,{readiness:l.session.readiness,snapshot:l.session.snapshot,busy:l.session.busy,primaryLabel:r(`shell.createSpecs`),onPrimary:l.session.goToCommit,onRepair:()=>void l.session.repairSnapshot()})]},`builder-blueprint`)}):(0,$.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[!e&&(0,$.jsx)(nN,{expanded:f}),_.map(({key:e,icon:t,label:n,onClick:r,disabled:i,disabledTitle:a})=>(0,$.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,$.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),f&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:n})]},e))]})]})}var aN=`specrails:terminal-settings-updated`;function oN(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(aN,{detail:e}))}function sN(){return new uN(xM(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function cN(){return Y(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new uN(new wM(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var lN=[`tauri://created`,`tauri://error`],uN=class{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),n?.skip||Y(`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 cN()).find(t=>t.label===e)??null}static getCurrent(){return sN()}static async getAll(){return cN()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:mr(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)}:gr(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(lN.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return hr(e,t)}async emitTo(e,t,n){if(lN.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return _r(e,t,n)}_handleTauriEvent(e,t){return lN.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return Y(`plugin:webview|webview_position`,{label:this.label}).then(e=>new gM(e))}async size(){return Y(`plugin:webview|webview_size`,{label:this.label}).then(e=>new pM(e))}async close(){return Y(`plugin:webview|webview_close`,{label:this.label})}async setSize(e){return Y(`plugin:webview|set_webview_size`,{label:this.label,value:e instanceof mM?e:new mM(e)})}async setPosition(e){return Y(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof _M?e:new _M(e)})}async setFocus(){return Y(`plugin:webview|set_webview_focus`,{label:this.label})}async setAutoResize(e){return Y(`plugin:webview|set_webview_auto_resize`,{label:this.label,value:e})}async hide(){return Y(`plugin:webview|webview_hide`,{label:this.label})}async show(){return Y(`plugin:webview|webview_show`,{label:this.label})}async setZoom(e){return Y(`plugin:webview|set_webview_zoom`,{label:this.label,value:e})}async reparent(e){return Y(`plugin:webview|reparent`,{label:this.label,window:typeof e==`string`?e:e.label})}async clearAllBrowsingData(){return Y(`plugin:webview|clear_all_browsing_data`)}async setBackgroundColor(e){return Y(`plugin:webview|set_webview_background_color`,{color:e})}async onDragDropEvent(e){let t=await this.listen(vr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),n=await this.listen(vr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new gM(t.payload.position)}})}),r=await this.listen(vr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new gM(t.payload.position)}})}),i=await this.listen(vr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function dN(e){return`'${e.replace(/'/g,`'\\''`)}'`}function fN(e){if(/[\x00-\x1f"%!]/.test(e))throw Error(`unsafe-cmd-path`);return`"`+e+`"`}function pN(e){return`'${e.replace(/'/g,`''`)}'`}function mN(e,t,n=`powershell`){return t?n===`cmd`?fN(e):pN(e):dN(e)}function hN(e,t,n=`powershell`){return e.map(e=>mN(e,t,n)).join(` `)}function gN(e){return/(?:^|[\\/])cmd(?:\.exe)?$/i.test(e??``)?`cmd`:`powershell`}async function _N(e){if(!me())return{dispose:()=>{}};let t=[];try{let 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&&yN(s,u.viewportEl.getBoundingClientRect(),window.devicePixelRatio||1))try{u.writeText(hN(o,i,gN(u.shell)))}catch{J.error(G.t(`terminal:errors.pathPasteUnsafe`))}},o=vN((()=>{try{return sN()}catch{return null}})());o&&t.push(await o(a));let s=vN((()=>{try{return xM()}catch{return null}})());return s&&t.push(await s(a)),t.length===0?{dispose:()=>{}}:{dispose:()=>{for(let e of t)try{e()}catch{}}}}catch{for(let e of t)try{e()}catch{}return{dispose:()=>{}}}}function vN(e){let t=e?.onDragDropEvent;return typeof t==`function`?t.bind(e):null}function yN(e,t,n){let r=Number.isFinite(n)&&n>0?n:1;return bN(e.x/r,e.y/r,t)}function bN(e,t,n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function xN({x:e,y:t,label:n,onSelect:r,onClose:i}){let a=(0,Q.useRef)(null);return(0,Q.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,$.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,$.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 SN({x:e,y:t,providers:n,onSelect:r,onClose:i}){let{t:a}=K(`terminal`),o=(0,Q.useRef)(null);(0,Q.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,$.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,$.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:ur(e)})},e))})}var CN=(0,Q.forwardRef)(function({isOpen:e,className:t,...n},r){let{t:i}=K(`terminal`);return(0,$.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,$.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,$.jsx)(`rect`,{x:`1`,y:`1`,width:`12`,height:`8`,rx:`1.5`}),e?(0,$.jsx)(`path`,{d:`M5 3.5 L7 5.5 L9 3.5`}):(0,$.jsx)(`path`,{d:`M5 6.5 L7 4.5 L9 6.5`})]})})});function wN({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}=K(`terminal`),g=!!i&&i.length>1,_=ur(r),v=h(`topBar.maxTerminals`,{max:10}),y=t?g?h(`topBar.openCliMulti`):h(`topBar.openCli`,{cli:_}):v;return(0,$.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,$.jsx)(`div`,{className:`flex items-center gap-2 pl-1`,children:(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:h(`topBar.title`)})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(TN,{label:y,disabled:!t,onClick:e=>o(e?{x:e.clientX,y:e.clientY}:void 0),children:(0,$.jsx)(un,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(`topBar.openInBrowser`),onClick:s,onContextMenu:e=>{e.preventDefault(),u({x:e.clientX,y:e.clientY})},children:(0,$.jsx)(E,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(l?`topBar.pasteScriptNoActive`:`topBar.pasteScript`),disabled:l,onClick:c,onContextMenu:e=>{e.preventDefault(),d({x:e.clientX,y:e.clientY})},children:(0,$.jsx)(Lo,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:t?h(`topBar.newTerminal`):v,disabled:!t,onClick:a,children:(0,$.jsx)(cn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(`topBar.killActive`),disabled:!n,onClick:f,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(TN,{label:h(e===`maximized`?`topBar.restorePanel`:`topBar.maximizePanel`),onClick:p,children:e===`maximized`?(0,$.jsx)(ks,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Os,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(CN,{isOpen:!0,onClick:m})]})]})}function TN({label:e,disabled:t,onClick:n,onContextMenu:r,children:i}){return(0,$.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 EN({sessions:e,activeId:t,onActivate:n,onRename:r,onKill:i}){return(0,$.jsx)(`aside`,{className:X(`w-44 shrink-0 border-l border-border/40 bg-background/70`,`overflow-y-auto`),children:(0,$.jsx)(`ul`,{className:`py-1`,children:e.map(e=>(0,$.jsx)(DN,{session:e,active:e.id===t,onActivate:()=>n(e.id),onRename:t=>r(e.id,t),onKill:()=>i(e.id)},e.id))})})}function DN({session:e,active:t,onActivate:n,onRename:r,onKill:i}){let{t:a}=K(`terminal`),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(e.name),u=(0,Q.useRef)(null);(0,Q.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,$.jsx)(`li`,{className:`relative group px-1`,children:(0,$.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,$.jsx)(dc,{className:`h-3 w-3 shrink-0`}),o?(0,$.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,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),!o&&(0,$.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,$.jsx)(an,{className:`h-3 w-3`})}),(0,$.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,$.jsx)(mn,{className:`h-3 w-3`})})]})})}function ON({search:e,onClose:t}){let{t:n}=K(`terminal`),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(r.current?.focus(),()=>{try{e.clearDecorations()}catch{}}),[e]),(0,Q.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,Q.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,$.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,$.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,$.jsxs)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:[f.current,`/`,f.total]}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.previous`),onClick:g,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(Gt,{size:14})}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.next`),onClick:h,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(Zt,{size:14})}),(0,$.jsx)(kN,{label:`Aa`,title:n(`search.matchCase`),active:o,onToggle:()=>s(e=>!e)}),(0,$.jsx)(kN,{label:`.*`,title:n(`search.regex`),active:c,onToggle:()=>l(e=>!e)}),(0,$.jsx)(kN,{label:`W`,title:n(`search.wholeWord`),active:u,onToggle:()=>d(e=>!e)}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.close`),onClick:t,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(mn,{size:14})})]})}function kN({label:e,title:t,active:n,onToggle:r}){return(0,$.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 AN({x:e,y:t,term:n,cwd:r,hasReveal:i,onClose:a,onOpenSearch:o,onReveal:s,onSaveScrollback:c}){let{t:l}=K(`terminal`),u=(0,Q.useRef)(null);(0,Q.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=/Mac/i.test(navigator.platform||``)?`⌘`:`Ctrl+`,m=n.getSelection(),h=m.length>0;function g(){h&&(ma(m),a())}function _(){pa().then(e=>{if(e)try{n.paste(e)}catch{}}),a()}function v(){try{n.selectAll()}catch{}a()}function y(){try{n.clear()}catch{}a()}function b(){o(),a()}function x(){c(),a()}function S(){r&&s(r),a()}return(0,$.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,$.jsx)(jN,{onClick:g,disabled:!h,label:l(`common:actions.copy`),shortcut:p+`C`}),(0,$.jsx)(jN,{onClick:_,label:l(`contextMenu.paste`),shortcut:p+`V`}),(0,$.jsx)(jN,{onClick:v,label:l(`contextMenu.selectAll`),shortcut:p+`A`}),(0,$.jsx)(MN,{}),(0,$.jsx)(jN,{onClick:y,label:l(`contextMenu.clear`),shortcut:p+`K`}),(0,$.jsx)(jN,{onClick:b,label:l(`contextMenu.search`),shortcut:p+`F`}),(0,$.jsx)(jN,{onClick:x,label:l(`contextMenu.saveScrollback`)}),r&&i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(MN,{}),(0,$.jsx)(jN,{onClick:S,label:l(`contextMenu.openPath`,{path:NN(r,40)})})]})]})}function jN({onClick:e,label:t,shortcut:n,disabled:r}){return(0,$.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,$.jsx)(`span`,{children:t}),n&&(0,$.jsx)(`span`,{className:`text-xs text-[#6272a4] tabular-nums`,children:n})]})}function MN(){return(0,$.jsx)(`div`,{className:`my-1 border-t border-[#44475a]`})}function NN(e,t){return e.length<=t?e:`…`+e.slice(e.length-t+1)}async function PN(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(`
|
|
44
44
|
`);if(me()){let{invoke:e}=await c(async()=>{let{invoke:e}=await import(`./core-B3mKBIh5.js`).then(e=>e.i);return{invoke:e}},__vite__mapDeps([0,1]));await e(`desktop_save_text`,{suggestedName:t,text:i});return}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 FN({sessionId:e}){let[t,n]=(0,Q.useState)(()=>Ei(e));return(0,Q.useEffect)(()=>Ti(e,n),[e]),t.promptRows.length===0?null:(0,$.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,$.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 IN({sessionId:e}){let{t}=K(`terminal`),[n,r]=(0,Q.useState)(Ei(e).openPreExec?.startedAt??null),[i,a]=(0,Q.useState)(Date.now());if((0,Q.useEffect)(()=>Ti(e,e=>r(e.openPreExec?.startedAt??null)),[e]),(0,Q.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,$.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:LN(o,t)})}function LN(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 RN({activeId:e}){let{t}=K(`terminal`),n=(0,Q.useRef)(null),r=Ca(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=me();(0,Q.useEffect)(()=>{if(e)return r.subscribeOpenSearch(e,()=>a(!0))},[e,r]),(0,Q.useEffect)(()=>{a(!1),s(null)},[e]);let l=e?r.getSearchAddon(e):null,u=e?r.getTerminalInstance(e):null,d=e?r.getCwd(e):null,[f,p]=(0,Q.useState)(!1),m=(0,Q.useCallback)(t=>{if(!t)return!1;if(e&&r.writeToSession(e,t))return!0;if(!u)return!1;try{return u.paste(t),!0}catch{return!1}},[e,r,u]),h=(0,Q.useCallback)(n=>{if(!u||!n||n.length===0)return!1;let i=Array.from(n).map(e=>zN(e)).filter(e=>!!e);if(i.length===0)return!1;let a=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);try{return m(hN(i,a,gN(e?r.getShell?.(e):null)))}catch{return J.error(t(`errors.pathPasteUnsafe`)),!1}},[u,m,e,r,t]),g=(0,Q.useCallback)(e=>{if(e.preventDefault(),!e.shiftKey&&u){let e=u.modes?.mouseTrackingMode;if(e&&e!==`none`)return}s({x:e.clientX,y:e.clientY})},[u]),_=(0,Q.useCallback)(n=>{if(!u)return;if(n.clipboardData.files&&n.clipboardData.files.length>0){let i=Array.from(n.clipboardData.files).map(e=>zN(e)).filter(e=>!!e);if(i.length>0){n.preventDefault(),n.stopPropagation();let a=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);try{m(hN(i,a,gN(e?r.getShell?.(e):null)))}catch{J.error(t(`errors.pathPasteUnsafe`))}return}}let i=n.clipboardData.getData(`text/plain`);i&&(n.preventDefault(),n.stopPropagation(),m(i))},[u,m,e,r,t]),v=(0,Q.useCallback)(e=>{if(!u)return;let t=u.getSelection();t&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault(),e.stopPropagation())},[u]),y=(0,Q.useCallback)(e=>{if(u&&(typeof navigator<`u`&&/Mac/i.test(navigator.platform||``)?e.metaKey:e.ctrlKey)&&(e.key===`c`||e.key===`C`)){let t=u.getSelection();if(!t)return;e.preventDefault(),e.stopPropagation(),ma(t)}},[u]);return(0,Q.useEffect)(()=>{let t=n.current;if(!t||!e)return;let i=r.getContainer(e);if(i)return t.appendChild(i),r.notifyAdopted(e),()=>{let e=document.getElementById(`specrails-terminal-host`);e&&i.parentElement===t&&e.appendChild(i)}},[e,r]),(0,Q.useEffect)(()=>{let t=n.current;if(!t||!e)return;let i=[],a=t.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 n=t;n.propertyName!==`width`&&n.propertyName!==`height`||r.refitActive(e)};return i.forEach(e=>e.addEventListener(`transitionend`,o)),()=>{i.forEach(e=>e.removeEventListener(`transitionend`,o))}},[e,r]),(0,$.jsxs)(`div`,{ref:n,className:`flex-1 min-w-0 bg-background px-2 py-1 relative ${f?`outline outline-2 outline-accent-primary outline-offset-[-2px]`:``}`,role:`presentation`,"data-terminal-viewport":!0,onContextMenu:g,onPasteCapture:_,onCopyCapture:v,onKeyDownCapture:y,tabIndex:-1,onDragEnter:e=>{BN(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),p(!0))},onDragOver:e=>{BN(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),p(!0))},onDragLeave:()=>p(!1),onDrop:e=>{BN(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),h(e.dataTransfer.files)),p(!1)},children:[e&&(0,$.jsx)(FN,{sessionId:e}),e&&(0,$.jsx)(IN,{sessionId:e}),i&&l&&(0,$.jsx)(ON,{search:l,onClose:()=>a(!1)}),o&&u&&(0,$.jsx)(AN,{x:o.x,y:o.y,term:u,cwd:d,hasReveal:c,onClose:()=>s(null),onOpenSearch:()=>a(!0),onReveal:e=>{oe(e).catch(()=>J.error(t(`errors.nativeActionFailed`)))},onSaveScrollback:()=>{u&&PN(u).catch(()=>J.error(t(`errors.nativeActionFailed`)))}})]})}function zN(e){let t=e.path;return typeof t==`string`&&t.length>0?t:null}function BN(e){return e?Array.from(e.types).includes(`Files`):!1}function VN({height:e,maxHeight:t,onHeightCommit:n,onHeightPreview:r,minHeight:i=120}){let{t:a}=K(`terminal`),o=(0,Q.useRef)(!1),s=(0,Q.useRef)(0),c=(0,Q.useRef)(e),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(e),d=(0,Q.useCallback)(e=>e<i?i:e>t?t:Math.round(e),[i,t]);(0,Q.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,$.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 HN({onCreate:e}){let{t}=K(`terminal`);return(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-center px-6 bg-background-deep`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,$.jsx)(dc,{className:`h-8 w-8 opacity-50`}),(0,$.jsx)(`p`,{className:`text-xs`,children:t(`emptyState.noTerminals`)}),(0,$.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,$.jsx)(cn,{className:`h-3 w-3`}),` `,t(`emptyState.newTerminal`)]})]})})}var UN=300;function WN({projectId:e,provider:t=`claude`,providers:n,state:r,viewportHeight:i,statusBarHeight:a}){let o=Ca(),{t:s}=K(`terminal`),c=v(),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(vi),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),{launchDescriptors:y}=UO(),b=(0,Q.useRef)(a===0&&r.visibility!==`hidden`),[x,S]=(0,Q.useState)(()=>r.visibility===`hidden`?`hidden`:b.current?`opening`:`open`),C=(0,Q.useRef)(!1),w=n&&n.length>0?n:[t],T=w.length>1,E=(0,Q.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&&p(r.resolved)}catch{}},[e]);(0,Q.useEffect)(()=>{let e=!1;return E(()=>e),()=>{e=!0}},[E]),(0,Q.useEffect)(()=>{let t=t=>{let n=t.detail;n?.mode===`project`&&n.projectId!==e||E()};return window.addEventListener(aN,t),()=>window.removeEventListener(aN,t)},[E,e]);let D=Math.max(120,i-a-40),O=Math.min(Math.max(r.userHeight||320,120),D),k=r.visibility===`maximized`?Math.max(120,i-a):u??O,A=x===`open`,j=A?k:0,M=a===0,N=r.sessions.length<10,P=r.activeId!==null;(0,Q.useEffect)(()=>{let e=null,t=null,n=null,i=()=>{S(`opening`),t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>S(`open`))})};return C.current?(r.visibility===`hidden`?(S(`closing`),e=setTimeout(()=>S(`hidden`),UN)):i(),()=>{e&&clearTimeout(e),t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)}):(C.current=!0,b.current&&i(),()=>{t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)})},[r.visibility]),(0,Q.useEffect)(()=>{let e=!1,t=null;return _N(()=>{let e=l.current,t=r.activeId;return!e||!t||r.visibility===`hidden`?null:{viewportEl:e,shell:o.getShell?.(t),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 F=(0,Q.useCallback)(()=>{N&&o.create(e)},[N,e,o]),I=(0,Q.useCallback)(t=>{if(!N)return;let n=y[t]??{command:t,args:[]},i=[n.command,...n.args].join(` `)+`
|
|
45
45
|
`,a=t||`claude`,s=RegExp(`^${a} \\(\\d+\\)$`),c=r.sessions.filter(e=>e.name===a||s.test(e.name)),l=c.length===0?a:`${a} (${c.length+1})`;o.createAndType(e,i,{name:l})},[N,y,e,r.sessions,o]),L=(0,Q.useCallback)(e=>{if(N){if(T&&e){_(e);return}I(t)}},[N,T,t,I]),R=(0,Q.useCallback)(()=>{Te(f.browserShortcutUrl)},[f.browserShortcutUrl]),z=(0,Q.useCallback)(()=>{r.activeId&&f.quickScript&&o.writeToSession(r.activeId,f.quickScript)},[f.quickScript,r.activeId,o]),B=(0,Q.useCallback)(e=>{h({...e,kind:`browser`})},[]),ee=(0,Q.useCallback)(e=>{h({...e,kind:`script`})},[]),V=(0,Q.useCallback)(e=>{c(`/settings${e===`browser`?`#terminal-browser-shortcut-url`:`#terminal-quick-script`}`)},[c]),H=(0,Q.useCallback)(()=>{r.activeId&&o.kill(e,r.activeId)},[e,r.activeId,o]),te=(0,Q.useCallback)(()=>{o.setVisibility(e,r.visibility===`maximized`?`restored`:`maximized`)},[e,r.visibility,o]),ne=(0,Q.useCallback)(()=>{o.setVisibility(e,`hidden`)},[e,o]);return(0,Q.useEffect)(()=>{d(null)},[r.visibility]),x===`hidden`?null:(0,$.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:j,opacity:+!!A,transform:A?`translateY(0) scaleY(1)`:`translateY(${M?14:8}px) scaleY(${M?.96:.985})`,clipPath:A?`inset(0 0 0 0)`:`inset(100% 0 0 0)`},"data-testid":`terminal-bottom-panel`,children:[(0,$.jsx)(VN,{height:O,maxHeight:D,onHeightPreview:e=>d(e),onHeightCommit:t=>{d(null),o.setUserHeight(e,t),r.visibility===`maximized`&&o.setVisibility(e,`restored`)}}),(0,$.jsx)(wN,{visibility:r.visibility,canCreate:N,hasActive:P,provider:t,providers:w,onCreate:F,onOpenCli:L,onOpenBrowser:R,onPasteScript:z,pasteScriptDisabled:!P||!f.quickScript,onConfigureBrowser:B,onConfigureScript:ee,onKillActive:H,onToggleMaximize:te,onCollapse:ne}),m&&(0,$.jsx)(xN,{x:m.x,y:m.y,label:m.kind===`browser`?s(`shortcutMenu.configureBrowserUrl`):s(`shortcutMenu.editQuickScript`),onSelect:()=>V(m.kind),onClose:()=>h(null)}),g&&(0,$.jsx)(SN,{x:g.x,y:g.y,providers:w,onSelect:e=>I(e),onClose:()=>_(null)}),(0,$.jsx)(`div`,{className:`flex-1 flex min-h-0`,children:r.sessions.length===0?(0,$.jsx)(HN,{onCreate:F}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(RN,{activeId:r.activeId}),(0,$.jsx)(EN,{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 GN(){let{t:e}=K(`agent`),{current:t,initialized:n}=si(),{active:r}=lM(),{activeProjectId:i,projects:a}=at(),o=wa(i),s=a.find(e=>e.id===i),[c,l]=(0,Q.useState)(window.innerHeight);return(0,Q.useEffect)(()=>{!me()||!t||r?.id!==t.conversationId||xM().setTitle(`${r.title?.trim()||e(`header.untitled`)} — Specrails`).catch(()=>{})},[t?.conversationId,r?.id,r?.title,e]),(0,Q.useEffect)(()=>{let e=()=>l(window.innerHeight);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),!n||!t||r?.id!==t.conversationId?(0,$.jsx)(`div`,{role:`status`,className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:e(`window.loading`)}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,"data-mission-window":!0,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(BM,{})}),Ce&&s&&i&&(0,$.jsx)(WN,{projectId:i,provider:s.provider,providers:rt(s),state:o,viewportHeight:c-36,statusBarHeight:0})]}),(0,$.jsx)(iN,{missionOnly:!0})]})}function KN(){var e=[...arguments];return(0,Q.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var qN=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function JN(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function YN(e){return`nodeType`in e}function XN(e){return e?JN(e)?e:YN(e)?e.ownerDocument?.defaultView??window:window:window}function ZN(e){let{Document:t}=XN(e);return e instanceof t}function QN(e){return!JN(e)&&e instanceof XN(e).HTMLElement}function $N(e){return e instanceof XN(e).SVGElement}function eP(e){return e?JN(e)?e.document:YN(e)?ZN(e)?e:QN(e)||$N(e)?e.ownerDocument:document:document:document}var tP=qN?Q.useLayoutEffect:Q.useEffect;function nP(e){let t=(0,Q.useRef)(e);return tP(()=>{t.current=e}),(0,Q.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function rP(){let e=(0,Q.useRef)(null);return[(0,Q.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,Q.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function iP(e,t){t===void 0&&(t=[e]);let n=(0,Q.useRef)(e);return tP(()=>{n.current!==e&&(n.current=e)},t),n}function aP(e,t){let n=(0,Q.useRef)();return(0,Q.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function oP(e){let t=nP(e),n=(0,Q.useRef)(null);return[n,(0,Q.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function sP(e){let t=(0,Q.useRef)();return(0,Q.useEffect)(()=>{t.current=e},[e]),t.current}var cP={};function lP(e,t){return(0,Q.useMemo)(()=>{if(t)return t;let n=cP[e]==null?0:cP[e]+1;return cP[e]=n,e+`-`+n},[e,t])}function uP(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var dP=uP(1),fP=uP(-1);function pP(e){return`clientX`in e&&`clientY`in e}function mP(e){if(!e)return!1;let{KeyboardEvent:t}=XN(e.target);return t&&e instanceof t}function hP(e){if(!e)return!1;let{TouchEvent:t}=XN(e.target);return t&&e instanceof t}function gP(e){if(hP(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return pP(e)?{x:e.clientX,y:e.clientY}:null}var _P=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[_P.Translate.toString(e),_P.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),vP=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function yP(e){return e.matches(vP)?e:e.querySelector(vP)}var bP={display:`none`};function xP(e){let{id:t,value:n}=e;return Q.createElement(`div`,{id:t,style:bP},n)}function SP(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return Q.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function CP(){let[e,t]=(0,Q.useState)(``);return{announce:(0,Q.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var wP=(0,Q.createContext)(null);function TP(e){let t=(0,Q.useContext)(wP);(0,Q.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function EP(){let[e]=(0,Q.useState)(()=>new Set),t=(0,Q.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,Q.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var DP={draggable:`
|
|
46
46
|
To pick up a draggable item, press the space bar.
|
|
@@ -67,10 +67,10 @@ Error generating stack: `+e.message+`
|
|
|
67
67
|
`)})}finally{h.current&&m.current===n&&d(!1)}}async function M(){let e=y.recoveryWorktreePaths;if(e.length===0){J.info(i(`railPr.localResultUnavailableHere`));return}let t=e.join(`
|
|
68
68
|
`),n=!1;try{await navigator.clipboard.writeText(t),n=!0}catch{}try{me()&&await oe(e[0])}catch{}n?J.success(i(`railPr.localResultPathCopied`),{description:t}):J.info(i(`railPr.localResultPath`),{description:t})}let N=`inline-flex items-center gap-1 rounded-full font-medium border ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,P=`inline-flex items-center gap-1 rounded-md font-medium bg-accent-primary text-white hover:bg-accent-primary/90 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,F=`inline-flex items-center gap-1 rounded-md font-medium border border-border/60 text-foreground/70 hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,I=`inline-flex items-center gap-1 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,L=T?`w-2.5 h-2.5`:`w-3 h-3`,z=(0,$.jsx)(rn,{className:`${L} animate-spin`,"aria-hidden":!0}),B=c!==null||u||e.operation!=null,ee=s.has(e.prDeliveryId),V=i(g===`implementation_failed`?`railPr.implementationFailedHint`:`railPr.discardTooltip`),H=e.prUrl?(0,$.jsxs)(`a`,{href:e.prUrl,target:`_blank`,rel:`noreferrer`,"data-testid":`rail-pr-link`,title:i(`railPr.openPrTitle`),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 rounded-md font-mono border border-accent-info/30 bg-accent-info/10 text-accent-info hover:bg-accent-info/20 hover:border-accent-info/60 transition-colors ${T?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:[e.prNumber==null?i(`railPr.prLinkFallback`):`#${e.prNumber}`,(0,$.jsx)(Vt,{className:T?`w-2 h-2`:`w-2.5 h-2.5`,"aria-hidden":!0})]}):null,te=e.branch?(0,$.jsx)(`span`,{"data-testid":`rail-pr-branch`,className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded-md font-mono border border-border/60 bg-surface/60 text-foreground/70 ${T?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:(0,$.jsx)(`span`,{className:`truncate`,children:e.branch})}):null,ne=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-discard`,disabled:B,title:V,onClick:e=>{e.stopPropagation(),D(`discard`)},className:I,children:[c===`discard`?z:null,i(`railPr.discard`)]}),re=!_&&(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-merge-local`,disabled:B,title:i(`railPr.mergeLocalTooltip`,{base:e.baseBranch}),onClick:e=>{e.stopPropagation(),D(`merge-local`)},className:`inline-flex items-center gap-1 rounded-md font-medium border border-accent-success/40 bg-accent-success/10 text-accent-success hover:bg-accent-success/20 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[c===`merge-local`?z:(0,$.jsx)(ls,{className:L,"aria-hidden":!0}),i(`railPr.mergeLocal`)]}),ie=(e,t,n,r,i,a)=>!_&&(0,$.jsxs)(`button`,{type:`button`,"data-testid":r,disabled:B,title:i,onClick:n=>{n.stopPropagation(),A(e,t)},className:P,children:[c===e?z:a,n]}),ae=ve?(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-open-packet`,title:i(`railPr.openReviewTooltip`),onClick:t=>{t.stopPropagation(),a(`/review/${e.prDeliveryId}`)},className:`inline-flex items-center gap-1 rounded-md font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary hover:bg-accent-primary/20 transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[(0,$.jsx)(Qo,{className:L,"aria-hidden":!0}),i(`railPr.openReview`)]}):null,se=pt(e),ce=r&&se&&!_?(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-checkout`,disabled:B,title:i(`railPr.checkoutTooltip`,{branch:se}),onClick:e=>{e.stopPropagation(),j()},className:`inline-flex items-center gap-1 rounded-md font-medium border border-border/60 text-foreground/70 hover:border-accent-primary/40 hover:bg-accent-primary/10 disabled:opacity-50 disabled:pointer-events-none transition-colors ${T?`px-1.5 py-0.5 text-[9px]`:`px-2 py-0.5 text-[10px]`}`,children:[u?z:(0,$.jsx)(nn,{className:L,"aria-hidden":!0}),i(`railPr.checkout`)]}):null,le=y.recoveryWorktreePaths.length>0?(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-inspect-local-result`,disabled:B,onClick:e=>{e.stopPropagation(),M()},className:F,title:i(`railPr.inspectLocalResultTooltip`),children:[(0,$.jsx)(as,{className:L,"aria-hidden":!0}),i(`railPr.inspectLocalResult`)]}):null,ue=y.recoveryRecheck,de=y.manualRecovery||ue?(0,$.jsxs)(`button`,{type:`button`,"data-testid":ue?`rail-pr-recheck-recovery`:`rail-pr-recover-and-retry`,disabled:B,onClick:e=>{e.stopPropagation(),D(`recover-and-retry`)},className:ue?F:P,children:[c===`recover-and-retry`?z:(0,$.jsx)(Zs,{className:L,"aria-hidden":!0}),i(ue?`railPr.recheckRecovery`:`railPr.recoverAndRetry`)]}):null,fe=(e.runIds??[]).map((t,n)=>(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-run-log`,title:i(`railPr.viewRunLog`,{ref:e.ticketIds[n]==null?t.slice(0,8):`#${e.ticketIds[n]}`}),"aria-label":i(`railPr.viewRunLog`,{ref:e.ticketIds[n]==null?t.slice(0,8):`#${e.ticketIds[n]}`}),onClick:e=>{e.stopPropagation(),a(`/jobs/${t}`)},className:`inline-flex items-center gap-1 rounded-md border border-accent-info/30 bg-accent-info/10 font-medium text-accent-info transition-colors hover:border-accent-info/55 hover:bg-accent-info/15 ${T?`px-1 py-0.5 text-[9px]`:`px-1.5 py-0.5 text-[10px]`}`,children:[(0,$.jsx)($s,{className:L,"aria-hidden":!0}),e.ticketIds[n]==null?t.slice(0,8):`#${e.ticketIds[n]}`]},t)),pe=(e.units??[]).map(e=>{let t=e.implementationOutcome===`failed`||e.implementationOutcome==null&&!e.succeeded,n=e.deliveryOutcome===`blocked`,r=e.deliveryOutcome===`no_changes`||e.changed===!1;return(0,$.jsxs)(`span`,{"data-testid":`rail-pr-unit-evidence`,title:e.failureCode??e.branch,className:`${N} ${t?`border-destructive/30 bg-destructive/10 text-destructive`:n?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:`border-accent-success/30 bg-accent-success/10 text-accent-success`}`,children:[`#`,e.ticketId,` · `,i(t?`railPr.unit.failed`:n?`railPr.unit.blocked`:r?`railPr.unit.noChanges`:`railPr.unit.succeeded`)]},`${e.ticketId}-${e.runId??e.branch}`)}),he=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-dismiss`,disabled:B,onClick:e=>{e.stopPropagation(),D(`dismiss`)},className:I,children:[c===`dismiss`?z:null,i(`railPr.dismiss`)]}),ge=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-discard-local`,disabled:B,onClick:e=>{e.stopPropagation(),D(`discard-local`)},className:I,children:[c===`discard`?z:null,i(`railPr.discardLocalResult`)]}),_e=!_&&(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-no-changes-done`,disabled:B,onClick:e=>{e.stopPropagation(),D(`no-changes-done`)},className:P,children:[c===`acknowledge-no-changes`?z:(0,$.jsx)(Mo,{className:L,"aria-hidden":!0}),i(`railPr.markDone`)]}),ye=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-pr-refine`,disabled:B,onClick:e=>{e.stopPropagation(),D(`refine`)},className:I,children:[c===`discard`?z:null,i(`railPr.refine`)]}),U=null,be=null;return w?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-info/30 bg-accent-info/10 text-accent-info`,children:[(0,$.jsx)(rn,{className:`${L} animate-spin`,"aria-hidden":!0}),i(`railPr.iteratingPr`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,te]})):y.noChanges?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-success/30 bg-accent-success/10 text-accent-success`,children:[(0,$.jsx)(Mo,{className:L,"aria-hidden":!0}),i(`railPr.noChanges`)]}),be=(0,$.jsxs)($.Fragment,{children:[e.prUrl?H:null,y.continuation?he:(0,$.jsxs)($.Fragment,{children:[_e,ye]})]})):y.partial&&!y.deliveryBlocked&&!y.retryablePush&&!y.retryablePrCreation&&!y.closed?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.partial`,{succeeded:y.succeededCount,total:y.totalCount})]}),be=g===`pr_draft`&&e.prUrl?(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`publish`,`pr_draft`,i(`railPr.publish`),`rail-pr-publish`,i(`railPr.publishTooltip`)),y.continuation?he:ne]}):g===`pr_ready`?(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`poll-merge`,`pr_ready`,i(`railPr.verifyPr`),`rail-pr-poll`,i(`railPr.verifyPrTooltip`)),y.continuation?he:ne]}):g===`on_review`||g===`pr_draft`&&!e.prUrl?(0,$.jsxs)($.Fragment,{children:[ce,ie(`create-pr`,g,i(`railPr.createPartialPr`,{count:y.deliverableCount}),`rail-pr-create-partial`),y.continuation?he:ne]}):(0,$.jsxs)($.Fragment,{children:[H,ce,y.continuation?he:ne]})):y.deliveryBlocked?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:e.statusDetail??void 0,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.deliveryBlocked`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,le,de,y.continuation?y.hasDiscardableRecoveryResult?ge:he:ne]})):y.retryablePush?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:e.statusDetail??void 0,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.updateFailed`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`create-pr`,g,i(`railPr.retryPush`),`rail-pr-retry-push`),y.continuation?he:ne]})):y.retryablePrCreation?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:e.statusDetail??void 0,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),y.localOnly?i(`railPr.localOnly`):e.prState===`pushed`?i(`railPr.branchPushed`):i(`railPr.prFailed`)]}),be=(0,$.jsxs)($.Fragment,{children:[ie(`create-pr`,g,i(`railPr.retryPr`),`rail-pr-create`),ce,re,y.continuation?he:ne]})):y.closed?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.prClosed`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`reopen`,`pr_closed`,i(`railPr.reopen`),`rail-pr-reopen`,void 0,(0,$.jsx)(Zs,{className:L,"aria-hidden":!0})),y.continuation?he:ne]})):g===`on_review`?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,children:[(0,$.jsx)(Qo,{className:L,"aria-hidden":!0}),i(`railPr.readyForReview`)]}),be=(0,$.jsxs)($.Fragment,{children:[ae,ce,ie(`create-pr`,`on_review`,i(`railPr.createPr`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch}),(0,$.jsx)(R,{className:L,"aria-hidden":!0})),re,y.continuation?he:ne]})):g===`pr_draft`&&e.prUrl?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-info/30 bg-accent-info/10 text-accent-info`,children:[(0,$.jsx)(R,{className:L,"aria-hidden":!0}),i(`railPr.draftPr`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`publish`,`pr_draft`,i(`railPr.publish`),`rail-pr-publish`,i(`railPr.publishTooltip`)),y.continuation?he:ne]})):g===`pr_draft`?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-warning/30 bg-accent-warning/10 text-accent-warning`,title:i(`railPr.branchPushedHint`),children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),y.localOnly?i(`railPr.localOnly`):i(`railPr.branchPushed`)]}),be=(0,$.jsxs)($.Fragment,{children:[ie(`create-pr`,`pr_draft`,i(`railPr.retryPr`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch})),ce,re,y.continuation?he:ne]})):g===`pr_ready`?(U=(0,$.jsxs)(`span`,{className:`${N} border-accent-success/30 bg-accent-success/10 text-accent-success`,children:[(0,$.jsx)(ls,{className:L,"aria-hidden":!0}),i(`railPr.prReady`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`poll-merge`,`pr_ready`,i(`railPr.verifyPr`),`rail-pr-poll`,i(`railPr.verifyPrTooltip`)),y.continuation?he:ne]})):g===`pr_failed`?(U=(0,$.jsxs)(`span`,{className:`${N} border-destructive/30 bg-destructive/10 text-destructive`,children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.prFailed`)]}),be=(0,$.jsxs)($.Fragment,{children:[H,ce,ie(`create-pr`,`pr_failed`,i(`railPr.retry`),`rail-pr-create`,i(`railPr.createPrTooltip`,{base:e.baseBranch})),!e.prUrl&&re,y.continuation?he:ne]})):g===`implementation_failed`&&y.implementationFailed&&(U=(0,$.jsxs)(`span`,{className:`${N} border-destructive/30 bg-destructive/10 text-destructive`,title:i(`railPr.implementationFailedHint`),children:[(0,$.jsx)(fn,{className:L,"aria-hidden":!0}),i(`railPr.implementationFailed`)]}),be=(0,$.jsx)($.Fragment,{children:y.continuation?he:ne})),(0,$.jsxs)(`div`,{"data-testid":`rail-pr-strip`,"data-decision":g,className:`flex items-center flex-wrap animate-in fade-in slide-in-from-top-1 duration-200 ${T?`gap-1`:`gap-1.5`}`,onClick:e=>e.stopPropagation(),children:[C&&(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-label":C,className:`sr-only`}),(0,$.jsx)(Mt,{deliveryId:e.prDeliveryId,repositories:e.repositoryDeliveries,busy:B,onAct:(t,n)=>A(t,e.decision,e.prDeliveryId,n),onCheckout:r?j:void 0}),U,e.operation&&(0,$.jsxs)(`span`,{className:`${N} border-accent-info/30 bg-accent-info/10 text-accent-info`,"data-testid":`rail-pr-operation`,children:[(0,$.jsx)(rn,{className:`${L} animate-spin`,"aria-hidden":!0}),i(`railPr.operation.${e.operation}`)]}),be,e.deliverySha&&(0,$.jsxs)(`span`,{className:`${N} ${e.deliveryOutcome===`delivered`?`border-accent-success/30 bg-accent-success/10 text-accent-success`:`border-border/60 bg-surface/60 text-foreground/60`} font-mono`,"data-testid":`rail-pr-delivery-sha`,title:e.deliverySha,children:[(0,$.jsx)(Mo,{className:L,"aria-hidden":!0}),i(`railPr.deliveryCommit`,{sha:e.deliverySha.slice(0,8)})]}),fe,pe,S&&(0,$.jsx)(`span`,{className:`${N} border-border/60 bg-surface/60 text-foreground/55`,"data-testid":`rail-pr-status-code`,children:S}),(x||y.recoveryUnavailable||!b&&e.statusDetail&&!y.recoveryUnavailable||y.cleanupWarnings.length>0)&&(0,$.jsxs)(`div`,{className:`basis-full rounded-md border border-accent-warning/30 bg-accent-warning/10 text-accent-warning ${T?`px-1.5 py-1 text-[9px]`:`px-2 py-1.5 text-[10px]`}`,"data-testid":`rail-pr-delivery-detail`,children:[x&&(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5`,"data-testid":`rail-pr-recovery-interrupted`,children:[(0,$.jsx)(Zs,{className:`${L} mt-px shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:i(`common:prRecovery.interrupted`)})]}),y.recoveryUnavailable&&(0,$.jsx)(`p`,{"data-testid":`rail-pr-recovery-unavailable`,children:i(`railPr.recoveryUnavailableBody`)}),y.recoveryUnavailable&&e.statusDetail&&!b&&(0,$.jsxs)(`details`,{className:`mt-1 text-foreground/60`,"data-testid":`rail-pr-recovery-technical-detail`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground/70`,children:i(`railPr.recoveryDetailSummary`)}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:e.statusDetail})]}),!b&&e.statusDetail&&!y.recoveryUnavailable&&(0,$.jsx)(`p`,{children:e.statusDetail}),y.cleanupWarnings.length>0&&(0,$.jsxs)(`div`,{className:x||!b&&e.statusDetail?`mt-1`:void 0,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:i(`railPr.cleanupIncomplete`,{count:y.cleanupWarnings.length})}),(0,$.jsx)(`ul`,{className:`mt-0.5 list-disc pl-4 text-foreground/60`,children:y.cleanupWarnings.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}-${e}`))})]})]}),y.safetyArchives.length>0&&(0,$.jsxs)(`details`,{className:`basis-full rounded-md border border-accent-info/25 bg-accent-info/5 text-foreground/65 ${T?`px-1.5 py-1 text-[9px]`:`px-2 py-1.5 text-[10px]`}`,"data-testid":`rail-pr-safety-archives`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer font-medium text-accent-info`,children:i(`railPr.safetyArchiveTitle`,{count:y.safetyArchives.length})}),(0,$.jsx)(`p`,{className:`mt-1`,children:i(`railPr.safetyArchiveHint`)}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[0.9em] text-foreground/55`,children:y.safetyArchives.map(e=>(0,$.jsx)(`li`,{className:`break-all`,children:e},e))})]}),(0,$.jsx)(Hn,{open:E(`merge-local`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-merge-local-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.mergeLocalConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.mergeLocalConfirmBody`,{base:e.baseBranch})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:B,"data-testid":`rail-pr-merge-local-confirm-btn`,onClick:()=>k(`merge-local`,`merge-local`),children:i(`railPr.mergeLocal`)})]})]})}),(0,$.jsx)(Hn,{open:E(`discard`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-discard-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(g===`implementation_failed`?`railPr.implementationFailedDiscardTitle`:`railPr.discardConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(g===`implementation_failed`?`railPr.implementationFailedDiscardBody`:`railPr.discardConfirmBody`)}),ee&&(0,$.jsx)(`p`,{className:`mt-2 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-2 py-1.5 text-xs text-accent-warning`,"data-testid":`rail-pr-discard-stacked-note`,children:i(`railPr.discardStackedNote`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:B,"data-testid":`rail-pr-discard-confirm-btn`,onClick:()=>k(`discard`,`discard`),children:i(`railPr.discard`)})]})]})}),(0,$.jsx)(Hn,{open:E(`dismiss`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-dismiss-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.dismissConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.dismissConfirmBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:B,"data-testid":`rail-pr-dismiss-confirm-btn`,onClick:()=>k(`dismiss`,`dismiss`),children:i(`railPr.dismiss`)})]})]})}),(0,$.jsx)(Hn,{open:E(`discard-local`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-discard-local-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.discardLocalConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.discardLocalConfirmBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:B,"data-testid":`rail-pr-discard-local-confirm-btn`,onClick:()=>k(`discard-local`,`discard`),children:i(`railPr.discardLocalResult`)})]})]})}),(0,$.jsx)(Hn,{open:E(`no-changes-done`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-no-changes-done-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.markDoneConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.markDoneConfirmBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:B,"data-testid":`rail-pr-no-changes-done-confirm-btn`,onClick:()=>k(`no-changes-done`,`acknowledge-no-changes`),children:i(`railPr.markDone`)})]})]})}),(0,$.jsx)(Hn,{open:E(`refine`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-refine-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(`railPr.refineConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(`railPr.refineConfirmBody`)})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:B,"data-testid":`rail-pr-refine-confirm-btn`,onClick:()=>k(`refine`,`discard`),children:i(`railPr.refine`)})]})]})}),(0,$.jsx)(Hn,{open:E(`recover-and-retry`),onOpenChange:e=>{e||O()},children:(0,$.jsxs)(Bn,{className:`max-w-sm`,"data-testid":`rail-pr-recover-and-retry-confirm`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:i(ue?`railPr.recheckRecoveryConfirmTitle`:`railPr.recoverAndRetryConfirmTitle`)}),(0,$.jsx)(Mn,{children:i(ue?`railPr.recheckRecoveryConfirmBody`:`railPr.recoverAndRetryConfirmBody`,{branch:e.branch??``})})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,children:i(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:B,onClick:()=>k(`recover-and-retry`,`recover-and-retry`),children:i(ue?`railPr.recheckRecovery`:`railPr.recoverAndRetry`)})]})]})})]})}function LV({railIndex:e,value:t,onChange:n}){let{t:r}=K(`dashboard`),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(``),f=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!i)return;let t=!1;return s(!0),fetch(`${nt()}/rails/${e}/pr-candidates`).then(e=>e.ok?e.json():Promise.reject(Error(`${e.status}`))).then(e=>{t||l(Array.isArray(e.candidates)?e.candidates:[])}).catch(()=>{t||l([])}).finally(()=>{t||s(!1)}),()=>{t=!0}},[i,e]),(0,Q.useEffect)(()=>{if(!i)return;function e(e){f.current&&!f.current.contains(e.target)&&a(!1)}function t(e){e.key===`Escape`&&a(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=e=>{n(e),a(!1),d(``)},m=/^\d{1,9}$/.test(u.trim())?parseInt(u.trim(),10):null;return(0,$.jsxs)(`div`,{ref:f,className:`relative inline-flex items-center`,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`button`,{type:`button`,"data-testid":`rail-target-pr-selector`,title:r(`targetPr.chipTitle`),"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`inline-flex h-5 items-center gap-1 rounded border px-1 text-[10px] transition-colors focus:outline-none focus:ring-1 focus:ring-primary/40 ${t?`border-accent-info/50 text-accent-info hover:text-accent-info`:`border-border/50 bg-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,$.jsx)(R,{className:`h-3 w-3`,"aria-hidden":!0}),t?`#${t.number}`:r(`targetPr.chipNew`)]}),t&&(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`targetPr.clear`),onClick:()=>n(null),className:`ml-0.5 rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(mn,{className:`h-2.5 w-2.5`,"aria-hidden":!0})}),i&&(0,$.jsxs)(`div`,{role:`listbox`,"aria-label":r(`targetPr.chipTitle`),className:`absolute left-0 top-6 z-50 w-72 rounded-lg border border-border bg-popover p-1.5 shadow-xl`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!t,onClick:()=>p(null),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-foreground hover:bg-muted/60`,children:[(0,$.jsx)(R,{className:`h-3 w-3 text-muted-foreground`,"aria-hidden":!0}),r(`targetPr.newPr`)]}),(0,$.jsx)(`div`,{className:`my-1 border-t border-border/60`}),o&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(rn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),r(`targetPr.loading`)]}),!o&&c!==null&&c.length===0&&(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:r(`targetPr.none`)}),!o&&(c??[]).map(e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t?.number===e.number,disabled:e.isCrossRepository,onClick:()=>p({number:e.number,title:e.title,headRefName:e.headRefName}),title:e.isCrossRepository?r(`targetPr.fork`):e.url,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-xs transition-colors ${e.isCrossRepository?`cursor-not-allowed text-muted-foreground/50`:`text-foreground hover:bg-muted/60`}`,children:[e.isCrossRepository?(0,$.jsx)(cs,{className:`mt-0.5 h-3 w-3 shrink-0`,"aria-hidden":!0}):(0,$.jsx)(R,{className:`mt-0.5 h-3 w-3 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`block truncate font-medium`,children:[`#`,e.number,` · `,e.title]}),(0,$.jsxs)(`span`,{className:`block truncate text-[10px] text-muted-foreground`,children:[e.headRefName,e.isCrossRepository&&` — ${r(`targetPr.fork`)}`]})]})]},e.number)),(0,$.jsx)(`div`,{className:`my-1 border-t border-border/60`}),(0,$.jsxs)(`form`,{className:`flex items-center gap-1.5 px-1 py-1`,onSubmit:e=>{e.preventDefault(),m&&p({number:m})},children:[(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),inputMode:`numeric`,placeholder:r(`targetPr.manualPlaceholder`),"aria-label":r(`targetPr.manualPlaceholder`),className:`h-6 w-full rounded border border-border/60 bg-transparent px-1.5 text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-1 focus:ring-primary/40`}),(0,$.jsx)(`button`,{type:`submit`,disabled:!m,className:`h-6 shrink-0 rounded border border-border/60 px-2 text-[10px] text-muted-foreground enabled:hover:text-foreground disabled:opacity-40`,children:r(`targetPr.manualUse`)})]})]})]})}function RV(e){return`rail-${e+1}`}function zV(e){let t=/^rail-(\d+)$/.exec(e);if(!t)return null;let n=parseInt(t[1],10);return!Number.isInteger(n)||n<1?null:n-1}var BV=800;function VV({id:e,label:t,tickets:n,mode:r,status:i,activeJobId:a,profileName:o,aiEngine:s,freestyleModel:c,loopModel:l,providers:u,loopAvailable:d,selectedLoopId:f,reasoningEffort:p,targetPr:m,worktreeSummary:h,prDecision:g,onPrDecision:_,onPrCheckout:v,executionMetric:y,jiggleMode:b,dragHandleListeners:x,dragHandleAttributes:S,density:C=`normal`,onModeChange:w,onProfileChange:T,onEngineChange:E,onFreestyleModelChange:D,onLoopModelChange:O,onLoopChange:k,onEffortChange:A,onTargetPrChange:j,onToggle:M,onTicketClick:N,onDelete:P,onLongPress:F,onRename:I,onTicketMoveToSpecs:L}){let{t:R}=K(`dashboard`),z=zV(e),B=s??u?.[0]??`claude`,ee=dr(B),V=cr(B),H=!!E&&i!==`running`&&(u?.length??0)>1,te=!!T&&i!==`running`&&ee&&r!==`loop`,ne=!!D&&i!==`running`&&r===`freestyle`&&V,re=!!O&&i!==`running`&&r===`loop`,ie=B,ae=fz(ie),oe=l&&(ae.some(e=>e.value===l)||nr(ie)&&gD(l))?l:pz(ie),se=or(B,oe),ce=re&&O?(0,$.jsx)(wV,{provider:ie,value:oe,onChange:O,testId:`loop-model-selector`,ariaLabel:R(`railSelectors.loopModelTitle`)}):null,le=!!k&&i!==`running`,ue=H||ne||re||le,[de,fe]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!de)return;function e(e){e.target?.closest(`[role="menu"]`)||fe(null)}function t(e){e.key===`Escape`&&fe(null)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[de]);let{isOver:pe,setNodeRef:me}=UI({id:e}),{active:he}=BI(),ge=typeof he?.id==`number`,[_e,ve]=(0,Q.useState)(0),[ye,U]=(0,Q.useState)(!1),[be,xe]=(0,Q.useState)(!1),[Se,Ce]=(0,Q.useState)(!1),[W,we]=(0,Q.useState)(``),Te=(0,Q.useRef)(null),Ee=(0,Q.useRef)(null),De=(0,Q.useRef)(null),Oe=(0,Q.useRef)(!1),ke=i===`running`,Ae=!ke,je=(0,Q.useCallback)(()=>{De.current&&=(clearTimeout(De.current),null)},[]),Me=(0,Q.useCallback)(()=>{Ae&&(Oe.current=!1,De.current=setTimeout(()=>{Oe.current=!0,F(),De.current=null},BV))},[Ae,F]),Ne=(0,Q.useCallback)(e=>{let t=e.touches[0];Ee.current={x:t.clientX,y:t.clientY},U(!1),xe(!1),Me()},[Me]),Pe=(0,Q.useCallback)(e=>{if(!Ee.current)return;let t=e.touches[0],n=t.clientX-Ee.current.x,r=t.clientY-Ee.current.y;(Math.abs(n)>10||Math.abs(r)>10)&&je(),Ae&&n<-10&&Math.abs(n)>Math.abs(r)*1.5&&(U(!0),ve(Math.max(n,-150)))},[Ae,je]),Fe=(0,Q.useCallback)(()=>{je(),ye&&(_e<-60&&Ae?(xe(!0),ve(-80)):(ve(0),xe(!1)),U(!1)),Ee.current=null},[_e,ye,Ae,je]),Ie=(0,Q.useCallback)(e=>{e.target.closest(`button`)||Me()},[Me]),Le=(0,Q.useCallback)(()=>{je()},[je]),Re=(0,Q.useCallback)(e=>{if(Oe.current){e.stopPropagation(),Oe.current=!1;return}be&&(xe(!1),ve(0))},[be]),ze=(0,Q.useCallback)(e=>{e.stopPropagation(),xe(!1),ve(0),P()},[P]),Be=b&&Ae?-(Array.from(e).reduce((e,t)=>e+t.charCodeAt(0),0)*53%400):void 0,G=Be===void 0?void 0:{animationDelay:`${Be}ms`};return C===`compact`?(0,$.jsxs)(`div`,{ref:me,"data-testid":`rail-row-compact-${e}`,"data-density":`compact`,onMouseDown:Ie,onMouseUp:Le,onMouseLeave:Le,onClick:Re,style:G,className:`group relative flex flex-col gap-1.5 rounded-xl border bg-card p-2.5 transition-all ${pe?`border-accent-info/60 shadow-[0_0_0_1px_hsl(var(--accent-info)/0.35),0_0_14px_hsl(var(--accent-info)/0.18)]`:ge?`border-dashed border-accent-info/35`:ke?`border-accent-success/40 shadow-sm`:`border-border/40 hover:border-accent-info/30 hover:shadow-md`} ${b&&Ae?`animate-jiggle`:``}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,$.jsx)(`button`,{type:`button`,className:`touch-none cursor-grab active:cursor-grabbing text-muted-foreground/30 hover:text-muted-foreground/70 transition-colors shrink-0`,...x,...S,children:(0,$.jsx)(fs,{className:`w-3 h-3`})}),(0,$.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0 transition-all duration-300 ${ke?`bg-accent-success shadow-[0_0_4px_hsl(var(--accent-success)/0.8)] animate-pulse`:i===`failed`?`bg-accent-warning shadow-[0_0_4px_hsl(var(--accent-warning)/0.6)]`:`bg-muted-foreground/25`}`,"aria-hidden":!0}),Se?(0,$.jsx)(`form`,{className:`flex items-center gap-0.5 min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let t=W.trim();t&&I(t),Ce(!1)},children:(0,$.jsx)(`input`,{ref:Te,type:`text`,value:W,onChange:e=>we(e.target.value),onBlur:()=>{let e=W.trim();e&&I(e),Ce(!1)},onKeyDown:e=>{e.key===`Escape`&&Ce(!1)},className:`flex-1 min-w-0 text-xs font-medium bg-transparent border-b border-accent-info/60 outline-none text-foreground/90 px-0.5`,autoFocus:!0})}):(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation();let n=t.startsWith(`Rail `)?t.slice(5):t;we(n),Ce(!0),setTimeout(()=>Te.current?.select(),0)},className:`flex-1 min-w-0 text-left text-xs font-medium text-foreground/90 hover:text-foreground truncate`,title:t,children:t})]}),n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,"data-testid":`rail-row-compact-tickets-${e}`,children:n.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),N(e)},onMouseDown:t=>{t.button===2&&L&&(t.preventDefault(),t.stopPropagation(),fe({ticketId:e.id,x:t.clientX,y:t.clientY}))},onContextMenu:e=>{L&&(e.preventDefault(),e.stopPropagation())},onPointerDown:e=>e.stopPropagation(),title:`#${e.id} ${e.title}`,className:`inline-flex items-center px-1.5 py-0.5 rounded-md text-[10px] font-mono font-medium border border-accent-info/30 bg-accent-info/10 text-accent-info hover:bg-accent-info/20 hover:border-accent-info/60 transition-colors`,children:[`#`,e.id]},e.id))}),de&&L&&(0,xb.createPortal)((0,$.jsx)(`div`,{role:`menu`,"data-testid":`rail-row-compact-context-menu-${e}`,className:`fixed z-[200] min-w-[160px] rounded-lg border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,style:{top:Math.min(de.y,window.innerHeight-60),left:Math.min(de.x,window.innerWidth-180)},onPointerDown:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{e.stopPropagation(),L(de.ticketId),fe(null)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs text-accent-warning hover:bg-accent-warning/10 transition-colors`,children:[(0,$.jsx)(Rt,{className:`w-3 h-3`,"aria-hidden":!0}),R(`railRow.moveToSpecs`)]})}),document.body),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[E&&!ke&&(0,$.jsx)(CV,{value:s??null,providers:u??[],onChange:E}),T&&!ke&&ee&&r!==`loop`&&(0,$.jsx)(SV,{provider:B,value:o??null,onChange:T}),D&&!ke&&r===`freestyle`&&V&&(0,$.jsx)(wV,{provider:B,value:c??null,onChange:D}),ce,k&&!ke&&(0,$.jsx)(NV,{value:bV(f,r),onChange:k,freestyleAvailable:V,loopsEnabled:d}),A&&!ke&&r===`loop`&&se&&(0,$.jsx)(FV,{provider:B,model:oe,value:p??null,onChange:A}),j&&!ke&&z!==null&&(0,$.jsx)(LV,{railIndex:z,value:m??null,onChange:j}),(0,$.jsx)(hV,{mode:r,status:i,activeJobId:a,ticketCount:n.length,freestyleAvailable:V,loopAvailable:d,onModeChange:w,onToggle:M})]}),ke&&y&&(0,$.jsx)(PV,{metric:y}),h&&(h.merged>0||h.needsReview>0)&&(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px]`,"data-testid":`rail-worktree-summary`,children:[h.merged>0&&(0,$.jsx)(`span`,{className:`text-accent-success`,children:R(`railControls.worktreesMerged`,{count:h.merged})}),h.needsReview>0&&(0,$.jsx)(`span`,{className:`text-accent-warning`,children:R(`railControls.worktreesNeedsReview`,{count:h.needsReview})})]}),g&&_&&(0,$.jsx)(`div`,{className:`mt-1`,children:(0,$.jsx)(IV,{decision:g,density:`compact`,act:_,checkout:v},g.prDeliveryId)}),b&&Ae&&(0,$.jsx)(`button`,{type:`button`,onClick:ze,className:`absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center rounded-full bg-destructive text-destructive-foreground shadow-sm hover:opacity-90 transition-opacity`,"aria-label":R(`railRow.deleteRail`,{label:t}),children:(0,$.jsx)(dn,{className:`w-3 h-3`})})]}):(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl`,onClick:Re,onTouchStart:Ne,onTouchMove:Pe,onTouchEnd:Fe,onMouseDown:Ie,onMouseUp:Le,onMouseLeave:Le,children:[Ae&&(be||_e<0)&&(0,$.jsx)(`div`,{className:`absolute inset-y-0 right-0 w-20 flex items-center justify-center bg-red-500/90 rounded-r-xl z-0`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:ze,className:`flex flex-col items-center gap-1 text-white`,children:[(0,$.jsx)(dn,{className:`w-5 h-5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-medium`,children:R(`common:actions.delete`)})]})}),(0,$.jsxs)(`div`,{className:`relative z-10 flex flex-col rounded-xl border overflow-hidden bg-card ${b&&Ae?`animate-jiggle`:``} ${pe?`border-primary/50 shadow-[0_0_0_1px_hsl(var(--primary)/0.25),0_0_12px_hsl(var(--primary)/0.08)]`:`border-border/40 hover:border-border/60`}`,style:{transform:_e<0?`translateX(${_e}px)`:void 0,transition:ye?`none`:`transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)`,...Be===void 0?{}:{animationDelay:`${Be}ms`}},children:[(0,$.jsxs)(`div`,{className:`flex flex-col border-b border-border/30 bg-gradient-to-r from-muted/30 to-transparent shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`button`,{type:`button`,className:`touch-none cursor-grab active:cursor-grabbing text-muted-foreground/30 hover:text-muted-foreground/60 transition-colors -ml-1`,...x,...S,children:(0,$.jsx)(fs,{className:`w-3.5 h-3.5`})}),(0,$.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0 transition-all duration-300 ${i===`running`?`bg-emerald-400 shadow-[0_0_4px_hsl(142_70%_56%/0.8)] animate-pulse`:i===`failed`?`bg-amber-400 shadow-[0_0_4px_hsl(38_92%_50%/0.6)]`:`bg-muted-foreground/25`}`}),Se?(0,$.jsxs)(`form`,{className:`flex items-center gap-0.5`,onSubmit:e=>{e.preventDefault();let t=W.trim();t&&I(t),Ce(!1)},children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground/50`,children:`Rail `}),(0,$.jsx)(`input`,{ref:Te,type:`text`,value:W,onChange:e=>we(e.target.value),onBlur:()=>{let e=W.trim();e&&I(e),Ce(!1)},onKeyDown:e=>{e.key===`Escape`&&Ce(!1)},className:`w-24 text-xs font-medium bg-transparent border-b border-primary/50 outline-none text-foreground/80 px-0.5`,autoFocus:!0})]}):(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation();let n=t.startsWith(`Rail `)?t.slice(5):t;we(n),Ce(!0),setTimeout(()=>Te.current?.select(),0)},className:`text-xs font-medium text-foreground/80 hover:text-foreground hover:underline decoration-dotted underline-offset-2 cursor-text transition-colors`,children:t}),n.length>0&&(0,$.jsx)(`span`,{className:`text-[9px] text-muted-foreground bg-muted/30 rounded-full px-1.5 py-0.5 leading-none`,children:n.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[!ue&&te&&T&&(0,$.jsx)(SV,{provider:B,value:o??null,onChange:T}),(0,$.jsx)(hV,{mode:r,status:i,activeJobId:a,ticketCount:n.length,freestyleAvailable:V,loopAvailable:d,onModeChange:w,onToggle:M}),b&&Ae&&(0,$.jsx)(`button`,{type:`button`,onClick:ze,className:`w-5 h-5 flex items-center justify-center rounded-full bg-red-500 text-white shadow-sm hover:bg-red-600 transition-colors`,children:(0,$.jsx)(dn,{className:`w-3 h-3`})})]})]}),ke&&y&&(0,$.jsx)(`div`,{className:`px-3 pb-1`,children:(0,$.jsx)(PV,{metric:y})}),h&&(h.merged>0||h.needsReview>0)&&(0,$.jsxs)(`div`,{className:`px-3 pb-1 flex items-center gap-2 text-[10px]`,children:[h.merged>0&&(0,$.jsx)(`span`,{className:`text-accent-success`,children:R(`railControls.worktreesMerged`,{count:h.merged})}),h.needsReview>0&&(0,$.jsx)(`span`,{className:`text-accent-warning`,children:R(`railControls.worktreesNeedsReview`,{count:h.needsReview})})]}),g&&_&&(0,$.jsx)(`div`,{className:`px-3 pb-1.5`,children:(0,$.jsx)(IV,{decision:g,density:`normal`,act:_,checkout:v},g.prDeliveryId)}),ue&&(0,$.jsxs)(`div`,{className:`flex items-center flex-wrap gap-x-3 gap-y-1 px-3 py-1.5 border-t border-border/20 bg-background/20`,children:[H&&E&&(0,$.jsx)(CV,{value:s??null,providers:u??[],onChange:E}),ue&&te&&T&&(0,$.jsx)(SV,{provider:B,value:o??null,onChange:T}),ne&&D&&(0,$.jsx)(wV,{provider:B,value:c??null,onChange:D}),ce,le&&k&&(0,$.jsx)(NV,{value:bV(f,r),onChange:k,freestyleAvailable:V,loopsEnabled:d}),r===`loop`&&!ke&&se&&A&&(0,$.jsx)(FV,{provider:B,model:oe,value:p??null,onChange:A}),j&&!ke&&z!==null&&(0,$.jsx)(LV,{railIndex:z,value:m??null,onChange:j})]})]}),(0,$.jsx)(`div`,{ref:me,"data-drop-target":ge?`available`:void 0,className:`min-h-[56px] px-3 py-2 space-y-1.5 transition-colors duration-150 ${pe?`bg-accent-info/[0.06]`:ge?`bg-accent-info/[0.02]`:`bg-card/20`}`,children:n.length===0?(0,$.jsx)(`div`,{className:`h-10 flex items-center justify-center rounded-lg border border-dashed transition-all duration-150 ${pe?`border-accent-info/60 text-accent-info/80 bg-accent-info/[0.06]`:ge?`border-accent-info/35 text-accent-info/60`:`border-border/25 text-muted-foreground/30`}`,children:(0,$.jsx)(`span`,{className:`text-[10px] select-none`,children:R(pe?`railRow.dropHere`:ge?`railRow.dropOnThisRail`:`railRow.dragSpecsHere`)})}):(0,$.jsx)(pL,{items:n.map(e=>e.id),strategy:lL,children:n.map(e=>(0,$.jsx)(`div`,{onMouseDown:t=>{t.button===2&&L&&(t.preventDefault(),t.stopPropagation(),fe({ticketId:e.id,x:t.clientX,y:t.clientY}))},onContextMenu:e=>{L&&(e.preventDefault(),e.stopPropagation())},children:(0,$.jsx)(ML,{ticket:e,onClick:N,dragDisabled:i===`running`})},e.id))})}),de&&L&&C===`normal`&&(0,xb.createPortal)((0,$.jsx)(`div`,{role:`menu`,"data-testid":`rail-row-normal-context-menu-${e}`,className:`fixed z-[200] min-w-[160px] rounded-lg border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,style:{top:Math.min(de.y,window.innerHeight-60),left:Math.min(de.x,window.innerWidth-180)},onPointerDown:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{e.stopPropagation(),L(de.ticketId),fe(null)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs text-accent-warning hover:bg-accent-warning/10 transition-colors`,children:[(0,$.jsx)(Rt,{className:`w-3 h-3`,"aria-hidden":!0}),R(`railRow.moveToSpecs`)]})}),document.body)]})]})}function HV(e,t,n,r){return{...e,[t]:{...e[t]??{},[n]:r}}}function UV(e){if(!e)return null;let t=Object.values(e);if(t.length===0)return null;let n=0,r=0,i=0;for(let e of t)e===`merged`?n++:e===`needs-review`?r++:e===`failed`&&i++;return{merged:n,needsReview:r,failed:i,reported:t.length}}var WV=`__rail:`;function GV(e){return`${WV}${e}`}function KV(e){return typeof e==`string`&&e.startsWith(`__rail:`)}function qV(e){return e.slice(7)}function JV(e,t,n){let r=new Set(n),i=RV(t),a=e.some(e=>e.id===i);return e.map((e,n)=>(a?e.id===i:n===t)?{...e,status:`idle`,activeJobId:void 0,ticketIds:r.size>0?e.ticketIds.filter(e=>!r.has(e)):[]}:e)}function YV({railId:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=xL({id:GV(e)});return(0,$.jsx)(`div`,{ref:i,style:{transform:_P.Translate.toString(a),transition:o,opacity:s?.4:void 0,position:`relative`,zIndex:s?50:void 0},children:t({listeners:r??{},attributes:n,isDragging:s})})}function XV({rails:e,ticketMap:t,railWorktrees:n,railMetrics:r,railPrDecisions:i,onPrDecision:a,onPrCheckout:o,providers:s,onModeChange:c,onProfileChange:l,onEngineChange:u,onFreestyleModelChange:d,onLoopModelChange:f,loopAvailable:p,onLoopChange:m,onEffortChange:h,onTargetPrChange:g,onToggle:_,onTicketClick:v,onAddRail:y,onDeleteRail:b,onRenameRail:x,onTicketMoveToSpecs:S,onLaunchAll:C,launchAllCount:w}){let{t:T}=K(`dashboard`),E=e.filter(e=>e.status===`running`).length,[D,O]=(0,Q.useState)(!1),k=(0,Q.useRef)(null),[A,j]=(0,Q.useState)(`normal`);(0,Q.useEffect)(()=>{if(typeof ResizeObserver>`u`)return;let e=k.current;if(!e)return;let t=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.width;j(e<320?`compact`:`normal`)}});return t.observe(e),()=>t.disconnect()},[]);let M=(0,Q.useCallback)(()=>{D&&O(!1)},[D]);(0,Q.useEffect)(()=>{if(!D)return;let e=e=>{e.key===`Escape`&&O(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[D]);let N=e.map(e=>GV(e.id));return(0,$.jsxs)(`div`,{ref:k,className:`flex flex-col h-full`,"data-density":A,onClick:M,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12 border-b border-border/40 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(xs,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-accent-secondary`,children:T(`railsBoard.title`)}),E>0&&(0,$.jsx)(`span`,{className:`text-[10px] text-emerald-400 aurora-light:text-accent-success bg-emerald-400/10 aurora-light:bg-accent-success/10 rounded-full px-1.5 py-0.5 font-medium whitespace-nowrap`,children:T(`railsBoard.runningCount`,{count:E})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[C&&(0,$.jsxs)(`button`,{type:`button`,disabled:(w??0)===0,onClick:e=>{e.stopPropagation(),C()},title:T(`railsBoard.launchAllTitle`),className:`flex items-center gap-1.5 h-7 px-2.5 text-xs font-semibold rounded-md border border-emerald-400/50 text-emerald-400 aurora-light:text-accent-success aurora-light:border-accent-success/50 bg-gradient-to-r from-emerald-400/10 to-accent-primary/10 hover:from-emerald-400/20 hover:to-accent-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:from-emerald-400/10 disabled:hover:to-accent-primary/10`,children:[(0,$.jsx)(Xs,{className:`w-3.5 h-3.5`}),T(`railsBoard.launchAll`),(w??0)>0&&(0,$.jsx)(`span`,{className:`text-[10px] font-mono rounded-full bg-emerald-400/15 px-1.5 py-0.5 leading-none`,children:w})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y()},className:`flex items-center gap-1 h-7 px-2.5 text-xs font-medium rounded-md border border-accent-primary/50 text-accent-primary hover:bg-accent-primary/10 transition-colors`,children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5`}),T(`common:actions.add`)]})]})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-3 flex flex-col gap-2.5`,children:(0,$.jsx)(pL,{items:N,strategy:lL,children:e.map((e,y)=>{let C=zV(e.id)??y;return(0,$.jsx)(YV,{railId:e.id,children:({listeners:w,attributes:T})=>(0,$.jsx)(`div`,{"data-tour":y===0?`rail-1`:void 0,children:(0,$.jsx)(VV,{id:e.id,label:e.label,tickets:e.ticketIds.map(e=>t.get(e)).filter(e=>e!==void 0),mode:e.mode,status:e.status,activeJobId:e.activeJobId,profileName:e.profileName??null,aiEngine:e.aiEngine??null,freestyleModel:e.freestyleModel??null,loopModel:e.loopModel??null,worktreeSummary:UV(n?.[C]),prDecision:i?.get(C)??null,onPrDecision:a?(e,t,n,r)=>a(C,e,t,n,r):void 0,onPrCheckout:o?(e,t)=>o(C,e,t):void 0,executionMetric:r?.[C]??null,providers:s,loopAvailable:p,selectedLoopId:e.selectedLoopId??null,reasoningEffort:e.reasoningEffort??null,targetPr:e.targetPr??null,jiggleMode:D,density:A,dragHandleListeners:w,dragHandleAttributes:T,onModeChange:t=>c(e.id,t),onProfileChange:l?t=>l(e.id,t):void 0,onEngineChange:u?t=>u(e.id,t):void 0,onFreestyleModelChange:d?t=>d(e.id,t):void 0,onLoopModelChange:f?t=>f(e.id,t):void 0,onLoopChange:m?t=>m(e.id,t):void 0,onEffortChange:h?t=>h(e.id,t):void 0,onTargetPrChange:g?t=>g(e.id,t):void 0,onToggle:()=>_(e.id),onTicketClick:v,onDelete:()=>b(e.id),onLongPress:()=>O(!0),onRename:t=>x(e.id,t),onTicketMoveToSpecs:S})})},e.id)})})})]})}var ZV=new Set([`editing`,`writing`,`reading`,`searching`,`running`]);function QV(e){return e.length>40?`${e.slice(0,39)}…`:e}function $V(e){return typeof e!=`string`||e.length===0?``:QV(e.replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??``)}function eH(e){return typeof e!=`string`||e.length===0?``:QV((e.trim().split(/\s+/)[0]??``).replace(/^['"`]+/,``))}var tH=/(^|\/)(ba|z|k|da|fi)?sh$/;function nH(e){if(e.length===0||!tH.test(e[0]))return e;let t=e.slice(1).filter(e=>!e.startsWith(`-`));return t.length>0?t:e}function rH(e){return Array.isArray(e)?eH(nH(e.filter(e=>typeof e==`string`)).join(` `)):typeof e!=`string`||e.length===0?``:eH(nH(e.trim().split(/\s+/)).join(` `))}function iH(e){return Array.isArray(e)?nH(e.filter(e=>typeof e==`string`)).join(` `).trim():typeof e!=`string`||e.length===0?``:nH(e.trim().split(/\s+/)).join(` `).trim()}function aH(e){if(typeof e!=`string`)return``;try{let t=JSON.parse(e)?.command;if(Array.isArray(t)||typeof t==`string`)return rH(t)}catch{}return``}function oH(e,t){let n=t??{},r=$V(n.file_path??n.path);switch(typeof e==`string`?e.toLowerCase():``){case`edit`:case`multiedit`:case`notebookedit`:case`update`:case`editfile`:case`strreplace`:case`searchreplace`:return{step:!0,actionKey:`editing`,actionArg:r};case`write`:case`create`:case`writefile`:return{step:!0,actionKey:`writing`,actionArg:r};case`read`:case`readfile`:case`readmediafile`:return{step:!0,actionKey:`reading`,actionArg:r};case`grep`:case`glob`:case`search`:case`websearch`:return{step:!0,actionKey:`searching`,actionArg:QV(String(n.pattern??n.query??``))};case`bash`:case`shell`:return{step:!0,actionKey:`running`,actionArg:rH(n.command)};case`task`:return{step:!0,actionKey:`delegating`,actionArg:QV(String(n.subagent_type??n.description??``).replace(/^sr-/,``))};default:return{step:!0,actionKey:`working`}}}function sH(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e;if(typeof e==`string`)try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}catch{return}}function cH(e){let t=e.event_type,n={};try{let t=JSON.parse(e.payload);t&&typeof t==`object`&&!Array.isArray(t)&&(n=t)}catch{}if(t===`assistant`){let e=n.message?.content;if(Array.isArray(e)){let t=e.filter(e=>e?.type===`tool_use`);if(t.length>0){let e=t[t.length-1];return{...oH(e.name,e.input),stepCount:t.length}}if(e.some(e=>e?.type===`text`))return{step:!0,actionKey:`thinking`}}let t=(Array.isArray(n.tool_calls)?n.tool_calls:[]).flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.function;return!t||typeof t!=`object`||Array.isArray(t)?[]:[t]});if(t.length>0){let e=t[t.length-1];return{...oH(e.name,sH(e.arguments)),stepCount:t.length}}return typeof n.content==`string`||Array.isArray(n.content)&&n.content.length>0?{step:!0,actionKey:`thinking`}:{step:!0}}if(t===`tool_use`)return oH(n.name,n.input);if(t===`item.completed`){let e=n.item,t=e?.type;return t===`agent_message`?{step:!0,actionKey:`thinking`}:t===`agent_reasoning`?{step:!0,actionKey:`reasoning`}:t===`function_call`||t===`local_shell_call`||t===`command_execution`?{step:!0,actionKey:`running`,actionArg:rH(e?.command)||aH(e?.arguments)||(typeof e?.name==`string`?QV(e.name):``)||(t===`local_shell_call`?`shell`:``)}:{step:!0}}return{step:!1}}function lH(e){let t={};try{let n=JSON.parse(e.payload);n&&typeof n==`object`&&!Array.isArray(n)&&(t=n)}catch{return``}if(e.event_type===`assistant`){let e=t.message?.content;if(!Array.isArray(e))return``;for(let t of e){if(t?.type!==`tool_use`)continue;let e=t.input?.command;if(e)return iH(e)}return``}if(e.event_type===`item.completed`){let e=t.item;if(!e)return``;if(e.command)return iH(e.command);if(typeof e.arguments==`string`)try{let t=JSON.parse(e.arguments);if(t?.command)return iH(t.command)}catch{return``}}return``}var uH=(0,Q.createContext)({});function dH(){return(0,Q.useContext)(uH)}function fH({activeProjectId:e,children:t}){let[n,r]=(0,Q.useState)(new Map),{registerHandler:i,unregisterHandler:a}=qe(),o=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{o.current=e},[e]),(0,Q.useEffect)(()=>{if(r(new Map),!e)return;let t=!1;return fetch(`/api/projects/${e}/rails`).then(e=>e.ok?e.json():null).then(e=>{if(t||!e?.activeLoopRuns)return;let n=new Map;for(let[t,r]of Object.entries(e.activeLoopRuns))r?.loopRunId&&n.set(r.loopRunId,{railIndex:Number(t),startedAt:r.startedAt?new Date(r.startedAt).getTime():Date.now(),steps:r.steps??0,lines:r.lines??0});n.size!==0&&r(e=>{let t=new Map(e);for(let[e,r]of n)t.has(e)||t.set(e,r);return t})}).catch(()=>{}),()=>{t=!0}},[e]);let s=(0,Q.useCallback)(e=>{let t=e;if(!(!t||typeof t.type!=`string`)){if(t.type===`loop.run_started`){if(t.projectId!==o.current||!t.loopRunId)return;r(e=>{let n=new Map(e);return n.set(t.loopRunId,{railIndex:t.railIndex??0,startedAt:Date.now(),steps:0,lines:0}),n});return}if(t.type===`loop.run_completed`){r(e=>{if(!t.loopRunId||!e.has(t.loopRunId))return e;let n=new Map(e);return n.delete(t.loopRunId),n});return}if(t.type===`rail.job_started`){if(t.projectId!==o.current||!t.jobId||t.railIndex==null)return;r(e=>{let n=new Map(e);return n.set(t.jobId,{railIndex:t.railIndex,startedAt:Date.now(),steps:0,lines:0}),n});return}if(t.type===`rail.job_completed`||t.type===`rail.job_stopped`){r(e=>{if(!t.jobId||!e.has(t.jobId))return e;let n=new Map(e);return n.delete(t.jobId),n});return}if(t.type===`event`&&t.event_type&&t.jobId){let e=cH({event_type:t.event_type,payload:t.payload??``});if(!e.step)return;r(n=>{let r=n.get(t.jobId);if(!r)return n;let i=new Map(n);return i.set(t.jobId,{...r,steps:r.steps+(e.stepCount??1)}),i});return}t.type===`log`&&t.processId&&r(e=>{let n=e.get(t.processId);if(!n)return e;let r=new Map(e);return r.set(t.processId,{...n,lines:n.lines+1}),r})}},[]);(0,Q.useLayoutEffect)(()=>(i(`rail-exec-metrics`,s),()=>a(`rail-exec-metrics`)),[s,i,a]);let c=(0,Q.useMemo)(()=>{let e={};for(let t of n.values()){let n=e[t.railIndex];n?(n.startedAt=Math.min(n.startedAt,t.startedAt),n.steps+=t.steps,n.lines+=t.lines):e[t.railIndex]={startedAt:t.startedAt,steps:t.steps,lines:t.lines}}return e},[n]);return(0,$.jsx)(uH.Provider,{value:c,children:t})}var pH=(0,Q.createContext)({decisions:new Map,hydrated:!0,act:async()=>({status:0,ok:!1,error:`no_provider`}),checkout:async()=>({status:0,ok:!1,error:`no_provider`})});function mH(){return(0,Q.useContext)(pH)}function hH(e,t){return ut(e,t)}var gH=new Set([`merged`,`discarded`,`completed`,`superseded`]),_H=new Set([`create-pr`,`publish`,`discard`,`poll-merge`,`merge-local`,`dismiss`,`reopen`,`acknowledge-no-changes`,`recover-and-retry`]);function vH(e,t){return JSON.stringify(e)===JSON.stringify(t)}function yH({activeProjectId:e,children:t}){let{t:n}=K(`dashboard`),[r,i]=(0,Q.useState)(new Map),[a,o]=(0,Q.useState)(!1),{registerHandler:s,unregisterHandler:c,connectionStatus:l}=qe(),u=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{u.current=e},[e]);let d=(0,Q.useRef)(r),f=(0,Q.useRef)(new Map),p=(0,Q.useRef)(0),m=(0,Q.useRef)(new Set),h=(0,Q.useRef)(new Map),g=(0,Q.useRef)(new Set),_=(0,Q.useRef)(new Map),v=(0,Q.useCallback)((e,t=!0)=>{let r=d.current,a=r.get(e.railIndex),o=gH.has(e.decision),s=e.restoredFromDeliveryId??null,c=h.current.get(e.prDeliveryId),l=a?.supersedesDeliveryId===e.prDeliveryId?a.prDeliveryId:null,u=!!(s&&_.current.get(e.prDeliveryId)!==s&&(!c||c===s)&&(!l||l===s));if(a?.prDeliveryId===e.prDeliveryId){let t=Ft(a.updatedAt,e.updatedAt);if(t===-1||t===0&&!vH(a,e))return`stale`;if(t===0&&vH(a,e))return`accepted`}if(!o&&(g.current.has(e.prDeliveryId)||m.current.has(e.prDeliveryId))&&!u)return`stale`;let p=!1;if(a&&a.prDeliveryId!==e.prDeliveryId)if(u&&a.prDeliveryId===s)p=!0;else{let t=e.supersedesDeliveryId===a.prDeliveryId,n=a.supersedesDeliveryId===e.prDeliveryId||m.current.has(e.prDeliveryId),r=e.createdAt?Date.parse(e.createdAt):NaN,i=a.createdAt?Date.parse(a.createdAt):NaN;if(n||!t&&!(Number.isFinite(r)&&Number.isFinite(i)&&r>i))return o&&g.current.add(e.prDeliveryId),e.decision===`superseded`&&m.current.add(e.prDeliveryId),o?`untracked`:`stale`;p=!0}if(u&&s&&(g.current.delete(e.prDeliveryId),m.current.delete(e.prDeliveryId),g.current.add(s),_.current.set(e.prDeliveryId,s),h.current.set(e.prDeliveryId,s)),o){if(g.current.add(e.prDeliveryId),e.decision===`superseded`&&m.current.add(e.prDeliveryId),!a||a.prDeliveryId!==e.prDeliveryId)return`untracked`;if(t){if(e.safetyArchives?.length){let t=e.safetyArchives.join(`
|
|
69
69
|
`);J.warning(n(`railPr.safetyArchiveTitle`,{count:e.safetyArchives.length}),{description:`${n(`railPr.safetyArchiveHint`)}\n${t}`,duration:1/0,action:{label:n(`railPr.copySafetyArchive`),onClick:()=>{navigator.clipboard?.writeText(t)}}})}if(e.cleanupWarnings?.length){let t=e.cleanupWarnings.join(`
|
|
70
|
-
`);J.warning(n(`railPr.cleanupIncomplete`,{count:e.cleanupWarnings.length}),{description:`${n(`railPr.cleanupIncompleteHint`)}\n${t}`,duration:1/0,action:{label:n(`railPr.copyCleanupDetails`),onClick:()=>{navigator.clipboard?.writeText(t)}}})}else e.decision===`merged`?J.success(n(`railPr.mergedToast`)):e.decision===`discarded`?J.info(n(`railPr.discardedToast`)):e.decision===`completed`&&J.success(n(`railPr.completedToast`))}}else e.supersedesDeliveryId&&(m.current.add(e.supersedesDeliveryId),h.current.set(e.supersedesDeliveryId,e.prDeliveryId)),p&&a&&m.current.add(a.prDeliveryId);let v=new Map(r);return o?v.delete(e.railIndex):v.set(e.railIndex,e),f.current.set(e.railIndex,(f.current.get(e.railIndex)??0)+1),d.current=v,i(v),`accepted`},[n]),y=(0,Q.useCallback)(async(e,t)=>{let n=++p.current,r=new Map(f.current);try{let t=await fetch(`/api/projects/${e}/rails`);if(!t.ok)return;let a=await t.json();if(n!==p.current||u.current!==e)return;let o=new Map;for(let[e,t]of Object.entries(a.prDeliveries??{})){let n=hH(t,Number(e)),r=d.current.get(n?.railIndex??Number(e)),i=n?.restoredFromDeliveryId??null,a=n?h.current.get(n.prDeliveryId):void 0,s=n&&r?.supersedesDeliveryId===n.prDeliveryId?r.prDeliveryId:null,c=!!(n&&i&&_.current.get(n.prDeliveryId)!==i&&(!a||a===i)&&(!s||s===i));n&&!gH.has(n.decision)&&(c||!g.current.has(n.prDeliveryId)&&!m.current.has(n.prDeliveryId))&&o.set(Number(e),n)}let s=d.current,c=new Map(o);for(let[e,t]of f.current){if(t===(r.get(e)??0))continue;let n=s.get(e);n?c.set(e,n):c.delete(e)}for(let e of c.values()){e.supersedesDeliveryId&&(m.current.add(e.supersedesDeliveryId),h.current.set(e.supersedesDeliveryId,e.prDeliveryId));let t=e.restoredFromDeliveryId;t&&_.current.get(e.prDeliveryId)!==t&&(!h.current.get(e.prDeliveryId)||h.current.get(e.prDeliveryId)===t)&&(g.current.delete(e.prDeliveryId),m.current.delete(e.prDeliveryId),g.current.add(t),_.current.set(e.prDeliveryId,t),h.current.set(e.prDeliveryId,t))}d.current=c,i(c)}catch{}finally{t&&n===p.current&&u.current===e&&o(!0)}},[]);(0,Q.useEffect)(()=>{u.current=e,p.current++;let t=new Map;if(d.current=t,i(t),o(!1),f.current=new Map,m.current=new Set,h.current=new Map,g.current=new Set,_.current=new Map,!e){o(!0);return}y(e,!0)},[e,y]);let b=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`rail.pr_state`||t.projectId!==u.current||typeof t.railIndex!=`number`||typeof t.prDeliveryId!=`string`||!t.decision)return;let n=ut(t,t.railIndex);n&&v(n)},[v]);(0,Q.useLayoutEffect)(()=>(s(`rail-pr-decision`,b),()=>c(`rail-pr-decision`)),[b,s,c]),(0,Q.useEffect)(()=>{let e=()=>{let e=u.current;e&&y(e,!1)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]);let x=(0,Q.useRef)(l);(0,Q.useEffect)(()=>{let e=x.current;x.current=l;let t=u.current;t&&l===`connected`&&e!==`connected`&&y(t,!1)},[l,y]);let S=(0,Q.useCallback)(async(e,t,n,r,i)=>{let a=d.current.get(e),o=u.current;if(!a||!o)return{status:0,ok:!1,error:`no_delivery`};if(a.prDeliveryId!==r)return{status:409,ok:!1,error:`stale_decision`,current:a.decision,snapshotApplication:`stale`};try{let e=await fetch(`/api/projects/${o}/rails/pr-decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:a.prDeliveryId,action:t,expectedDecision:n,...i?{repositoryId:i}:{}})}),r=await e.json().catch(()=>({})),s=ut(r.snapshot),c;return s&&u.current===o&&(c=v(s)),{...r,snapshot:s,snapshotApplication:c,busy:e.status===409&&r.error===`operation_in_progress`,operation:s?.operation??(typeof r.operation==`string`&&_H.has(r.operation)?r.operation:null),status:e.status,ok:e.ok&&r.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[v]),C=(0,Q.useCallback)(async(e,t,n)=>{let r=d.current.get(e),i=u.current;if(!r||!i)return{status:0,ok:!1,error:`no_delivery`};if(r.prDeliveryId!==t)return{status:409,ok:!1,error:`stale_decision`,detail:`The delivery generation changed before checkout.`};try{let e=await fetch(`/api/projects/${i}/rails/pr-checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:r.prDeliveryId,...n?{repositoryId:n}:{}})}),t=await e.json().catch(()=>({}));return{...t,status:e.status,ok:e.ok&&t.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[]),w=(0,Q.useMemo)(()=>({decisions:r,hydrated:a,act:S,checkout:C}),[r,a,S,C]);return(0,$.jsx)(pH.Provider,{value:w,children:t})}function bH(e){return e?`specrails-desktop:dashboard-split:${e}`:null}function xH(e){let t=bH(e);if(!t)return null;try{let e=localStorage.getItem(t);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function SH(e,t){let n=bH(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function CH(e,t){let n=Math.max(320,t-280);return Math.min(Math.max(e,320),n)}var wH=.7;function TH(e){return CH(Math.round(e*wH),e)}function EH(e,t){let n=TH(t);return Math.abs(e-n)<=48?n:e}function DH(e,t){let[n,r]=(0,Q.useState)(()=>typeof window<`u`?window.innerWidth:1200),i=(0,Q.useRef)(n),[a,o]=(0,Q.useState)(()=>{if(typeof window>`u`)return null;let e=window.innerWidth;return e<900?null:TH(e)}),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(typeof window>`u`)return;let e=t?.current?.clientWidth||window.innerWidth;if(r(e),i.current=e,e<900){o(null);return}o(TH(e))},[e,t]),(0,Q.useEffect)(()=>{function n(t){if(r(t),t<900){i.current=t,o(null);return}let n=t-i.current;i.current=t,o(r=>{let i=r??xH(e)??TH(t),a=CH(r!==null&&Number.isFinite(n)?i+n:i,t);return a!==r&&SH(e,a),a})}let a=t?.current;if(a&&typeof ResizeObserver<`u`){let e=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&n(t)});return e.observe(a),n(a.clientWidth||window.innerWidth),()=>e.disconnect()}function s(){n(window.innerWidth)}return window.addEventListener(`resize`,s),()=>window.removeEventListener(`resize`,s)},[e,t]);let u=(0,Q.useCallback)(()=>{if(c.current=null,l.current===null)return;let e=CH(l.current,n);l.current=null,o(e)},[n]),d=(0,Q.useCallback)(e=>{if(!s.current)return;let t=e.clientX-s.current.startClientX;l.current=s.current.startLeftWidth+t,c.current===null&&(c.current=requestAnimationFrame(u))},[u]),f=(0,Q.useCallback)(t=>{if(!s.current)return;let{pointerId:r,element:i}=s.current;try{i.releasePointerCapture(r)}catch{}s.current=null,window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),o(t=>{if(t===null)return t;let r=CH(EH(t,n),n);return SH(e,r),r})},[d,e,n]),p=(0,Q.useCallback)(e=>{let t=e.nativeEvent??e,n=e.currentTarget??t.target;try{n.setPointerCapture(t.pointerId)}catch{}s.current={pointerId:t.pointerId,element:n,startClientX:t.clientX,startLeftWidth:a??0},window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[d,f,a]),m=(0,Q.useCallback)(()=>{if(typeof window>`u`)return;let n=t?.current?.clientWidth||window.innerWidth;if(n<900)return;let r=TH(n);o(r),SH(e,r)},[e,t]);return{leftWidth:a,enabled:a!==null&&n>=900,beginDrag:p,resetToDefault:m}}function OH({leftWidth:e,onPointerDown:t,onReset:n,viewport:r}){let i=(0,Q.useCallback)(t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`&&(t.preventDefault(),e-n)},[e]);return(0,$.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":e,"aria-valuemin":320,"aria-valuemax":Math.max(320,r-280),tabIndex:0,onPointerDown:t,onDoubleClick:n,onKeyDown:i,className:`relative w-1.5 shrink-0 cursor-col-resize group select-none touch-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/60`,"data-testid":`dashboard-splitter`,children:[(0,$.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border/40 group-hover:bg-accent-info/40 group-focus-visible:bg-accent-info/60 transition-colors`}),(0,$.jsxs)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 flex flex-col items-center justify-center gap-1 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`})]})]})}function kH({open:e,allLabels:t,onClose:n,onCreate:r}){let{t:i}=K(`tickets`),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(`todo`),[d,f]=(0,Q.useState)(`medium`),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e&&setTimeout(()=>x.current?.focus(),100)},[e]),(0,Q.useEffect)(()=>{e||(o(``),c(``),u(`todo`),f(`medium`),m([]),g(void 0),v(``))},[e]);let C=(0,Q.useMemo)(()=>{if(!_.trim())return[];let e=_.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!p.includes(t)).slice(0,5)},[_,t,p]),w=(0,Q.useCallback)(e=>{let t=e.trim();t&&!p.includes(t)&&m(e=>[...e,t]),v(``)},[p]),T=(0,Q.useCallback)(async()=>{if(!a.trim())return;b(!0);let e=await r({title:a.trim(),description:s.trim()||void 0,status:l,priority:d,labels:p.length>0?p:void 0,...h?{repositoryIds:h}:{}});b(!1),e?(J.success(i(`createModal.toast.created`)),n()):J.error(i(`createModal.toast.createFailed`))},[a,s,l,d,p,h,r,n,i]);return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>!e&&n(),children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-lg glass-card`,children:[(0,$.jsx)(Rn,{children:(0,$.jsx)(Fn,{children:i(`createModal.title`)})}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:[i(`fields.title`),` `,(0,$.jsx)(`span`,{className:`text-red-400 aurora-light:text-destructive`,children:`*`})]}),(0,$.jsx)(`input`,{ref:x,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a.trim()&&T()},placeholder:i(`createModal.titlePlaceholder`),className:`w-full h-8 rounded border border-border bg-input px-3 text-xs text-foreground placeholder:text-muted-foreground`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.description`)}),(0,$.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:4,placeholder:i(`fields.markdownPlaceholder`),className:`w-full rounded border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-y min-h-[80px]`}),(0,$.jsx)(`span`,{className:`text-[9px] text-muted-foreground mt-0.5 block`,children:i(`fields.supportsMarkdown`)})]}),(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.status`)}),(0,$.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:[(0,$.jsx)(`option`,{value:`todo`,children:i(`ticketStatus.todo`)}),(0,$.jsx)(`option`,{value:`in_progress`,children:i(`ticketStatus.inProgress`)}),(0,$.jsx)(`option`,{value:`done`,children:i(`ticketStatus.done`)}),(0,$.jsx)(`option`,{value:`cancelled`,children:i(`ticketStatus.cancelled`)})]})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.priority`)}),(0,$.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:[(0,$.jsx)(`option`,{value:`critical`,children:i(`priority.critical`)}),(0,$.jsx)(`option`,{value:`high`,children:i(`priority.high`)}),(0,$.jsx)(`option`,{value:`medium`,children:i(`priority.medium`)}),(0,$.jsx)(`option`,{value:`low`,children:i(`priority.low`)})]})]})]}),(0,$.jsx)(tr,{value:h,onChange:g,disabled:y}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.labels`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:p.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium bg-accent/60 text-foreground/70`,children:[e,(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(t=>t.filter(t=>t!==e)),className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,$.jsx)(en,{className:`w-2.5 h-2.5`})})]},e))}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{ref:S,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_.trim()&&(e.preventDefault(),w(_))},placeholder:i(`createModal.labelsPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),C.length>0&&(0,$.jsx)(`div`,{className:`absolute left-0 right-0 top-full mt-0.5 rounded border border-border/50 bg-popover shadow-lg z-10 py-0.5`,children:C.map(e=>(0,$.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),w(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]})]})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:n,children:i(`common:actions.cancel`)}),(0,$.jsxs)(Z,{size:`sm`,onClick:T,disabled:y||!a.trim(),children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5 mr-1`}),i(y?`createModal.creating`:`createModal.create`)]})]})]})})}function AH({open:e,railLabel:t,specCount:n,provider:r=`claude`,model:i,onConfirm:a,onCancel:o}){let{t:s}=K(`dashboard`),c=(0,Q.useRef)(null),l=ur(r);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),a())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,a]),(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30`,children:(0,$.jsx)(un,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:s(`freestyleDialog.title`)}),(0,$.jsxs)(Mn,{children:[s(`freestyleDialog.context`,{rail:t,count:n}),i?` · ${i}`:``]})]})]})}),(0,$.jsxs)(`ul`,{className:`space-y-2.5 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.noPipelineTitle`)}),` `,s(`freestyleDialog.noPipelineBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(So,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.autonomyTitle`,{provider:l})}),` `,s(`freestyleDialog.autonomyBody`,{provider:l})]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(Jo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.costTitle`)}),` `,s(`freestyleDialog.costBody`,{provider:l})]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:o,children:s(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:c,className:`h-9 gap-2 bg-emerald-500 text-white hover:bg-emerald-400 focus-visible:ring-emerald-400`,onClick:a,children:[s(`freestyleDialog.continue`),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:`⌘↵`})]})]})]})})}function jH(e,t=typeof navigator>`u`?``:navigator.platform){return/Mac|iPhone|iPad/i.test(t)?e:e.replace(/⌥/g,`Alt+`).replace(/⌘/g,`Ctrl+`).replace(/⇧/g,`Shift+`).replace(/[⏎↵]/g,`Enter`)}function MH({open:e,railCount:t,specCount:n,onConfirm:r,onCancel:i}){let{t:a}=K(`dashboard`),o=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),r())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),o.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-primary/15 text-accent-primary ring-1 ring-accent-primary/30`,children:(0,$.jsx)(Xs,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:a(`launchAllDialog.title`)}),(0,$.jsxs)(Mn,{children:[a(`launchAllDialog.railsCount`,{count:t}),` · `,a(`launchAllDialog.specsCount`,{count:n})]})]})]})}),(0,$.jsxs)(`ul`,{className:`space-y-2.5 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.isolationTitle`)}),` `,a(`launchAllDialog.isolationBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(xs,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-secondary`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.pipelinesTitle`,{count:t})}),` `,a(`launchAllDialog.pipelinesBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(Jo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.costTitle`)}),` `,a(`launchAllDialog.costBody`)]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:i,children:a(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:o,className:`h-9 gap-2 bg-emerald-500 text-white hover:bg-emerald-400 focus-visible:ring-emerald-400`,onClick:r,children:[a(`launchAllDialog.launch`,{count:t}),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:jH(`⌘↵`)})]})]})]})})}function NH({open:e,target:t,onConfirm:n,onCancel:r}){let{t:i}=K(`dashboard`),a=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),n())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n]),t?(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||r()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),a.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-info/15 text-accent-info ring-1 ring-accent-info/30`,children:(0,$.jsx)(R,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:i(`targetPr.confirmTitle`)}),(0,$.jsx)(Mn,{children:i(`targetPr.confirmBody`)})]})]})}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 bg-muted/30 p-3 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(R,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 font-medium text-foreground`,children:[`#`,t.number,t.title?` · ${t.title}`:``]})]}),t.headRefName&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-muted-foreground`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 truncate`,children:[i(`targetPr.confirmBranch`),`: `,(0,$.jsx)(`span`,{className:`font-mono`,children:t.headRefName})]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:r,children:i(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:a,className:`h-9 gap-2 bg-accent-info text-white hover:bg-accent-info/85 focus-visible:ring-accent-info`,onClick:n,children:[i(`targetPr.confirmLaunch`,{number:t.number}),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:jH(`⌘↵`)})]})]})]})}):null}var PH=`postit`,FH=e=>`specrails-desktop:specs-view-tier:${e}`;function IH(e){return e===`row`||e===`postit`}function LH(e){if(!e)return PH;try{let t=localStorage.getItem(FH(e));if(IH(t))return t}catch{}return PH}function RH(e,t){if(e)try{localStorage.setItem(FH(e),t)}catch{}}function zH(e,t,n){if(typeof n==`number`&&n===t)return e;if(typeof n==`number`&&e.includes(n)){let r=e.indexOf(n),i=[...e];return i.splice(r,0,t),i}return[...e,t]}function BH(e,t,n,r,i){if(typeof e==`string`){if(r(e)){let n=i(e);return t.has(n)?n:null}return t.has(e)?e:null}if(typeof e==`number`){let r=n(e);return r&&t.has(r)?r:null}return null}var VH=[{id:`rail-1`,label:`Rail 1`,ticketIds:[],mode:`implement`,status:`idle`},{id:`rail-2`,label:`Rail 2`,ticketIds:[],mode:`implement`,status:`idle`},{id:`rail-3`,label:`Rail 3`,ticketIds:[],mode:`implement`,status:`idle`}],HH=e=>e===`implement`||e===`batch-implement`||e===`freestyle`||e===`loop`;function UH(e,t){if(!e||e.decision!==`pr_draft`&&e.decision!==`pr_ready`||!e.prUrl||!e.branch)return!1;let n=new Set(e.ticketIds);return t.length>0&&t.every(e=>n.has(e))}function WH(e,t){for(let n of t.values())if(UH(n,[e]))return!0;return!1}function GH(e){if(!e)return null;try{let t=localStorage.getItem(`specrails-desktop:spec-order:${e}`);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function KH(e,t){if(e)try{t?localStorage.setItem(`specrails-desktop:spec-order:${e}`,JSON.stringify(t)):localStorage.removeItem(`specrails-desktop:spec-order:${e}`)}catch{}}function qH(e){if(!e)return null;try{let t=localStorage.getItem(`specrails-desktop:rails:${e}`);if(!t)return null;let n=JSON.parse(t);return!Array.isArray(n)||n.length===0?null:n}catch{return null}}function JH(e,t){if(e)try{localStorage.setItem(`specrails-desktop:rails:${e}`,JSON.stringify(t))}catch{}}function YH(){let{t:e}=K(`dashboard`),{activeProjectId:t,projects:n}=at(),r=ca().id===`galaxy`,i=(()=>{let e=n.find(e=>e.id===t);return e?rt(e):[`claude`]})(),{tickets:a,isLoading:o,error:s,updateTicket:c,updateTicketStatus:l,updateTicketPriority:u,deleteTicket:d,createTicket:f,refetch:p,contractRefiningIds:m}=T(),{registerHandler:h,unregisterHandler:g,connectionStatus:_}=qe(),{specToOpen:v,clearSpecToOpen:y}=tz(),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!v||v.projectId!==t||(x(v.ticket),p(),y())},[v,t,p,y]);let[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(()=>GH(t)),[L,R]=(0,Q.useState)(()=>qH(t)??VH),[z,B]=(0,Q.useState)({}),ee=dH(),{decisions:V,hydrated:H,act:te,checkout:ne}=mH(),re=AR(t),[ie,ae]=(0,Q.useState)(re.mode),[oe,se]=(0,Q.useState)(re.dir),[ce,le]=(0,Q.useState)(()=>LH(t));(0,Q.useEffect)(()=>{I(GH(t)),R(qH(t)??VH),B({});let e=AR(t);ae(e.mode),se(e.dir),le(LH(t))},[t]);let ue=(0,Q.useCallback)((e,n)=>{ae(e),se(n),jR(t,e,n)},[t]),de=(0,Q.useCallback)(e=>{le(e),RH(t,e)},[t]);(0,Q.useEffect)(()=>{if(_!==`connected`||!t)return;let e=!1,n=qH(t)??VH,r=new Map(n.map(e=>[e.id,e]));return fetch(`${nt()}/rails`).then(e=>e.ok?e.json():null).then(n=>{if(e||!n)return;let i=n.activeJobs??{},a=n.activeLoopRuns??{},o=new Set([...Object.keys(i).map(Number),...Object.keys(a).map(Number)]),s=n.rails??[],c=new Map;for(let e of s)c.set(e.railIndex,Array.isArray(e.ticketIds)?e.ticketIds:[]);let l=new Set(s.map(e=>e.railIndex));R(e=>{let n=!1,u=new Map,d=e.map((e,t)=>{let s=zV(e.id)??t,l=a[String(s)],d=i[String(s)]?.jobId??l?.loopRunId;if(o.has(s)){if(e.status===`running`)return d&&!e.activeJobId?(n=!0,{...e,activeJobId:d}):e;if(r.get(e.id)?.status===`running`)return e;let t=c.get(s)??[],a=i[String(s)]?.mode,o=HH(a)?a:l?yV(l.loopId):void 0,f=t.length?t:e.ticketIds;return u.set(e.id,f),n=!0,{...e,status:`running`,activeJobId:d,ticketIds:f,mode:o??e.mode,...l?.loopId&&l.loopId.startsWith(`custom:`)?{selectedLoopId:l.loopId}:{}}}return e.status!==`running`||r.get(e.id)?.status!==`running`?e:(n=!0,{...e,status:`idle`,activeJobId:void 0,ticketIds:[]})}),f=new Set(d.map(e=>e.id)),p=[];for(let e of s){let t=RV(e.railIndex);if(f.has(t))continue;let r=a[String(e.railIndex)],s=i[String(e.railIndex)]?.mode,l=HH(s)?s:r?yV(r.loopId):HH(e.mode)?e.mode:`implement`,d=o.has(e.railIndex),m=c.get(e.railIndex)??[];p.push({id:t,label:e.name?`Rail ${e.name}`:`Rail ${e.railIndex+1}`,ticketIds:m,mode:l,status:d?`running`:`idle`,activeJobId:i[String(e.railIndex)]?.jobId??r?.loopRunId,...r?.loopId&&r.loopId.startsWith(`custom:`)?{selectedLoopId:r.loopId}:{}}),m.length>0&&u.set(t,m),n=!0}let m=p.length>0?[...d,...p]:d;if(s.length>0){let e=m.filter(e=>{let t=zV(e.id);return t===null||l.has(t)||!r.has(e.id)?!0:e.status===`running`||e.ticketIds.length>0});e.length!==m.length&&(m=e,n=!0)}if(!n)return e;let h=new Set([...u.values()].flat()),g=h.size?m.map(e=>{if(u.has(e.id))return e;let t=e.ticketIds.filter(e=>!h.has(e));return t.length===e.ticketIds.length?e:{...e,ticketIds:t}}):m;return JH(t,g),g})}).catch(()=>{}),()=>{e=!0}},[t,_]),(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`${nt()}/rails`).then(e=>e.ok?e.json():null).then(n=>{if(e||!n?.rails)return;let r=new Map;for(let e of n.rails)r.set(e.railIndex,e.name??null);R(e=>{let n=!1,i=e.map((e,t)=>{let i=zV(e.id)??t,a=r.get(i)??null;if(!a)return e;let o=`Rail ${a}`;return o===e.label?e:(n=!0,{...e,label:o})});return n?(JH(t,i),i):e})}).catch(()=>{}),()=>{e=!0}},[t]),(0,Q.useEffect)(()=>{let e=new Set(a.filter(e=>e.status===`done`||H&&e.status===`on_review`&&!WH(e.id,V)).map(e=>e.id));e.size!==0&&R(n=>{let r=n.map(t=>{let n=t.ticketIds.filter(t=>!e.has(t));return n.length===t.ticketIds.length?t:{...t,ticketIds:n}});return r.every((e,t)=>e===n[t])?n:(JH(t,r),r)})},[a,t,L,V,H]);let fe=(0,Q.useCallback)(e=>{I(n=>{let r=e(n);return KH(t,r),r})},[t]),pe=(0,Q.useCallback)(e=>{R(n=>{let r=e(n);return JH(t,r),r})},[t]),me=(0,Q.useMemo)(()=>{let e=new Set([`specs`,`done-specs`]);for(let t of L)e.add(t.id);return e},[L]),he=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${nt()}/rails`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(t.ok){let n=(await t.json()).rail?.railIndex;if(typeof n==`number`){let t=RV(n);pe(e=>e.some(e=>e.id===t)?e:[...e,{id:t,label:`Rail ${n+1}`,ticketIds:[],mode:`implement`,status:`idle`}]),J.success(e(`toasts.railAdded`,{n:n+1}));return}}else{let n=await t.json().catch(()=>({error:``}));if(n.error===`rail_limit_reached`){J.error(e(`toasts.railLimitReached`,{max:n.maxRails??12}));return}}}catch{}let t=L.map(e=>zV(e.id)).filter(e=>e!==null),n=t.length>0?Math.max(...t)+2:1,r={id:`rail-${n}`,label:`Rail ${n}`,ticketIds:[],mode:`implement`,status:`idle`};pe(e=>[...e,r]),J.success(e(`toasts.railAdded`,{n}))},[L,pe,e]),_e=(0,Q.useCallback)(async t=>{let n=L.find(e=>e.id===t);if(!n||n.status===`running`)return;let r=()=>{n.ticketIds.length>0&&fe(e=>[...e??[],...n.ticketIds]),pe(e=>e.filter(e=>e.id!==t)),J.info(e(`toasts.railRemoved`,{rail:n.label}))},i=zV(t);if(i===null){r();return}try{let t=await fetch(`${nt()}/rails/${i}`,{method:`DELETE`});if(t.ok||t.status===404){r();return}J.error(e(`toasts.railDeleteFailed`))}catch{J.error(e(`toasts.railDeleteFailed`))}},[L,pe,fe,e]),ve=(0,Q.useCallback)((e,t)=>{pe(n=>n.map(n=>n.id===e?{...n,label:`Rail ${t}`}:n));let n=zV(e);n!==null&&fetch(`${nt()}/rails/${n}/name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})}).catch(()=>{})},[pe]),ye=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{ye.current=t},[t]);let U=(0,Q.useCallback)(t=>{let n=t;if(n.projectId===ye.current){if(n.type===`rail.job_started`||n.type===`loop.run_started`){if(n.railIndex==null)return;let e=RV(n.railIndex),t=n.jobId??n.loopRunId;pe(n=>n.map(n=>n.id===e?{...n,status:`running`,activeJobId:t??n.activeJobId}:n));return}if(n.type===`rail.updated`){let e=n.railIndex??0,t=RV(e),r=n.ticketIds??[],i=n.name?`Rail ${n.name}`:`Rail ${e+1}`;pe(e=>e.some(e=>e.id===t)?e.map(e=>e.id===t?n.changed!==`tickets`||e.status===`running`?{...e,label:i}:{...e,label:i,ticketIds:r}:e):[...e,{id:t,label:i,ticketIds:r,mode:HH(n.mode)?n.mode:`implement`,status:`idle`}]);return}if(n.type===`rail.removed`){if(n.railIndex==null)return;let e=RV(n.railIndex);pe(t=>t.filter(t=>t.id!==e||t.status===`running`));return}if(n.type===`rail.worktree_progress`){let t=n.railIndex??0,r=n.ticketId,i=n.state;typeof r==`number`&&i&&(B(e=>HV(e,t,r,i)),i===`needs-review`&&J.error(e(`toasts.railWorktreeNeedsReview`,{n:t+1,ticket:r})));return}if(n.type===`rail.job_completed`){let t=n.railIndex??0;pe(e=>JV(e,t,n.ticketIds??[])),n.status===`completed`?J.info(e(`toasts.railCompleted`,{n:t+1})):n.status===`failed`||n.status===`zombie_terminated`?J.error(e(`toasts.railFailed`,{n:t+1})):J.info(e(`toasts.railEnded`,{n:t+1,status:n.status??`finished`}))}if(n.type===`loop.run_completed`){let t=n.railIndex??0;pe(e=>JV(e,t,n.ticketIds??[])),n.status===`success`?J.info(e(`toasts.railCompleted`,{n:t+1})):n.status===`failed`||n.status===`max-iterations`?J.error(e(`toasts.railFailed`,{n:t+1})):J.info(e(`toasts.railEnded`,{n:t+1,status:n.status??`finished`}))}}},[pe,e]);(0,Q.useEffect)(()=>(h(`dashboard-rails`,U),()=>g(`dashboard-rails`)),[U,h,g]);let xe=NP(MP(RF,{activationConstraint:{distance:5}}),MP(NF)),Se=(0,Q.useCallback)(e=>{let t=typeof e.active.id==`string`&&KV(e.active.id),n=e.droppableContainers.filter(e=>{let n=e.id;return typeof n==`string`&&KV(n)?t:!t}),r={...e,droppableContainers:n};if(t)return UP(r);let i=qP(r);if(BP(i))return i;let a=GP(r);return BP(a)?a:UP(r)},[]),Ce=(0,Q.useMemo)(()=>new Map(a.map(e=>[e.id,e])),[a]),W=(0,Q.useMemo)(()=>{let e=[],t=[];return L.forEach((n,r)=>{let i=zV(n.id)??r;if(n.status===`running`){t.push({rail:n,reason:`running`});return}if(n.ticketIds.length===0){t.push({rail:n,reason:`empty`});return}let a=V.get(i);if(a&&!UH(a,n.ticketIds)){t.push({rail:n,reason:`pendingDecision`});return}if(n.ticketIds.some(e=>Ce.get(e)?.status===`on_review`&&(!H||!WH(e,V)))){t.push({rail:n,reason:`onReview`});return}e.push(n)}),{eligible:e,skipped:t}},[L,V,H,Ce]),we=(0,Q.useMemo)(()=>{let e=new Set;for(let t of a)for(let n of t.labels)e.add(n);return Array.from(e).sort()},[a]),Te=(0,Q.useMemo)(()=>{let e=new Set;for(let t of L)for(let n of t.ticketIds)e.add(n);return e},[L]),Ee=(0,Q.useMemo)(()=>a.filter(e=>(e.source===`propose-spec`||e.source===`product-backlog`||e.source===`get-backlog-specs`||e.source===`explore-draft`||e.source===`specs-smash`||e.source===`free-prompt`||e.source===`mcp`||e.source===`project-builder`||e.source===`manual`&&e.created_by===`project-builder`||e.source===`jira`)&&!Te.has(e.id)),[a,Te]);(0,Q.useEffect)(()=>{o||ie===`jira-key`&&!Ee.some(e=>e.jira_key)&&ue(`default`,oe)},[o,ie,oe,Ee,ue]);let De=(0,Q.useMemo)(()=>{let e=Ee.filter(e=>e.status!==`done`);if(ie!=="default")return RR(e,ie,oe);if(!F)return e;let t=new Map(e.map(e=>[e.id,e])),n=[];for(let e of F){let r=t.get(e);r&&n.push(r)}for(let t of e)F.includes(t.id)||n.push(t);return n},[Ee,F,ie,oe]),Oe=(0,Q.useMemo)(()=>Ee.filter(e=>e.status===`done`),[Ee]),ke=(0,Q.useMemo)(()=>{let e=new Set;if(!H)return e;for(let t of a)t.status===`on_review`&&WH(t.id,V)&&e.add(t.id);return e},[a,V,H]),Ae=(0,Q.useCallback)((t,n)=>{let r=L.find(e=>e.id===n);if(r){if(a.find(e=>e.id===t)?.status===`on_review`&&(!H||!WH(t,V))){J.info(e(`toasts.onReviewCannotMoveToRail`));return}if(r.ticketIds.includes(t)){J.info(e(`toasts.alreadyOnRail`,{rail:r.label}));return}fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==t)),pe(e=>e.map(e=>e.id===n?{...e,ticketIds:[...e.ticketIds.filter(e=>e!==t),t]}:e.ticketIds.includes(t)?{...e,ticketIds:e.ticketIds.filter(e=>e!==t)}:e)),J.success(e(`toasts.movedToRail`,{rail:r.label}))}},[L,a,De,pe,fe,e,V,H]),je=(0,Q.useCallback)(t=>{let n=L.find(e=>e.ticketIds.includes(t));if(n){if(n.status===`running`){J.error(e(`toasts.railRunningStopFirst`,{rail:n.label}));return}pe(e=>e.map(e=>e.id===n.id?{...e,ticketIds:e.ticketIds.filter(e=>e!==t)}:e)),fe(e=>{let n=e??De.map(e=>e.id);return n.includes(t)?n:[...n,t]}),J.success(e(`toasts.removedFromRail`,{rail:n.label}))}},[L,De,pe,fe,e]),Me=(0,Q.useCallback)(e=>{if(De.some(t=>t.id===e))return`specs`;if(Oe.some(t=>t.id===e))return`done-specs`;for(let t of L)if(t.ticketIds.includes(e))return t.id;return null},[De,Oe,L]);function Ne({active:e}){if(KV(e.id)){let t=qV(e.id),n=L.find(e=>e.id===t);P(n?.label??t);return}M(e.id)}function Pe({active:n,over:r}){if(M(null),P(null),!r)return;if(KV(n.id)){if(!KV(r.id))return;let e=qV(n.id),t=qV(r.id);if(e===t)return;pe(n=>{let r=n.findIndex(t=>t.id===e),i=n.findIndex(e=>e.id===t);return r===-1||i===-1?n:nL(n,r,i)});return}let i=n.id,o=r.id,s=Me(i);if(!s)return;let l=BH(o,me,Me,KV,qV)??s;if(me.has(l))if(s===l)if(l===`specs`){let e=De.map(e=>e.id),n=e.indexOf(i),r=e.indexOf(o);if(n!==-1&&r!==-1&&n!==r){let i=nL(e,n,r);fe(()=>i),ie!=="default"&&(ae(`default`),jR(t,`default`,oe))}}else pe(e=>e.map(e=>{if(e.id!==l)return e;let t=e.ticketIds.indexOf(i),n=e.ticketIds.indexOf(o);return t!==-1&&n!==-1&&t!==n?{...e,ticketIds:nL(e.ticketIds,t,n)}:e}));else if(s===`specs`&&l===`done-specs`){if(a.find(e=>e.id===i)?.status===`on_review`){J.info(e(`toasts.onReviewCannotMoveToRail`));return}fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==i)),c(i,{status:`done`})}else if(s===`done-specs`&&l===`specs`)c(i,{status:`todo`}),fe(e=>zH(e??De.map(e=>e.id),i,o));else if(s===`specs`){if(a.find(e=>e.id===i)?.status===`on_review`&&(!H||!WH(i,V))){J.info(e(`toasts.onReviewCannotMoveToRail`));return}let t=L.find(e=>e.id===l);fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==i)),pe(e=>e.map(e=>e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e)),t&&(t.status===`running`?J.info(e(`toasts.queuedOnRail`,{rail:t.label}),{description:e(`toasts.queuedOnRailDescription`)}):J.success(e(`toasts.movedToRail`,{rail:t.label})))}else if(l===`specs`){let t=L.find(e=>e.id===s);if(t?.status===`running`){J.error(e(`toasts.railRunningStopFirst`,{rail:t.label}));return}pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e)),fe(e=>zH(e??De.map(e=>e.id),i,o)),t&&J.success(e(`toasts.removedFromRail`,{rail:t.label}))}else s===`done-specs`?(c(i,{status:`todo`}),pe(e=>e.map(e=>e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e))):l===`done-specs`?(pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e)),c(i,{status:`done`})):pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e))}function Fe(e,t){pe(n=>n.map(n=>n.id===e?{...n,mode:t}:n))}function Ie(e){let t=zV(e);return t===null?L.findIndex(t=>t.id===e):t}async function Le(e,t){pe(n=>n.map(n=>n.id===e?{...n,profileName:t}:n));let n=Ie(e);if(n!==-1)try{await fetch(`${nt()}/rails/${n}/profile`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profileName:t})})}catch{}}function Re(e,t){pe(n=>n.map(n=>n.id===e?{...n,freestyleModel:t}:n))}function ze(e,t){let n=yV(t);pe(r=>r.map(r=>r.id===e?{...r,selectedLoopId:t,mode:n}:r))}function Be(e,t){pe(n=>n.map(n=>{if(n.id!==e)return n;let r=n.aiEngine??i[0]??`claude`,a=lr(r,t);return{...n,loopModel:t,reasoningEffort:n.reasoningEffort&&a.includes(n.reasoningEffort)?n.reasoningEffort:fr(r,t)??null}}))}function G(e,t){pe(n=>n.map(n=>n.id===e?{...n,reasoningEffort:t}:n))}async function Ve(e,t){pe(n=>n.map(n=>{if(n.id!==e)return n;let r=n.mode===`freestyle`||n.selectedLoopId===`factory:freestyle`,i=!cr(t)&&r,a=fz(t),o=e=>!!(e&&(a.some(t=>t.value===e)||nr(t)&&gD(e))),s=o(n.loopModel)?n.loopModel:pz(t),c=lr(t,s);return{...n,aiEngine:t,mode:i?`implement`:n.mode,selectedLoopId:i?`factory:implement`:n.selectedLoopId,profileName:null,freestyleModel:o(n.freestyleModel)?n.freestyleModel:pz(t),loopModel:s,reasoningEffort:n.reasoningEffort&&c.includes(n.reasoningEffort)?n.reasoningEffort:fr(t,s)??null}}));let n=Ie(e);if(n!==-1)try{await fetch(`${nt()}/rails/${n}/engine`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({aiEngine:t})})}catch{}}function He(e,t){pe(n=>n.map(n=>n.id===e?{...n,targetPr:t}:n))}async function Ue(t){let n=L.find(e=>e.id===t),r=Ie(t);if(!(!n||r===-1)){if(n.status===`running`){try{await fetch(`${nt()}/rails/${r}/stop`,{method:`POST`}),pe(e=>e.map(e=>e.id===t?{...e,status:`idle`,activeJobId:void 0}:e)),J.info(e(`toasts.railStopped`,{rail:n.label}))}catch{J.error(e(`toasts.stopFailed`))}return}if(n.ticketIds.length!==0){if(n.mode===`freestyle`){E({railId:t});return}if(n.targetPr){O({railId:t});return}await We(t)}}}async function We(t,n){let r=n?.silent??!1,o=L.find(e=>e.id===t),s=Ie(t);if(!o||s===-1)return`failed`;if(o.ticketIds.length===0)return`skipped`;if(o.ticketIds.some(e=>a.find(t=>t.id===e)?.status===`on_review`&&(!H||!WH(e,V))))return r||J.info(e(`toasts.onReviewNotLaunchable`)),`skipped`;let c=bV(o.selectedLoopId,o.mode);if(!c)return r||J.error(e(`railControls.pickLoop`)),`failed`;let l=o.aiEngine??i[0]??`claude`,u=lr(l,o.loopModel??pz(l)),d=o.reasoningEffort&&u.includes(o.reasoningEffort)?o.reasoningEffort:null,f=nt();try{await fetch(`${f}/rails/${s}/tickets`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({ticketIds:o.ticketIds})})}catch{return r||J.error(e(`toasts.syncTicketsFailed`)),`failed`}try{let n=await fetch(`${f}/rails/${s}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:o.mode,...o.profileName===void 0?{}:{profileName:o.profileName},...o.aiEngine==null?{}:{aiEngine:o.aiEngine},...o.mode===`freestyle`&&o.freestyleModel?{model:o.freestyleModel}:{},...o.mode===`loop`&&o.loopModel?{model:o.loopModel}:{},loopId:c,...o.mode===`loop`&&d?{reasoning_effort:d}:{},...o.targetPr?{targetPrNumber:o.targetPr.number}:{}})});if(!n.ok){let t=await n.json().catch(()=>({error:``}));return n.status===409&&t.error===`pr_decision_pending`?(r||J.info(e(`railPr.decisionPending`)),`pendingDecision`):n.status===409&&t.error===`tickets_in_flight`?(r||J.info(e(`toasts.launchTicketsInFlight`)),`skipped`):n.status===400&&t.error===`rail_ticket_cap_exceeded`?(r||J.error(e(`toasts.launchTicketCap`,{max:t.max??3,count:t.ticketCount??0})),`failed`):typeof t.error==`string`&&[`invalid_target_pr`,`target_pr_requires_pr_mode`,`target_pr_not_found`,`target_pr_not_open`,`target_pr_fork`,`target_pr_invalid`,`target_pr_unfetchable`].includes(t.error)?(r||J.error(e(`targetPr.errors.${t.error}`),{description:t.detail,duration:1e4}),`failed`):(r||J.error(t.error||e(`toasts.launchFailed`)),`failed`)}let i=await n.json();!r&&i.isolationUnavailable===`no-git`?J.info(e(`toasts.railWorktreesNoGit`)):!r&&i.isolationUnavailable===`no-commits`?J.info(e(`toasts.railWorktreesNoCommits`)):!r&&i.isolationUnavailable===`error`&&J.warning(e(`toasts.railWorktreesError`),{description:i.isolationUnavailableDetail,duration:12e3});let a=i.jobId??i.loopRunIds?.[0];return pe(e=>e.map(e=>e.id===t?{...e,status:`running`,activeJobId:a,targetPr:null}:e)),r||J.success(e(`toasts.railLaunched`,{rail:o.label}),{description:e(`toasts.launchDescription`,{mode:o.mode,count:o.ticketIds.length})}),`launched`}catch{return r||J.error(e(`toasts.launchNetworkError`)),`failed`}}function Ge(){if(W.eligible.length===0){J.info(e(`toasts.launchAllNoneEligible`));return}A(!0)}async function Ke(){A(!1);let{eligible:t,skipped:n}=W;if(t.length===0){J.info(e(`toasts.launchAllNoneEligible`));return}let r=await Promise.allSettled(t.map(e=>We(e.id,{silent:!0}))),i=0,a=0,o=0,s=0;for(let e of r){let t=e.status===`fulfilled`?e.value:`failed`;t===`launched`?i++:t===`pendingDecision`?o++:t===`skipped`?s++:a++}let c=new Map;for(let e of n)c.set(e.reason,(c.get(e.reason)??0)+1);o>0&&c.set(`pendingDecision`,(c.get(`pendingDecision`)??0)+o);let l={running:`launchAll.skipRunning`,empty:`launchAll.skipEmpty`,pendingDecision:`launchAll.skipPendingDecision`,onReview:`launchAll.skipOnReview`},u=[];for(let[t,n]of c)n>0&&u.push(e(l[t],{count:n}));s>0&&u.push(e(`launchAll.skipInFlight`,{count:s})),a>0&&u.push(e(`launchAll.failedCount`,{count:a}));let d=u.length>0?u.join(` · `):void 0;i>0?J.success(e(`toasts.launchAllSummary`,{count:i}),d?{description:d}:void 0):J.error(e(`toasts.launchAllFailed`),d?{description:d}:void 0)}let Je=j===null?void 0:Ce.get(j),Ye=(0,Q.useRef)(null),{leftWidth:Xe,enabled:Ze,beginDrag:Qe,resetToDefault:$e}=DH(t,Ye),et=typeof window<`u`?window.innerWidth:1200;return(0,$.jsx)(LL,{children:(0,$.jsxs)(FI,{sensors:xe,collisionDetection:Se,onDragStart:Ne,onDragEnd:Pe,children:[(0,$.jsxs)(`div`,{ref:Ye,className:`relative z-0 flex h-full overflow-hidden`,children:[r&&(0,$.jsx)(IM,{}),(0,$.jsx)(`div`,{className:`relative z-10 min-w-0 flex flex-col overflow-hidden`,style:Ze&&Xe!==null?{width:`${Xe}px`,flex:`0 0 auto`}:{flex:`1 1 0%`},children:(0,$.jsx)(pV,{tickets:De,allTickets:a,doneTickets:Oe,isLoading:o,error:s,onRetry:()=>{p()},onTicketClick:x,onTicketCreated:e=>{x(e),p()},onTicketDelete:e=>d(e),onTicketStatusChange:(e,t)=>{l(e,t)},onTicketPriorityChange:(e,t)=>{u(e,t)},contractRefiningIds:m,sortMode:ie,sortDir:oe,onSortChange:ue,viewTier:ce,onViewTierChange:de,rails:L,onMoveToRail:Ae,continuableReviewTicketIds:ke})}),Ze&&Xe!==null&&(0,$.jsx)(OH,{leftWidth:Xe,viewport:et,onPointerDown:Qe,onReset:$e}),(0,$.jsx)(`div`,{className:`relative z-10 flex-1 min-w-0 flex flex-col overflow-hidden`,children:(0,$.jsx)(XV,{rails:L,ticketMap:Ce,railWorktrees:z,railMetrics:ee,railPrDecisions:V,onPrDecision:te,onPrCheckout:ne,providers:i,onModeChange:Fe,onProfileChange:Le,onEngineChange:Ve,onFreestyleModelChange:Re,onLoopModelChange:Be,loopAvailable:ge,onLoopChange:ze,onEffortChange:G,onToggle:Ue,onTargetPrChange:He,onTicketClick:x,onAddRail:()=>{he()},onDeleteRail:e=>{_e(e)},onRenameRail:ve,onTicketMoveToSpecs:je,onLaunchAll:Ge,launchAllCount:W.eligible.length})})]}),(0,$.jsx)(tL,{dropAnimation:{duration:180,easing:`ease`},children:Je?ce===`postit`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-accent-info/40 bg-card/95 shadow-xl shadow-black/30 backdrop-blur-sm p-3 rotate-1 scale-[1.02] pointer-events-none w-[260px] min-h-[180px]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/60`,children:[`#`,Je.id]}),Je.priority&&(0,$.jsx)(`span`,{className:`h-4 px-1.5 rounded-full text-[9px] font-medium uppercase bg-muted/40 text-foreground`,children:Je.priority})]}),(0,$.jsx)(`h3`,{className:`text-sm font-medium leading-snug line-clamp-2 text-foreground`,children:Je.title}),Je.short_summary&&Je.short_summary.trim().length>0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 leading-relaxed line-clamp-3 italic`,children:Je.short_summary})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border border-primary/40 bg-card/95 shadow-xl shadow-black/20 backdrop-blur-sm rotate-1 scale-[1.03] pointer-events-none`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/50 shrink-0`,children:[`#`,Je.id]}),(0,$.jsx)(`span`,{className:`flex-1 text-sm truncate max-w-[240px]`,children:Je.title})]}):N?(0,$.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-xl border border-primary/40 bg-card/95 shadow-xl shadow-black/20 backdrop-blur-sm rotate-[0.5deg] scale-[1.02] pointer-events-none`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:N})}):null}),b&&(()=>{let e=a.find(e=>e.id===b.id)??b;return(0,$.jsx)(be,{ticket:e,allLabels:we,allTickets:a,onClose:()=>x(null),onOpenTicket:e=>{let t=a.find(t=>t.id===e);t&&x(t)},onSave:c,onDelete:d,rails:L,onMoveToRail:Ae,onRemoveFromRail:je},e.id)})(),(0,$.jsx)(kH,{open:S,allLabels:we,onClose:()=>C(!1),onCreate:f}),(0,$.jsx)(MH,{open:k,railCount:W.eligible.length,specCount:W.eligible.reduce((e,t)=>e+t.ticketIds.length,0),onCancel:()=>A(!1),onConfirm:()=>{Ke()}}),(()=>{let e=D?L.find(e=>e.id===D.railId):void 0;return(0,$.jsx)(NH,{open:!!D&&!!e?.targetPr,target:e?.targetPr??null,onCancel:()=>O(null),onConfirm:()=>{let e=D?.railId;O(null),e&&We(e)}})})(),(()=>{let e=w?L.find(e=>e.id===w.railId):void 0,t=e?.aiEngine??i[0]??`claude`;return(0,$.jsx)(AH,{open:!!w&&!!e,railLabel:e?.label??``,specCount:e?.ticketIds.length??0,provider:t,model:e?.freestyleModel??pz(t),onCancel:()=>E(null),onConfirm:()=>{let e=w?.railId;E(null),e&&We(e)}})})()]})})}var XH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`rounded-lg border border-border bg-card text-card-foreground shadow-sm`,e),...t}));XH.displayName=`Card`;var ZH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`flex flex-col space-y-1 p-4`,e),...t}));ZH.displayName=`CardHeader`;var QH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`h3`,{ref:n,className:X(`text-sm font-semibold leading-none tracking-tight`,e),...t}));QH.displayName=`CardTitle`;var $H=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`p`,{ref:n,className:X(`text-xs text-muted-foreground`,e),...t}));$H.displayName=`CardDescription`;var eU=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`p-4 pt-0`,e),...t}));eU.displayName=`CardContent`;var tU=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`flex items-center p-4 pt-0`,e),...t}));tU.displayName=`CardFooter`;var nU=[`auto`,`canvas`,`webgl`];function rU({mode:e}){let{t}=K(`settings`),{activeProjectId:n}=at(),[r,i]=(0,Q.useState)(vi),[a,o]=(0,Q.useState)({}),[s,c]=(0,Q.useState)(vi),[l,u]=(0,Q.useState)(vi),[d,f]=(0,Q.useState)(new Set),[p,m]=(0,Q.useState)(!0),[h,g]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let t=!1;if(e===`project`&&!n){m(!1);return}return(async()=>{try{if(e===`desktop`){let e=await fetch(`/api/terminal-settings`);if(!e.ok)throw Error(`desktop settings fetch failed`);let n=await e.json();!t&&n&&typeof n==`object`&&`fontSize`in n&&(i(n),c(n),u(n),f(new Set)),t||m(!1)}else if(n){let e=await fetch(`/api/projects/${n}/terminal-settings`);if(!e.ok)throw Error(`project fetch failed`);let r=await e.json();!t&&r&&typeof r==`object`&&r.resolved&&r.desktopDefaults&&(i(r.desktopDefaults),o(r.override??{}),c(r.resolved),u(r.resolved),f(new Set)),t||m(!1)}}catch(e){t||(m(!1),console.error(e))}})(),()=>{t=!0}},[e,n]);let _=(0,Q.useMemo)(()=>d.size>0||Object.keys(l).some(e=>l[e]!==s[e]),[l,s,d]);function v(e,t){u(n=>({...n,[e]:t})),d.has(e)&&f(t=>{let n=new Set(t);return n.delete(e),n})}function y(t){e===`project`&&(f(e=>{let n=new Set(e);return n.add(t),n}),u(e=>({...e,[t]:r[t]})))}function b(){u(s),f(new Set)}async function x(){g(!0);try{let r={};for(let e of Object.keys(l)){if(d.has(e)){r[e]=null;continue}l[e]!==s[e]&&(r[e]=l[e])}if(Object.keys(r).length===0){J(t(`terminal.nothingToSave`)),g(!1);return}if(e===`desktop`){let e=await fetch(`/api/terminal-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(await e.text()||`patch failed`);let n=await e.json();i(n),c(n),u(n),f(new Set),oN({mode:`desktop`,projectId:null}),J.success(t(`terminal.saved`))}else if(n){let e=await fetch(`/api/projects/${n}/terminal-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(await e.text()||`patch failed`);let a=await e.json();i(a.desktopDefaults),o(a.override),c(a.resolved),u(a.resolved),f(new Set),oN({mode:`project`,projectId:n}),J.success(t(`terminal.saved`))}}catch(e){J.error(t(`errors.saveFailed`,{message:e.message}))}finally{g(!1)}}function S(t){return e!==`project`||d.has(t)?!1:a[t]!==void 0}return p?(0,$.jsx)(XH,{children:(0,$.jsx)(eU,{children:t(`common:states.loading`)})}):(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:t(`terminal.title`)}),(0,$.jsx)($H,{children:t(e===`desktop`?`terminal.desktopDescription`:`terminal.projectDescription`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsx)(iU,{label:t(`terminal.fontFamily`),overridden:S(`fontFamily`),onClear:()=>y(`fontFamily`),mode:e,children:(0,$.jsx)(Qk,{value:l.fontFamily,onChange:e=>v(`fontFamily`,e.target.value)})}),(0,$.jsx)(iU,{label:t(`terminal.fontSize`,{min:8,max:32}),overridden:S(`fontSize`),onClear:()=>y(`fontSize`),mode:e,children:(0,$.jsx)(Qk,{type:`number`,min:8,max:32,value:l.fontSize,onChange:e=>v(`fontSize`,parseInt(e.target.value,10)||l.fontSize)})}),(0,$.jsx)(iU,{label:t(`terminal.renderMode`),overridden:S(`renderMode`),onClear:()=>y(`renderMode`),mode:e,children:(0,$.jsx)(`select`,{value:l.renderMode,onChange:e=>v(`renderMode`,e.target.value),className:`border rounded px-2 py-1 bg-transparent`,children:nU.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})}),(0,$.jsx)(aU,{label:t(`terminal.copyOnSelect`),checked:l.copyOnSelect,overridden:S(`copyOnSelect`),onClear:()=>y(`copyOnSelect`),onChange:e=>v(`copyOnSelect`,e),mode:e}),(0,$.jsx)(aU,{label:t(`terminal.shellIntegration`),checked:l.shellIntegrationEnabled,overridden:S(`shellIntegrationEnabled`),onClear:()=>y(`shellIntegrationEnabled`),onChange:e=>v(`shellIntegrationEnabled`,e),mode:e}),(0,$.jsx)(aU,{label:t(`terminal.notifyLongRunning`),checked:l.notifyOnCompletion,overridden:S(`notifyOnCompletion`),onClear:()=>y(`notifyOnCompletion`),onChange:e=>v(`notifyOnCompletion`,e),mode:e}),(0,$.jsx)(iU,{label:t(`terminal.longCommandThreshold`),overridden:S(`longCommandThresholdMs`),onClear:()=>y(`longCommandThresholdMs`),mode:e,children:(0,$.jsx)(Qk,{type:`number`,min:1e3,value:l.longCommandThresholdMs,onChange:e=>v(`longCommandThresholdMs`,parseInt(e.target.value,10)||l.longCommandThresholdMs)})}),(0,$.jsx)(aU,{label:t(`terminal.imageRendering`),checked:l.imageRendering,overridden:S(`imageRendering`),onClear:()=>y(`imageRendering`),onChange:e=>v(`imageRendering`,e),mode:e}),(0,$.jsx)(iU,{id:`terminal-browser-shortcut-url`,label:t(`terminal.browserShortcutUrl`),overridden:S(`browserShortcutUrl`),onClear:()=>y(`browserShortcutUrl`),mode:e,children:(0,$.jsx)(Qk,{type:`url`,value:l.browserShortcutUrl,placeholder:`https://specrails.dev`,onChange:e=>v(`browserShortcutUrl`,e.target.value)})}),(0,$.jsx)(iU,{id:`terminal-quick-script`,label:t(`terminal.quickScript`),overridden:S(`quickScript`),onClear:()=>y(`quickScript`),mode:e,children:(0,$.jsx)(`textarea`,{value:l.quickScript,placeholder:`echo "Hello World!"`,onChange:e=>v(`quickScript`,e.target.value),rows:3,className:`w-full border rounded px-2 py-1 bg-transparent font-mono text-xs`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 border-t`,children:[(0,$.jsx)(Z,{onClick:x,disabled:!_||h,children:t(h?`common:states.saving`:`common:actions.save`)}),(0,$.jsx)(Z,{variant:`ghost`,onClick:b,disabled:!_||h,children:t(`terminal.reset`)}),_&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`terminal.unsavedChanges`)})]})]})]})}function iU({id:e,label:t,overridden:n,onClear:r,mode:i,children:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(`div`,{id:e,"data-terminal-settings-anchor":e?``:void 0,className:e?`scroll-mt-4`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center mb-1`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium`,children:t}),i===`project`&&n&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:r,children:o(`terminal.clearOverride`)})]}),a,i===`project`&&!n&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:o(`terminal.inheritingDefault`)})]})}function aU({label:e,checked:t,overridden:n,onClear:r,onChange:i,mode:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium`,children:e}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a===`project`&&n&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:r,children:o(`terminal.clear`)}),(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":e,"aria-checked":t,onClick:()=>i(!t),className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${t?`bg-primary`:`bg-input`}`,children:(0,$.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})})]})]})}function oU(){let{activeProjectId:e,projects:t,refreshProjects:n}=at(),r=t.find(t=>t.id===e);return r?(0,$.jsx)(sU,{project:r,refreshProjects:n},r.id):null}function sU({project:e,refreshProjects:t}){let{t:n}=K(`common`),[r,i]=(0,Q.useState)(()=>er(e)),[a,o]=(0,Q.useState)(null),[s,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]),(0,Q.useEffect)(()=>{i(er(e))},[e]);let x=`${$n(e.id)}/repositories`;function S(e){y(null),o(e??null),l(!e),d(e?.path??``),p(e?.name??``),h(e?.integrationBranch??``)}async function C(e,n){if(!g){_(!0),y(null);try{let r=await fetch(n?`${x}/${encodeURIComponent(n)}`:x,{method:e,headers:{"Content-Type":`application/json`},...e===`DELETE`?{}:{body:JSON.stringify({...!a||!a.isPrimary&&u.trim()!==a.path?{path:u.trim()}:{},...f.trim()?{name:f.trim()}:{},integrationBranch:m.trim()||null})}});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let s=await fetch(x,{cache:`no-store`});if(!s.ok)throw Error(`HTTP ${s.status}`);let c=await s.json();b.current&&(i(c.repositories),l(!1),o(null)),await t?.()}catch(e){b.current&&y(e instanceof Error?e.message:String(e))}finally{b.current&&_(!1)}}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsxs)(QH,{className:`flex items-center gap-2`,children:[(0,$.jsx)(is,{className:`h-4 w-4`}),n(`repositories.title`)]}),(0,$.jsx)($H,{children:n(`repositories.sharedBacklog`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.isPrimary?n(`repositories.primary`):e.kind===`folder`?n(`repositories.contextOnly`):`Git`}),e.available===!1&&(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:n(`repositories.unavailable`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex gap-1`,children:[(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,disabled:g,onClick:()=>S(e),children:n(`actions.edit`)}),!e.isPrimary&&(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,disabled:g,onClick:()=>void C(`DELETE`,e.id),children:n(`repositories.detach`)})]})]}),(0,$.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:e.path}),e.integrationBranch&&(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[n(`repositories.integrationBranch`),`: `,e.integrationBranch]})]},e.id))}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`repositories.detachHint`)}),v&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:v}),s||a?(0,$.jsxs)(`form`,{className:`space-y-3 rounded-lg border border-border p-3`,onSubmit:e=>{e.preventDefault(),C(a?`PATCH`:`POST`,a?.id)},children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.name`),(0,$.jsx)(Qk,{value:f,disabled:g,onChange:e=>p(e.target.value)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.path`),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{value:u,required:!0,disabled:g||a?.isPrimary,onChange:e=>d(e.target.value)}),`__TAURI_INTERNALS__`in window&&!a?.isPrimary&&(0,$.jsx)(Z,{type:`button`,variant:`outline`,disabled:g,"aria-label":n(`repositories.browse`),onClick:async()=>{try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!1});typeof t==`string`&&b.current&&d(t)}catch{}},children:(0,$.jsx)(as,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.integrationBranch`),(0,$.jsx)(Qk,{value:m,disabled:g,placeholder:n(`repositories.branchDefault`),onChange:e=>h(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`submit`,size:`sm`,disabled:g||!u.trim(),children:n(g?`actions.saving`:`actions.save`)}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`ghost`,disabled:g,onClick:()=>{l(!1),o(null),y(null)},children:n(`actions.cancel`)})]})]}):(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,disabled:g,onClick:()=>S(),children:[(0,$.jsx)(cn,{className:`mr-1 h-4 w-4`}),n(`repositories.addFolder`)]})]})]})}function cU(){return(0,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-lg bg-muted/30`,"data-testid":`section-skeleton`})}function lU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!t)return;let e=!1;return s(!1),fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&r(t.pipelineTelemetryEnabled??!1)}).catch(()=>{}).finally(()=>{e||s(!0)}),()=>{e=!0}},[t]),!o)return(0,$.jsx)(cU,{});async function c(t){a(!0);let i=n;r(t);try{if(!(await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pipelineTelemetryEnabled:t})})).ok)throw Error(`Failed to save`);J.success(e(t?`telemetry.enabled`:`telemetry.disabled`))}catch(t){r(i),J.error(e(`telemetry.saveFailed`),{description:t.message})}finally{a(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`telemetry.title`)}),(0,$.jsx)($H,{children:e(`telemetry.description`)})]}),(0,$.jsx)(eU,{className:`space-y-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:e(`telemetry.toggleLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`telemetry.toggleDescription`,components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})})]}),(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":e(`telemetry.toggleLabel`),"aria-checked":n,disabled:i,onClick:()=>c(!n),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 ${n?`bg-primary`:`bg-input`}`,children:(0,$.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${n?`translate-x-4`:`translate-x-0.5`}`})})]})})]})}function uU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);async function u(e){let t=await fetch(`${nt()}/integration-branch`).then(e=>e.ok?e.json():null).catch(()=>null);e?.current||t&&(r(t.configured??``),t.branch&&a({branch:t.branch,source:t.source??``}))}if((0,Q.useEffect)(()=>{if(!t)return;let e={current:!1};return l(!1),u(e).finally(()=>{e.current||l(!0)}),()=>{e.current=!0}},[t]),!c)return(0,$.jsx)(cU,{});async function d(){s(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({integrationBranch:n.trim()})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to save`)}J.success(e(`integrationBranch.saved`)),await u()}catch(t){J.error(e(`integrationBranch.saveFailed`),{description:t.message})}finally{s(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`integrationBranch.title`)}),(0,$.jsx)($H,{children:e(`integrationBranch.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-3`,children:[(0,$.jsx)(Qk,{value:n,onChange:e=>r(e.target.value),placeholder:e(`integrationBranch.placeholder`),"data-testid":`integration-branch-input`}),i&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`integration-branch-resolved`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`integrationBranch.resolved`,values:{branch:i.branch},components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(Z,{size:`sm`,onClick:d,disabled:o,"data-testid":`integration-branch-save`,children:e(`integrationBranch.save`)})]})]})}var dU=/^[A-Za-z_][A-Za-z0-9_]*$/,fU=[`NODE_AUTH_TOKEN`,`NPM_TOKEN`,`AWS_PROFILE`];function pU(e){return e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}function mU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),s(``),fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&r(Array.isArray(t.worktreeEnvPassthrough)?t.worktreeEnvPassthrough:[])}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]),!u)return(0,$.jsx)(cU,{});function f(t){let i=pU(t);if(i.length===0)return;let o=[...n];for(let t of i){if(t.includes(`=`)){s(e(`worktreeEnv.noValues`));return}if(!dU.test(t)){s(e(`worktreeEnv.invalidName`,{name:t}));return}o.includes(t)||o.push(t)}r(o),a(``),s(``)}async function p(){l(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({worktreeEnvPassthrough:n})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to save`)}let i=await t.json();r(i.settings?.worktreeEnvPassthrough??n),J.success(e(`worktreeEnv.saved`))}catch(t){J.error(e(`worktreeEnv.saveFailed`),{description:t.message})}finally{l(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`worktreeEnv.title`)}),(0,$.jsx)($H,{children:e(`worktreeEnv.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:`worktree-env-name`,className:`text-xs font-medium`,children:e(`worktreeEnv.label`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{id:`worktree-env-name`,value:i,onChange:e=>{a(e.target.value),s(``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f(i))},placeholder:e(`worktreeEnv.placeholder`),"aria-invalid":!!o,"data-testid":`worktree-env-input`}),(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`secondary`,className:`h-9 shrink-0`,onClick:()=>f(i),disabled:!i.trim(),"data-testid":`worktree-env-add`,children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5`}),e(`worktreeEnv.add`)]})]}),o?(0,$.jsx)(`p`,{className:`text-[10px] text-destructive`,"data-testid":`worktree-env-error`,children:o}):(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`worktreeEnv.helper`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:fU.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`rounded-md border border-border bg-muted/30 px-2 py-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:e},e))}),n.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`worktree-env-list`,children:n.map(t=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 font-mono text-[11px]`,children:[t,(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e!==t)),className:`rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":e(`worktreeEnv.remove`,{name:t}),children:(0,$.jsx)(mn,{className:`w-3 h-3`})})]},t))}):(0,$.jsx)(`p`,{className:`rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:e(`worktreeEnv.empty`)}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,onClick:p,disabled:c,"data-testid":`worktree-env-save`,children:e(c?`common:states.saving`:`worktreeEnv.save`)})})]})]})}function hU({value:e,onChange:t,onSave:n,isSaving:r,fieldId:i,i18nRoot:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:o(`${a}.title`)}),(0,$.jsx)($H,{children:o(`${a}.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium`,children:o(`${a}.label`)}),(0,$.jsx)(`textarea`,{id:i,value:e,onChange:e=>t(e.target.value),placeholder:o(`${a}.placeholder`),className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`${a}.helper`)})]}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:r,onClick:n,children:o(r?`common:states.saving`:`${a}.saveButton`)})})]})]})}function gU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)({pre:!1,freestyle:!1});(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),f.current={pre:!1,freestyle:!1},fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{e||!t||(f.current.pre||r(t.prePrompt??``),f.current.freestyle||s(t.freestylePrePrompt??``))}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]);async function p(){a(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prePrompt:n})});if(!t.ok)throw Error(`Failed to save`);let i=(await t.json()).settings?.prePrompt??``;r(i),J.success(i.trim()===``?e(`prePrompt.cleared`):e(`prePrompt.saved`))}catch(t){J.error(e(`prePrompt.saveFailed`),{description:t.message})}finally{a(!1)}}async function m(){l(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({freestylePrePrompt:o})});if(!t.ok)throw Error(`Failed to save`);let n=(await t.json()).settings?.freestylePrePrompt??``;s(n),J.success(n.trim()===``?e(`freestylePrePrompt.resetToDefault`):e(`freestylePrePrompt.saved`))}catch(t){J.error(e(`freestylePrePrompt.saveFailed`),{description:t.message})}finally{l(!1)}}return u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hU,{value:n,onChange:e=>{f.current.pre=!0,r(e)},onSave:p,isSaving:i,fieldId:`project-pre-prompt`,i18nRoot:`prePrompt`}),(0,$.jsx)(hU,{value:o,onChange:e=>{f.current.freestyle=!0,s(e)},onSave:m,isSaving:c,fieldId:`project-freestyle-pre-prompt`,i18nRoot:`freestylePrePrompt`})]}):(0,$.jsx)(cU,{})}function _U(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)({daily:!1,perJob:!1});(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),f.current={daily:!1,perJob:!1},fetch(`${nt()}/budget`).then(e=>e.ok?e.json():null).then(t=>{e||!t||(f.current.daily||r(t.dailyBudgetUsd==null?``:String(t.dailyBudgetUsd)),f.current.perJob||s(t.jobCostThresholdUsd==null?``:String(t.jobCostThresholdUsd)))}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]);async function p(t,n,r,i){i(!0);try{if(!(await fetch(`${nt()}/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`Failed to save`);J.success(n)}catch(t){J.error(e(r),{description:t.message})}finally{i(!1)}}function m(t){let n=t.trim()===``?null:parseFloat(t);if(n!==null&&(isNaN(n)||n<=0)){J.error(e(`budget.invalidNumber`));return}return n}function h(){let t=m(n);t!==void 0&&p({dailyBudgetUsd:t},t==null?e(`budget.dailyRemoved`):e(`budget.dailySet`,{amount:t}),`budget.saveBudgetFailed`,a)}function g(){let t=m(o);t!==void 0&&p({jobCostThresholdUsd:t},t==null?e(`budget.perJobAlertDisabled`):e(`budget.alertSet`,{amount:t}),`budget.saveThresholdFailed`,l)}return u?(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`budget.title`)}),(0,$.jsx)($H,{children:e(`budget.description`)})]}),(0,$.jsx)(eU,{children:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs font-medium`,children:e(`budget.dailyLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`budget.dailyHelper`)})]}),(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:n,onChange:e=>{f.current.daily=!0,r(e.target.value)},placeholder:e(`budget.dailyPlaceholder`),className:`h-8 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:i,onClick:h,children:e(i?`common:states.saving`:`common:actions.save`)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs font-medium`,children:e(`budget.perJobLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`budget.perJobHelper`)})]}),(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:o,onChange:e=>{f.current.perJob=!0,s(e.target.value)},placeholder:e(`budget.perJobPlaceholder`),className:`h-8 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:c,onClick:g,children:e(c?`common:states.saving`:`common:actions.save`)})})]})]})})]}):(0,$.jsx)(cU,{})}function vU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),n=p(),r=t!==null;(0,Q.useEffect)(()=>{if(!n.hash)return;let e=n.hash.slice(1),t=!1,r=Date.now()+3e3,i=()=>{if(t)return;let n=document.getElementById(e);if(n){n.scrollIntoView({behavior:`smooth`,block:`center`}),n.classList.add(`ring-2`,`ring-accent-primary/60`,`rounded`),window.setTimeout(()=>{n.classList.remove(`ring-2`,`ring-accent-primary/60`,`rounded`)},1800);return}Date.now()<r&&window.setTimeout(i,80)};return i(),()=>{t=!0}},[n.hash,n.key]);let[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!0),c=(0,Q.useRef)(new Map);return(0,Q.useEffect)(()=>{if(t){let e=c.current.get(t);e?(a(e),s(!1)):s(!0)}async function e(){try{let e=await fetch(`${nt()}/config`);if(!e.ok)return;let n=await e.json();a(n),t&&c.current.set(t,n)}catch{}finally{s(!1)}}e()},[t]),o?(0,$.jsx)(`div`,{className:`max-w-2xl mx-auto px-4 py-6 space-y-3`,children:[0,1,2].map(e=>(0,$.jsx)(`div`,{className:`h-32 bg-muted/30 rounded-lg animate-pulse`},e))}):(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto px-4 py-6 space-y-6`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-base font-semibold`,children:e(`page.title`)}),i&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[i.project.name,i.project.repo&&` · ${i.project.repo}`]})]}),r&&(0,$.jsx)(lU,{}),(0,$.jsx)(gU,{}),(0,$.jsx)(oU,{}),(0,$.jsx)(uU,{}),(0,$.jsx)(mU,{}),(0,$.jsx)(_U,{}),(0,$.jsx)(rU,{mode:`project`})]})}function yU(){let{t:e}=K(`settings`),t=rk();return(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`effects-section`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`effects.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`effects.description`)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t.agentThinkingHalo,onClick:()=>tk({agentThinkingHalo:!t.agentThinkingHalo}),className:X(`relative mt-0.5 inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors`,t.agentThinkingHalo?`bg-accent-primary/70`:`bg-muted-foreground/30`),"data-testid":`effects-thinking-halo-toggle`,children:(0,$.jsx)(`span`,{className:X(`absolute h-3 w-3 rounded-full bg-background shadow transition-transform`,t.agentThinkingHalo?`translate-x-3.5`:`translate-x-0.5`)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[(0,$.jsx)(un,{className:`h-3.5 w-3.5 text-accent-primary`,"aria-hidden":!0}),e(`effects.thinkingHalo.label`)]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:e(`effects.thinkingHalo.description`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground/80`,children:e(`effects.reducedMotion`)}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`p`,{className:`mb-1.5 text-[10px] uppercase tracking-wider text-muted-foreground`,children:e(`effects.preview`)}),(0,$.jsxs)(`div`,{className:`relative max-w-sm rounded-xl border border-border/60 bg-background/60 px-3 py-2`,"data-testid":`effects-thinking-halo-preview`,"data-active":t.agentThinkingHalo,children:[(0,$.jsx)(JO,{active:t.agentThinkingHalo,radius:`0.75rem`,inset:-3,fadeInMs:450,fadeOutMs:800}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex gap-0.5`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary`}),(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary [animation-delay:150ms]`}),(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary [animation-delay:300ms]`})]}),e(`effects.previewThinking`)]})]})]})]})]})]})]})}function bU(){let{t:e}=K(`settings`),t=sa();if(!t)return null;let{themeId:n,setTheme:r,isUpdating:i}=t;async function a(t){if(t!==n)try{await r(t)}catch(t){J.error(e(`appearance.updateFailed`),{description:t instanceof Error?t.message:void 0})}}return(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-2`,role:`radiogroup`,"aria-label":e(`appearance.themeGroupLabel`),children:Pi.map(t=>{let r=Yi[t],o=t===n;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:i,onClick:()=>void a(t),className:`group relative overflow-hidden rounded-lg border text-left transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/60 disabled:opacity-60 disabled:cursor-not-allowed `+(o?`border-accent-primary ring-1 ring-accent-primary shadow-[0_0_0_1px_var(--color-accent-primary)] `:`border-border hover:border-accent-primary/40 hover:shadow-md `),"data-testid":`theme-card-${t}`,"data-selected":o?`true`:`false`,children:[(0,$.jsx)(`div`,{className:`h-20 w-full flex items-end gap-1 p-2`,style:{background:`linear-gradient(135deg, ${r.previewSwatches.background} 0%, ${r.previewSwatches.background} 60%, color-mix(in srgb, ${r.previewSwatches.accents[0]} 18%, ${r.previewSwatches.background}) 100%)`},"aria-hidden":`true`,children:r.previewSwatches.accents.map((e,t)=>(0,$.jsx)(`span`,{className:`h-3 w-3 rounded-full ring-1 ring-black/10`,style:{background:e}},t))}),(0,$.jsxs)(`div`,{className:`p-3 space-y-1 bg-card`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold`,children:r.displayName}),o&&(0,$.jsx)(Ht,{className:`w-3.5 h-3.5 text-accent-primary shrink-0`,"aria-label":e(`appearance.currentlyActive`)})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground leading-tight`,children:e(`appearance.taglines.${t}`,{defaultValue:r.tagline})})]})]},t)})})}function xU(){let{t:e}=K(`settings`);return sa()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`appearance.heading`)}),(0,$.jsx)(bU,{})]}):null}function SU(e={}){let t={...e},n=Ve();return n&&(t[`X-Desktop-Token`]=n),t}var CU=(0,Q.createContext)(null);function wU(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(ze,e)}catch{}}function TU(){if(!(typeof localStorage>`u`))try{localStorage.removeItem(ze)}catch{}}function EU({children:e,endpoint:t=`/api/language`}){let[n,r]=(0,Q.useState)(()=>Ke()),[i,a]=(0,Q.useState)(!1),o=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(o.current)return;o.current=!0;let e=!1;return(async()=>{try{let n=await fetch(t,{headers:SU()});if(!n.ok)return;let i=await n.json();if(e)return;Fe(i.language)&&i.language!==Ke()&&(await Ze(i.language),wU(i.language),e||r(i.language))}catch{}})(),()=>{e=!0}},[t]);let s=(0,Q.useCallback)(async e=>{if(e===n)return;let i=n,o=typeof localStorage<`u`&&Fe(localStorage.getItem(`specrails-desktop:ui-language`));await Ze(e),wU(e),r(e),a(!0);try{let n=await fetch(t,{method:`PATCH`,headers:SU({"Content-Type":`application/json`}),body:JSON.stringify({language:e})});if(!n.ok)throw Error(`server rejected language: ${n.status}`)}catch(e){throw await Ze(i),o?wU(i):TU(),r(i),e}finally{a(!1)}},[n,t]),c=(0,Q.useMemo)(()=>({languageId:n,language:Xe[n],setLanguage:s,isUpdating:i}),[n,s,i]);return(0,$.jsx)(CU.Provider,{value:c,children:e})}function DU(){return(0,Q.useContext)(CU)}function OU(){let{t:e}=K(`settings`),t=DU();if(!t)return null;let{languageId:n,setLanguage:r,isUpdating:i}=t;async function a(t){if(t!==n)try{await r(t)}catch(t){J.error(e(`language.updateFailed`),{description:t instanceof Error?t.message:void 0})}}return(0,$.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,role:`radiogroup`,"aria-label":e(`language.selectLabel`),children:Re.map(e=>{let t=Xe[e],r=e===n;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,disabled:i,onClick:()=>void a(e),className:`flex items-center justify-between gap-2 rounded-lg border bg-card px-3 py-2 text-left transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/60 disabled:opacity-60 disabled:cursor-not-allowed `+(r?`border-accent-primary ring-1 ring-accent-primary `:`border-border hover:border-accent-primary/40 hover:shadow-md `),"data-testid":`language-card-${e}`,"data-selected":r?`true`:`false`,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-xs font-semibold truncate`,children:t.nativeName}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground truncate`,children:t.englishName})]}),r&&(0,$.jsx)(Ht,{className:`w-3.5 h-3.5 text-accent-primary shrink-0`,"aria-hidden":`true`})]},e)})})}function kU(){let{t:e}=K(`settings`);return DU()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`language.title`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`language.description`)}),(0,$.jsx)(OU,{})]}):null}function AU(){if(!se)return null;let{t:e}=K(`settings`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1;return fetch(`/api/code-explorer-settings`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{e||n(t)}).catch(()=>{e||n({language:`en`,monthlyBudgetUsd:5})}),()=>{e=!0}},[]);async function a(r){if(!t)return;let a={...t,...r};n(a),i(!0);try{let e=await fetch(`/api/code-explorer-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();n(t)}catch(r){J.error(e(`errors.saveFailed`,{message:r.message})),n(t)}finally{i(!1)}}return t?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`codeSection.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`codeSection.summaryLanguage`)}),(0,$.jsxs)(`select`,{value:t.language,disabled:r,onChange:e=>a({language:e.target.value}),className:`bg-background border border-border rounded px-2 py-1 text-xs`,children:[(0,$.jsx)(`option`,{value:`en`,children:`English`}),(0,$.jsx)(`option`,{value:`es`,children:`Español`})]})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`codeSection.monthlyBudget`)}),(0,$.jsx)(`input`,{type:`number`,min:0,step:.5,value:t.monthlyBudgetUsd,disabled:r,onChange:e=>{let t=parseFloat(e.target.value);!isNaN(t)&&t>=0&&a({monthlyBudgetUsd:t})},className:`bg-background border border-border rounded px-2 py-1 text-xs w-24 text-right`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:e(`codeSection.budgetHelper`)})]})]}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})}var jU=`__default__`,MU={"sr-architect":Yo,"sr-developer":ps,"sr-reviewer":ec};function NU(e){let t=e;return!t||!Array.isArray(t.catalog)||typeof t.settings!=`object`||t.settings===null||typeof t.settings.providers!=`object`||t.settings.providers===null?null:t}function PU(){let{t:e}=K(`settings`),t=gz(),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1;return fetch(`/api/agent-defaults`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{if(e)return;let n=NU(t);n?r(n):a(!0)}).catch(()=>{e||a(!0)}),()=>{e=!0}},[]);async function o(t,i){if(!n)return;let a=n;r({...a,settings:{...a.settings,providers:{...a.settings.providers,[t]:i}}});try{let e=await fetch(`/api/agent-defaults`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providers:{[t]:i}})});if(!e.ok){let t=await e.json().catch(()=>({message:`HTTP ${e.status}`}));throw Error(t.message??`HTTP ${e.status}`)}let n=NU(await e.json());if(!n)throw Error(`unexpected response`);r(n)}catch(t){r(a),J.error(e(`errors.saveFailed`,{message:t.message}))}}return i?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`specrailsAgents.loadFailed`)})]}):n?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`specrailsAgents.description`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:n.catalog.map(e=>(0,$.jsx)(IU,{entry:e,config:n.settings.providers[e.id]??{custom:!1},detected:t.loading||t.detected.includes(e.id),unauthenticated:t.providers[e.id]?.authState===`unauthenticated`,version:t.providers[e.id]?.version,onChange:t=>void o(e.id,t)},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})]})}function FU({t:e}){return(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:[(0,$.jsx)(wo,{className:`h-3.5 w-3.5`}),e(`specrailsAgents.heading`)]})}function IU({entry:e,config:t,detected:n,unauthenticated:r,version:i,onChange:a}){let{t:o}=K(`settings`),s=t.custom===!0,c=s||!!t.pipelineModel||!!t.pipelineEffort||Object.keys(t.agentModels??{}).length>0,l=t.pipelineModel??e.defaultModel,u=e.effortsByModel[l]??[],d=e.models.find(t=>t.value===e.defaultModel)?.label??e.defaultModel,f=(0,Q.useMemo)(()=>[{value:jU,label:o(`specrailsAgents.defaultModel`,{model:d})},...e.models.map(e=>({value:e.value,label:e.label})),...t.pipelineModel&&!e.models.some(e=>e.value===t.pipelineModel)?[{value:t.pipelineModel,label:t.pipelineModel}]:[]],[e.models,t.pipelineModel,d,o]),p=(0,Q.useMemo)(()=>[{value:jU,label:o(`specrailsAgents.defaultEffort`)},...u.map(e=>({value:e,label:e}))],[u,o]);function m(n){let r=t.agentModels?.[n];return[{value:jU,label:o(`specrailsAgents.defaultModel`,{model:d})},...e.models.map(e=>({value:e.value,label:e.label})),...r&&!e.models.some(e=>e.value===r)?[{value:r,label:r}]:[]]}function h(e){a({...t,custom:!0,...e})}function g(e,n){let r={...t.agentModels??{}};n===jU?delete r[e]:r[e]=n,h({agentModels:r})}return(0,$.jsxs)(`div`,{"data-testid":`agent-defaults-card-${e.id}`,className:X(`rounded-lg border transition-colors`,s&&n?`border-accent-primary/45`:`border-border`,!n&&`opacity-60`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5`,children:[(0,$.jsx)(Go,{className:`h-4 w-4 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.displayName}),i&&(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:i}),!n&&(0,$.jsx)(`span`,{className:`rounded-full bg-muted/50 px-1.5 py-px text-[10px] leading-4 text-muted-foreground`,children:o(`specrailsAgents.notDetected`)}),n&&r&&(0,$.jsx)(`span`,{className:`rounded-full bg-accent-warning/15 px-1.5 py-px text-[10px] leading-4 text-accent-warning`,children:o(`specrailsAgents.notSignedIn`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[c&&n&&(0,$.jsx)(`button`,{type:`button`,title:o(`specrailsAgents.reset`),"aria-label":o(`specrailsAgents.reset`),"data-testid":`agent-defaults-reset-${e.id}`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,onClick:()=>a({custom:!1}),children:(0,$.jsx)(Zs,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(LU,{custom:s,disabled:!n,providerId:e.id,onToggle:e=>e?h({}):a({...t,custom:!1})})]})]}),(0,$.jsx)(f_,{initial:!1,children:s&&(0,$.jsx)(fy.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.16,ease:`easeOut`},className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-border/60 px-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:o(`specrailsAgents.pipeline`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(uD,{label:o(`specrailsAgents.model`),value:t.pipelineModel??jU,options:f,icon:un,disabled:!n,testId:`agent-defaults-model-${e.id}`,onSelect:e=>h({pipelineModel:e===jU?void 0:e})}),e.supportsEffort&&u.length>0&&(0,$.jsx)(uD,{label:o(`specrailsAgents.effort`),value:t.pipelineEffort??jU,options:p,icon:ss,disabled:!n,testId:`agent-defaults-effort-${e.id}`,onSelect:e=>h({pipelineEffort:e===jU?void 0:e})})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`specrailsAgents.pipelineHint`)})]}),e.perAgentModels?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:o(`specrailsAgents.agentsTitle`)}),(0,$.jsx)(`div`,{className:`space-y-1`,children:e.baselineAgents.map(r=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/60 px-2.5 py-1.5`,children:[(0,$.jsx)(MU[r]??wo,{className:`h-3.5 w-3.5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:o(`specrailsAgents.agentNames.${r}`,{defaultValue:r})}),(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:r}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(uD,{label:o(`specrailsAgents.model`),value:t.agentModels?.[r]??jU,options:m(r),icon:un,disabled:!n,testId:`agent-defaults-agent-${e.id}-${r}`,onSelect:e=>g(r,e)})})]},r))}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`specrailsAgents.agentsHint`)})]}):(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(vs,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),e.id===`codex`?o(`specrailsAgents.inheritNote`):o(`specrailsAgents.noPerAgentNote`)]})]})},`body`)})]})}function LU({custom:e,disabled:t,providerId:n,onToggle:r}){let{t:i}=K(`settings`),a=`rounded-full px-2.5 py-0.5 text-[10px] font-medium transition-colors disabled:cursor-not-allowed`;return(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-full bg-muted/30 p-0.5`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`agent-defaults-mode-default-${n}`,className:X(a,e?`text-muted-foreground hover:text-foreground`:`bg-surface text-foreground shadow-sm`),onClick:()=>r(!1),children:i(`specrailsAgents.modeDefault`)}),(0,$.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`agent-defaults-mode-custom-${n}`,className:X(a,e?`bg-accent-primary/15 text-accent-primary shadow-sm`:`text-muted-foreground hover:text-foreground`),onClick:()=>r(!0),children:i(`specrailsAgents.modeCustom`)})]})}function RU(){let{t:e}=K(`settings`),{registerHandler:t,unregisterHandler:n}=qe(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(0),f=(0,Q.useRef)(null),p=(0,Q.useCallback)(async()=>{let e=++d.current;try{let t=await fetch(`/api/core-update/status`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return e===d.current?(i(n),u(!1),n.updating||c(null),n):null}catch{return e===d.current&&u(!0),null}},[]);(0,Q.useEffect)(()=>{p();let e=()=>{p()};return window.addEventListener(`focus`,e),()=>{d.current++,window.removeEventListener(`focus`,e)}},[p]);let m=(0,Q.useRef)(p);m.current=p,(0,Q.useEffect)(()=>(t(`core-update`,t=>{let n=t;if(n.type===`framework.updated`){m.current();return}if(n.type!==`core_update.progress`)return;let r=n.phase;c(r),r===`done`?(J.success(e(`coreUpdate.toastDone`,{version:String(n.version??``)})),m.current(),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),2500)):r===`error`&&(J.error(e(`coreUpdate.toastError`,{message:String(n.message??``)})),m.current(),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),4e3))}),()=>{n(`core-update`),f.current&&clearTimeout(f.current)}),[t,n,e]);let h=(0,Q.useCallback)(async()=>{let t=++d.current;o(!0);try{let n=await fetch(`/api/core-update/check`,{method:`POST`});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(t!==d.current)return;i(r),r.updateAvailable||J.success(e(`coreUpdate.toastUpToDate`))}catch(t){J.error(e(`coreUpdate.toastCheckFailed`,{message:t.message}))}finally{o(!1)}},[e]),g=s===`downloading`||s===`materializing`||!!r?.updating;(0,Q.useEffect)(()=>{if(!g)return;let e=setInterval(()=>{p()},1500);return()=>clearInterval(e)},[g,p]);let _=(0,Q.useCallback)(async()=>{c(`downloading`);try{let e=await fetch(`/api/core-update/update`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(e.status!==202){let t=await e.json().catch(()=>({}));throw Error(t.message??`HTTP ${e.status}`)}}catch(t){c(null),J.error(e(`coreUpdate.toastError`,{message:t.message}))}},[e]);if(!r)return l?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{p()},className:`text-xs text-destructive`,children:e(`coreUpdate.loadFailed`)}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`});let v=r.currentVersion??`—`,y=r.pendingVersion??r.latestVersion;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`coreUpdate.heading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:r.available?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-foreground`,children:[e(`coreUpdate.installed`),` `,(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:v})]}),r.runtimeVersion&&(0,$.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[e(`coreUpdate.runtime`,{version:r.runtimeVersion}),r.runtimeSource?` · ${e(`coreUpdate.sources.${r.runtimeSource}`)}`:``]}),r.bundledVersion&&r.bundledVersion!==r.runtimeVersion&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`coreUpdate.bundled`,{version:r.bundledVersion})}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:r.updateAvailable&&r.latestVersion?e(`coreUpdate.updateAvailable`,{version:r.latestVersion}):r.lastCheckedAt?e(`coreUpdate.upToDate`):e(`coreUpdate.neverChecked`)})]}),r.updateAvailable&&y?(0,$.jsxs)(`button`,{type:`button`,onClick:_,disabled:g,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-accent-primary/45 bg-accent-primary/15 px-3 text-[11px] font-semibold text-accent-primary disabled:opacity-50`,children:[g?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(tn,{className:`h-3.5 w-3.5`}),g?e(s===`materializing`?`coreUpdate.materializing`:`coreUpdate.downloading`):r.pendingVersion?e(`coreUpdate.repair`,{version:y}):e(`coreUpdate.update`,{version:y})]}):(0,$.jsxs)(`button`,{type:`button`,onClick:h,disabled:a||g,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,children:[a?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):s===`done`?(0,$.jsx)(Mo,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Js,{className:`h-3.5 w-3.5`}),e(a?`coreUpdate.checking`:`coreUpdate.check`)]})]}),r.runtimeError&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.runtimeError}),r.migrationError&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.migrationError}),l&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-destructive`,onClick:()=>{p()},children:e(`coreUpdate.loadFailed`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:e(`coreUpdate.affectsAll`)})]}):(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`coreUpdate.unavailable`)})})]})}var zU=class extends st{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,t){VU(t);let n=new lt;e&&(n.onmessage=e);let r=await Y(`plugin:updater|download`,{onEvent:n,rid:this.rid,...t});this.downloadedBytes=new st(r)}async install(){if(!this.downloadedBytes)throw Error(`Update.install called before Update.download`);await Y(`plugin:updater|install`,{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(e,t){VU(t);let n=new lt;e&&(n.onmessage=e),await Y(`plugin:updater|download_and_install`,{onEvent:n,rid:this.rid,...t})}async close(){await this.downloadedBytes?.close(),await super.close()}};async function BU(e){VU(e);let t=await Y(`plugin:updater|check`,{...e});return t?new zU(t):null}function VU(e){e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}var HU;(function(e){e.Nsis=`nsis`,e.Msi=`msi`,e.Deb=`deb`,e.Rpm=`rpm`,e.AppImage=`appimage`,e.App=`app`})(HU||={});async function UU(){return Y(`plugin:app|version`)}async function WU(){await Y(`plugin:process|restart`)}var GU=`specrails-desktop:dismissedDesktopUpdateVersion`,KU=`specrails-desktop-desktop-update`,qU=360*60*1e3;function JU(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function YU(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE===`true`}function XU(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE_VERSION||`99.0.0-test`}function ZU(e){return new Promise(t=>setTimeout(t,e))}function QU(){return{currentVersion:`1.40.1`,version:XU(),isMock:!0,async downloadAndInstall(e){e({event:`Started`,data:{contentLength:18874368}});for(let t=0;t<12;t+=1)await ZU(180),e({event:`Progress`,data:{chunkLength:1572864}});e({event:`Finished`})}}}function $U(e){return e<1024*1024?G.t(`commands:update.units.kb`,{value:Math.max(1,Math.round(e/1024))}):G.t(`commands:update.units.mb`,{value:(e/(1024*1024)).toFixed(1)})}function eW(){try{return localStorage.getItem(GU)}catch{return null}}function tW(e){try{localStorage.setItem(GU,e)}catch{}J.dismiss(KU)}function nW(e){switch(e){case`downloading`:return`var(--color-accent-info)`;case`ready`:return`var(--color-accent-success)`;default:return`var(--color-accent-primary)`}}function rW({state:e}){let t=`h-[15px] w-[15px]`;return e===`installing`?(0,$.jsx)(Ro,{className:`${t} u-spin`,"aria-hidden":!0}):e===`ready`?(0,$.jsx)(Ht,{className:`${t} u-check`,"aria-hidden":!0}):e===`error`?(0,$.jsx)(fn,{className:t,"aria-hidden":!0}):(0,$.jsx)(Io,{className:t,"aria-hidden":!0})}function iW({state:e,progress:t}){let n=e===`downloading`&&t!=null,r=e===`installing`||e===`downloading`&&t==null,i=e===`ready`;return(0,$.jsxs)(`div`,{className:`relative h-1.5 w-full overflow-hidden rounded-full border border-border/30 bg-background/70`,children:[n&&(0,$.jsx)(`div`,{className:`relative h-full overflow-hidden rounded-full bg-[color:var(--u-accent)] transition-[width] duration-300 ease-out`,style:{width:`${t}%`},role:`progressbar`,"aria-valuenow":t??0,"aria-valuemin":0,"aria-valuemax":100,children:(0,$.jsx)(`span`,{className:`u-shimmer`,"aria-hidden":!0})}),r&&(0,$.jsx)(`span`,{className:`u-indeterminate`,"aria-hidden":!0}),i&&(0,$.jsx)(`div`,{className:`h-full w-full rounded-full bg-[color:var(--u-accent)]/80`,"aria-hidden":!0})]})}function aW({update:e,onClose:t}){let{t:n}=K(`commands`),[r,i]=(0,Q.useState)(`available`),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null);async function d(){try{i(`downloading`),o(0),c(null),u(null),await e.downloadAndInstall(e=>{if(e.event===`Started`){c(e.data.contentLength??null),o(0);return}if(e.event===`Progress`){o(t=>t+e.data.chunkLength);return}i(`installing`)}),i(`ready`)}catch(e){u(e.message||n(`update.errors.installFailed`)),i(`error`)}}function f(){if(e.isMock){J.success(n(`update.mockReady`),{duration:2500}),J.dismiss(KU),t?.();return}Y(`restart_app`).catch(()=>{WU()})}let p=s&&s>0?Math.min(100,Math.round(a/s*100)):null,m=nW(r),h=r===`downloading`||r===`installing`,g=n(r===`downloading`?`update.title.downloading`:r===`installing`?`update.title.installing`:r===`ready`?`update.title.ready`:r===`error`?`update.title.error`:`update.title.available`),_=r===`available`?n(`update.desc.available`):r===`downloading`?p==null?n(`update.desc.fetching`,{size:$U(a)}):n(`update.desc.progress`,{percent:p,downloaded:$U(a),total:$U(s??0)}):r===`installing`?n(`update.desc.installing`):r===`ready`?n(`update.desc.ready`,{version:e.version}):l&&l.length<=80?l:n(`update.desc.errorFallback`),v=r===`available`?`${e.currentVersion} → ${e.version}`:r===`downloading`?n(`update.pill.downloading`):r===`installing`?n(`update.pill.installing`):r===`ready`?n(`update.pill.ready`):null;return(0,$.jsxs)(`div`,{className:`u-update-card relative flex w-full flex-col gap-2 overflow-hidden`,style:{"--u-accent":m},role:r===`error`?`alert`:`status`,"aria-live":r===`error`?`assertive`:`polite`,"data-state":r,children:[(0,$.jsx)(`span`,{className:`u-glow`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`u-badge grid h-7 w-7 shrink-0 place-items-center rounded-lg border border-border/50 bg-background/60 text-[color:var(--u-accent)]`,"aria-hidden":!0,children:(0,$.jsx)(rW,{state:r})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold leading-tight text-foreground`,children:g}),v!=null&&(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap rounded-md border border-border/40 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground`,style:r===`available`?void 0:{color:`var(--u-accent)`},children:v})]}),(0,$.jsx)(`p`,{className:`h-4 truncate text-[11px] leading-4 text-muted-foreground`,"data-testid":`update-description`,children:_}),(0,$.jsx)(iW,{state:r,progress:p}),(0,$.jsx)(`div`,{className:`flex items-center justify-end gap-1.5`,children:r===`ready`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`inline-grid h-7 min-w-[64px] place-items-center rounded-lg border border-[color:var(--u-accent)]/45 bg-[color:var(--u-accent)]/15 px-3 text-[11px] font-semibold leading-none text-foreground transition-colors hover:bg-[color:var(--u-accent)]/25`,onClick:f,children:n(`update.actions.restart`)}),(0,$.jsx)(`button`,{type:`button`,className:`h-7 rounded-lg px-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground`,onClick:()=>{J.dismiss(KU),t?.()},children:n(`update.actions.later`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`inline-grid h-7 min-w-[64px] place-items-center rounded-lg border border-[color:var(--u-accent)]/45 bg-[color:var(--u-accent)]/15 px-3 text-[11px] font-semibold leading-none text-foreground transition-colors hover:bg-[color:var(--u-accent)]/25 disabled:cursor-not-allowed disabled:opacity-50`,disabled:h,onClick:()=>void d(),children:n(r===`installing`?`update.actions.installing`:r===`error`?`update.actions.tryAgain`:`update.actions.update`)}),(0,$.jsx)(`button`,{type:`button`,className:`h-7 rounded-lg px-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,disabled:h,onClick:()=>{tW(e.version),t?.()},children:n(`update.actions.dismiss`)})]})})]})}function oW(e){J.custom(()=>(0,$.jsx)(aW,{update:e}),{id:KU,duration:1/0,dismissible:!1,unstyled:!0,closeButton:!1})}function sW(){(0,Q.useEffect)(()=>{let e=YU();if(!e&&!JU())return;let t=!1,n={current:!1};async function r(){if(!(t||n.current))try{let r=e?QU():await BU();if(t||!r||eW()===r.version)return;n.current=!0,J.custom(()=>(0,$.jsx)(aW,{update:r,onClose:()=>{n.current=!1}}),{id:KU,duration:1/0,dismissible:!1,unstyled:!0,closeButton:!1,onDismiss:()=>{n.current=!1},onAutoClose:()=>{n.current=!1}})}catch(e){console.warn(`[desktop-update] update check failed:`,e)}}r();let i=setInterval(()=>void r(),qU);return()=>{t=!0,clearInterval(i)}},[])}function cW(){let{t:e}=K(`settings`),t=YU(),n=JU()||t,[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!JU())return;let e=!0;return UU().then(t=>{e&&i(t)}).catch(()=>{}),()=>{e=!1}},[]);let d=(0,Q.useCallback)(async()=>{o(!0),c(null);try{let n=t?QU():await BU();n?(c(`update-available`),u(n.version),oW(n)):(c(`up-to-date`),J.success(e(`appUpdate.toastUpToDate`)))}catch(t){J.error(e(`appUpdate.toastCheckFailed`,{message:t.message}))}finally{o(!1)}},[t,e]);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`appUpdate.heading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:n?(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-foreground`,children:[e(`appUpdate.installed`),` `,(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:r??`—`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:s===`update-available`&&l?e(`appUpdate.updateAvailable`,{version:l}):e(s===`up-to-date`?`appUpdate.upToDate`:`appUpdate.autoHint`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void d(),disabled:a,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,children:[a?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):s===`up-to-date`?(0,$.jsx)(Mo,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Js,{className:`h-3.5 w-3.5`}),e(a?`appUpdate.checking`:`appUpdate.check`)]})]})}):(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`appUpdate.unavailable`)})})]})}var lW=Object.defineProperty,uW=Object.getOwnPropertySymbols,dW=Object.prototype.hasOwnProperty,fW=Object.prototype.propertyIsEnumerable,pW=(e,t,n)=>t in e?lW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mW=(e,t)=>{for(var n in t||={})dW.call(t,n)&&pW(e,n,t[n]);if(uW)for(var n of uW(t))fW.call(t,n)&&pW(e,n,t[n]);return e},hW=(e,t)=>{var n={};for(var r in e)dW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&uW)for(var r of uW(e))t.indexOf(r)<0&&fW.call(e,r)&&(n[r]=e[r]);return n},gW;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(gW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(gW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(gW||={});var _W=gW,vW={L:_W.QrCode.Ecc.LOW,M:_W.QrCode.Ecc.MEDIUM,Q:_W.QrCode.Ecc.QUARTILE,H:_W.QrCode.Ecc.HIGH},yW=128,bW=`L`,xW=`#FFFFFF`,SW=`#000000`,CW=!1,wW=1,TW=4,EW=0,DW=.1;function OW(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function kW(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function AW(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*DW),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function jW(e,t){return t==null?e?TW:EW:Math.max(Math.floor(t),0)}function MW({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Q.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(..._W.QrSegment.makeSegments(t)),e),[]);return _W.QrCode.encodeSegments(r,vW[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Q.useMemo(()=>{let e=c.getModules(),t=jW(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:AW(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var NW=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),PW=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=yW,level:a=bW,bgColor:o=xW,fgColor:s=SW,includeMargin:c=CW,minVersion:l=wW,boostLevel:u,marginSize:d,imageSettings:f}=n,p=hW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=hW(p,[`style`]),g=f?.src,_=Q.useRef(null),v=Q.useRef(null),y=Q.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Q.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=MW({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Q.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=kW(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,NW?t.fill(new Path2D(OW(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Q.useEffect(()=>{x(!1)},[g]);let E=mW({height:i,width:i},m),D=null;return g!=null&&(D=Q.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Q.createElement(Q.Fragment,null,Q.createElement(`canvas`,mW({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});PW.displayName=`QRCodeCanvas`;var FW=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=yW,level:a=bW,bgColor:o=xW,fgColor:s=SW,includeMargin:c=CW,minVersion:l=wW,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=hW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=MW({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=kW(g,v.excavation)),b=Q.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=OW(y,h);return Q.createElement(`svg`,mW({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Q.createElement(`title`,null,d),Q.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Q.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});FW.displayName=`QRCodeSVG`;var IW=e(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.jsQR=r():n.jsQR=r()})(typeof self<`u`?self:e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=3)})([(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.BitMatrix=function(){function e(e,t){this.width=t,this.height=e.length/t,this.data=e}return e.createEmpty=function(t,n){return new e(new Uint8ClampedArray(t*n),t)},e.prototype.get=function(e,t){return e<0||e>=this.width||t<0||t>=this.height?!1:!!this.data[t*this.width+e]},e.prototype.set=function(e,t,n){this.data[t*this.width+e]=+!!n},e.prototype.setRegion=function(e,t,n,r,i){for(var a=t;a<t+r;a++)for(var o=e;o<e+n;o++)this.set(o,a,!!i)},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(2);function i(e,t){return e^t}t.addOrSubtractGF=i,t.default=function(){function e(e,t,n){this.primitive=e,this.size=t,this.generatorBase=n,this.expTable=Array(this.size),this.logTable=Array(this.size);for(var i=1,a=0;a<this.size;a++)this.expTable[a]=i,i*=2,i>=this.size&&(i=(i^this.primitive)&this.size-1);for(var a=0;a<this.size-1;a++)this.logTable[this.expTable[a]]=a;this.zero=new r.default(this,Uint8ClampedArray.from([0])),this.one=new r.default(this,Uint8ClampedArray.from([1]))}return e.prototype.multiply=function(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.size-1)]},e.prototype.inverse=function(e){if(e===0)throw Error(`Can't invert 0`);return this.expTable[this.size-this.logTable[e]-1]},e.prototype.buildMonomial=function(e,t){if(e<0)throw Error(`Invalid monomial degree less than 0`);if(t===0)return this.zero;var n=new Uint8ClampedArray(e+1);return n[0]=t,new r.default(this,n)},e.prototype.log=function(e){if(e===0)throw Error(`Can't take log(0)`);return this.logTable[e]},e.prototype.exp=function(e){return this.expTable[e]},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);t.default=function(){function e(e,t){if(t.length===0)throw Error(`No coefficients.`);this.field=e;var n=t.length;if(n>1&&t[0]===0){for(var r=1;r<n&&t[r]===0;)r++;if(r===n)this.coefficients=e.zero.coefficients;else{this.coefficients=new Uint8ClampedArray(n-r);for(var i=0;i<this.coefficients.length;i++)this.coefficients[i]=t[r+i]}}else this.coefficients=t}return e.prototype.degree=function(){return this.coefficients.length-1},e.prototype.isZero=function(){return this.coefficients[0]===0},e.prototype.getCoefficient=function(e){return this.coefficients[this.coefficients.length-1-e]},e.prototype.addOrSubtract=function(t){var n;if(this.isZero())return t;if(t.isZero())return this;var i=this.coefficients,a=t.coefficients;i.length>a.length&&(n=[a,i],i=n[0],a=n[1]);for(var o=new Uint8ClampedArray(a.length),s=a.length-i.length,c=0;c<s;c++)o[c]=a[c];for(var c=s;c<a.length;c++)o[c]=r.addOrSubtractGF(i[c-s],a[c]);return new e(this.field,o)},e.prototype.multiply=function(t){if(t===0)return this.field.zero;if(t===1)return this;for(var n=this.coefficients.length,r=new Uint8ClampedArray(n),i=0;i<n;i++)r[i]=this.field.multiply(this.coefficients[i],t);return new e(this.field,r)},e.prototype.multiplyPoly=function(t){if(this.isZero()||t.isZero())return this.field.zero;for(var n=this.coefficients,i=n.length,a=t.coefficients,o=a.length,s=new Uint8ClampedArray(i+o-1),c=0;c<i;c++)for(var l=n[c],u=0;u<o;u++)s[c+u]=r.addOrSubtractGF(s[c+u],this.field.multiply(l,a[u]));return new e(this.field,s)},e.prototype.multiplyByMonomial=function(t,n){if(t<0)throw Error(`Invalid degree less than 0`);if(n===0)return this.field.zero;for(var r=this.coefficients.length,i=new Uint8ClampedArray(r+t),a=0;a<r;a++)i[a]=this.field.multiply(this.coefficients[a],n);return new e(this.field,i)},e.prototype.evaluateAt=function(e){var t=0;if(e===0)return this.getCoefficient(0);var n=this.coefficients.length;if(e===1)return this.coefficients.forEach(function(e){t=r.addOrSubtractGF(t,e)}),t;t=this.coefficients[0];for(var i=1;i<n;i++)t=r.addOrSubtractGF(this.field.multiply(e,t),this.coefficients[i]);return t},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(4),i=n(5),a=n(11),o=n(12);function s(e){var t=o.locate(e);if(!t)return null;for(var n=0,r=t;n<r.length;n++){var s=r[n],c=a.extract(e,s),l=i.decode(c.matrix);if(l)return{binaryData:l.bytes,data:l.text,chunks:l.chunks,version:l.version,location:{topRightCorner:c.mappingFunction(s.dimension,0),topLeftCorner:c.mappingFunction(0,0),bottomRightCorner:c.mappingFunction(s.dimension,s.dimension),bottomLeftCorner:c.mappingFunction(0,s.dimension),topRightFinderPattern:s.topRight,topLeftFinderPattern:s.topLeft,bottomLeftFinderPattern:s.bottomLeft,bottomRightAlignmentPattern:s.alignmentPattern}}}return null}var c={inversionAttempts:`attemptBoth`};function l(e,t,n,i){i===void 0&&(i={});var a=c;Object.keys(a||{}).forEach(function(e){a[e]=i[e]||a[e]});var o=a.inversionAttempts===`attemptBoth`||a.inversionAttempts===`invertFirst`,l=a.inversionAttempts===`onlyInvert`||a.inversionAttempts===`invertFirst`,u=r.binarize(e,t,n,o),d=u.binarized,f=u.inverted,p=s(l?f:d);return!p&&(a.inversionAttempts===`attemptBoth`||a.inversionAttempts===`invertFirst`)&&(p=s(l?d:f)),p}l.default=l,t.default=l}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=8,a=24;function o(e,t,n){return e<t?t:e>n?n:e}var s=function(){function e(e,t){this.width=e,this.data=new Uint8ClampedArray(e*t)}return e.prototype.get=function(e,t){return this.data[t*this.width+e]},e.prototype.set=function(e,t,n){this.data[t*this.width+e]=n},e}();function c(e,t,n,c){if(e.length!==t*n*4)throw Error(`Malformed data passed to binarizer.`);for(var l=new s(t,n),u=0;u<t;u++)for(var d=0;d<n;d++){var f=e[(d*t+u)*4+0],p=e[(d*t+u)*4+1],m=e[(d*t+u)*4+2];l.set(u,d,.2126*f+.7152*p+.0722*m)}for(var h=Math.ceil(t/i),g=Math.ceil(n/i),_=new s(h,g),v=0;v<g;v++)for(var y=0;y<h;y++){for(var b=0,x=1/0,S=0,d=0;d<i;d++)for(var u=0;u<i;u++){var C=l.get(y*i+u,v*i+d);b+=C,x=Math.min(x,C),S=Math.max(S,C)}var w=b/i**2;if(S-x<=a&&(w=x/2,v>0&&y>0)){var T=(_.get(y,v-1)+2*_.get(y-1,v)+_.get(y-1,v-1))/4;x<T&&(w=T)}_.set(y,v,w)}var E=r.BitMatrix.createEmpty(t,n),D=null;c&&(D=r.BitMatrix.createEmpty(t,n));for(var v=0;v<g;v++)for(var y=0;y<h;y++){for(var O=o(y,2,h-3),k=o(v,2,g-3),b=0,A=-2;A<=2;A++)for(var j=-2;j<=2;j++)b+=_.get(O+A,k+j);for(var M=b/25,A=0;A<i;A++)for(var j=0;j<i;j++){var u=y*i+A,d=v*i+j,N=l.get(u,d);E.set(u,d,N<=M),c&&D.set(u,d,!(N<=M))}}return c?{binarized:E,inverted:D}:{binarized:E}}t.binarize=c}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(6),a=n(9),o=n(10);function s(e,t){for(var n=e^t,r=0;n;)r++,n&=n-1;return r}function c(e,t){return t<<1|e}var l=[{bits:21522,formatInfo:{errorCorrectionLevel:1,dataMask:0}},{bits:20773,formatInfo:{errorCorrectionLevel:1,dataMask:1}},{bits:24188,formatInfo:{errorCorrectionLevel:1,dataMask:2}},{bits:23371,formatInfo:{errorCorrectionLevel:1,dataMask:3}},{bits:17913,formatInfo:{errorCorrectionLevel:1,dataMask:4}},{bits:16590,formatInfo:{errorCorrectionLevel:1,dataMask:5}},{bits:20375,formatInfo:{errorCorrectionLevel:1,dataMask:6}},{bits:19104,formatInfo:{errorCorrectionLevel:1,dataMask:7}},{bits:30660,formatInfo:{errorCorrectionLevel:0,dataMask:0}},{bits:29427,formatInfo:{errorCorrectionLevel:0,dataMask:1}},{bits:32170,formatInfo:{errorCorrectionLevel:0,dataMask:2}},{bits:30877,formatInfo:{errorCorrectionLevel:0,dataMask:3}},{bits:26159,formatInfo:{errorCorrectionLevel:0,dataMask:4}},{bits:25368,formatInfo:{errorCorrectionLevel:0,dataMask:5}},{bits:27713,formatInfo:{errorCorrectionLevel:0,dataMask:6}},{bits:26998,formatInfo:{errorCorrectionLevel:0,dataMask:7}},{bits:5769,formatInfo:{errorCorrectionLevel:3,dataMask:0}},{bits:5054,formatInfo:{errorCorrectionLevel:3,dataMask:1}},{bits:7399,formatInfo:{errorCorrectionLevel:3,dataMask:2}},{bits:6608,formatInfo:{errorCorrectionLevel:3,dataMask:3}},{bits:1890,formatInfo:{errorCorrectionLevel:3,dataMask:4}},{bits:597,formatInfo:{errorCorrectionLevel:3,dataMask:5}},{bits:3340,formatInfo:{errorCorrectionLevel:3,dataMask:6}},{bits:2107,formatInfo:{errorCorrectionLevel:3,dataMask:7}},{bits:13663,formatInfo:{errorCorrectionLevel:2,dataMask:0}},{bits:12392,formatInfo:{errorCorrectionLevel:2,dataMask:1}},{bits:16177,formatInfo:{errorCorrectionLevel:2,dataMask:2}},{bits:14854,formatInfo:{errorCorrectionLevel:2,dataMask:3}},{bits:9396,formatInfo:{errorCorrectionLevel:2,dataMask:4}},{bits:8579,formatInfo:{errorCorrectionLevel:2,dataMask:5}},{bits:11994,formatInfo:{errorCorrectionLevel:2,dataMask:6}},{bits:11245,formatInfo:{errorCorrectionLevel:2,dataMask:7}}],u=[function(e){return(e.y+e.x)%2==0},function(e){return e.y%2==0},function(e){return e.x%3==0},function(e){return(e.y+e.x)%3==0},function(e){return(Math.floor(e.y/2)+Math.floor(e.x/3))%2==0},function(e){return e.x*e.y%2+e.x*e.y%3==0},function(e){return(e.y*e.x%2+e.y*e.x%3)%2==0},function(e){return((e.y+e.x)%2+e.y*e.x%3)%2==0}];function d(e){var t=17+4*e.versionNumber,n=r.BitMatrix.createEmpty(t,t);n.setRegion(0,0,9,9,!0),n.setRegion(t-8,0,8,9,!0),n.setRegion(0,t-8,9,8,!0);for(var i=0,a=e.alignmentPatternCenters;i<a.length;i++)for(var o=a[i],s=0,c=e.alignmentPatternCenters;s<c.length;s++){var l=c[s];o===6&&l===6||o===6&&l===t-7||o===t-7&&l===6||n.setRegion(o-2,l-2,5,5,!0)}return n.setRegion(6,9,1,t-17,!0),n.setRegion(9,6,t-17,1,!0),e.versionNumber>6&&(n.setRegion(t-11,0,3,6,!0),n.setRegion(0,t-11,6,3,!0)),n}function f(e,t,n){for(var r=u[n.dataMask],i=e.height,a=d(t),o=[],s=0,l=0,f=!0,p=i-1;p>0;p-=2){p===6&&p--;for(var m=0;m<i;m++)for(var h=f?i-1-m:m,g=0;g<2;g++){var _=p-g;if(!a.get(_,h)){l++;var v=e.get(_,h);r({y:h,x:_})&&(v=!v),s=c(v,s),l===8&&(o.push(s),l=0,s=0)}}f=!f}return o}function p(e){var t=e.height,n=Math.floor((t-17)/4);if(n<=6)return o.VERSIONS[n-1];for(var r=0,i=5;i>=0;i--)for(var a=t-9;a>=t-11;a--)r=c(e.get(a,i),r);for(var l=0,a=5;a>=0;a--)for(var i=t-9;i>=t-11;i--)l=c(e.get(a,i),l);for(var u=1/0,d,f=0,p=o.VERSIONS;f<p.length;f++){var m=p[f];if(m.infoBits===r||m.infoBits===l)return m;var h=s(r,m.infoBits);h<u&&(d=m,u=h),h=s(l,m.infoBits),h<u&&(d=m,u=h)}if(u<=3)return d}function m(e){for(var t=0,n=0;n<=8;n++)n!==6&&(t=c(e.get(n,8),t));for(var r=7;r>=0;r--)r!==6&&(t=c(e.get(8,r),t));for(var i=e.height,a=0,r=i-1;r>=i-7;r--)a=c(e.get(8,r),a);for(var n=i-8;n<i;n++)a=c(e.get(n,8),a);for(var o=1/0,u=null,d=0,f=l;d<f.length;d++){var p=f[d],m=p.bits,h=p.formatInfo;if(m===t||m===a)return h;var g=s(t,m);g<o&&(u=h,o=g),t!==a&&(g=s(a,m),g<o&&(u=h,o=g))}return o<=3?u:null}function h(e,t,n){var r=t.errorCorrectionLevels[n],i=[],a=0;if(r.ecBlocks.forEach(function(e){for(var t=0;t<e.numBlocks;t++)i.push({numDataCodewords:e.dataCodewordsPerBlock,codewords:[]}),a+=e.dataCodewordsPerBlock+r.ecCodewordsPerBlock}),e.length<a)return null;e=e.slice(0,a);for(var o=r.ecBlocks[0].dataCodewordsPerBlock,s=0;s<o;s++)for(var c=0,l=i;c<l.length;c++){var u=l[c];u.codewords.push(e.shift())}if(r.ecBlocks.length>1)for(var d=r.ecBlocks[0].numBlocks,f=r.ecBlocks[1].numBlocks,s=0;s<f;s++)i[d+s].codewords.push(e.shift());for(;e.length>0;)for(var p=0,m=i;p<m.length;p++){var u=m[p];u.codewords.push(e.shift())}return i}function g(e){var t=p(e);if(!t)return null;var n=m(e);if(!n)return null;var r=h(f(e,t,n),t,n.errorCorrectionLevel);if(!r)return null;for(var o=r.reduce(function(e,t){return e+t.numDataCodewords},0),s=new Uint8ClampedArray(o),c=0,l=0,u=r;l<u.length;l++){var d=u[l],g=a.decode(d.codewords,d.codewords.length-d.numDataCodewords);if(!g)return null;for(var _=0;_<d.numDataCodewords;_++)s[c++]=g[_]}try{return i.decode(s,t.versionNumber)}catch{return null}}function _(e){if(e==null)return null;var t=g(e);if(t)return t;for(var n=0;n<e.width;n++)for(var r=n+1;r<e.height;r++)e.get(n,r)!==e.get(r,n)&&(e.set(n,r,!e.get(n,r)),e.set(r,n,!e.get(r,n)));return g(e)}t.decode=_}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(8),a;(function(e){e.Numeric=`numeric`,e.Alphanumeric=`alphanumeric`,e.Byte=`byte`,e.Kanji=`kanji`,e.ECI=`eci`})(a=t.Mode||={});var o;(function(e){e[e.Terminator=0]=`Terminator`,e[e.Numeric=1]=`Numeric`,e[e.Alphanumeric=2]=`Alphanumeric`,e[e.Byte=4]=`Byte`,e[e.Kanji=8]=`Kanji`,e[e.ECI=7]=`ECI`})(o||={});function s(e,t){for(var n=[],r=``,i=[10,12,14][t],a=e.readBits(i);a>=3;){var o=e.readBits(10);if(o>=1e3)throw Error(`Invalid numeric value above 999`);var s=Math.floor(o/100),c=Math.floor(o/10)%10,l=o%10;n.push(48+s,48+c,48+l),r+=s.toString()+c.toString()+l.toString(),a-=3}if(a===2){var o=e.readBits(7);if(o>=100)throw Error(`Invalid numeric value above 99`);var s=Math.floor(o/10),c=o%10;n.push(48+s,48+c),r+=s.toString()+c.toString()}else if(a===1){var o=e.readBits(4);if(o>=10)throw Error(`Invalid numeric value above 9`);n.push(48+o),r+=o.toString()}return{bytes:n,text:r}}var c=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function l(e,t){for(var n=[],r=``,i=[9,11,13][t],a=e.readBits(i);a>=2;){var o=e.readBits(11),s=Math.floor(o/45),l=o%45;n.push(c[s].charCodeAt(0),c[l].charCodeAt(0)),r+=c[s]+c[l],a-=2}if(a===1){var s=e.readBits(6);n.push(c[s].charCodeAt(0)),r+=c[s]}return{bytes:n,text:r}}function u(e,t){for(var n=[],r=``,i=[8,16,16][t],a=e.readBits(i),o=0;o<a;o++){var s=e.readBits(8);n.push(s)}try{r+=decodeURIComponent(n.map(function(e){return`%`+(`0`+e.toString(16)).substr(-2)}).join(``))}catch{}return{bytes:n,text:r}}function d(e,t){for(var n=[],r=``,a=[8,10,12][t],o=e.readBits(a),s=0;s<o;s++){var c=e.readBits(13),l=Math.floor(c/192)<<8|c%192;l<7936?l+=33088:l+=49472,n.push(l>>8,l&255),r+=String.fromCharCode(i.shiftJISTable[l])}return{bytes:n,text:r}}function f(e,t){for(var n,i,c,f,p=new r.BitStream(e),m=t<=9?0:t<=26?1:2,h={text:``,bytes:[],chunks:[],version:t};p.available()>=4;){var g=p.readBits(4);if(g===o.Terminator)return h;if(g===o.ECI)p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(7)}):p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(14)}):p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(21)}):h.chunks.push({type:a.ECI,assignmentNumber:-1});else if(g===o.Numeric){var _=s(p,m);h.text+=_.text,(n=h.bytes).push.apply(n,_.bytes),h.chunks.push({type:a.Numeric,text:_.text})}else if(g===o.Alphanumeric){var v=l(p,m);h.text+=v.text,(i=h.bytes).push.apply(i,v.bytes),h.chunks.push({type:a.Alphanumeric,text:v.text})}else if(g===o.Byte){var y=u(p,m);h.text+=y.text,(c=h.bytes).push.apply(c,y.bytes),h.chunks.push({type:a.Byte,bytes:y.bytes,text:y.text})}else if(g===o.Kanji){var b=d(p,m);h.text+=b.text,(f=h.bytes).push.apply(f,b.bytes),h.chunks.push({type:a.Kanji,bytes:b.bytes,text:b.text})}}if(p.available()===0||p.readBits(p.available())===0)return h}t.decode=f}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.BitStream=function(){function e(e){this.byteOffset=0,this.bitOffset=0,this.bytes=e}return e.prototype.readBits=function(e){if(e<1||e>32||e>this.available())throw Error(`Cannot read `+e.toString()+` bits`);var t=0;if(this.bitOffset>0){var n=8-this.bitOffset,r=e<n?e:n,i=n-r,a=255>>8-r<<i;t=(this.bytes[this.byteOffset]&a)>>i,e-=r,this.bitOffset+=r,this.bitOffset===8&&(this.bitOffset=0,this.byteOffset++)}if(e>0){for(;e>=8;)t=t<<8|this.bytes[this.byteOffset]&255,this.byteOffset++,e-=8;if(e>0){var i=8-e,a=255>>i<<i;t=t<<e|(this.bytes[this.byteOffset]&a)>>i,this.bitOffset+=e}}return t},e.prototype.available=function(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.shiftJISTable={32:32,33:33,34:34,35:35,36:36,37:37,38:38,39:39,40:40,41:41,42:42,43:43,44:44,45:45,46:46,47:47,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,58:58,59:59,60:60,61:61,62:62,63:63,64:64,65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,91:91,92:165,93:93,94:94,95:95,96:96,97:97,98:98,99:99,100:100,101:101,102:102,103:103,104:104,105:105,106:106,107:107,108:108,109:109,110:110,111:111,112:112,113:113,114:114,115:115,116:116,117:117,118:118,119:119,120:120,121:121,122:122,123:123,124:124,125:125,126:8254,33088:12288,33089:12289,33090:12290,33091:65292,33092:65294,33093:12539,33094:65306,33095:65307,33096:65311,33097:65281,33098:12443,33099:12444,33100:180,33101:65344,33102:168,33103:65342,33104:65507,33105:65343,33106:12541,33107:12542,33108:12445,33109:12446,33110:12291,33111:20189,33112:12293,33113:12294,33114:12295,33115:12540,33116:8213,33117:8208,33118:65295,33119:92,33120:12316,33121:8214,33122:65372,33123:8230,33124:8229,33125:8216,33126:8217,33127:8220,33128:8221,33129:65288,33130:65289,33131:12308,33132:12309,33133:65339,33134:65341,33135:65371,33136:65373,33137:12296,33138:12297,33139:12298,33140:12299,33141:12300,33142:12301,33143:12302,33144:12303,33145:12304,33146:12305,33147:65291,33148:8722,33149:177,33150:215,33152:247,33153:65309,33154:8800,33155:65308,33156:65310,33157:8806,33158:8807,33159:8734,33160:8756,33161:9794,33162:9792,33163:176,33164:8242,33165:8243,33166:8451,33167:65509,33168:65284,33169:162,33170:163,33171:65285,33172:65283,33173:65286,33174:65290,33175:65312,33176:167,33177:9734,33178:9733,33179:9675,33180:9679,33181:9678,33182:9671,33183:9670,33184:9633,33185:9632,33186:9651,33187:9650,33188:9661,33189:9660,33190:8251,33191:12306,33192:8594,33193:8592,33194:8593,33195:8595,33196:12307,33208:8712,33209:8715,33210:8838,33211:8839,33212:8834,33213:8835,33214:8746,33215:8745,33224:8743,33225:8744,33226:172,33227:8658,33228:8660,33229:8704,33230:8707,33242:8736,33243:8869,33244:8978,33245:8706,33246:8711,33247:8801,33248:8786,33249:8810,33250:8811,33251:8730,33252:8765,33253:8733,33254:8757,33255:8747,33256:8748,33264:8491,33265:8240,33266:9839,33267:9837,33268:9834,33269:8224,33270:8225,33271:182,33276:9711,33359:65296,33360:65297,33361:65298,33362:65299,33363:65300,33364:65301,33365:65302,33366:65303,33367:65304,33368:65305,33376:65313,33377:65314,33378:65315,33379:65316,33380:65317,33381:65318,33382:65319,33383:65320,33384:65321,33385:65322,33386:65323,33387:65324,33388:65325,33389:65326,33390:65327,33391:65328,33392:65329,33393:65330,33394:65331,33395:65332,33396:65333,33397:65334,33398:65335,33399:65336,33400:65337,33401:65338,33409:65345,33410:65346,33411:65347,33412:65348,33413:65349,33414:65350,33415:65351,33416:65352,33417:65353,33418:65354,33419:65355,33420:65356,33421:65357,33422:65358,33423:65359,33424:65360,33425:65361,33426:65362,33427:65363,33428:65364,33429:65365,33430:65366,33431:65367,33432:65368,33433:65369,33434:65370,33439:12353,33440:12354,33441:12355,33442:12356,33443:12357,33444:12358,33445:12359,33446:12360,33447:12361,33448:12362,33449:12363,33450:12364,33451:12365,33452:12366,33453:12367,33454:12368,33455:12369,33456:12370,33457:12371,33458:12372,33459:12373,33460:12374,33461:12375,33462:12376,33463:12377,33464:12378,33465:12379,33466:12380,33467:12381,33468:12382,33469:12383,33470:12384,33471:12385,33472:12386,33473:12387,33474:12388,33475:12389,33476:12390,33477:12391,33478:12392,33479:12393,33480:12394,33481:12395,33482:12396,33483:12397,33484:12398,33485:12399,33486:12400,33487:12401,33488:12402,33489:12403,33490:12404,33491:12405,33492:12406,33493:12407,33494:12408,33495:12409,33496:12410,33497:12411,33498:12412,33499:12413,33500:12414,33501:12415,33502:12416,33503:12417,33504:12418,33505:12419,33506:12420,33507:12421,33508:12422,33509:12423,33510:12424,33511:12425,33512:12426,33513:12427,33514:12428,33515:12429,33516:12430,33517:12431,33518:12432,33519:12433,33520:12434,33521:12435,33600:12449,33601:12450,33602:12451,33603:12452,33604:12453,33605:12454,33606:12455,33607:12456,33608:12457,33609:12458,33610:12459,33611:12460,33612:12461,33613:12462,33614:12463,33615:12464,33616:12465,33617:12466,33618:12467,33619:12468,33620:12469,33621:12470,33622:12471,33623:12472,33624:12473,33625:12474,33626:12475,33627:12476,33628:12477,33629:12478,33630:12479,33631:12480,33632:12481,33633:12482,33634:12483,33635:12484,33636:12485,33637:12486,33638:12487,33639:12488,33640:12489,33641:12490,33642:12491,33643:12492,33644:12493,33645:12494,33646:12495,33647:12496,33648:12497,33649:12498,33650:12499,33651:12500,33652:12501,33653:12502,33654:12503,33655:12504,33656:12505,33657:12506,33658:12507,33659:12508,33660:12509,33661:12510,33662:12511,33664:12512,33665:12513,33666:12514,33667:12515,33668:12516,33669:12517,33670:12518,33671:12519,33672:12520,33673:12521,33674:12522,33675:12523,33676:12524,33677:12525,33678:12526,33679:12527,33680:12528,33681:12529,33682:12530,33683:12531,33684:12532,33685:12533,33686:12534,33695:913,33696:914,33697:915,33698:916,33699:917,33700:918,33701:919,33702:920,33703:921,33704:922,33705:923,33706:924,33707:925,33708:926,33709:927,33710:928,33711:929,33712:931,33713:932,33714:933,33715:934,33716:935,33717:936,33718:937,33727:945,33728:946,33729:947,33730:948,33731:949,33732:950,33733:951,33734:952,33735:953,33736:954,33737:955,33738:956,33739:957,33740:958,33741:959,33742:960,33743:961,33744:963,33745:964,33746:965,33747:966,33748:967,33749:968,33750:969,33856:1040,33857:1041,33858:1042,33859:1043,33860:1044,33861:1045,33862:1025,33863:1046,33864:1047,33865:1048,33866:1049,33867:1050,33868:1051,33869:1052,33870:1053,33871:1054,33872:1055,33873:1056,33874:1057,33875:1058,33876:1059,33877:1060,33878:1061,33879:1062,33880:1063,33881:1064,33882:1065,33883:1066,33884:1067,33885:1068,33886:1069,33887:1070,33888:1071,33904:1072,33905:1073,33906:1074,33907:1075,33908:1076,33909:1077,33910:1105,33911:1078,33912:1079,33913:1080,33914:1081,33915:1082,33916:1083,33917:1084,33918:1085,33920:1086,33921:1087,33922:1088,33923:1089,33924:1090,33925:1091,33926:1092,33927:1093,33928:1094,33929:1095,33930:1096,33931:1097,33932:1098,33933:1099,33934:1100,33935:1101,33936:1102,33937:1103,33951:9472,33952:9474,33953:9484,33954:9488,33955:9496,33956:9492,33957:9500,33958:9516,33959:9508,33960:9524,33961:9532,33962:9473,33963:9475,33964:9487,33965:9491,33966:9499,33967:9495,33968:9507,33969:9523,33970:9515,33971:9531,33972:9547,33973:9504,33974:9519,33975:9512,33976:9527,33977:9535,33978:9501,33979:9520,33980:9509,33981:9528,33982:9538,34975:20124,34976:21782,34977:23043,34978:38463,34979:21696,34980:24859,34981:25384,34982:23030,34983:36898,34984:33909,34985:33564,34986:31312,34987:24746,34988:25569,34989:28197,34990:26093,34991:33894,34992:33446,34993:39925,34994:26771,34995:22311,34996:26017,34997:25201,34998:23451,34999:22992,35e3:34427,35001:39156,35002:32098,35003:32190,35004:39822,35005:25110,35006:31903,35007:34999,35008:23433,35009:24245,35010:25353,35011:26263,35012:26696,35013:38343,35014:38797,35015:26447,35016:20197,35017:20234,35018:20301,35019:20381,35020:20553,35021:22258,35022:22839,35023:22996,35024:23041,35025:23561,35026:24799,35027:24847,35028:24944,35029:26131,35030:26885,35031:28858,35032:30031,35033:30064,35034:31227,35035:32173,35036:32239,35037:32963,35038:33806,35039:34915,35040:35586,35041:36949,35042:36986,35043:21307,35044:20117,35045:20133,35046:22495,35047:32946,35048:37057,35049:30959,35050:19968,35051:22769,35052:28322,35053:36920,35054:31282,35055:33576,35056:33419,35057:39983,35058:20801,35059:21360,35060:21693,35061:21729,35062:22240,35063:23035,35064:24341,35065:39154,35066:28139,35067:32996,35068:34093,35136:38498,35137:38512,35138:38560,35139:38907,35140:21515,35141:21491,35142:23431,35143:28879,35144:32701,35145:36802,35146:38632,35147:21359,35148:40284,35149:31418,35150:19985,35151:30867,35152:33276,35153:28198,35154:22040,35155:21764,35156:27421,35157:34074,35158:39995,35159:23013,35160:21417,35161:28006,35162:29916,35163:38287,35164:22082,35165:20113,35166:36939,35167:38642,35168:33615,35169:39180,35170:21473,35171:21942,35172:23344,35173:24433,35174:26144,35175:26355,35176:26628,35177:27704,35178:27891,35179:27945,35180:29787,35181:30408,35182:31310,35183:38964,35184:33521,35185:34907,35186:35424,35187:37613,35188:28082,35189:30123,35190:30410,35191:39365,35192:24742,35193:35585,35194:36234,35195:38322,35196:27022,35197:21421,35198:20870,35200:22290,35201:22576,35202:22852,35203:23476,35204:24310,35205:24616,35206:25513,35207:25588,35208:27839,35209:28436,35210:28814,35211:28948,35212:29017,35213:29141,35214:29503,35215:32257,35216:33398,35217:33489,35218:34199,35219:36960,35220:37467,35221:40219,35222:22633,35223:26044,35224:27738,35225:29989,35226:20985,35227:22830,35228:22885,35229:24448,35230:24540,35231:25276,35232:26106,35233:27178,35234:27431,35235:27572,35236:29579,35237:32705,35238:35158,35239:40236,35240:40206,35241:40644,35242:23713,35243:27798,35244:33659,35245:20740,35246:23627,35247:25014,35248:33222,35249:26742,35250:29281,35251:20057,35252:20474,35253:21368,35254:24681,35255:28201,35256:31311,35257:38899,35258:19979,35259:21270,35260:20206,35261:20309,35262:20285,35263:20385,35264:20339,35265:21152,35266:21487,35267:22025,35268:22799,35269:23233,35270:23478,35271:23521,35272:31185,35273:26247,35274:26524,35275:26550,35276:27468,35277:27827,35278:28779,35279:29634,35280:31117,35281:31166,35282:31292,35283:31623,35284:33457,35285:33499,35286:33540,35287:33655,35288:33775,35289:33747,35290:34662,35291:35506,35292:22057,35293:36008,35294:36838,35295:36942,35296:38686,35297:34442,35298:20420,35299:23784,35300:25105,35301:29273,35302:30011,35303:33253,35304:33469,35305:34558,35306:36032,35307:38597,35308:39187,35309:39381,35310:20171,35311:20250,35312:35299,35313:22238,35314:22602,35315:22730,35316:24315,35317:24555,35318:24618,35319:24724,35320:24674,35321:25040,35322:25106,35323:25296,35324:25913,35392:39745,35393:26214,35394:26800,35395:28023,35396:28784,35397:30028,35398:30342,35399:32117,35400:33445,35401:34809,35402:38283,35403:38542,35404:35997,35405:20977,35406:21182,35407:22806,35408:21683,35409:23475,35410:23830,35411:24936,35412:27010,35413:28079,35414:30861,35415:33995,35416:34903,35417:35442,35418:37799,35419:39608,35420:28012,35421:39336,35422:34521,35423:22435,35424:26623,35425:34510,35426:37390,35427:21123,35428:22151,35429:21508,35430:24275,35431:25313,35432:25785,35433:26684,35434:26680,35435:27579,35436:29554,35437:30906,35438:31339,35439:35226,35440:35282,35441:36203,35442:36611,35443:37101,35444:38307,35445:38548,35446:38761,35447:23398,35448:23731,35449:27005,35450:38989,35451:38990,35452:25499,35453:31520,35454:27179,35456:27263,35457:26806,35458:39949,35459:28511,35460:21106,35461:21917,35462:24688,35463:25324,35464:27963,35465:28167,35466:28369,35467:33883,35468:35088,35469:36676,35470:19988,35471:39993,35472:21494,35473:26907,35474:27194,35475:38788,35476:26666,35477:20828,35478:31427,35479:33970,35480:37340,35481:37772,35482:22107,35483:40232,35484:26658,35485:33541,35486:33841,35487:31909,35488:21e3,35489:33477,35490:29926,35491:20094,35492:20355,35493:20896,35494:23506,35495:21002,35496:21208,35497:21223,35498:24059,35499:21914,35500:22570,35501:23014,35502:23436,35503:23448,35504:23515,35505:24178,35506:24185,35507:24739,35508:24863,35509:24931,35510:25022,35511:25563,35512:25954,35513:26577,35514:26707,35515:26874,35516:27454,35517:27475,35518:27735,35519:28450,35520:28567,35521:28485,35522:29872,35523:29976,35524:30435,35525:30475,35526:31487,35527:31649,35528:31777,35529:32233,35530:32566,35531:32752,35532:32925,35533:33382,35534:33694,35535:35251,35536:35532,35537:36011,35538:36996,35539:37969,35540:38291,35541:38289,35542:38306,35543:38501,35544:38867,35545:39208,35546:33304,35547:20024,35548:21547,35549:23736,35550:24012,35551:29609,35552:30284,35553:30524,35554:23721,35555:32747,35556:36107,35557:38593,35558:38929,35559:38996,35560:39e3,35561:20225,35562:20238,35563:21361,35564:21916,35565:22120,35566:22522,35567:22855,35568:23305,35569:23492,35570:23696,35571:24076,35572:24190,35573:24524,35574:25582,35575:26426,35576:26071,35577:26082,35578:26399,35579:26827,35580:26820,35648:27231,35649:24112,35650:27589,35651:27671,35652:27773,35653:30079,35654:31048,35655:23395,35656:31232,35657:32e3,35658:24509,35659:35215,35660:35352,35661:36020,35662:36215,35663:36556,35664:36637,35665:39138,35666:39438,35667:39740,35668:20096,35669:20605,35670:20736,35671:22931,35672:23452,35673:25135,35674:25216,35675:25836,35676:27450,35677:29344,35678:30097,35679:31047,35680:32681,35681:34811,35682:35516,35683:35696,35684:25516,35685:33738,35686:38816,35687:21513,35688:21507,35689:21931,35690:26708,35691:27224,35692:35440,35693:30759,35694:26485,35695:40653,35696:21364,35697:23458,35698:33050,35699:34384,35700:36870,35701:19992,35702:20037,35703:20167,35704:20241,35705:21450,35706:21560,35707:23470,35708:24339,35709:24613,35710:25937,35712:26429,35713:27714,35714:27762,35715:27875,35716:28792,35717:29699,35718:31350,35719:31406,35720:31496,35721:32026,35722:31998,35723:32102,35724:26087,35725:29275,35726:21435,35727:23621,35728:24040,35729:25298,35730:25312,35731:25369,35732:28192,35733:34394,35734:35377,35735:36317,35736:37624,35737:28417,35738:31142,35739:39770,35740:20136,35741:20139,35742:20140,35743:20379,35744:20384,35745:20689,35746:20807,35747:31478,35748:20849,35749:20982,35750:21332,35751:21281,35752:21375,35753:21483,35754:21932,35755:22659,35756:23777,35757:24375,35758:24394,35759:24623,35760:24656,35761:24685,35762:25375,35763:25945,35764:27211,35765:27841,35766:29378,35767:29421,35768:30703,35769:33016,35770:33029,35771:33288,35772:34126,35773:37111,35774:37857,35775:38911,35776:39255,35777:39514,35778:20208,35779:20957,35780:23597,35781:26241,35782:26989,35783:23616,35784:26354,35785:26997,35786:29577,35787:26704,35788:31873,35789:20677,35790:21220,35791:22343,35792:24062,35793:37670,35794:26020,35795:27427,35796:27453,35797:29748,35798:31105,35799:31165,35800:31563,35801:32202,35802:33465,35803:33740,35804:34943,35805:35167,35806:35641,35807:36817,35808:37329,35809:21535,35810:37504,35811:20061,35812:20534,35813:21477,35814:21306,35815:29399,35816:29590,35817:30697,35818:33510,35819:36527,35820:39366,35821:39368,35822:39378,35823:20855,35824:24858,35825:34398,35826:21936,35827:31354,35828:20598,35829:23507,35830:36935,35831:38533,35832:20018,35833:27355,35834:37351,35835:23633,35836:23624,35904:25496,35905:31391,35906:27795,35907:38772,35908:36705,35909:31402,35910:29066,35911:38536,35912:31874,35913:26647,35914:32368,35915:26705,35916:37740,35917:21234,35918:21531,35919:34219,35920:35347,35921:32676,35922:36557,35923:37089,35924:21350,35925:34952,35926:31041,35927:20418,35928:20670,35929:21009,35930:20804,35931:21843,35932:22317,35933:29674,35934:22411,35935:22865,35936:24418,35937:24452,35938:24693,35939:24950,35940:24935,35941:25001,35942:25522,35943:25658,35944:25964,35945:26223,35946:26690,35947:28179,35948:30054,35949:31293,35950:31995,35951:32076,35952:32153,35953:32331,35954:32619,35955:33550,35956:33610,35957:34509,35958:35336,35959:35427,35960:35686,35961:36605,35962:38938,35963:40335,35964:33464,35965:36814,35966:39912,35968:21127,35969:25119,35970:25731,35971:28608,35972:38553,35973:26689,35974:20625,35975:27424,35976:27770,35977:28500,35978:31348,35979:32080,35980:34880,35981:35363,35982:26376,35983:20214,35984:20537,35985:20518,35986:20581,35987:20860,35988:21048,35989:21091,35990:21927,35991:22287,35992:22533,35993:23244,35994:24314,35995:25010,35996:25080,35997:25331,35998:25458,35999:26908,36e3:27177,36001:29309,36002:29356,36003:29486,36004:30740,36005:30831,36006:32121,36007:30476,36008:32937,36009:35211,36010:35609,36011:36066,36012:36562,36013:36963,36014:37749,36015:38522,36016:38997,36017:39443,36018:40568,36019:20803,36020:21407,36021:21427,36022:24187,36023:24358,36024:28187,36025:28304,36026:29572,36027:29694,36028:32067,36029:33335,36030:35328,36031:35578,36032:38480,36033:20046,36034:20491,36035:21476,36036:21628,36037:22266,36038:22993,36039:23396,36040:24049,36041:24235,36042:24359,36043:25144,36044:25925,36045:26543,36046:28246,36047:29392,36048:31946,36049:34996,36050:32929,36051:32993,36052:33776,36053:34382,36054:35463,36055:36328,36056:37431,36057:38599,36058:39015,36059:40723,36060:20116,36061:20114,36062:20237,36063:21320,36064:21577,36065:21566,36066:23087,36067:24460,36068:24481,36069:24735,36070:26791,36071:27278,36072:29786,36073:30849,36074:35486,36075:35492,36076:35703,36077:37264,36078:20062,36079:39881,36080:20132,36081:20348,36082:20399,36083:20505,36084:20502,36085:20809,36086:20844,36087:21151,36088:21177,36089:21246,36090:21402,36091:21475,36092:21521,36160:21518,36161:21897,36162:22353,36163:22434,36164:22909,36165:23380,36166:23389,36167:23439,36168:24037,36169:24039,36170:24055,36171:24184,36172:24195,36173:24218,36174:24247,36175:24344,36176:24658,36177:24908,36178:25239,36179:25304,36180:25511,36181:25915,36182:26114,36183:26179,36184:26356,36185:26477,36186:26657,36187:26775,36188:27083,36189:27743,36190:27946,36191:28009,36192:28207,36193:28317,36194:30002,36195:30343,36196:30828,36197:31295,36198:31968,36199:32005,36200:32024,36201:32094,36202:32177,36203:32789,36204:32771,36205:32943,36206:32945,36207:33108,36208:33167,36209:33322,36210:33618,36211:34892,36212:34913,36213:35611,36214:36002,36215:36092,36216:37066,36217:37237,36218:37489,36219:30783,36220:37628,36221:38308,36222:38477,36224:38917,36225:39321,36226:39640,36227:40251,36228:21083,36229:21163,36230:21495,36231:21512,36232:22741,36233:25335,36234:28640,36235:35946,36236:36703,36237:40633,36238:20811,36239:21051,36240:21578,36241:22269,36242:31296,36243:37239,36244:40288,36245:40658,36246:29508,36247:28425,36248:33136,36249:29969,36250:24573,36251:24794,36252:39592,36253:29403,36254:36796,36255:27492,36256:38915,36257:20170,36258:22256,36259:22372,36260:22718,36261:23130,36262:24680,36263:25031,36264:26127,36265:26118,36266:26681,36267:26801,36268:28151,36269:30165,36270:32058,36271:33390,36272:39746,36273:20123,36274:20304,36275:21449,36276:21766,36277:23919,36278:24038,36279:24046,36280:26619,36281:27801,36282:29811,36283:30722,36284:35408,36285:37782,36286:35039,36287:22352,36288:24231,36289:25387,36290:20661,36291:20652,36292:20877,36293:26368,36294:21705,36295:22622,36296:22971,36297:23472,36298:24425,36299:25165,36300:25505,36301:26685,36302:27507,36303:28168,36304:28797,36305:37319,36306:29312,36307:30741,36308:30758,36309:31085,36310:25998,36311:32048,36312:33756,36313:35009,36314:36617,36315:38555,36316:21092,36317:22312,36318:26448,36319:32618,36320:36001,36321:20916,36322:22338,36323:38442,36324:22586,36325:27018,36326:32948,36327:21682,36328:23822,36329:22524,36330:30869,36331:40442,36332:20316,36333:21066,36334:21643,36335:25662,36336:26152,36337:26388,36338:26613,36339:31364,36340:31574,36341:32034,36342:37679,36343:26716,36344:39853,36345:31545,36346:21273,36347:20874,36348:21047,36416:23519,36417:25334,36418:25774,36419:25830,36420:26413,36421:27578,36422:34217,36423:38609,36424:30352,36425:39894,36426:25420,36427:37638,36428:39851,36429:30399,36430:26194,36431:19977,36432:20632,36433:21442,36434:23665,36435:24808,36436:25746,36437:25955,36438:26719,36439:29158,36440:29642,36441:29987,36442:31639,36443:32386,36444:34453,36445:35715,36446:36059,36447:37240,36448:39184,36449:26028,36450:26283,36451:27531,36452:20181,36453:20180,36454:20282,36455:20351,36456:21050,36457:21496,36458:21490,36459:21987,36460:22235,36461:22763,36462:22987,36463:22985,36464:23039,36465:23376,36466:23629,36467:24066,36468:24107,36469:24535,36470:24605,36471:25351,36472:25903,36473:23388,36474:26031,36475:26045,36476:26088,36477:26525,36478:27490,36480:27515,36481:27663,36482:29509,36483:31049,36484:31169,36485:31992,36486:32025,36487:32043,36488:32930,36489:33026,36490:33267,36491:35222,36492:35422,36493:35433,36494:35430,36495:35468,36496:35566,36497:36039,36498:36060,36499:38604,36500:39164,36501:27503,36502:20107,36503:20284,36504:20365,36505:20816,36506:23383,36507:23546,36508:24904,36509:25345,36510:26178,36511:27425,36512:28363,36513:27835,36514:29246,36515:29885,36516:30164,36517:30913,36518:31034,36519:32780,36520:32819,36521:33258,36522:33940,36523:36766,36524:27728,36525:40575,36526:24335,36527:35672,36528:40235,36529:31482,36530:36600,36531:23437,36532:38635,36533:19971,36534:21489,36535:22519,36536:22833,36537:23241,36538:23460,36539:24713,36540:28287,36541:28422,36542:30142,36543:36074,36544:23455,36545:34048,36546:31712,36547:20594,36548:26612,36549:33437,36550:23649,36551:34122,36552:32286,36553:33294,36554:20889,36555:23556,36556:25448,36557:36198,36558:26012,36559:29038,36560:31038,36561:32023,36562:32773,36563:35613,36564:36554,36565:36974,36566:34503,36567:37034,36568:20511,36569:21242,36570:23610,36571:26451,36572:28796,36573:29237,36574:37196,36575:37320,36576:37675,36577:33509,36578:23490,36579:24369,36580:24825,36581:20027,36582:21462,36583:23432,36584:25163,36585:26417,36586:27530,36587:29417,36588:29664,36589:31278,36590:33131,36591:36259,36592:37202,36593:39318,36594:20754,36595:21463,36596:21610,36597:23551,36598:25480,36599:27193,36600:32172,36601:38656,36602:22234,36603:21454,36604:21608,36672:23447,36673:23601,36674:24030,36675:20462,36676:24833,36677:25342,36678:27954,36679:31168,36680:31179,36681:32066,36682:32333,36683:32722,36684:33261,36685:33311,36686:33936,36687:34886,36688:35186,36689:35728,36690:36468,36691:36655,36692:36913,36693:37195,36694:37228,36695:38598,36696:37276,36697:20160,36698:20303,36699:20805,36700:21313,36701:24467,36702:25102,36703:26580,36704:27713,36705:28171,36706:29539,36707:32294,36708:37325,36709:37507,36710:21460,36711:22809,36712:23487,36713:28113,36714:31069,36715:32302,36716:31899,36717:22654,36718:29087,36719:20986,36720:34899,36721:36848,36722:20426,36723:23803,36724:26149,36725:30636,36726:31459,36727:33308,36728:39423,36729:20934,36730:24490,36731:26092,36732:26991,36733:27529,36734:28147,36736:28310,36737:28516,36738:30462,36739:32020,36740:24033,36741:36981,36742:37255,36743:38918,36744:20966,36745:21021,36746:25152,36747:26257,36748:26329,36749:28186,36750:24246,36751:32210,36752:32626,36753:26360,36754:34223,36755:34295,36756:35576,36757:21161,36758:21465,36759:22899,36760:24207,36761:24464,36762:24661,36763:37604,36764:38500,36765:20663,36766:20767,36767:21213,36768:21280,36769:21319,36770:21484,36771:21736,36772:21830,36773:21809,36774:22039,36775:22888,36776:22974,36777:23100,36778:23477,36779:23558,36780:23567,36781:23569,36782:23578,36783:24196,36784:24202,36785:24288,36786:24432,36787:25215,36788:25220,36789:25307,36790:25484,36791:25463,36792:26119,36793:26124,36794:26157,36795:26230,36796:26494,36797:26786,36798:27167,36799:27189,36800:27836,36801:28040,36802:28169,36803:28248,36804:28988,36805:28966,36806:29031,36807:30151,36808:30465,36809:30813,36810:30977,36811:31077,36812:31216,36813:31456,36814:31505,36815:31911,36816:32057,36817:32918,36818:33750,36819:33931,36820:34121,36821:34909,36822:35059,36823:35359,36824:35388,36825:35412,36826:35443,36827:35937,36828:36062,36829:37284,36830:37478,36831:37758,36832:37912,36833:38556,36834:38808,36835:19978,36836:19976,36837:19998,36838:20055,36839:20887,36840:21104,36841:22478,36842:22580,36843:22732,36844:23330,36845:24120,36846:24773,36847:25854,36848:26465,36849:26454,36850:27972,36851:29366,36852:30067,36853:31331,36854:33976,36855:35698,36856:37304,36857:37664,36858:22065,36859:22516,36860:39166,36928:25325,36929:26893,36930:27542,36931:29165,36932:32340,36933:32887,36934:33394,36935:35302,36936:39135,36937:34645,36938:36785,36939:23611,36940:20280,36941:20449,36942:20405,36943:21767,36944:23072,36945:23517,36946:23529,36947:24515,36948:24910,36949:25391,36950:26032,36951:26187,36952:26862,36953:27035,36954:28024,36955:28145,36956:30003,36957:30137,36958:30495,36959:31070,36960:31206,36961:32051,36962:33251,36963:33455,36964:34218,36965:35242,36966:35386,36967:36523,36968:36763,36969:36914,36970:37341,36971:38663,36972:20154,36973:20161,36974:20995,36975:22645,36976:22764,36977:23563,36978:29978,36979:23613,36980:33102,36981:35338,36982:36805,36983:38499,36984:38765,36985:31525,36986:35535,36987:38920,36988:37218,36989:22259,36990:21416,36992:36887,36993:21561,36994:22402,36995:24101,36996:25512,36997:27700,36998:28810,36999:30561,37e3:31883,37001:32736,37002:34928,37003:36930,37004:37204,37005:37648,37006:37656,37007:38543,37008:29790,37009:39620,37010:23815,37011:23913,37012:25968,37013:26530,37014:36264,37015:38619,37016:25454,37017:26441,37018:26905,37019:33733,37020:38935,37021:38592,37022:35070,37023:28548,37024:25722,37025:23544,37026:19990,37027:28716,37028:30045,37029:26159,37030:20932,37031:21046,37032:21218,37033:22995,37034:24449,37035:24615,37036:25104,37037:25919,37038:25972,37039:26143,37040:26228,37041:26866,37042:26646,37043:27491,37044:28165,37045:29298,37046:29983,37047:30427,37048:31934,37049:32854,37050:22768,37051:35069,37052:35199,37053:35488,37054:35475,37055:35531,37056:36893,37057:37266,37058:38738,37059:38745,37060:25993,37061:31246,37062:33030,37063:38587,37064:24109,37065:24796,37066:25114,37067:26021,37068:26132,37069:26512,37070:30707,37071:31309,37072:31821,37073:32318,37074:33034,37075:36012,37076:36196,37077:36321,37078:36447,37079:30889,37080:20999,37081:25305,37082:25509,37083:25666,37084:25240,37085:35373,37086:31363,37087:31680,37088:35500,37089:38634,37090:32118,37091:33292,37092:34633,37093:20185,37094:20808,37095:21315,37096:21344,37097:23459,37098:23554,37099:23574,37100:24029,37101:25126,37102:25159,37103:25776,37104:26643,37105:26676,37106:27849,37107:27973,37108:27927,37109:26579,37110:28508,37111:29006,37112:29053,37113:26059,37114:31359,37115:31661,37116:32218,37184:32330,37185:32680,37186:33146,37187:33307,37188:33337,37189:34214,37190:35438,37191:36046,37192:36341,37193:36984,37194:36983,37195:37549,37196:37521,37197:38275,37198:39854,37199:21069,37200:21892,37201:28472,37202:28982,37203:20840,37204:31109,37205:32341,37206:33203,37207:31950,37208:22092,37209:22609,37210:23720,37211:25514,37212:26366,37213:26365,37214:26970,37215:29401,37216:30095,37217:30094,37218:30990,37219:31062,37220:31199,37221:31895,37222:32032,37223:32068,37224:34311,37225:35380,37226:38459,37227:36961,37228:40736,37229:20711,37230:21109,37231:21452,37232:21474,37233:20489,37234:21930,37235:22766,37236:22863,37237:29245,37238:23435,37239:23652,37240:21277,37241:24803,37242:24819,37243:25436,37244:25475,37245:25407,37246:25531,37248:25805,37249:26089,37250:26361,37251:24035,37252:27085,37253:27133,37254:28437,37255:29157,37256:20105,37257:30185,37258:30456,37259:31379,37260:31967,37261:32207,37262:32156,37263:32865,37264:33609,37265:33624,37266:33900,37267:33980,37268:34299,37269:35013,37270:36208,37271:36865,37272:36973,37273:37783,37274:38684,37275:39442,37276:20687,37277:22679,37278:24974,37279:33235,37280:34101,37281:36104,37282:36896,37283:20419,37284:20596,37285:21063,37286:21363,37287:24687,37288:25417,37289:26463,37290:28204,37291:36275,37292:36895,37293:20439,37294:23646,37295:36042,37296:26063,37297:32154,37298:21330,37299:34966,37300:20854,37301:25539,37302:23384,37303:23403,37304:23562,37305:25613,37306:26449,37307:36956,37308:20182,37309:22810,37310:22826,37311:27760,37312:35409,37313:21822,37314:22549,37315:22949,37316:24816,37317:25171,37318:26561,37319:33333,37320:26965,37321:38464,37322:39364,37323:39464,37324:20307,37325:22534,37326:23550,37327:32784,37328:23729,37329:24111,37330:24453,37331:24608,37332:24907,37333:25140,37334:26367,37335:27888,37336:28382,37337:32974,37338:33151,37339:33492,37340:34955,37341:36024,37342:36864,37343:36910,37344:38538,37345:40667,37346:39899,37347:20195,37348:21488,37349:22823,37350:31532,37351:37261,37352:38988,37353:40441,37354:28381,37355:28711,37356:21331,37357:21828,37358:23429,37359:25176,37360:25246,37361:25299,37362:27810,37363:28655,37364:29730,37365:35351,37366:37944,37367:28609,37368:35582,37369:33592,37370:20967,37371:34552,37372:21482,37440:21481,37441:20294,37442:36948,37443:36784,37444:22890,37445:33073,37446:24061,37447:31466,37448:36799,37449:26842,37450:35895,37451:29432,37452:40008,37453:27197,37454:35504,37455:20025,37456:21336,37457:22022,37458:22374,37459:25285,37460:25506,37461:26086,37462:27470,37463:28129,37464:28251,37465:28845,37466:30701,37467:31471,37468:31658,37469:32187,37470:32829,37471:32966,37472:34507,37473:35477,37474:37723,37475:22243,37476:22727,37477:24382,37478:26029,37479:26262,37480:27264,37481:27573,37482:30007,37483:35527,37484:20516,37485:30693,37486:22320,37487:24347,37488:24677,37489:26234,37490:27744,37491:30196,37492:31258,37493:32622,37494:33268,37495:34584,37496:36933,37497:39347,37498:31689,37499:30044,37500:31481,37501:31569,37502:33988,37504:36880,37505:31209,37506:31378,37507:33590,37508:23265,37509:30528,37510:20013,37511:20210,37512:23449,37513:24544,37514:25277,37515:26172,37516:26609,37517:27880,37518:34411,37519:34935,37520:35387,37521:37198,37522:37619,37523:39376,37524:27159,37525:28710,37526:29482,37527:33511,37528:33879,37529:36015,37530:19969,37531:20806,37532:20939,37533:21899,37534:23541,37535:24086,37536:24115,37537:24193,37538:24340,37539:24373,37540:24427,37541:24500,37542:25074,37543:25361,37544:26274,37545:26397,37546:28526,37547:29266,37548:30010,37549:30522,37550:32884,37551:33081,37552:33144,37553:34678,37554:35519,37555:35548,37556:36229,37557:36339,37558:37530,37559:38263,37560:38914,37561:40165,37562:21189,37563:25431,37564:30452,37565:26389,37566:27784,37567:29645,37568:36035,37569:37806,37570:38515,37571:27941,37572:22684,37573:26894,37574:27084,37575:36861,37576:37786,37577:30171,37578:36890,37579:22618,37580:26626,37581:25524,37582:27131,37583:20291,37584:28460,37585:26584,37586:36795,37587:34086,37588:32180,37589:37716,37590:26943,37591:28528,37592:22378,37593:22775,37594:23340,37595:32044,37596:29226,37597:21514,37598:37347,37599:40372,37600:20141,37601:20302,37602:20572,37603:20597,37604:21059,37605:35998,37606:21576,37607:22564,37608:23450,37609:24093,37610:24213,37611:24237,37612:24311,37613:24351,37614:24716,37615:25269,37616:25402,37617:25552,37618:26799,37619:27712,37620:30855,37621:31118,37622:31243,37623:32224,37624:33351,37625:35330,37626:35558,37627:36420,37628:36883,37696:37048,37697:37165,37698:37336,37699:40718,37700:27877,37701:25688,37702:25826,37703:25973,37704:28404,37705:30340,37706:31515,37707:36969,37708:37841,37709:28346,37710:21746,37711:24505,37712:25764,37713:36685,37714:36845,37715:37444,37716:20856,37717:22635,37718:22825,37719:23637,37720:24215,37721:28155,37722:32399,37723:29980,37724:36028,37725:36578,37726:39003,37727:28857,37728:20253,37729:27583,37730:28593,37731:3e4,37732:38651,37733:20814,37734:21520,37735:22581,37736:22615,37737:22956,37738:23648,37739:24466,37740:26007,37741:26460,37742:28193,37743:30331,37744:33759,37745:36077,37746:36884,37747:37117,37748:37709,37749:30757,37750:30778,37751:21162,37752:24230,37753:22303,37754:22900,37755:24594,37756:20498,37757:20826,37758:20908,37760:20941,37761:20992,37762:21776,37763:22612,37764:22616,37765:22871,37766:23445,37767:23798,37768:23947,37769:24764,37770:25237,37771:25645,37772:26481,37773:26691,37774:26812,37775:26847,37776:30423,37777:28120,37778:28271,37779:28059,37780:28783,37781:29128,37782:24403,37783:30168,37784:31095,37785:31561,37786:31572,37787:31570,37788:31958,37789:32113,37790:21040,37791:33891,37792:34153,37793:34276,37794:35342,37795:35588,37796:35910,37797:36367,37798:36867,37799:36879,37800:37913,37801:38518,37802:38957,37803:39472,37804:38360,37805:20685,37806:21205,37807:21516,37808:22530,37809:23566,37810:24999,37811:25758,37812:27934,37813:30643,37814:31461,37815:33012,37816:33796,37817:36947,37818:37509,37819:23776,37820:40199,37821:21311,37822:24471,37823:24499,37824:28060,37825:29305,37826:30563,37827:31167,37828:31716,37829:27602,37830:29420,37831:35501,37832:26627,37833:27233,37834:20984,37835:31361,37836:26932,37837:23626,37838:40182,37839:33515,37840:23493,37841:37193,37842:28702,37843:22136,37844:23663,37845:24775,37846:25958,37847:27788,37848:35930,37849:36929,37850:38931,37851:21585,37852:26311,37853:37389,37854:22856,37855:37027,37856:20869,37857:20045,37858:20970,37859:34201,37860:35598,37861:28760,37862:25466,37863:37707,37864:26978,37865:39348,37866:32260,37867:30071,37868:21335,37869:26976,37870:36575,37871:38627,37872:27741,37873:20108,37874:23612,37875:24336,37876:36841,37877:21250,37878:36049,37879:32905,37880:34425,37881:24319,37882:26085,37883:20083,37884:20837,37952:22914,37953:23615,37954:38894,37955:20219,37956:22922,37957:24525,37958:35469,37959:28641,37960:31152,37961:31074,37962:23527,37963:33905,37964:29483,37965:29105,37966:24180,37967:24565,37968:25467,37969:25754,37970:29123,37971:31896,37972:20035,37973:24316,37974:20043,37975:22492,37976:22178,37977:24745,37978:28611,37979:32013,37980:33021,37981:33075,37982:33215,37983:36786,37984:35223,37985:34468,37986:24052,37987:25226,37988:25773,37989:35207,37990:26487,37991:27874,37992:27966,37993:29750,37994:30772,37995:23110,37996:32629,37997:33453,37998:39340,37999:20467,38e3:24259,38001:25309,38002:25490,38003:25943,38004:26479,38005:30403,38006:29260,38007:32972,38008:32954,38009:36649,38010:37197,38011:20493,38012:22521,38013:23186,38014:26757,38016:26995,38017:29028,38018:29437,38019:36023,38020:22770,38021:36064,38022:38506,38023:36889,38024:34687,38025:31204,38026:30695,38027:33833,38028:20271,38029:21093,38030:21338,38031:25293,38032:26575,38033:27850,38034:30333,38035:31636,38036:31893,38037:33334,38038:34180,38039:36843,38040:26333,38041:28448,38042:29190,38043:32283,38044:33707,38045:39361,38046:40614,38047:20989,38048:31665,38049:30834,38050:31672,38051:32903,38052:31560,38053:27368,38054:24161,38055:32908,38056:30033,38057:30048,38058:20843,38059:37474,38060:28300,38061:30330,38062:37271,38063:39658,38064:20240,38065:32624,38066:25244,38067:31567,38068:38309,38069:40169,38070:22138,38071:22617,38072:34532,38073:38588,38074:20276,38075:21028,38076:21322,38077:21453,38078:21467,38079:24070,38080:25644,38081:26001,38082:26495,38083:27710,38084:27726,38085:29256,38086:29359,38087:29677,38088:30036,38089:32321,38090:33324,38091:34281,38092:36009,38093:31684,38094:37318,38095:29033,38096:38930,38097:39151,38098:25405,38099:26217,38100:30058,38101:30436,38102:30928,38103:34115,38104:34542,38105:21290,38106:21329,38107:21542,38108:22915,38109:24199,38110:24444,38111:24754,38112:25161,38113:25209,38114:25259,38115:26e3,38116:27604,38117:27852,38118:30130,38119:30382,38120:30865,38121:31192,38122:32203,38123:32631,38124:32933,38125:34987,38126:35513,38127:36027,38128:36991,38129:38750,38130:39131,38131:27147,38132:31800,38133:20633,38134:23614,38135:24494,38136:26503,38137:27608,38138:29749,38139:30473,38140:32654,38208:40763,38209:26570,38210:31255,38211:21305,38212:30091,38213:39661,38214:24422,38215:33181,38216:33777,38217:32920,38218:24380,38219:24517,38220:30050,38221:31558,38222:36924,38223:26727,38224:23019,38225:23195,38226:32016,38227:30334,38228:35628,38229:20469,38230:24426,38231:27161,38232:27703,38233:28418,38234:29922,38235:31080,38236:34920,38237:35413,38238:35961,38239:24287,38240:25551,38241:30149,38242:31186,38243:33495,38244:37672,38245:37618,38246:33948,38247:34541,38248:39981,38249:21697,38250:24428,38251:25996,38252:27996,38253:28693,38254:36007,38255:36051,38256:38971,38257:25935,38258:29942,38259:19981,38260:20184,38261:22496,38262:22827,38263:23142,38264:23500,38265:20904,38266:24067,38267:24220,38268:24598,38269:25206,38270:25975,38272:26023,38273:26222,38274:28014,38275:29238,38276:31526,38277:33104,38278:33178,38279:33433,38280:35676,38281:36e3,38282:36070,38283:36212,38284:38428,38285:38468,38286:20398,38287:25771,38288:27494,38289:33310,38290:33889,38291:34154,38292:37096,38293:23553,38294:26963,38295:39080,38296:33914,38297:34135,38298:20239,38299:21103,38300:24489,38301:24133,38302:26381,38303:31119,38304:33145,38305:35079,38306:35206,38307:28149,38308:24343,38309:25173,38310:27832,38311:20175,38312:29289,38313:39826,38314:20998,38315:21563,38316:22132,38317:22707,38318:24996,38319:25198,38320:28954,38321:22894,38322:31881,38323:31966,38324:32027,38325:38640,38326:25991,38327:32862,38328:19993,38329:20341,38330:20853,38331:22592,38332:24163,38333:24179,38334:24330,38335:26564,38336:20006,38337:34109,38338:38281,38339:38491,38340:31859,38341:38913,38342:20731,38343:22721,38344:30294,38345:30887,38346:21029,38347:30629,38348:34065,38349:31622,38350:20559,38351:22793,38352:29255,38353:31687,38354:32232,38355:36794,38356:36820,38357:36941,38358:20415,38359:21193,38360:23081,38361:24321,38362:38829,38363:20445,38364:33303,38365:37610,38366:22275,38367:25429,38368:27497,38369:29995,38370:35036,38371:36628,38372:31298,38373:21215,38374:22675,38375:24917,38376:25098,38377:26286,38378:27597,38379:31807,38380:33769,38381:20515,38382:20472,38383:21253,38384:21574,38385:22577,38386:22857,38387:23453,38388:23792,38389:23791,38390:23849,38391:24214,38392:25265,38393:25447,38394:25918,38395:26041,38396:26379,38464:27861,38465:27873,38466:28921,38467:30770,38468:32299,38469:32990,38470:33459,38471:33804,38472:34028,38473:34562,38474:35090,38475:35370,38476:35914,38477:37030,38478:37586,38479:39165,38480:40179,38481:40300,38482:20047,38483:20129,38484:20621,38485:21078,38486:22346,38487:22952,38488:24125,38489:24536,38490:24537,38491:25151,38492:26292,38493:26395,38494:26576,38495:26834,38496:20882,38497:32033,38498:32938,38499:33192,38500:35584,38501:35980,38502:36031,38503:37502,38504:38450,38505:21536,38506:38956,38507:21271,38508:20693,38509:21340,38510:22696,38511:25778,38512:26420,38513:29287,38514:30566,38515:31302,38516:37350,38517:21187,38518:27809,38519:27526,38520:22528,38521:24140,38522:22868,38523:26412,38524:32763,38525:20961,38526:30406,38528:25705,38529:30952,38530:39764,38531:40635,38532:22475,38533:22969,38534:26151,38535:26522,38536:27598,38537:21737,38538:27097,38539:24149,38540:33180,38541:26517,38542:39850,38543:26622,38544:40018,38545:26717,38546:20134,38547:20451,38548:21448,38549:25273,38550:26411,38551:27819,38552:36804,38553:20397,38554:32365,38555:40639,38556:19975,38557:24930,38558:28288,38559:28459,38560:34067,38561:21619,38562:26410,38563:39749,38564:24051,38565:31637,38566:23724,38567:23494,38568:34588,38569:28234,38570:34001,38571:31252,38572:33032,38573:22937,38574:31885,38575:27665,38576:30496,38577:21209,38578:22818,38579:28961,38580:29279,38581:30683,38582:38695,38583:40289,38584:26891,38585:23167,38586:23064,38587:20901,38588:21517,38589:21629,38590:26126,38591:30431,38592:36855,38593:37528,38594:40180,38595:23018,38596:29277,38597:28357,38598:20813,38599:26825,38600:32191,38601:32236,38602:38754,38603:40634,38604:25720,38605:27169,38606:33538,38607:22916,38608:23391,38609:27611,38610:29467,38611:30450,38612:32178,38613:32791,38614:33945,38615:20786,38616:26408,38617:40665,38618:30446,38619:26466,38620:21247,38621:39173,38622:23588,38623:25147,38624:31870,38625:36016,38626:21839,38627:24758,38628:32011,38629:38272,38630:21249,38631:20063,38632:20918,38633:22812,38634:29242,38635:32822,38636:37326,38637:24357,38638:30690,38639:21380,38640:24441,38641:32004,38642:34220,38643:35379,38644:36493,38645:38742,38646:26611,38647:34222,38648:37971,38649:24841,38650:24840,38651:27833,38652:30290,38720:35565,38721:36664,38722:21807,38723:20305,38724:20778,38725:21191,38726:21451,38727:23461,38728:24189,38729:24736,38730:24962,38731:25558,38732:26377,38733:26586,38734:28263,38735:28044,38736:29494,38737:29495,38738:30001,38739:31056,38740:35029,38741:35480,38742:36938,38743:37009,38744:37109,38745:38596,38746:34701,38747:22805,38748:20104,38749:20313,38750:19982,38751:35465,38752:36671,38753:38928,38754:20653,38755:24188,38756:22934,38757:23481,38758:24248,38759:25562,38760:25594,38761:25793,38762:26332,38763:26954,38764:27096,38765:27915,38766:28342,38767:29076,38768:29992,38769:31407,38770:32650,38771:32768,38772:33865,38773:33993,38774:35201,38775:35617,38776:36362,38777:36965,38778:38525,38779:39178,38780:24958,38781:25233,38782:27442,38784:27779,38785:28020,38786:32716,38787:32764,38788:28096,38789:32645,38790:34746,38791:35064,38792:26469,38793:33713,38794:38972,38795:38647,38796:27931,38797:32097,38798:33853,38799:37226,38800:20081,38801:21365,38802:23888,38803:27396,38804:28651,38805:34253,38806:34349,38807:35239,38808:21033,38809:21519,38810:23653,38811:26446,38812:26792,38813:29702,38814:29827,38815:30178,38816:35023,38817:35041,38818:37324,38819:38626,38820:38520,38821:24459,38822:29575,38823:31435,38824:33870,38825:25504,38826:30053,38827:21129,38828:27969,38829:28316,38830:29705,38831:30041,38832:30827,38833:31890,38834:38534,38835:31452,38836:40845,38837:20406,38838:24942,38839:26053,38840:34396,38841:20102,38842:20142,38843:20698,38844:20001,38845:20940,38846:23534,38847:26009,38848:26753,38849:28092,38850:29471,38851:30274,38852:30637,38853:31260,38854:31975,38855:33391,38856:35538,38857:36988,38858:37327,38859:38517,38860:38936,38861:21147,38862:32209,38863:20523,38864:21400,38865:26519,38866:28107,38867:29136,38868:29747,38869:33256,38870:36650,38871:38563,38872:40023,38873:40607,38874:29792,38875:22593,38876:28057,38877:32047,38878:39006,38879:20196,38880:20278,38881:20363,38882:20919,38883:21169,38884:23994,38885:24604,38886:29618,38887:31036,38888:33491,38889:37428,38890:38583,38891:38646,38892:38666,38893:40599,38894:40802,38895:26278,38896:27508,38897:21015,38898:21155,38899:28872,38900:35010,38901:24265,38902:24651,38903:24976,38904:28451,38905:29001,38906:31806,38907:32244,38908:32879,38976:34030,38977:36899,38978:37676,38979:21570,38980:39791,38981:27347,38982:28809,38983:36034,38984:36335,38985:38706,38986:21172,38987:23105,38988:24266,38989:24324,38990:26391,38991:27004,38992:27028,38993:28010,38994:28431,38995:29282,38996:29436,38997:31725,38998:32769,38999:32894,39e3:34635,39001:37070,39002:20845,39003:40595,39004:31108,39005:32907,39006:37682,39007:35542,39008:20525,39009:21644,39010:35441,39011:27498,39012:36036,39013:33031,39014:24785,39015:26528,39016:40434,39017:20121,39018:20120,39019:39952,39020:35435,39021:34241,39022:34152,39023:26880,39024:28286,39025:30871,39026:33109,39071:24332,39072:19984,39073:19989,39074:20010,39075:20017,39076:20022,39077:20028,39078:20031,39079:20034,39080:20054,39081:20056,39082:20098,39083:20101,39084:35947,39085:20106,39086:33298,39087:24333,39088:20110,39089:20126,39090:20127,39091:20128,39092:20130,39093:20144,39094:20147,39095:20150,39096:20174,39097:20173,39098:20164,39099:20166,39100:20162,39101:20183,39102:20190,39103:20205,39104:20191,39105:20215,39106:20233,39107:20314,39108:20272,39109:20315,39110:20317,39111:20311,39112:20295,39113:20342,39114:20360,39115:20367,39116:20376,39117:20347,39118:20329,39119:20336,39120:20369,39121:20335,39122:20358,39123:20374,39124:20760,39125:20436,39126:20447,39127:20430,39128:20440,39129:20443,39130:20433,39131:20442,39132:20432,39133:20452,39134:20453,39135:20506,39136:20520,39137:20500,39138:20522,39139:20517,39140:20485,39141:20252,39142:20470,39143:20513,39144:20521,39145:20524,39146:20478,39147:20463,39148:20497,39149:20486,39150:20547,39151:20551,39152:26371,39153:20565,39154:20560,39155:20552,39156:20570,39157:20566,39158:20588,39159:20600,39160:20608,39161:20634,39162:20613,39163:20660,39164:20658,39232:20681,39233:20682,39234:20659,39235:20674,39236:20694,39237:20702,39238:20709,39239:20717,39240:20707,39241:20718,39242:20729,39243:20725,39244:20745,39245:20737,39246:20738,39247:20758,39248:20757,39249:20756,39250:20762,39251:20769,39252:20794,39253:20791,39254:20796,39255:20795,39256:20799,39257:20800,39258:20818,39259:20812,39260:20820,39261:20834,39262:31480,39263:20841,39264:20842,39265:20846,39266:20864,39267:20866,39268:22232,39269:20876,39270:20873,39271:20879,39272:20881,39273:20883,39274:20885,39275:20886,39276:20900,39277:20902,39278:20898,39279:20905,39280:20906,39281:20907,39282:20915,39283:20913,39284:20914,39285:20912,39286:20917,39287:20925,39288:20933,39289:20937,39290:20955,39291:20960,39292:34389,39293:20969,39294:20973,39296:20976,39297:20981,39298:20990,39299:20996,39300:21003,39301:21012,39302:21006,39303:21031,39304:21034,39305:21038,39306:21043,39307:21049,39308:21071,39309:21060,39310:21067,39311:21068,39312:21086,39313:21076,39314:21098,39315:21108,39316:21097,39317:21107,39318:21119,39319:21117,39320:21133,39321:21140,39322:21138,39323:21105,39324:21128,39325:21137,39326:36776,39327:36775,39328:21164,39329:21165,39330:21180,39331:21173,39332:21185,39333:21197,39334:21207,39335:21214,39336:21219,39337:21222,39338:39149,39339:21216,39340:21235,39341:21237,39342:21240,39343:21241,39344:21254,39345:21256,39346:30008,39347:21261,39348:21264,39349:21263,39350:21269,39351:21274,39352:21283,39353:21295,39354:21297,39355:21299,39356:21304,39357:21312,39358:21318,39359:21317,39360:19991,39361:21321,39362:21325,39363:20950,39364:21342,39365:21353,39366:21358,39367:22808,39368:21371,39369:21367,39370:21378,39371:21398,39372:21408,39373:21414,39374:21413,39375:21422,39376:21424,39377:21430,39378:21443,39379:31762,39380:38617,39381:21471,39382:26364,39383:29166,39384:21486,39385:21480,39386:21485,39387:21498,39388:21505,39389:21565,39390:21568,39391:21548,39392:21549,39393:21564,39394:21550,39395:21558,39396:21545,39397:21533,39398:21582,39399:21647,39400:21621,39401:21646,39402:21599,39403:21617,39404:21623,39405:21616,39406:21650,39407:21627,39408:21632,39409:21622,39410:21636,39411:21648,39412:21638,39413:21703,39414:21666,39415:21688,39416:21669,39417:21676,39418:21700,39419:21704,39420:21672,39488:21675,39489:21698,39490:21668,39491:21694,39492:21692,39493:21720,39494:21733,39495:21734,39496:21775,39497:21780,39498:21757,39499:21742,39500:21741,39501:21754,39502:21730,39503:21817,39504:21824,39505:21859,39506:21836,39507:21806,39508:21852,39509:21829,39510:21846,39511:21847,39512:21816,39513:21811,39514:21853,39515:21913,39516:21888,39517:21679,39518:21898,39519:21919,39520:21883,39521:21886,39522:21912,39523:21918,39524:21934,39525:21884,39526:21891,39527:21929,39528:21895,39529:21928,39530:21978,39531:21957,39532:21983,39533:21956,39534:21980,39535:21988,39536:21972,39537:22036,39538:22007,39539:22038,39540:22014,39541:22013,39542:22043,39543:22009,39544:22094,39545:22096,39546:29151,39547:22068,39548:22070,39549:22066,39550:22072,39552:22123,39553:22116,39554:22063,39555:22124,39556:22122,39557:22150,39558:22144,39559:22154,39560:22176,39561:22164,39562:22159,39563:22181,39564:22190,39565:22198,39566:22196,39567:22210,39568:22204,39569:22209,39570:22211,39571:22208,39572:22216,39573:22222,39574:22225,39575:22227,39576:22231,39577:22254,39578:22265,39579:22272,39580:22271,39581:22276,39582:22281,39583:22280,39584:22283,39585:22285,39586:22291,39587:22296,39588:22294,39589:21959,39590:22300,39591:22310,39592:22327,39593:22328,39594:22350,39595:22331,39596:22336,39597:22351,39598:22377,39599:22464,39600:22408,39601:22369,39602:22399,39603:22409,39604:22419,39605:22432,39606:22451,39607:22436,39608:22442,39609:22448,39610:22467,39611:22470,39612:22484,39613:22482,39614:22483,39615:22538,39616:22486,39617:22499,39618:22539,39619:22553,39620:22557,39621:22642,39622:22561,39623:22626,39624:22603,39625:22640,39626:27584,39627:22610,39628:22589,39629:22649,39630:22661,39631:22713,39632:22687,39633:22699,39634:22714,39635:22750,39636:22715,39637:22712,39638:22702,39639:22725,39640:22739,39641:22737,39642:22743,39643:22745,39644:22744,39645:22757,39646:22748,39647:22756,39648:22751,39649:22767,39650:22778,39651:22777,39652:22779,39653:22780,39654:22781,39655:22786,39656:22794,39657:22800,39658:22811,39659:26790,39660:22821,39661:22828,39662:22829,39663:22834,39664:22840,39665:22846,39666:31442,39667:22869,39668:22864,39669:22862,39670:22874,39671:22872,39672:22882,39673:22880,39674:22887,39675:22892,39676:22889,39744:22904,39745:22913,39746:22941,39747:20318,39748:20395,39749:22947,39750:22962,39751:22982,39752:23016,39753:23004,39754:22925,39755:23001,39756:23002,39757:23077,39758:23071,39759:23057,39760:23068,39761:23049,39762:23066,39763:23104,39764:23148,39765:23113,39766:23093,39767:23094,39768:23138,39769:23146,39770:23194,39771:23228,39772:23230,39773:23243,39774:23234,39775:23229,39776:23267,39777:23255,39778:23270,39779:23273,39780:23254,39781:23290,39782:23291,39783:23308,39784:23307,39785:23318,39786:23346,39787:23248,39788:23338,39789:23350,39790:23358,39791:23363,39792:23365,39793:23360,39794:23377,39795:23381,39796:23386,39797:23387,39798:23397,39799:23401,39800:23408,39801:23411,39802:23413,39803:23416,39804:25992,39805:23418,39806:23424,39808:23427,39809:23462,39810:23480,39811:23491,39812:23495,39813:23497,39814:23508,39815:23504,39816:23524,39817:23526,39818:23522,39819:23518,39820:23525,39821:23531,39822:23536,39823:23542,39824:23539,39825:23557,39826:23559,39827:23560,39828:23565,39829:23571,39830:23584,39831:23586,39832:23592,39833:23608,39834:23609,39835:23617,39836:23622,39837:23630,39838:23635,39839:23632,39840:23631,39841:23409,39842:23660,39843:23662,39844:20066,39845:23670,39846:23673,39847:23692,39848:23697,39849:23700,39850:22939,39851:23723,39852:23739,39853:23734,39854:23740,39855:23735,39856:23749,39857:23742,39858:23751,39859:23769,39860:23785,39861:23805,39862:23802,39863:23789,39864:23948,39865:23786,39866:23819,39867:23829,39868:23831,39869:23900,39870:23839,39871:23835,39872:23825,39873:23828,39874:23842,39875:23834,39876:23833,39877:23832,39878:23884,39879:23890,39880:23886,39881:23883,39882:23916,39883:23923,39884:23926,39885:23943,39886:23940,39887:23938,39888:23970,39889:23965,39890:23980,39891:23982,39892:23997,39893:23952,39894:23991,39895:23996,39896:24009,39897:24013,39898:24019,39899:24018,39900:24022,39901:24027,39902:24043,39903:24050,39904:24053,39905:24075,39906:24090,39907:24089,39908:24081,39909:24091,39910:24118,39911:24119,39912:24132,39913:24131,39914:24128,39915:24142,39916:24151,39917:24148,39918:24159,39919:24162,39920:24164,39921:24135,39922:24181,39923:24182,39924:24186,39925:40636,39926:24191,39927:24224,39928:24257,39929:24258,39930:24264,39931:24272,39932:24271,4e4:24278,40001:24291,40002:24285,40003:24282,40004:24283,40005:24290,40006:24289,40007:24296,40008:24297,40009:24300,40010:24305,40011:24307,40012:24304,40013:24308,40014:24312,40015:24318,40016:24323,40017:24329,40018:24413,40019:24412,40020:24331,40021:24337,40022:24342,40023:24361,40024:24365,40025:24376,40026:24385,40027:24392,40028:24396,40029:24398,40030:24367,40031:24401,40032:24406,40033:24407,40034:24409,40035:24417,40036:24429,40037:24435,40038:24439,40039:24451,40040:24450,40041:24447,40042:24458,40043:24456,40044:24465,40045:24455,40046:24478,40047:24473,40048:24472,40049:24480,40050:24488,40051:24493,40052:24508,40053:24534,40054:24571,40055:24548,40056:24568,40057:24561,40058:24541,40059:24755,40060:24575,40061:24609,40062:24672,40064:24601,40065:24592,40066:24617,40067:24590,40068:24625,40069:24603,40070:24597,40071:24619,40072:24614,40073:24591,40074:24634,40075:24666,40076:24641,40077:24682,40078:24695,40079:24671,40080:24650,40081:24646,40082:24653,40083:24675,40084:24643,40085:24676,40086:24642,40087:24684,40088:24683,40089:24665,40090:24705,40091:24717,40092:24807,40093:24707,40094:24730,40095:24708,40096:24731,40097:24726,40098:24727,40099:24722,40100:24743,40101:24715,40102:24801,40103:24760,40104:24800,40105:24787,40106:24756,40107:24560,40108:24765,40109:24774,40110:24757,40111:24792,40112:24909,40113:24853,40114:24838,40115:24822,40116:24823,40117:24832,40118:24820,40119:24826,40120:24835,40121:24865,40122:24827,40123:24817,40124:24845,40125:24846,40126:24903,40127:24894,40128:24872,40129:24871,40130:24906,40131:24895,40132:24892,40133:24876,40134:24884,40135:24893,40136:24898,40137:24900,40138:24947,40139:24951,40140:24920,40141:24921,40142:24922,40143:24939,40144:24948,40145:24943,40146:24933,40147:24945,40148:24927,40149:24925,40150:24915,40151:24949,40152:24985,40153:24982,40154:24967,40155:25004,40156:24980,40157:24986,40158:24970,40159:24977,40160:25003,40161:25006,40162:25036,40163:25034,40164:25033,40165:25079,40166:25032,40167:25027,40168:25030,40169:25018,40170:25035,40171:32633,40172:25037,40173:25062,40174:25059,40175:25078,40176:25082,40177:25076,40178:25087,40179:25085,40180:25084,40181:25086,40182:25088,40183:25096,40184:25097,40185:25101,40186:25100,40187:25108,40188:25115,40256:25118,40257:25121,40258:25130,40259:25134,40260:25136,40261:25138,40262:25139,40263:25153,40264:25166,40265:25182,40266:25187,40267:25179,40268:25184,40269:25192,40270:25212,40271:25218,40272:25225,40273:25214,40274:25234,40275:25235,40276:25238,40277:25300,40278:25219,40279:25236,40280:25303,40281:25297,40282:25275,40283:25295,40284:25343,40285:25286,40286:25812,40287:25288,40288:25308,40289:25292,40290:25290,40291:25282,40292:25287,40293:25243,40294:25289,40295:25356,40296:25326,40297:25329,40298:25383,40299:25346,40300:25352,40301:25327,40302:25333,40303:25424,40304:25406,40305:25421,40306:25628,40307:25423,40308:25494,40309:25486,40310:25472,40311:25515,40312:25462,40313:25507,40314:25487,40315:25481,40316:25503,40317:25525,40318:25451,40320:25449,40321:25534,40322:25577,40323:25536,40324:25542,40325:25571,40326:25545,40327:25554,40328:25590,40329:25540,40330:25622,40331:25652,40332:25606,40333:25619,40334:25638,40335:25654,40336:25885,40337:25623,40338:25640,40339:25615,40340:25703,40341:25711,40342:25718,40343:25678,40344:25898,40345:25749,40346:25747,40347:25765,40348:25769,40349:25736,40350:25788,40351:25818,40352:25810,40353:25797,40354:25799,40355:25787,40356:25816,40357:25794,40358:25841,40359:25831,40360:33289,40361:25824,40362:25825,40363:25260,40364:25827,40365:25839,40366:25900,40367:25846,40368:25844,40369:25842,40370:25850,40371:25856,40372:25853,40373:25880,40374:25884,40375:25861,40376:25892,40377:25891,40378:25899,40379:25908,40380:25909,40381:25911,40382:25910,40383:25912,40384:30027,40385:25928,40386:25942,40387:25941,40388:25933,40389:25944,40390:25950,40391:25949,40392:25970,40393:25976,40394:25986,40395:25987,40396:35722,40397:26011,40398:26015,40399:26027,40400:26039,40401:26051,40402:26054,40403:26049,40404:26052,40405:26060,40406:26066,40407:26075,40408:26073,40409:26080,40410:26081,40411:26097,40412:26482,40413:26122,40414:26115,40415:26107,40416:26483,40417:26165,40418:26166,40419:26164,40420:26140,40421:26191,40422:26180,40423:26185,40424:26177,40425:26206,40426:26205,40427:26212,40428:26215,40429:26216,40430:26207,40431:26210,40432:26224,40433:26243,40434:26248,40435:26254,40436:26249,40437:26244,40438:26264,40439:26269,40440:26305,40441:26297,40442:26313,40443:26302,40444:26300,40512:26308,40513:26296,40514:26326,40515:26330,40516:26336,40517:26175,40518:26342,40519:26345,40520:26352,40521:26357,40522:26359,40523:26383,40524:26390,40525:26398,40526:26406,40527:26407,40528:38712,40529:26414,40530:26431,40531:26422,40532:26433,40533:26424,40534:26423,40535:26438,40536:26462,40537:26464,40538:26457,40539:26467,40540:26468,40541:26505,40542:26480,40543:26537,40544:26492,40545:26474,40546:26508,40547:26507,40548:26534,40549:26529,40550:26501,40551:26551,40552:26607,40553:26548,40554:26604,40555:26547,40556:26601,40557:26552,40558:26596,40559:26590,40560:26589,40561:26594,40562:26606,40563:26553,40564:26574,40565:26566,40566:26599,40567:27292,40568:26654,40569:26694,40570:26665,40571:26688,40572:26701,40573:26674,40574:26702,40576:26803,40577:26667,40578:26713,40579:26723,40580:26743,40581:26751,40582:26783,40583:26767,40584:26797,40585:26772,40586:26781,40587:26779,40588:26755,40589:27310,40590:26809,40591:26740,40592:26805,40593:26784,40594:26810,40595:26895,40596:26765,40597:26750,40598:26881,40599:26826,40600:26888,40601:26840,40602:26914,40603:26918,40604:26849,40605:26892,40606:26829,40607:26836,40608:26855,40609:26837,40610:26934,40611:26898,40612:26884,40613:26839,40614:26851,40615:26917,40616:26873,40617:26848,40618:26863,40619:26920,40620:26922,40621:26906,40622:26915,40623:26913,40624:26822,40625:27001,40626:26999,40627:26972,40628:27e3,40629:26987,40630:26964,40631:27006,40632:26990,40633:26937,40634:26996,40635:26941,40636:26969,40637:26928,40638:26977,40639:26974,40640:26973,40641:27009,40642:26986,40643:27058,40644:27054,40645:27088,40646:27071,40647:27073,40648:27091,40649:27070,40650:27086,40651:23528,40652:27082,40653:27101,40654:27067,40655:27075,40656:27047,40657:27182,40658:27025,40659:27040,40660:27036,40661:27029,40662:27060,40663:27102,40664:27112,40665:27138,40666:27163,40667:27135,40668:27402,40669:27129,40670:27122,40671:27111,40672:27141,40673:27057,40674:27166,40675:27117,40676:27156,40677:27115,40678:27146,40679:27154,40680:27329,40681:27171,40682:27155,40683:27204,40684:27148,40685:27250,40686:27190,40687:27256,40688:27207,40689:27234,40690:27225,40691:27238,40692:27208,40693:27192,40694:27170,40695:27280,40696:27277,40697:27296,40698:27268,40699:27298,40700:27299,40768:27287,40769:34327,40770:27323,40771:27331,40772:27330,40773:27320,40774:27315,40775:27308,40776:27358,40777:27345,40778:27359,40779:27306,40780:27354,40781:27370,40782:27387,40783:27397,40784:34326,40785:27386,40786:27410,40787:27414,40788:39729,40789:27423,40790:27448,40791:27447,40792:30428,40793:27449,40794:39150,40795:27463,40796:27459,40797:27465,40798:27472,40799:27481,40800:27476,40801:27483,40802:27487,40803:27489,40804:27512,40805:27513,40806:27519,40807:27520,40808:27524,40809:27523,40810:27533,40811:27544,40812:27541,40813:27550,40814:27556,40815:27562,40816:27563,40817:27567,40818:27570,40819:27569,40820:27571,40821:27575,40822:27580,40823:27590,40824:27595,40825:27603,40826:27615,40827:27628,40828:27627,40829:27635,40830:27631,40832:40638,40833:27656,40834:27667,40835:27668,40836:27675,40837:27684,40838:27683,40839:27742,40840:27733,40841:27746,40842:27754,40843:27778,40844:27789,40845:27802,40846:27777,40847:27803,40848:27774,40849:27752,40850:27763,40851:27794,40852:27792,40853:27844,40854:27889,40855:27859,40856:27837,40857:27863,40858:27845,40859:27869,40860:27822,40861:27825,40862:27838,40863:27834,40864:27867,40865:27887,40866:27865,40867:27882,40868:27935,40869:34893,40870:27958,40871:27947,40872:27965,40873:27960,40874:27929,40875:27957,40876:27955,40877:27922,40878:27916,40879:28003,40880:28051,40881:28004,40882:27994,40883:28025,40884:27993,40885:28046,40886:28053,40887:28644,40888:28037,40889:28153,40890:28181,40891:28170,40892:28085,40893:28103,40894:28134,40895:28088,40896:28102,40897:28140,40898:28126,40899:28108,40900:28136,40901:28114,40902:28101,40903:28154,40904:28121,40905:28132,40906:28117,40907:28138,40908:28142,40909:28205,40910:28270,40911:28206,40912:28185,40913:28274,40914:28255,40915:28222,40916:28195,40917:28267,40918:28203,40919:28278,40920:28237,40921:28191,40922:28227,40923:28218,40924:28238,40925:28196,40926:28415,40927:28189,40928:28216,40929:28290,40930:28330,40931:28312,40932:28361,40933:28343,40934:28371,40935:28349,40936:28335,40937:28356,40938:28338,40939:28372,40940:28373,40941:28303,40942:28325,40943:28354,40944:28319,40945:28481,40946:28433,40947:28748,40948:28396,40949:28408,40950:28414,40951:28479,40952:28402,40953:28465,40954:28399,40955:28466,40956:28364,161:65377,162:65378,163:65379,164:65380,165:65381,166:65382,167:65383,168:65384,169:65385,170:65386,171:65387,172:65388,173:65389,174:65390,175:65391,176:65392,177:65393,178:65394,179:65395,180:65396,181:65397,182:65398,183:65399,184:65400,185:65401,186:65402,187:65403,188:65404,189:65405,190:65406,191:65407,192:65408,193:65409,194:65410,195:65411,196:65412,197:65413,198:65414,199:65415,200:65416,201:65417,202:65418,203:65419,204:65420,205:65421,206:65422,207:65423,208:65424,209:65425,210:65426,211:65427,212:65428,213:65429,214:65430,215:65431,216:65432,217:65433,218:65434,219:65435,220:65436,221:65437,222:65438,223:65439,57408:28478,57409:28435,57410:28407,57411:28550,57412:28538,57413:28536,57414:28545,57415:28544,57416:28527,57417:28507,57418:28659,57419:28525,57420:28546,57421:28540,57422:28504,57423:28558,57424:28561,57425:28610,57426:28518,57427:28595,57428:28579,57429:28577,57430:28580,57431:28601,57432:28614,57433:28586,57434:28639,57435:28629,57436:28652,57437:28628,57438:28632,57439:28657,57440:28654,57441:28635,57442:28681,57443:28683,57444:28666,57445:28689,57446:28673,57447:28687,57448:28670,57449:28699,57450:28698,57451:28532,57452:28701,57453:28696,57454:28703,57455:28720,57456:28734,57457:28722,57458:28753,57459:28771,57460:28825,57461:28818,57462:28847,57463:28913,57464:28844,57465:28856,57466:28851,57467:28846,57468:28895,57469:28875,57470:28893,57472:28889,57473:28937,57474:28925,57475:28956,57476:28953,57477:29029,57478:29013,57479:29064,57480:29030,57481:29026,57482:29004,57483:29014,57484:29036,57485:29071,57486:29179,57487:29060,57488:29077,57489:29096,57490:29100,57491:29143,57492:29113,57493:29118,57494:29138,57495:29129,57496:29140,57497:29134,57498:29152,57499:29164,57500:29159,57501:29173,57502:29180,57503:29177,57504:29183,57505:29197,57506:29200,57507:29211,57508:29224,57509:29229,57510:29228,57511:29232,57512:29234,57513:29243,57514:29244,57515:29247,57516:29248,57517:29254,57518:29259,57519:29272,57520:29300,57521:29310,57522:29314,57523:29313,57524:29319,57525:29330,57526:29334,57527:29346,57528:29351,57529:29369,57530:29362,57531:29379,57532:29382,57533:29380,57534:29390,57535:29394,57536:29410,57537:29408,57538:29409,57539:29433,57540:29431,57541:20495,57542:29463,57543:29450,57544:29468,57545:29462,57546:29469,57547:29492,57548:29487,57549:29481,57550:29477,57551:29502,57552:29518,57553:29519,57554:40664,57555:29527,57556:29546,57557:29544,57558:29552,57559:29560,57560:29557,57561:29563,57562:29562,57563:29640,57564:29619,57565:29646,57566:29627,57567:29632,57568:29669,57569:29678,57570:29662,57571:29858,57572:29701,57573:29807,57574:29733,57575:29688,57576:29746,57577:29754,57578:29781,57579:29759,57580:29791,57581:29785,57582:29761,57583:29788,57584:29801,57585:29808,57586:29795,57587:29802,57588:29814,57589:29822,57590:29835,57591:29854,57592:29863,57593:29898,57594:29903,57595:29908,57596:29681,57664:29920,57665:29923,57666:29927,57667:29929,57668:29934,57669:29938,57670:29936,57671:29937,57672:29944,57673:29943,57674:29956,57675:29955,57676:29957,57677:29964,57678:29966,57679:29965,57680:29973,57681:29971,57682:29982,57683:29990,57684:29996,57685:30012,57686:30020,57687:30029,57688:30026,57689:30025,57690:30043,57691:30022,57692:30042,57693:30057,57694:30052,57695:30055,57696:30059,57697:30061,57698:30072,57699:30070,57700:30086,57701:30087,57702:30068,57703:30090,57704:30089,57705:30082,57706:30100,57707:30106,57708:30109,57709:30117,57710:30115,57711:30146,57712:30131,57713:30147,57714:30133,57715:30141,57716:30136,57717:30140,57718:30129,57719:30157,57720:30154,57721:30162,57722:30169,57723:30179,57724:30174,57725:30206,57726:30207,57728:30204,57729:30209,57730:30192,57731:30202,57732:30194,57733:30195,57734:30219,57735:30221,57736:30217,57737:30239,57738:30247,57739:30240,57740:30241,57741:30242,57742:30244,57743:30260,57744:30256,57745:30267,57746:30279,57747:30280,57748:30278,57749:30300,57750:30296,57751:30305,57752:30306,57753:30312,57754:30313,57755:30314,57756:30311,57757:30316,57758:30320,57759:30322,57760:30326,57761:30328,57762:30332,57763:30336,57764:30339,57765:30344,57766:30347,57767:30350,57768:30358,57769:30355,57770:30361,57771:30362,57772:30384,57773:30388,57774:30392,57775:30393,57776:30394,57777:30402,57778:30413,57779:30422,57780:30418,57781:30430,57782:30433,57783:30437,57784:30439,57785:30442,57786:34351,57787:30459,57788:30472,57789:30471,57790:30468,57791:30505,57792:30500,57793:30494,57794:30501,57795:30502,57796:30491,57797:30519,57798:30520,57799:30535,57800:30554,57801:30568,57802:30571,57803:30555,57804:30565,57805:30591,57806:30590,57807:30585,57808:30606,57809:30603,57810:30609,57811:30624,57812:30622,57813:30640,57814:30646,57815:30649,57816:30655,57817:30652,57818:30653,57819:30651,57820:30663,57821:30669,57822:30679,57823:30682,57824:30684,57825:30691,57826:30702,57827:30716,57828:30732,57829:30738,57830:31014,57831:30752,57832:31018,57833:30789,57834:30862,57835:30836,57836:30854,57837:30844,57838:30874,57839:30860,57840:30883,57841:30901,57842:30890,57843:30895,57844:30929,57845:30918,57846:30923,57847:30932,57848:30910,57849:30908,57850:30917,57851:30922,57852:30956,57920:30951,57921:30938,57922:30973,57923:30964,57924:30983,57925:30994,57926:30993,57927:31001,57928:31020,57929:31019,57930:31040,57931:31072,57932:31063,57933:31071,57934:31066,57935:31061,57936:31059,57937:31098,57938:31103,57939:31114,57940:31133,57941:31143,57942:40779,57943:31146,57944:31150,57945:31155,57946:31161,57947:31162,57948:31177,57949:31189,57950:31207,57951:31212,57952:31201,57953:31203,57954:31240,57955:31245,57956:31256,57957:31257,57958:31264,57959:31263,57960:31104,57961:31281,57962:31291,57963:31294,57964:31287,57965:31299,57966:31319,57967:31305,57968:31329,57969:31330,57970:31337,57971:40861,57972:31344,57973:31353,57974:31357,57975:31368,57976:31383,57977:31381,57978:31384,57979:31382,57980:31401,57981:31432,57982:31408,57984:31414,57985:31429,57986:31428,57987:31423,57988:36995,57989:31431,57990:31434,57991:31437,57992:31439,57993:31445,57994:31443,57995:31449,57996:31450,57997:31453,57998:31457,57999:31458,58e3:31462,58001:31469,58002:31472,58003:31490,58004:31503,58005:31498,58006:31494,58007:31539,58008:31512,58009:31513,58010:31518,58011:31541,58012:31528,58013:31542,58014:31568,58015:31610,58016:31492,58017:31565,58018:31499,58019:31564,58020:31557,58021:31605,58022:31589,58023:31604,58024:31591,58025:31600,58026:31601,58027:31596,58028:31598,58029:31645,58030:31640,58031:31647,58032:31629,58033:31644,58034:31642,58035:31627,58036:31634,58037:31631,58038:31581,58039:31641,58040:31691,58041:31681,58042:31692,58043:31695,58044:31668,58045:31686,58046:31709,58047:31721,58048:31761,58049:31764,58050:31718,58051:31717,58052:31840,58053:31744,58054:31751,58055:31763,58056:31731,58057:31735,58058:31767,58059:31757,58060:31734,58061:31779,58062:31783,58063:31786,58064:31775,58065:31799,58066:31787,58067:31805,58068:31820,58069:31811,58070:31828,58071:31823,58072:31808,58073:31824,58074:31832,58075:31839,58076:31844,58077:31830,58078:31845,58079:31852,58080:31861,58081:31875,58082:31888,58083:31908,58084:31917,58085:31906,58086:31915,58087:31905,58088:31912,58089:31923,58090:31922,58091:31921,58092:31918,58093:31929,58094:31933,58095:31936,58096:31941,58097:31938,58098:31960,58099:31954,58100:31964,58101:31970,58102:39739,58103:31983,58104:31986,58105:31988,58106:31990,58107:31994,58108:32006,58176:32002,58177:32028,58178:32021,58179:32010,58180:32069,58181:32075,58182:32046,58183:32050,58184:32063,58185:32053,58186:32070,58187:32115,58188:32086,58189:32078,58190:32114,58191:32104,58192:32110,58193:32079,58194:32099,58195:32147,58196:32137,58197:32091,58198:32143,58199:32125,58200:32155,58201:32186,58202:32174,58203:32163,58204:32181,58205:32199,58206:32189,58207:32171,58208:32317,58209:32162,58210:32175,58211:32220,58212:32184,58213:32159,58214:32176,58215:32216,58216:32221,58217:32228,58218:32222,58219:32251,58220:32242,58221:32225,58222:32261,58223:32266,58224:32291,58225:32289,58226:32274,58227:32305,58228:32287,58229:32265,58230:32267,58231:32290,58232:32326,58233:32358,58234:32315,58235:32309,58236:32313,58237:32323,58238:32311,58240:32306,58241:32314,58242:32359,58243:32349,58244:32342,58245:32350,58246:32345,58247:32346,58248:32377,58249:32362,58250:32361,58251:32380,58252:32379,58253:32387,58254:32213,58255:32381,58256:36782,58257:32383,58258:32392,58259:32393,58260:32396,58261:32402,58262:32400,58263:32403,58264:32404,58265:32406,58266:32398,58267:32411,58268:32412,58269:32568,58270:32570,58271:32581,58272:32588,58273:32589,58274:32590,58275:32592,58276:32593,58277:32597,58278:32596,58279:32600,58280:32607,58281:32608,58282:32616,58283:32617,58284:32615,58285:32632,58286:32642,58287:32646,58288:32643,58289:32648,58290:32647,58291:32652,58292:32660,58293:32670,58294:32669,58295:32666,58296:32675,58297:32687,58298:32690,58299:32697,58300:32686,58301:32694,58302:32696,58303:35697,58304:32709,58305:32710,58306:32714,58307:32725,58308:32724,58309:32737,58310:32742,58311:32745,58312:32755,58313:32761,58314:39132,58315:32774,58316:32772,58317:32779,58318:32786,58319:32792,58320:32793,58321:32796,58322:32801,58323:32808,58324:32831,58325:32827,58326:32842,58327:32838,58328:32850,58329:32856,58330:32858,58331:32863,58332:32866,58333:32872,58334:32883,58335:32882,58336:32880,58337:32886,58338:32889,58339:32893,58340:32895,58341:32900,58342:32902,58343:32901,58344:32923,58345:32915,58346:32922,58347:32941,58348:20880,58349:32940,58350:32987,58351:32997,58352:32985,58353:32989,58354:32964,58355:32986,58356:32982,58357:33033,58358:33007,58359:33009,58360:33051,58361:33065,58362:33059,58363:33071,58364:33099,58432:38539,58433:33094,58434:33086,58435:33107,58436:33105,58437:33020,58438:33137,58439:33134,58440:33125,58441:33126,58442:33140,58443:33155,58444:33160,58445:33162,58446:33152,58447:33154,58448:33184,58449:33173,58450:33188,58451:33187,58452:33119,58453:33171,58454:33193,58455:33200,58456:33205,58457:33214,58458:33208,58459:33213,58460:33216,58461:33218,58462:33210,58463:33225,58464:33229,58465:33233,58466:33241,58467:33240,58468:33224,58469:33242,58470:33247,58471:33248,58472:33255,58473:33274,58474:33275,58475:33278,58476:33281,58477:33282,58478:33285,58479:33287,58480:33290,58481:33293,58482:33296,58483:33302,58484:33321,58485:33323,58486:33336,58487:33331,58488:33344,58489:33369,58490:33368,58491:33373,58492:33370,58493:33375,58494:33380,58496:33378,58497:33384,58498:33386,58499:33387,58500:33326,58501:33393,58502:33399,58503:33400,58504:33406,58505:33421,58506:33426,58507:33451,58508:33439,58509:33467,58510:33452,58511:33505,58512:33507,58513:33503,58514:33490,58515:33524,58516:33523,58517:33530,58518:33683,58519:33539,58520:33531,58521:33529,58522:33502,58523:33542,58524:33500,58525:33545,58526:33497,58527:33589,58528:33588,58529:33558,58530:33586,58531:33585,58532:33600,58533:33593,58534:33616,58535:33605,58536:33583,58537:33579,58538:33559,58539:33560,58540:33669,58541:33690,58542:33706,58543:33695,58544:33698,58545:33686,58546:33571,58547:33678,58548:33671,58549:33674,58550:33660,58551:33717,58552:33651,58553:33653,58554:33696,58555:33673,58556:33704,58557:33780,58558:33811,58559:33771,58560:33742,58561:33789,58562:33795,58563:33752,58564:33803,58565:33729,58566:33783,58567:33799,58568:33760,58569:33778,58570:33805,58571:33826,58572:33824,58573:33725,58574:33848,58575:34054,58576:33787,58577:33901,58578:33834,58579:33852,58580:34138,58581:33924,58582:33911,58583:33899,58584:33965,58585:33902,58586:33922,58587:33897,58588:33862,58589:33836,58590:33903,58591:33913,58592:33845,58593:33994,58594:33890,58595:33977,58596:33983,58597:33951,58598:34009,58599:33997,58600:33979,58601:34010,58602:34e3,58603:33985,58604:33990,58605:34006,58606:33953,58607:34081,58608:34047,58609:34036,58610:34071,58611:34072,58612:34092,58613:34079,58614:34069,58615:34068,58616:34044,58617:34112,58618:34147,58619:34136,58620:34120,58688:34113,58689:34306,58690:34123,58691:34133,58692:34176,58693:34212,58694:34184,58695:34193,58696:34186,58697:34216,58698:34157,58699:34196,58700:34203,58701:34282,58702:34183,58703:34204,58704:34167,58705:34174,58706:34192,58707:34249,58708:34234,58709:34255,58710:34233,58711:34256,58712:34261,58713:34269,58714:34277,58715:34268,58716:34297,58717:34314,58718:34323,58719:34315,58720:34302,58721:34298,58722:34310,58723:34338,58724:34330,58725:34352,58726:34367,58727:34381,58728:20053,58729:34388,58730:34399,58731:34407,58732:34417,58733:34451,58734:34467,58735:34473,58736:34474,58737:34443,58738:34444,58739:34486,58740:34479,58741:34500,58742:34502,58743:34480,58744:34505,58745:34851,58746:34475,58747:34516,58748:34526,58749:34537,58750:34540,58752:34527,58753:34523,58754:34543,58755:34578,58756:34566,58757:34568,58758:34560,58759:34563,58760:34555,58761:34577,58762:34569,58763:34573,58764:34553,58765:34570,58766:34612,58767:34623,58768:34615,58769:34619,58770:34597,58771:34601,58772:34586,58773:34656,58774:34655,58775:34680,58776:34636,58777:34638,58778:34676,58779:34647,58780:34664,58781:34670,58782:34649,58783:34643,58784:34659,58785:34666,58786:34821,58787:34722,58788:34719,58789:34690,58790:34735,58791:34763,58792:34749,58793:34752,58794:34768,58795:38614,58796:34731,58797:34756,58798:34739,58799:34759,58800:34758,58801:34747,58802:34799,58803:34802,58804:34784,58805:34831,58806:34829,58807:34814,58808:34806,58809:34807,58810:34830,58811:34770,58812:34833,58813:34838,58814:34837,58815:34850,58816:34849,58817:34865,58818:34870,58819:34873,58820:34855,58821:34875,58822:34884,58823:34882,58824:34898,58825:34905,58826:34910,58827:34914,58828:34923,58829:34945,58830:34942,58831:34974,58832:34933,58833:34941,58834:34997,58835:34930,58836:34946,58837:34967,58838:34962,58839:34990,58840:34969,58841:34978,58842:34957,58843:34980,58844:34992,58845:35007,58846:34993,58847:35011,58848:35012,58849:35028,58850:35032,58851:35033,58852:35037,58853:35065,58854:35074,58855:35068,58856:35060,58857:35048,58858:35058,58859:35076,58860:35084,58861:35082,58862:35091,58863:35139,58864:35102,58865:35109,58866:35114,58867:35115,58868:35137,58869:35140,58870:35131,58871:35126,58872:35128,58873:35148,58874:35101,58875:35168,58876:35166,58944:35174,58945:35172,58946:35181,58947:35178,58948:35183,58949:35188,58950:35191,58951:35198,58952:35203,58953:35208,58954:35210,58955:35219,58956:35224,58957:35233,58958:35241,58959:35238,58960:35244,58961:35247,58962:35250,58963:35258,58964:35261,58965:35263,58966:35264,58967:35290,58968:35292,58969:35293,58970:35303,58971:35316,58972:35320,58973:35331,58974:35350,58975:35344,58976:35340,58977:35355,58978:35357,58979:35365,58980:35382,58981:35393,58982:35419,58983:35410,58984:35398,58985:35400,58986:35452,58987:35437,58988:35436,58989:35426,58990:35461,58991:35458,58992:35460,58993:35496,58994:35489,58995:35473,58996:35493,58997:35494,58998:35482,58999:35491,59e3:35524,59001:35533,59002:35522,59003:35546,59004:35563,59005:35571,59006:35559,59008:35556,59009:35569,59010:35604,59011:35552,59012:35554,59013:35575,59014:35550,59015:35547,59016:35596,59017:35591,59018:35610,59019:35553,59020:35606,59021:35600,59022:35607,59023:35616,59024:35635,59025:38827,59026:35622,59027:35627,59028:35646,59029:35624,59030:35649,59031:35660,59032:35663,59033:35662,59034:35657,59035:35670,59036:35675,59037:35674,59038:35691,59039:35679,59040:35692,59041:35695,59042:35700,59043:35709,59044:35712,59045:35724,59046:35726,59047:35730,59048:35731,59049:35734,59050:35737,59051:35738,59052:35898,59053:35905,59054:35903,59055:35912,59056:35916,59057:35918,59058:35920,59059:35925,59060:35938,59061:35948,59062:35960,59063:35962,59064:35970,59065:35977,59066:35973,59067:35978,59068:35981,59069:35982,59070:35988,59071:35964,59072:35992,59073:25117,59074:36013,59075:36010,59076:36029,59077:36018,59078:36019,59079:36014,59080:36022,59081:36040,59082:36033,59083:36068,59084:36067,59085:36058,59086:36093,59087:36090,59088:36091,59089:36100,59090:36101,59091:36106,59092:36103,59093:36111,59094:36109,59095:36112,59096:40782,59097:36115,59098:36045,59099:36116,59100:36118,59101:36199,59102:36205,59103:36209,59104:36211,59105:36225,59106:36249,59107:36290,59108:36286,59109:36282,59110:36303,59111:36314,59112:36310,59113:36300,59114:36315,59115:36299,59116:36330,59117:36331,59118:36319,59119:36323,59120:36348,59121:36360,59122:36361,59123:36351,59124:36381,59125:36382,59126:36368,59127:36383,59128:36418,59129:36405,59130:36400,59131:36404,59132:36426,59200:36423,59201:36425,59202:36428,59203:36432,59204:36424,59205:36441,59206:36452,59207:36448,59208:36394,59209:36451,59210:36437,59211:36470,59212:36466,59213:36476,59214:36481,59215:36487,59216:36485,59217:36484,59218:36491,59219:36490,59220:36499,59221:36497,59222:36500,59223:36505,59224:36522,59225:36513,59226:36524,59227:36528,59228:36550,59229:36529,59230:36542,59231:36549,59232:36552,59233:36555,59234:36571,59235:36579,59236:36604,59237:36603,59238:36587,59239:36606,59240:36618,59241:36613,59242:36629,59243:36626,59244:36633,59245:36627,59246:36636,59247:36639,59248:36635,59249:36620,59250:36646,59251:36659,59252:36667,59253:36665,59254:36677,59255:36674,59256:36670,59257:36684,59258:36681,59259:36678,59260:36686,59261:36695,59262:36700,59264:36706,59265:36707,59266:36708,59267:36764,59268:36767,59269:36771,59270:36781,59271:36783,59272:36791,59273:36826,59274:36837,59275:36834,59276:36842,59277:36847,59278:36999,59279:36852,59280:36869,59281:36857,59282:36858,59283:36881,59284:36885,59285:36897,59286:36877,59287:36894,59288:36886,59289:36875,59290:36903,59291:36918,59292:36917,59293:36921,59294:36856,59295:36943,59296:36944,59297:36945,59298:36946,59299:36878,59300:36937,59301:36926,59302:36950,59303:36952,59304:36958,59305:36968,59306:36975,59307:36982,59308:38568,59309:36978,59310:36994,59311:36989,59312:36993,59313:36992,59314:37002,59315:37001,59316:37007,59317:37032,59318:37039,59319:37041,59320:37045,59321:37090,59322:37092,59323:25160,59324:37083,59325:37122,59326:37138,59327:37145,59328:37170,59329:37168,59330:37194,59331:37206,59332:37208,59333:37219,59334:37221,59335:37225,59336:37235,59337:37234,59338:37259,59339:37257,59340:37250,59341:37282,59342:37291,59343:37295,59344:37290,59345:37301,59346:37300,59347:37306,59348:37312,59349:37313,59350:37321,59351:37323,59352:37328,59353:37334,59354:37343,59355:37345,59356:37339,59357:37372,59358:37365,59359:37366,59360:37406,59361:37375,59362:37396,59363:37420,59364:37397,59365:37393,59366:37470,59367:37463,59368:37445,59369:37449,59370:37476,59371:37448,59372:37525,59373:37439,59374:37451,59375:37456,59376:37532,59377:37526,59378:37523,59379:37531,59380:37466,59381:37583,59382:37561,59383:37559,59384:37609,59385:37647,59386:37626,59387:37700,59388:37678,59456:37657,59457:37666,59458:37658,59459:37667,59460:37690,59461:37685,59462:37691,59463:37724,59464:37728,59465:37756,59466:37742,59467:37718,59468:37808,59469:37804,59470:37805,59471:37780,59472:37817,59473:37846,59474:37847,59475:37864,59476:37861,59477:37848,59478:37827,59479:37853,59480:37840,59481:37832,59482:37860,59483:37914,59484:37908,59485:37907,59486:37891,59487:37895,59488:37904,59489:37942,59490:37931,59491:37941,59492:37921,59493:37946,59494:37953,59495:37970,59496:37956,59497:37979,59498:37984,59499:37986,59500:37982,59501:37994,59502:37417,59503:38e3,59504:38005,59505:38007,59506:38013,59507:37978,59508:38012,59509:38014,59510:38017,59511:38015,59512:38274,59513:38279,59514:38282,59515:38292,59516:38294,59517:38296,59518:38297,59520:38304,59521:38312,59522:38311,59523:38317,59524:38332,59525:38331,59526:38329,59527:38334,59528:38346,59529:28662,59530:38339,59531:38349,59532:38348,59533:38357,59534:38356,59535:38358,59536:38364,59537:38369,59538:38373,59539:38370,59540:38433,59541:38440,59542:38446,59543:38447,59544:38466,59545:38476,59546:38479,59547:38475,59548:38519,59549:38492,59550:38494,59551:38493,59552:38495,59553:38502,59554:38514,59555:38508,59556:38541,59557:38552,59558:38549,59559:38551,59560:38570,59561:38567,59562:38577,59563:38578,59564:38576,59565:38580,59566:38582,59567:38584,59568:38585,59569:38606,59570:38603,59571:38601,59572:38605,59573:35149,59574:38620,59575:38669,59576:38613,59577:38649,59578:38660,59579:38662,59580:38664,59581:38675,59582:38670,59583:38673,59584:38671,59585:38678,59586:38681,59587:38692,59588:38698,59589:38704,59590:38713,59591:38717,59592:38718,59593:38724,59594:38726,59595:38728,59596:38722,59597:38729,59598:38748,59599:38752,59600:38756,59601:38758,59602:38760,59603:21202,59604:38763,59605:38769,59606:38777,59607:38789,59608:38780,59609:38785,59610:38778,59611:38790,59612:38795,59613:38799,59614:38800,59615:38812,59616:38824,59617:38822,59618:38819,59619:38835,59620:38836,59621:38851,59622:38854,59623:38856,59624:38859,59625:38876,59626:38893,59627:40783,59628:38898,59629:31455,59630:38902,59631:38901,59632:38927,59633:38924,59634:38968,59635:38948,59636:38945,59637:38967,59638:38973,59639:38982,59640:38991,59641:38987,59642:39019,59643:39023,59644:39024,59712:39025,59713:39028,59714:39027,59715:39082,59716:39087,59717:39089,59718:39094,59719:39108,59720:39107,59721:39110,59722:39145,59723:39147,59724:39171,59725:39177,59726:39186,59727:39188,59728:39192,59729:39201,59730:39197,59731:39198,59732:39204,59733:39200,59734:39212,59735:39214,59736:39229,59737:39230,59738:39234,59739:39241,59740:39237,59741:39248,59742:39243,59743:39249,59744:39250,59745:39244,59746:39253,59747:39319,59748:39320,59749:39333,59750:39341,59751:39342,59752:39356,59753:39391,59754:39387,59755:39389,59756:39384,59757:39377,59758:39405,59759:39406,59760:39409,59761:39410,59762:39419,59763:39416,59764:39425,59765:39439,59766:39429,59767:39394,59768:39449,59769:39467,59770:39479,59771:39493,59772:39490,59773:39488,59774:39491,59776:39486,59777:39509,59778:39501,59779:39515,59780:39511,59781:39519,59782:39522,59783:39525,59784:39524,59785:39529,59786:39531,59787:39530,59788:39597,59789:39600,59790:39612,59791:39616,59792:39631,59793:39633,59794:39635,59795:39636,59796:39646,59797:39647,59798:39650,59799:39651,59800:39654,59801:39663,59802:39659,59803:39662,59804:39668,59805:39665,59806:39671,59807:39675,59808:39686,59809:39704,59810:39706,59811:39711,59812:39714,59813:39715,59814:39717,59815:39719,59816:39720,59817:39721,59818:39722,59819:39726,59820:39727,59821:39730,59822:39748,59823:39747,59824:39759,59825:39757,59826:39758,59827:39761,59828:39768,59829:39796,59830:39827,59831:39811,59832:39825,59833:39830,59834:39831,59835:39839,59836:39840,59837:39848,59838:39860,59839:39872,59840:39882,59841:39865,59842:39878,59843:39887,59844:39889,59845:39890,59846:39907,59847:39906,59848:39908,59849:39892,59850:39905,59851:39994,59852:39922,59853:39921,59854:39920,59855:39957,59856:39956,59857:39945,59858:39955,59859:39948,59860:39942,59861:39944,59862:39954,59863:39946,59864:39940,59865:39982,59866:39963,59867:39973,59868:39972,59869:39969,59870:39984,59871:40007,59872:39986,59873:40006,59874:39998,59875:40026,59876:40032,59877:40039,59878:40054,59879:40056,59880:40167,59881:40172,59882:40176,59883:40201,59884:40200,59885:40171,59886:40195,59887:40198,59888:40234,59889:40230,59890:40367,59891:40227,59892:40223,59893:40260,59894:40213,59895:40210,59896:40257,59897:40255,59898:40254,59899:40262,59900:40264,59968:40285,59969:40286,59970:40292,59971:40273,59972:40272,59973:40281,59974:40306,59975:40329,59976:40327,59977:40363,59978:40303,59979:40314,59980:40346,59981:40356,59982:40361,59983:40370,59984:40388,59985:40385,59986:40379,59987:40376,59988:40378,59989:40390,59990:40399,59991:40386,59992:40409,59993:40403,59994:40440,59995:40422,59996:40429,59997:40431,59998:40445,59999:40474,6e4:40475,60001:40478,60002:40565,60003:40569,60004:40573,60005:40577,60006:40584,60007:40587,60008:40588,60009:40594,60010:40597,60011:40593,60012:40605,60013:40613,60014:40617,60015:40632,60016:40618,60017:40621,60018:38753,60019:40652,60020:40654,60021:40655,60022:40656,60023:40660,60024:40668,60025:40670,60026:40669,60027:40672,60028:40677,60029:40680,60030:40687,60032:40692,60033:40694,60034:40695,60035:40697,60036:40699,60037:40700,60038:40701,60039:40711,60040:40712,60041:30391,60042:40725,60043:40737,60044:40748,60045:40766,60046:40778,60047:40786,60048:40788,60049:40803,60050:40799,60051:40800,60052:40801,60053:40806,60054:40807,60055:40812,60056:40810,60057:40823,60058:40818,60059:40822,60060:40853,60061:40860,60062:40864,60063:22575,60064:27079,60065:36953,60066:29796,60067:20956,60068:29081}}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(2);function a(e,t,n,r){var i;t.degree()<n.degree()&&(i=[n,t],t=i[0],n=i[1]);for(var a=t,o=n,s=e.zero,c=e.one;o.degree()>=r/2;){var l=a,u=s;if(a=o,s=c,a.isZero())return null;o=l;for(var d=e.zero,f=a.getCoefficient(a.degree()),p=e.inverse(f);o.degree()>=a.degree()&&!o.isZero();){var m=o.degree()-a.degree(),h=e.multiply(o.getCoefficient(o.degree()),p);d=d.addOrSubtract(e.buildMonomial(m,h)),o=o.addOrSubtract(a.multiplyByMonomial(m,h))}if(c=d.multiplyPoly(s).addOrSubtract(u),o.degree()>=a.degree())return null}var g=c.getCoefficient(0);if(g===0)return null;var _=e.inverse(g);return[c.multiply(_),o.multiply(_)]}function o(e,t){var n=t.degree();if(n===1)return[t.getCoefficient(1)];for(var r=Array(n),i=0,a=1;a<e.size&&i<n;a++)t.evaluateAt(a)===0&&(r[i]=e.inverse(a),i++);return i===n?r:null}function s(e,t,n){for(var i=n.length,a=Array(i),o=0;o<i;o++){for(var s=e.inverse(n[o]),c=1,l=0;l<i;l++)o!==l&&(c=e.multiply(c,r.addOrSubtractGF(1,e.multiply(n[l],s))));a[o]=e.multiply(t.evaluateAt(s),e.inverse(c)),e.generatorBase!==0&&(a[o]=e.multiply(a[o],s))}return a}function c(e,t){var n=new Uint8ClampedArray(e.length);n.set(e);for(var c=new r.default(285,256,0),l=new i.default(c,n),u=new Uint8ClampedArray(t),d=!1,f=0;f<t;f++){var p=l.evaluateAt(c.exp(f+c.generatorBase));u[u.length-1-f]=p,p!==0&&(d=!0)}if(!d)return n;var m=new i.default(c,u),h=a(c,c.buildMonomial(t,1),m,t);if(h===null)return null;var g=o(c,h[0]);if(g==null)return null;for(var _=s(c,h[1],g),v=0;v<g.length;v++){var y=n.length-1-c.log(g[v]);if(y<0)return null;n[y]=r.addOrSubtractGF(n[y],_[v])}return n}t.decode=c}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.VERSIONS=[{infoBits:null,versionNumber:1,alignmentPatternCenters:[],errorCorrectionLevels:[{ecCodewordsPerBlock:7,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:13,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:13}]},{ecCodewordsPerBlock:17,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:2,alignmentPatternCenters:[6,18],errorCorrectionLevels:[{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:34}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:28}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]}]},{infoBits:null,versionNumber:3,alignmentPatternCenters:[6,22],errorCorrectionLevels:[{ecCodewordsPerBlock:15,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:55}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:13}]}]},{infoBits:null,versionNumber:4,alignmentPatternCenters:[6,26],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:80}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:32}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:5,alignmentPatternCenters:[6,30],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:43}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:11},{numBlocks:2,dataCodewordsPerBlock:12}]}]},{infoBits:null,versionNumber:6,alignmentPatternCenters:[6,34],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:27}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:31892,versionNumber:7,alignmentPatternCenters:[6,22,38],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:78}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:31}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:13},{numBlocks:1,dataCodewordsPerBlock:14}]}]},{infoBits:34236,versionNumber:8,alignmentPatternCenters:[6,24,42],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:97}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:38},{numBlocks:2,dataCodewordsPerBlock:39}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:18},{numBlocks:2,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:14},{numBlocks:2,dataCodewordsPerBlock:15}]}]},{infoBits:39577,versionNumber:9,alignmentPatternCenters:[6,26,46],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:12},{numBlocks:4,dataCodewordsPerBlock:13}]}]},{infoBits:42195,versionNumber:10,alignmentPatternCenters:[6,28,50],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68},{numBlocks:2,dataCodewordsPerBlock:69}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:43},{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]}]},{infoBits:48118,versionNumber:11,alignmentPatternCenters:[6,30,54],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:81}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:50},{numBlocks:4,dataCodewordsPerBlock:51}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:22},{numBlocks:4,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:12},{numBlocks:8,dataCodewordsPerBlock:13}]}]},{infoBits:51042,versionNumber:12,alignmentPatternCenters:[6,32,58],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:92},{numBlocks:2,dataCodewordsPerBlock:93}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:20},{numBlocks:6,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:55367,versionNumber:13,alignmentPatternCenters:[6,34,62],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:37},{numBlocks:1,dataCodewordsPerBlock:38}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:20},{numBlocks:4,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:11},{numBlocks:4,dataCodewordsPerBlock:12}]}]},{infoBits:58893,versionNumber:14,alignmentPatternCenters:[6,26,46,66],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:40},{numBlocks:5,dataCodewordsPerBlock:41}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:16},{numBlocks:5,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:5,dataCodewordsPerBlock:13}]}]},{infoBits:63784,versionNumber:15,alignmentPatternCenters:[6,26,48,70],errorCorrectionLevels:[{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:87},{numBlocks:1,dataCodewordsPerBlock:88}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:41},{numBlocks:5,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:7,dataCodewordsPerBlock:13}]}]},{infoBits:68472,versionNumber:16,alignmentPatternCenters:[6,26,50,74],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:98},{numBlocks:1,dataCodewordsPerBlock:99}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:70749,versionNumber:17,alignmentPatternCenters:[6,30,54,78],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:1,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22},{numBlocks:15,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:17,dataCodewordsPerBlock:15}]}]},{infoBits:76311,versionNumber:18,alignmentPatternCenters:[6,30,56,82],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:120},{numBlocks:1,dataCodewordsPerBlock:121}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:43},{numBlocks:4,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:1,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:19,dataCodewordsPerBlock:15}]}]},{infoBits:79154,versionNumber:19,alignmentPatternCenters:[6,30,58,86],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:113},{numBlocks:4,dataCodewordsPerBlock:114}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:44},{numBlocks:11,dataCodewordsPerBlock:45}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:21},{numBlocks:4,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:13},{numBlocks:16,dataCodewordsPerBlock:14}]}]},{infoBits:84390,versionNumber:20,alignmentPatternCenters:[6,34,62,90],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:41},{numBlocks:13,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:5,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:15},{numBlocks:10,dataCodewordsPerBlock:16}]}]},{infoBits:87683,versionNumber:21,alignmentPatternCenters:[6,28,50,72,94],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:116},{numBlocks:4,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:16},{numBlocks:6,dataCodewordsPerBlock:17}]}]},{infoBits:92361,versionNumber:22,alignmentPatternCenters:[6,26,50,74,98],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:111},{numBlocks:7,dataCodewordsPerBlock:112}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:13}]}]},{infoBits:96236,versionNumber:23,alignmentPatternCenters:[6,30,54,74,102],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:121},{numBlocks:5,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:47},{numBlocks:14,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:16,dataCodewordsPerBlock:15},{numBlocks:14,dataCodewordsPerBlock:16}]}]},{infoBits:102084,versionNumber:24,alignmentPatternCenters:[6,28,54,80,106],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:45},{numBlocks:14,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:30,dataCodewordsPerBlock:16},{numBlocks:2,dataCodewordsPerBlock:17}]}]},{infoBits:102881,versionNumber:25,alignmentPatternCenters:[6,32,58,84,110],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:106},{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:47},{numBlocks:13,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:110507,versionNumber:26,alignmentPatternCenters:[6,30,58,86,114],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:114},{numBlocks:2,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:46},{numBlocks:4,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:28,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:33,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]}]},{infoBits:110734,versionNumber:27,alignmentPatternCenters:[6,34,62,90,118],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:23},{numBlocks:26,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:117786,versionNumber:28,alignmentPatternCenters:[6,26,50,74,98,122],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:117},{numBlocks:10,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:45},{numBlocks:23,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:24},{numBlocks:31,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:31,dataCodewordsPerBlock:16}]}]},{infoBits:119615,versionNumber:29,alignmentPatternCenters:[6,30,54,78,102,126],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:116},{numBlocks:7,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:21,dataCodewordsPerBlock:45},{numBlocks:7,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:23},{numBlocks:37,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:26,dataCodewordsPerBlock:16}]}]},{infoBits:126325,versionNumber:30,alignmentPatternCenters:[6,26,52,78,104,130],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:115},{numBlocks:10,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:47},{numBlocks:10,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:25,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:25,dataCodewordsPerBlock:16}]}]},{infoBits:127568,versionNumber:31,alignmentPatternCenters:[6,30,56,82,108,134],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:3,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:46},{numBlocks:29,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:24},{numBlocks:1,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:133589,versionNumber:32,alignmentPatternCenters:[6,34,60,86,112,138],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:24},{numBlocks:35,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:35,dataCodewordsPerBlock:16}]}]},{infoBits:136944,versionNumber:33,alignmentPatternCenters:[6,30,58,86,114,142],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:21,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:24},{numBlocks:19,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:141498,versionNumber:34,alignmentPatternCenters:[6,34,62,90,118,146],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:6,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:44,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:59,dataCodewordsPerBlock:16},{numBlocks:1,dataCodewordsPerBlock:17}]}]},{infoBits:145311,versionNumber:35,alignmentPatternCenters:[6,30,54,78,102,126,150],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:121},{numBlocks:7,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:47},{numBlocks:26,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:39,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:41,dataCodewordsPerBlock:16}]}]},{infoBits:150283,versionNumber:36,alignmentPatternCenters:[6,24,50,76,102,128,154],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:121},{numBlocks:14,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:47},{numBlocks:34,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:46,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:64,dataCodewordsPerBlock:16}]}]},{infoBits:152622,versionNumber:37,alignmentPatternCenters:[6,28,54,80,106,132,158],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:46},{numBlocks:14,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:49,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:24,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:158308,versionNumber:38,alignmentPatternCenters:[6,32,58,84,110,136,162],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:122},{numBlocks:18,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:46},{numBlocks:32,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:48,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:15},{numBlocks:32,dataCodewordsPerBlock:16}]}]},{infoBits:161089,versionNumber:39,alignmentPatternCenters:[6,26,54,82,110,138,166],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:40,dataCodewordsPerBlock:47},{numBlocks:7,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:43,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:15},{numBlocks:67,dataCodewordsPerBlock:16}]}]},{infoBits:167017,versionNumber:40,alignmentPatternCenters:[6,30,58,86,114,142,170],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:118},{numBlocks:6,dataCodewordsPerBlock:119}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:18,dataCodewordsPerBlock:47},{numBlocks:31,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:24},{numBlocks:34,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:15},{numBlocks:61,dataCodewordsPerBlock:16}]}]}]}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function i(e,t,n,r){var i=e.x-t.x+n.x-r.x,a=e.y-t.y+n.y-r.y;if(i===0&&a===0)return{a11:t.x-e.x,a12:t.y-e.y,a13:0,a21:n.x-t.x,a22:n.y-t.y,a23:0,a31:e.x,a32:e.y,a33:1};var o=t.x-n.x,s=r.x-n.x,c=t.y-n.y,l=r.y-n.y,u=o*l-s*c,d=(i*l-s*a)/u,f=(o*a-i*c)/u;return{a11:t.x-e.x+d*t.x,a12:t.y-e.y+d*t.y,a13:d,a21:r.x-e.x+f*r.x,a22:r.y-e.y+f*r.y,a23:f,a31:e.x,a32:e.y,a33:1}}function a(e,t,n,r){var a=i(e,t,n,r);return{a11:a.a22*a.a33-a.a23*a.a32,a12:a.a13*a.a32-a.a12*a.a33,a13:a.a12*a.a23-a.a13*a.a22,a21:a.a23*a.a31-a.a21*a.a33,a22:a.a11*a.a33-a.a13*a.a31,a23:a.a13*a.a21-a.a11*a.a23,a31:a.a21*a.a32-a.a22*a.a31,a32:a.a12*a.a31-a.a11*a.a32,a33:a.a11*a.a22-a.a12*a.a21}}function o(e,t){return{a11:e.a11*t.a11+e.a21*t.a12+e.a31*t.a13,a12:e.a12*t.a11+e.a22*t.a12+e.a32*t.a13,a13:e.a13*t.a11+e.a23*t.a12+e.a33*t.a13,a21:e.a11*t.a21+e.a21*t.a22+e.a31*t.a23,a22:e.a12*t.a21+e.a22*t.a22+e.a32*t.a23,a23:e.a13*t.a21+e.a23*t.a22+e.a33*t.a23,a31:e.a11*t.a31+e.a21*t.a32+e.a31*t.a33,a32:e.a12*t.a31+e.a22*t.a32+e.a32*t.a33,a33:e.a13*t.a31+e.a23*t.a32+e.a33*t.a33}}function s(e,t){for(var n=a({x:3.5,y:3.5},{x:t.dimension-3.5,y:3.5},{x:t.dimension-6.5,y:t.dimension-6.5},{x:3.5,y:t.dimension-3.5}),s=o(i(t.topLeft,t.topRight,t.alignmentPattern,t.bottomLeft),n),c=r.BitMatrix.createEmpty(t.dimension,t.dimension),l=function(e,t){var n=s.a13*e+s.a23*t+s.a33;return{x:(s.a11*e+s.a21*t+s.a31)/n,y:(s.a12*e+s.a22*t+s.a32)/n}},u=0;u<t.dimension;u++)for(var d=0;d<t.dimension;d++){var f=l(d+.5,u+.5);c.set(d,u,e.get(Math.floor(f.x),Math.floor(f.y)))}return{matrix:c,mappingFunction:l}}t.extract=s}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=4,i=.5,a=1.5,o=function(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)};function s(e){return e.reduce(function(e,t){return e+t})}function c(e,t,n){var r,i,a,s,c=o(e,t),l=o(t,n),u=o(e,n),d,f,p;return l>=c&&l>=u?(r=[t,e,n],d=r[0],f=r[1],p=r[2]):u>=l&&u>=c?(i=[e,t,n],d=i[0],f=i[1],p=i[2]):(a=[e,n,t],d=a[0],f=a[1],p=a[2]),(p.x-f.x)*(d.y-f.y)-(p.y-f.y)*(d.x-f.x)<0&&(s=[p,d],d=s[0],p=s[1]),{bottomLeft:d,topLeft:f,topRight:p}}function l(e,t,n,r){var i=(s(d(e,n,r,5))/7+s(d(e,t,r,5))/7+s(d(n,e,r,5))/7+s(d(t,e,r,5))/7)/4;if(i<1)throw Error(`Invalid module size`);var a=Math.round(o(e,t)/i),c=Math.round(o(e,n)/i),l=Math.floor((a+c)/2)+7;switch(l%4){case 0:l++;break;case 2:l--;break}return{dimension:l,moduleSize:i}}function u(e,t,n,r){var i=[{x:Math.floor(e.x),y:Math.floor(e.y)}],a=Math.abs(t.y-e.y)>Math.abs(t.x-e.x),s,c,l,u;a?(s=Math.floor(e.y),c=Math.floor(e.x),l=Math.floor(t.y),u=Math.floor(t.x)):(s=Math.floor(e.x),c=Math.floor(e.y),l=Math.floor(t.x),u=Math.floor(t.y));for(var d=Math.abs(l-s),f=Math.abs(u-c),p=Math.floor(-d/2),m=s<l?1:-1,h=c<u?1:-1,g=!0,_=s,v=c;_!==l+m;_+=m){var y=a?v:_,b=a?_:v;if(n.get(y,b)!==g&&(g=!g,i.push({x:y,y:b}),i.length===r+1))break;if(p+=f,p>0){if(v===u)break;v+=h,p-=d}}for(var x=[],S=0;S<r;S++)i[S]&&i[S+1]?x.push(o(i[S],i[S+1])):x.push(0);return x}function d(e,t,n,r){var i,a=t.y-e.y,o=t.x-e.x,s=u(e,t,n,Math.ceil(r/2)),c=u(e,{x:e.x-o,y:e.y-a},n,Math.ceil(r/2)),l=s.shift()+c.shift()-1;return(i=c.concat(l)).concat.apply(i,s)}function f(e,t){var n=s(e)/s(t),r=0;return t.forEach(function(t,i){r+=(e[i]-t*n)**2}),{averageSize:n,error:r}}function p(e,t,n){try{var r=d(e,{x:-1,y:e.y},n,t.length),i=d(e,{x:e.x,y:-1},n,t.length),a=d(e,{x:Math.max(0,e.x-e.y)-1,y:Math.max(0,e.y-e.x)-1},n,t.length),o=d(e,{x:Math.min(n.width,e.x+e.y)+1,y:Math.min(n.height,e.y+e.x)+1},n,t.length),s=f(r,t),c=f(i,t),l=f(a,t),u=f(o,t),p=Math.sqrt(s.error*s.error+c.error*c.error+l.error*l.error+u.error*u.error),m=(s.averageSize+c.averageSize+l.averageSize+u.averageSize)/4;return p+((s.averageSize-m)**2+(c.averageSize-m)**2+(l.averageSize-m)**2+(u.averageSize-m)**2)/m}catch{return 1/0}}function m(e,t){for(var n=Math.round(t.x);e.get(n,Math.round(t.y));)n--;for(var r=Math.round(t.x);e.get(r,Math.round(t.y));)r++;for(var i=(n+r)/2,a=Math.round(t.y);e.get(Math.round(i),a);)a--;for(var o=Math.round(t.y);e.get(Math.round(i),o);)o++;return{x:i,y:(a+o)/2}}function h(e){for(var t=[],n=[],o=[],l=[],u=function(r){for(var c=0,u=!1,d=[0,0,0,0,0],f=function(t){var o=e.get(t,r);if(o===u)c++;else{d=[d[1],d[2],d[3],d[4],c],c=1,u=o;var f=s(d)/7,p=Math.abs(d[0]-f)<f&&Math.abs(d[1]-f)<f&&Math.abs(d[2]-3*f)<3*f&&Math.abs(d[3]-f)<f&&Math.abs(d[4]-f)<f&&!o,m=s(d.slice(-3))/3,h=Math.abs(d[2]-m)<m&&Math.abs(d[3]-m)<m&&Math.abs(d[4]-m)<m&&o;if(p){var g=t-d[3]-d[4],_=g-d[2],v={startX:_,endX:g,y:r},y=n.filter(function(e){return _>=e.bottom.startX&&_<=e.bottom.endX||g>=e.bottom.startX&&_<=e.bottom.endX||_<=e.bottom.startX&&g>=e.bottom.endX&&d[2]/(e.bottom.endX-e.bottom.startX)<a&&d[2]/(e.bottom.endX-e.bottom.startX)>i});y.length>0?y[0].bottom=v:n.push({top:v,bottom:v})}if(h){var b=t-d[4],x=b-d[3],v={startX:x,y:r,endX:b},y=l.filter(function(e){return x>=e.bottom.startX&&x<=e.bottom.endX||b>=e.bottom.startX&&x<=e.bottom.endX||x<=e.bottom.startX&&b>=e.bottom.endX&&d[2]/(e.bottom.endX-e.bottom.startX)<a&&d[2]/(e.bottom.endX-e.bottom.startX)>i});y.length>0?y[0].bottom=v:l.push({top:v,bottom:v})}}},p=-1;p<=e.width;p++)f(p);t.push.apply(t,n.filter(function(e){return e.bottom.y!==r&&e.bottom.y-e.top.y>=2})),n=n.filter(function(e){return e.bottom.y===r}),o.push.apply(o,l.filter(function(e){return e.bottom.y!==r})),l=l.filter(function(e){return e.bottom.y===r})},d=0;d<=e.height;d++)u(d);t.push.apply(t,n.filter(function(e){return e.bottom.y-e.top.y>=2})),o.push.apply(o,l);var f=t.filter(function(e){return e.bottom.y-e.top.y>=2}).map(function(t){var n=(t.top.startX+t.top.endX+t.bottom.startX+t.bottom.endX)/4,r=(t.top.y+t.bottom.y+1)/2;if(e.get(Math.round(n),Math.round(r))){var i=[t.top.endX-t.top.startX,t.bottom.endX-t.bottom.startX,t.bottom.y-t.top.y+1],a=s(i)/i.length;return{score:p({x:Math.round(n),y:Math.round(r)},[1,1,3,1,1],e),x:n,y:r,size:a}}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score}).map(function(e,t,n){if(t>r)return null;var i=n.filter(function(e,n){return t!==n}).map(function(t){return{x:t.x,y:t.y,score:t.score+(t.size-e.size)**2/e.size,size:t.size}}).sort(function(e,t){return e.score-t.score});if(i.length<2)return null;var a=e.score+i[0].score+i[1].score;return{points:[e].concat(i.slice(0,2)),score:a}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score});if(f.length===0)return null;var h=c(f[0].points[0],f[0].points[1],f[0].points[2]),_=h.topRight,v=h.topLeft,y=h.bottomLeft,b=g(e,o,_,v,y),x=[];b&&x.push({alignmentPattern:{x:b.alignmentPattern.x,y:b.alignmentPattern.y},bottomLeft:{x:y.x,y:y.y},dimension:b.dimension,topLeft:{x:v.x,y:v.y},topRight:{x:_.x,y:_.y}});var S=m(e,_),C=m(e,v),w=m(e,y),T=g(e,o,S,C,w);return T&&x.push({alignmentPattern:{x:T.alignmentPattern.x,y:T.alignmentPattern.y},bottomLeft:{x:w.x,y:w.y},topLeft:{x:C.x,y:C.y},topRight:{x:S.x,y:S.y},dimension:T.dimension}),x.length===0?null:x}t.locate=h;function g(e,t,n,r,i){var a,c,u;try{a=l(r,n,i,e),c=a.dimension,u=a.moduleSize}catch{return null}var d={x:n.x-r.x+i.x,y:n.y-r.y+i.y},f=(o(r,i)+o(r,n))/2/u,m=1-3/f,h={x:r.x+m*(d.x-r.x),y:r.y+m*(d.y-r.y)},g=t.map(function(t){var n=(t.top.startX+t.top.endX+t.bottom.startX+t.bottom.endX)/4,r=(t.top.y+t.bottom.y+1)/2;if(e.get(Math.floor(n),Math.floor(r))){var i=[t.top.endX-t.top.startX,t.bottom.endX-t.bottom.startX,t.bottom.y-t.top.y+1];return s(i)/i.length,{x:n,y:r,score:p({x:Math.floor(n),y:Math.floor(r)},[1,1,1],e)+o({x:n,y:r},h)}}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score});return{alignmentPattern:f>=15&&g.length?g[0]:h,dimension:c}}})]).default})}))(),1);function LW(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function RW(e){let t=e.length%4,n=(e+(t?`=`.repeat(4-t):``)).replace(/-/g,`+`).replace(/_/g,`/`),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}async function zW(e,t){let n=t.writable.getWriter();n.write(e),n.close();let r=t.readable.getReader(),i=[],a=0;for(;;){let{value:e,done:t}=await r.read();if(t)break;e&&(i.push(e),a+=e.length)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return o}async function BW(e){let t=new TextEncoder().encode(e),n=await zW(t,new CompressionStream(`deflate-raw`));return n.length<t.length?`D`+LW(n):`R`+LW(t)}async function VW(e){let t=e.trim();if(!t)throw Error(`empty signal token`);let n=RW(t.slice(1));if(t[0]===`D`)return new TextDecoder().decode(await zW(n,new DecompressionStream(`deflate-raw`)));if(t[0]===`R`)return new TextDecoder().decode(n);throw Error(`unknown signal codec tag: ${t[0]}`)}async function HW(e){return BW(JSON.stringify({k:`offer`,v:2,hub:e.hubInstanceId,name:e.hubName,sdp:e.sdp,sec:e.secret}))}async function UW(e){try{let t=JSON.parse(await VW(e.trim()));return t.k!==`answer`||typeof t.sdp!=`string`?null:{sdp:t.sdp,deviceName:typeof t.dev==`string`?t.dev:`Mobile device`,platform:typeof t.plat==`string`?t.plat:`web`,secret:typeof t.sec==`string`?t.sec:``}}catch{return null}}function WW({open:e,onClose:t,onPaired:n}){let{t:r}=K(`settings`),[i,a]=(0,Q.useState)(`loading`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useCallback)(()=>{f.current!=null&&(cancelAnimationFrame(f.current),f.current=null),d.current?.getTracks().forEach(e=>e.stop()),d.current=null},[]),m=(0,Q.useCallback)(()=>{p(),a(`loading`),s(``),l(null),t()},[t,p]),h=(0,Q.useCallback)(async e=>{let t=await UW(e);if(!t){J.error(r(`pairWeb.notAnswer`));return}p(),a(`connecting`);try{let e=await fetch(`/api/mobile/webrtc/answer`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sdp:t.sdp})}),i=await e.json().catch(()=>({}));if(!e.ok||!i.ok)throw Error(`rejected`);a(`paired`),J.success(r(`pairWeb.pairedToast`)),n();let o=0,s=setInterval(()=>{n(),++o>=3&&(clearInterval(s),m())},1500)}catch{l(r(`pairWeb.answerRejected`)),a(`offer`)}},[r,p,n,m]);(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return l(null),a(`loading`),(async()=>{try{let e=await fetch(`/api/mobile/webrtc/offer`,{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json(),r=await HW({hubInstanceId:n.hubInstanceId,hubName:n.hubName,sdp:n.sdp,secret:n.secret});t||(s(r),a(`offer`))}catch(e){t||(l(e.message),a(`offer`))}})(),()=>{t=!0}},[e]),(0,Q.useEffect)(()=>{if(i!==`scanning`)return;let e=d.current,t=u.current;if(!e||!t)return;t.srcObject=e,t.play().catch(()=>{});let n=document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return;let a=()=>{if(d.current){if(t.videoWidth){n.width=t.videoWidth,n.height=t.videoHeight,r.drawImage(t,0,0);let e=r.getImageData(0,0,n.width,n.height),i=(0,IW.default)(e.data,e.width,e.height);if(i){h(i.data);return}}f.current=requestAnimationFrame(a)}};f.current=requestAnimationFrame(a)},[i,h]),(0,Q.useEffect)(()=>()=>p(),[p]);async function g(){if(l(null),!navigator.mediaDevices?.getUserMedia){J.error(r(`pairWeb.cameraFailed`,{message:`unsupported`}));return}try{d.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),a(`scanning`)}catch(e){J.error(r(`pairWeb.cameraFailed`,{message:e.message})),a(`offer`)}}return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||m()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-md`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:r(`pairWeb.title`)}),(0,$.jsx)(Mn,{children:r(`pairWeb.description`)})]}),c&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:r(`pairWeb.startFailed`,{error:c})}),i===`loading`&&(0,$.jsx)(`div`,{className:`h-56 bg-muted/30 rounded-lg animate-pulse`}),i===`offer`&&o&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,children:[(0,$.jsx)(`div`,{className:`bg-white p-3 rounded-lg`,children:(0,$.jsx)(FW,{value:o,size:220})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:r(`pairWeb.showThenScan`)}),(0,$.jsx)(Z,{onClick:()=>void g(),className:`gap-2`,children:r(`pairWeb.scanAnswer`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent-info underline`,onClick:()=>{navigator.clipboard?.writeText(o),J.success(r(`pairWeb.codeCopied`))},children:r(`pairWeb.copyCode`)})]}),i===`scanning`&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,children:[(0,$.jsx)(`video`,{ref:u,playsInline:!0,className:`w-full max-h-72 rounded-lg bg-black`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:r(`pairWeb.scanning`)}),(0,$.jsx)(Z,{variant:`outline`,onClick:()=>{p(),a(`offer`)},children:r(`pairWeb.cancel`)})]}),i===`connecting`&&(0,$.jsx)(`p`,{className:`py-6 text-center text-muted-foreground`,children:r(`pairWeb.connecting`)}),i===`paired`&&(0,$.jsx)(`p`,{className:`py-6 text-center text-accent-success font-medium`,children:r(`pairWeb.paired`)})]})})}var GW=typeof navigator<`u`&&/Win/i.test(navigator.platform);function KW(e){return!e||e.length<16?e??`—`:`${e.slice(0,8)}…${e.slice(-8)}`}function qW(){let{t:e}=K(`settings`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/mobile/status`);e.ok&&n(await e.json())}catch{}},[]),u=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/mobile/devices`);e.ok&&i((await e.json()).devices)}catch{}},[]);(0,Q.useEffect)(()=>{l(),u()},[l,u]);let{registerHandler:d,unregisterHandler:f}=qe();(0,Q.useEffect)(()=>{let e=`mobile-access-devices`;return d(e,e=>{let t=e?.type;(t===`mobile.device_paired`||t===`mobile.device_revoked`)&&u()}),()=>f(e)},[d,f,u]);async function p(){if(t){o(!0);try{let e=t.enabled?`disable`:`enable`,r=await fetch(`/api/mobile/${e}`,{method:`POST`});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}n(await r.json())}catch(n){J.error(t.enabled?e(`mobile.disableFailed`,{message:n.message}):e(`mobile.enableFailed`,{message:n.message}))}finally{o(!1)}}}async function m(e){await fetch(`/api/mobile/devices/${e}`,{method:`DELETE`}).catch(()=>{}),u()}async function h(){if(window.confirm(e(`mobile.resetConfirm`))){o(!0);try{let t=await fetch(`/api/mobile/cert/rotate`,{method:`POST`});t.ok&&n(await t.json()),u(),J.success(e(`mobile.identityReset`))}finally{o(!1)}}}return t?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2`,children:[(0,$.jsx)(oc,{className:`h-3.5 w-3.5`}),` `,e(`mobile.heading`)]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`mobile.description`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:t.enabled?e(`mobile.accessOn`):e(`mobile.accessOff`)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.running?e(`mobile.listeningOnPort`,{port:t.port}):e(`mobile.notListening`)})]}),(0,$.jsx)(Z,{variant:t.enabled?`outline`:`default`,disabled:a,onClick:p,children:t.enabled?e(`mobile.turnOff`):e(`mobile.turnOn`)})]}),t.enabled&&t.running&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(Z,{onClick:()=>c(!0),className:`gap-2`,children:[(0,$.jsx)(E,{className:`h-4 w-4`}),` `,e(`mobile.pairWebDevice`)]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(ic,{className:`h-3.5 w-3.5 text-accent-success`}),(0,$.jsx)(`span`,{title:t.certFingerprint??``,children:KW(t.certFingerprint)}),(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:h,disabled:a,children:e(`mobile.reset`)})]})]}),GW&&(0,$.jsx)(`p`,{className:`text-xs text-accent-warning`,children:e(`mobile.windowsFirewall`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground`,children:e(`mobile.pairedDevices`)}),r.filter(e=>!e.revoked).length===0?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e(`mobile.noDevices`)}):r.filter(e=>!e.revoked).map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-muted/30 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`text-sm`,children:[t.name,` `,(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,t.platform]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`mobile.revokeDevice`,{name:t.name}),className:`text-muted-foreground hover:text-destructive`,onClick:()=>m(t.id),children:(0,$.jsx)(dn,{className:`h-4 w-4`})})]},t.id))]})]}),(0,$.jsx)(WW,{open:s,onClose:()=>c(!1),onPaired:u})]}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})}var JW=[`claude`,`codex`,`gemini`,`kimi`],YW=[`claude`,`gemini`,`kimi`],XW=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function ZW(e){return`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium transition-all duration-150 disabled:opacity-50 ${e?`border-accent-primary/50 bg-accent-primary/15 text-accent-primary shadow-[0_0_8px_-2px] shadow-accent-primary/30`:`border-border/60 bg-transparent text-muted-foreground/70 hover:border-border hover:text-foreground hover:bg-muted/30`}`}function QW(){let{t:e}=K(`mcp`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)({}),[_,v]=(0,Q.useState)(null),y=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/external-mcp`);if(!e.ok)return;let t=await e.json();t?.settings?.servers&&t?.discovered?.orphanIds&&n(t)}catch{}},[]);(0,Q.useEffect)(()=>{y()},[y]);let b=(0,Q.useCallback)(async r=>{if(!t)return;let a=t;n({...t,settings:{version:1,servers:r}}),i(!0);try{let e=await fetch(`${He}/api/external-mcp`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({servers:r})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`HTTP ${e.status}`)}let t=await e.json();return t?.settings?.servers&&t?.discovered?.orphanIds&&n(t),!0}catch(t){n(a);let r=t.message;return J.error(e([`external.errors.${r}`,`external.updateFailed`])),!1}finally{i(!1)}},[t,e]),x=(0,Q.useMemo)(()=>{if(!t)return[];let{settings:e,discovered:n}=t,r=[],i=new Set(Object.keys(e.servers));for(let[t,i]of Object.entries(e.servers))r.push({id:t,name:i.name,source:i.source,sourceProvider:i.sourceProvider,providers:i.providers,orphan:n.orphanIds.includes(t),stored:!0});for(let e of YW)for(let t of n[e])i.has(t.id)||r.push({id:t.id,name:t.name,source:`discovered`,sourceProvider:e,providers:{},orphan:!1,stored:!1});return r.sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))},[t]),S=(0,Q.useCallback)((e,n)=>{if(!t)return;let r={...t.settings.servers},i=r[e.id],a={...i?.providers??{}};a[n]?delete a[n]:a[n]=!0,e.source===`discovered`&&Object.keys(a).length===0?delete r[e.id]:r[e.id]=i?{...i,providers:a}:{source:`discovered`,sourceProvider:e.sourceProvider,name:e.name,providers:a},b(r)},[t,b]),C=(0,Q.useCallback)(e=>{if(!t)return;let n={...t.settings.servers};delete n[e],b(n)},[t,b]),w=s.trim(),T=w!==``&&(!XW.test(w)||w===`specrails`),D=w!==``&&!T&&`c:${w}`!==_&&!!t?.settings.servers[`c:${w}`],O=w!==``&&!T&&!D&&l.trim()!==``,k=(0,Q.useCallback)(()=>{o(!1),v(null),c(``),u(``),f(``),m([]),g({})},[]),A=(0,Q.useCallback)(()=>{v(null),c(``),u(``),f(``),m([]),g({}),o(!0)},[]),j=(0,Q.useCallback)(e=>{let n=t?.settings.servers[e];!n||n.source!==`custom`||!n.transport||(v(e),c(n.name),u(n.transport.command),f(n.transport.args.join(` `)),m(Object.entries(n.transport.env).map(([e,t])=>({key:e,value:t}))),g({...n.providers}),o(!0))},[t]),M=(0,Q.useCallback)(async()=>{if(!t||!O)return;let e=w,n={};for(let e of p){let t=e.key.trim();t&&(n[t]=e.value)}let r={};for(let[e,t]of Object.entries(h))t&&(r[e]=!0);let i={...t.settings.servers};_&&_!==`c:${e}`&&delete i[_],i[`c:${e}`]={source:`custom`,name:e,providers:r,transport:{command:l.trim(),args:d.trim()?d.trim().split(/\s+/):[],env:n}},await b(i)&&k()},[t,O,w,l,d,p,h,_,b,k]);return t?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,"data-testid":`external-mcp-card`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`text-xs font-semibold text-foreground flex items-center gap-1.5`,children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),` `,e(`external.heading`)]}),(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-[11px]`,disabled:r,onClick:()=>a&&!_?o(!1):A(),"data-testid":`external-mcp-add`,children:[(0,$.jsx)(cn,{className:`h-3 w-3`}),` `,e(`external.addCustom`)]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`external.description`)}),(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] text-accent-warning`,children:[(0,$.jsx)(fn,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),e(`external.warning`)]}),a&&(0,$.jsxs)(`div`,{className:`space-y-2.5 rounded-md border border-border/70 bg-muted/20 p-3`,"data-testid":`external-mcp-form`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-name`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.nameLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-name`,autoFocus:!0,value:s,onChange:e=>c(e.target.value),placeholder:e(`external.form.name`),className:`w-full rounded-md border bg-background px-2 py-1 text-xs transition-colors ${T||D?`border-destructive/60 focus:outline-destructive`:`border-border`}`}),(T||D)&&(0,$.jsx)(`p`,{className:`text-[10px] text-destructive`,"data-testid":`external-mcp-name-hint`,children:e(T?`external.form.nameInvalid`:`external.form.nameTaken`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-command`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.commandLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-command`,value:l,onChange:e=>u(e.target.value),placeholder:e(`external.form.command`),className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-args`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.argsLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-args`,value:d,onChange:e=>f(e.target.value),placeholder:e(`external.form.args`),className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.envLabel`)}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>[...e,{key:``,value:``}]),className:`inline-flex items-center gap-1 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors`,"data-testid":`external-mcp-env-add`,children:[(0,$.jsx)(cn,{className:`h-2.5 w-2.5`}),` `,e(`external.form.addVar`)]})]}),p.map((t,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`input`,{value:t.key,onChange:e=>m(t=>t.map((t,r)=>r===n?{...t,key:e.target.value}:t)),placeholder:e(`external.form.envKey`),"aria-label":`${e(`external.form.envKey`)} ${n+1}`,className:`w-2/5 rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`=`}),(0,$.jsx)(`input`,{value:t.value,onChange:e=>m(t=>t.map((t,r)=>r===n?{...t,value:e.target.value}:t)),placeholder:e(`external.form.envValue`),"aria-label":`${e(`external.form.envValue`)} ${n+1}`,className:`flex-1 rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e=>e.filter((e,t)=>t!==n)),className:`text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`${e(`external.remove`)} ${n+1}`,children:(0,$.jsx)(dn,{className:`h-3 w-3`})})]},n))]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.enableFor`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:JW.map(e=>{let t=h[e]===!0;return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`custom · ${e}`,onClick:()=>g(t=>({...t,[e]:!t[e]})),className:ZW(t),"data-testid":`external-mcp-form-provider-${e}`,children:[t&&(0,$.jsx)(Ht,{className:`h-2.5 w-2.5`,strokeWidth:3}),e]},e)})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-1.5 pt-0.5`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px]`,onClick:k,children:e(`external.form.cancel`)}),(0,$.jsx)(Z,{size:`sm`,className:`h-7 text-[11px]`,disabled:r||!O,onClick:()=>void M(),"data-testid":`external-mcp-form-save`,children:e(`external.form.save`)})]})]}),x.length===0&&t.discovered.codexNative.length===0?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:e(`external.empty`)}):(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[x.map(t=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-border/60 px-2 py-1.5`,"data-testid":`external-mcp-row-${t.id}`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground min-w-0 truncate`,children:t.name}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-1.5 py-px text-[10px] text-muted-foreground`,children:t.source===`custom`?e(`external.sourceCustom`):e(`external.sourceDiscovered`,{provider:t.sourceProvider})}),t.orphan&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-accent-warning/15 px-1.5 py-px text-[10px] text-accent-warning`,"data-testid":`external-mcp-orphan`,children:[(0,$.jsx)(fn,{className:`h-2.5 w-2.5`}),` `,e(`external.orphan`)]}),(0,$.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex items-center gap-1`,children:JW.map(e=>{let n=t.providers[e]===!0;return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":`${t.name} · ${e}`,disabled:r,onClick:()=>S(t,e),className:ZW(n),children:[n&&(0,$.jsx)(Ht,{className:`h-2.5 w-2.5`,strokeWidth:3}),e]},e)})}),t.stored&&t.source===`custom`&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(t.id),disabled:r,className:`text-muted-foreground hover:text-foreground`,"aria-label":e(`external.edit`),"data-testid":`external-mcp-edit-${t.id}`,children:(0,$.jsx)(an,{className:`h-3 w-3`})}),t.stored&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t.id),disabled:r,className:`text-muted-foreground hover:text-destructive`,"aria-label":e(`external.remove`),"data-testid":`external-mcp-remove-${t.id}`,children:(0,$.jsx)(dn,{className:`h-3 w-3`})})]})]},t.id)),t.discovered.codexNative.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border/40 px-2 py-1.5 opacity-70`,"data-testid":`external-mcp-codex-${t}`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground min-w-0 truncate`,children:t}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-1.5 py-px text-[10px] text-muted-foreground`,children:e(`external.codexNative`)})]},`codex:${t}`))]})]}):(0,$.jsx)(`div`,{className:`h-16 bg-muted/30 rounded-lg animate-pulse`,"data-testid":`external-mcp-skeleton`})}async function $W(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 eG(e){return JSON.stringify({mcpServers:{specrails:{command:e.bridgeCommand}}},null,2)}function tG(){let{t:e}=K(`mcp`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/mcp-admin/status`);e.ok&&n(await e.json())}catch{}},[]),u=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/mcp-admin/config`);e.ok&&i(await e.json())}catch{}},[]);(0,Q.useEffect)(()=>{l(),u()},[l,u]);let d=(0,Q.useCallback)(async()=>{if(t){o(!0);try{let e=t.enabled?`disable`:`enable`,n=await fetch(`${He}/api/mcp-admin/${e}`,{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}await l()}catch(n){J.error(t.enabled?e(`enable.disableFailed`,{message:n.message}):e(`enable.enableFailed`,{message:n.message}))}finally{o(!1)}}},[t,l,e]),f=(0,Q.useCallback)(async r=>{if(!t)return;o(!0);let i=!t.tiers[r];try{let e=await fetch(`${He}/api/mcp-admin/tiers`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({[r]:i})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`HTTP ${e.status}`)}let t=await e.json();n(e=>e&&{...e,tiers:t.tiers})}catch(t){J.error(e(`tiers.updateFailed`,{message:t.message}))}finally{o(!1)}},[t,e]),p=(0,Q.useCallback)(async()=>{r&&(await $W(eG(r))?(c(`config`),window.setTimeout(()=>c(e=>e===`config`?null:e),1500)):J.error(e(`config.copyFailed`)))},[r,e]),m=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${He}/api/mcp-admin/token`);if(!t.ok)throw Error(`HTTP ${t.status}`);let{token:n}=await t.json();await $W(n)?(c(`token`),window.setTimeout(()=>c(e=>e===`token`?null:e),1500)):J.error(e(`config.copyFailed`))}catch{J.error(e(`config.copyFailed`))}},[e]),h=(0,Q.useCallback)(async()=>{if(window.confirm(e(`token.regenerateConfirm`))){o(!0);try{let t=await fetch(`${He}/api/mcp-admin/regenerate-token`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}`);await l(),J.success(e(`token.regenerated`))}catch(t){J.error(e(`token.regenerateFailed`,{message:t.message}))}finally{o(!1)}}},[l,e]);if(!t)return(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`});let g=[{key:`write`,label:e(`tiers.write`),help:e(`tiers.writeHelp`)},{key:`aiSpawn`,label:e(`tiers.aiSpawn`),help:e(`tiers.aiSpawnHelp`)},{key:`destructive`,label:e(`tiers.destructive`),help:e(`tiers.destructiveHelp`)}];return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2`,children:[(0,$.jsx)(Us,{className:`h-3.5 w-3.5`}),` `,e(`heading`)]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`explainer.what`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80`,children:e(`explainer.how`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:t.enabled?e(`enable.on`):e(`enable.off`)}),(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[t.running?e(`enable.running`,{count:t.toolCount}):e(`enable.stopped`),t.enabled&&t.activeSessions>0&&(0,$.jsxs)($.Fragment,{children:[` · `,e(`enable.activeSessions`,{count:t.activeSessions})]})]})]}),(0,$.jsx)(Z,{variant:t.enabled?`outline`:`default`,disabled:a,onClick:()=>void d(),children:t.enabled?e(`enable.turnOff`):e(`enable.turnOn`)})]}),t.enabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`tiers.heading`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`explainer.grants`)}),(0,$.jsxs)(`label`,{className:`flex items-start gap-2 opacity-70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!0,className:`mt-0.5`,"aria-label":e(`tiers.read`)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e(`tiers.read`)}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:e(`tiers.readHelp`)})]})]}),g.map(e=>(0,$.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.tiers[e.key],disabled:a,onChange:()=>void f(e.key),className:`mt-0.5`,"aria-label":e.label}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:e.help})]})]},e.key))]}),r&&(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`config.heading`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,"data-testid":`mcp-copy-config`,children:s===`config`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`h-3 w-3 text-accent-success`}),` `,e(`config.configCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`h-3 w-3`}),` `,e(`config.copyConfig`)]})})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`config.description`)}),(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-muted/40 p-2 text-[10px] leading-relaxed text-foreground`,children:eG(r)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`token.heading`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`token.description`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:e(`token.hint`,{hint:t.tokenHint})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,"data-testid":`mcp-copy-token`,children:s===`token`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`h-3 w-3 text-accent-success`}),` `,e(`token.tokenCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`h-3 w-3`}),` `,e(`token.copyToken`)]})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void h(),disabled:a,className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`mcp-regenerate-token`,children:[(0,$.jsx)(Js,{className:`h-3 w-3`}),` `,e(`token.regenerate`)]})]})]})]})]}),(0,$.jsx)(QW,{})]})}var nG=`specrails-os-notifications`,rG={enabled:!0,filter:`all`};function iG(){try{let e=localStorage.getItem(nG);if(!e)return rG;let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:rG.enabled,filter:t.filter===`completed`||t.filter===`failed`?t.filter:rG.filter}}catch{return rG}}function aG(e){localStorage.setItem(nG,JSON.stringify(e))}function oG({setActiveProjectId:e,projectsById:t}={}){let n=v(),r=(0,Q.useRef)(n);(0,Q.useEffect)(()=>{r.current=n},[n]);let i=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{i.current=e},[e]);let a=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{a.current=t},[t]);let o=(0,Q.useRef)(new Map),s=(0,Q.useRef)(new Map),{registerHandler:c,unregisterHandler:l}=qe(),u=(0,Q.useCallback)(e=>{let t=e;if(!t)return;if(t.type===`job.stuck`&&typeof t.jobId==`string`){let e=Array.isArray(t.actions)?t.actions.filter(e=>e===`stop`):[];f(t.jobId,t.projectId??null,t.staleMs??0,e);return}if(t.type===`loop.provider_limit`&&typeof t.runId==`string`){d(t.runId,t.projectId??null,typeof t.provider==`string`?t.provider:``,typeof t.resetsAt==`string`&&t.resetsAt?t.resetsAt:null,typeof t.message==`string`?t.message:``);return}if(t.type!==`queue`||!Array.isArray(t.jobs))return;let n=t.projectId??null;for(let e of t.jobs){let t=o.current.get(e.id),r=e.status;n&&s.current.set(e.id,n),t===`running`&&(r===`completed`||r===`failed`)&&m(e,n),o.current.set(e.id,r)}},[]);function d(e,t,n,r,i){let o=iG();if(!o.enabled||o.filter===`completed`)return;let s=t?a.current?.get(t)??``:``,c=n?n.charAt(0).toUpperCase()+n.slice(1):`AI`,l=r?G.t(`commands:notifications.providerLimitBody`,{provider:c,resetsAt:r}):G.t(`commands:notifications.providerLimitBodyNoReset`,{provider:c}),u=G.t(`commands:notifications.providerLimit`);J.error(u,{id:`provider-limit:${e}`,description:`${s?`[${s}] `:``}${l}${i?` · ${i}`:``}`,duration:6e4}),!(typeof Notification>`u`)&&Notification.permission===`granted`&&(()=>{let t=new Notification(u,{body:s?`[${s}] ${l}`:l,tag:`specrails-provider-limit:${e}`});t.onclick=()=>{window.focus(),t.close()}})()}function f(e,t,n,o=[]){let s=iG();if(!s.enabled||s.filter===`completed`)return;let c=Math.max(1,Math.round(n/6e4)),l=t?a.current?.get(t)??``:``,u=G.t(`commands:notifications.jobStuckBody`,{count:c});if(t&&o.includes(`stop`)&&J.warning(G.t(`commands:notifications.jobStuck`),{id:`job-stuck:${e}`,description:l?`[${l}] ${u}`:u,duration:2e4,action:{label:G.t(`commands:notifications.jobStuckStop`),onClick:()=>{p(t,e)}}}),typeof Notification>`u`)return;function d(){let n=new Notification(G.t(`commands:notifications.jobStuck`),{body:l?`[${l}] ${u}`:u,tag:`specrails-job-stuck:${e}`});n.onclick=()=>{window.focus(),t&&i.current?(i.current(t),setTimeout(()=>{r.current(`/jobs/${e}`)},100)):r.current(`/jobs/${e}`),n.close()}}Notification.permission===`granted`?d():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&d()})}async function p(e,t){try{let n=await fetch(`/api/projects/${e}/jobs/${t}/cancel`,{method:`POST`});if(!n.ok)throw Error(`HTTP ${n.status}`);J.success(G.t(`commands:notifications.jobStuckStopped`),{id:`job-stuck:${t}`})}catch{J.error(G.t(`commands:notifications.jobStuckStopFailed`),{id:`job-stuck:${t}`})}}function m(e,t){if(typeof Notification>`u`||typeof document<`u`&&!document.hidden)return;let n=iG();if(!n.enabled||n.filter===`completed`&&e.status!==`completed`||n.filter===`failed`&&e.status!==`failed`)return;function o(){let n=e.status===`completed`?G.t(`commands:notifications.jobCompleted`):G.t(`commands:notifications.jobFailed`),o=t?a.current?.get(t)??``:``,s=e.command?e.command.slice(0,80):G.t(`commands:notifications.unknownCommand`),c=o?`[${o}] ${s}`:s,l=new Notification(n,{body:c,tag:`specrails-job:${e.id}:${e.status}`}),u=e.id,d=t;l.onclick=()=>{window.focus(),d&&i.current?(i.current(d),setTimeout(()=>{r.current(`/jobs/${u}`)},100)):r.current(`/jobs/${u}`),l.close()}}Notification.permission===`granted`?o():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&o()})}(0,Q.useLayoutEffect)(()=>(c(`os-notifications`,u),()=>l(`os-notifications`)),[u,c,l])}var sG=[{value:`job.completed`,labelKey:`webhooks.eventJobCompleted`},{value:`job.failed`,labelKey:`webhooks.eventJobFailed`},{value:`daily_budget_exceeded`,labelKey:`webhooks.eventDailyBudgetExceeded`}];function cG({project:e,onRemove:t}){let{t:n}=K(`settings`);return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 p-2.5 rounded-md border border-border`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:e.path})]}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,className:`h-6 px-2 text-[10px] text-muted-foreground hover:text-destructive shrink-0`,onClick:()=>t(e.id),children:n(`common:actions.remove`)})]})}var lG=[{id:`appearance`,icon:Fs,labelKey:`desktop.nav.appearance`},{id:`effects`,icon:un,labelKey:`desktop.nav.effects`},{id:`specrailsAgents`,icon:wo,labelKey:`desktop.nav.specrailsAgents`},{id:`code`,icon:Lo,labelKey:`desktop.nav.code`},{id:`terminal`,icon:sc,labelKey:`desktop.nav.terminal`},{id:`updates`,icon:Js,labelKey:`desktop.nav.updates`},{id:`mobile`,icon:oc,labelKey:`desktop.nav.mobile`},{id:`mcp`,icon:So,labelKey:`desktop.nav.mcp`},{id:`projects`,icon:as,labelKey:`desktop.nav.projects`},{id:`advanced`,icon:ac,labelKey:`desktop.nav.advanced`},{id:`webhooks`,icon:hc,labelKey:`desktop.nav.webhooks`},{id:`about`,icon:vs,labelKey:`desktop.nav.about`}];function uG({open:e,onClose:t,onOpenOnboarding:n}){let{t:r}=K(`settings`),{projects:i,removeProject:a}=at(),[o,s]=(0,Q.useState)(`appearance`),c=e=>X(`space-y-5`,o===e?``:`hidden`),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!0),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)([]),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)([`job.completed`,`job.failed`]),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(()=>iG().enabled),[N,P]=(0,Q.useState)(()=>iG().filter);function F(e){M(e),aG({enabled:e,filter:N}),J.success(r(e?`notifications.enabledToast`:`notifications.disabledToast`))}function I(e){P(e),aG({enabled:j,filter:e})}let L=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/webhooks`);if(e.ok){let t=await e.json();S(t.webhooks)}}catch{}},[]);(0,Q.useEffect)(()=>{if(!e)return;f(!0);async function t(){try{let e=await fetch(`/api/settings`);if(e.ok){let t=await e.json();u(t),m(t.costAlertThresholdUsd==null?``:String(t.costAlertThresholdUsd))}}catch{}finally{f(!1)}}t(),L()},[e,L]),(0,Q.useEffect)(()=>{e&&fetch(`/api/budget`).then(e=>e.json()).then(e=>{e.desktopDailyBudgetUsd==null?v(``):v(String(e.desktopDailyBudgetUsd))}).catch(()=>{})},[e]);async function R(){g(!0);try{let e=p.trim()===``?null:parseFloat(p);if(e!==null&&(isNaN(e)||e<=0)){J.error(r(`budget.invalidNumber`));return}(await fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({costAlertThresholdUsd:e})})).ok?J.success(e==null?r(`desktop.costAlertsDisabled`):r(`budget.alertSet`,{amount:e})):J.error(r(`budget.saveThresholdFailed`))}catch{J.error(r(`budget.saveThresholdFailed`))}finally{g(!1)}}async function z(){b(!0);try{let e=_.trim()===``?null:parseFloat(_);if(e!==null&&(isNaN(e)||e<=0)){J.error(r(`budget.invalidNumber`));return}(await fetch(`/api/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({desktopDailyBudgetUsd:e})})).ok?J.success(e==null?r(`desktop.dailyBudgetRemoved`):r(`desktop.dailyBudgetSet`,{amount:e})):J.error(r(`desktop.dailyBudgetSaveFailed`))}catch{J.error(r(`desktop.dailyBudgetSaveFailed`))}finally{b(!1)}}async function B(e){try{await a(e),J.success(r(`desktop.projectRemoved`))}catch(e){J.error(r(`desktop.projectRemoveFailed`),{description:e.message})}}async function ee(){if(!C.trim()){J.error(r(`webhooks.urlRequired`));return}if(D.length===0){J.error(r(`webhooks.selectEvent`));return}A(!0);try{let e=await fetch(`/api/webhooks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:C.trim(),secret:T.trim(),events:D})});if(e.ok)J.success(r(`webhooks.added`)),w(``),E(``),O([`job.completed`,`job.failed`]),await L();else{let t=await e.json();J.error(t.error??r(`webhooks.addFailed`))}}catch{J.error(r(`webhooks.addFailed`))}finally{A(!1)}}async function V(e,t){try{await fetch(`/api/webhooks/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})}),await L()}catch{J.error(r(`webhooks.updateFailed`))}}async function H(e){try{(await fetch(`/api/webhooks/${e}`,{method:`DELETE`})).ok&&(J.success(r(`webhooks.removed`)),await L())}catch{J.error(r(`webhooks.removeFailed`))}}async function te(e){try{(await fetch(`/api/webhooks/${e}/test`,{method:`POST`})).ok&&J.success(r(`webhooks.testPingSent`))}catch{J.error(r(`webhooks.testPingFailed`))}}function ne(e){O(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(nc,{className:`w-4 h-4`}),r(`desktop.title`)]}),(0,$.jsx)(Mn,{children:r(`desktop.description`)})]}),d?(0,$.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,$.jsx)(`div`,{className:`h-16 bg-muted/30 rounded-lg animate-pulse`})]}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,$.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:lG.map(e=>{if(e.id===`mcp`&&!xe)return null;let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:X(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,$.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:r(e.labelKey)})]},e.id)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,$.jsxs)(`div`,{className:c(`appearance`),children:[(0,$.jsx)(xU,{}),(0,$.jsx)(kU,{})]}),(0,$.jsx)(`div`,{className:c(`effects`),children:(0,$.jsx)(yU,{})}),(0,$.jsx)(`div`,{className:c(`specrailsAgents`),children:(0,$.jsx)(PU,{})}),(0,$.jsx)(`div`,{className:c(`code`),children:(0,$.jsx)(AU,{})}),(0,$.jsxs)(`div`,{className:c(`updates`),children:[(0,$.jsx)(cW,{}),(0,$.jsx)(RU,{})]}),(0,$.jsx)(`div`,{className:c(`mobile`),children:(0,$.jsx)(qW,{})}),xe&&(0,$.jsx)(`div`,{className:c(`mcp`),children:(0,$.jsx)(tG,{})}),(0,$.jsx)(`div`,{className:c(`projects`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.registeredProjects`)}),i.length===0?(0,$.jsx)(`div`,{className:`rounded-md border border-dashed border-border p-4 text-center`,children:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`desktop.noProjects`)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:i.map(e=>(0,$.jsx)(cG,{project:e,onRemove:B},e.id))})]})}),(0,$.jsxs)(`div`,{className:c(`advanced`),children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.budgetAlertsHeading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`desktop.dailyBudgetLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.dailyBudgetHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:_,onChange:e=>v(e.target.value),placeholder:r(`desktop.dailyBudgetPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:y,onClick:()=>void z(),children:r(`common:actions.save`)})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`budget.perJobLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.perJobHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:p,onChange:e=>m(e.target.value),placeholder:r(`budget.perJobPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:h,onClick:R,children:r(`common:actions.save`)})]})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`notifications.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`notifications.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:j,onChange:e=>F(e.target.checked),className:`w-3.5 h-3.5`,"data-testid":`notif-toggle`}),(0,$.jsx)(bo,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs`,children:r(`notifications.enableLabel`)})]}),j&&(0,$.jsxs)(`div`,{className:`space-y-1.5 pl-6`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`notifications.notifyOn`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:[{value:`all`,label:r(`notifications.filterAll`)},{value:`completed`,label:r(`notifications.filterCompleted`)},{value:`failed`,label:r(`notifications.filterFailed`)}].map(({value:e,label:t})=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`notif-filter`,checked:N===e,onChange:()=>I(e),className:`w-3 h-3`}),t]},e))})]})]})]})]}),(0,$.jsx)(`div`,{className:c(`webhooks`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`webhooks.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`webhooks.description`,components:{code:(0,$.jsx)(`code`,{className:`font-mono`})}})}),x.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>{let t=(()=>{try{return JSON.parse(e.events)}catch{return[]}})();return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border p-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-mono truncate`,children:e.url}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:t.join(`, `)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{onClick:()=>void V(e.id,!e.enabled),className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${e.enabled?`bg-green-500/10 aurora-light:bg-accent-success/10 text-green-600 aurora-light:text-accent-success dark:text-green-400`:`bg-muted text-muted-foreground`}`,title:e.enabled?r(`webhooks.disable`):r(`webhooks.enable`),children:e.enabled?r(`webhooks.statusOn`):r(`webhooks.statusOff`)}),(0,$.jsx)(`button`,{onClick:()=>void te(e.id),className:`text-muted-foreground hover:text-foreground p-0.5`,title:r(`webhooks.sendTestPing`),children:(0,$.jsx)(hn,{className:`w-3 h-3`})}),(0,$.jsx)(`button`,{onClick:()=>void H(e.id),className:`text-muted-foreground hover:text-destructive p-0.5`,title:r(`common:actions.remove`),children:(0,$.jsx)(dn,{className:`w-3 h-3`})})]})]},e.id)})}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-muted-foreground`,children:r(`webhooks.addHeading`)}),(0,$.jsx)(Qk,{value:C,onChange:e=>w(e.target.value),placeholder:`https://hooks.example.com/...`,className:`h-7 text-xs font-mono`}),(0,$.jsx)(Qk,{value:T,onChange:e=>E(e.target.value),placeholder:r(`webhooks.secretPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:sG.map(({value:e,labelKey:t})=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:D.includes(e),onChange:()=>ne(e),className:`w-3 h-3`}),r(t)]},e))}),(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs w-full`,disabled:k||!C.trim(),onClick:()=>void ee(),children:[(0,$.jsx)(cn,{className:`w-3 h-3 mr-1`}),r(`webhooks.addButton`)]})]})]})]})}),(0,$.jsx)(`div`,{className:c(`about`),children:n&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.onboardingHeading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`desktop.platformTour`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.platformTourDescription`)})]}),(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,onClick:n,"data-testid":`replay-onboarding`,children:[(0,$.jsx)(ds,{className:`w-3 h-3 mr-1`}),r(`desktop.replayTour`)]})]})})]})}),(0,$.jsx)(`div`,{className:c(`terminal`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.terminalPanelHeading`)}),(0,$.jsx)(rU,{mode:`desktop`})]})}),(0,$.jsx)(`div`,{className:c(`about`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.infoHeading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoPort`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:l?.port??4200})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoProjects`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:i.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoDb`)}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:`~/.specrails/desktop.sqlite`})]})]})]})})]})]})]})})}var dG=[{keys:`?`,descriptionKey:`shortcuts.items.showCheatsheet`,category:`general`},{keys:`Esc`,descriptionKey:`shortcuts.items.closeModal`,category:`general`},{keys:`⌘B`,descriptionKey:`shortcuts.items.toggleRightSidebar`,category:`general`},{keys:`⌥⌘B`,descriptionKey:`shortcuts.items.toggleLeftSidebar`,category:`general`},{keys:`⌘J`,descriptionKey:`shortcuts.items.toggleTerminal`,category:`general`},...P?[{keys:`⌘⇧A`,descriptionKey:`shortcuts.items.toggleAgent`,category:`general`}]:[],{keys:V?`⌘1–5`:`⌘1–4`,descriptionKey:V?`shortcuts.items.navigateProjectPageWithAgents`:`shortcuts.items.navigateProjectPage`,category:`general`},{keys:`⌥⌘1–9`,descriptionKey:`shortcuts.items.switchProject`,category:`general`},{keys:`G D`,descriptionKey:`shortcuts.items.goDashboard`,category:`navigation`},{keys:`G J`,descriptionKey:`shortcuts.items.goActivity`,category:`navigation`},{keys:`G A`,descriptionKey:`shortcuts.items.goAnalytics`,category:`navigation`},{keys:`G S`,descriptionKey:`shortcuts.items.goSettings`,category:`navigation`},{keys:`J`,descriptionKey:`shortcuts.items.nextItem`,category:`actions`},{keys:`K`,descriptionKey:`shortcuts.items.prevItem`,category:`actions`}];function fG(e){let t=e.target;if(!t)return!1;let n=t.tagName;return!!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable)}function pG(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`[role="dialog"]`)}function mG(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`.specrails-xterm-container, .xterm`)}function hG({onOpenCheatsheet:e,onListNavigate:t,onToggleLeftSidebar:n,onToggleRightSidebar:r,onSwitchProject:i,onSwitchProjectPage:a,onToggleTerminalPanel:o,onToggleAgentChat:s}){let c=v(),l=p(),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(e);f.current=e;let m=(0,Q.useRef)(t);m.current=t;let h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(r);g.current=r;let _=(0,Q.useRef)(i);_.current=i;let y=(0,Q.useRef)(a);y.current=a;let b=(0,Q.useRef)(o);b.current=o;let x=(0,Q.useRef)(s);x.current=s;let S=(0,Q.useRef)(l);S.current=l,(0,Q.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.code===`KeyJ`){if(pG(e))return;e.preventDefault(),b.current?.();return}if((e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.code===`KeyA`){if(pG(e))return;e.preventDefault(),x.current?.();return}if(fG(e)||mG(e)||pG(e))return;if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.code===`KeyB`){e.preventDefault(),g.current?.();return}if((e.metaKey||e.ctrlKey)&&e.altKey&&e.code===`KeyB`){e.preventDefault(),h.current?.();return}if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey){let t=e.code.match(/^Digit([1-9])$/);if(t){e.preventDefault(),y.current?.(parseInt(t[1],10));return}}if((e.metaKey||e.ctrlKey)&&e.altKey&&!e.shiftKey){let t=e.code.match(/^Digit([1-9])$/);if(t){e.preventDefault(),_.current?.(parseInt(t[1],10));return}}if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.key;if(u.current===`g`){d.current&&clearTimeout(d.current),u.current=null;let n=t.toUpperCase(),r={D:`/`,P:`/`,J:`/activity`,A:`/analytics`,S:`/settings`};if(r[n]){e.preventDefault(),c(r[n]);return}return}if(t===`?`){e.preventDefault(),f.current();return}if(t===`g`){e.preventDefault(),u.current=`g`,d.current=setTimeout(()=>{u.current=null},800);return}if(t===`j`){m.current?.(`down`);return}if(t===`k`){m.current?.(`up`);return}}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),d.current&&clearTimeout(d.current)}},[c])}function gG(){let[e,t]=(0,Q.useState)(!1);return{cheatsheetOpen:e,setCheatsheetOpen:t,openCheatsheet:(0,Q.useCallback)(()=>t(!0),[]),closeCheatsheet:(0,Q.useCallback)(()=>t(!1),[])}}var _G={general:`shortcuts.categories.general`,navigation:`shortcuts.categories.navigation`,actions:`shortcuts.categories.actions`},vG=[`general`,`navigation`,`actions`];function yG({children:e}){return(0,$.jsx)(`kbd`,{className:`inline-flex items-center justify-center min-w-[1.5rem] h-6 px-1.5 rounded border border-border/50 bg-card/80 font-mono text-xs text-foreground`,children:e})}function bG({shortcut:e}){let{t}=K(`commands`),n=jH(e.keys).split(` `);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:t(e.descriptionKey)}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 ml-4 shrink-0`,children:n.map((e,t)=>(0,$.jsx)(yG,{children:e},t))})]})}function xG({open:e,onOpenChange:t}){let{t:n}=K(`commands`),r=vG.map(e=>({category:e,label:n(_G[e]),shortcuts:dG.filter(t=>t.category===e)})).filter(e=>e.shortcuts.length>0);return(0,$.jsx)(Hn,{open:e,onOpenChange:t,children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-md`,"data-testid":`shortcuts-cheatsheet`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:n(`shortcuts.title`)}),(0,$.jsx)(Mn,{children:(0,$.jsxs)(tt,{i18nKey:`shortcuts.subtitle`,ns:`commands`,children:[`Press `,(0,$.jsx)(yG,{children:`?`}),` anywhere to toggle this panel`]})})]}),(0,$.jsx)(`div`,{className:`space-y-4 mt-2`,children:r.map(e=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-accent-primary mb-2`,children:e.label}),(0,$.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.shortcuts.map(e=>(0,$.jsx)(bG,{shortcut:e},e.keys))})]},e.category))})]})})}function SG(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function CG(){return SG()&&/mac/i.test(navigator.platform)}function wG({onClick:e,icon:t,hoverColor:n=`var(--color-accent)`,hoverTextColor:r=`var(--color-accent-foreground)`,ariaLabel:i}){let[a,o]=(0,Q.useState)(!1);return(0,$.jsx)(`button`,{onClick:e,"aria-label":i,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{width:34,height:28,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:7,border:`none`,cursor:`pointer`,background:a?n:`transparent`,color:a?r:`var(--color-muted-foreground)`,transition:`background 0.12s ease, color 0.12s ease`,WebkitAppRegion:`no-drag`},children:t})}function TG({projectName:e,hidden:t=!1}){let{t:n}=K(`nav`),[r,i]=(0,Q.useState)(!1);function a(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,bubbles:!0}))}return(0,$.jsxs)(`button`,{onClick:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"aria-label":n(`titleBar.searchShortcut`),"aria-hidden":t||void 0,tabIndex:t?-1:void 0,style:{position:`absolute`,left:`50%`,top:`50%`,transform:`translate(-50%, -50%) scale(${t?.96:1})`,width:`40%`,maxWidth:360,minWidth:160,height:20,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,paddingLeft:8,paddingRight:8,borderRadius:9999,border:`1px solid color-mix(in srgb, var(--color-border) 70%, transparent)`,cursor:`pointer`,background:r?`color-mix(in srgb, var(--color-accent) 82%, transparent)`:`color-mix(in srgb, var(--color-surface) 72%, transparent)`,color:e?`var(--color-foreground)`:`var(--color-muted-foreground)`,fontSize:12,fontWeight:400,letterSpacing:0,opacity:+!t,pointerEvents:t?`none`:`auto`,transition:`background 0.12s ease, opacity 0.22s ease, transform 0.22s ease`,WebkitAppRegion:`no-drag`,overflow:`hidden`,whiteSpace:`nowrap`},children:[(0,$.jsx)(ln,{size:11,style:{flexShrink:0,opacity:e?.72:.48}}),(0,$.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e??n(`titleBar.searchPlaceholder`)})]})}function EG(){return SG()?CG()?(0,$.jsx)(DG,{}):(0,$.jsx)(OG,{}):null}function DG(){let{projects:e,activeProjectId:t}=at(),{uiMode:n}=Ij();return(0,$.jsx)(`div`,{"data-tauri-drag-region":!0,style:{position:`relative`,height:28,minHeight:28,background:`var(--color-background-deep)`,display:`flex`,alignItems:`center`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--color-border)`},children:(0,$.jsx)(TG,{projectName:(e.find(e=>e.id===t)??null)?.name??null,hidden:n===`agent`})})}function OG(){let{t:e}=K(`nav`),{projects:t,activeProjectId:n}=at(),{uiMode:r}=Ij(),i=t.find(e=>e.id===n)??null,a=(0,Q.useMemo)(()=>xM(),[]),[o,s]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1,t=0,n,r=async()=>{let n=++t;try{let r=await a.isMaximized?.();!e&&n===t&&s(r===!0)}catch{}};return r(),a.onResized?.(()=>{r()}).then(t=>{e?t():n=t}).catch(()=>{}),()=>{e=!0,n?.()}},[a]);let c=(0,Q.useCallback)(()=>{a.minimize()},[a]),l=(0,Q.useCallback)(()=>{a.toggleMaximize()},[a]),u=(0,Q.useCallback)(()=>{a.close()},[a]);return(0,$.jsxs)(`div`,{"data-tauri-drag-region":!0,style:{position:`relative`,height:36,minHeight:36,background:`var(--color-background-deep)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`0 10px`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--color-border)`},children:[(0,$.jsx)(TG,{projectName:i?.name??null,hidden:r===`agent`}),(0,$.jsx)(`div`,{"data-tauri-drag-region":!0,style:{minWidth:116,height:`100%`}}),(0,$.jsxs)(`div`,{style:{minWidth:116,display:`flex`,justifyContent:`flex-end`,gap:2,alignItems:`center`,WebkitAppRegion:`no-drag`},children:[(0,$.jsx)(wG,{onClick:c,icon:(0,$.jsx)(As,{size:14,strokeWidth:1.8}),ariaLabel:e(`titleBar.minimizeWindow`)}),(0,$.jsx)(wG,{onClick:l,icon:o?(0,$.jsx)(Ho,{size:12,strokeWidth:1.8}):(0,$.jsx)(sn,{size:12,strokeWidth:1.8}),ariaLabel:e(o?`titleBar.restoreWindow`:`titleBar.maximizeWindow`)}),(0,$.jsx)(wG,{onClick:u,icon:(0,$.jsx)(mn,{size:15,strokeWidth:1.8}),hoverColor:`var(--color-destructive)`,hoverTextColor:`var(--color-destructive-foreground)`,ariaLabel:e(`titleBar.closeWindow`)})]})]})}var kG=`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン0123456789ABCDEF`,AG=16,jG=AG,MG=AG*1.1,NG=180,PG=340,FG=.07,IG=.22,LG=18,RG=600,zG=48,BG=160,VG=360;function HG(){return kG[Math.floor(Math.random()*61)]??` `}function UG(e){return{head:-Math.random()*Math.max(e,12),speed:FG+Math.random()*(IG-FG),glyphs:Array.from({length:LG},()=>HG()),nextSwapAt:0}}function WG(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=null,s=[],c=0,l=0,u=!document.hidden;function d(){let e=window.devicePixelRatio||1,t=window.innerWidth,n=window.innerHeight;r.width=Math.max(1,Math.floor(t*e)),r.height=Math.max(1,Math.floor(n*e)),r.style.width=`${t}px`,r.style.height=`${n}px`,i.setTransform(e,0,0,e,0,0),i.font=`${AG}px "DM Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace`,i.textBaseline=`top`;let o=Math.ceil(t/jG),s=Math.ceil(n/MG);if(a.length===0)a=Array.from({length:o},()=>UG(s));else if(a.length<o){let e=Array.from({length:o-a.length},()=>UG(s));a=a.concat(e)}else a.length>o&&(a=a.slice(0,o))}function f(e){let t=performance.now();o&&(Math.abs(o.x-e.clientX)>=2||Math.abs(o.y-e.clientY)>=2)&&(s.push({x:o.x,y:o.y,t}),s.length>zG&&s.splice(0,s.length-zG)),o={x:e.clientX,y:e.clientY}}function p(){o=null}function m(){u=!document.hidden,u?(l=0,c=requestAnimationFrame(h)):cancelAnimationFrame(c)}function h(e){if(!u)return;let t=l===0?1:Math.min(2.5,(e-l)/16.67);l=e;let n=performance.now();for(;s.length>0&&n-s[0].t>RG;)s.shift();let r=window.innerWidth,d=window.innerHeight;i.clearRect(0,0,r,d);let f=Math.ceil(d/MG),p=o!==null||s.length>0;for(let r=0;r<a.length;r++){let c=a[r];if(c.head+=c.speed*t,c.head-LG>f+4&&(c.head=-Math.random()*12,c.speed=FG+Math.random()*(IG-FG)),e>c.nextSwapAt&&(c.glyphs[Math.floor(Math.random()*LG)]=HG(),c.nextSwapAt=e+BG+Math.random()*VG),!p)continue;let l=r*jG+jG/2,u=o===null?1/0:Math.abs(l-o.x);for(let e of s){let t=Math.abs(l-e.x);if(t<u&&(u=t),u===0)break}if(!(u>PG))for(let e=0;e<LG;e++){let t=c.head-e;if(t<-1||t>f+2)continue;let a=t*MG,u=0;if(o!==null){let e=l-o.x,t=a-o.y,n=Math.sqrt(e*e+t*t);if(n<=PG){let e=n<NG?1:1-(n-NG)/(PG-NG);e>u&&(u=e)}}if(u<.999)for(let e of s){let t=l-e.x,r=a-e.y,i=Math.sqrt(t*t+r*r);if(i>PG)continue;let o=i<NG?1:1-(i-NG)/(PG-NG),s=n-e.t,c=o*(s>RG?0:1-s/RG);if(c>u&&(u=c),u>=.999)break}if(u<.02)continue;let d=1-e/LG,p=u*d*.85;p<.02||(i.fillStyle=e===0?`hsla(150, 100%, 92%, ${p.toFixed(3)})`:`hsla(144, 100%, 55%, ${p.toFixed(3)})`,i.fillText(c.glyphs[e],r*jG,a))}}c=requestAnimationFrame(h)}return d(),window.addEventListener(`resize`,d),window.addEventListener(`pointermove`,f),document.addEventListener(`mouseleave`,p),document.addEventListener(`visibilitychange`,m),c=requestAnimationFrame(h),()=>{cancelAnimationFrame(c),window.removeEventListener(`resize`,d),window.removeEventListener(`pointermove`,f),document.removeEventListener(`mouseleave`,p),document.removeEventListener(`visibilitychange`,m)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`fixed inset-0 pointer-events-none`,style:{zIndex:-1}})}var GG=24,KG=200,qG=3.5,JG=10,YG=`hsl(210, 60%, 96%)`,XG=`hsl(212, 100%, 62%)`;function ZG(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=0,s=!document.hidden;function c(){let e=window.devicePixelRatio||1,t=window.innerWidth,n=window.innerHeight;r.width=Math.max(1,Math.floor(t*e)),r.height=Math.max(1,Math.floor(n*e)),r.style.width=`${t}px`,r.style.height=`${n}px`,i.setTransform(e,0,0,e,0,0)}function l(e){let t=performance.now();a.push({x:e.clientX,y:e.clientY,t}),a.length>GG&&a.splice(0,a.length-GG)}function u(){a=[]}function d(){s=!document.hidden,s?o=requestAnimationFrame(f):cancelAnimationFrame(o)}function f(){if(!s)return;let e=performance.now();for(;a.length>0&&e-a[0].t>KG;)a.shift();let t=window.innerWidth,n=window.innerHeight;if(i.clearRect(0,0,t,n),a.length>=2){i.lineCap=`round`,i.lineJoin=`round`,i.shadowColor=XG;for(let t=1;t<a.length;t++){let n=a[t-1],r=a[t],o=e-r.t,s=Math.max(0,1-o/KG);if(s<=0)continue;let c=t/a.length;i.globalAlpha=s*(.25+.75*c),i.lineWidth=Math.max(.5,qG*c),i.shadowBlur=JG*c,i.strokeStyle=c>.6?YG:XG,i.beginPath(),i.moveTo(n.x,n.y),i.lineTo(r.x,r.y),i.stroke()}i.globalAlpha=1,i.shadowBlur=0}o=requestAnimationFrame(f)}return c(),window.addEventListener(`resize`,c),window.addEventListener(`pointermove`,l),document.addEventListener(`mouseleave`,u),document.addEventListener(`visibilitychange`,d),o=requestAnimationFrame(f),()=>{cancelAnimationFrame(o),window.removeEventListener(`resize`,c),window.removeEventListener(`pointermove`,l),document.removeEventListener(`mouseleave`,u),document.removeEventListener(`visibilitychange`,d)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`fixed inset-0 pointer-events-none`,style:{zIndex:-1}})}var QG={"code-rain":WG,galaxy:ZG};function $G(){let e=QG[ca().id];return e?(0,$.jsx)(e,{}):null}function eK({project:e}){let{t}=K(`nav`),n=sB(),{registerHandler:r,unregisterHandler:i}=qe(),[a,o]=(0,Q.useState)(null),s=(0,Q.useRef)(e.id);return s.current=e.id,(0,Q.useEffect)(()=>{let n=`cost-alerts-${e.id}`;return r(n,e=>{let n=e;n.projectId!==void 0&&n.projectId!==``&&n.projectId!==s.current||(n.type===`cost_alert`?J.warning(t(`costAlerts.costAlertTitle`),{description:t(`costAlerts.costAlertDescription`,{cost:(n.cost??0).toFixed(4),threshold:(n.threshold??0).toFixed(2)})}):n.type===`daily_budget_exceeded`?(J.error(t(`costAlerts.dailyBudgetTitle`),{description:t(`costAlerts.dailyBudgetDescription`,{spent:(n.dailySpend??0).toFixed(2),budget:(n.budget??0).toFixed(2)}),duration:1/0}),o({dailySpend:n.dailySpend??0,budget:n.budget??0})):n.type===`desktop_daily_budget_exceeded`&&J.error(t(`costAlerts.desktopBudgetTitle`),{description:t(`costAlerts.desktopBudgetDescription`,{spent:(n.desktopDailySpend??0).toFixed(2),budget:(n.desktopBudget??0).toFixed(2)}),duration:1/0}))}),()=>i(n)},[e.id,r,i,t]),(0,$.jsx)(TO,{delayDuration:400,children:(0,$.jsx)(aB.Provider,{value:n,children:(0,$.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[a&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-destructive/10 border-b border-destructive/20 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-destructive font-medium`,children:t(`costAlerts.bannerMessage`,{spent:a.dailySpend.toFixed(2),budget:a.budget.toFixed(2)})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`text-muted-foreground hover:text-foreground ml-4 shrink-0`,children:t(`costAlerts.dismiss`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden min-h-0`,children:[(0,$.jsx)(`main`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(l,{})}),!1]})]})})})}function tK({projectName:e,errorMessage:t,onRetry:n}){let{t:r}=K(`nav`);return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 p-8`,children:[(0,$.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`errorBoundary.title`)}),e&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`nav`,i18nKey:`errorBoundary.occurredIn`,values:{name:e},components:{strong:(0,$.jsx)(`span`,{className:`font-medium`})}})}),t&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60 font-mono`,children:t})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,children:[(0,$.jsx)(Js,{className:`w-3.5 h-3.5`}),r(`common:actions.retry`)]})]})}var nK=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ProjectErrorBoundary]`,e,t.componentStack)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,$.jsx)(tK,{projectName:this.props.projectName,errorMessage:this.state.error?.message??null,onRetry:this.handleRetry}):this.props.children}};function rK({onAddProject:e}){let{t}=K(`setup`);return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full min-h-[400px] gap-6 px-8 text-center`,children:[(0,$.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-muted/50 flex items-center justify-center`,children:(0,$.jsx)(dc,{className:`w-7 h-7 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,$.jsx)(tt,{t,i18nKey:`welcome.title`,components:{spec:(0,$.jsx)(`span`,{className:`text-accent-primary`}),rails:(0,$.jsx)(`span`,{className:`text-accent-secondary`})}})}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-sm`,children:t(`welcome.description`)}),we&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.jiraHint`)}),xe&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.mcpHint`)}),P&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.agentChatHint`)})]}),(0,$.jsxs)(Z,{onClick:e,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(as,{className:`w-3.5 h-3.5`}),t(`welcome.addFirstProject`)]})]})}var iK=`https://specrails.dev/companion-app`,aK=`specrails-desktop:onboarding-dismissed`;function oK(){try{return localStorage.getItem(aK)===`true`}catch{return!1}}function sK(){try{localStorage.setItem(aK,`true`)}catch{}}var cK=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||``),lK=cK?`⌘`:`Ctrl`,uK=cK?`⌥`:`Alt`,dK={primary:{text:`text-accent-primary`,bar:`bg-accent-primary`,glow:`glow-primary`,btn:`bg-accent-primary hover:bg-accent-primary/90 text-primary-foreground`,softBorder:`border-accent-primary/30`,softBg:`bg-accent-primary/5`,chipBg:`bg-accent-primary/10 text-accent-primary`},info:{text:`text-accent-info`,bar:`bg-accent-info`,glow:`glow-info`,btn:`bg-accent-info hover:bg-accent-info/90 text-primary-foreground`,softBorder:`border-accent-info/30`,softBg:`bg-accent-info/5`,chipBg:`bg-accent-info/10 text-accent-info`},success:{text:`text-accent-success`,bar:`bg-accent-success`,glow:`glow-success`,btn:`bg-accent-success hover:bg-accent-success/90 text-primary-foreground`,softBorder:`border-accent-success/30`,softBg:`bg-accent-success/5`,chipBg:`bg-accent-success/10 text-accent-success`},secondary:{text:`text-accent-secondary`,bar:`bg-accent-secondary`,glow:`glow-secondary`,btn:`bg-accent-secondary hover:bg-accent-secondary/90 text-primary-foreground`,softBorder:`border-accent-secondary/30`,softBg:`bg-accent-secondary/5`,chipBg:`bg-accent-secondary/10 text-accent-secondary`},warning:{text:`text-accent-warning`,bar:`bg-accent-warning`,glow:`glow-warning`,btn:`bg-accent-warning hover:bg-accent-warning/90 text-primary-foreground`,softBorder:`border-accent-warning/30`,softBg:`bg-accent-warning/5`,chipBg:`bg-accent-warning/10 text-accent-warning`},highlight:{text:`text-accent-highlight`,bar:`bg-accent-highlight`,glow:`glow-highlight`,btn:`bg-accent-highlight hover:bg-accent-highlight/90 text-primary-foreground`,softBorder:`border-accent-highlight/30`,softBg:`bg-accent-highlight/5`,chipBg:`bg-accent-highlight/10 text-accent-highlight`}};function fK({children:e}){return(0,$.jsx)(`kbd`,{className:`inline-flex items-center justify-center min-w-[1.5rem] h-5 px-1.5 rounded border border-border/60 bg-card/80 font-mono text-[11px] text-foreground shadow-sm`,children:e})}function pK({icon:e,label:t,children:n,accent:r}){return(0,$.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,$.jsx)(`div`,{className:X(`mt-0.5 shrink-0 grid place-items-center w-7 h-7 rounded-md border border-border/40`,r.softBg,r.text),children:e}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground leading-tight`,children:t}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground leading-relaxed`,children:n})]})]})}function mK({accent:e,label:t,children:n}){return(0,$.jsxs)(`div`,{className:X(`rounded-lg border p-3`,e.softBorder,e.softBg),children:[t&&(0,$.jsx)(`p`,{className:X(`text-[10px] font-semibold uppercase tracking-wider mb-1.5`,e.text),children:t}),(0,$.jsx)(`div`,{className:`text-xs text-foreground/90 leading-relaxed`,children:n})]})}function hK({steps:e}){return(0,$.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap text-[13px] font-medium`,children:e.map((t,n)=>(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:t.cls,children:t.label}),n<e.length-1&&(0,$.jsx)(B,{className:`w-3.5 h-3.5 text-muted-foreground`})]},t.label))})}function gK(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e(`onboarding.language.intro`)}),(0,$.jsx)(OU,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.language.note`)})]})}function _K(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e(`onboarding.theme.intro`)}),(0,$.jsx)(bU,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.theme.note`)})]})}function vK({icon:e,url:t,label:n,testId:r}){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border/40 bg-card/40 p-3`,children:[(0,$.jsx)(`div`,{className:`shrink-0 rounded-md bg-white p-1.5`,"aria-hidden":`true`,children:(0,$.jsx)(FW,{value:t,size:72})}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[13px] font-semibold text-foreground leading-tight`,children:[e,n]}),(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,"data-testid":r,"aria-label":n,className:`inline-flex items-center gap-1 text-xs text-accent-info hover:underline break-all`,children:[t.replace(`https://`,``),(0,$.jsx)(Vt,{className:`w-3 h-3 shrink-0`,"aria-hidden":`true`})]})]})]})}function yK(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.companion.intro`,components:{b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,$.jsx)(mK,{accent:dK.success,label:e(`onboarding.companion.localLabel`),children:e(`onboarding.companion.localBody`)}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:e(`onboarding.companion.downloadLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`onboarding.companion.downloadHint`)}),(0,$.jsx)(vK,{icon:(0,$.jsx)(oc,{className:`w-4 h-4 shrink-0`,"aria-hidden":`true`}),url:iK,label:e(`onboarding.companion.open`),testId:`companion-web-link`})]}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Gs,{className:`w-4 h-4`}),label:e(`onboarding.companion.pairLabel`),accent:dK.success,children:e(`onboarding.companion.pairBody`)})]})}function bK(e){let t={b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})};return[{navLabel:e(`onboarding.language.nav`),icon:(0,$.jsx)(bs,{className:`w-6 h-6`}),accent:dK.info,title:e(`onboarding.language.title`),subtitle:e(`onboarding.language.subtitle`),content:(0,$.jsx)(gK,{})},{navLabel:e(`onboarding.theme.nav`),icon:(0,$.jsx)(Fs,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.theme.title`),subtitle:e(`onboarding.theme.subtitle`),content:(0,$.jsx)(_K,{})},{navLabel:e(`onboarding.welcome.nav`),icon:(0,$.jsx)(un,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.welcome.title`),subtitle:e(`onboarding.welcome.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.intro`,components:t})}),(0,$.jsxs)(mK,{accent:dK.primary,label:e(`onboarding.welcome.coreLoopLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.describe`),cls:`text-accent-info`},{label:e(`onboarding.flow.specs`),cls:`text-accent-success`},{label:e(`onboarding.flow.rails`),cls:`text-accent-warning`},{label:e(`onboarding.flow.review`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.flowCaption`,components:t})})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.welcome.missionLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.missionBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Ss,{className:`w-4 h-4`}),label:e(`onboarding.welcome.boardLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.boardBody`,components:t})})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,$.jsx)(ic,{className:`w-4 h-4 mt-0.5 shrink-0 text-accent-success`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.localNote`,components:{...t,i:(0,$.jsx)(`span`,{className:`italic`})}})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.welcome.tourNote`)})]})},...P?[{navLabel:e(`onboarding.mission.nav`),icon:(0,$.jsx)(So,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.mission.title`),subtitle:e(`onboarding.mission.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.mission.missionsLabel`),accent:dK.primary,children:e(`onboarding.mission.missionsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ic,{className:`w-4 h-4`}),label:e(`onboarding.mission.levelsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.levelsBody`,components:{...t,shift:(0,$.jsx)(fK,{children:`Shift`}),tab:(0,$.jsx)(fK,{children:`Tab`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(xs,{className:`w-4 h-4`}),label:e(`onboarding.mission.cardsLabel`),accent:dK.primary,children:e(`onboarding.mission.cardsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Co,{className:`w-4 h-4`}),label:e(`onboarding.mission.workspaceLabel`),accent:dK.primary,children:e(`onboarding.mission.workspaceBody`)})]}),(0,$.jsx)(mK,{accent:dK.primary,label:e(`onboarding.mission.mcpLabel`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.mcpBody`,components:t})})]})}]:[],...ne?[{navLabel:e(`onboarding.builder.nav`),icon:(0,$.jsx)(ps,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.builder.title`),subtitle:e(`onboarding.builder.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.builder.intro`,components:t})}),(0,$.jsxs)(mK,{accent:dK.highlight,label:e(`onboarding.builder.flowLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.blueprint`),cls:`text-accent-info`},{label:e(`onboarding.flow.approve`),cls:`text-accent-success`},{label:e(`onboarding.flow.m1Specs`),cls:`text-accent-warning`},{label:e(`onboarding.flow.milestones`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:e(`onboarding.builder.flowCaption`)})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(mc,{className:`w-4 h-4`}),label:e(`onboarding.builder.cardsLabel`),accent:dK.highlight,children:e(`onboarding.builder.cardsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(es,{className:`w-4 h-4`}),label:e(`onboarding.builder.specsLabel`),accent:dK.highlight,children:e(`onboarding.builder.specsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Xs,{className:`w-4 h-4`}),label:e(`onboarding.builder.milestonesLabel`),accent:dK.highlight,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.builder.milestonesBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ss,{className:`w-4 h-4`}),label:e(`onboarding.builder.progressLabel`),accent:dK.highlight,children:e(`onboarding.builder.progressBody`)})]})]})}]:[],{navLabel:e(`onboarding.authorSpecs.nav`),icon:(0,$.jsx)(x,{className:`w-6 h-6`}),accent:dK.info,title:e(`onboarding.authorSpecs.title`),subtitle:e(`onboarding.authorSpecs.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.authorSpecs.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.agentLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.agentBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.exploreLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.exploreBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(hn,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.quickLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.quickBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(E,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.websiteLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.websiteBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Qs,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.smashLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.smashBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(zt,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.draftsLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.draftsBody`)})]}),we&&(0,$.jsx)(mK,{accent:dK.info,label:e(`onboarding.jira.label`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.jira.body`,components:t})})]})},{navLabel:e(`onboarding.rails.nav`),icon:(0,$.jsx)(gc,{className:`w-6 h-6`}),accent:dK.success,title:e(`onboarding.rails.title`),subtitle:e(`onboarding.rails.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.intro`,components:{...t,play:(0,$.jsx)(`span`,{className:`text-accent-warning font-medium`})}})}),(0,$.jsxs)(mK,{accent:dK.success,label:e(`onboarding.rails.jobLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.architect`),cls:`text-accent-info`},{label:e(`onboarding.flow.developer`),cls:`text-accent-success`},{label:e(`onboarding.flow.reviewer`),cls:`text-accent-warning`},{label:e(`onboarding.flow.yourReview`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:e(`onboarding.rails.flowCaption`)})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(nn,{className:`w-4 h-4`}),label:e(`onboarding.rails.reviewLabel`),accent:dK.success,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.reviewBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Qo,{className:`w-4 h-4`}),label:e(`onboarding.rails.packetLabel`),accent:dK.success,children:e(`onboarding.rails.packetBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.rails.steerLabel`),accent:dK.success,children:e(`onboarding.rails.steerBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Ys,{className:`w-4 h-4`}),label:e(`onboarding.rails.loopsLabel`),accent:dK.success,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.loopsBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.rails.profilesLabel`),accent:dK.success,children:e(`onboarding.rails.profilesBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(as,{className:`w-4 h-4`}),label:e(`onboarding.rails.isolationLabel`),accent:dK.success,children:e(`onboarding.rails.isolationBody`)})]})]})},{navLabel:e(`onboarding.providers.nav`),icon:(0,$.jsx)(So,{className:`w-6 h-6`}),accent:dK.secondary,title:e(`onboarding.providers.title`),subtitle:e(`onboarding.providers.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.providers.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 overflow-hidden text-xs`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[1.4fr_1fr_1fr_1fr_1fr] bg-card/40`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-muted-foreground`,children:e(`onboarding.providers.table.capability`)}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-secondary text-center`,children:`Claude Code`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-success text-center`,children:`Codex CLI`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-info text-center`,children:`Gemini CLI`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-purple-300 text-center`,children:`Kimi Code`})]}),[[e(`onboarding.providers.table.streamingResume`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`)],[e(`onboarding.providers.table.costReporting`),e(`onboarding.providers.table.providerBilled`),e(`onboarding.providers.table.estimated`),e(`onboarding.providers.table.estimated`),e(`onboarding.providers.table.unavailable`)],[e(`onboarding.providers.table.telemetry`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.synthesized`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.synthesized`)],[e(`onboarding.providers.table.agentProfiles`),e(`common:states.yes`),`—`,`—`,e(`common:states.yes`)]].map(e=>(0,$.jsxs)(`div`,{className:`grid grid-cols-[1.4fr_1fr_1fr_1fr_1fr] border-t border-border/30`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 text-foreground/90`,children:e[0]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[1]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[2]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[3]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[4]})]},e[0]))]}),(0,$.jsx)(mK,{accent:dK.secondary,label:e(`onboarding.providers.calloutLabel`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.providers.calloutBody`,components:{...t,mono:(0,$.jsx)(`span`,{className:`font-mono`})}})})]})},{navLabel:e(`onboarding.cost.nav`),icon:(0,$.jsx)(zo,{className:`w-6 h-6`}),accent:dK.warning,title:e(`onboarding.cost.title`),subtitle:e(`onboarding.cost.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.cost.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(ss,{className:`w-4 h-4`}),label:e(`onboarding.cost.analyticsLabel`),accent:dK.warning,children:e(`onboarding.cost.analyticsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(qs,{className:`w-4 h-4`}),label:e(`onboarding.cost.perTicketLabel`),accent:dK.warning,children:e(`onboarding.cost.perTicketBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Jo,{className:`w-4 h-4`}),label:e(`onboarding.cost.honestLabel`),accent:dK.warning,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.cost.honestBody`,components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(pc,{className:`w-4 h-4`}),label:e(`onboarding.cost.budgetsLabel`),accent:dK.warning,children:e(`onboarding.cost.budgetsBody`)})]})]})},{navLabel:e(`onboarding.workspace.nav`),icon:(0,$.jsx)(Co,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.workspace.title`),subtitle:e(`onboarding.workspace.subtitle`),content:(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(dc,{className:`w-4 h-4`}),label:e(`onboarding.workspace.terminalLabel`),accent:dK.highlight,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.workspace.terminalBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),j:(0,$.jsx)(fK,{children:`J`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(es,{className:`w-4 h-4`}),label:e(`onboarding.workspace.codeLabel`),accent:dK.highlight,children:e(`onboarding.workspace.codeBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(E,{className:`w-4 h-4`}),label:e(`onboarding.workspace.browserLabel`),accent:dK.highlight,children:e(`onboarding.workspace.browserBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Us,{className:`w-4 h-4`}),label:e(`onboarding.workspace.integrationsLabel`),accent:dK.highlight,children:e(`onboarding.workspace.integrationsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Fs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.themesLabel`),accent:dK.highlight,children:e(`onboarding.workspace.themesBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(xs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.chatsLabel`),accent:dK.highlight,children:e(`onboarding.workspace.chatsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(U,{className:`w-4 h-4`}),label:e(`onboarding.workspace.compareLabel`),accent:dK.highlight,children:e(`onboarding.workspace.compareBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Xs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.desktopLabel`),accent:dK.highlight,children:e(`onboarding.workspace.desktopBody`)})]})})},{navLabel:e(`onboarding.companion.nav`),icon:(0,$.jsx)(oc,{className:`w-6 h-6`}),accent:dK.success,title:e(`onboarding.companion.title`),subtitle:e(`onboarding.companion.subtitle`),content:(0,$.jsx)(yK,{})},{navLabel:e(`onboarding.moveFast.nav`),icon:(0,$.jsx)(Vo,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.moveFast.title`),subtitle:e(`onboarding.moveFast.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(mK,{accent:dK.primary,label:e(`onboarding.moveFast.paletteLabel`),children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.paletteShortcut`,values:{mod:lK},components:{f:(0,$.jsx)(`span`,{className:`text-foreground`}),m:(0,$.jsx)(`span`,{className:`text-muted-foreground`}),mod:(0,$.jsx)(fK,{children:lK}),k:(0,$.jsx)(fK,{children:`K`})}})}),e(`onboarding.moveFast.paletteBody`)]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-3`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.agentLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.agentBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),shift:(0,$.jsx)(fK,{children:`Shift`}),a:(0,$.jsx)(fK,{children:`A`}),tab:(0,$.jsx)(fK,{children:`Tab`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(dc,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.terminalLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.terminalBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),j:(0,$.jsx)(fK,{children:`J`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ys,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.shortcutsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.shortcutsBody`,components:{q:(0,$.jsx)(fK,{children:`?`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.chatLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.chatBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),bkey:(0,$.jsx)(fK,{children:`B`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(as,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.projectsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.projectsBody`,values:{alt:uK,mod:lK},components:{alt:(0,$.jsx)(fK,{children:uK}),mod:(0,$.jsx)(fK,{children:lK}),bkey:(0,$.jsx)(fK,{children:`B`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Vo,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.pagesLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.pagesBody`,values:{alt:uK,mod:lK},components:{alt:(0,$.jsx)(fK,{children:uK}),mod:(0,$.jsx)(fK,{children:lK}),n:(0,$.jsx)(fK,{children:`1–9`})}})})]}),(0,$.jsx)(mK,{accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.outro`,components:t})})]})}]}function xK({open:e,onClose:t}){let{t:n}=K(`setup`),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),s=(0,Q.useMemo)(()=>bK(n),[n]),c=s[r],l=r===0,u=r===s.length-1,d=(0,Q.useCallback)(()=>{a&&sK(),i(0),t()},[a,t]),f=(0,Q.useCallback)(()=>{sK(),i(0),t()},[t]),p=(0,Q.useCallback)(()=>{u?f():i(e=>e+1)},[u,f]),m=(0,Q.useCallback)(()=>i(e=>Math.max(0,e-1)),[]);return(0,$.jsx)(zn,{open:e,onOpenChange:e=>{e||d()},children:(0,$.jsxs)(kn,{children:[(0,$.jsx)(On,{className:`fixed inset-0 z-50 bg-black/70 backdrop-blur-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),(0,$.jsxs)(Un,{className:`fixed left-[50%] top-[50%] z-50 flex flex-col w-[calc(100vw-2rem)] max-w-5xl h-[min(88vh,820px)] translate-x-[-50%] translate-y-[-50%] overflow-hidden border border-border/30 bg-popover shadow-2xl backdrop-blur-xl sm:rounded-2xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,"data-testid":`onboarding-wizard`,"aria-describedby":`onboarding-description`,children:[(0,$.jsx)(`div`,{className:X(`h-1 w-full shrink-0 transition-all duration-500`,c.accent.bar)}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`nav`,{className:`hidden md:flex w-60 shrink-0 flex-col border-r border-border/30 bg-card/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`px-2 mb-5`,children:[(0,$.jsxs)(`p`,{className:`text-sm font-bold tracking-tight`,children:[(0,$.jsx)(`span`,{className:`text-accent-primary`,children:`spec`}),(0,$.jsx)(`span`,{className:`text-accent-secondary`,children:`rails`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:n(`onboarding.productTour`)})]}),(0,$.jsx)(`ol`,{className:`space-y-0.5 min-h-0 overflow-y-auto`,children:s.map((e,t)=>{let a=t===r,o=t<r;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":n(`onboarding.goToStep`,{step:t+1,label:e.navLabel}),"aria-current":a?`step`:void 0,className:X(`w-full flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors`,a?X(`bg-card/70`,e.accent.text):`text-muted-foreground hover:bg-card/40 hover:text-foreground`),children:[(0,$.jsx)(`span`,{className:X(`grid place-items-center w-5 h-5 shrink-0 rounded-full text-[10px] font-bold border`,a?X(e.accent.bar,`text-primary-foreground border-transparent`):o?`bg-accent-success/15 text-accent-success border-accent-success/30`:`border-border/50 text-muted-foreground`),children:o?(0,$.jsx)(Ht,{className:`w-3 h-3`}):t+1}),(0,$.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.navLabel})]})},e.navLabel)})}),(0,$.jsx)(`div`,{className:`mt-auto px-2.5 pt-4 text-[10px] text-muted-foreground`,children:n(`onboarding.stepCount`,{current:r+1,total:s.length})})]}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 sm:p-7`,children:[(0,$.jsxs)(`div`,{className:X(`flex items-center gap-3.5 mb-5`,c.accent.text),children:[(0,$.jsx)(`div`,{className:X(`grid place-items-center w-12 h-12 shrink-0 rounded-xl border border-border/30 bg-card/40`,c.accent.glow),children:c.icon}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(In,{className:`text-lg font-bold leading-tight text-foreground`,children:c.title}),(0,$.jsx)(`p`,{id:`onboarding-description`,className:`text-xs text-muted-foreground mt-0.5`,children:c.subtitle})]})]}),(0,$.jsx)(`div`,{className:`md:hidden flex items-center gap-1.5 mb-5`,children:s.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":n(`onboarding.stepLabel`,{step:t+1}),"aria-current":t===r?`step`:void 0,className:X(`h-1.5 rounded-full transition-all`,t===r?X(`w-6`,e.accent.bar):`w-1.5 bg-muted-foreground/30`)},e.navLabel))}),(0,$.jsx)(`div`,{className:`min-h-[300px]`,children:c.content})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border/30 px-6 sm:px-7 py-3.5`,children:[(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:l&&(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-2 cursor-pointer group`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`w-3.5 h-3.5 rounded`,"data-testid":`onboarding-dismiss-checkbox`}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground group-hover:text-foreground transition-colors`,children:n(`onboarding.dontShowAgain`)})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:d,className:`text-xs text-muted-foreground`,"data-testid":`onboarding-skip`,children:n(`onboarding.skipTour`)}):(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:m,className:`text-xs`,"data-testid":`onboarding-back`,children:[(0,$.jsx)(Rt,{className:`w-3.5 h-3.5 mr-1`}),n(`common:actions.back`)]}),(0,$.jsxs)(Z,{size:`sm`,onClick:p,className:X(`text-xs`,c.accent.btn),"data-testid":`onboarding-next`,children:[n(u?`onboarding.getStarted`:`common:actions.next`),!u&&(0,$.jsx)(B,{className:`w-3.5 h-3.5 ml-1`})]})]})]})]})]})]})]})})}function SK(){let[e,t]=(0,Q.useState)(new Map),n=(0,Q.useContext)(Ye);return(0,Q.useEffect)(()=>n?(n.registerHandler(`assemble-progress`,e=>{let n=e;if(n.type!==`project.assemble_progress`||typeof n.projectId!=`string`||typeof n.provider!=`string`)return;let{projectId:r,provider:i,status:a}=n;t(e=>{let t=new Map(e),n=t.get(r)?{running:new Set(t.get(r).running),failed:new Set(t.get(r).failed)}:{running:new Set,failed:new Set};return a===`running`?(n.running.add(i),n.failed.delete(i)):a===`done`?(n.running.delete(i),n.failed.delete(i)):a===`failed`&&(n.running.delete(i),n.failed.add(i)),t.set(r,n),t})}),()=>n.unregisterHandler(`assemble-progress`)):void 0,[n]),{statusFor:(0,Q.useCallback)(t=>{let n=e.get(t);return n?n.running.size>0?`assembling`:n.failed.size>0?`failed`:`ready`:`ready`},[e]),retry:(0,Q.useCallback)(async e=>{await fetch(`${He}/api/projects/${e}/assemble-retry`,{method:`POST`})},[])}}var CK=(0,Q.lazy)(()=>c(()=>import(`./ProjectSettingsDialog-Bcsq5o0U.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([84,1,7,42,44,8,12,10,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,53,63,49,64,65]))),wK=`specrails-desktop:agentTreeExpanded`;function TK(){try{let e=localStorage.getItem(wK);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 EK(e){try{localStorage.setItem(wK,JSON.stringify([...e]))}catch{}}function DK(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var OK=`__home__`,kK=`__favorites__`;function AK({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=K(`agent`),u=e.title?.trim()||l(`untitled`),[d,f]=(0,Q.useState)(!1),p=(0,Q.useRef)(null),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(r);(0,Q.useEffect)(()=>{if(g.current&&!r){h(!0);let e=setTimeout(()=>h(!1),900);return g.current=r,()=>clearTimeout(e)}g.current=r},[r]),(0,Q.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,$.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,$.jsx)(x,{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,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`relative text-[11px] truncate flex-1 text-left`,children:[u,(r||m)&&(0,$.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,$.jsx)(`span`,{className:X(`flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/45`,d?`hidden`:`group-hover:hidden`),title:Ob(e.updated_at),children:Db(e.updated_at)}),(0,$.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,$.jsx)(ms,{className:`w-2.5 h-2.5`,fill:a?`currentColor`:`none`})}),(0,$.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,$.jsx)(mn,{className:`w-2.5 h-2.5`})})]})]})}function jK({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,assembleStatus:_=`ready`,onRetryAssemble:v}){let{t:y}=K(`nav`),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);function C(e){e.stopPropagation(),b?(S.current&&clearTimeout(S.current),x(!1),i()):(x(!0),S.current=setTimeout(()=>{x(!1),S.current=null},3e3))}function w(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))}let T=a&&o&&n,E=(0,$.jsx)(as,{className:X(`flex-shrink-0 w-4 h-4`,t&&`text-accent-primary`)});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:w,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:[T?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(`span`,{className:`flex transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:E}),(0,$.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":y(s?`projects.collapse`:`projects.expand`,{name:e.name}),"aria-expanded":s,children:s?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):E,n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:e.name}),_===`assembling`&&(0,$.jsx)(`span`,{className:`flex-shrink-0 h-1.5 w-1.5 rounded-full bg-accent-info animate-pulse`,title:y(`projects.assembling`),"data-testid":`assemble-indicator`,"aria-label":y(`projects.assembling`)}),_===`failed`&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v?.()},className:`flex-shrink-0 h-2 w-2 rounded-full bg-accent-warning hover:ring-2 hover:ring-accent-warning/40 transition-shadow`,title:y(`projects.assembleFailed`),"data-testid":`assemble-retry`,"aria-label":y(`projects.assembleFailed`)}),g&&(0,$.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":y(`projects.settings`,{name:e.name}),title:y(`projects.settings`,{name:e.name}),children:(0,$.jsx)(nc,{className:`w-2.5 h-2.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:C,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`,b?`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":y(b?`projects.confirmRemove`:`projects.remove`,{name:e.name}),children:b?y(`projects.confirmShort`):(0,$.jsx)(mn,{className:`w-2.5 h-2.5`})})]})]}),a&&s&&n&&l.length>0&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:l.map(e=>(0,$.jsx)(AK,{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 MK={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function NK({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a}){let{t:o}=K(`nav`),{t:s}=K(`agent`),{projects:c,activeProjectId:l,setActiveProjectId:u,removeProject:d}=at(),f=SK(),m=v(),h=p(),g=h.pathname.startsWith(`/loops`),_=h.pathname.startsWith(`/plugins`),b=g||_||h.pathname.startsWith(`/docs`),{leftMode:x,cycleLeftMode:S}=eN(),{uiMode:C,toggleUiMode:w}=Ij(),T=lM(),E=C===`agent`,D=(0,Q.useMemo)(()=>{let e=new Map,t=new Set(c.map(e=>e.id));for(let n of T.conversations){if(T.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:OK,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[T.conversations,T.favoriteConversationIds,c]),O=(0,Q.useMemo)(()=>T.conversations.filter(e=>T.favoriteConversationIds.has(e.id)),[T.conversations,T.favoriteConversationIds]),k=D.get(OK)??[],[A,j]=(0,Q.useState)(TK),M=A.has(kK),[N,P]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!E||!l||j(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),EK(t),t})},[E,l]);let F=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),EK(n),n})},I=e=>{T.selectConversation(e),b&&m(`/`)},L=e=>{T.deleteConversation(e).catch(()=>{})},R=e=>{T.toggleFavoriteConversation(e)};function z(e){if(E){u(e),F(e);return}if(e===l){b&&m(`/`);return}u(e)}let[B,ee]=(0,Q.useState)(!1),V=x===`pinned-open`||x===`unpinned`&&B,H=UM(`left-arc`,{side:`left`,defaultWidth:240,min:200,max:460,collapsedWidth:44,expanded:V}),te=x!==`unpinned`,ne=o(MK[x]),re=[{label:o(`arcSidebar.docs`),icon:xo,action:i},{label:o(`arcSidebar.analytics`),icon:Oo,action:r},{label:o(`arcSidebar.settings`),icon:nc,action:a}];async function ie(e){try{await d(e.id)}catch{}}return(0,$.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:()=>{x===`unpinned`&&ee(!0)},onMouseLeave:()=>{x===`unpinned`&&!H.dragging&&ee(!1)},children:[V&&(0,$.jsx)(WM,{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,$.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,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:o(`arcSidebar.desktopTitle`)}),(0,$.jsx)(`button`,{type:`button`,onClick:S,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,te?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":ne,title:o(`sidebarPin.withShortcut`,{label:ne,shortcut:jH(`⌥⌘B`)}),children:(0,$.jsx)(Is,{className:`w-4 h-4`})})]}),y&&(0,$.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[E&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{T.startNewConversation(l),b&&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,$.jsx)(cn,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`newAgent`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:w,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(E?`switchToKanban`:`switchToAgent`),title:s(E?`switchToKanban`:`switchToAgent`),children:[E?(0,$.jsx)(Ss,{className:`w-4 h-4 flex-shrink-0`}):(0,$.jsx)(So,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),V&&(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:s(E?`switchToKanban`:`switchToAgent`)})]}),E&&(0,$.jsxs)(`button`,{type:`button`,onClick:DK,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,$.jsx)(ln,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`search`)})]})]}),ge&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`py-2 px-1.5`,children:[(0,$.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,$.jsx)(gc,{className:X(`w-4 h-4 flex-shrink-0`,g&&`text-accent-primary`)}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.loops`)})]}),(0,$.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,$.jsx)(Ws,{className:X(`w-4 h-4 flex-shrink-0`,_&&`text-accent-primary`)}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.plugins`)})]})]}),(0,$.jsx)(`div`,{className:`border-t border-border`,"aria-hidden":!0})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1.5 space-y-0.5`,children:[E&&O.length>0&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-0.5 border-b border-border/70 pb-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>F(kK),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":M,title:V?void 0:s(`favoriteMissions`),children:[V?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(ms,{className:`h-4 w-4 fill-current text-accent-primary transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,$.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:M?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(ms,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),V&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`favoriteMissions`)})]}),M&&V&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:O.map(e=>(0,$.jsx)(AK,{conversation:e,active:e.id===T.active?.id,streaming:T.streamingConversationIds.has(e.id),unread:T.unreadConversationIds.has(e.id),favorite:!0,expanded:V,onSelect:()=>I(e.id),onToggleFavorite:()=>R(e.id),onDelete:()=>L(e.id)},e.id))})]}),E&&k.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>F(OK),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":A.has(OK),title:V?void 0:s(`home`),children:[V?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(gs,{className:`h-4 w-4 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,$.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:A.has(OK)?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(gs,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`home`)})]}),A.has(OK)&&V&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:k.map(e=>(0,$.jsx)(AK,{conversation:e,active:e.id===T.active?.id,streaming:T.streamingConversationIds.has(e.id),unread:T.unreadConversationIds.has(e.id),expanded:V,onSelect:()=>I(e.id),onToggleFavorite:()=>R(e.id),onDelete:()=>L(e.id)},e.id))})]}),c.map(e=>{let t=D.get(e.id)??[];return(0,$.jsx)(jK,{project:e,isActive:e.id===l&&!b,expanded:V,onSelect:()=>z(e.id),onRemove:()=>ie(e),agentMode:E,hasTree:t.length>0,treeOpen:A.has(e.id),onToggleTree:()=>F(e.id),conversations:t,activeConversationId:T.active?.id??null,streamingConversationIds:T.streamingConversationIds,unreadConversationIds:T.unreadConversationIds,onSelectConversation:I,onToggleConversationFavorite:R,onDeleteConversation:L,assembleStatus:f.statusFor(e.id),onRetryAssemble:()=>{f.retry(e.id)},onOpenProjectSettings:E?()=>{u(e.id),P(!0)}:void 0},e.id)}),(0,$.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,$.jsx)(cn,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`projects.addProject`)})]})]}),(0,$.jsx)(`div`,{className:`border-t border-border py-2 px-1.5 space-y-0.5`,children:re.map(({label:e,icon:t,action:n})=>(0,$.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,$.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:e})]},e))}),N&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(CK,{open:!0,onClose:()=>P(!1)})})]})}var PK={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function FK(){let{t:e}=K(`nav`),{rightMode:t,cycleRightMode:n}=eN(),[r,i]=(0,Q.useState)(!1),a=t===`pinned-open`||t===`unpinned`&&r,o=t!==`unpinned`,s=e(PK[t]),c=[{to:`/`,end:!0,icon:Cs,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:Eo,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:Do,label:e(`rightSidebar.analytics`)},...se?[{to:`/code`,end:!1,icon:Lo,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:nc,label:e(`rightSidebar.settings`)}];return(0,$.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`,a?`w-44`:`w-11`),onMouseEnter:()=>{t===`unpinned`&&i(!0)},onMouseLeave:()=>{t===`unpinned`&&i(!1)},children:[(0,$.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,a?`px-3 justify-between`:`justify-center`),children:[a&&(0,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`rightSidebar.projectTitle`)}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,o?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":s,title:e(`sidebarPin.withShortcut`,{label:s,shortcut:jH(`⌘B`)}),children:(0,$.jsx)(Ls,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,$.jsx)(nN,{expanded:a}),c.map(({to:e,end:t,icon:n,label:r})=>(0,$.jsxs)(h,{to:e,end:t,className:({isActive:e})=>X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,a?`px-2`:`px-0 justify-center`,e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:a?void 0:r,children:[(0,$.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}),a&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:r})]},e))]})]})}function IK(e,t){return e.error===`corrupted-bundle`?t(`setup:prerequisites.corruptedBundle`):e.installed?e.executable===!1?e.resolvedPath&&e.executionError?t(`setup:prerequisites.failedToExecuteAtWithError`,{path:e.resolvedPath,error:e.executionError}):e.resolvedPath?t(`setup:prerequisites.failedToExecuteAt`,{path:e.resolvedPath}):e.executionError?t(`setup:prerequisites.failedToExecuteWithError`,{error:e.executionError}):t(`setup:prerequisites.failedToExecute`):!e.meetsMinimum&&e.minVersion?t(`setup:prerequisites.needsMinimum`,{version:e.version??t(`setup:prerequisites.unknownVersion`),minVersion:e.minVersion}):e.version??t(`setup:prerequisites.installedLabel`):t(`setup:prerequisites.notInstalled`)}function LK({status:e,isLoading:t,error:n,onRefresh:r,onMoreInfo:i}){let{t:a}=K(`setup`);if(t&&!e)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`loading`,className:`rounded-lg border border-border/30 bg-background/30 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-muted-foreground/20 animate-pulse`}),(0,$.jsx)(`div`,{className:`h-3 w-32 rounded bg-muted-foreground/15 animate-pulse`})]})});if(n&&!e)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`error`,className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`prerequisites.verifyError`)})});if(!e)return null;if(e.ok)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`ok`,className:`rounded-lg border border-accent-success/25 bg-accent-success/5 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Mo,{className:`w-4 h-4 text-accent-success flex-shrink-0`}),(0,$.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:a(`prerequisites.allDetected`)})]}),r&&(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:t,className:`h-7 px-2 gap-1.5 text-[11px] flex-shrink-0`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,t&&`animate-spin`)}),a(`common:actions.refresh`)]})]})});let o=e.missingRequired?.length??0,s=o>0&&(e.missingRequired??[]).every(e=>e.error===`corrupted-bundle`),c=(e.missingRequired??[]).some(e=>e.error===`corrupted-bundle`);return(0,$.jsxs)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`missing`,className:X(`rounded-lg border px-3 py-2`,c?`border-destructive/40 bg-destructive/10`:`border-accent-primary/40 bg-accent-primary/10`),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(fn,{className:X(`w-4 h-4 flex-shrink-0`,c?`text-destructive`:`text-accent-primary`)}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:s?a(`prerequisites.bundleCorruptedTitle`):a(`prerequisites.toolsRequired`,{count:o})}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(s?`prerequisites.reinstallHint`:`prerequisites.installMissingHint`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[i&&!s&&(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-7 px-2 gap-1.5 text-[11px]`,"data-testid":`prerequisites-more-info`,children:a(`prerequisites.moreInfo`)}),r&&(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:t,className:`h-7 px-2 gap-1.5 text-[11px]`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,t&&`animate-spin`)}),a(`common:actions.refresh`)]})]})]}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1`,children:e.prerequisites.map(e=>{let t=e.error===`corrupted-bundle`,n=e.bundled===!0&&e.executable===!0&&!t,r=!t&&e.installed&&e.meetsMinimum,i=e.key===`gh`||e.key===`uv`,o=!r&&!t&&i;return(0,$.jsxs)(`li`,{"data-testid":`prereq-row-${e.key}`,"data-ok":r?`true`:`false`,"data-bundled":e.bundled?`true`:void 0,"data-corrupted":t?`true`:void 0,className:X(`flex items-center gap-2 rounded-md border px-2 py-1.5 text-[11px]`,t?`border-destructive/40 bg-destructive/10 text-foreground`:r||o?`border-border/30 bg-background/30 text-muted-foreground`:`border-accent-primary/30 bg-background/50 text-foreground`),children:[t?(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-destructive flex-shrink-0`}):n||r?(0,$.jsx)(Mo,{className:`w-3.5 h-3.5 text-accent-success flex-shrink-0`}):o?(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-accent-primary flex-shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),i&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:a(`prerequisites.optional`)}),e.key===`gh`&&e.executable&&e.authenticated===!1&&(0,$.jsx)(`span`,{"data-testid":`prereq-gh-noauth`,className:`inline-flex items-center rounded px-1 py-0.5 text-[10px] font-medium bg-accent-warning/15 text-accent-warning border border-accent-warning/30`,children:a(`prerequisites.ghNoAuth`)}),n&&(0,$.jsxs)(`span`,{"data-testid":`prereq-bundled-badge-${e.key}`,className:`inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium bg-accent-secondary/20 text-accent-secondary border border-accent-secondary/30`,children:[(0,$.jsx)(Ps,{className:`w-2.5 h-2.5`}),a(`prerequisites.bundledBadge`)]}),(0,$.jsxs)(`span`,{className:X(`text-muted-foreground`,t&&`text-destructive/80`),children:[`— `,IK(e,a)]})]},e.key)})})]})}function RK(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 zK=[`darwin`,`win32`,`linux`];async function BK(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 VK({command:e}){let{t}=K(`setup`),[n,r]=(0,Q.useState)(!1);return(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await BK(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,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function HK({platform:e,primary:t}){let{t:n}=K(`setup`),r=RK(n)[e];return(0,$.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,$.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r.title}),r.intro&&(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r.intro}),(0,$.jsx)(`div`,{className:`mt-2 space-y-2`,children:r.commands.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-border/30 bg-background/60 px-2 py-2`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-1`,children:e.label}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`code`,{className:`text-xs text-foreground font-mono break-all`,children:e.command}),(0,$.jsx)(VK,{command:e.command})]})]},e.command))}),r.links.length>0&&(0,$.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1`,children:r.links.map(e=>(0,$.jsx)(`li`,{children:(0,$.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,$.jsx)(Vt,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function UK(){let{t:e}=K(`setup`),[t,n]=(0,Q.useState)(`idle`);return(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{n(`copying`);try{let e=await fetch(`${He}/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,$.jsx)(Ht,{className:`w-3 h-3 text-accent-success`}):(0,$.jsx)(Fo,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function WK({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=K(`setup`),[o,s]=(0,Q.useState)(!1),c=n?.platform??`darwin`,l=zK.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:a(`instructions.corrupted.title`)}),(0,$.jsx)(Mn,{children:a(`instructions.corrupted.description`)})]}),(0,$.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`instructions.corrupted.body`)}),(0,$.jsx)(`div`,{className:`flex justify-end mt-2`,children:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,"data-testid":`install-corrupted-close-button`,children:a(`common:actions.close`)})})]})}):(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-xl`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:a(`instructions.title`)}),(0,$.jsx)(Mn,{children:a(`instructions.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(HK,{platform:c,primary:!0}),(0,$.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,$.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,$.jsx)(HK,{platform:e,primary:!1},e))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,$.jsx)(UK,{}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:a(`common:actions.close`)}),(0,$.jsxs)(Z,{type:`button`,variant:`default`,size:`sm`,onClick:r,disabled:i,className:`gap-1.5`,"data-testid":`install-recheck-button`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var GK=typeof window<`u`&&`__TAURI_INTERNALS__`in window;function KK({open:e,onClose:t,onOpenBuilder:n}){let r=ne&&!!n,[i,a]=(0,Q.useState)(r?`choose`:`existing`),[o,s]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)({claude:!0}),[_,v]=(0,Q.useState)(!1),{t:y}=K(`setup`),{addProject:b}=at(),{status:x,isLoading:S,error:C,recheck:w}=sA(),T=(0,Q.useMemo)(()=>{if(!x||x.ok)return null;let e=x.missingRequired.map(e=>e.label);return e.length===0?null:y(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[x,y]),E=x!==null&&!x.ok&&!C;(0,Q.useEffect)(()=>{e&&fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n===`tiers`||n===`providerIssues`||n===`launchDescriptors`||typeof r==`boolean`&&(t[n]=r);g(t)}).catch(()=>{})},[e]);async function D(){let e=o.trim();if(!e){J.error(y(`addProject.errors.pathRequired`));return}m(!0);try{let t=d.map(e=>({path:e.trim()})).filter(e=>e.path),n=t.length?await b(e,l.trim()||void 0,void 0,t):await b(e,l.trim()||void 0);if(!n)return;J.success(y(`addProject.toasts.registered`,{name:n.project.name})),O()}catch(e){J.error(y(`addProject.errors.addFailed`),{description:e.message})}finally{m(!1)}}function O(){s(``),u(``),f([]),a(r?`choose`:`existing`),t()}function k(e){e||O()}let A=!Object.values(h).some(Boolean);return i===`choose`?(0,$.jsx)(Hn,{open:e,onOpenChange:k,children:(0,$.jsxs)(Bn,{className:`max-w-md`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(as,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,$.jsx)(Mn,{children:y(`addProject.chooser.description`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 py-2`,children:[(0,$.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,$.jsx)(is,{className:`h-5 w-5 text-accent-info`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.existingTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.existingDescription`)})]}),(0,$.jsxs)(`button`,{type:`button`,"data-testid":`chooser-new`,onClick:()=>{O(),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,$.jsx)(un,{className:`h-5 w-5 text-accent-highlight`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.newTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.newDescription`)})]})]})]})}):(0,$.jsx)(Hn,{open:e,onOpenChange:k,children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-h-[calc(100vh-2rem)] w-[calc(100vw-2rem)] max-w-2xl overflow-x-hidden`,"data-testid":`existing-project-dialog`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(as,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,$.jsx)(Mn,{children:y(`addProject.description`)})]}),A&&(0,$.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:y(`addProject.noProviderDetected`)}),(0,$.jsx)(LK,{status:x,isLoading:S,error:C,onMoreInfo:()=>v(!0),onRefresh:w}),(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.pathLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{placeholder:y(`addProject.pathPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()},autoFocus:!0,className:`flex-1`}),GK&&(0,$.jsx)(Z,{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-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!1,title:y(`addProject.selectProjectFolder`)});typeof t==`string`&&t&&(s(t),l||u(t.split(`/`).filter(Boolean).pop()??``))}catch{}},children:(0,$.jsx)(as,{className:`w-4 h-4`})})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.pathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.nameLabel`),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:y(`addProject.optional`)})]}),(0,$.jsx)(Qk,{placeholder:y(`addProject.namePlaceholder`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()}}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.nameHint`)})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2`,disabled:p,children:[(0,$.jsx)(`legend`,{className:`text-xs font-medium`,children:y(`common:repositories.additional`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:y(`common:repositories.sharedBacklog`)}),d.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{"aria-label":y(`common:repositories.folderNumber`,{number:t+2}),value:e,placeholder:y(`addProject.pathPlaceholder`),onChange:e=>f(n=>n.map((n,r)=>r===t?e.target.value:n))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":y(`common:repositories.removeFolder`),onClick:()=>f(e=>e.filter((e,n)=>n!==t)),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]},t)),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(GK)try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!0});t&&f(e=>[...e,...Array.isArray(t)?t:[t]]);return}catch{}f(e=>[...e,``])},children:[(0,$.jsx)(cn,{className:`mr-1 h-3.5 w-3.5`}),y(`common:repositories.addFolder`)]})]})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,disabled:p,children:y(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,onClick:D,disabled:p||!o.trim()||E||S,title:E?T??void 0:void 0,"data-testid":`add-project-submit`,children:y(p?`addProject.adding`:`addProject.submit`)})]}),(0,$.jsx)(WK,{open:_,onClose:()=>v(!1),status:x,onRecheck:w,isRechecking:S})]})})}var qK=1,JK=.9,YK=.8,XK=.17,ZK=.1,QK=.999,$K=.9999,eq=.99,tq=/[\\\/_+.#"@\[\(\{&]/,nq=/[\\\/_+.#"@\[\(\{&]/g,rq=/[\s-]/,iq=/[\s-]/g;function aq(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?qK:eq;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=aq(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=qK:tq.test(e.charAt(l-1))?(d*=YK,p=e.slice(i,l-1).match(nq),p&&i>0&&(d*=QK**+p.length)):rq.test(e.charAt(l-1))?(d*=JK,m=e.slice(i,l-1).match(iq),m&&i>0&&(d*=QK**+m.length)):(d*=XK,i>0&&(d*=QK**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=$K)),(d<ZK&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=aq(e,t,n,r,l+1,a+2,o),f*ZK>d&&(d=f*ZK)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function oq(e){return e.toLowerCase().replace(iq,` `)}function sq(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,aq(e,t,oq(e),oq(t),0,0,{})}var cq=`[cmdk-group=""]`,lq=`[cmdk-group-items=""]`,uq=`[cmdk-group-heading=""]`,dq=`[cmdk-item=""]`,fq=`${dq}:not([aria-disabled="true"])`,pq=`cmdk-item-select`,mq=`data-value`,hq=(e,t,n)=>sq(e,t,n),gq=Q.createContext(void 0),_q=()=>Q.useContext(gq),vq=Q.createContext(void 0),yq=()=>Q.useContext(vq),bq=Q.createContext(void 0),xq=Q.forwardRef((e,t)=>{let n=Fq(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Fq(()=>new Set),i=Fq(()=>new Map),a=Fq(()=>new Map),o=Fq(()=>new Set),s=Nq(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Cn(),y=Cn(),b=Cn(),x=Q.useRef(null),S=Rq();Pq(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Pq(()=>{S(6,k)},[]);let C=Q.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=Q.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??hq;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(lq);t?t.appendChild(e.parentElement===t?e:e.closest(`${lq} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${lq} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${cq}[${mq}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(mq);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(cq)?.querySelector(uq))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${dq}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(fq)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(mq))}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(mq))}function P(e){let t=A()?.closest(cq),n;for(;t&&!n;)t=e>0?jq(t,cq):Mq(t,cq),n=t?.querySelector(fq);n?C.setState(`value`,n.getAttribute(mq)):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 Q.createElement(_n.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(pq);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Vq},c),Bq(e,e=>Q.createElement(vq.Provider,{value:C},Q.createElement(gq.Provider,{value:w},e))))}),Sq=Q.forwardRef((e,t)=>{let n=Cn(),r=Q.useRef(null),i=Q.useContext(bq),a=_q(),o=Nq(e),s=o.current?.forceMount??i?.forceMount;Pq(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Lq(n,r,[e.value,e.children,r],e.keywords),l=yq(),u=Iq(e=>e.value&&e.value===c.current),d=Iq(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);Q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(pq,f),()=>t.removeEventListener(pq,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 Q.createElement(_n.div,{ref:Pn(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)}),Cq=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Cn(),s=Q.useRef(null),c=Q.useRef(null),l=Cn(),u=_q(),d=Iq(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Pq(()=>u.group(o),[]),Lq(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(_n.div,{ref:Pn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&Q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Bq(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(bq.Provider,{value:f},e))))}),wq=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=Iq(e=>!e.search);return!n&&!a?null:Q.createElement(_n.div,{ref:Pn(i,t),...r,"cmdk-separator":``,role:`separator`})}),Tq=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=yq(),o=Iq(e=>e.search),s=Iq(e=>e.selectedItemId),c=_q();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(_n.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)}})}),Eq=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=Iq(e=>e.selectedItemId),c=_q();return Q.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)}}},[]),Q.createElement(_n.div,{ref:Pn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Bq(e,e=>Q.createElement(`div`,{ref:Pn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Dq=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(zn,{open:n,onOpenChange:r},Q.createElement(kn,{container:o},Q.createElement(On,{"cmdk-overlay":``,className:i}),Q.createElement(Un,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement(xq,{ref:t,...s}))))}),Oq=Q.forwardRef((e,t)=>Iq(e=>e.filtered.count===0)?Q.createElement(_n.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),kq=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(_n.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Bq(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),Aq=Object.assign(xq,{List:Eq,Item:Sq,Input:Tq,Group:Cq,Separator:wq,Dialog:Dq,Empty:Oq,Loading:kq});function jq(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Mq(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Nq(e){let t=Q.useRef(e);return Pq(()=>{t.current=e}),t}var Pq=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Fq(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function Iq(e){let t=yq(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function Lq(e,t,n,r=[]){let i=Q.useRef(),a=_q();return Pq(()=>{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(mq,s),i.current=s}),i}var Rq=()=>{let[e,t]=Q.useState(),n=Fq(()=>new Map);return Pq(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function zq(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Bq({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(zq(t),{ref:t.ref},n(t.props.children)):n(t)}var Vq={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Hq(e){return e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase()}function Uq(e,t,n=[]){let r=Hq(e.trim());return!r||Hq(t).includes(r)?!0:n.some(e=>e&&Hq(e).includes(r))}function Wq(e,t){return Tb(t.updated_at)-Tb(e.updated_at)}function Gq(e,t=8){return[...e].sort(Wq).slice(0,Math.max(0,t)).map(e=>({conversation:e,match:`recent`,messageId:null,snippet:null}))}function Kq(e,t,n,r=20){let i=Hq(t.trim());if(!i)return[];let a=Hq(n);return[...e].sort(Wq).filter(e=>Hq(e.title?.trim()||``).includes(i)||!e.title?.trim()&&a.includes(i)).slice(0,Math.max(0,r)).map(e=>({conversation:e,match:`title`,messageId:null,snippet:null}))}function qq(e,t,n=20){let r=new Map;for(let e of t)r.has(e.conversation.id)||r.set(e.conversation.id,e);let i=[],a=new Set;for(let t of e){let e=r.get(t.conversation.id);i.push(e?{conversation:e.conversation,match:`title`,messageId:e.messageId,snippet:e.snippet}:t),a.add(t.conversation.id)}for(let e of[`title`,`content`])for(let n of t)n.match!==e||a.has(n.conversation.id)||(a.add(n.conversation.id),i.push({conversation:n.conversation,match:n.match,messageId:n.messageId,snippet:n.snippet}));return i.slice(0,Math.max(0,n))}function Jq(e){return e===`agent`?[`missions`,`projects`,`spec`,`jobs`,`navigation`]:[`projects`,`missions`,`spec`,`jobs`,`navigation`]}var Yq=[];function Xq(e){let t=[],n=0;return e.ranges.forEach(([r,i],a)=>{r>n&&t.push(e.text.slice(n,r)),t.push((0,$.jsx)(`mark`,{className:`rounded-sm bg-accent-primary/20 px-0.5 text-foreground`,children:e.text.slice(r,i)},a)),n=i}),n<e.text.length&&t.push(e.text.slice(n)),t}function Zq({onOpenSettings:e,onOpenAnalytics:t,onOpenDocs:n}){let{t:r}=K(`commands`),{t:i}=K(`agent`),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)({query:``,hits:Yq}),{projects:h,activeProjectId:g,setActiveProjectId:_}=at(),{leftMode:y,rightMode:b,cycleLeftMode:x,cycleRightMode:S}=eN(),{uiMode:C}=Ij(),{conversations:w,liveByConversation:T,selectConversation:E,open:D}=lM(),O=r(y===`pinned-open`?`palette.sidebar.collapseLeftKeepPinned`:y===`pinned-collapsed`?`palette.sidebar.unpinLeft`:`palette.sidebar.pinLeftOpen`),k=r(b===`pinned-open`?`palette.sidebar.collapseRightKeepPinned`:b===`pinned-collapsed`?`palette.sidebar.unpinRight`:`palette.sidebar.pinRightOpen`),A=v(),j=(0,Q.useRef)(!1),M=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),o(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,Q.useEffect)(()=>{if(!a){j.current=!1,c(``);return}if(j.current)return;j.current=!0;async function e(){try{let[e,t]=await Promise.all([fetch(`${nt()}/config`),fetch(`${nt()}/jobs?limit=10`)]);if(e.ok){let t=await e.json();u(t.commands)}if(t.ok){let e=await t.json();f(e.jobs)}}catch{}}e()},[a]),(0,Q.useEffect)(()=>{let e=s.trim(),t=++M.current;if(!a||!e)return;let n=new AbortController,r=setTimeout(()=>{za(e,20,n.signal).then(n=>{t===M.current&&m({query:e,hits:n})}).catch(()=>{})},80);return()=>{clearTimeout(r),n.abort()}},[s,a]);let N=i(`mission.untitled`),P=(0,Q.useMemo)(()=>{let e=s.trim();return e?qq(Kq(w,e,N),p.query===e?p.hits:Yq):Gq(w)},[w,s,p,N]),F=(0,Q.useMemo)(()=>new Map(h.map(e=>[e.id,e.name])),[h]),I=(0,Q.useCallback)(e=>{_(e),o(!1)},[_]),L=(0,Q.useCallback)(e=>{o(!1),E(e),C!==`agent`&&D()},[E,D,C]),R=(0,Q.useCallback)(async e=>{o(!1);try{let t=await fetch(`${nt()}/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`));J.success(r(`toasts.queued`,{name:e})),A(`/jobs/${n.jobId}`)}catch(e){J.error(e instanceof Error?e.message:r(`errors.spawnFailed`))}},[A,r]),z=(0,Q.useCallback)(e=>{o(!1),A(`/jobs/${e}`)},[A]),B=(0,Q.useCallback)(e=>{o(!1),A(e)},[A]),ee=(0,Q.useCallback)(e=>{e&&(o(!1),e())},[]),V=`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`,H=h.filter(e=>Uq(s,e.name,[e.slug])),te=l.filter(e=>Uq(s,e.name,[e.slug,e.description??``])),ne=d.filter(e=>Uq(s,`${e.command} ${e.id}`,[e.status])),re=[{key:`dashboard`,label:r(`palette.nav.dashboard`),keywords:[`home`],icon:(0,$.jsx)(Cs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/`)},...t?[{key:`desktopAnalytics`,label:r(`palette.nav.desktopAnalytics`),keywords:[`cross-project`,`desktop`],icon:(0,$.jsx)(ko,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>ee(t)}]:[],{key:`projectAnalytics`,label:r(`palette.nav.projectAnalytics`),keywords:[`metrics`],icon:(0,$.jsx)(Do,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/analytics`)},{key:`activityFeed`,label:r(`palette.nav.activityFeed`),keywords:[`log`],icon:(0,$.jsx)(po,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/activity`)},{key:`desktopSettings`,label:r(`palette.nav.desktopSettings`),keywords:[`configuration`],icon:(0,$.jsx)(nc,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>e?ee(e):B(`/settings`)},{key:`docs`,label:r(`palette.nav.docs`),keywords:[`documentation`],icon:(0,$.jsx)($t,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>n?ee(n):B(`/docs`)},{key:`leftSidebar`,label:O,keywords:[`sidebar`,`panel`,`left`,`pin`,`collapse`,`unpin`,`cycle`],icon:(0,$.jsx)(Is,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>{x(),o(!1)}},{key:`rightSidebar`,label:k,keywords:[`sidebar`,`panel`,`right`,`nav`,`pin`,`collapse`,`unpin`,`cycle`],icon:(0,$.jsx)(Ls,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>{S(),o(!1)}}].filter(e=>Uq(s,e.label,e.keywords)),ie={missions:P.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.missions`),"data-testid":`palette-group-missions`,children:P.map(e=>{let{conversation:t}=e,n=T.get(t.id)?.isStreaming===!0,a=t.pinned_project_id?F.get(t.pinned_project_id)??null:null;return(0,$.jsxs)(Aq.Item,{value:`mission:${t.id}`,onSelect:()=>L(t.id),className:X(V,`items-start`),"data-testid":`palette-mission-${t.id}`,children:[(0,$.jsx)(Yt,{className:`w-4 h-4 mt-0.5 text-accent-primary shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:t.title?.trim()||N}),n&&(0,$.jsxs)(`span`,{"aria-label":i(`mission.working`),"data-testid":`palette-mission-live-${t.id}`,className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] tabular-nums text-muted-foreground/60`,title:Ob(t.updated_at),children:Db(t.updated_at)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 text-[11px] text-muted-foreground/60`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:a??r(`palette.missions.home`)}),e.snippet&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsx)(`span`,{className:`truncate`,"data-testid":`palette-mission-snippet-${t.id}`,children:Xq(e.snippet)})]})]})]})]},t.id)})},`missions`),projects:H.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.projects`),"data-testid":`palette-group-projects`,children:H.map(e=>(0,$.jsxs)(Aq.Item,{value:e.name,keywords:[e.slug],onSelect:()=>I(e.id),className:X(V,e.id===g&&`text-accent-primary`),children:[(0,$.jsx)(as,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),e.id===g&&(0,$.jsx)(`span`,{className:`text-[10px] text-accent-primary font-medium`,children:r(`palette.activeBadge`)})]},e.id))},`projects`),spec:te.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.spec`),children:te.map(e=>(0,$.jsxs)(Aq.Item,{value:e.name,keywords:[e.slug,e.description??``],onSelect:()=>R(e.slug),className:V,children:[(0,$.jsx)(hn,{className:`w-4 h-4 text-accent-info shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.description&&(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60 ml-2 truncate`,children:e.description})]})]},e.id))},`spec`),jobs:ne.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.jobs`),children:ne.map(e=>(0,$.jsxs)(Aq.Item,{value:`${e.command} ${e.id}`,keywords:[e.status],onSelect:()=>z(e.id),className:V,children:[(0,$.jsx)(Eo,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.command}),(0,$.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))},`jobs`),navigation:re.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.navigation`),children:re.map(e=>(0,$.jsxs)(Aq.Item,{value:e.label,keywords:e.keywords,onSelect:e.onSelect,className:V,children:[e.icon,(0,$.jsx)(`span`,{children:e.label})]},e.key))},`navigation`)};return(0,$.jsxs)(Aq.Dialog,{open:a,onOpenChange:o,shouldFilter:!1,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,$.jsx)(`span`,{className:`sr-only`,children:r(`palette.label`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border/30`,children:[(0,$.jsx)(ln,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(Aq.Input,{value:s,onValueChange:c,placeholder:r(C===`agent`?`palette.searchPlaceholderAgent`:`palette.searchPlaceholder`),className:`flex-1 h-11 bg-transparent text-sm outline-none placeholder:text-muted-foreground/50`}),(0,$.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,$.jsxs)(Aq.List,{className:`max-h-80 overflow-y-auto p-2`,children:[(0,$.jsx)(Aq.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`palette.noResults`)}),Jq(C).map(e=>ie[e])]}),(0,$.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,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`↑↓`}),` `,r(`palette.footer.navigate`)]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`↵`}),` `,r(`palette.footer.select`)]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`esc`}),` `,r(`palette.footer.close`)]})]})})]})}var Qq=`
|
|
70
|
+
`);J.warning(n(`railPr.cleanupIncomplete`,{count:e.cleanupWarnings.length}),{description:`${n(`railPr.cleanupIncompleteHint`)}\n${t}`,duration:1/0,action:{label:n(`railPr.copyCleanupDetails`),onClick:()=>{navigator.clipboard?.writeText(t)}}})}else e.decision===`merged`?J.success(n(`railPr.mergedToast`)):e.decision===`discarded`?J.info(n(`railPr.discardedToast`)):e.decision===`completed`&&J.success(n(`railPr.completedToast`))}}else e.supersedesDeliveryId&&(m.current.add(e.supersedesDeliveryId),h.current.set(e.supersedesDeliveryId,e.prDeliveryId)),p&&a&&m.current.add(a.prDeliveryId);let v=new Map(r);return o?v.delete(e.railIndex):v.set(e.railIndex,e),f.current.set(e.railIndex,(f.current.get(e.railIndex)??0)+1),d.current=v,i(v),`accepted`},[n]),y=(0,Q.useCallback)(async(e,t)=>{let n=++p.current,r=new Map(f.current);try{let t=await fetch(`/api/projects/${e}/rails`);if(!t.ok)return;let a=await t.json();if(n!==p.current||u.current!==e)return;let o=new Map;for(let[e,t]of Object.entries(a.prDeliveries??{})){let n=hH(t,Number(e)),r=d.current.get(n?.railIndex??Number(e)),i=n?.restoredFromDeliveryId??null,a=n?h.current.get(n.prDeliveryId):void 0,s=n&&r?.supersedesDeliveryId===n.prDeliveryId?r.prDeliveryId:null,c=!!(n&&i&&_.current.get(n.prDeliveryId)!==i&&(!a||a===i)&&(!s||s===i));n&&!gH.has(n.decision)&&(c||!g.current.has(n.prDeliveryId)&&!m.current.has(n.prDeliveryId))&&o.set(Number(e),n)}let s=d.current,c=new Map(o);for(let[e,t]of f.current){if(t===(r.get(e)??0))continue;let n=s.get(e);n?c.set(e,n):c.delete(e)}for(let e of c.values()){e.supersedesDeliveryId&&(m.current.add(e.supersedesDeliveryId),h.current.set(e.supersedesDeliveryId,e.prDeliveryId));let t=e.restoredFromDeliveryId;t&&_.current.get(e.prDeliveryId)!==t&&(!h.current.get(e.prDeliveryId)||h.current.get(e.prDeliveryId)===t)&&(g.current.delete(e.prDeliveryId),m.current.delete(e.prDeliveryId),g.current.add(t),_.current.set(e.prDeliveryId,t),h.current.set(e.prDeliveryId,t))}d.current=c,i(c)}catch{}finally{t&&n===p.current&&u.current===e&&o(!0)}},[]);(0,Q.useEffect)(()=>{u.current=e,p.current++;let t=new Map;if(d.current=t,i(t),o(!1),f.current=new Map,m.current=new Set,h.current=new Map,g.current=new Set,_.current=new Map,!e){o(!0);return}y(e,!0)},[e,y]);let b=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`rail.pr_state`||t.projectId!==u.current||typeof t.railIndex!=`number`||typeof t.prDeliveryId!=`string`||!t.decision)return;let n=ut(t,t.railIndex);n&&v(n)},[v]);(0,Q.useLayoutEffect)(()=>(s(`rail-pr-decision`,b),()=>c(`rail-pr-decision`)),[b,s,c]),(0,Q.useEffect)(()=>{let e=()=>{let e=u.current;e&&y(e,!1)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]);let x=(0,Q.useRef)(l);(0,Q.useEffect)(()=>{let e=x.current;x.current=l;let t=u.current;t&&l===`connected`&&e!==`connected`&&y(t,!1)},[l,y]);let S=(0,Q.useCallback)(async(e,t,n,r,i)=>{let a=d.current.get(e),o=u.current;if(!a||!o)return{status:0,ok:!1,error:`no_delivery`};if(a.prDeliveryId!==r)return{status:409,ok:!1,error:`stale_decision`,current:a.decision,snapshotApplication:`stale`};try{let e=await fetch(`/api/projects/${o}/rails/pr-decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:a.prDeliveryId,action:t,expectedDecision:n,...i?{repositoryId:i}:{}})}),r=await e.json().catch(()=>({})),s=ut(r.snapshot),c;return s&&u.current===o&&(c=v(s)),{...r,snapshot:s,snapshotApplication:c,busy:e.status===409&&r.error===`operation_in_progress`,operation:s?.operation??(typeof r.operation==`string`&&_H.has(r.operation)?r.operation:null),status:e.status,ok:e.ok&&r.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[v]),C=(0,Q.useCallback)(async(e,t,n)=>{let r=d.current.get(e),i=u.current;if(!r||!i)return{status:0,ok:!1,error:`no_delivery`};if(r.prDeliveryId!==t)return{status:409,ok:!1,error:`stale_decision`,detail:`The delivery generation changed before checkout.`};try{let e=await fetch(`/api/projects/${i}/rails/pr-checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prDeliveryId:r.prDeliveryId,...n?{repositoryId:n}:{}})}),t=await e.json().catch(()=>({}));return{...t,status:e.status,ok:e.ok&&t.ok===!0}}catch(e){return{status:0,ok:!1,error:`network`,detail:e.message}}},[]),w=(0,Q.useMemo)(()=>({decisions:r,hydrated:a,act:S,checkout:C}),[r,a,S,C]);return(0,$.jsx)(pH.Provider,{value:w,children:t})}function bH(e){return e?`specrails-desktop:dashboard-split:${e}`:null}function xH(e){let t=bH(e);if(!t)return null;try{let e=localStorage.getItem(t);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function SH(e,t){let n=bH(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function CH(e,t){let n=Math.max(320,t-280);return Math.min(Math.max(e,320),n)}var wH=.7;function TH(e){return CH(Math.round(e*wH),e)}function EH(e,t){let n=TH(t);return Math.abs(e-n)<=48?n:e}function DH(e,t){let[n,r]=(0,Q.useState)(()=>typeof window<`u`?window.innerWidth:1200),i=(0,Q.useRef)(n),[a,o]=(0,Q.useState)(()=>{if(typeof window>`u`)return null;let e=window.innerWidth;return e<900?null:TH(e)}),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(typeof window>`u`)return;let e=t?.current?.clientWidth||window.innerWidth;if(r(e),i.current=e,e<900){o(null);return}o(TH(e))},[e,t]),(0,Q.useEffect)(()=>{function n(t){if(r(t),t<900){i.current=t,o(null);return}let n=t-i.current;i.current=t,o(r=>{let i=r??xH(e)??TH(t),a=CH(r!==null&&Number.isFinite(n)?i+n:i,t);return a!==r&&SH(e,a),a})}let a=t?.current;if(a&&typeof ResizeObserver<`u`){let e=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&n(t)});return e.observe(a),n(a.clientWidth||window.innerWidth),()=>e.disconnect()}function s(){n(window.innerWidth)}return window.addEventListener(`resize`,s),()=>window.removeEventListener(`resize`,s)},[e,t]);let u=(0,Q.useCallback)(()=>{if(c.current=null,l.current===null)return;let e=CH(l.current,n);l.current=null,o(e)},[n]),d=(0,Q.useCallback)(e=>{if(!s.current)return;let t=e.clientX-s.current.startClientX;l.current=s.current.startLeftWidth+t,c.current===null&&(c.current=requestAnimationFrame(u))},[u]),f=(0,Q.useCallback)(t=>{if(!s.current)return;let{pointerId:r,element:i}=s.current;try{i.releasePointerCapture(r)}catch{}s.current=null,window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),o(t=>{if(t===null)return t;let r=CH(EH(t,n),n);return SH(e,r),r})},[d,e,n]),p=(0,Q.useCallback)(e=>{let t=e.nativeEvent??e,n=e.currentTarget??t.target;try{n.setPointerCapture(t.pointerId)}catch{}s.current={pointerId:t.pointerId,element:n,startClientX:t.clientX,startLeftWidth:a??0},window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},[d,f,a]),m=(0,Q.useCallback)(()=>{if(typeof window>`u`)return;let n=t?.current?.clientWidth||window.innerWidth;if(n<900)return;let r=TH(n);o(r),SH(e,r)},[e,t]);return{leftWidth:a,enabled:a!==null&&n>=900,beginDrag:p,resetToDefault:m}}function OH({leftWidth:e,onPointerDown:t,onReset:n,viewport:r}){let i=(0,Q.useCallback)(t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`&&(t.preventDefault(),e-n)},[e]);return(0,$.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":e,"aria-valuemin":320,"aria-valuemax":Math.max(320,r-280),tabIndex:0,onPointerDown:t,onDoubleClick:n,onKeyDown:i,className:`relative w-1.5 shrink-0 cursor-col-resize group select-none touch-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-info/60`,"data-testid":`dashboard-splitter`,children:[(0,$.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border/40 group-hover:bg-accent-info/40 group-focus-visible:bg-accent-info/60 transition-colors`}),(0,$.jsxs)(`div`,{className:`absolute inset-y-0 left-1/2 -translate-x-1/2 flex flex-col items-center justify-center gap-1 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`}),(0,$.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-accent-info/60`})]})]})}function kH({open:e,allLabels:t,onClose:n,onCreate:r}){let{t:i}=K(`tickets`),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(`todo`),[d,f]=(0,Q.useState)(`medium`),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e&&setTimeout(()=>x.current?.focus(),100)},[e]),(0,Q.useEffect)(()=>{e||(o(``),c(``),u(`todo`),f(`medium`),m([]),g(void 0),v(``))},[e]);let C=(0,Q.useMemo)(()=>{if(!_.trim())return[];let e=_.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!p.includes(t)).slice(0,5)},[_,t,p]),w=(0,Q.useCallback)(e=>{let t=e.trim();t&&!p.includes(t)&&m(e=>[...e,t]),v(``)},[p]),T=(0,Q.useCallback)(async()=>{if(!a.trim())return;b(!0);let e=await r({title:a.trim(),description:s.trim()||void 0,status:l,priority:d,labels:p.length>0?p:void 0,...h?{repositoryIds:h}:{}});b(!1),e?(J.success(i(`createModal.toast.created`)),n()):J.error(i(`createModal.toast.createFailed`))},[a,s,l,d,p,h,r,n,i]);return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>!e&&n(),children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-lg glass-card`,children:[(0,$.jsx)(Rn,{children:(0,$.jsx)(Fn,{children:i(`createModal.title`)})}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:[i(`fields.title`),` `,(0,$.jsx)(`span`,{className:`text-red-400 aurora-light:text-destructive`,children:`*`})]}),(0,$.jsx)(`input`,{ref:x,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a.trim()&&T()},placeholder:i(`createModal.titlePlaceholder`),className:`w-full h-8 rounded border border-border bg-input px-3 text-xs text-foreground placeholder:text-muted-foreground`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.description`)}),(0,$.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:4,placeholder:i(`fields.markdownPlaceholder`),className:`w-full rounded border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-y min-h-[80px]`}),(0,$.jsx)(`span`,{className:`text-[9px] text-muted-foreground mt-0.5 block`,children:i(`fields.supportsMarkdown`)})]}),(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.status`)}),(0,$.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:[(0,$.jsx)(`option`,{value:`todo`,children:i(`ticketStatus.todo`)}),(0,$.jsx)(`option`,{value:`in_progress`,children:i(`ticketStatus.inProgress`)}),(0,$.jsx)(`option`,{value:`done`,children:i(`ticketStatus.done`)}),(0,$.jsx)(`option`,{value:`cancelled`,children:i(`ticketStatus.cancelled`)})]})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.priority`)}),(0,$.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:[(0,$.jsx)(`option`,{value:`critical`,children:i(`priority.critical`)}),(0,$.jsx)(`option`,{value:`high`,children:i(`priority.high`)}),(0,$.jsx)(`option`,{value:`medium`,children:i(`priority.medium`)}),(0,$.jsx)(`option`,{value:`low`,children:i(`priority.low`)})]})]})]}),(0,$.jsx)(tr,{value:h,onChange:g,disabled:y}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1`,children:i(`fields.labels`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:p.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium bg-accent/60 text-foreground/70`,children:[e,(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(t=>t.filter(t=>t!==e)),className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,$.jsx)(en,{className:`w-2.5 h-2.5`})})]},e))}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{ref:S,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_.trim()&&(e.preventDefault(),w(_))},placeholder:i(`createModal.labelsPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),C.length>0&&(0,$.jsx)(`div`,{className:`absolute left-0 right-0 top-full mt-0.5 rounded border border-border/50 bg-popover shadow-lg z-10 py-0.5`,children:C.map(e=>(0,$.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),w(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]})]})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:n,children:i(`common:actions.cancel`)}),(0,$.jsxs)(Z,{size:`sm`,onClick:T,disabled:y||!a.trim(),children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5 mr-1`}),i(y?`createModal.creating`:`createModal.create`)]})]})]})})}function AH({open:e,railLabel:t,specCount:n,provider:r=`claude`,model:i,onConfirm:a,onCancel:o}){let{t:s}=K(`dashboard`),c=(0,Q.useRef)(null),l=ur(r);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),a())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,a]),(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30`,children:(0,$.jsx)(un,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:s(`freestyleDialog.title`)}),(0,$.jsxs)(Mn,{children:[s(`freestyleDialog.context`,{rail:t,count:n}),i?` · ${i}`:``]})]})]})}),(0,$.jsxs)(`ul`,{className:`space-y-2.5 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.noPipelineTitle`)}),` `,s(`freestyleDialog.noPipelineBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(So,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.autonomyTitle`,{provider:l})}),` `,s(`freestyleDialog.autonomyBody`,{provider:l})]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(Jo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s(`freestyleDialog.costTitle`)}),` `,s(`freestyleDialog.costBody`,{provider:l})]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:o,children:s(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:c,className:`h-9 gap-2 bg-emerald-500 text-white hover:bg-emerald-400 focus-visible:ring-emerald-400`,onClick:a,children:[s(`freestyleDialog.continue`),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:`⌘↵`})]})]})]})})}function jH(e,t=typeof navigator>`u`?``:navigator.platform){return/Mac|iPhone|iPad/i.test(t)?e:e.replace(/⌥/g,`Alt+`).replace(/⌘/g,`Ctrl+`).replace(/⇧/g,`Shift+`).replace(/[⏎↵]/g,`Enter`)}function MH({open:e,railCount:t,specCount:n,onConfirm:r,onCancel:i}){let{t:a}=K(`dashboard`),o=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),r())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),o.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-primary/15 text-accent-primary ring-1 ring-accent-primary/30`,children:(0,$.jsx)(Xs,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:a(`launchAllDialog.title`)}),(0,$.jsxs)(Mn,{children:[a(`launchAllDialog.railsCount`,{count:t}),` · `,a(`launchAllDialog.specsCount`,{count:n})]})]})]})}),(0,$.jsxs)(`ul`,{className:`space-y-2.5 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.isolationTitle`)}),` `,a(`launchAllDialog.isolationBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(xs,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-secondary`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.pipelinesTitle`,{count:t})}),` `,a(`launchAllDialog.pipelinesBody`)]})]}),(0,$.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,$.jsx)(Jo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:a(`launchAllDialog.costTitle`)}),` `,a(`launchAllDialog.costBody`)]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:i,children:a(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:o,className:`h-9 gap-2 bg-emerald-500 text-white hover:bg-emerald-400 focus-visible:ring-emerald-400`,onClick:r,children:[a(`launchAllDialog.launch`,{count:t}),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:jH(`⌘↵`)})]})]})]})})}function NH({open:e,target:t,onConfirm:n,onCancel:r}){let{t:i}=K(`dashboard`),a=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!e)return;function t(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),n())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n]),t?(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||r()},children:(0,$.jsxs)(Bn,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),a.current?.focus()},children:[(0,$.jsx)(Rn,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-xl bg-accent-info/15 text-accent-info ring-1 ring-accent-info/30`,children:(0,$.jsx)(R,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(Fn,{className:`text-base`,children:i(`targetPr.confirmTitle`)}),(0,$.jsx)(Mn,{children:i(`targetPr.confirmBody`)})]})]})}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 bg-muted/30 p-3 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(R,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 font-medium text-foreground`,children:[`#`,t.number,t.title?` · ${t.title}`:``]})]}),t.headRefName&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-muted-foreground`,children:[(0,$.jsx)(nn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 truncate`,children:[i(`targetPr.confirmBranch`),`: `,(0,$.jsx)(`span`,{className:`font-mono`,children:t.headRefName})]})]})]}),(0,$.jsxs)(Tn,{className:`gap-2 sm:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`h-9`,onClick:r,children:i(`common:actions.cancel`)}),(0,$.jsxs)(Z,{ref:a,className:`h-9 gap-2 bg-accent-info text-white hover:bg-accent-info/85 focus-visible:ring-accent-info`,onClick:n,children:[i(`targetPr.confirmLaunch`,{number:t.number}),(0,$.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center rounded border border-white/30 bg-white/10 px-1 text-[9px] font-medium leading-4`,children:jH(`⌘↵`)})]})]})]})}):null}var PH=`postit`,FH=e=>`specrails-desktop:specs-view-tier:${e}`;function IH(e){return e===`row`||e===`postit`}function LH(e){if(!e)return PH;try{let t=localStorage.getItem(FH(e));if(IH(t))return t}catch{}return PH}function RH(e,t){if(e)try{localStorage.setItem(FH(e),t)}catch{}}function zH(e,t,n){if(typeof n==`number`&&n===t)return e;if(typeof n==`number`&&e.includes(n)){let r=e.indexOf(n),i=[...e];return i.splice(r,0,t),i}return[...e,t]}function BH(e,t,n,r,i){if(typeof e==`string`){if(r(e)){let n=i(e);return t.has(n)?n:null}return t.has(e)?e:null}if(typeof e==`number`){let r=n(e);return r&&t.has(r)?r:null}return null}var VH=[{id:`rail-1`,label:`Rail 1`,ticketIds:[],mode:`implement`,status:`idle`},{id:`rail-2`,label:`Rail 2`,ticketIds:[],mode:`implement`,status:`idle`},{id:`rail-3`,label:`Rail 3`,ticketIds:[],mode:`implement`,status:`idle`}],HH=e=>e===`implement`||e===`batch-implement`||e===`freestyle`||e===`loop`;function UH(e,t){if(!e||e.decision!==`pr_draft`&&e.decision!==`pr_ready`||!e.prUrl||!e.branch)return!1;let n=new Set(e.ticketIds);return t.length>0&&t.every(e=>n.has(e))}function WH(e,t){for(let n of t.values())if(UH(n,[e]))return!0;return!1}function GH(e){if(!e)return null;try{let t=localStorage.getItem(`specrails-desktop:spec-order:${e}`);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function KH(e,t){if(e)try{t?localStorage.setItem(`specrails-desktop:spec-order:${e}`,JSON.stringify(t)):localStorage.removeItem(`specrails-desktop:spec-order:${e}`)}catch{}}function qH(e){if(!e)return null;try{let t=localStorage.getItem(`specrails-desktop:rails:${e}`);if(!t)return null;let n=JSON.parse(t);return!Array.isArray(n)||n.length===0?null:n}catch{return null}}function JH(e,t){if(e)try{localStorage.setItem(`specrails-desktop:rails:${e}`,JSON.stringify(t))}catch{}}function YH(){let{t:e}=K(`dashboard`),{activeProjectId:t,projects:n}=at(),r=ca().id===`galaxy`,i=(()=>{let e=n.find(e=>e.id===t);return e?rt(e):[`claude`]})(),{tickets:a,isLoading:o,error:s,updateTicket:c,updateTicketStatus:l,updateTicketPriority:u,deleteTicket:d,createTicket:f,refetch:p,contractRefiningIds:m}=T(),{registerHandler:h,unregisterHandler:g,connectionStatus:_}=qe(),{specToOpen:v,clearSpecToOpen:y}=tz(),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!v||v.projectId!==t||(x(v.ticket),p(),y())},[v,t,p,y]);let[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(()=>GH(t)),[L,R]=(0,Q.useState)(()=>qH(t)??VH),[z,B]=(0,Q.useState)({}),ee=dH(),{decisions:V,hydrated:H,act:te,checkout:ne}=mH(),re=AR(t),[ie,ae]=(0,Q.useState)(re.mode),[oe,se]=(0,Q.useState)(re.dir),[ce,le]=(0,Q.useState)(()=>LH(t));(0,Q.useEffect)(()=>{I(GH(t)),R(qH(t)??VH),B({});let e=AR(t);ae(e.mode),se(e.dir),le(LH(t))},[t]);let ue=(0,Q.useCallback)((e,n)=>{ae(e),se(n),jR(t,e,n)},[t]),de=(0,Q.useCallback)(e=>{le(e),RH(t,e)},[t]);(0,Q.useEffect)(()=>{if(_!==`connected`||!t)return;let e=!1,n=qH(t)??VH,r=new Map(n.map(e=>[e.id,e]));return fetch(`${nt()}/rails`).then(e=>e.ok?e.json():null).then(n=>{if(e||!n)return;let i=n.activeJobs??{},a=n.activeLoopRuns??{},o=new Set([...Object.keys(i).map(Number),...Object.keys(a).map(Number)]),s=n.rails??[],c=new Map;for(let e of s)c.set(e.railIndex,Array.isArray(e.ticketIds)?e.ticketIds:[]);let l=new Set(s.map(e=>e.railIndex));R(e=>{let n=!1,u=new Map,d=e.map((e,t)=>{let s=zV(e.id)??t,l=a[String(s)],d=i[String(s)]?.jobId??l?.loopRunId;if(o.has(s)){if(e.status===`running`)return d&&!e.activeJobId?(n=!0,{...e,activeJobId:d}):e;if(r.get(e.id)?.status===`running`)return e;let t=c.get(s)??[],a=i[String(s)]?.mode,o=HH(a)?a:l?yV(l.loopId):void 0,f=t.length?t:e.ticketIds;return u.set(e.id,f),n=!0,{...e,status:`running`,activeJobId:d,ticketIds:f,mode:o??e.mode,...l?.loopId&&l.loopId.startsWith(`custom:`)?{selectedLoopId:l.loopId}:{}}}return e.status!==`running`||r.get(e.id)?.status!==`running`?e:(n=!0,{...e,status:`idle`,activeJobId:void 0,ticketIds:[]})}),f=new Set(d.map(e=>e.id)),p=[];for(let e of s){let t=RV(e.railIndex);if(f.has(t))continue;let r=a[String(e.railIndex)],s=i[String(e.railIndex)]?.mode,l=HH(s)?s:r?yV(r.loopId):HH(e.mode)?e.mode:`implement`,d=o.has(e.railIndex),m=c.get(e.railIndex)??[];p.push({id:t,label:e.name?`Rail ${e.name}`:`Rail ${e.railIndex+1}`,ticketIds:m,mode:l,status:d?`running`:`idle`,activeJobId:i[String(e.railIndex)]?.jobId??r?.loopRunId,...r?.loopId&&r.loopId.startsWith(`custom:`)?{selectedLoopId:r.loopId}:{}}),m.length>0&&u.set(t,m),n=!0}let m=p.length>0?[...d,...p]:d;if(s.length>0){let e=m.filter(e=>{let t=zV(e.id);return t===null||l.has(t)||!r.has(e.id)?!0:e.status===`running`||e.ticketIds.length>0});e.length!==m.length&&(m=e,n=!0)}if(!n)return e;let h=new Set([...u.values()].flat()),g=h.size?m.map(e=>{if(u.has(e.id))return e;let t=e.ticketIds.filter(e=>!h.has(e));return t.length===e.ticketIds.length?e:{...e,ticketIds:t}}):m;return JH(t,g),g})}).catch(()=>{}),()=>{e=!0}},[t,_]),(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`${nt()}/rails`).then(e=>e.ok?e.json():null).then(n=>{if(e||!n?.rails)return;let r=new Map;for(let e of n.rails)r.set(e.railIndex,e.name??null);R(e=>{let n=!1,i=e.map((e,t)=>{let i=zV(e.id)??t,a=r.get(i)??null;if(!a)return e;let o=`Rail ${a}`;return o===e.label?e:(n=!0,{...e,label:o})});return n?(JH(t,i),i):e})}).catch(()=>{}),()=>{e=!0}},[t]),(0,Q.useEffect)(()=>{let e=new Set(a.filter(e=>e.status===`done`||H&&e.status===`on_review`&&!WH(e.id,V)).map(e=>e.id));e.size!==0&&R(n=>{let r=n.map(t=>{let n=t.ticketIds.filter(t=>!e.has(t));return n.length===t.ticketIds.length?t:{...t,ticketIds:n}});return r.every((e,t)=>e===n[t])?n:(JH(t,r),r)})},[a,t,L,V,H]);let fe=(0,Q.useCallback)(e=>{I(n=>{let r=e(n);return KH(t,r),r})},[t]),pe=(0,Q.useCallback)(e=>{R(n=>{let r=e(n);return JH(t,r),r})},[t]),me=(0,Q.useMemo)(()=>{let e=new Set([`specs`,`done-specs`]);for(let t of L)e.add(t.id);return e},[L]),he=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${nt()}/rails`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(t.ok){let n=(await t.json()).rail?.railIndex;if(typeof n==`number`){let t=RV(n);pe(e=>e.some(e=>e.id===t)?e:[...e,{id:t,label:`Rail ${n+1}`,ticketIds:[],mode:`implement`,status:`idle`}]),J.success(e(`toasts.railAdded`,{n:n+1}));return}}else{let n=await t.json().catch(()=>({error:``}));if(n.error===`rail_limit_reached`){J.error(e(`toasts.railLimitReached`,{max:n.maxRails??12}));return}}}catch{}let t=L.map(e=>zV(e.id)).filter(e=>e!==null),n=t.length>0?Math.max(...t)+2:1,r={id:`rail-${n}`,label:`Rail ${n}`,ticketIds:[],mode:`implement`,status:`idle`};pe(e=>[...e,r]),J.success(e(`toasts.railAdded`,{n}))},[L,pe,e]),_e=(0,Q.useCallback)(async t=>{let n=L.find(e=>e.id===t);if(!n||n.status===`running`)return;let r=()=>{n.ticketIds.length>0&&fe(e=>[...e??[],...n.ticketIds]),pe(e=>e.filter(e=>e.id!==t)),J.info(e(`toasts.railRemoved`,{rail:n.label}))},i=zV(t);if(i===null){r();return}try{let t=await fetch(`${nt()}/rails/${i}`,{method:`DELETE`});if(t.ok||t.status===404){r();return}J.error(e(`toasts.railDeleteFailed`))}catch{J.error(e(`toasts.railDeleteFailed`))}},[L,pe,fe,e]),ve=(0,Q.useCallback)((e,t)=>{pe(n=>n.map(n=>n.id===e?{...n,label:`Rail ${t}`}:n));let n=zV(e);n!==null&&fetch(`${nt()}/rails/${n}/name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})}).catch(()=>{})},[pe]),ye=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{ye.current=t},[t]);let U=(0,Q.useCallback)(t=>{let n=t;if(n.projectId===ye.current){if(n.type===`rail.job_started`||n.type===`loop.run_started`){if(n.railIndex==null)return;let e=RV(n.railIndex),t=n.jobId??n.loopRunId;pe(n=>n.map(n=>n.id===e?{...n,status:`running`,activeJobId:t??n.activeJobId}:n));return}if(n.type===`rail.updated`){let e=n.railIndex??0,t=RV(e),r=n.ticketIds??[],i=n.name?`Rail ${n.name}`:`Rail ${e+1}`;pe(e=>e.some(e=>e.id===t)?e.map(e=>e.id===t?n.changed!==`tickets`||e.status===`running`?{...e,label:i}:{...e,label:i,ticketIds:r}:e):[...e,{id:t,label:i,ticketIds:r,mode:HH(n.mode)?n.mode:`implement`,status:`idle`}]);return}if(n.type===`rail.removed`){if(n.railIndex==null)return;let e=RV(n.railIndex);pe(t=>t.filter(t=>t.id!==e||t.status===`running`));return}if(n.type===`rail.worktree_progress`){let t=n.railIndex??0,r=n.ticketId,i=n.state;typeof r==`number`&&i&&(B(e=>HV(e,t,r,i)),i===`needs-review`&&J.error(e(`toasts.railWorktreeNeedsReview`,{n:t+1,ticket:r})));return}if(n.type===`rail.job_completed`){let t=n.railIndex??0;pe(e=>JV(e,t,n.ticketIds??[])),n.status===`completed`?J.info(e(`toasts.railCompleted`,{n:t+1})):n.status===`failed`||n.status===`zombie_terminated`?J.error(e(`toasts.railFailed`,{n:t+1})):J.info(e(`toasts.railEnded`,{n:t+1,status:n.status??`finished`}))}if(n.type===`loop.run_completed`){let t=n.railIndex??0;pe(e=>JV(e,t,n.ticketIds??[])),n.status===`success`?J.info(e(`toasts.railCompleted`,{n:t+1})):n.status===`failed`||n.status===`max-iterations`?J.error(e(`toasts.railFailed`,{n:t+1})):J.info(e(`toasts.railEnded`,{n:t+1,status:n.status??`finished`}))}}},[pe,e]);(0,Q.useEffect)(()=>(h(`dashboard-rails`,U),()=>g(`dashboard-rails`)),[U,h,g]);let xe=NP(MP(RF,{activationConstraint:{distance:5}}),MP(NF)),Se=(0,Q.useCallback)(e=>{let t=typeof e.active.id==`string`&&KV(e.active.id),n=e.droppableContainers.filter(e=>{let n=e.id;return typeof n==`string`&&KV(n)?t:!t}),r={...e,droppableContainers:n};if(t)return UP(r);let i=qP(r);if(BP(i))return i;let a=GP(r);return BP(a)?a:UP(r)},[]),Ce=(0,Q.useMemo)(()=>new Map(a.map(e=>[e.id,e])),[a]),W=(0,Q.useMemo)(()=>{let e=[],t=[];return L.forEach((n,r)=>{let i=zV(n.id)??r;if(n.status===`running`){t.push({rail:n,reason:`running`});return}if(n.ticketIds.length===0){t.push({rail:n,reason:`empty`});return}let a=V.get(i);if(a&&!UH(a,n.ticketIds)){t.push({rail:n,reason:`pendingDecision`});return}if(n.ticketIds.some(e=>Ce.get(e)?.status===`on_review`&&(!H||!WH(e,V)))){t.push({rail:n,reason:`onReview`});return}e.push(n)}),{eligible:e,skipped:t}},[L,V,H,Ce]),we=(0,Q.useMemo)(()=>{let e=new Set;for(let t of a)for(let n of t.labels)e.add(n);return Array.from(e).sort()},[a]),Te=(0,Q.useMemo)(()=>{let e=new Set;for(let t of L)for(let n of t.ticketIds)e.add(n);return e},[L]),Ee=(0,Q.useMemo)(()=>a.filter(e=>(e.source===`propose-spec`||e.source===`product-backlog`||e.source===`get-backlog-specs`||e.source===`explore-draft`||e.source===`specs-smash`||e.source===`free-prompt`||e.source===`mcp`||e.source===`project-builder`||e.source===`manual`&&e.created_by===`project-builder`||e.source===`jira`)&&!Te.has(e.id)),[a,Te]);(0,Q.useEffect)(()=>{o||ie===`jira-key`&&!Ee.some(e=>e.jira_key)&&ue(`default`,oe)},[o,ie,oe,Ee,ue]);let De=(0,Q.useMemo)(()=>{let e=Ee.filter(e=>e.status!==`done`);if(ie!=="default")return RR(e,ie,oe);if(!F)return e;let t=new Map(e.map(e=>[e.id,e])),n=[];for(let e of F){let r=t.get(e);r&&n.push(r)}for(let t of e)F.includes(t.id)||n.push(t);return n},[Ee,F,ie,oe]),Oe=(0,Q.useMemo)(()=>Ee.filter(e=>e.status===`done`),[Ee]),ke=(0,Q.useMemo)(()=>{let e=new Set;if(!H)return e;for(let t of a)t.status===`on_review`&&WH(t.id,V)&&e.add(t.id);return e},[a,V,H]),Ae=(0,Q.useCallback)((t,n)=>{let r=L.find(e=>e.id===n);if(r){if(a.find(e=>e.id===t)?.status===`on_review`&&(!H||!WH(t,V))){J.info(e(`toasts.onReviewCannotMoveToRail`));return}if(r.ticketIds.includes(t)){J.info(e(`toasts.alreadyOnRail`,{rail:r.label}));return}fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==t)),pe(e=>e.map(e=>e.id===n?{...e,ticketIds:[...e.ticketIds.filter(e=>e!==t),t]}:e.ticketIds.includes(t)?{...e,ticketIds:e.ticketIds.filter(e=>e!==t)}:e)),J.success(e(`toasts.movedToRail`,{rail:r.label}))}},[L,a,De,pe,fe,e,V,H]),je=(0,Q.useCallback)(t=>{let n=L.find(e=>e.ticketIds.includes(t));if(n){if(n.status===`running`){J.error(e(`toasts.railRunningStopFirst`,{rail:n.label}));return}pe(e=>e.map(e=>e.id===n.id?{...e,ticketIds:e.ticketIds.filter(e=>e!==t)}:e)),fe(e=>{let n=e??De.map(e=>e.id);return n.includes(t)?n:[...n,t]}),J.success(e(`toasts.removedFromRail`,{rail:n.label}))}},[L,De,pe,fe,e]),Me=(0,Q.useCallback)(e=>{if(De.some(t=>t.id===e))return`specs`;if(Oe.some(t=>t.id===e))return`done-specs`;for(let t of L)if(t.ticketIds.includes(e))return t.id;return null},[De,Oe,L]);function Ne({active:e}){if(KV(e.id)){let t=qV(e.id),n=L.find(e=>e.id===t);P(n?.label??t);return}M(e.id)}function Pe({active:n,over:r}){if(M(null),P(null),!r)return;if(KV(n.id)){if(!KV(r.id))return;let e=qV(n.id),t=qV(r.id);if(e===t)return;pe(n=>{let r=n.findIndex(t=>t.id===e),i=n.findIndex(e=>e.id===t);return r===-1||i===-1?n:nL(n,r,i)});return}let i=n.id,o=r.id,s=Me(i);if(!s)return;let l=BH(o,me,Me,KV,qV)??s;if(me.has(l))if(s===l)if(l===`specs`){let e=De.map(e=>e.id),n=e.indexOf(i),r=e.indexOf(o);if(n!==-1&&r!==-1&&n!==r){let i=nL(e,n,r);fe(()=>i),ie!=="default"&&(ae(`default`),jR(t,`default`,oe))}}else pe(e=>e.map(e=>{if(e.id!==l)return e;let t=e.ticketIds.indexOf(i),n=e.ticketIds.indexOf(o);return t!==-1&&n!==-1&&t!==n?{...e,ticketIds:nL(e.ticketIds,t,n)}:e}));else if(s===`specs`&&l===`done-specs`){if(a.find(e=>e.id===i)?.status===`on_review`){J.info(e(`toasts.onReviewCannotMoveToRail`));return}fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==i)),c(i,{status:`done`})}else if(s===`done-specs`&&l===`specs`)c(i,{status:`todo`}),fe(e=>zH(e??De.map(e=>e.id),i,o));else if(s===`specs`){if(a.find(e=>e.id===i)?.status===`on_review`&&(!H||!WH(i,V))){J.info(e(`toasts.onReviewCannotMoveToRail`));return}let t=L.find(e=>e.id===l);fe(e=>(e??De.map(e=>e.id)).filter(e=>e!==i)),pe(e=>e.map(e=>e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e)),t&&(t.status===`running`?J.info(e(`toasts.queuedOnRail`,{rail:t.label}),{description:e(`toasts.queuedOnRailDescription`)}):J.success(e(`toasts.movedToRail`,{rail:t.label})))}else if(l===`specs`){let t=L.find(e=>e.id===s);if(t?.status===`running`){J.error(e(`toasts.railRunningStopFirst`,{rail:t.label}));return}pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e)),fe(e=>zH(e??De.map(e=>e.id),i,o)),t&&J.success(e(`toasts.removedFromRail`,{rail:t.label}))}else s===`done-specs`?(c(i,{status:`todo`}),pe(e=>e.map(e=>e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e))):l===`done-specs`?(pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e)),c(i,{status:`done`})):pe(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e.id===l?{...e,ticketIds:zH(e.ticketIds,i,o)}:e))}function Fe(e,t){pe(n=>n.map(n=>n.id===e?{...n,mode:t}:n))}function Ie(e){let t=zV(e);return t===null?L.findIndex(t=>t.id===e):t}async function Le(e,t){pe(n=>n.map(n=>n.id===e?{...n,profileName:t}:n));let n=Ie(e);if(n!==-1)try{await fetch(`${nt()}/rails/${n}/profile`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profileName:t})})}catch{}}function Re(e,t){pe(n=>n.map(n=>n.id===e?{...n,freestyleModel:t}:n))}function ze(e,t){let n=yV(t);pe(r=>r.map(r=>r.id===e?{...r,selectedLoopId:t,mode:n}:r))}function Be(e,t){pe(n=>n.map(n=>{if(n.id!==e)return n;let r=n.aiEngine??i[0]??`claude`,a=lr(r,t);return{...n,loopModel:t,reasoningEffort:n.reasoningEffort&&a.includes(n.reasoningEffort)?n.reasoningEffort:fr(r,t)??null}}))}function G(e,t){pe(n=>n.map(n=>n.id===e?{...n,reasoningEffort:t}:n))}async function Ve(e,t){pe(n=>n.map(n=>{if(n.id!==e)return n;let r=n.mode===`freestyle`||n.selectedLoopId===`factory:freestyle`,i=!cr(t)&&r,a=fz(t),o=e=>!!(e&&(a.some(t=>t.value===e)||nr(t)&&gD(e))),s=o(n.loopModel)?n.loopModel:pz(t),c=lr(t,s);return{...n,aiEngine:t,mode:i?`implement`:n.mode,selectedLoopId:i?`factory:implement`:n.selectedLoopId,profileName:null,freestyleModel:o(n.freestyleModel)?n.freestyleModel:pz(t),loopModel:s,reasoningEffort:n.reasoningEffort&&c.includes(n.reasoningEffort)?n.reasoningEffort:fr(t,s)??null}}));let n=Ie(e);if(n!==-1)try{await fetch(`${nt()}/rails/${n}/engine`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({aiEngine:t})})}catch{}}function He(e,t){pe(n=>n.map(n=>n.id===e?{...n,targetPr:t}:n))}async function Ue(t){let n=L.find(e=>e.id===t),r=Ie(t);if(!(!n||r===-1)){if(n.status===`running`){try{await fetch(`${nt()}/rails/${r}/stop`,{method:`POST`}),pe(e=>e.map(e=>e.id===t?{...e,status:`idle`,activeJobId:void 0}:e)),J.info(e(`toasts.railStopped`,{rail:n.label}))}catch{J.error(e(`toasts.stopFailed`))}return}if(n.ticketIds.length!==0){if(n.mode===`freestyle`){E({railId:t});return}if(n.targetPr){O({railId:t});return}await We(t)}}}async function We(t,n){let r=n?.silent??!1,o=L.find(e=>e.id===t),s=Ie(t);if(!o||s===-1)return`failed`;if(o.ticketIds.length===0)return`skipped`;if(o.ticketIds.some(e=>a.find(t=>t.id===e)?.status===`on_review`&&(!H||!WH(e,V))))return r||J.info(e(`toasts.onReviewNotLaunchable`)),`skipped`;let c=bV(o.selectedLoopId,o.mode);if(!c)return r||J.error(e(`railControls.pickLoop`)),`failed`;let l=o.aiEngine??i[0]??`claude`,u=lr(l,o.loopModel??pz(l)),d=o.reasoningEffort&&u.includes(o.reasoningEffort)?o.reasoningEffort:null,f=nt();try{await fetch(`${f}/rails/${s}/tickets`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({ticketIds:o.ticketIds})})}catch{return r||J.error(e(`toasts.syncTicketsFailed`)),`failed`}try{let n=await fetch(`${f}/rails/${s}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:o.mode,...o.profileName===void 0?{}:{profileName:o.profileName},...o.aiEngine==null?{}:{aiEngine:o.aiEngine},...o.mode===`freestyle`&&o.freestyleModel?{model:o.freestyleModel}:{},...o.mode===`loop`&&o.loopModel?{model:o.loopModel}:{},loopId:c,...o.mode===`loop`&&d?{reasoning_effort:d}:{},...o.targetPr?{targetPrNumber:o.targetPr.number}:{}})});if(!n.ok){let t=await n.json().catch(()=>({error:``}));return n.status===409&&t.error===`pr_decision_pending`?(r||J.info(e(`railPr.decisionPending`)),`pendingDecision`):n.status===409&&t.error===`tickets_in_flight`?(r||J.info(e(`toasts.launchTicketsInFlight`)),`skipped`):n.status===400&&t.error===`rail_ticket_cap_exceeded`?(r||J.error(e(`toasts.launchTicketCap`,{max:t.max??3,count:t.ticketCount??0})),`failed`):typeof t.error==`string`&&[`invalid_target_pr`,`target_pr_requires_pr_mode`,`target_pr_not_found`,`target_pr_not_open`,`target_pr_fork`,`target_pr_invalid`,`target_pr_unfetchable`].includes(t.error)?(r||J.error(e(`targetPr.errors.${t.error}`),{description:t.detail,duration:1e4}),`failed`):(r||J.error(t.error||e(`toasts.launchFailed`)),`failed`)}let i=await n.json();!r&&i.isolationUnavailable===`no-git`?J.info(e(`toasts.railWorktreesNoGit`)):!r&&i.isolationUnavailable===`no-commits`?J.info(e(`toasts.railWorktreesNoCommits`)):!r&&i.isolationUnavailable===`error`&&J.warning(e(`toasts.railWorktreesError`),{description:i.isolationUnavailableDetail,duration:12e3});let a=i.jobId??i.loopRunIds?.[0];return pe(e=>e.map(e=>e.id===t?{...e,status:`running`,activeJobId:a,targetPr:null}:e)),r||J.success(e(`toasts.railLaunched`,{rail:o.label}),{description:e(`toasts.launchDescription`,{mode:o.mode,count:o.ticketIds.length})}),`launched`}catch{return r||J.error(e(`toasts.launchNetworkError`)),`failed`}}function Ge(){if(W.eligible.length===0){J.info(e(`toasts.launchAllNoneEligible`));return}A(!0)}async function Ke(){A(!1);let{eligible:t,skipped:n}=W;if(t.length===0){J.info(e(`toasts.launchAllNoneEligible`));return}let r=await Promise.allSettled(t.map(e=>We(e.id,{silent:!0}))),i=0,a=0,o=0,s=0;for(let e of r){let t=e.status===`fulfilled`?e.value:`failed`;t===`launched`?i++:t===`pendingDecision`?o++:t===`skipped`?s++:a++}let c=new Map;for(let e of n)c.set(e.reason,(c.get(e.reason)??0)+1);o>0&&c.set(`pendingDecision`,(c.get(`pendingDecision`)??0)+o);let l={running:`launchAll.skipRunning`,empty:`launchAll.skipEmpty`,pendingDecision:`launchAll.skipPendingDecision`,onReview:`launchAll.skipOnReview`},u=[];for(let[t,n]of c)n>0&&u.push(e(l[t],{count:n}));s>0&&u.push(e(`launchAll.skipInFlight`,{count:s})),a>0&&u.push(e(`launchAll.failedCount`,{count:a}));let d=u.length>0?u.join(` · `):void 0;i>0?J.success(e(`toasts.launchAllSummary`,{count:i}),d?{description:d}:void 0):J.error(e(`toasts.launchAllFailed`),d?{description:d}:void 0)}let Je=j===null?void 0:Ce.get(j),Ye=(0,Q.useRef)(null),{leftWidth:Xe,enabled:Ze,beginDrag:Qe,resetToDefault:$e}=DH(t,Ye),et=typeof window<`u`?window.innerWidth:1200;return(0,$.jsx)(LL,{children:(0,$.jsxs)(FI,{sensors:xe,collisionDetection:Se,onDragStart:Ne,onDragEnd:Pe,children:[(0,$.jsxs)(`div`,{ref:Ye,className:`relative z-0 flex h-full overflow-hidden`,children:[r&&(0,$.jsx)(IM,{}),(0,$.jsx)(`div`,{className:`relative z-10 min-w-0 flex flex-col overflow-hidden`,style:Ze&&Xe!==null?{width:`${Xe}px`,flex:`0 0 auto`}:{flex:`1 1 0%`},children:(0,$.jsx)(pV,{tickets:De,allTickets:a,doneTickets:Oe,isLoading:o,error:s,onRetry:()=>{p()},onTicketClick:x,onTicketCreated:e=>{x(e),p()},onTicketDelete:e=>d(e),onTicketStatusChange:(e,t)=>{l(e,t)},onTicketPriorityChange:(e,t)=>{u(e,t)},contractRefiningIds:m,sortMode:ie,sortDir:oe,onSortChange:ue,viewTier:ce,onViewTierChange:de,rails:L,onMoveToRail:Ae,continuableReviewTicketIds:ke})}),Ze&&Xe!==null&&(0,$.jsx)(OH,{leftWidth:Xe,viewport:et,onPointerDown:Qe,onReset:$e}),(0,$.jsx)(`div`,{className:`relative z-10 flex-1 min-w-0 flex flex-col overflow-hidden`,children:(0,$.jsx)(XV,{rails:L,ticketMap:Ce,railWorktrees:z,railMetrics:ee,railPrDecisions:V,onPrDecision:te,onPrCheckout:ne,providers:i,onModeChange:Fe,onProfileChange:Le,onEngineChange:Ve,onFreestyleModelChange:Re,onLoopModelChange:Be,loopAvailable:ge,onLoopChange:ze,onEffortChange:G,onToggle:Ue,onTargetPrChange:He,onTicketClick:x,onAddRail:()=>{he()},onDeleteRail:e=>{_e(e)},onRenameRail:ve,onTicketMoveToSpecs:je,onLaunchAll:Ge,launchAllCount:W.eligible.length})})]}),(0,$.jsx)(tL,{dropAnimation:{duration:180,easing:`ease`},children:Je?ce===`postit`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-accent-info/40 bg-card/95 shadow-xl shadow-black/30 backdrop-blur-sm p-3 rotate-1 scale-[1.02] pointer-events-none w-[260px] min-h-[180px]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/60`,children:[`#`,Je.id]}),Je.priority&&(0,$.jsx)(`span`,{className:`h-4 px-1.5 rounded-full text-[9px] font-medium uppercase bg-muted/40 text-foreground`,children:Je.priority})]}),(0,$.jsx)(`h3`,{className:`text-sm font-medium leading-snug line-clamp-2 text-foreground`,children:Je.title}),Je.short_summary&&Je.short_summary.trim().length>0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 leading-relaxed line-clamp-3 italic`,children:Je.short_summary})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border border-primary/40 bg-card/95 shadow-xl shadow-black/20 backdrop-blur-sm rotate-1 scale-[1.03] pointer-events-none`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/50 shrink-0`,children:[`#`,Je.id]}),(0,$.jsx)(`span`,{className:`flex-1 text-sm truncate max-w-[240px]`,children:Je.title})]}):N?(0,$.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-xl border border-primary/40 bg-card/95 shadow-xl shadow-black/20 backdrop-blur-sm rotate-[0.5deg] scale-[1.02] pointer-events-none`,children:(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:N})}):null}),b&&(()=>{let e=a.find(e=>e.id===b.id)??b;return(0,$.jsx)(be,{ticket:e,allLabels:we,allTickets:a,onClose:()=>x(null),onOpenTicket:e=>{let t=a.find(t=>t.id===e);t&&x(t)},onSave:c,onDelete:d,rails:L,onMoveToRail:Ae,onRemoveFromRail:je},e.id)})(),(0,$.jsx)(kH,{open:S,allLabels:we,onClose:()=>C(!1),onCreate:f}),(0,$.jsx)(MH,{open:k,railCount:W.eligible.length,specCount:W.eligible.reduce((e,t)=>e+t.ticketIds.length,0),onCancel:()=>A(!1),onConfirm:()=>{Ke()}}),(()=>{let e=D?L.find(e=>e.id===D.railId):void 0;return(0,$.jsx)(NH,{open:!!D&&!!e?.targetPr,target:e?.targetPr??null,onCancel:()=>O(null),onConfirm:()=>{let e=D?.railId;O(null),e&&We(e)}})})(),(()=>{let e=w?L.find(e=>e.id===w.railId):void 0,t=e?.aiEngine??i[0]??`claude`;return(0,$.jsx)(AH,{open:!!w&&!!e,railLabel:e?.label??``,specCount:e?.ticketIds.length??0,provider:t,model:e?.freestyleModel??pz(t),onCancel:()=>E(null),onConfirm:()=>{let e=w?.railId;E(null),e&&We(e)}})})()]})})}var XH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`rounded-lg border border-border bg-card text-card-foreground shadow-sm`,e),...t}));XH.displayName=`Card`;var ZH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`flex flex-col space-y-1 p-4`,e),...t}));ZH.displayName=`CardHeader`;var QH=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`h3`,{ref:n,className:X(`text-sm font-semibold leading-none tracking-tight`,e),...t}));QH.displayName=`CardTitle`;var $H=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`p`,{ref:n,className:X(`text-xs text-muted-foreground`,e),...t}));$H.displayName=`CardDescription`;var eU=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`p-4 pt-0`,e),...t}));eU.displayName=`CardContent`;var tU=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`flex items-center p-4 pt-0`,e),...t}));tU.displayName=`CardFooter`;var nU=[`auto`,`canvas`,`webgl`];function rU({mode:e}){let{t}=K(`settings`),{activeProjectId:n}=at(),[r,i]=(0,Q.useState)(vi),[a,o]=(0,Q.useState)({}),[s,c]=(0,Q.useState)(vi),[l,u]=(0,Q.useState)(vi),[d,f]=(0,Q.useState)(new Set),[p,m]=(0,Q.useState)(!0),[h,g]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let t=!1;if(e===`project`&&!n){m(!1);return}return(async()=>{try{if(e===`desktop`){let e=await fetch(`/api/terminal-settings`);if(!e.ok)throw Error(`desktop settings fetch failed`);let n=await e.json();!t&&n&&typeof n==`object`&&`fontSize`in n&&(i(n),c(n),u(n),f(new Set)),t||m(!1)}else if(n){let e=await fetch(`/api/projects/${n}/terminal-settings`);if(!e.ok)throw Error(`project fetch failed`);let r=await e.json();!t&&r&&typeof r==`object`&&r.resolved&&r.desktopDefaults&&(i(r.desktopDefaults),o(r.override??{}),c(r.resolved),u(r.resolved),f(new Set)),t||m(!1)}}catch(e){t||(m(!1),console.error(e))}})(),()=>{t=!0}},[e,n]);let _=(0,Q.useMemo)(()=>d.size>0||Object.keys(l).some(e=>l[e]!==s[e]),[l,s,d]);function v(e,t){u(n=>({...n,[e]:t})),d.has(e)&&f(t=>{let n=new Set(t);return n.delete(e),n})}function y(t){e===`project`&&(f(e=>{let n=new Set(e);return n.add(t),n}),u(e=>({...e,[t]:r[t]})))}function b(){u(s),f(new Set)}async function x(){g(!0);try{let r={};for(let e of Object.keys(l)){if(d.has(e)){r[e]=null;continue}l[e]!==s[e]&&(r[e]=l[e])}if(Object.keys(r).length===0){J(t(`terminal.nothingToSave`)),g(!1);return}if(e===`desktop`){let e=await fetch(`/api/terminal-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(await e.text()||`patch failed`);let n=await e.json();i(n),c(n),u(n),f(new Set),oN({mode:`desktop`,projectId:null}),J.success(t(`terminal.saved`))}else if(n){let e=await fetch(`/api/projects/${n}/terminal-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(await e.text()||`patch failed`);let a=await e.json();i(a.desktopDefaults),o(a.override),c(a.resolved),u(a.resolved),f(new Set),oN({mode:`project`,projectId:n}),J.success(t(`terminal.saved`))}}catch(e){J.error(t(`errors.saveFailed`,{message:e.message}))}finally{g(!1)}}function S(t){return e!==`project`||d.has(t)?!1:a[t]!==void 0}return p?(0,$.jsx)(XH,{children:(0,$.jsx)(eU,{children:t(`common:states.loading`)})}):(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:t(`terminal.title`)}),(0,$.jsx)($H,{children:t(e===`desktop`?`terminal.desktopDescription`:`terminal.projectDescription`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsx)(iU,{label:t(`terminal.fontFamily`),overridden:S(`fontFamily`),onClear:()=>y(`fontFamily`),mode:e,children:(0,$.jsx)(Qk,{value:l.fontFamily,onChange:e=>v(`fontFamily`,e.target.value)})}),(0,$.jsx)(iU,{label:t(`terminal.fontSize`,{min:8,max:32}),overridden:S(`fontSize`),onClear:()=>y(`fontSize`),mode:e,children:(0,$.jsx)(Qk,{type:`number`,min:8,max:32,value:l.fontSize,onChange:e=>v(`fontSize`,parseInt(e.target.value,10)||l.fontSize)})}),(0,$.jsx)(iU,{label:t(`terminal.renderMode`),overridden:S(`renderMode`),onClear:()=>y(`renderMode`),mode:e,children:(0,$.jsx)(`select`,{value:l.renderMode,onChange:e=>v(`renderMode`,e.target.value),className:`border rounded px-2 py-1 bg-transparent`,children:nU.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})}),(0,$.jsx)(aU,{label:t(`terminal.copyOnSelect`),checked:l.copyOnSelect,overridden:S(`copyOnSelect`),onClear:()=>y(`copyOnSelect`),onChange:e=>v(`copyOnSelect`,e),mode:e}),(0,$.jsx)(aU,{label:t(`terminal.shellIntegration`),checked:l.shellIntegrationEnabled,overridden:S(`shellIntegrationEnabled`),onClear:()=>y(`shellIntegrationEnabled`),onChange:e=>v(`shellIntegrationEnabled`,e),mode:e}),(0,$.jsx)(aU,{label:t(`terminal.notifyLongRunning`),checked:l.notifyOnCompletion,overridden:S(`notifyOnCompletion`),onClear:()=>y(`notifyOnCompletion`),onChange:e=>v(`notifyOnCompletion`,e),mode:e}),(0,$.jsx)(iU,{label:t(`terminal.longCommandThreshold`),overridden:S(`longCommandThresholdMs`),onClear:()=>y(`longCommandThresholdMs`),mode:e,children:(0,$.jsx)(Qk,{type:`number`,min:1e3,value:l.longCommandThresholdMs,onChange:e=>v(`longCommandThresholdMs`,parseInt(e.target.value,10)||l.longCommandThresholdMs)})}),(0,$.jsx)(aU,{label:t(`terminal.imageRendering`),checked:l.imageRendering,overridden:S(`imageRendering`),onClear:()=>y(`imageRendering`),onChange:e=>v(`imageRendering`,e),mode:e}),(0,$.jsx)(iU,{id:`terminal-browser-shortcut-url`,label:t(`terminal.browserShortcutUrl`),overridden:S(`browserShortcutUrl`),onClear:()=>y(`browserShortcutUrl`),mode:e,children:(0,$.jsx)(Qk,{type:`url`,value:l.browserShortcutUrl,placeholder:`https://specrails.dev`,onChange:e=>v(`browserShortcutUrl`,e.target.value)})}),(0,$.jsx)(iU,{id:`terminal-quick-script`,label:t(`terminal.quickScript`),overridden:S(`quickScript`),onClear:()=>y(`quickScript`),mode:e,children:(0,$.jsx)(`textarea`,{value:l.quickScript,placeholder:`echo "Hello World!"`,onChange:e=>v(`quickScript`,e.target.value),rows:3,className:`w-full border rounded px-2 py-1 bg-transparent font-mono text-xs`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 border-t`,children:[(0,$.jsx)(Z,{onClick:x,disabled:!_||h,children:t(h?`common:states.saving`:`common:actions.save`)}),(0,$.jsx)(Z,{variant:`ghost`,onClick:b,disabled:!_||h,children:t(`terminal.reset`)}),_&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`terminal.unsavedChanges`)})]})]})]})}function iU({id:e,label:t,overridden:n,onClear:r,mode:i,children:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(`div`,{id:e,"data-terminal-settings-anchor":e?``:void 0,className:e?`scroll-mt-4`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center mb-1`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium`,children:t}),i===`project`&&n&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:r,children:o(`terminal.clearOverride`)})]}),a,i===`project`&&!n&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:o(`terminal.inheritingDefault`)})]})}function aU({label:e,checked:t,overridden:n,onClear:r,onChange:i,mode:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium`,children:e}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a===`project`&&n&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:r,children:o(`terminal.clear`)}),(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":e,"aria-checked":t,onClick:()=>i(!t),className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${t?`bg-primary`:`bg-input`}`,children:(0,$.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})})]})]})}function oU(){let{activeProjectId:e,projects:t,refreshProjects:n}=at(),r=t.find(t=>t.id===e);return r?(0,$.jsx)(sU,{project:r,refreshProjects:n},r.id):null}function sU({project:e,refreshProjects:t}){let{t:n}=K(`common`),[r,i]=(0,Q.useState)(()=>er(e)),[a,o]=(0,Q.useState)(null),[s,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]),(0,Q.useEffect)(()=>{i(er(e))},[e]);let x=`${$n(e.id)}/repositories`;function S(e){y(null),o(e??null),l(!e),d(e?.path??``),p(e?.name??``),h(e?.integrationBranch??``)}async function C(e,n){if(!g){_(!0),y(null);try{let r=await fetch(n?`${x}/${encodeURIComponent(n)}`:x,{method:e,headers:{"Content-Type":`application/json`},...e===`DELETE`?{}:{body:JSON.stringify({...!a||!a.isPrimary&&u.trim()!==a.path?{path:u.trim()}:{},...f.trim()?{name:f.trim()}:{},integrationBranch:m.trim()||null})}});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let s=await fetch(x,{cache:`no-store`});if(!s.ok)throw Error(`HTTP ${s.status}`);let c=await s.json();b.current&&(i(c.repositories),l(!1),o(null)),await t?.()}catch(e){b.current&&y(e instanceof Error?e.message:String(e))}finally{b.current&&_(!1)}}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsxs)(QH,{className:`flex items-center gap-2`,children:[(0,$.jsx)(is,{className:`h-4 w-4`}),n(`repositories.title`)]}),(0,$.jsx)($H,{children:n(`repositories.sharedBacklog`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.isPrimary?n(`repositories.primary`):e.kind===`folder`?n(`repositories.contextOnly`):`Git`}),e.available===!1&&(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:n(`repositories.unavailable`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex gap-1`,children:[(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,disabled:g,onClick:()=>S(e),children:n(`actions.edit`)}),!e.isPrimary&&(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,disabled:g,onClick:()=>void C(`DELETE`,e.id),children:n(`repositories.detach`)})]})]}),(0,$.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:e.path}),e.integrationBranch&&(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[n(`repositories.integrationBranch`),`: `,e.integrationBranch]})]},e.id))}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`repositories.detachHint`)}),v&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:v}),s||a?(0,$.jsxs)(`form`,{className:`space-y-3 rounded-lg border border-border p-3`,onSubmit:e=>{e.preventDefault(),C(a?`PATCH`:`POST`,a?.id)},children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.name`),(0,$.jsx)(Qk,{value:f,disabled:g,onChange:e=>p(e.target.value)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.path`),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{value:u,required:!0,disabled:g||a?.isPrimary,onChange:e=>d(e.target.value)}),`__TAURI_INTERNALS__`in window&&!a?.isPrimary&&(0,$.jsx)(Z,{type:`button`,variant:`outline`,disabled:g,"aria-label":n(`repositories.browse`),onClick:async()=>{try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!1});typeof t==`string`&&b.current&&d(t)}catch{}},children:(0,$.jsx)(as,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.integrationBranch`),(0,$.jsx)(Qk,{value:m,disabled:g,placeholder:n(`repositories.branchDefault`),onChange:e=>h(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`submit`,size:`sm`,disabled:g||!u.trim(),children:n(g?`actions.saving`:`actions.save`)}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`ghost`,disabled:g,onClick:()=>{l(!1),o(null),y(null)},children:n(`actions.cancel`)})]})]}):(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,disabled:g,onClick:()=>S(),children:[(0,$.jsx)(cn,{className:`mr-1 h-4 w-4`}),n(`repositories.addFolder`)]})]})]})}function cU(){return(0,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-lg bg-muted/30`,"data-testid":`section-skeleton`})}function lU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(!0),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!t)return;let e=!1;return s(!1),fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&r(t.pipelineTelemetryEnabled??!0)}).catch(()=>{}).finally(()=>{e||s(!0)}),()=>{e=!0}},[t]),!o)return(0,$.jsx)(cU,{});async function c(t){a(!0);let i=n;r(t);try{if(!(await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pipelineTelemetryEnabled:t})})).ok)throw Error(`Failed to save`);J.success(e(t?`telemetry.enabled`:`telemetry.disabled`))}catch(t){r(i),J.error(e(`telemetry.saveFailed`),{description:t.message})}finally{a(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`telemetry.title`)}),(0,$.jsx)($H,{children:e(`telemetry.description`)})]}),(0,$.jsx)(eU,{className:`space-y-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:e(`telemetry.toggleLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`telemetry.toggleDescription`,components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})})]}),(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":e(`telemetry.toggleLabel`),"aria-checked":n,disabled:i,onClick:()=>c(!n),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 ${n?`bg-primary`:`bg-input`}`,children:(0,$.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${n?`translate-x-4`:`translate-x-0.5`}`})})]})})]})}function uU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);async function u(e){let t=await fetch(`${nt()}/integration-branch`).then(e=>e.ok?e.json():null).catch(()=>null);e?.current||t&&(r(t.configured??``),t.branch&&a({branch:t.branch,source:t.source??``}))}if((0,Q.useEffect)(()=>{if(!t)return;let e={current:!1};return l(!1),u(e).finally(()=>{e.current||l(!0)}),()=>{e.current=!0}},[t]),!c)return(0,$.jsx)(cU,{});async function d(){s(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({integrationBranch:n.trim()})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to save`)}J.success(e(`integrationBranch.saved`)),await u()}catch(t){J.error(e(`integrationBranch.saveFailed`),{description:t.message})}finally{s(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`integrationBranch.title`)}),(0,$.jsx)($H,{children:e(`integrationBranch.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-3`,children:[(0,$.jsx)(Qk,{value:n,onChange:e=>r(e.target.value),placeholder:e(`integrationBranch.placeholder`),"data-testid":`integration-branch-input`}),i&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`integration-branch-resolved`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`integrationBranch.resolved`,values:{branch:i.branch},components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(Z,{size:`sm`,onClick:d,disabled:o,"data-testid":`integration-branch-save`,children:e(`integrationBranch.save`)})]})]})}var dU=/^[A-Za-z_][A-Za-z0-9_]*$/,fU=[`NODE_AUTH_TOKEN`,`NPM_TOKEN`,`AWS_PROFILE`];function pU(e){return e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}function mU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),s(``),fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&r(Array.isArray(t.worktreeEnvPassthrough)?t.worktreeEnvPassthrough:[])}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]),!u)return(0,$.jsx)(cU,{});function f(t){let i=pU(t);if(i.length===0)return;let o=[...n];for(let t of i){if(t.includes(`=`)){s(e(`worktreeEnv.noValues`));return}if(!dU.test(t)){s(e(`worktreeEnv.invalidName`,{name:t}));return}o.includes(t)||o.push(t)}r(o),a(``),s(``)}async function p(){l(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({worktreeEnvPassthrough:n})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to save`)}let i=await t.json();r(i.settings?.worktreeEnvPassthrough??n),J.success(e(`worktreeEnv.saved`))}catch(t){J.error(e(`worktreeEnv.saveFailed`),{description:t.message})}finally{l(!1)}}return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`worktreeEnv.title`)}),(0,$.jsx)($H,{children:e(`worktreeEnv.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:`worktree-env-name`,className:`text-xs font-medium`,children:e(`worktreeEnv.label`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{id:`worktree-env-name`,value:i,onChange:e=>{a(e.target.value),s(``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f(i))},placeholder:e(`worktreeEnv.placeholder`),"aria-invalid":!!o,"data-testid":`worktree-env-input`}),(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`secondary`,className:`h-9 shrink-0`,onClick:()=>f(i),disabled:!i.trim(),"data-testid":`worktree-env-add`,children:[(0,$.jsx)(cn,{className:`w-3.5 h-3.5`}),e(`worktreeEnv.add`)]})]}),o?(0,$.jsx)(`p`,{className:`text-[10px] text-destructive`,"data-testid":`worktree-env-error`,children:o}):(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`worktreeEnv.helper`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:fU.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`rounded-md border border-border bg-muted/30 px-2 py-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:e},e))}),n.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`worktree-env-list`,children:n.map(t=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 font-mono text-[11px]`,children:[t,(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e!==t)),className:`rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":e(`worktreeEnv.remove`,{name:t}),children:(0,$.jsx)(mn,{className:`w-3 h-3`})})]},t))}):(0,$.jsx)(`p`,{className:`rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:e(`worktreeEnv.empty`)}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,onClick:p,disabled:c,"data-testid":`worktree-env-save`,children:e(c?`common:states.saving`:`worktreeEnv.save`)})})]})]})}function hU({value:e,onChange:t,onSave:n,isSaving:r,fieldId:i,i18nRoot:a}){let{t:o}=K(`settings`);return(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:o(`${a}.title`)}),(0,$.jsx)($H,{children:o(`${a}.description`)})]}),(0,$.jsxs)(eU,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium`,children:o(`${a}.label`)}),(0,$.jsx)(`textarea`,{id:i,value:e,onChange:e=>t(e.target.value),placeholder:o(`${a}.placeholder`),className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`${a}.helper`)})]}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:r,onClick:n,children:o(r?`common:states.saving`:`${a}.saveButton`)})})]})]})}function gU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)({pre:!1,freestyle:!1});(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),f.current={pre:!1,freestyle:!1},fetch(`${nt()}/settings`).then(e=>e.ok?e.json():null).then(t=>{e||!t||(f.current.pre||r(t.prePrompt??``),f.current.freestyle||s(t.freestylePrePrompt??``))}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]);async function p(){a(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prePrompt:n})});if(!t.ok)throw Error(`Failed to save`);let i=(await t.json()).settings?.prePrompt??``;r(i),J.success(i.trim()===``?e(`prePrompt.cleared`):e(`prePrompt.saved`))}catch(t){J.error(e(`prePrompt.saveFailed`),{description:t.message})}finally{a(!1)}}async function m(){l(!0);try{let t=await fetch(`${nt()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({freestylePrePrompt:o})});if(!t.ok)throw Error(`Failed to save`);let n=(await t.json()).settings?.freestylePrePrompt??``;s(n),J.success(n.trim()===``?e(`freestylePrePrompt.resetToDefault`):e(`freestylePrePrompt.saved`))}catch(t){J.error(e(`freestylePrePrompt.saveFailed`),{description:t.message})}finally{l(!1)}}return u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hU,{value:n,onChange:e=>{f.current.pre=!0,r(e)},onSave:p,isSaving:i,fieldId:`project-pre-prompt`,i18nRoot:`prePrompt`}),(0,$.jsx)(hU,{value:o,onChange:e=>{f.current.freestyle=!0,s(e)},onSave:m,isSaving:c,fieldId:`project-freestyle-pre-prompt`,i18nRoot:`freestylePrePrompt`})]}):(0,$.jsx)(cU,{})}function _U(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)({daily:!1,perJob:!1});(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return d(!1),f.current={daily:!1,perJob:!1},fetch(`${nt()}/budget`).then(e=>e.ok?e.json():null).then(t=>{e||!t||(f.current.daily||r(t.dailyBudgetUsd==null?``:String(t.dailyBudgetUsd)),f.current.perJob||s(t.jobCostThresholdUsd==null?``:String(t.jobCostThresholdUsd)))}).catch(()=>{}).finally(()=>{e||d(!0)}),()=>{e=!0}},[t]);async function p(t,n,r,i){i(!0);try{if(!(await fetch(`${nt()}/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`Failed to save`);J.success(n)}catch(t){J.error(e(r),{description:t.message})}finally{i(!1)}}function m(t){let n=t.trim()===``?null:parseFloat(t);if(n!==null&&(isNaN(n)||n<=0)){J.error(e(`budget.invalidNumber`));return}return n}function h(){let t=m(n);t!==void 0&&p({dailyBudgetUsd:t},t==null?e(`budget.dailyRemoved`):e(`budget.dailySet`,{amount:t}),`budget.saveBudgetFailed`,a)}function g(){let t=m(o);t!==void 0&&p({jobCostThresholdUsd:t},t==null?e(`budget.perJobAlertDisabled`):e(`budget.alertSet`,{amount:t}),`budget.saveThresholdFailed`,l)}return u?(0,$.jsxs)(XH,{children:[(0,$.jsxs)(ZH,{children:[(0,$.jsx)(QH,{children:e(`budget.title`)}),(0,$.jsx)($H,{children:e(`budget.description`)})]}),(0,$.jsx)(eU,{children:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs font-medium`,children:e(`budget.dailyLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`budget.dailyHelper`)})]}),(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:n,onChange:e=>{f.current.daily=!0,r(e.target.value)},placeholder:e(`budget.dailyPlaceholder`),className:`h-8 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:i,onClick:h,children:e(i?`common:states.saving`:`common:actions.save`)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs font-medium`,children:e(`budget.perJobLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`budget.perJobHelper`)})]}),(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:o,onChange:e=>{f.current.perJob=!0,s(e.target.value)},placeholder:e(`budget.perJobPlaceholder`),className:`h-8 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs`,disabled:c,onClick:g,children:e(c?`common:states.saving`:`common:actions.save`)})})]})]})})]}):(0,$.jsx)(cU,{})}function vU(){let{t:e}=K(`settings`),{activeProjectId:t}=at(),n=p(),r=t!==null;(0,Q.useEffect)(()=>{if(!n.hash)return;let e=n.hash.slice(1),t=!1,r=Date.now()+3e3,i=()=>{if(t)return;let n=document.getElementById(e);if(n){n.scrollIntoView({behavior:`smooth`,block:`center`}),n.classList.add(`ring-2`,`ring-accent-primary/60`,`rounded`),window.setTimeout(()=>{n.classList.remove(`ring-2`,`ring-accent-primary/60`,`rounded`)},1800);return}Date.now()<r&&window.setTimeout(i,80)};return i(),()=>{t=!0}},[n.hash,n.key]);let[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!0),c=(0,Q.useRef)(new Map);return(0,Q.useEffect)(()=>{if(t){let e=c.current.get(t);e?(a(e),s(!1)):s(!0)}async function e(){try{let e=await fetch(`${nt()}/config`);if(!e.ok)return;let n=await e.json();a(n),t&&c.current.set(t,n)}catch{}finally{s(!1)}}e()},[t]),o?(0,$.jsx)(`div`,{className:`max-w-2xl mx-auto px-4 py-6 space-y-3`,children:[0,1,2].map(e=>(0,$.jsx)(`div`,{className:`h-32 bg-muted/30 rounded-lg animate-pulse`},e))}):(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto px-4 py-6 space-y-6`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-base font-semibold`,children:e(`page.title`)}),i&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[i.project.name,i.project.repo&&` · ${i.project.repo}`]})]}),r&&(0,$.jsx)(lU,{}),(0,$.jsx)(gU,{}),(0,$.jsx)(oU,{}),(0,$.jsx)(uU,{}),(0,$.jsx)(mU,{}),(0,$.jsx)(_U,{}),(0,$.jsx)(rU,{mode:`project`})]})}function yU(){let{t:e}=K(`settings`),t=rk();return(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`effects-section`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`effects.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`effects.description`)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t.agentThinkingHalo,onClick:()=>tk({agentThinkingHalo:!t.agentThinkingHalo}),className:X(`relative mt-0.5 inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors`,t.agentThinkingHalo?`bg-accent-primary/70`:`bg-muted-foreground/30`),"data-testid":`effects-thinking-halo-toggle`,children:(0,$.jsx)(`span`,{className:X(`absolute h-3 w-3 rounded-full bg-background shadow transition-transform`,t.agentThinkingHalo?`translate-x-3.5`:`translate-x-0.5`)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[(0,$.jsx)(un,{className:`h-3.5 w-3.5 text-accent-primary`,"aria-hidden":!0}),e(`effects.thinkingHalo.label`)]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:e(`effects.thinkingHalo.description`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground/80`,children:e(`effects.reducedMotion`)}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`p`,{className:`mb-1.5 text-[10px] uppercase tracking-wider text-muted-foreground`,children:e(`effects.preview`)}),(0,$.jsxs)(`div`,{className:`relative max-w-sm rounded-xl border border-border/60 bg-background/60 px-3 py-2`,"data-testid":`effects-thinking-halo-preview`,"data-active":t.agentThinkingHalo,children:[(0,$.jsx)(JO,{active:t.agentThinkingHalo,radius:`0.75rem`,inset:-3,fadeInMs:450,fadeOutMs:800}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex gap-0.5`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary`}),(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary [animation-delay:150ms]`}),(0,$.jsx)(`span`,{className:`h-1 w-1 animate-pulse rounded-full bg-accent-primary [animation-delay:300ms]`})]}),e(`effects.previewThinking`)]})]})]})]})]})]})]})}function bU(){let{t:e}=K(`settings`),t=sa();if(!t)return null;let{themeId:n,setTheme:r,isUpdating:i}=t;async function a(t){if(t!==n)try{await r(t)}catch(t){J.error(e(`appearance.updateFailed`),{description:t instanceof Error?t.message:void 0})}}return(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-2`,role:`radiogroup`,"aria-label":e(`appearance.themeGroupLabel`),children:Pi.map(t=>{let r=Yi[t],o=t===n;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:i,onClick:()=>void a(t),className:`group relative overflow-hidden rounded-lg border text-left transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/60 disabled:opacity-60 disabled:cursor-not-allowed `+(o?`border-accent-primary ring-1 ring-accent-primary shadow-[0_0_0_1px_var(--color-accent-primary)] `:`border-border hover:border-accent-primary/40 hover:shadow-md `),"data-testid":`theme-card-${t}`,"data-selected":o?`true`:`false`,children:[(0,$.jsx)(`div`,{className:`h-20 w-full flex items-end gap-1 p-2`,style:{background:`linear-gradient(135deg, ${r.previewSwatches.background} 0%, ${r.previewSwatches.background} 60%, color-mix(in srgb, ${r.previewSwatches.accents[0]} 18%, ${r.previewSwatches.background}) 100%)`},"aria-hidden":`true`,children:r.previewSwatches.accents.map((e,t)=>(0,$.jsx)(`span`,{className:`h-3 w-3 rounded-full ring-1 ring-black/10`,style:{background:e}},t))}),(0,$.jsxs)(`div`,{className:`p-3 space-y-1 bg-card`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold`,children:r.displayName}),o&&(0,$.jsx)(Ht,{className:`w-3.5 h-3.5 text-accent-primary shrink-0`,"aria-label":e(`appearance.currentlyActive`)})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground leading-tight`,children:e(`appearance.taglines.${t}`,{defaultValue:r.tagline})})]})]},t)})})}function xU(){let{t:e}=K(`settings`);return sa()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`appearance.heading`)}),(0,$.jsx)(bU,{})]}):null}function SU(e={}){let t={...e},n=Ve();return n&&(t[`X-Desktop-Token`]=n),t}var CU=(0,Q.createContext)(null);function wU(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(ze,e)}catch{}}function TU(){if(!(typeof localStorage>`u`))try{localStorage.removeItem(ze)}catch{}}function EU({children:e,endpoint:t=`/api/language`}){let[n,r]=(0,Q.useState)(()=>Ke()),[i,a]=(0,Q.useState)(!1),o=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(o.current)return;o.current=!0;let e=!1;return(async()=>{try{let n=await fetch(t,{headers:SU()});if(!n.ok)return;let i=await n.json();if(e)return;Fe(i.language)&&i.language!==Ke()&&(await Ze(i.language),wU(i.language),e||r(i.language))}catch{}})(),()=>{e=!0}},[t]);let s=(0,Q.useCallback)(async e=>{if(e===n)return;let i=n,o=typeof localStorage<`u`&&Fe(localStorage.getItem(`specrails-desktop:ui-language`));await Ze(e),wU(e),r(e),a(!0);try{let n=await fetch(t,{method:`PATCH`,headers:SU({"Content-Type":`application/json`}),body:JSON.stringify({language:e})});if(!n.ok)throw Error(`server rejected language: ${n.status}`)}catch(e){throw await Ze(i),o?wU(i):TU(),r(i),e}finally{a(!1)}},[n,t]),c=(0,Q.useMemo)(()=>({languageId:n,language:Xe[n],setLanguage:s,isUpdating:i}),[n,s,i]);return(0,$.jsx)(CU.Provider,{value:c,children:e})}function DU(){return(0,Q.useContext)(CU)}function OU(){let{t:e}=K(`settings`),t=DU();if(!t)return null;let{languageId:n,setLanguage:r,isUpdating:i}=t;async function a(t){if(t!==n)try{await r(t)}catch(t){J.error(e(`language.updateFailed`),{description:t instanceof Error?t.message:void 0})}}return(0,$.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,role:`radiogroup`,"aria-label":e(`language.selectLabel`),children:Re.map(e=>{let t=Xe[e],r=e===n;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,disabled:i,onClick:()=>void a(e),className:`flex items-center justify-between gap-2 rounded-lg border bg-card px-3 py-2 text-left transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/60 disabled:opacity-60 disabled:cursor-not-allowed `+(r?`border-accent-primary ring-1 ring-accent-primary `:`border-border hover:border-accent-primary/40 hover:shadow-md `),"data-testid":`language-card-${e}`,"data-selected":r?`true`:`false`,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-xs font-semibold truncate`,children:t.nativeName}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground truncate`,children:t.englishName})]}),r&&(0,$.jsx)(Ht,{className:`w-3.5 h-3.5 text-accent-primary shrink-0`,"aria-hidden":`true`})]},e)})})}function kU(){let{t:e}=K(`settings`);return DU()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`language.title`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`language.description`)}),(0,$.jsx)(OU,{})]}):null}function AU(){if(!se)return null;let{t:e}=K(`settings`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1;return fetch(`/api/code-explorer-settings`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{e||n(t)}).catch(()=>{e||n({language:`en`,monthlyBudgetUsd:5})}),()=>{e=!0}},[]);async function a(r){if(!t)return;let a={...t,...r};n(a),i(!0);try{let e=await fetch(`/api/code-explorer-settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();n(t)}catch(r){J.error(e(`errors.saveFailed`,{message:r.message})),n(t)}finally{i(!1)}}return t?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`codeSection.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`codeSection.summaryLanguage`)}),(0,$.jsxs)(`select`,{value:t.language,disabled:r,onChange:e=>a({language:e.target.value}),className:`bg-background border border-border rounded px-2 py-1 text-xs`,children:[(0,$.jsx)(`option`,{value:`en`,children:`English`}),(0,$.jsx)(`option`,{value:`es`,children:`Español`})]})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`codeSection.monthlyBudget`)}),(0,$.jsx)(`input`,{type:`number`,min:0,step:.5,value:t.monthlyBudgetUsd,disabled:r,onChange:e=>{let t=parseFloat(e.target.value);!isNaN(t)&&t>=0&&a({monthlyBudgetUsd:t})},className:`bg-background border border-border rounded px-2 py-1 text-xs w-24 text-right`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:e(`codeSection.budgetHelper`)})]})]}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})}var jU=`__default__`,MU={"sr-architect":Yo,"sr-developer":ps,"sr-reviewer":ec};function NU(e){let t=e;return!t||!Array.isArray(t.catalog)||typeof t.settings!=`object`||t.settings===null||typeof t.settings.providers!=`object`||t.settings.providers===null?null:t}function PU(){let{t:e}=K(`settings`),t=gz(),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1;return fetch(`/api/agent-defaults`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{if(e)return;let n=NU(t);n?r(n):a(!0)}).catch(()=>{e||a(!0)}),()=>{e=!0}},[]);async function o(t,i){if(!n)return;let a=n;r({...a,settings:{...a.settings,providers:{...a.settings.providers,[t]:i}}});try{let e=await fetch(`/api/agent-defaults`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providers:{[t]:i}})});if(!e.ok){let t=await e.json().catch(()=>({message:`HTTP ${e.status}`}));throw Error(t.message??`HTTP ${e.status}`)}let n=NU(await e.json());if(!n)throw Error(`unexpected response`);r(n)}catch(t){r(a),J.error(e(`errors.saveFailed`,{message:t.message}))}}return i?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`specrailsAgents.loadFailed`)})]}):n?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`specrailsAgents.description`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:n.catalog.map(e=>(0,$.jsx)(IU,{entry:e,config:n.settings.providers[e.id]??{custom:!1},detected:t.loading||t.detected.includes(e.id),unauthenticated:t.providers[e.id]?.authState===`unauthenticated`,version:t.providers[e.id]?.version,onChange:t=>void o(e.id,t)},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(FU,{t:e}),(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})]})}function FU({t:e}){return(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:[(0,$.jsx)(wo,{className:`h-3.5 w-3.5`}),e(`specrailsAgents.heading`)]})}function IU({entry:e,config:t,detected:n,unauthenticated:r,version:i,onChange:a}){let{t:o}=K(`settings`),s=t.custom===!0,c=s||!!t.pipelineModel||!!t.pipelineEffort||Object.keys(t.agentModels??{}).length>0,l=t.pipelineModel??e.defaultModel,u=e.effortsByModel[l]??[],d=e.models.find(t=>t.value===e.defaultModel)?.label??e.defaultModel,f=(0,Q.useMemo)(()=>[{value:jU,label:o(`specrailsAgents.defaultModel`,{model:d})},...e.models.map(e=>({value:e.value,label:e.label})),...t.pipelineModel&&!e.models.some(e=>e.value===t.pipelineModel)?[{value:t.pipelineModel,label:t.pipelineModel}]:[]],[e.models,t.pipelineModel,d,o]),p=(0,Q.useMemo)(()=>[{value:jU,label:o(`specrailsAgents.defaultEffort`)},...u.map(e=>({value:e,label:e}))],[u,o]);function m(n){let r=t.agentModels?.[n];return[{value:jU,label:o(`specrailsAgents.defaultModel`,{model:d})},...e.models.map(e=>({value:e.value,label:e.label})),...r&&!e.models.some(e=>e.value===r)?[{value:r,label:r}]:[]]}function h(e){a({...t,custom:!0,...e})}function g(e,n){let r={...t.agentModels??{}};n===jU?delete r[e]:r[e]=n,h({agentModels:r})}return(0,$.jsxs)(`div`,{"data-testid":`agent-defaults-card-${e.id}`,className:X(`rounded-lg border transition-colors`,s&&n?`border-accent-primary/45`:`border-border`,!n&&`opacity-60`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5`,children:[(0,$.jsx)(Go,{className:`h-4 w-4 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.displayName}),i&&(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:i}),!n&&(0,$.jsx)(`span`,{className:`rounded-full bg-muted/50 px-1.5 py-px text-[10px] leading-4 text-muted-foreground`,children:o(`specrailsAgents.notDetected`)}),n&&r&&(0,$.jsx)(`span`,{className:`rounded-full bg-accent-warning/15 px-1.5 py-px text-[10px] leading-4 text-accent-warning`,children:o(`specrailsAgents.notSignedIn`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[c&&n&&(0,$.jsx)(`button`,{type:`button`,title:o(`specrailsAgents.reset`),"aria-label":o(`specrailsAgents.reset`),"data-testid":`agent-defaults-reset-${e.id}`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,onClick:()=>a({custom:!1}),children:(0,$.jsx)(Zs,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(LU,{custom:s,disabled:!n,providerId:e.id,onToggle:e=>e?h({}):a({...t,custom:!1})})]})]}),(0,$.jsx)(f_,{initial:!1,children:s&&(0,$.jsx)(fy.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.16,ease:`easeOut`},className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-border/60 px-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:o(`specrailsAgents.pipeline`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(uD,{label:o(`specrailsAgents.model`),value:t.pipelineModel??jU,options:f,icon:un,disabled:!n,testId:`agent-defaults-model-${e.id}`,onSelect:e=>h({pipelineModel:e===jU?void 0:e})}),e.supportsEffort&&u.length>0&&(0,$.jsx)(uD,{label:o(`specrailsAgents.effort`),value:t.pipelineEffort??jU,options:p,icon:ss,disabled:!n,testId:`agent-defaults-effort-${e.id}`,onSelect:e=>h({pipelineEffort:e===jU?void 0:e})})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`specrailsAgents.pipelineHint`)})]}),e.perAgentModels?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:o(`specrailsAgents.agentsTitle`)}),(0,$.jsx)(`div`,{className:`space-y-1`,children:e.baselineAgents.map(r=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/60 px-2.5 py-1.5`,children:[(0,$.jsx)(MU[r]??wo,{className:`h-3.5 w-3.5 shrink-0 text-accent-info`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:o(`specrailsAgents.agentNames.${r}`,{defaultValue:r})}),(0,$.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:r}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(uD,{label:o(`specrailsAgents.model`),value:t.agentModels?.[r]??jU,options:m(r),icon:un,disabled:!n,testId:`agent-defaults-agent-${e.id}-${r}`,onSelect:e=>g(r,e)})})]},r))}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`specrailsAgents.agentsHint`)})]}):(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(vs,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),e.id===`codex`?o(`specrailsAgents.inheritNote`):o(`specrailsAgents.noPerAgentNote`)]})]})},`body`)})]})}function LU({custom:e,disabled:t,providerId:n,onToggle:r}){let{t:i}=K(`settings`),a=`rounded-full px-2.5 py-0.5 text-[10px] font-medium transition-colors disabled:cursor-not-allowed`;return(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-full bg-muted/30 p-0.5`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`agent-defaults-mode-default-${n}`,className:X(a,e?`text-muted-foreground hover:text-foreground`:`bg-surface text-foreground shadow-sm`),onClick:()=>r(!1),children:i(`specrailsAgents.modeDefault`)}),(0,$.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`agent-defaults-mode-custom-${n}`,className:X(a,e?`bg-accent-primary/15 text-accent-primary shadow-sm`:`text-muted-foreground hover:text-foreground`),onClick:()=>r(!0),children:i(`specrailsAgents.modeCustom`)})]})}function RU(){let{t:e}=K(`settings`),{registerHandler:t,unregisterHandler:n}=qe(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(0),f=(0,Q.useRef)(null),p=(0,Q.useCallback)(async()=>{let e=++d.current;try{let t=await fetch(`/api/core-update/status`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return e===d.current?(i(n),u(!1),n.updating||c(null),n):null}catch{return e===d.current&&u(!0),null}},[]);(0,Q.useEffect)(()=>{p();let e=()=>{p()};return window.addEventListener(`focus`,e),()=>{d.current++,window.removeEventListener(`focus`,e)}},[p]);let m=(0,Q.useRef)(p);m.current=p,(0,Q.useEffect)(()=>(t(`core-update`,t=>{let n=t;if(n.type===`framework.updated`){m.current();return}if(n.type!==`core_update.progress`)return;let r=n.phase;c(r),r===`done`?(J.success(e(`coreUpdate.toastDone`,{version:String(n.version??``)})),m.current(),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),2500)):r===`error`&&(J.error(e(`coreUpdate.toastError`,{message:String(n.message??``)})),m.current(),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),4e3))}),()=>{n(`core-update`),f.current&&clearTimeout(f.current)}),[t,n,e]);let h=(0,Q.useCallback)(async()=>{let t=++d.current;o(!0);try{let n=await fetch(`/api/core-update/check`,{method:`POST`});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(t!==d.current)return;i(r),r.updateAvailable||J.success(e(`coreUpdate.toastUpToDate`))}catch(t){J.error(e(`coreUpdate.toastCheckFailed`,{message:t.message}))}finally{o(!1)}},[e]),g=s===`downloading`||s===`materializing`||!!r?.updating;(0,Q.useEffect)(()=>{if(!g)return;let e=setInterval(()=>{p()},1500);return()=>clearInterval(e)},[g,p]);let _=(0,Q.useCallback)(async()=>{c(`downloading`);try{let e=await fetch(`/api/core-update/update`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(e.status!==202){let t=await e.json().catch(()=>({}));throw Error(t.message??`HTTP ${e.status}`)}}catch(t){c(null),J.error(e(`coreUpdate.toastError`,{message:t.message}))}},[e]);if(!r)return l?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{p()},className:`text-xs text-destructive`,children:e(`coreUpdate.loadFailed`)}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`});let v=r.currentVersion??`—`,y=r.pendingVersion??r.latestVersion;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`coreUpdate.heading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:r.available?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-foreground`,children:[e(`coreUpdate.installed`),` `,(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:v})]}),r.runtimeVersion&&(0,$.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[e(`coreUpdate.runtime`,{version:r.runtimeVersion}),r.runtimeSource?` · ${e(`coreUpdate.sources.${r.runtimeSource}`)}`:``]}),r.bundledVersion&&r.bundledVersion!==r.runtimeVersion&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`coreUpdate.bundled`,{version:r.bundledVersion})}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:r.updateAvailable&&r.latestVersion?e(`coreUpdate.updateAvailable`,{version:r.latestVersion}):r.lastCheckedAt?e(`coreUpdate.upToDate`):e(`coreUpdate.neverChecked`)})]}),r.updateAvailable&&y?(0,$.jsxs)(`button`,{type:`button`,onClick:_,disabled:g,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-accent-primary/45 bg-accent-primary/15 px-3 text-[11px] font-semibold text-accent-primary disabled:opacity-50`,children:[g?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(tn,{className:`h-3.5 w-3.5`}),g?e(s===`materializing`?`coreUpdate.materializing`:`coreUpdate.downloading`):r.pendingVersion?e(`coreUpdate.repair`,{version:y}):e(`coreUpdate.update`,{version:y})]}):(0,$.jsxs)(`button`,{type:`button`,onClick:h,disabled:a||g,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,children:[a?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):s===`done`?(0,$.jsx)(Mo,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Js,{className:`h-3.5 w-3.5`}),e(a?`coreUpdate.checking`:`coreUpdate.check`)]})]}),r.runtimeError&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.runtimeError}),r.migrationError&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.migrationError}),l&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-destructive`,onClick:()=>{p()},children:e(`coreUpdate.loadFailed`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:e(`coreUpdate.affectsAll`)})]}):(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`coreUpdate.unavailable`)})})]})}var zU=class extends st{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,t){VU(t);let n=new lt;e&&(n.onmessage=e);let r=await Y(`plugin:updater|download`,{onEvent:n,rid:this.rid,...t});this.downloadedBytes=new st(r)}async install(){if(!this.downloadedBytes)throw Error(`Update.install called before Update.download`);await Y(`plugin:updater|install`,{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(e,t){VU(t);let n=new lt;e&&(n.onmessage=e),await Y(`plugin:updater|download_and_install`,{onEvent:n,rid:this.rid,...t})}async close(){await this.downloadedBytes?.close(),await super.close()}};async function BU(e){VU(e);let t=await Y(`plugin:updater|check`,{...e});return t?new zU(t):null}function VU(e){e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}var HU;(function(e){e.Nsis=`nsis`,e.Msi=`msi`,e.Deb=`deb`,e.Rpm=`rpm`,e.AppImage=`appimage`,e.App=`app`})(HU||={});async function UU(){return Y(`plugin:app|version`)}async function WU(){await Y(`plugin:process|restart`)}var GU=`specrails-desktop:dismissedDesktopUpdateVersion`,KU=`specrails-desktop-desktop-update`,qU=360*60*1e3;function JU(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function YU(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE===`true`}function XU(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE_VERSION||`99.0.0-test`}function ZU(e){return new Promise(t=>setTimeout(t,e))}function QU(){return{currentVersion:`1.40.1`,version:XU(),isMock:!0,async downloadAndInstall(e){e({event:`Started`,data:{contentLength:18874368}});for(let t=0;t<12;t+=1)await ZU(180),e({event:`Progress`,data:{chunkLength:1572864}});e({event:`Finished`})}}}function $U(e){return e<1024*1024?G.t(`commands:update.units.kb`,{value:Math.max(1,Math.round(e/1024))}):G.t(`commands:update.units.mb`,{value:(e/(1024*1024)).toFixed(1)})}function eW(){try{return localStorage.getItem(GU)}catch{return null}}function tW(e){try{localStorage.setItem(GU,e)}catch{}J.dismiss(KU)}function nW(e){switch(e){case`downloading`:return`var(--color-accent-info)`;case`ready`:return`var(--color-accent-success)`;default:return`var(--color-accent-primary)`}}function rW({state:e}){let t=`h-[15px] w-[15px]`;return e===`installing`?(0,$.jsx)(Ro,{className:`${t} u-spin`,"aria-hidden":!0}):e===`ready`?(0,$.jsx)(Ht,{className:`${t} u-check`,"aria-hidden":!0}):e===`error`?(0,$.jsx)(fn,{className:t,"aria-hidden":!0}):(0,$.jsx)(Io,{className:t,"aria-hidden":!0})}function iW({state:e,progress:t}){let n=e===`downloading`&&t!=null,r=e===`installing`||e===`downloading`&&t==null,i=e===`ready`;return(0,$.jsxs)(`div`,{className:`relative h-1.5 w-full overflow-hidden rounded-full border border-border/30 bg-background/70`,children:[n&&(0,$.jsx)(`div`,{className:`relative h-full overflow-hidden rounded-full bg-[color:var(--u-accent)] transition-[width] duration-300 ease-out`,style:{width:`${t}%`},role:`progressbar`,"aria-valuenow":t??0,"aria-valuemin":0,"aria-valuemax":100,children:(0,$.jsx)(`span`,{className:`u-shimmer`,"aria-hidden":!0})}),r&&(0,$.jsx)(`span`,{className:`u-indeterminate`,"aria-hidden":!0}),i&&(0,$.jsx)(`div`,{className:`h-full w-full rounded-full bg-[color:var(--u-accent)]/80`,"aria-hidden":!0})]})}function aW({update:e,onClose:t}){let{t:n}=K(`commands`),[r,i]=(0,Q.useState)(`available`),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null);async function d(){try{i(`downloading`),o(0),c(null),u(null),await e.downloadAndInstall(e=>{if(e.event===`Started`){c(e.data.contentLength??null),o(0);return}if(e.event===`Progress`){o(t=>t+e.data.chunkLength);return}i(`installing`)}),i(`ready`)}catch(e){u(e.message||n(`update.errors.installFailed`)),i(`error`)}}function f(){if(e.isMock){J.success(n(`update.mockReady`),{duration:2500}),J.dismiss(KU),t?.();return}Y(`restart_app`).catch(()=>{WU()})}let p=s&&s>0?Math.min(100,Math.round(a/s*100)):null,m=nW(r),h=r===`downloading`||r===`installing`,g=n(r===`downloading`?`update.title.downloading`:r===`installing`?`update.title.installing`:r===`ready`?`update.title.ready`:r===`error`?`update.title.error`:`update.title.available`),_=r===`available`?n(`update.desc.available`):r===`downloading`?p==null?n(`update.desc.fetching`,{size:$U(a)}):n(`update.desc.progress`,{percent:p,downloaded:$U(a),total:$U(s??0)}):r===`installing`?n(`update.desc.installing`):r===`ready`?n(`update.desc.ready`,{version:e.version}):l&&l.length<=80?l:n(`update.desc.errorFallback`),v=r===`available`?`${e.currentVersion} → ${e.version}`:r===`downloading`?n(`update.pill.downloading`):r===`installing`?n(`update.pill.installing`):r===`ready`?n(`update.pill.ready`):null;return(0,$.jsxs)(`div`,{className:`u-update-card relative flex w-full flex-col gap-2 overflow-hidden`,style:{"--u-accent":m},role:r===`error`?`alert`:`status`,"aria-live":r===`error`?`assertive`:`polite`,"data-state":r,children:[(0,$.jsx)(`span`,{className:`u-glow`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`u-badge grid h-7 w-7 shrink-0 place-items-center rounded-lg border border-border/50 bg-background/60 text-[color:var(--u-accent)]`,"aria-hidden":!0,children:(0,$.jsx)(rW,{state:r})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold leading-tight text-foreground`,children:g}),v!=null&&(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap rounded-md border border-border/40 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground`,style:r===`available`?void 0:{color:`var(--u-accent)`},children:v})]}),(0,$.jsx)(`p`,{className:`h-4 truncate text-[11px] leading-4 text-muted-foreground`,"data-testid":`update-description`,children:_}),(0,$.jsx)(iW,{state:r,progress:p}),(0,$.jsx)(`div`,{className:`flex items-center justify-end gap-1.5`,children:r===`ready`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`inline-grid h-7 min-w-[64px] place-items-center rounded-lg border border-[color:var(--u-accent)]/45 bg-[color:var(--u-accent)]/15 px-3 text-[11px] font-semibold leading-none text-foreground transition-colors hover:bg-[color:var(--u-accent)]/25`,onClick:f,children:n(`update.actions.restart`)}),(0,$.jsx)(`button`,{type:`button`,className:`h-7 rounded-lg px-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground`,onClick:()=>{J.dismiss(KU),t?.()},children:n(`update.actions.later`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`inline-grid h-7 min-w-[64px] place-items-center rounded-lg border border-[color:var(--u-accent)]/45 bg-[color:var(--u-accent)]/15 px-3 text-[11px] font-semibold leading-none text-foreground transition-colors hover:bg-[color:var(--u-accent)]/25 disabled:cursor-not-allowed disabled:opacity-50`,disabled:h,onClick:()=>void d(),children:n(r===`installing`?`update.actions.installing`:r===`error`?`update.actions.tryAgain`:`update.actions.update`)}),(0,$.jsx)(`button`,{type:`button`,className:`h-7 rounded-lg px-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,disabled:h,onClick:()=>{tW(e.version),t?.()},children:n(`update.actions.dismiss`)})]})})]})}function oW(e){J.custom(()=>(0,$.jsx)(aW,{update:e}),{id:KU,duration:1/0,dismissible:!1,unstyled:!0,closeButton:!1})}function sW(){(0,Q.useEffect)(()=>{let e=YU();if(!e&&!JU())return;let t=!1,n={current:!1};async function r(){if(!(t||n.current))try{let r=e?QU():await BU();if(t||!r||eW()===r.version)return;n.current=!0,J.custom(()=>(0,$.jsx)(aW,{update:r,onClose:()=>{n.current=!1}}),{id:KU,duration:1/0,dismissible:!1,unstyled:!0,closeButton:!1,onDismiss:()=>{n.current=!1},onAutoClose:()=>{n.current=!1}})}catch(e){console.warn(`[desktop-update] update check failed:`,e)}}r();let i=setInterval(()=>void r(),qU);return()=>{t=!0,clearInterval(i)}},[])}function cW(){let{t:e}=K(`settings`),t=YU(),n=JU()||t,[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!JU())return;let e=!0;return UU().then(t=>{e&&i(t)}).catch(()=>{}),()=>{e=!1}},[]);let d=(0,Q.useCallback)(async()=>{o(!0),c(null);try{let n=t?QU():await BU();n?(c(`update-available`),u(n.version),oW(n)):(c(`up-to-date`),J.success(e(`appUpdate.toastUpToDate`)))}catch(t){J.error(e(`appUpdate.toastCheckFailed`,{message:t.message}))}finally{o(!1)}},[t,e]);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e(`appUpdate.heading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:n?(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-foreground`,children:[e(`appUpdate.installed`),` `,(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:r??`—`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:s===`update-available`&&l?e(`appUpdate.updateAvailable`,{version:l}):e(s===`up-to-date`?`appUpdate.upToDate`:`appUpdate.autoHint`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void d(),disabled:a,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,children:[a?(0,$.jsx)(rn,{className:`h-3.5 w-3.5 animate-spin`}):s===`up-to-date`?(0,$.jsx)(Mo,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Js,{className:`h-3.5 w-3.5`}),e(a?`appUpdate.checking`:`appUpdate.check`)]})]})}):(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`appUpdate.unavailable`)})})]})}var lW=Object.defineProperty,uW=Object.getOwnPropertySymbols,dW=Object.prototype.hasOwnProperty,fW=Object.prototype.propertyIsEnumerable,pW=(e,t,n)=>t in e?lW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mW=(e,t)=>{for(var n in t||={})dW.call(t,n)&&pW(e,n,t[n]);if(uW)for(var n of uW(t))fW.call(t,n)&&pW(e,n,t[n]);return e},hW=(e,t)=>{var n={};for(var r in e)dW.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&uW)for(var r of uW(e))t.indexOf(r)<0&&fW.call(e,r)&&(n[r]=e[r]);return n},gW;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(gW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(gW||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(gW||={});var _W=gW,vW={L:_W.QrCode.Ecc.LOW,M:_W.QrCode.Ecc.MEDIUM,Q:_W.QrCode.Ecc.QUARTILE,H:_W.QrCode.Ecc.HIGH},yW=128,bW=`L`,xW=`#FFFFFF`,SW=`#000000`,CW=!1,wW=1,TW=4,EW=0,DW=.1;function OW(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function kW(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function AW(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*DW),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function jW(e,t){return t==null?e?TW:EW:Math.max(Math.floor(t),0)}function MW({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Q.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(..._W.QrSegment.makeSegments(t)),e),[]);return _W.QrCode.encodeSegments(r,vW[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Q.useMemo(()=>{let e=c.getModules(),t=jW(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:AW(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var NW=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),PW=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=yW,level:a=bW,bgColor:o=xW,fgColor:s=SW,includeMargin:c=CW,minVersion:l=wW,boostLevel:u,marginSize:d,imageSettings:f}=n,p=hW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=hW(p,[`style`]),g=f?.src,_=Q.useRef(null),v=Q.useRef(null),y=Q.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Q.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=MW({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Q.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=kW(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,NW?t.fill(new Path2D(OW(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Q.useEffect(()=>{x(!1)},[g]);let E=mW({height:i,width:i},m),D=null;return g!=null&&(D=Q.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Q.createElement(Q.Fragment,null,Q.createElement(`canvas`,mW({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});PW.displayName=`QRCodeCanvas`;var FW=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=yW,level:a=bW,bgColor:o=xW,fgColor:s=SW,includeMargin:c=CW,minVersion:l=wW,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=hW(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=MW({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=kW(g,v.excavation)),b=Q.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=OW(y,h);return Q.createElement(`svg`,mW({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Q.createElement(`title`,null,d),Q.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Q.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});FW.displayName=`QRCodeSVG`;var IW=e(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.jsQR=r():n.jsQR=r()})(typeof self<`u`?self:e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=3)})([(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.BitMatrix=function(){function e(e,t){this.width=t,this.height=e.length/t,this.data=e}return e.createEmpty=function(t,n){return new e(new Uint8ClampedArray(t*n),t)},e.prototype.get=function(e,t){return e<0||e>=this.width||t<0||t>=this.height?!1:!!this.data[t*this.width+e]},e.prototype.set=function(e,t,n){this.data[t*this.width+e]=+!!n},e.prototype.setRegion=function(e,t,n,r,i){for(var a=t;a<t+r;a++)for(var o=e;o<e+n;o++)this.set(o,a,!!i)},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(2);function i(e,t){return e^t}t.addOrSubtractGF=i,t.default=function(){function e(e,t,n){this.primitive=e,this.size=t,this.generatorBase=n,this.expTable=Array(this.size),this.logTable=Array(this.size);for(var i=1,a=0;a<this.size;a++)this.expTable[a]=i,i*=2,i>=this.size&&(i=(i^this.primitive)&this.size-1);for(var a=0;a<this.size-1;a++)this.logTable[this.expTable[a]]=a;this.zero=new r.default(this,Uint8ClampedArray.from([0])),this.one=new r.default(this,Uint8ClampedArray.from([1]))}return e.prototype.multiply=function(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.size-1)]},e.prototype.inverse=function(e){if(e===0)throw Error(`Can't invert 0`);return this.expTable[this.size-this.logTable[e]-1]},e.prototype.buildMonomial=function(e,t){if(e<0)throw Error(`Invalid monomial degree less than 0`);if(t===0)return this.zero;var n=new Uint8ClampedArray(e+1);return n[0]=t,new r.default(this,n)},e.prototype.log=function(e){if(e===0)throw Error(`Can't take log(0)`);return this.logTable[e]},e.prototype.exp=function(e){return this.expTable[e]},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);t.default=function(){function e(e,t){if(t.length===0)throw Error(`No coefficients.`);this.field=e;var n=t.length;if(n>1&&t[0]===0){for(var r=1;r<n&&t[r]===0;)r++;if(r===n)this.coefficients=e.zero.coefficients;else{this.coefficients=new Uint8ClampedArray(n-r);for(var i=0;i<this.coefficients.length;i++)this.coefficients[i]=t[r+i]}}else this.coefficients=t}return e.prototype.degree=function(){return this.coefficients.length-1},e.prototype.isZero=function(){return this.coefficients[0]===0},e.prototype.getCoefficient=function(e){return this.coefficients[this.coefficients.length-1-e]},e.prototype.addOrSubtract=function(t){var n;if(this.isZero())return t;if(t.isZero())return this;var i=this.coefficients,a=t.coefficients;i.length>a.length&&(n=[a,i],i=n[0],a=n[1]);for(var o=new Uint8ClampedArray(a.length),s=a.length-i.length,c=0;c<s;c++)o[c]=a[c];for(var c=s;c<a.length;c++)o[c]=r.addOrSubtractGF(i[c-s],a[c]);return new e(this.field,o)},e.prototype.multiply=function(t){if(t===0)return this.field.zero;if(t===1)return this;for(var n=this.coefficients.length,r=new Uint8ClampedArray(n),i=0;i<n;i++)r[i]=this.field.multiply(this.coefficients[i],t);return new e(this.field,r)},e.prototype.multiplyPoly=function(t){if(this.isZero()||t.isZero())return this.field.zero;for(var n=this.coefficients,i=n.length,a=t.coefficients,o=a.length,s=new Uint8ClampedArray(i+o-1),c=0;c<i;c++)for(var l=n[c],u=0;u<o;u++)s[c+u]=r.addOrSubtractGF(s[c+u],this.field.multiply(l,a[u]));return new e(this.field,s)},e.prototype.multiplyByMonomial=function(t,n){if(t<0)throw Error(`Invalid degree less than 0`);if(n===0)return this.field.zero;for(var r=this.coefficients.length,i=new Uint8ClampedArray(r+t),a=0;a<r;a++)i[a]=this.field.multiply(this.coefficients[a],n);return new e(this.field,i)},e.prototype.evaluateAt=function(e){var t=0;if(e===0)return this.getCoefficient(0);var n=this.coefficients.length;if(e===1)return this.coefficients.forEach(function(e){t=r.addOrSubtractGF(t,e)}),t;t=this.coefficients[0];for(var i=1;i<n;i++)t=r.addOrSubtractGF(this.field.multiply(e,t),this.coefficients[i]);return t},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(4),i=n(5),a=n(11),o=n(12);function s(e){var t=o.locate(e);if(!t)return null;for(var n=0,r=t;n<r.length;n++){var s=r[n],c=a.extract(e,s),l=i.decode(c.matrix);if(l)return{binaryData:l.bytes,data:l.text,chunks:l.chunks,version:l.version,location:{topRightCorner:c.mappingFunction(s.dimension,0),topLeftCorner:c.mappingFunction(0,0),bottomRightCorner:c.mappingFunction(s.dimension,s.dimension),bottomLeftCorner:c.mappingFunction(0,s.dimension),topRightFinderPattern:s.topRight,topLeftFinderPattern:s.topLeft,bottomLeftFinderPattern:s.bottomLeft,bottomRightAlignmentPattern:s.alignmentPattern}}}return null}var c={inversionAttempts:`attemptBoth`};function l(e,t,n,i){i===void 0&&(i={});var a=c;Object.keys(a||{}).forEach(function(e){a[e]=i[e]||a[e]});var o=a.inversionAttempts===`attemptBoth`||a.inversionAttempts===`invertFirst`,l=a.inversionAttempts===`onlyInvert`||a.inversionAttempts===`invertFirst`,u=r.binarize(e,t,n,o),d=u.binarized,f=u.inverted,p=s(l?f:d);return!p&&(a.inversionAttempts===`attemptBoth`||a.inversionAttempts===`invertFirst`)&&(p=s(l?d:f)),p}l.default=l,t.default=l}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=8,a=24;function o(e,t,n){return e<t?t:e>n?n:e}var s=function(){function e(e,t){this.width=e,this.data=new Uint8ClampedArray(e*t)}return e.prototype.get=function(e,t){return this.data[t*this.width+e]},e.prototype.set=function(e,t,n){this.data[t*this.width+e]=n},e}();function c(e,t,n,c){if(e.length!==t*n*4)throw Error(`Malformed data passed to binarizer.`);for(var l=new s(t,n),u=0;u<t;u++)for(var d=0;d<n;d++){var f=e[(d*t+u)*4+0],p=e[(d*t+u)*4+1],m=e[(d*t+u)*4+2];l.set(u,d,.2126*f+.7152*p+.0722*m)}for(var h=Math.ceil(t/i),g=Math.ceil(n/i),_=new s(h,g),v=0;v<g;v++)for(var y=0;y<h;y++){for(var b=0,x=1/0,S=0,d=0;d<i;d++)for(var u=0;u<i;u++){var C=l.get(y*i+u,v*i+d);b+=C,x=Math.min(x,C),S=Math.max(S,C)}var w=b/i**2;if(S-x<=a&&(w=x/2,v>0&&y>0)){var T=(_.get(y,v-1)+2*_.get(y-1,v)+_.get(y-1,v-1))/4;x<T&&(w=T)}_.set(y,v,w)}var E=r.BitMatrix.createEmpty(t,n),D=null;c&&(D=r.BitMatrix.createEmpty(t,n));for(var v=0;v<g;v++)for(var y=0;y<h;y++){for(var O=o(y,2,h-3),k=o(v,2,g-3),b=0,A=-2;A<=2;A++)for(var j=-2;j<=2;j++)b+=_.get(O+A,k+j);for(var M=b/25,A=0;A<i;A++)for(var j=0;j<i;j++){var u=y*i+A,d=v*i+j,N=l.get(u,d);E.set(u,d,N<=M),c&&D.set(u,d,!(N<=M))}}return c?{binarized:E,inverted:D}:{binarized:E}}t.binarize=c}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(6),a=n(9),o=n(10);function s(e,t){for(var n=e^t,r=0;n;)r++,n&=n-1;return r}function c(e,t){return t<<1|e}var l=[{bits:21522,formatInfo:{errorCorrectionLevel:1,dataMask:0}},{bits:20773,formatInfo:{errorCorrectionLevel:1,dataMask:1}},{bits:24188,formatInfo:{errorCorrectionLevel:1,dataMask:2}},{bits:23371,formatInfo:{errorCorrectionLevel:1,dataMask:3}},{bits:17913,formatInfo:{errorCorrectionLevel:1,dataMask:4}},{bits:16590,formatInfo:{errorCorrectionLevel:1,dataMask:5}},{bits:20375,formatInfo:{errorCorrectionLevel:1,dataMask:6}},{bits:19104,formatInfo:{errorCorrectionLevel:1,dataMask:7}},{bits:30660,formatInfo:{errorCorrectionLevel:0,dataMask:0}},{bits:29427,formatInfo:{errorCorrectionLevel:0,dataMask:1}},{bits:32170,formatInfo:{errorCorrectionLevel:0,dataMask:2}},{bits:30877,formatInfo:{errorCorrectionLevel:0,dataMask:3}},{bits:26159,formatInfo:{errorCorrectionLevel:0,dataMask:4}},{bits:25368,formatInfo:{errorCorrectionLevel:0,dataMask:5}},{bits:27713,formatInfo:{errorCorrectionLevel:0,dataMask:6}},{bits:26998,formatInfo:{errorCorrectionLevel:0,dataMask:7}},{bits:5769,formatInfo:{errorCorrectionLevel:3,dataMask:0}},{bits:5054,formatInfo:{errorCorrectionLevel:3,dataMask:1}},{bits:7399,formatInfo:{errorCorrectionLevel:3,dataMask:2}},{bits:6608,formatInfo:{errorCorrectionLevel:3,dataMask:3}},{bits:1890,formatInfo:{errorCorrectionLevel:3,dataMask:4}},{bits:597,formatInfo:{errorCorrectionLevel:3,dataMask:5}},{bits:3340,formatInfo:{errorCorrectionLevel:3,dataMask:6}},{bits:2107,formatInfo:{errorCorrectionLevel:3,dataMask:7}},{bits:13663,formatInfo:{errorCorrectionLevel:2,dataMask:0}},{bits:12392,formatInfo:{errorCorrectionLevel:2,dataMask:1}},{bits:16177,formatInfo:{errorCorrectionLevel:2,dataMask:2}},{bits:14854,formatInfo:{errorCorrectionLevel:2,dataMask:3}},{bits:9396,formatInfo:{errorCorrectionLevel:2,dataMask:4}},{bits:8579,formatInfo:{errorCorrectionLevel:2,dataMask:5}},{bits:11994,formatInfo:{errorCorrectionLevel:2,dataMask:6}},{bits:11245,formatInfo:{errorCorrectionLevel:2,dataMask:7}}],u=[function(e){return(e.y+e.x)%2==0},function(e){return e.y%2==0},function(e){return e.x%3==0},function(e){return(e.y+e.x)%3==0},function(e){return(Math.floor(e.y/2)+Math.floor(e.x/3))%2==0},function(e){return e.x*e.y%2+e.x*e.y%3==0},function(e){return(e.y*e.x%2+e.y*e.x%3)%2==0},function(e){return((e.y+e.x)%2+e.y*e.x%3)%2==0}];function d(e){var t=17+4*e.versionNumber,n=r.BitMatrix.createEmpty(t,t);n.setRegion(0,0,9,9,!0),n.setRegion(t-8,0,8,9,!0),n.setRegion(0,t-8,9,8,!0);for(var i=0,a=e.alignmentPatternCenters;i<a.length;i++)for(var o=a[i],s=0,c=e.alignmentPatternCenters;s<c.length;s++){var l=c[s];o===6&&l===6||o===6&&l===t-7||o===t-7&&l===6||n.setRegion(o-2,l-2,5,5,!0)}return n.setRegion(6,9,1,t-17,!0),n.setRegion(9,6,t-17,1,!0),e.versionNumber>6&&(n.setRegion(t-11,0,3,6,!0),n.setRegion(0,t-11,6,3,!0)),n}function f(e,t,n){for(var r=u[n.dataMask],i=e.height,a=d(t),o=[],s=0,l=0,f=!0,p=i-1;p>0;p-=2){p===6&&p--;for(var m=0;m<i;m++)for(var h=f?i-1-m:m,g=0;g<2;g++){var _=p-g;if(!a.get(_,h)){l++;var v=e.get(_,h);r({y:h,x:_})&&(v=!v),s=c(v,s),l===8&&(o.push(s),l=0,s=0)}}f=!f}return o}function p(e){var t=e.height,n=Math.floor((t-17)/4);if(n<=6)return o.VERSIONS[n-1];for(var r=0,i=5;i>=0;i--)for(var a=t-9;a>=t-11;a--)r=c(e.get(a,i),r);for(var l=0,a=5;a>=0;a--)for(var i=t-9;i>=t-11;i--)l=c(e.get(a,i),l);for(var u=1/0,d,f=0,p=o.VERSIONS;f<p.length;f++){var m=p[f];if(m.infoBits===r||m.infoBits===l)return m;var h=s(r,m.infoBits);h<u&&(d=m,u=h),h=s(l,m.infoBits),h<u&&(d=m,u=h)}if(u<=3)return d}function m(e){for(var t=0,n=0;n<=8;n++)n!==6&&(t=c(e.get(n,8),t));for(var r=7;r>=0;r--)r!==6&&(t=c(e.get(8,r),t));for(var i=e.height,a=0,r=i-1;r>=i-7;r--)a=c(e.get(8,r),a);for(var n=i-8;n<i;n++)a=c(e.get(n,8),a);for(var o=1/0,u=null,d=0,f=l;d<f.length;d++){var p=f[d],m=p.bits,h=p.formatInfo;if(m===t||m===a)return h;var g=s(t,m);g<o&&(u=h,o=g),t!==a&&(g=s(a,m),g<o&&(u=h,o=g))}return o<=3?u:null}function h(e,t,n){var r=t.errorCorrectionLevels[n],i=[],a=0;if(r.ecBlocks.forEach(function(e){for(var t=0;t<e.numBlocks;t++)i.push({numDataCodewords:e.dataCodewordsPerBlock,codewords:[]}),a+=e.dataCodewordsPerBlock+r.ecCodewordsPerBlock}),e.length<a)return null;e=e.slice(0,a);for(var o=r.ecBlocks[0].dataCodewordsPerBlock,s=0;s<o;s++)for(var c=0,l=i;c<l.length;c++){var u=l[c];u.codewords.push(e.shift())}if(r.ecBlocks.length>1)for(var d=r.ecBlocks[0].numBlocks,f=r.ecBlocks[1].numBlocks,s=0;s<f;s++)i[d+s].codewords.push(e.shift());for(;e.length>0;)for(var p=0,m=i;p<m.length;p++){var u=m[p];u.codewords.push(e.shift())}return i}function g(e){var t=p(e);if(!t)return null;var n=m(e);if(!n)return null;var r=h(f(e,t,n),t,n.errorCorrectionLevel);if(!r)return null;for(var o=r.reduce(function(e,t){return e+t.numDataCodewords},0),s=new Uint8ClampedArray(o),c=0,l=0,u=r;l<u.length;l++){var d=u[l],g=a.decode(d.codewords,d.codewords.length-d.numDataCodewords);if(!g)return null;for(var _=0;_<d.numDataCodewords;_++)s[c++]=g[_]}try{return i.decode(s,t.versionNumber)}catch{return null}}function _(e){if(e==null)return null;var t=g(e);if(t)return t;for(var n=0;n<e.width;n++)for(var r=n+1;r<e.height;r++)e.get(n,r)!==e.get(r,n)&&(e.set(n,r,!e.get(n,r)),e.set(r,n,!e.get(r,n)));return g(e)}t.decode=_}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(8),a;(function(e){e.Numeric=`numeric`,e.Alphanumeric=`alphanumeric`,e.Byte=`byte`,e.Kanji=`kanji`,e.ECI=`eci`})(a=t.Mode||={});var o;(function(e){e[e.Terminator=0]=`Terminator`,e[e.Numeric=1]=`Numeric`,e[e.Alphanumeric=2]=`Alphanumeric`,e[e.Byte=4]=`Byte`,e[e.Kanji=8]=`Kanji`,e[e.ECI=7]=`ECI`})(o||={});function s(e,t){for(var n=[],r=``,i=[10,12,14][t],a=e.readBits(i);a>=3;){var o=e.readBits(10);if(o>=1e3)throw Error(`Invalid numeric value above 999`);var s=Math.floor(o/100),c=Math.floor(o/10)%10,l=o%10;n.push(48+s,48+c,48+l),r+=s.toString()+c.toString()+l.toString(),a-=3}if(a===2){var o=e.readBits(7);if(o>=100)throw Error(`Invalid numeric value above 99`);var s=Math.floor(o/10),c=o%10;n.push(48+s,48+c),r+=s.toString()+c.toString()}else if(a===1){var o=e.readBits(4);if(o>=10)throw Error(`Invalid numeric value above 9`);n.push(48+o),r+=o.toString()}return{bytes:n,text:r}}var c=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function l(e,t){for(var n=[],r=``,i=[9,11,13][t],a=e.readBits(i);a>=2;){var o=e.readBits(11),s=Math.floor(o/45),l=o%45;n.push(c[s].charCodeAt(0),c[l].charCodeAt(0)),r+=c[s]+c[l],a-=2}if(a===1){var s=e.readBits(6);n.push(c[s].charCodeAt(0)),r+=c[s]}return{bytes:n,text:r}}function u(e,t){for(var n=[],r=``,i=[8,16,16][t],a=e.readBits(i),o=0;o<a;o++){var s=e.readBits(8);n.push(s)}try{r+=decodeURIComponent(n.map(function(e){return`%`+(`0`+e.toString(16)).substr(-2)}).join(``))}catch{}return{bytes:n,text:r}}function d(e,t){for(var n=[],r=``,a=[8,10,12][t],o=e.readBits(a),s=0;s<o;s++){var c=e.readBits(13),l=Math.floor(c/192)<<8|c%192;l<7936?l+=33088:l+=49472,n.push(l>>8,l&255),r+=String.fromCharCode(i.shiftJISTable[l])}return{bytes:n,text:r}}function f(e,t){for(var n,i,c,f,p=new r.BitStream(e),m=t<=9?0:t<=26?1:2,h={text:``,bytes:[],chunks:[],version:t};p.available()>=4;){var g=p.readBits(4);if(g===o.Terminator)return h;if(g===o.ECI)p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(7)}):p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(14)}):p.readBits(1)===0?h.chunks.push({type:a.ECI,assignmentNumber:p.readBits(21)}):h.chunks.push({type:a.ECI,assignmentNumber:-1});else if(g===o.Numeric){var _=s(p,m);h.text+=_.text,(n=h.bytes).push.apply(n,_.bytes),h.chunks.push({type:a.Numeric,text:_.text})}else if(g===o.Alphanumeric){var v=l(p,m);h.text+=v.text,(i=h.bytes).push.apply(i,v.bytes),h.chunks.push({type:a.Alphanumeric,text:v.text})}else if(g===o.Byte){var y=u(p,m);h.text+=y.text,(c=h.bytes).push.apply(c,y.bytes),h.chunks.push({type:a.Byte,bytes:y.bytes,text:y.text})}else if(g===o.Kanji){var b=d(p,m);h.text+=b.text,(f=h.bytes).push.apply(f,b.bytes),h.chunks.push({type:a.Kanji,bytes:b.bytes,text:b.text})}}if(p.available()===0||p.readBits(p.available())===0)return h}t.decode=f}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.BitStream=function(){function e(e){this.byteOffset=0,this.bitOffset=0,this.bytes=e}return e.prototype.readBits=function(e){if(e<1||e>32||e>this.available())throw Error(`Cannot read `+e.toString()+` bits`);var t=0;if(this.bitOffset>0){var n=8-this.bitOffset,r=e<n?e:n,i=n-r,a=255>>8-r<<i;t=(this.bytes[this.byteOffset]&a)>>i,e-=r,this.bitOffset+=r,this.bitOffset===8&&(this.bitOffset=0,this.byteOffset++)}if(e>0){for(;e>=8;)t=t<<8|this.bytes[this.byteOffset]&255,this.byteOffset++,e-=8;if(e>0){var i=8-e,a=255>>i<<i;t=t<<e|(this.bytes[this.byteOffset]&a)>>i,this.bitOffset+=e}}return t},e.prototype.available=function(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset},e}()}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.shiftJISTable={32:32,33:33,34:34,35:35,36:36,37:37,38:38,39:39,40:40,41:41,42:42,43:43,44:44,45:45,46:46,47:47,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,58:58,59:59,60:60,61:61,62:62,63:63,64:64,65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,91:91,92:165,93:93,94:94,95:95,96:96,97:97,98:98,99:99,100:100,101:101,102:102,103:103,104:104,105:105,106:106,107:107,108:108,109:109,110:110,111:111,112:112,113:113,114:114,115:115,116:116,117:117,118:118,119:119,120:120,121:121,122:122,123:123,124:124,125:125,126:8254,33088:12288,33089:12289,33090:12290,33091:65292,33092:65294,33093:12539,33094:65306,33095:65307,33096:65311,33097:65281,33098:12443,33099:12444,33100:180,33101:65344,33102:168,33103:65342,33104:65507,33105:65343,33106:12541,33107:12542,33108:12445,33109:12446,33110:12291,33111:20189,33112:12293,33113:12294,33114:12295,33115:12540,33116:8213,33117:8208,33118:65295,33119:92,33120:12316,33121:8214,33122:65372,33123:8230,33124:8229,33125:8216,33126:8217,33127:8220,33128:8221,33129:65288,33130:65289,33131:12308,33132:12309,33133:65339,33134:65341,33135:65371,33136:65373,33137:12296,33138:12297,33139:12298,33140:12299,33141:12300,33142:12301,33143:12302,33144:12303,33145:12304,33146:12305,33147:65291,33148:8722,33149:177,33150:215,33152:247,33153:65309,33154:8800,33155:65308,33156:65310,33157:8806,33158:8807,33159:8734,33160:8756,33161:9794,33162:9792,33163:176,33164:8242,33165:8243,33166:8451,33167:65509,33168:65284,33169:162,33170:163,33171:65285,33172:65283,33173:65286,33174:65290,33175:65312,33176:167,33177:9734,33178:9733,33179:9675,33180:9679,33181:9678,33182:9671,33183:9670,33184:9633,33185:9632,33186:9651,33187:9650,33188:9661,33189:9660,33190:8251,33191:12306,33192:8594,33193:8592,33194:8593,33195:8595,33196:12307,33208:8712,33209:8715,33210:8838,33211:8839,33212:8834,33213:8835,33214:8746,33215:8745,33224:8743,33225:8744,33226:172,33227:8658,33228:8660,33229:8704,33230:8707,33242:8736,33243:8869,33244:8978,33245:8706,33246:8711,33247:8801,33248:8786,33249:8810,33250:8811,33251:8730,33252:8765,33253:8733,33254:8757,33255:8747,33256:8748,33264:8491,33265:8240,33266:9839,33267:9837,33268:9834,33269:8224,33270:8225,33271:182,33276:9711,33359:65296,33360:65297,33361:65298,33362:65299,33363:65300,33364:65301,33365:65302,33366:65303,33367:65304,33368:65305,33376:65313,33377:65314,33378:65315,33379:65316,33380:65317,33381:65318,33382:65319,33383:65320,33384:65321,33385:65322,33386:65323,33387:65324,33388:65325,33389:65326,33390:65327,33391:65328,33392:65329,33393:65330,33394:65331,33395:65332,33396:65333,33397:65334,33398:65335,33399:65336,33400:65337,33401:65338,33409:65345,33410:65346,33411:65347,33412:65348,33413:65349,33414:65350,33415:65351,33416:65352,33417:65353,33418:65354,33419:65355,33420:65356,33421:65357,33422:65358,33423:65359,33424:65360,33425:65361,33426:65362,33427:65363,33428:65364,33429:65365,33430:65366,33431:65367,33432:65368,33433:65369,33434:65370,33439:12353,33440:12354,33441:12355,33442:12356,33443:12357,33444:12358,33445:12359,33446:12360,33447:12361,33448:12362,33449:12363,33450:12364,33451:12365,33452:12366,33453:12367,33454:12368,33455:12369,33456:12370,33457:12371,33458:12372,33459:12373,33460:12374,33461:12375,33462:12376,33463:12377,33464:12378,33465:12379,33466:12380,33467:12381,33468:12382,33469:12383,33470:12384,33471:12385,33472:12386,33473:12387,33474:12388,33475:12389,33476:12390,33477:12391,33478:12392,33479:12393,33480:12394,33481:12395,33482:12396,33483:12397,33484:12398,33485:12399,33486:12400,33487:12401,33488:12402,33489:12403,33490:12404,33491:12405,33492:12406,33493:12407,33494:12408,33495:12409,33496:12410,33497:12411,33498:12412,33499:12413,33500:12414,33501:12415,33502:12416,33503:12417,33504:12418,33505:12419,33506:12420,33507:12421,33508:12422,33509:12423,33510:12424,33511:12425,33512:12426,33513:12427,33514:12428,33515:12429,33516:12430,33517:12431,33518:12432,33519:12433,33520:12434,33521:12435,33600:12449,33601:12450,33602:12451,33603:12452,33604:12453,33605:12454,33606:12455,33607:12456,33608:12457,33609:12458,33610:12459,33611:12460,33612:12461,33613:12462,33614:12463,33615:12464,33616:12465,33617:12466,33618:12467,33619:12468,33620:12469,33621:12470,33622:12471,33623:12472,33624:12473,33625:12474,33626:12475,33627:12476,33628:12477,33629:12478,33630:12479,33631:12480,33632:12481,33633:12482,33634:12483,33635:12484,33636:12485,33637:12486,33638:12487,33639:12488,33640:12489,33641:12490,33642:12491,33643:12492,33644:12493,33645:12494,33646:12495,33647:12496,33648:12497,33649:12498,33650:12499,33651:12500,33652:12501,33653:12502,33654:12503,33655:12504,33656:12505,33657:12506,33658:12507,33659:12508,33660:12509,33661:12510,33662:12511,33664:12512,33665:12513,33666:12514,33667:12515,33668:12516,33669:12517,33670:12518,33671:12519,33672:12520,33673:12521,33674:12522,33675:12523,33676:12524,33677:12525,33678:12526,33679:12527,33680:12528,33681:12529,33682:12530,33683:12531,33684:12532,33685:12533,33686:12534,33695:913,33696:914,33697:915,33698:916,33699:917,33700:918,33701:919,33702:920,33703:921,33704:922,33705:923,33706:924,33707:925,33708:926,33709:927,33710:928,33711:929,33712:931,33713:932,33714:933,33715:934,33716:935,33717:936,33718:937,33727:945,33728:946,33729:947,33730:948,33731:949,33732:950,33733:951,33734:952,33735:953,33736:954,33737:955,33738:956,33739:957,33740:958,33741:959,33742:960,33743:961,33744:963,33745:964,33746:965,33747:966,33748:967,33749:968,33750:969,33856:1040,33857:1041,33858:1042,33859:1043,33860:1044,33861:1045,33862:1025,33863:1046,33864:1047,33865:1048,33866:1049,33867:1050,33868:1051,33869:1052,33870:1053,33871:1054,33872:1055,33873:1056,33874:1057,33875:1058,33876:1059,33877:1060,33878:1061,33879:1062,33880:1063,33881:1064,33882:1065,33883:1066,33884:1067,33885:1068,33886:1069,33887:1070,33888:1071,33904:1072,33905:1073,33906:1074,33907:1075,33908:1076,33909:1077,33910:1105,33911:1078,33912:1079,33913:1080,33914:1081,33915:1082,33916:1083,33917:1084,33918:1085,33920:1086,33921:1087,33922:1088,33923:1089,33924:1090,33925:1091,33926:1092,33927:1093,33928:1094,33929:1095,33930:1096,33931:1097,33932:1098,33933:1099,33934:1100,33935:1101,33936:1102,33937:1103,33951:9472,33952:9474,33953:9484,33954:9488,33955:9496,33956:9492,33957:9500,33958:9516,33959:9508,33960:9524,33961:9532,33962:9473,33963:9475,33964:9487,33965:9491,33966:9499,33967:9495,33968:9507,33969:9523,33970:9515,33971:9531,33972:9547,33973:9504,33974:9519,33975:9512,33976:9527,33977:9535,33978:9501,33979:9520,33980:9509,33981:9528,33982:9538,34975:20124,34976:21782,34977:23043,34978:38463,34979:21696,34980:24859,34981:25384,34982:23030,34983:36898,34984:33909,34985:33564,34986:31312,34987:24746,34988:25569,34989:28197,34990:26093,34991:33894,34992:33446,34993:39925,34994:26771,34995:22311,34996:26017,34997:25201,34998:23451,34999:22992,35e3:34427,35001:39156,35002:32098,35003:32190,35004:39822,35005:25110,35006:31903,35007:34999,35008:23433,35009:24245,35010:25353,35011:26263,35012:26696,35013:38343,35014:38797,35015:26447,35016:20197,35017:20234,35018:20301,35019:20381,35020:20553,35021:22258,35022:22839,35023:22996,35024:23041,35025:23561,35026:24799,35027:24847,35028:24944,35029:26131,35030:26885,35031:28858,35032:30031,35033:30064,35034:31227,35035:32173,35036:32239,35037:32963,35038:33806,35039:34915,35040:35586,35041:36949,35042:36986,35043:21307,35044:20117,35045:20133,35046:22495,35047:32946,35048:37057,35049:30959,35050:19968,35051:22769,35052:28322,35053:36920,35054:31282,35055:33576,35056:33419,35057:39983,35058:20801,35059:21360,35060:21693,35061:21729,35062:22240,35063:23035,35064:24341,35065:39154,35066:28139,35067:32996,35068:34093,35136:38498,35137:38512,35138:38560,35139:38907,35140:21515,35141:21491,35142:23431,35143:28879,35144:32701,35145:36802,35146:38632,35147:21359,35148:40284,35149:31418,35150:19985,35151:30867,35152:33276,35153:28198,35154:22040,35155:21764,35156:27421,35157:34074,35158:39995,35159:23013,35160:21417,35161:28006,35162:29916,35163:38287,35164:22082,35165:20113,35166:36939,35167:38642,35168:33615,35169:39180,35170:21473,35171:21942,35172:23344,35173:24433,35174:26144,35175:26355,35176:26628,35177:27704,35178:27891,35179:27945,35180:29787,35181:30408,35182:31310,35183:38964,35184:33521,35185:34907,35186:35424,35187:37613,35188:28082,35189:30123,35190:30410,35191:39365,35192:24742,35193:35585,35194:36234,35195:38322,35196:27022,35197:21421,35198:20870,35200:22290,35201:22576,35202:22852,35203:23476,35204:24310,35205:24616,35206:25513,35207:25588,35208:27839,35209:28436,35210:28814,35211:28948,35212:29017,35213:29141,35214:29503,35215:32257,35216:33398,35217:33489,35218:34199,35219:36960,35220:37467,35221:40219,35222:22633,35223:26044,35224:27738,35225:29989,35226:20985,35227:22830,35228:22885,35229:24448,35230:24540,35231:25276,35232:26106,35233:27178,35234:27431,35235:27572,35236:29579,35237:32705,35238:35158,35239:40236,35240:40206,35241:40644,35242:23713,35243:27798,35244:33659,35245:20740,35246:23627,35247:25014,35248:33222,35249:26742,35250:29281,35251:20057,35252:20474,35253:21368,35254:24681,35255:28201,35256:31311,35257:38899,35258:19979,35259:21270,35260:20206,35261:20309,35262:20285,35263:20385,35264:20339,35265:21152,35266:21487,35267:22025,35268:22799,35269:23233,35270:23478,35271:23521,35272:31185,35273:26247,35274:26524,35275:26550,35276:27468,35277:27827,35278:28779,35279:29634,35280:31117,35281:31166,35282:31292,35283:31623,35284:33457,35285:33499,35286:33540,35287:33655,35288:33775,35289:33747,35290:34662,35291:35506,35292:22057,35293:36008,35294:36838,35295:36942,35296:38686,35297:34442,35298:20420,35299:23784,35300:25105,35301:29273,35302:30011,35303:33253,35304:33469,35305:34558,35306:36032,35307:38597,35308:39187,35309:39381,35310:20171,35311:20250,35312:35299,35313:22238,35314:22602,35315:22730,35316:24315,35317:24555,35318:24618,35319:24724,35320:24674,35321:25040,35322:25106,35323:25296,35324:25913,35392:39745,35393:26214,35394:26800,35395:28023,35396:28784,35397:30028,35398:30342,35399:32117,35400:33445,35401:34809,35402:38283,35403:38542,35404:35997,35405:20977,35406:21182,35407:22806,35408:21683,35409:23475,35410:23830,35411:24936,35412:27010,35413:28079,35414:30861,35415:33995,35416:34903,35417:35442,35418:37799,35419:39608,35420:28012,35421:39336,35422:34521,35423:22435,35424:26623,35425:34510,35426:37390,35427:21123,35428:22151,35429:21508,35430:24275,35431:25313,35432:25785,35433:26684,35434:26680,35435:27579,35436:29554,35437:30906,35438:31339,35439:35226,35440:35282,35441:36203,35442:36611,35443:37101,35444:38307,35445:38548,35446:38761,35447:23398,35448:23731,35449:27005,35450:38989,35451:38990,35452:25499,35453:31520,35454:27179,35456:27263,35457:26806,35458:39949,35459:28511,35460:21106,35461:21917,35462:24688,35463:25324,35464:27963,35465:28167,35466:28369,35467:33883,35468:35088,35469:36676,35470:19988,35471:39993,35472:21494,35473:26907,35474:27194,35475:38788,35476:26666,35477:20828,35478:31427,35479:33970,35480:37340,35481:37772,35482:22107,35483:40232,35484:26658,35485:33541,35486:33841,35487:31909,35488:21e3,35489:33477,35490:29926,35491:20094,35492:20355,35493:20896,35494:23506,35495:21002,35496:21208,35497:21223,35498:24059,35499:21914,35500:22570,35501:23014,35502:23436,35503:23448,35504:23515,35505:24178,35506:24185,35507:24739,35508:24863,35509:24931,35510:25022,35511:25563,35512:25954,35513:26577,35514:26707,35515:26874,35516:27454,35517:27475,35518:27735,35519:28450,35520:28567,35521:28485,35522:29872,35523:29976,35524:30435,35525:30475,35526:31487,35527:31649,35528:31777,35529:32233,35530:32566,35531:32752,35532:32925,35533:33382,35534:33694,35535:35251,35536:35532,35537:36011,35538:36996,35539:37969,35540:38291,35541:38289,35542:38306,35543:38501,35544:38867,35545:39208,35546:33304,35547:20024,35548:21547,35549:23736,35550:24012,35551:29609,35552:30284,35553:30524,35554:23721,35555:32747,35556:36107,35557:38593,35558:38929,35559:38996,35560:39e3,35561:20225,35562:20238,35563:21361,35564:21916,35565:22120,35566:22522,35567:22855,35568:23305,35569:23492,35570:23696,35571:24076,35572:24190,35573:24524,35574:25582,35575:26426,35576:26071,35577:26082,35578:26399,35579:26827,35580:26820,35648:27231,35649:24112,35650:27589,35651:27671,35652:27773,35653:30079,35654:31048,35655:23395,35656:31232,35657:32e3,35658:24509,35659:35215,35660:35352,35661:36020,35662:36215,35663:36556,35664:36637,35665:39138,35666:39438,35667:39740,35668:20096,35669:20605,35670:20736,35671:22931,35672:23452,35673:25135,35674:25216,35675:25836,35676:27450,35677:29344,35678:30097,35679:31047,35680:32681,35681:34811,35682:35516,35683:35696,35684:25516,35685:33738,35686:38816,35687:21513,35688:21507,35689:21931,35690:26708,35691:27224,35692:35440,35693:30759,35694:26485,35695:40653,35696:21364,35697:23458,35698:33050,35699:34384,35700:36870,35701:19992,35702:20037,35703:20167,35704:20241,35705:21450,35706:21560,35707:23470,35708:24339,35709:24613,35710:25937,35712:26429,35713:27714,35714:27762,35715:27875,35716:28792,35717:29699,35718:31350,35719:31406,35720:31496,35721:32026,35722:31998,35723:32102,35724:26087,35725:29275,35726:21435,35727:23621,35728:24040,35729:25298,35730:25312,35731:25369,35732:28192,35733:34394,35734:35377,35735:36317,35736:37624,35737:28417,35738:31142,35739:39770,35740:20136,35741:20139,35742:20140,35743:20379,35744:20384,35745:20689,35746:20807,35747:31478,35748:20849,35749:20982,35750:21332,35751:21281,35752:21375,35753:21483,35754:21932,35755:22659,35756:23777,35757:24375,35758:24394,35759:24623,35760:24656,35761:24685,35762:25375,35763:25945,35764:27211,35765:27841,35766:29378,35767:29421,35768:30703,35769:33016,35770:33029,35771:33288,35772:34126,35773:37111,35774:37857,35775:38911,35776:39255,35777:39514,35778:20208,35779:20957,35780:23597,35781:26241,35782:26989,35783:23616,35784:26354,35785:26997,35786:29577,35787:26704,35788:31873,35789:20677,35790:21220,35791:22343,35792:24062,35793:37670,35794:26020,35795:27427,35796:27453,35797:29748,35798:31105,35799:31165,35800:31563,35801:32202,35802:33465,35803:33740,35804:34943,35805:35167,35806:35641,35807:36817,35808:37329,35809:21535,35810:37504,35811:20061,35812:20534,35813:21477,35814:21306,35815:29399,35816:29590,35817:30697,35818:33510,35819:36527,35820:39366,35821:39368,35822:39378,35823:20855,35824:24858,35825:34398,35826:21936,35827:31354,35828:20598,35829:23507,35830:36935,35831:38533,35832:20018,35833:27355,35834:37351,35835:23633,35836:23624,35904:25496,35905:31391,35906:27795,35907:38772,35908:36705,35909:31402,35910:29066,35911:38536,35912:31874,35913:26647,35914:32368,35915:26705,35916:37740,35917:21234,35918:21531,35919:34219,35920:35347,35921:32676,35922:36557,35923:37089,35924:21350,35925:34952,35926:31041,35927:20418,35928:20670,35929:21009,35930:20804,35931:21843,35932:22317,35933:29674,35934:22411,35935:22865,35936:24418,35937:24452,35938:24693,35939:24950,35940:24935,35941:25001,35942:25522,35943:25658,35944:25964,35945:26223,35946:26690,35947:28179,35948:30054,35949:31293,35950:31995,35951:32076,35952:32153,35953:32331,35954:32619,35955:33550,35956:33610,35957:34509,35958:35336,35959:35427,35960:35686,35961:36605,35962:38938,35963:40335,35964:33464,35965:36814,35966:39912,35968:21127,35969:25119,35970:25731,35971:28608,35972:38553,35973:26689,35974:20625,35975:27424,35976:27770,35977:28500,35978:31348,35979:32080,35980:34880,35981:35363,35982:26376,35983:20214,35984:20537,35985:20518,35986:20581,35987:20860,35988:21048,35989:21091,35990:21927,35991:22287,35992:22533,35993:23244,35994:24314,35995:25010,35996:25080,35997:25331,35998:25458,35999:26908,36e3:27177,36001:29309,36002:29356,36003:29486,36004:30740,36005:30831,36006:32121,36007:30476,36008:32937,36009:35211,36010:35609,36011:36066,36012:36562,36013:36963,36014:37749,36015:38522,36016:38997,36017:39443,36018:40568,36019:20803,36020:21407,36021:21427,36022:24187,36023:24358,36024:28187,36025:28304,36026:29572,36027:29694,36028:32067,36029:33335,36030:35328,36031:35578,36032:38480,36033:20046,36034:20491,36035:21476,36036:21628,36037:22266,36038:22993,36039:23396,36040:24049,36041:24235,36042:24359,36043:25144,36044:25925,36045:26543,36046:28246,36047:29392,36048:31946,36049:34996,36050:32929,36051:32993,36052:33776,36053:34382,36054:35463,36055:36328,36056:37431,36057:38599,36058:39015,36059:40723,36060:20116,36061:20114,36062:20237,36063:21320,36064:21577,36065:21566,36066:23087,36067:24460,36068:24481,36069:24735,36070:26791,36071:27278,36072:29786,36073:30849,36074:35486,36075:35492,36076:35703,36077:37264,36078:20062,36079:39881,36080:20132,36081:20348,36082:20399,36083:20505,36084:20502,36085:20809,36086:20844,36087:21151,36088:21177,36089:21246,36090:21402,36091:21475,36092:21521,36160:21518,36161:21897,36162:22353,36163:22434,36164:22909,36165:23380,36166:23389,36167:23439,36168:24037,36169:24039,36170:24055,36171:24184,36172:24195,36173:24218,36174:24247,36175:24344,36176:24658,36177:24908,36178:25239,36179:25304,36180:25511,36181:25915,36182:26114,36183:26179,36184:26356,36185:26477,36186:26657,36187:26775,36188:27083,36189:27743,36190:27946,36191:28009,36192:28207,36193:28317,36194:30002,36195:30343,36196:30828,36197:31295,36198:31968,36199:32005,36200:32024,36201:32094,36202:32177,36203:32789,36204:32771,36205:32943,36206:32945,36207:33108,36208:33167,36209:33322,36210:33618,36211:34892,36212:34913,36213:35611,36214:36002,36215:36092,36216:37066,36217:37237,36218:37489,36219:30783,36220:37628,36221:38308,36222:38477,36224:38917,36225:39321,36226:39640,36227:40251,36228:21083,36229:21163,36230:21495,36231:21512,36232:22741,36233:25335,36234:28640,36235:35946,36236:36703,36237:40633,36238:20811,36239:21051,36240:21578,36241:22269,36242:31296,36243:37239,36244:40288,36245:40658,36246:29508,36247:28425,36248:33136,36249:29969,36250:24573,36251:24794,36252:39592,36253:29403,36254:36796,36255:27492,36256:38915,36257:20170,36258:22256,36259:22372,36260:22718,36261:23130,36262:24680,36263:25031,36264:26127,36265:26118,36266:26681,36267:26801,36268:28151,36269:30165,36270:32058,36271:33390,36272:39746,36273:20123,36274:20304,36275:21449,36276:21766,36277:23919,36278:24038,36279:24046,36280:26619,36281:27801,36282:29811,36283:30722,36284:35408,36285:37782,36286:35039,36287:22352,36288:24231,36289:25387,36290:20661,36291:20652,36292:20877,36293:26368,36294:21705,36295:22622,36296:22971,36297:23472,36298:24425,36299:25165,36300:25505,36301:26685,36302:27507,36303:28168,36304:28797,36305:37319,36306:29312,36307:30741,36308:30758,36309:31085,36310:25998,36311:32048,36312:33756,36313:35009,36314:36617,36315:38555,36316:21092,36317:22312,36318:26448,36319:32618,36320:36001,36321:20916,36322:22338,36323:38442,36324:22586,36325:27018,36326:32948,36327:21682,36328:23822,36329:22524,36330:30869,36331:40442,36332:20316,36333:21066,36334:21643,36335:25662,36336:26152,36337:26388,36338:26613,36339:31364,36340:31574,36341:32034,36342:37679,36343:26716,36344:39853,36345:31545,36346:21273,36347:20874,36348:21047,36416:23519,36417:25334,36418:25774,36419:25830,36420:26413,36421:27578,36422:34217,36423:38609,36424:30352,36425:39894,36426:25420,36427:37638,36428:39851,36429:30399,36430:26194,36431:19977,36432:20632,36433:21442,36434:23665,36435:24808,36436:25746,36437:25955,36438:26719,36439:29158,36440:29642,36441:29987,36442:31639,36443:32386,36444:34453,36445:35715,36446:36059,36447:37240,36448:39184,36449:26028,36450:26283,36451:27531,36452:20181,36453:20180,36454:20282,36455:20351,36456:21050,36457:21496,36458:21490,36459:21987,36460:22235,36461:22763,36462:22987,36463:22985,36464:23039,36465:23376,36466:23629,36467:24066,36468:24107,36469:24535,36470:24605,36471:25351,36472:25903,36473:23388,36474:26031,36475:26045,36476:26088,36477:26525,36478:27490,36480:27515,36481:27663,36482:29509,36483:31049,36484:31169,36485:31992,36486:32025,36487:32043,36488:32930,36489:33026,36490:33267,36491:35222,36492:35422,36493:35433,36494:35430,36495:35468,36496:35566,36497:36039,36498:36060,36499:38604,36500:39164,36501:27503,36502:20107,36503:20284,36504:20365,36505:20816,36506:23383,36507:23546,36508:24904,36509:25345,36510:26178,36511:27425,36512:28363,36513:27835,36514:29246,36515:29885,36516:30164,36517:30913,36518:31034,36519:32780,36520:32819,36521:33258,36522:33940,36523:36766,36524:27728,36525:40575,36526:24335,36527:35672,36528:40235,36529:31482,36530:36600,36531:23437,36532:38635,36533:19971,36534:21489,36535:22519,36536:22833,36537:23241,36538:23460,36539:24713,36540:28287,36541:28422,36542:30142,36543:36074,36544:23455,36545:34048,36546:31712,36547:20594,36548:26612,36549:33437,36550:23649,36551:34122,36552:32286,36553:33294,36554:20889,36555:23556,36556:25448,36557:36198,36558:26012,36559:29038,36560:31038,36561:32023,36562:32773,36563:35613,36564:36554,36565:36974,36566:34503,36567:37034,36568:20511,36569:21242,36570:23610,36571:26451,36572:28796,36573:29237,36574:37196,36575:37320,36576:37675,36577:33509,36578:23490,36579:24369,36580:24825,36581:20027,36582:21462,36583:23432,36584:25163,36585:26417,36586:27530,36587:29417,36588:29664,36589:31278,36590:33131,36591:36259,36592:37202,36593:39318,36594:20754,36595:21463,36596:21610,36597:23551,36598:25480,36599:27193,36600:32172,36601:38656,36602:22234,36603:21454,36604:21608,36672:23447,36673:23601,36674:24030,36675:20462,36676:24833,36677:25342,36678:27954,36679:31168,36680:31179,36681:32066,36682:32333,36683:32722,36684:33261,36685:33311,36686:33936,36687:34886,36688:35186,36689:35728,36690:36468,36691:36655,36692:36913,36693:37195,36694:37228,36695:38598,36696:37276,36697:20160,36698:20303,36699:20805,36700:21313,36701:24467,36702:25102,36703:26580,36704:27713,36705:28171,36706:29539,36707:32294,36708:37325,36709:37507,36710:21460,36711:22809,36712:23487,36713:28113,36714:31069,36715:32302,36716:31899,36717:22654,36718:29087,36719:20986,36720:34899,36721:36848,36722:20426,36723:23803,36724:26149,36725:30636,36726:31459,36727:33308,36728:39423,36729:20934,36730:24490,36731:26092,36732:26991,36733:27529,36734:28147,36736:28310,36737:28516,36738:30462,36739:32020,36740:24033,36741:36981,36742:37255,36743:38918,36744:20966,36745:21021,36746:25152,36747:26257,36748:26329,36749:28186,36750:24246,36751:32210,36752:32626,36753:26360,36754:34223,36755:34295,36756:35576,36757:21161,36758:21465,36759:22899,36760:24207,36761:24464,36762:24661,36763:37604,36764:38500,36765:20663,36766:20767,36767:21213,36768:21280,36769:21319,36770:21484,36771:21736,36772:21830,36773:21809,36774:22039,36775:22888,36776:22974,36777:23100,36778:23477,36779:23558,36780:23567,36781:23569,36782:23578,36783:24196,36784:24202,36785:24288,36786:24432,36787:25215,36788:25220,36789:25307,36790:25484,36791:25463,36792:26119,36793:26124,36794:26157,36795:26230,36796:26494,36797:26786,36798:27167,36799:27189,36800:27836,36801:28040,36802:28169,36803:28248,36804:28988,36805:28966,36806:29031,36807:30151,36808:30465,36809:30813,36810:30977,36811:31077,36812:31216,36813:31456,36814:31505,36815:31911,36816:32057,36817:32918,36818:33750,36819:33931,36820:34121,36821:34909,36822:35059,36823:35359,36824:35388,36825:35412,36826:35443,36827:35937,36828:36062,36829:37284,36830:37478,36831:37758,36832:37912,36833:38556,36834:38808,36835:19978,36836:19976,36837:19998,36838:20055,36839:20887,36840:21104,36841:22478,36842:22580,36843:22732,36844:23330,36845:24120,36846:24773,36847:25854,36848:26465,36849:26454,36850:27972,36851:29366,36852:30067,36853:31331,36854:33976,36855:35698,36856:37304,36857:37664,36858:22065,36859:22516,36860:39166,36928:25325,36929:26893,36930:27542,36931:29165,36932:32340,36933:32887,36934:33394,36935:35302,36936:39135,36937:34645,36938:36785,36939:23611,36940:20280,36941:20449,36942:20405,36943:21767,36944:23072,36945:23517,36946:23529,36947:24515,36948:24910,36949:25391,36950:26032,36951:26187,36952:26862,36953:27035,36954:28024,36955:28145,36956:30003,36957:30137,36958:30495,36959:31070,36960:31206,36961:32051,36962:33251,36963:33455,36964:34218,36965:35242,36966:35386,36967:36523,36968:36763,36969:36914,36970:37341,36971:38663,36972:20154,36973:20161,36974:20995,36975:22645,36976:22764,36977:23563,36978:29978,36979:23613,36980:33102,36981:35338,36982:36805,36983:38499,36984:38765,36985:31525,36986:35535,36987:38920,36988:37218,36989:22259,36990:21416,36992:36887,36993:21561,36994:22402,36995:24101,36996:25512,36997:27700,36998:28810,36999:30561,37e3:31883,37001:32736,37002:34928,37003:36930,37004:37204,37005:37648,37006:37656,37007:38543,37008:29790,37009:39620,37010:23815,37011:23913,37012:25968,37013:26530,37014:36264,37015:38619,37016:25454,37017:26441,37018:26905,37019:33733,37020:38935,37021:38592,37022:35070,37023:28548,37024:25722,37025:23544,37026:19990,37027:28716,37028:30045,37029:26159,37030:20932,37031:21046,37032:21218,37033:22995,37034:24449,37035:24615,37036:25104,37037:25919,37038:25972,37039:26143,37040:26228,37041:26866,37042:26646,37043:27491,37044:28165,37045:29298,37046:29983,37047:30427,37048:31934,37049:32854,37050:22768,37051:35069,37052:35199,37053:35488,37054:35475,37055:35531,37056:36893,37057:37266,37058:38738,37059:38745,37060:25993,37061:31246,37062:33030,37063:38587,37064:24109,37065:24796,37066:25114,37067:26021,37068:26132,37069:26512,37070:30707,37071:31309,37072:31821,37073:32318,37074:33034,37075:36012,37076:36196,37077:36321,37078:36447,37079:30889,37080:20999,37081:25305,37082:25509,37083:25666,37084:25240,37085:35373,37086:31363,37087:31680,37088:35500,37089:38634,37090:32118,37091:33292,37092:34633,37093:20185,37094:20808,37095:21315,37096:21344,37097:23459,37098:23554,37099:23574,37100:24029,37101:25126,37102:25159,37103:25776,37104:26643,37105:26676,37106:27849,37107:27973,37108:27927,37109:26579,37110:28508,37111:29006,37112:29053,37113:26059,37114:31359,37115:31661,37116:32218,37184:32330,37185:32680,37186:33146,37187:33307,37188:33337,37189:34214,37190:35438,37191:36046,37192:36341,37193:36984,37194:36983,37195:37549,37196:37521,37197:38275,37198:39854,37199:21069,37200:21892,37201:28472,37202:28982,37203:20840,37204:31109,37205:32341,37206:33203,37207:31950,37208:22092,37209:22609,37210:23720,37211:25514,37212:26366,37213:26365,37214:26970,37215:29401,37216:30095,37217:30094,37218:30990,37219:31062,37220:31199,37221:31895,37222:32032,37223:32068,37224:34311,37225:35380,37226:38459,37227:36961,37228:40736,37229:20711,37230:21109,37231:21452,37232:21474,37233:20489,37234:21930,37235:22766,37236:22863,37237:29245,37238:23435,37239:23652,37240:21277,37241:24803,37242:24819,37243:25436,37244:25475,37245:25407,37246:25531,37248:25805,37249:26089,37250:26361,37251:24035,37252:27085,37253:27133,37254:28437,37255:29157,37256:20105,37257:30185,37258:30456,37259:31379,37260:31967,37261:32207,37262:32156,37263:32865,37264:33609,37265:33624,37266:33900,37267:33980,37268:34299,37269:35013,37270:36208,37271:36865,37272:36973,37273:37783,37274:38684,37275:39442,37276:20687,37277:22679,37278:24974,37279:33235,37280:34101,37281:36104,37282:36896,37283:20419,37284:20596,37285:21063,37286:21363,37287:24687,37288:25417,37289:26463,37290:28204,37291:36275,37292:36895,37293:20439,37294:23646,37295:36042,37296:26063,37297:32154,37298:21330,37299:34966,37300:20854,37301:25539,37302:23384,37303:23403,37304:23562,37305:25613,37306:26449,37307:36956,37308:20182,37309:22810,37310:22826,37311:27760,37312:35409,37313:21822,37314:22549,37315:22949,37316:24816,37317:25171,37318:26561,37319:33333,37320:26965,37321:38464,37322:39364,37323:39464,37324:20307,37325:22534,37326:23550,37327:32784,37328:23729,37329:24111,37330:24453,37331:24608,37332:24907,37333:25140,37334:26367,37335:27888,37336:28382,37337:32974,37338:33151,37339:33492,37340:34955,37341:36024,37342:36864,37343:36910,37344:38538,37345:40667,37346:39899,37347:20195,37348:21488,37349:22823,37350:31532,37351:37261,37352:38988,37353:40441,37354:28381,37355:28711,37356:21331,37357:21828,37358:23429,37359:25176,37360:25246,37361:25299,37362:27810,37363:28655,37364:29730,37365:35351,37366:37944,37367:28609,37368:35582,37369:33592,37370:20967,37371:34552,37372:21482,37440:21481,37441:20294,37442:36948,37443:36784,37444:22890,37445:33073,37446:24061,37447:31466,37448:36799,37449:26842,37450:35895,37451:29432,37452:40008,37453:27197,37454:35504,37455:20025,37456:21336,37457:22022,37458:22374,37459:25285,37460:25506,37461:26086,37462:27470,37463:28129,37464:28251,37465:28845,37466:30701,37467:31471,37468:31658,37469:32187,37470:32829,37471:32966,37472:34507,37473:35477,37474:37723,37475:22243,37476:22727,37477:24382,37478:26029,37479:26262,37480:27264,37481:27573,37482:30007,37483:35527,37484:20516,37485:30693,37486:22320,37487:24347,37488:24677,37489:26234,37490:27744,37491:30196,37492:31258,37493:32622,37494:33268,37495:34584,37496:36933,37497:39347,37498:31689,37499:30044,37500:31481,37501:31569,37502:33988,37504:36880,37505:31209,37506:31378,37507:33590,37508:23265,37509:30528,37510:20013,37511:20210,37512:23449,37513:24544,37514:25277,37515:26172,37516:26609,37517:27880,37518:34411,37519:34935,37520:35387,37521:37198,37522:37619,37523:39376,37524:27159,37525:28710,37526:29482,37527:33511,37528:33879,37529:36015,37530:19969,37531:20806,37532:20939,37533:21899,37534:23541,37535:24086,37536:24115,37537:24193,37538:24340,37539:24373,37540:24427,37541:24500,37542:25074,37543:25361,37544:26274,37545:26397,37546:28526,37547:29266,37548:30010,37549:30522,37550:32884,37551:33081,37552:33144,37553:34678,37554:35519,37555:35548,37556:36229,37557:36339,37558:37530,37559:38263,37560:38914,37561:40165,37562:21189,37563:25431,37564:30452,37565:26389,37566:27784,37567:29645,37568:36035,37569:37806,37570:38515,37571:27941,37572:22684,37573:26894,37574:27084,37575:36861,37576:37786,37577:30171,37578:36890,37579:22618,37580:26626,37581:25524,37582:27131,37583:20291,37584:28460,37585:26584,37586:36795,37587:34086,37588:32180,37589:37716,37590:26943,37591:28528,37592:22378,37593:22775,37594:23340,37595:32044,37596:29226,37597:21514,37598:37347,37599:40372,37600:20141,37601:20302,37602:20572,37603:20597,37604:21059,37605:35998,37606:21576,37607:22564,37608:23450,37609:24093,37610:24213,37611:24237,37612:24311,37613:24351,37614:24716,37615:25269,37616:25402,37617:25552,37618:26799,37619:27712,37620:30855,37621:31118,37622:31243,37623:32224,37624:33351,37625:35330,37626:35558,37627:36420,37628:36883,37696:37048,37697:37165,37698:37336,37699:40718,37700:27877,37701:25688,37702:25826,37703:25973,37704:28404,37705:30340,37706:31515,37707:36969,37708:37841,37709:28346,37710:21746,37711:24505,37712:25764,37713:36685,37714:36845,37715:37444,37716:20856,37717:22635,37718:22825,37719:23637,37720:24215,37721:28155,37722:32399,37723:29980,37724:36028,37725:36578,37726:39003,37727:28857,37728:20253,37729:27583,37730:28593,37731:3e4,37732:38651,37733:20814,37734:21520,37735:22581,37736:22615,37737:22956,37738:23648,37739:24466,37740:26007,37741:26460,37742:28193,37743:30331,37744:33759,37745:36077,37746:36884,37747:37117,37748:37709,37749:30757,37750:30778,37751:21162,37752:24230,37753:22303,37754:22900,37755:24594,37756:20498,37757:20826,37758:20908,37760:20941,37761:20992,37762:21776,37763:22612,37764:22616,37765:22871,37766:23445,37767:23798,37768:23947,37769:24764,37770:25237,37771:25645,37772:26481,37773:26691,37774:26812,37775:26847,37776:30423,37777:28120,37778:28271,37779:28059,37780:28783,37781:29128,37782:24403,37783:30168,37784:31095,37785:31561,37786:31572,37787:31570,37788:31958,37789:32113,37790:21040,37791:33891,37792:34153,37793:34276,37794:35342,37795:35588,37796:35910,37797:36367,37798:36867,37799:36879,37800:37913,37801:38518,37802:38957,37803:39472,37804:38360,37805:20685,37806:21205,37807:21516,37808:22530,37809:23566,37810:24999,37811:25758,37812:27934,37813:30643,37814:31461,37815:33012,37816:33796,37817:36947,37818:37509,37819:23776,37820:40199,37821:21311,37822:24471,37823:24499,37824:28060,37825:29305,37826:30563,37827:31167,37828:31716,37829:27602,37830:29420,37831:35501,37832:26627,37833:27233,37834:20984,37835:31361,37836:26932,37837:23626,37838:40182,37839:33515,37840:23493,37841:37193,37842:28702,37843:22136,37844:23663,37845:24775,37846:25958,37847:27788,37848:35930,37849:36929,37850:38931,37851:21585,37852:26311,37853:37389,37854:22856,37855:37027,37856:20869,37857:20045,37858:20970,37859:34201,37860:35598,37861:28760,37862:25466,37863:37707,37864:26978,37865:39348,37866:32260,37867:30071,37868:21335,37869:26976,37870:36575,37871:38627,37872:27741,37873:20108,37874:23612,37875:24336,37876:36841,37877:21250,37878:36049,37879:32905,37880:34425,37881:24319,37882:26085,37883:20083,37884:20837,37952:22914,37953:23615,37954:38894,37955:20219,37956:22922,37957:24525,37958:35469,37959:28641,37960:31152,37961:31074,37962:23527,37963:33905,37964:29483,37965:29105,37966:24180,37967:24565,37968:25467,37969:25754,37970:29123,37971:31896,37972:20035,37973:24316,37974:20043,37975:22492,37976:22178,37977:24745,37978:28611,37979:32013,37980:33021,37981:33075,37982:33215,37983:36786,37984:35223,37985:34468,37986:24052,37987:25226,37988:25773,37989:35207,37990:26487,37991:27874,37992:27966,37993:29750,37994:30772,37995:23110,37996:32629,37997:33453,37998:39340,37999:20467,38e3:24259,38001:25309,38002:25490,38003:25943,38004:26479,38005:30403,38006:29260,38007:32972,38008:32954,38009:36649,38010:37197,38011:20493,38012:22521,38013:23186,38014:26757,38016:26995,38017:29028,38018:29437,38019:36023,38020:22770,38021:36064,38022:38506,38023:36889,38024:34687,38025:31204,38026:30695,38027:33833,38028:20271,38029:21093,38030:21338,38031:25293,38032:26575,38033:27850,38034:30333,38035:31636,38036:31893,38037:33334,38038:34180,38039:36843,38040:26333,38041:28448,38042:29190,38043:32283,38044:33707,38045:39361,38046:40614,38047:20989,38048:31665,38049:30834,38050:31672,38051:32903,38052:31560,38053:27368,38054:24161,38055:32908,38056:30033,38057:30048,38058:20843,38059:37474,38060:28300,38061:30330,38062:37271,38063:39658,38064:20240,38065:32624,38066:25244,38067:31567,38068:38309,38069:40169,38070:22138,38071:22617,38072:34532,38073:38588,38074:20276,38075:21028,38076:21322,38077:21453,38078:21467,38079:24070,38080:25644,38081:26001,38082:26495,38083:27710,38084:27726,38085:29256,38086:29359,38087:29677,38088:30036,38089:32321,38090:33324,38091:34281,38092:36009,38093:31684,38094:37318,38095:29033,38096:38930,38097:39151,38098:25405,38099:26217,38100:30058,38101:30436,38102:30928,38103:34115,38104:34542,38105:21290,38106:21329,38107:21542,38108:22915,38109:24199,38110:24444,38111:24754,38112:25161,38113:25209,38114:25259,38115:26e3,38116:27604,38117:27852,38118:30130,38119:30382,38120:30865,38121:31192,38122:32203,38123:32631,38124:32933,38125:34987,38126:35513,38127:36027,38128:36991,38129:38750,38130:39131,38131:27147,38132:31800,38133:20633,38134:23614,38135:24494,38136:26503,38137:27608,38138:29749,38139:30473,38140:32654,38208:40763,38209:26570,38210:31255,38211:21305,38212:30091,38213:39661,38214:24422,38215:33181,38216:33777,38217:32920,38218:24380,38219:24517,38220:30050,38221:31558,38222:36924,38223:26727,38224:23019,38225:23195,38226:32016,38227:30334,38228:35628,38229:20469,38230:24426,38231:27161,38232:27703,38233:28418,38234:29922,38235:31080,38236:34920,38237:35413,38238:35961,38239:24287,38240:25551,38241:30149,38242:31186,38243:33495,38244:37672,38245:37618,38246:33948,38247:34541,38248:39981,38249:21697,38250:24428,38251:25996,38252:27996,38253:28693,38254:36007,38255:36051,38256:38971,38257:25935,38258:29942,38259:19981,38260:20184,38261:22496,38262:22827,38263:23142,38264:23500,38265:20904,38266:24067,38267:24220,38268:24598,38269:25206,38270:25975,38272:26023,38273:26222,38274:28014,38275:29238,38276:31526,38277:33104,38278:33178,38279:33433,38280:35676,38281:36e3,38282:36070,38283:36212,38284:38428,38285:38468,38286:20398,38287:25771,38288:27494,38289:33310,38290:33889,38291:34154,38292:37096,38293:23553,38294:26963,38295:39080,38296:33914,38297:34135,38298:20239,38299:21103,38300:24489,38301:24133,38302:26381,38303:31119,38304:33145,38305:35079,38306:35206,38307:28149,38308:24343,38309:25173,38310:27832,38311:20175,38312:29289,38313:39826,38314:20998,38315:21563,38316:22132,38317:22707,38318:24996,38319:25198,38320:28954,38321:22894,38322:31881,38323:31966,38324:32027,38325:38640,38326:25991,38327:32862,38328:19993,38329:20341,38330:20853,38331:22592,38332:24163,38333:24179,38334:24330,38335:26564,38336:20006,38337:34109,38338:38281,38339:38491,38340:31859,38341:38913,38342:20731,38343:22721,38344:30294,38345:30887,38346:21029,38347:30629,38348:34065,38349:31622,38350:20559,38351:22793,38352:29255,38353:31687,38354:32232,38355:36794,38356:36820,38357:36941,38358:20415,38359:21193,38360:23081,38361:24321,38362:38829,38363:20445,38364:33303,38365:37610,38366:22275,38367:25429,38368:27497,38369:29995,38370:35036,38371:36628,38372:31298,38373:21215,38374:22675,38375:24917,38376:25098,38377:26286,38378:27597,38379:31807,38380:33769,38381:20515,38382:20472,38383:21253,38384:21574,38385:22577,38386:22857,38387:23453,38388:23792,38389:23791,38390:23849,38391:24214,38392:25265,38393:25447,38394:25918,38395:26041,38396:26379,38464:27861,38465:27873,38466:28921,38467:30770,38468:32299,38469:32990,38470:33459,38471:33804,38472:34028,38473:34562,38474:35090,38475:35370,38476:35914,38477:37030,38478:37586,38479:39165,38480:40179,38481:40300,38482:20047,38483:20129,38484:20621,38485:21078,38486:22346,38487:22952,38488:24125,38489:24536,38490:24537,38491:25151,38492:26292,38493:26395,38494:26576,38495:26834,38496:20882,38497:32033,38498:32938,38499:33192,38500:35584,38501:35980,38502:36031,38503:37502,38504:38450,38505:21536,38506:38956,38507:21271,38508:20693,38509:21340,38510:22696,38511:25778,38512:26420,38513:29287,38514:30566,38515:31302,38516:37350,38517:21187,38518:27809,38519:27526,38520:22528,38521:24140,38522:22868,38523:26412,38524:32763,38525:20961,38526:30406,38528:25705,38529:30952,38530:39764,38531:40635,38532:22475,38533:22969,38534:26151,38535:26522,38536:27598,38537:21737,38538:27097,38539:24149,38540:33180,38541:26517,38542:39850,38543:26622,38544:40018,38545:26717,38546:20134,38547:20451,38548:21448,38549:25273,38550:26411,38551:27819,38552:36804,38553:20397,38554:32365,38555:40639,38556:19975,38557:24930,38558:28288,38559:28459,38560:34067,38561:21619,38562:26410,38563:39749,38564:24051,38565:31637,38566:23724,38567:23494,38568:34588,38569:28234,38570:34001,38571:31252,38572:33032,38573:22937,38574:31885,38575:27665,38576:30496,38577:21209,38578:22818,38579:28961,38580:29279,38581:30683,38582:38695,38583:40289,38584:26891,38585:23167,38586:23064,38587:20901,38588:21517,38589:21629,38590:26126,38591:30431,38592:36855,38593:37528,38594:40180,38595:23018,38596:29277,38597:28357,38598:20813,38599:26825,38600:32191,38601:32236,38602:38754,38603:40634,38604:25720,38605:27169,38606:33538,38607:22916,38608:23391,38609:27611,38610:29467,38611:30450,38612:32178,38613:32791,38614:33945,38615:20786,38616:26408,38617:40665,38618:30446,38619:26466,38620:21247,38621:39173,38622:23588,38623:25147,38624:31870,38625:36016,38626:21839,38627:24758,38628:32011,38629:38272,38630:21249,38631:20063,38632:20918,38633:22812,38634:29242,38635:32822,38636:37326,38637:24357,38638:30690,38639:21380,38640:24441,38641:32004,38642:34220,38643:35379,38644:36493,38645:38742,38646:26611,38647:34222,38648:37971,38649:24841,38650:24840,38651:27833,38652:30290,38720:35565,38721:36664,38722:21807,38723:20305,38724:20778,38725:21191,38726:21451,38727:23461,38728:24189,38729:24736,38730:24962,38731:25558,38732:26377,38733:26586,38734:28263,38735:28044,38736:29494,38737:29495,38738:30001,38739:31056,38740:35029,38741:35480,38742:36938,38743:37009,38744:37109,38745:38596,38746:34701,38747:22805,38748:20104,38749:20313,38750:19982,38751:35465,38752:36671,38753:38928,38754:20653,38755:24188,38756:22934,38757:23481,38758:24248,38759:25562,38760:25594,38761:25793,38762:26332,38763:26954,38764:27096,38765:27915,38766:28342,38767:29076,38768:29992,38769:31407,38770:32650,38771:32768,38772:33865,38773:33993,38774:35201,38775:35617,38776:36362,38777:36965,38778:38525,38779:39178,38780:24958,38781:25233,38782:27442,38784:27779,38785:28020,38786:32716,38787:32764,38788:28096,38789:32645,38790:34746,38791:35064,38792:26469,38793:33713,38794:38972,38795:38647,38796:27931,38797:32097,38798:33853,38799:37226,38800:20081,38801:21365,38802:23888,38803:27396,38804:28651,38805:34253,38806:34349,38807:35239,38808:21033,38809:21519,38810:23653,38811:26446,38812:26792,38813:29702,38814:29827,38815:30178,38816:35023,38817:35041,38818:37324,38819:38626,38820:38520,38821:24459,38822:29575,38823:31435,38824:33870,38825:25504,38826:30053,38827:21129,38828:27969,38829:28316,38830:29705,38831:30041,38832:30827,38833:31890,38834:38534,38835:31452,38836:40845,38837:20406,38838:24942,38839:26053,38840:34396,38841:20102,38842:20142,38843:20698,38844:20001,38845:20940,38846:23534,38847:26009,38848:26753,38849:28092,38850:29471,38851:30274,38852:30637,38853:31260,38854:31975,38855:33391,38856:35538,38857:36988,38858:37327,38859:38517,38860:38936,38861:21147,38862:32209,38863:20523,38864:21400,38865:26519,38866:28107,38867:29136,38868:29747,38869:33256,38870:36650,38871:38563,38872:40023,38873:40607,38874:29792,38875:22593,38876:28057,38877:32047,38878:39006,38879:20196,38880:20278,38881:20363,38882:20919,38883:21169,38884:23994,38885:24604,38886:29618,38887:31036,38888:33491,38889:37428,38890:38583,38891:38646,38892:38666,38893:40599,38894:40802,38895:26278,38896:27508,38897:21015,38898:21155,38899:28872,38900:35010,38901:24265,38902:24651,38903:24976,38904:28451,38905:29001,38906:31806,38907:32244,38908:32879,38976:34030,38977:36899,38978:37676,38979:21570,38980:39791,38981:27347,38982:28809,38983:36034,38984:36335,38985:38706,38986:21172,38987:23105,38988:24266,38989:24324,38990:26391,38991:27004,38992:27028,38993:28010,38994:28431,38995:29282,38996:29436,38997:31725,38998:32769,38999:32894,39e3:34635,39001:37070,39002:20845,39003:40595,39004:31108,39005:32907,39006:37682,39007:35542,39008:20525,39009:21644,39010:35441,39011:27498,39012:36036,39013:33031,39014:24785,39015:26528,39016:40434,39017:20121,39018:20120,39019:39952,39020:35435,39021:34241,39022:34152,39023:26880,39024:28286,39025:30871,39026:33109,39071:24332,39072:19984,39073:19989,39074:20010,39075:20017,39076:20022,39077:20028,39078:20031,39079:20034,39080:20054,39081:20056,39082:20098,39083:20101,39084:35947,39085:20106,39086:33298,39087:24333,39088:20110,39089:20126,39090:20127,39091:20128,39092:20130,39093:20144,39094:20147,39095:20150,39096:20174,39097:20173,39098:20164,39099:20166,39100:20162,39101:20183,39102:20190,39103:20205,39104:20191,39105:20215,39106:20233,39107:20314,39108:20272,39109:20315,39110:20317,39111:20311,39112:20295,39113:20342,39114:20360,39115:20367,39116:20376,39117:20347,39118:20329,39119:20336,39120:20369,39121:20335,39122:20358,39123:20374,39124:20760,39125:20436,39126:20447,39127:20430,39128:20440,39129:20443,39130:20433,39131:20442,39132:20432,39133:20452,39134:20453,39135:20506,39136:20520,39137:20500,39138:20522,39139:20517,39140:20485,39141:20252,39142:20470,39143:20513,39144:20521,39145:20524,39146:20478,39147:20463,39148:20497,39149:20486,39150:20547,39151:20551,39152:26371,39153:20565,39154:20560,39155:20552,39156:20570,39157:20566,39158:20588,39159:20600,39160:20608,39161:20634,39162:20613,39163:20660,39164:20658,39232:20681,39233:20682,39234:20659,39235:20674,39236:20694,39237:20702,39238:20709,39239:20717,39240:20707,39241:20718,39242:20729,39243:20725,39244:20745,39245:20737,39246:20738,39247:20758,39248:20757,39249:20756,39250:20762,39251:20769,39252:20794,39253:20791,39254:20796,39255:20795,39256:20799,39257:20800,39258:20818,39259:20812,39260:20820,39261:20834,39262:31480,39263:20841,39264:20842,39265:20846,39266:20864,39267:20866,39268:22232,39269:20876,39270:20873,39271:20879,39272:20881,39273:20883,39274:20885,39275:20886,39276:20900,39277:20902,39278:20898,39279:20905,39280:20906,39281:20907,39282:20915,39283:20913,39284:20914,39285:20912,39286:20917,39287:20925,39288:20933,39289:20937,39290:20955,39291:20960,39292:34389,39293:20969,39294:20973,39296:20976,39297:20981,39298:20990,39299:20996,39300:21003,39301:21012,39302:21006,39303:21031,39304:21034,39305:21038,39306:21043,39307:21049,39308:21071,39309:21060,39310:21067,39311:21068,39312:21086,39313:21076,39314:21098,39315:21108,39316:21097,39317:21107,39318:21119,39319:21117,39320:21133,39321:21140,39322:21138,39323:21105,39324:21128,39325:21137,39326:36776,39327:36775,39328:21164,39329:21165,39330:21180,39331:21173,39332:21185,39333:21197,39334:21207,39335:21214,39336:21219,39337:21222,39338:39149,39339:21216,39340:21235,39341:21237,39342:21240,39343:21241,39344:21254,39345:21256,39346:30008,39347:21261,39348:21264,39349:21263,39350:21269,39351:21274,39352:21283,39353:21295,39354:21297,39355:21299,39356:21304,39357:21312,39358:21318,39359:21317,39360:19991,39361:21321,39362:21325,39363:20950,39364:21342,39365:21353,39366:21358,39367:22808,39368:21371,39369:21367,39370:21378,39371:21398,39372:21408,39373:21414,39374:21413,39375:21422,39376:21424,39377:21430,39378:21443,39379:31762,39380:38617,39381:21471,39382:26364,39383:29166,39384:21486,39385:21480,39386:21485,39387:21498,39388:21505,39389:21565,39390:21568,39391:21548,39392:21549,39393:21564,39394:21550,39395:21558,39396:21545,39397:21533,39398:21582,39399:21647,39400:21621,39401:21646,39402:21599,39403:21617,39404:21623,39405:21616,39406:21650,39407:21627,39408:21632,39409:21622,39410:21636,39411:21648,39412:21638,39413:21703,39414:21666,39415:21688,39416:21669,39417:21676,39418:21700,39419:21704,39420:21672,39488:21675,39489:21698,39490:21668,39491:21694,39492:21692,39493:21720,39494:21733,39495:21734,39496:21775,39497:21780,39498:21757,39499:21742,39500:21741,39501:21754,39502:21730,39503:21817,39504:21824,39505:21859,39506:21836,39507:21806,39508:21852,39509:21829,39510:21846,39511:21847,39512:21816,39513:21811,39514:21853,39515:21913,39516:21888,39517:21679,39518:21898,39519:21919,39520:21883,39521:21886,39522:21912,39523:21918,39524:21934,39525:21884,39526:21891,39527:21929,39528:21895,39529:21928,39530:21978,39531:21957,39532:21983,39533:21956,39534:21980,39535:21988,39536:21972,39537:22036,39538:22007,39539:22038,39540:22014,39541:22013,39542:22043,39543:22009,39544:22094,39545:22096,39546:29151,39547:22068,39548:22070,39549:22066,39550:22072,39552:22123,39553:22116,39554:22063,39555:22124,39556:22122,39557:22150,39558:22144,39559:22154,39560:22176,39561:22164,39562:22159,39563:22181,39564:22190,39565:22198,39566:22196,39567:22210,39568:22204,39569:22209,39570:22211,39571:22208,39572:22216,39573:22222,39574:22225,39575:22227,39576:22231,39577:22254,39578:22265,39579:22272,39580:22271,39581:22276,39582:22281,39583:22280,39584:22283,39585:22285,39586:22291,39587:22296,39588:22294,39589:21959,39590:22300,39591:22310,39592:22327,39593:22328,39594:22350,39595:22331,39596:22336,39597:22351,39598:22377,39599:22464,39600:22408,39601:22369,39602:22399,39603:22409,39604:22419,39605:22432,39606:22451,39607:22436,39608:22442,39609:22448,39610:22467,39611:22470,39612:22484,39613:22482,39614:22483,39615:22538,39616:22486,39617:22499,39618:22539,39619:22553,39620:22557,39621:22642,39622:22561,39623:22626,39624:22603,39625:22640,39626:27584,39627:22610,39628:22589,39629:22649,39630:22661,39631:22713,39632:22687,39633:22699,39634:22714,39635:22750,39636:22715,39637:22712,39638:22702,39639:22725,39640:22739,39641:22737,39642:22743,39643:22745,39644:22744,39645:22757,39646:22748,39647:22756,39648:22751,39649:22767,39650:22778,39651:22777,39652:22779,39653:22780,39654:22781,39655:22786,39656:22794,39657:22800,39658:22811,39659:26790,39660:22821,39661:22828,39662:22829,39663:22834,39664:22840,39665:22846,39666:31442,39667:22869,39668:22864,39669:22862,39670:22874,39671:22872,39672:22882,39673:22880,39674:22887,39675:22892,39676:22889,39744:22904,39745:22913,39746:22941,39747:20318,39748:20395,39749:22947,39750:22962,39751:22982,39752:23016,39753:23004,39754:22925,39755:23001,39756:23002,39757:23077,39758:23071,39759:23057,39760:23068,39761:23049,39762:23066,39763:23104,39764:23148,39765:23113,39766:23093,39767:23094,39768:23138,39769:23146,39770:23194,39771:23228,39772:23230,39773:23243,39774:23234,39775:23229,39776:23267,39777:23255,39778:23270,39779:23273,39780:23254,39781:23290,39782:23291,39783:23308,39784:23307,39785:23318,39786:23346,39787:23248,39788:23338,39789:23350,39790:23358,39791:23363,39792:23365,39793:23360,39794:23377,39795:23381,39796:23386,39797:23387,39798:23397,39799:23401,39800:23408,39801:23411,39802:23413,39803:23416,39804:25992,39805:23418,39806:23424,39808:23427,39809:23462,39810:23480,39811:23491,39812:23495,39813:23497,39814:23508,39815:23504,39816:23524,39817:23526,39818:23522,39819:23518,39820:23525,39821:23531,39822:23536,39823:23542,39824:23539,39825:23557,39826:23559,39827:23560,39828:23565,39829:23571,39830:23584,39831:23586,39832:23592,39833:23608,39834:23609,39835:23617,39836:23622,39837:23630,39838:23635,39839:23632,39840:23631,39841:23409,39842:23660,39843:23662,39844:20066,39845:23670,39846:23673,39847:23692,39848:23697,39849:23700,39850:22939,39851:23723,39852:23739,39853:23734,39854:23740,39855:23735,39856:23749,39857:23742,39858:23751,39859:23769,39860:23785,39861:23805,39862:23802,39863:23789,39864:23948,39865:23786,39866:23819,39867:23829,39868:23831,39869:23900,39870:23839,39871:23835,39872:23825,39873:23828,39874:23842,39875:23834,39876:23833,39877:23832,39878:23884,39879:23890,39880:23886,39881:23883,39882:23916,39883:23923,39884:23926,39885:23943,39886:23940,39887:23938,39888:23970,39889:23965,39890:23980,39891:23982,39892:23997,39893:23952,39894:23991,39895:23996,39896:24009,39897:24013,39898:24019,39899:24018,39900:24022,39901:24027,39902:24043,39903:24050,39904:24053,39905:24075,39906:24090,39907:24089,39908:24081,39909:24091,39910:24118,39911:24119,39912:24132,39913:24131,39914:24128,39915:24142,39916:24151,39917:24148,39918:24159,39919:24162,39920:24164,39921:24135,39922:24181,39923:24182,39924:24186,39925:40636,39926:24191,39927:24224,39928:24257,39929:24258,39930:24264,39931:24272,39932:24271,4e4:24278,40001:24291,40002:24285,40003:24282,40004:24283,40005:24290,40006:24289,40007:24296,40008:24297,40009:24300,40010:24305,40011:24307,40012:24304,40013:24308,40014:24312,40015:24318,40016:24323,40017:24329,40018:24413,40019:24412,40020:24331,40021:24337,40022:24342,40023:24361,40024:24365,40025:24376,40026:24385,40027:24392,40028:24396,40029:24398,40030:24367,40031:24401,40032:24406,40033:24407,40034:24409,40035:24417,40036:24429,40037:24435,40038:24439,40039:24451,40040:24450,40041:24447,40042:24458,40043:24456,40044:24465,40045:24455,40046:24478,40047:24473,40048:24472,40049:24480,40050:24488,40051:24493,40052:24508,40053:24534,40054:24571,40055:24548,40056:24568,40057:24561,40058:24541,40059:24755,40060:24575,40061:24609,40062:24672,40064:24601,40065:24592,40066:24617,40067:24590,40068:24625,40069:24603,40070:24597,40071:24619,40072:24614,40073:24591,40074:24634,40075:24666,40076:24641,40077:24682,40078:24695,40079:24671,40080:24650,40081:24646,40082:24653,40083:24675,40084:24643,40085:24676,40086:24642,40087:24684,40088:24683,40089:24665,40090:24705,40091:24717,40092:24807,40093:24707,40094:24730,40095:24708,40096:24731,40097:24726,40098:24727,40099:24722,40100:24743,40101:24715,40102:24801,40103:24760,40104:24800,40105:24787,40106:24756,40107:24560,40108:24765,40109:24774,40110:24757,40111:24792,40112:24909,40113:24853,40114:24838,40115:24822,40116:24823,40117:24832,40118:24820,40119:24826,40120:24835,40121:24865,40122:24827,40123:24817,40124:24845,40125:24846,40126:24903,40127:24894,40128:24872,40129:24871,40130:24906,40131:24895,40132:24892,40133:24876,40134:24884,40135:24893,40136:24898,40137:24900,40138:24947,40139:24951,40140:24920,40141:24921,40142:24922,40143:24939,40144:24948,40145:24943,40146:24933,40147:24945,40148:24927,40149:24925,40150:24915,40151:24949,40152:24985,40153:24982,40154:24967,40155:25004,40156:24980,40157:24986,40158:24970,40159:24977,40160:25003,40161:25006,40162:25036,40163:25034,40164:25033,40165:25079,40166:25032,40167:25027,40168:25030,40169:25018,40170:25035,40171:32633,40172:25037,40173:25062,40174:25059,40175:25078,40176:25082,40177:25076,40178:25087,40179:25085,40180:25084,40181:25086,40182:25088,40183:25096,40184:25097,40185:25101,40186:25100,40187:25108,40188:25115,40256:25118,40257:25121,40258:25130,40259:25134,40260:25136,40261:25138,40262:25139,40263:25153,40264:25166,40265:25182,40266:25187,40267:25179,40268:25184,40269:25192,40270:25212,40271:25218,40272:25225,40273:25214,40274:25234,40275:25235,40276:25238,40277:25300,40278:25219,40279:25236,40280:25303,40281:25297,40282:25275,40283:25295,40284:25343,40285:25286,40286:25812,40287:25288,40288:25308,40289:25292,40290:25290,40291:25282,40292:25287,40293:25243,40294:25289,40295:25356,40296:25326,40297:25329,40298:25383,40299:25346,40300:25352,40301:25327,40302:25333,40303:25424,40304:25406,40305:25421,40306:25628,40307:25423,40308:25494,40309:25486,40310:25472,40311:25515,40312:25462,40313:25507,40314:25487,40315:25481,40316:25503,40317:25525,40318:25451,40320:25449,40321:25534,40322:25577,40323:25536,40324:25542,40325:25571,40326:25545,40327:25554,40328:25590,40329:25540,40330:25622,40331:25652,40332:25606,40333:25619,40334:25638,40335:25654,40336:25885,40337:25623,40338:25640,40339:25615,40340:25703,40341:25711,40342:25718,40343:25678,40344:25898,40345:25749,40346:25747,40347:25765,40348:25769,40349:25736,40350:25788,40351:25818,40352:25810,40353:25797,40354:25799,40355:25787,40356:25816,40357:25794,40358:25841,40359:25831,40360:33289,40361:25824,40362:25825,40363:25260,40364:25827,40365:25839,40366:25900,40367:25846,40368:25844,40369:25842,40370:25850,40371:25856,40372:25853,40373:25880,40374:25884,40375:25861,40376:25892,40377:25891,40378:25899,40379:25908,40380:25909,40381:25911,40382:25910,40383:25912,40384:30027,40385:25928,40386:25942,40387:25941,40388:25933,40389:25944,40390:25950,40391:25949,40392:25970,40393:25976,40394:25986,40395:25987,40396:35722,40397:26011,40398:26015,40399:26027,40400:26039,40401:26051,40402:26054,40403:26049,40404:26052,40405:26060,40406:26066,40407:26075,40408:26073,40409:26080,40410:26081,40411:26097,40412:26482,40413:26122,40414:26115,40415:26107,40416:26483,40417:26165,40418:26166,40419:26164,40420:26140,40421:26191,40422:26180,40423:26185,40424:26177,40425:26206,40426:26205,40427:26212,40428:26215,40429:26216,40430:26207,40431:26210,40432:26224,40433:26243,40434:26248,40435:26254,40436:26249,40437:26244,40438:26264,40439:26269,40440:26305,40441:26297,40442:26313,40443:26302,40444:26300,40512:26308,40513:26296,40514:26326,40515:26330,40516:26336,40517:26175,40518:26342,40519:26345,40520:26352,40521:26357,40522:26359,40523:26383,40524:26390,40525:26398,40526:26406,40527:26407,40528:38712,40529:26414,40530:26431,40531:26422,40532:26433,40533:26424,40534:26423,40535:26438,40536:26462,40537:26464,40538:26457,40539:26467,40540:26468,40541:26505,40542:26480,40543:26537,40544:26492,40545:26474,40546:26508,40547:26507,40548:26534,40549:26529,40550:26501,40551:26551,40552:26607,40553:26548,40554:26604,40555:26547,40556:26601,40557:26552,40558:26596,40559:26590,40560:26589,40561:26594,40562:26606,40563:26553,40564:26574,40565:26566,40566:26599,40567:27292,40568:26654,40569:26694,40570:26665,40571:26688,40572:26701,40573:26674,40574:26702,40576:26803,40577:26667,40578:26713,40579:26723,40580:26743,40581:26751,40582:26783,40583:26767,40584:26797,40585:26772,40586:26781,40587:26779,40588:26755,40589:27310,40590:26809,40591:26740,40592:26805,40593:26784,40594:26810,40595:26895,40596:26765,40597:26750,40598:26881,40599:26826,40600:26888,40601:26840,40602:26914,40603:26918,40604:26849,40605:26892,40606:26829,40607:26836,40608:26855,40609:26837,40610:26934,40611:26898,40612:26884,40613:26839,40614:26851,40615:26917,40616:26873,40617:26848,40618:26863,40619:26920,40620:26922,40621:26906,40622:26915,40623:26913,40624:26822,40625:27001,40626:26999,40627:26972,40628:27e3,40629:26987,40630:26964,40631:27006,40632:26990,40633:26937,40634:26996,40635:26941,40636:26969,40637:26928,40638:26977,40639:26974,40640:26973,40641:27009,40642:26986,40643:27058,40644:27054,40645:27088,40646:27071,40647:27073,40648:27091,40649:27070,40650:27086,40651:23528,40652:27082,40653:27101,40654:27067,40655:27075,40656:27047,40657:27182,40658:27025,40659:27040,40660:27036,40661:27029,40662:27060,40663:27102,40664:27112,40665:27138,40666:27163,40667:27135,40668:27402,40669:27129,40670:27122,40671:27111,40672:27141,40673:27057,40674:27166,40675:27117,40676:27156,40677:27115,40678:27146,40679:27154,40680:27329,40681:27171,40682:27155,40683:27204,40684:27148,40685:27250,40686:27190,40687:27256,40688:27207,40689:27234,40690:27225,40691:27238,40692:27208,40693:27192,40694:27170,40695:27280,40696:27277,40697:27296,40698:27268,40699:27298,40700:27299,40768:27287,40769:34327,40770:27323,40771:27331,40772:27330,40773:27320,40774:27315,40775:27308,40776:27358,40777:27345,40778:27359,40779:27306,40780:27354,40781:27370,40782:27387,40783:27397,40784:34326,40785:27386,40786:27410,40787:27414,40788:39729,40789:27423,40790:27448,40791:27447,40792:30428,40793:27449,40794:39150,40795:27463,40796:27459,40797:27465,40798:27472,40799:27481,40800:27476,40801:27483,40802:27487,40803:27489,40804:27512,40805:27513,40806:27519,40807:27520,40808:27524,40809:27523,40810:27533,40811:27544,40812:27541,40813:27550,40814:27556,40815:27562,40816:27563,40817:27567,40818:27570,40819:27569,40820:27571,40821:27575,40822:27580,40823:27590,40824:27595,40825:27603,40826:27615,40827:27628,40828:27627,40829:27635,40830:27631,40832:40638,40833:27656,40834:27667,40835:27668,40836:27675,40837:27684,40838:27683,40839:27742,40840:27733,40841:27746,40842:27754,40843:27778,40844:27789,40845:27802,40846:27777,40847:27803,40848:27774,40849:27752,40850:27763,40851:27794,40852:27792,40853:27844,40854:27889,40855:27859,40856:27837,40857:27863,40858:27845,40859:27869,40860:27822,40861:27825,40862:27838,40863:27834,40864:27867,40865:27887,40866:27865,40867:27882,40868:27935,40869:34893,40870:27958,40871:27947,40872:27965,40873:27960,40874:27929,40875:27957,40876:27955,40877:27922,40878:27916,40879:28003,40880:28051,40881:28004,40882:27994,40883:28025,40884:27993,40885:28046,40886:28053,40887:28644,40888:28037,40889:28153,40890:28181,40891:28170,40892:28085,40893:28103,40894:28134,40895:28088,40896:28102,40897:28140,40898:28126,40899:28108,40900:28136,40901:28114,40902:28101,40903:28154,40904:28121,40905:28132,40906:28117,40907:28138,40908:28142,40909:28205,40910:28270,40911:28206,40912:28185,40913:28274,40914:28255,40915:28222,40916:28195,40917:28267,40918:28203,40919:28278,40920:28237,40921:28191,40922:28227,40923:28218,40924:28238,40925:28196,40926:28415,40927:28189,40928:28216,40929:28290,40930:28330,40931:28312,40932:28361,40933:28343,40934:28371,40935:28349,40936:28335,40937:28356,40938:28338,40939:28372,40940:28373,40941:28303,40942:28325,40943:28354,40944:28319,40945:28481,40946:28433,40947:28748,40948:28396,40949:28408,40950:28414,40951:28479,40952:28402,40953:28465,40954:28399,40955:28466,40956:28364,161:65377,162:65378,163:65379,164:65380,165:65381,166:65382,167:65383,168:65384,169:65385,170:65386,171:65387,172:65388,173:65389,174:65390,175:65391,176:65392,177:65393,178:65394,179:65395,180:65396,181:65397,182:65398,183:65399,184:65400,185:65401,186:65402,187:65403,188:65404,189:65405,190:65406,191:65407,192:65408,193:65409,194:65410,195:65411,196:65412,197:65413,198:65414,199:65415,200:65416,201:65417,202:65418,203:65419,204:65420,205:65421,206:65422,207:65423,208:65424,209:65425,210:65426,211:65427,212:65428,213:65429,214:65430,215:65431,216:65432,217:65433,218:65434,219:65435,220:65436,221:65437,222:65438,223:65439,57408:28478,57409:28435,57410:28407,57411:28550,57412:28538,57413:28536,57414:28545,57415:28544,57416:28527,57417:28507,57418:28659,57419:28525,57420:28546,57421:28540,57422:28504,57423:28558,57424:28561,57425:28610,57426:28518,57427:28595,57428:28579,57429:28577,57430:28580,57431:28601,57432:28614,57433:28586,57434:28639,57435:28629,57436:28652,57437:28628,57438:28632,57439:28657,57440:28654,57441:28635,57442:28681,57443:28683,57444:28666,57445:28689,57446:28673,57447:28687,57448:28670,57449:28699,57450:28698,57451:28532,57452:28701,57453:28696,57454:28703,57455:28720,57456:28734,57457:28722,57458:28753,57459:28771,57460:28825,57461:28818,57462:28847,57463:28913,57464:28844,57465:28856,57466:28851,57467:28846,57468:28895,57469:28875,57470:28893,57472:28889,57473:28937,57474:28925,57475:28956,57476:28953,57477:29029,57478:29013,57479:29064,57480:29030,57481:29026,57482:29004,57483:29014,57484:29036,57485:29071,57486:29179,57487:29060,57488:29077,57489:29096,57490:29100,57491:29143,57492:29113,57493:29118,57494:29138,57495:29129,57496:29140,57497:29134,57498:29152,57499:29164,57500:29159,57501:29173,57502:29180,57503:29177,57504:29183,57505:29197,57506:29200,57507:29211,57508:29224,57509:29229,57510:29228,57511:29232,57512:29234,57513:29243,57514:29244,57515:29247,57516:29248,57517:29254,57518:29259,57519:29272,57520:29300,57521:29310,57522:29314,57523:29313,57524:29319,57525:29330,57526:29334,57527:29346,57528:29351,57529:29369,57530:29362,57531:29379,57532:29382,57533:29380,57534:29390,57535:29394,57536:29410,57537:29408,57538:29409,57539:29433,57540:29431,57541:20495,57542:29463,57543:29450,57544:29468,57545:29462,57546:29469,57547:29492,57548:29487,57549:29481,57550:29477,57551:29502,57552:29518,57553:29519,57554:40664,57555:29527,57556:29546,57557:29544,57558:29552,57559:29560,57560:29557,57561:29563,57562:29562,57563:29640,57564:29619,57565:29646,57566:29627,57567:29632,57568:29669,57569:29678,57570:29662,57571:29858,57572:29701,57573:29807,57574:29733,57575:29688,57576:29746,57577:29754,57578:29781,57579:29759,57580:29791,57581:29785,57582:29761,57583:29788,57584:29801,57585:29808,57586:29795,57587:29802,57588:29814,57589:29822,57590:29835,57591:29854,57592:29863,57593:29898,57594:29903,57595:29908,57596:29681,57664:29920,57665:29923,57666:29927,57667:29929,57668:29934,57669:29938,57670:29936,57671:29937,57672:29944,57673:29943,57674:29956,57675:29955,57676:29957,57677:29964,57678:29966,57679:29965,57680:29973,57681:29971,57682:29982,57683:29990,57684:29996,57685:30012,57686:30020,57687:30029,57688:30026,57689:30025,57690:30043,57691:30022,57692:30042,57693:30057,57694:30052,57695:30055,57696:30059,57697:30061,57698:30072,57699:30070,57700:30086,57701:30087,57702:30068,57703:30090,57704:30089,57705:30082,57706:30100,57707:30106,57708:30109,57709:30117,57710:30115,57711:30146,57712:30131,57713:30147,57714:30133,57715:30141,57716:30136,57717:30140,57718:30129,57719:30157,57720:30154,57721:30162,57722:30169,57723:30179,57724:30174,57725:30206,57726:30207,57728:30204,57729:30209,57730:30192,57731:30202,57732:30194,57733:30195,57734:30219,57735:30221,57736:30217,57737:30239,57738:30247,57739:30240,57740:30241,57741:30242,57742:30244,57743:30260,57744:30256,57745:30267,57746:30279,57747:30280,57748:30278,57749:30300,57750:30296,57751:30305,57752:30306,57753:30312,57754:30313,57755:30314,57756:30311,57757:30316,57758:30320,57759:30322,57760:30326,57761:30328,57762:30332,57763:30336,57764:30339,57765:30344,57766:30347,57767:30350,57768:30358,57769:30355,57770:30361,57771:30362,57772:30384,57773:30388,57774:30392,57775:30393,57776:30394,57777:30402,57778:30413,57779:30422,57780:30418,57781:30430,57782:30433,57783:30437,57784:30439,57785:30442,57786:34351,57787:30459,57788:30472,57789:30471,57790:30468,57791:30505,57792:30500,57793:30494,57794:30501,57795:30502,57796:30491,57797:30519,57798:30520,57799:30535,57800:30554,57801:30568,57802:30571,57803:30555,57804:30565,57805:30591,57806:30590,57807:30585,57808:30606,57809:30603,57810:30609,57811:30624,57812:30622,57813:30640,57814:30646,57815:30649,57816:30655,57817:30652,57818:30653,57819:30651,57820:30663,57821:30669,57822:30679,57823:30682,57824:30684,57825:30691,57826:30702,57827:30716,57828:30732,57829:30738,57830:31014,57831:30752,57832:31018,57833:30789,57834:30862,57835:30836,57836:30854,57837:30844,57838:30874,57839:30860,57840:30883,57841:30901,57842:30890,57843:30895,57844:30929,57845:30918,57846:30923,57847:30932,57848:30910,57849:30908,57850:30917,57851:30922,57852:30956,57920:30951,57921:30938,57922:30973,57923:30964,57924:30983,57925:30994,57926:30993,57927:31001,57928:31020,57929:31019,57930:31040,57931:31072,57932:31063,57933:31071,57934:31066,57935:31061,57936:31059,57937:31098,57938:31103,57939:31114,57940:31133,57941:31143,57942:40779,57943:31146,57944:31150,57945:31155,57946:31161,57947:31162,57948:31177,57949:31189,57950:31207,57951:31212,57952:31201,57953:31203,57954:31240,57955:31245,57956:31256,57957:31257,57958:31264,57959:31263,57960:31104,57961:31281,57962:31291,57963:31294,57964:31287,57965:31299,57966:31319,57967:31305,57968:31329,57969:31330,57970:31337,57971:40861,57972:31344,57973:31353,57974:31357,57975:31368,57976:31383,57977:31381,57978:31384,57979:31382,57980:31401,57981:31432,57982:31408,57984:31414,57985:31429,57986:31428,57987:31423,57988:36995,57989:31431,57990:31434,57991:31437,57992:31439,57993:31445,57994:31443,57995:31449,57996:31450,57997:31453,57998:31457,57999:31458,58e3:31462,58001:31469,58002:31472,58003:31490,58004:31503,58005:31498,58006:31494,58007:31539,58008:31512,58009:31513,58010:31518,58011:31541,58012:31528,58013:31542,58014:31568,58015:31610,58016:31492,58017:31565,58018:31499,58019:31564,58020:31557,58021:31605,58022:31589,58023:31604,58024:31591,58025:31600,58026:31601,58027:31596,58028:31598,58029:31645,58030:31640,58031:31647,58032:31629,58033:31644,58034:31642,58035:31627,58036:31634,58037:31631,58038:31581,58039:31641,58040:31691,58041:31681,58042:31692,58043:31695,58044:31668,58045:31686,58046:31709,58047:31721,58048:31761,58049:31764,58050:31718,58051:31717,58052:31840,58053:31744,58054:31751,58055:31763,58056:31731,58057:31735,58058:31767,58059:31757,58060:31734,58061:31779,58062:31783,58063:31786,58064:31775,58065:31799,58066:31787,58067:31805,58068:31820,58069:31811,58070:31828,58071:31823,58072:31808,58073:31824,58074:31832,58075:31839,58076:31844,58077:31830,58078:31845,58079:31852,58080:31861,58081:31875,58082:31888,58083:31908,58084:31917,58085:31906,58086:31915,58087:31905,58088:31912,58089:31923,58090:31922,58091:31921,58092:31918,58093:31929,58094:31933,58095:31936,58096:31941,58097:31938,58098:31960,58099:31954,58100:31964,58101:31970,58102:39739,58103:31983,58104:31986,58105:31988,58106:31990,58107:31994,58108:32006,58176:32002,58177:32028,58178:32021,58179:32010,58180:32069,58181:32075,58182:32046,58183:32050,58184:32063,58185:32053,58186:32070,58187:32115,58188:32086,58189:32078,58190:32114,58191:32104,58192:32110,58193:32079,58194:32099,58195:32147,58196:32137,58197:32091,58198:32143,58199:32125,58200:32155,58201:32186,58202:32174,58203:32163,58204:32181,58205:32199,58206:32189,58207:32171,58208:32317,58209:32162,58210:32175,58211:32220,58212:32184,58213:32159,58214:32176,58215:32216,58216:32221,58217:32228,58218:32222,58219:32251,58220:32242,58221:32225,58222:32261,58223:32266,58224:32291,58225:32289,58226:32274,58227:32305,58228:32287,58229:32265,58230:32267,58231:32290,58232:32326,58233:32358,58234:32315,58235:32309,58236:32313,58237:32323,58238:32311,58240:32306,58241:32314,58242:32359,58243:32349,58244:32342,58245:32350,58246:32345,58247:32346,58248:32377,58249:32362,58250:32361,58251:32380,58252:32379,58253:32387,58254:32213,58255:32381,58256:36782,58257:32383,58258:32392,58259:32393,58260:32396,58261:32402,58262:32400,58263:32403,58264:32404,58265:32406,58266:32398,58267:32411,58268:32412,58269:32568,58270:32570,58271:32581,58272:32588,58273:32589,58274:32590,58275:32592,58276:32593,58277:32597,58278:32596,58279:32600,58280:32607,58281:32608,58282:32616,58283:32617,58284:32615,58285:32632,58286:32642,58287:32646,58288:32643,58289:32648,58290:32647,58291:32652,58292:32660,58293:32670,58294:32669,58295:32666,58296:32675,58297:32687,58298:32690,58299:32697,58300:32686,58301:32694,58302:32696,58303:35697,58304:32709,58305:32710,58306:32714,58307:32725,58308:32724,58309:32737,58310:32742,58311:32745,58312:32755,58313:32761,58314:39132,58315:32774,58316:32772,58317:32779,58318:32786,58319:32792,58320:32793,58321:32796,58322:32801,58323:32808,58324:32831,58325:32827,58326:32842,58327:32838,58328:32850,58329:32856,58330:32858,58331:32863,58332:32866,58333:32872,58334:32883,58335:32882,58336:32880,58337:32886,58338:32889,58339:32893,58340:32895,58341:32900,58342:32902,58343:32901,58344:32923,58345:32915,58346:32922,58347:32941,58348:20880,58349:32940,58350:32987,58351:32997,58352:32985,58353:32989,58354:32964,58355:32986,58356:32982,58357:33033,58358:33007,58359:33009,58360:33051,58361:33065,58362:33059,58363:33071,58364:33099,58432:38539,58433:33094,58434:33086,58435:33107,58436:33105,58437:33020,58438:33137,58439:33134,58440:33125,58441:33126,58442:33140,58443:33155,58444:33160,58445:33162,58446:33152,58447:33154,58448:33184,58449:33173,58450:33188,58451:33187,58452:33119,58453:33171,58454:33193,58455:33200,58456:33205,58457:33214,58458:33208,58459:33213,58460:33216,58461:33218,58462:33210,58463:33225,58464:33229,58465:33233,58466:33241,58467:33240,58468:33224,58469:33242,58470:33247,58471:33248,58472:33255,58473:33274,58474:33275,58475:33278,58476:33281,58477:33282,58478:33285,58479:33287,58480:33290,58481:33293,58482:33296,58483:33302,58484:33321,58485:33323,58486:33336,58487:33331,58488:33344,58489:33369,58490:33368,58491:33373,58492:33370,58493:33375,58494:33380,58496:33378,58497:33384,58498:33386,58499:33387,58500:33326,58501:33393,58502:33399,58503:33400,58504:33406,58505:33421,58506:33426,58507:33451,58508:33439,58509:33467,58510:33452,58511:33505,58512:33507,58513:33503,58514:33490,58515:33524,58516:33523,58517:33530,58518:33683,58519:33539,58520:33531,58521:33529,58522:33502,58523:33542,58524:33500,58525:33545,58526:33497,58527:33589,58528:33588,58529:33558,58530:33586,58531:33585,58532:33600,58533:33593,58534:33616,58535:33605,58536:33583,58537:33579,58538:33559,58539:33560,58540:33669,58541:33690,58542:33706,58543:33695,58544:33698,58545:33686,58546:33571,58547:33678,58548:33671,58549:33674,58550:33660,58551:33717,58552:33651,58553:33653,58554:33696,58555:33673,58556:33704,58557:33780,58558:33811,58559:33771,58560:33742,58561:33789,58562:33795,58563:33752,58564:33803,58565:33729,58566:33783,58567:33799,58568:33760,58569:33778,58570:33805,58571:33826,58572:33824,58573:33725,58574:33848,58575:34054,58576:33787,58577:33901,58578:33834,58579:33852,58580:34138,58581:33924,58582:33911,58583:33899,58584:33965,58585:33902,58586:33922,58587:33897,58588:33862,58589:33836,58590:33903,58591:33913,58592:33845,58593:33994,58594:33890,58595:33977,58596:33983,58597:33951,58598:34009,58599:33997,58600:33979,58601:34010,58602:34e3,58603:33985,58604:33990,58605:34006,58606:33953,58607:34081,58608:34047,58609:34036,58610:34071,58611:34072,58612:34092,58613:34079,58614:34069,58615:34068,58616:34044,58617:34112,58618:34147,58619:34136,58620:34120,58688:34113,58689:34306,58690:34123,58691:34133,58692:34176,58693:34212,58694:34184,58695:34193,58696:34186,58697:34216,58698:34157,58699:34196,58700:34203,58701:34282,58702:34183,58703:34204,58704:34167,58705:34174,58706:34192,58707:34249,58708:34234,58709:34255,58710:34233,58711:34256,58712:34261,58713:34269,58714:34277,58715:34268,58716:34297,58717:34314,58718:34323,58719:34315,58720:34302,58721:34298,58722:34310,58723:34338,58724:34330,58725:34352,58726:34367,58727:34381,58728:20053,58729:34388,58730:34399,58731:34407,58732:34417,58733:34451,58734:34467,58735:34473,58736:34474,58737:34443,58738:34444,58739:34486,58740:34479,58741:34500,58742:34502,58743:34480,58744:34505,58745:34851,58746:34475,58747:34516,58748:34526,58749:34537,58750:34540,58752:34527,58753:34523,58754:34543,58755:34578,58756:34566,58757:34568,58758:34560,58759:34563,58760:34555,58761:34577,58762:34569,58763:34573,58764:34553,58765:34570,58766:34612,58767:34623,58768:34615,58769:34619,58770:34597,58771:34601,58772:34586,58773:34656,58774:34655,58775:34680,58776:34636,58777:34638,58778:34676,58779:34647,58780:34664,58781:34670,58782:34649,58783:34643,58784:34659,58785:34666,58786:34821,58787:34722,58788:34719,58789:34690,58790:34735,58791:34763,58792:34749,58793:34752,58794:34768,58795:38614,58796:34731,58797:34756,58798:34739,58799:34759,58800:34758,58801:34747,58802:34799,58803:34802,58804:34784,58805:34831,58806:34829,58807:34814,58808:34806,58809:34807,58810:34830,58811:34770,58812:34833,58813:34838,58814:34837,58815:34850,58816:34849,58817:34865,58818:34870,58819:34873,58820:34855,58821:34875,58822:34884,58823:34882,58824:34898,58825:34905,58826:34910,58827:34914,58828:34923,58829:34945,58830:34942,58831:34974,58832:34933,58833:34941,58834:34997,58835:34930,58836:34946,58837:34967,58838:34962,58839:34990,58840:34969,58841:34978,58842:34957,58843:34980,58844:34992,58845:35007,58846:34993,58847:35011,58848:35012,58849:35028,58850:35032,58851:35033,58852:35037,58853:35065,58854:35074,58855:35068,58856:35060,58857:35048,58858:35058,58859:35076,58860:35084,58861:35082,58862:35091,58863:35139,58864:35102,58865:35109,58866:35114,58867:35115,58868:35137,58869:35140,58870:35131,58871:35126,58872:35128,58873:35148,58874:35101,58875:35168,58876:35166,58944:35174,58945:35172,58946:35181,58947:35178,58948:35183,58949:35188,58950:35191,58951:35198,58952:35203,58953:35208,58954:35210,58955:35219,58956:35224,58957:35233,58958:35241,58959:35238,58960:35244,58961:35247,58962:35250,58963:35258,58964:35261,58965:35263,58966:35264,58967:35290,58968:35292,58969:35293,58970:35303,58971:35316,58972:35320,58973:35331,58974:35350,58975:35344,58976:35340,58977:35355,58978:35357,58979:35365,58980:35382,58981:35393,58982:35419,58983:35410,58984:35398,58985:35400,58986:35452,58987:35437,58988:35436,58989:35426,58990:35461,58991:35458,58992:35460,58993:35496,58994:35489,58995:35473,58996:35493,58997:35494,58998:35482,58999:35491,59e3:35524,59001:35533,59002:35522,59003:35546,59004:35563,59005:35571,59006:35559,59008:35556,59009:35569,59010:35604,59011:35552,59012:35554,59013:35575,59014:35550,59015:35547,59016:35596,59017:35591,59018:35610,59019:35553,59020:35606,59021:35600,59022:35607,59023:35616,59024:35635,59025:38827,59026:35622,59027:35627,59028:35646,59029:35624,59030:35649,59031:35660,59032:35663,59033:35662,59034:35657,59035:35670,59036:35675,59037:35674,59038:35691,59039:35679,59040:35692,59041:35695,59042:35700,59043:35709,59044:35712,59045:35724,59046:35726,59047:35730,59048:35731,59049:35734,59050:35737,59051:35738,59052:35898,59053:35905,59054:35903,59055:35912,59056:35916,59057:35918,59058:35920,59059:35925,59060:35938,59061:35948,59062:35960,59063:35962,59064:35970,59065:35977,59066:35973,59067:35978,59068:35981,59069:35982,59070:35988,59071:35964,59072:35992,59073:25117,59074:36013,59075:36010,59076:36029,59077:36018,59078:36019,59079:36014,59080:36022,59081:36040,59082:36033,59083:36068,59084:36067,59085:36058,59086:36093,59087:36090,59088:36091,59089:36100,59090:36101,59091:36106,59092:36103,59093:36111,59094:36109,59095:36112,59096:40782,59097:36115,59098:36045,59099:36116,59100:36118,59101:36199,59102:36205,59103:36209,59104:36211,59105:36225,59106:36249,59107:36290,59108:36286,59109:36282,59110:36303,59111:36314,59112:36310,59113:36300,59114:36315,59115:36299,59116:36330,59117:36331,59118:36319,59119:36323,59120:36348,59121:36360,59122:36361,59123:36351,59124:36381,59125:36382,59126:36368,59127:36383,59128:36418,59129:36405,59130:36400,59131:36404,59132:36426,59200:36423,59201:36425,59202:36428,59203:36432,59204:36424,59205:36441,59206:36452,59207:36448,59208:36394,59209:36451,59210:36437,59211:36470,59212:36466,59213:36476,59214:36481,59215:36487,59216:36485,59217:36484,59218:36491,59219:36490,59220:36499,59221:36497,59222:36500,59223:36505,59224:36522,59225:36513,59226:36524,59227:36528,59228:36550,59229:36529,59230:36542,59231:36549,59232:36552,59233:36555,59234:36571,59235:36579,59236:36604,59237:36603,59238:36587,59239:36606,59240:36618,59241:36613,59242:36629,59243:36626,59244:36633,59245:36627,59246:36636,59247:36639,59248:36635,59249:36620,59250:36646,59251:36659,59252:36667,59253:36665,59254:36677,59255:36674,59256:36670,59257:36684,59258:36681,59259:36678,59260:36686,59261:36695,59262:36700,59264:36706,59265:36707,59266:36708,59267:36764,59268:36767,59269:36771,59270:36781,59271:36783,59272:36791,59273:36826,59274:36837,59275:36834,59276:36842,59277:36847,59278:36999,59279:36852,59280:36869,59281:36857,59282:36858,59283:36881,59284:36885,59285:36897,59286:36877,59287:36894,59288:36886,59289:36875,59290:36903,59291:36918,59292:36917,59293:36921,59294:36856,59295:36943,59296:36944,59297:36945,59298:36946,59299:36878,59300:36937,59301:36926,59302:36950,59303:36952,59304:36958,59305:36968,59306:36975,59307:36982,59308:38568,59309:36978,59310:36994,59311:36989,59312:36993,59313:36992,59314:37002,59315:37001,59316:37007,59317:37032,59318:37039,59319:37041,59320:37045,59321:37090,59322:37092,59323:25160,59324:37083,59325:37122,59326:37138,59327:37145,59328:37170,59329:37168,59330:37194,59331:37206,59332:37208,59333:37219,59334:37221,59335:37225,59336:37235,59337:37234,59338:37259,59339:37257,59340:37250,59341:37282,59342:37291,59343:37295,59344:37290,59345:37301,59346:37300,59347:37306,59348:37312,59349:37313,59350:37321,59351:37323,59352:37328,59353:37334,59354:37343,59355:37345,59356:37339,59357:37372,59358:37365,59359:37366,59360:37406,59361:37375,59362:37396,59363:37420,59364:37397,59365:37393,59366:37470,59367:37463,59368:37445,59369:37449,59370:37476,59371:37448,59372:37525,59373:37439,59374:37451,59375:37456,59376:37532,59377:37526,59378:37523,59379:37531,59380:37466,59381:37583,59382:37561,59383:37559,59384:37609,59385:37647,59386:37626,59387:37700,59388:37678,59456:37657,59457:37666,59458:37658,59459:37667,59460:37690,59461:37685,59462:37691,59463:37724,59464:37728,59465:37756,59466:37742,59467:37718,59468:37808,59469:37804,59470:37805,59471:37780,59472:37817,59473:37846,59474:37847,59475:37864,59476:37861,59477:37848,59478:37827,59479:37853,59480:37840,59481:37832,59482:37860,59483:37914,59484:37908,59485:37907,59486:37891,59487:37895,59488:37904,59489:37942,59490:37931,59491:37941,59492:37921,59493:37946,59494:37953,59495:37970,59496:37956,59497:37979,59498:37984,59499:37986,59500:37982,59501:37994,59502:37417,59503:38e3,59504:38005,59505:38007,59506:38013,59507:37978,59508:38012,59509:38014,59510:38017,59511:38015,59512:38274,59513:38279,59514:38282,59515:38292,59516:38294,59517:38296,59518:38297,59520:38304,59521:38312,59522:38311,59523:38317,59524:38332,59525:38331,59526:38329,59527:38334,59528:38346,59529:28662,59530:38339,59531:38349,59532:38348,59533:38357,59534:38356,59535:38358,59536:38364,59537:38369,59538:38373,59539:38370,59540:38433,59541:38440,59542:38446,59543:38447,59544:38466,59545:38476,59546:38479,59547:38475,59548:38519,59549:38492,59550:38494,59551:38493,59552:38495,59553:38502,59554:38514,59555:38508,59556:38541,59557:38552,59558:38549,59559:38551,59560:38570,59561:38567,59562:38577,59563:38578,59564:38576,59565:38580,59566:38582,59567:38584,59568:38585,59569:38606,59570:38603,59571:38601,59572:38605,59573:35149,59574:38620,59575:38669,59576:38613,59577:38649,59578:38660,59579:38662,59580:38664,59581:38675,59582:38670,59583:38673,59584:38671,59585:38678,59586:38681,59587:38692,59588:38698,59589:38704,59590:38713,59591:38717,59592:38718,59593:38724,59594:38726,59595:38728,59596:38722,59597:38729,59598:38748,59599:38752,59600:38756,59601:38758,59602:38760,59603:21202,59604:38763,59605:38769,59606:38777,59607:38789,59608:38780,59609:38785,59610:38778,59611:38790,59612:38795,59613:38799,59614:38800,59615:38812,59616:38824,59617:38822,59618:38819,59619:38835,59620:38836,59621:38851,59622:38854,59623:38856,59624:38859,59625:38876,59626:38893,59627:40783,59628:38898,59629:31455,59630:38902,59631:38901,59632:38927,59633:38924,59634:38968,59635:38948,59636:38945,59637:38967,59638:38973,59639:38982,59640:38991,59641:38987,59642:39019,59643:39023,59644:39024,59712:39025,59713:39028,59714:39027,59715:39082,59716:39087,59717:39089,59718:39094,59719:39108,59720:39107,59721:39110,59722:39145,59723:39147,59724:39171,59725:39177,59726:39186,59727:39188,59728:39192,59729:39201,59730:39197,59731:39198,59732:39204,59733:39200,59734:39212,59735:39214,59736:39229,59737:39230,59738:39234,59739:39241,59740:39237,59741:39248,59742:39243,59743:39249,59744:39250,59745:39244,59746:39253,59747:39319,59748:39320,59749:39333,59750:39341,59751:39342,59752:39356,59753:39391,59754:39387,59755:39389,59756:39384,59757:39377,59758:39405,59759:39406,59760:39409,59761:39410,59762:39419,59763:39416,59764:39425,59765:39439,59766:39429,59767:39394,59768:39449,59769:39467,59770:39479,59771:39493,59772:39490,59773:39488,59774:39491,59776:39486,59777:39509,59778:39501,59779:39515,59780:39511,59781:39519,59782:39522,59783:39525,59784:39524,59785:39529,59786:39531,59787:39530,59788:39597,59789:39600,59790:39612,59791:39616,59792:39631,59793:39633,59794:39635,59795:39636,59796:39646,59797:39647,59798:39650,59799:39651,59800:39654,59801:39663,59802:39659,59803:39662,59804:39668,59805:39665,59806:39671,59807:39675,59808:39686,59809:39704,59810:39706,59811:39711,59812:39714,59813:39715,59814:39717,59815:39719,59816:39720,59817:39721,59818:39722,59819:39726,59820:39727,59821:39730,59822:39748,59823:39747,59824:39759,59825:39757,59826:39758,59827:39761,59828:39768,59829:39796,59830:39827,59831:39811,59832:39825,59833:39830,59834:39831,59835:39839,59836:39840,59837:39848,59838:39860,59839:39872,59840:39882,59841:39865,59842:39878,59843:39887,59844:39889,59845:39890,59846:39907,59847:39906,59848:39908,59849:39892,59850:39905,59851:39994,59852:39922,59853:39921,59854:39920,59855:39957,59856:39956,59857:39945,59858:39955,59859:39948,59860:39942,59861:39944,59862:39954,59863:39946,59864:39940,59865:39982,59866:39963,59867:39973,59868:39972,59869:39969,59870:39984,59871:40007,59872:39986,59873:40006,59874:39998,59875:40026,59876:40032,59877:40039,59878:40054,59879:40056,59880:40167,59881:40172,59882:40176,59883:40201,59884:40200,59885:40171,59886:40195,59887:40198,59888:40234,59889:40230,59890:40367,59891:40227,59892:40223,59893:40260,59894:40213,59895:40210,59896:40257,59897:40255,59898:40254,59899:40262,59900:40264,59968:40285,59969:40286,59970:40292,59971:40273,59972:40272,59973:40281,59974:40306,59975:40329,59976:40327,59977:40363,59978:40303,59979:40314,59980:40346,59981:40356,59982:40361,59983:40370,59984:40388,59985:40385,59986:40379,59987:40376,59988:40378,59989:40390,59990:40399,59991:40386,59992:40409,59993:40403,59994:40440,59995:40422,59996:40429,59997:40431,59998:40445,59999:40474,6e4:40475,60001:40478,60002:40565,60003:40569,60004:40573,60005:40577,60006:40584,60007:40587,60008:40588,60009:40594,60010:40597,60011:40593,60012:40605,60013:40613,60014:40617,60015:40632,60016:40618,60017:40621,60018:38753,60019:40652,60020:40654,60021:40655,60022:40656,60023:40660,60024:40668,60025:40670,60026:40669,60027:40672,60028:40677,60029:40680,60030:40687,60032:40692,60033:40694,60034:40695,60035:40697,60036:40699,60037:40700,60038:40701,60039:40711,60040:40712,60041:30391,60042:40725,60043:40737,60044:40748,60045:40766,60046:40778,60047:40786,60048:40788,60049:40803,60050:40799,60051:40800,60052:40801,60053:40806,60054:40807,60055:40812,60056:40810,60057:40823,60058:40818,60059:40822,60060:40853,60061:40860,60062:40864,60063:22575,60064:27079,60065:36953,60066:29796,60067:20956,60068:29081}}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(2);function a(e,t,n,r){var i;t.degree()<n.degree()&&(i=[n,t],t=i[0],n=i[1]);for(var a=t,o=n,s=e.zero,c=e.one;o.degree()>=r/2;){var l=a,u=s;if(a=o,s=c,a.isZero())return null;o=l;for(var d=e.zero,f=a.getCoefficient(a.degree()),p=e.inverse(f);o.degree()>=a.degree()&&!o.isZero();){var m=o.degree()-a.degree(),h=e.multiply(o.getCoefficient(o.degree()),p);d=d.addOrSubtract(e.buildMonomial(m,h)),o=o.addOrSubtract(a.multiplyByMonomial(m,h))}if(c=d.multiplyPoly(s).addOrSubtract(u),o.degree()>=a.degree())return null}var g=c.getCoefficient(0);if(g===0)return null;var _=e.inverse(g);return[c.multiply(_),o.multiply(_)]}function o(e,t){var n=t.degree();if(n===1)return[t.getCoefficient(1)];for(var r=Array(n),i=0,a=1;a<e.size&&i<n;a++)t.evaluateAt(a)===0&&(r[i]=e.inverse(a),i++);return i===n?r:null}function s(e,t,n){for(var i=n.length,a=Array(i),o=0;o<i;o++){for(var s=e.inverse(n[o]),c=1,l=0;l<i;l++)o!==l&&(c=e.multiply(c,r.addOrSubtractGF(1,e.multiply(n[l],s))));a[o]=e.multiply(t.evaluateAt(s),e.inverse(c)),e.generatorBase!==0&&(a[o]=e.multiply(a[o],s))}return a}function c(e,t){var n=new Uint8ClampedArray(e.length);n.set(e);for(var c=new r.default(285,256,0),l=new i.default(c,n),u=new Uint8ClampedArray(t),d=!1,f=0;f<t;f++){var p=l.evaluateAt(c.exp(f+c.generatorBase));u[u.length-1-f]=p,p!==0&&(d=!0)}if(!d)return n;var m=new i.default(c,u),h=a(c,c.buildMonomial(t,1),m,t);if(h===null)return null;var g=o(c,h[0]);if(g==null)return null;for(var _=s(c,h[1],g),v=0;v<g.length;v++){var y=n.length-1-c.log(g[v]);if(y<0)return null;n[y]=r.addOrSubtractGF(n[y],_[v])}return n}t.decode=c}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.VERSIONS=[{infoBits:null,versionNumber:1,alignmentPatternCenters:[],errorCorrectionLevels:[{ecCodewordsPerBlock:7,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:13,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:13}]},{ecCodewordsPerBlock:17,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:2,alignmentPatternCenters:[6,18],errorCorrectionLevels:[{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:34}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:28}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]}]},{infoBits:null,versionNumber:3,alignmentPatternCenters:[6,22],errorCorrectionLevels:[{ecCodewordsPerBlock:15,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:55}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:13}]}]},{infoBits:null,versionNumber:4,alignmentPatternCenters:[6,26],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:80}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:32}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:5,alignmentPatternCenters:[6,30],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:43}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:11},{numBlocks:2,dataCodewordsPerBlock:12}]}]},{infoBits:null,versionNumber:6,alignmentPatternCenters:[6,34],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:27}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:31892,versionNumber:7,alignmentPatternCenters:[6,22,38],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:78}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:31}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:13},{numBlocks:1,dataCodewordsPerBlock:14}]}]},{infoBits:34236,versionNumber:8,alignmentPatternCenters:[6,24,42],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:97}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:38},{numBlocks:2,dataCodewordsPerBlock:39}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:18},{numBlocks:2,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:14},{numBlocks:2,dataCodewordsPerBlock:15}]}]},{infoBits:39577,versionNumber:9,alignmentPatternCenters:[6,26,46],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:12},{numBlocks:4,dataCodewordsPerBlock:13}]}]},{infoBits:42195,versionNumber:10,alignmentPatternCenters:[6,28,50],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68},{numBlocks:2,dataCodewordsPerBlock:69}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:43},{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]}]},{infoBits:48118,versionNumber:11,alignmentPatternCenters:[6,30,54],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:81}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:50},{numBlocks:4,dataCodewordsPerBlock:51}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:22},{numBlocks:4,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:12},{numBlocks:8,dataCodewordsPerBlock:13}]}]},{infoBits:51042,versionNumber:12,alignmentPatternCenters:[6,32,58],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:92},{numBlocks:2,dataCodewordsPerBlock:93}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:20},{numBlocks:6,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:55367,versionNumber:13,alignmentPatternCenters:[6,34,62],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:37},{numBlocks:1,dataCodewordsPerBlock:38}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:20},{numBlocks:4,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:11},{numBlocks:4,dataCodewordsPerBlock:12}]}]},{infoBits:58893,versionNumber:14,alignmentPatternCenters:[6,26,46,66],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:40},{numBlocks:5,dataCodewordsPerBlock:41}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:16},{numBlocks:5,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:5,dataCodewordsPerBlock:13}]}]},{infoBits:63784,versionNumber:15,alignmentPatternCenters:[6,26,48,70],errorCorrectionLevels:[{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:87},{numBlocks:1,dataCodewordsPerBlock:88}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:41},{numBlocks:5,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:7,dataCodewordsPerBlock:13}]}]},{infoBits:68472,versionNumber:16,alignmentPatternCenters:[6,26,50,74],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:98},{numBlocks:1,dataCodewordsPerBlock:99}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:70749,versionNumber:17,alignmentPatternCenters:[6,30,54,78],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:1,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22},{numBlocks:15,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:17,dataCodewordsPerBlock:15}]}]},{infoBits:76311,versionNumber:18,alignmentPatternCenters:[6,30,56,82],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:120},{numBlocks:1,dataCodewordsPerBlock:121}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:43},{numBlocks:4,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:1,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:19,dataCodewordsPerBlock:15}]}]},{infoBits:79154,versionNumber:19,alignmentPatternCenters:[6,30,58,86],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:113},{numBlocks:4,dataCodewordsPerBlock:114}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:44},{numBlocks:11,dataCodewordsPerBlock:45}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:21},{numBlocks:4,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:13},{numBlocks:16,dataCodewordsPerBlock:14}]}]},{infoBits:84390,versionNumber:20,alignmentPatternCenters:[6,34,62,90],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:41},{numBlocks:13,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:5,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:15},{numBlocks:10,dataCodewordsPerBlock:16}]}]},{infoBits:87683,versionNumber:21,alignmentPatternCenters:[6,28,50,72,94],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:116},{numBlocks:4,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:16},{numBlocks:6,dataCodewordsPerBlock:17}]}]},{infoBits:92361,versionNumber:22,alignmentPatternCenters:[6,26,50,74,98],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:111},{numBlocks:7,dataCodewordsPerBlock:112}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:13}]}]},{infoBits:96236,versionNumber:23,alignmentPatternCenters:[6,30,54,74,102],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:121},{numBlocks:5,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:47},{numBlocks:14,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:16,dataCodewordsPerBlock:15},{numBlocks:14,dataCodewordsPerBlock:16}]}]},{infoBits:102084,versionNumber:24,alignmentPatternCenters:[6,28,54,80,106],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:45},{numBlocks:14,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:30,dataCodewordsPerBlock:16},{numBlocks:2,dataCodewordsPerBlock:17}]}]},{infoBits:102881,versionNumber:25,alignmentPatternCenters:[6,32,58,84,110],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:106},{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:47},{numBlocks:13,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:110507,versionNumber:26,alignmentPatternCenters:[6,30,58,86,114],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:114},{numBlocks:2,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:46},{numBlocks:4,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:28,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:33,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]}]},{infoBits:110734,versionNumber:27,alignmentPatternCenters:[6,34,62,90,118],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:23},{numBlocks:26,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:117786,versionNumber:28,alignmentPatternCenters:[6,26,50,74,98,122],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:117},{numBlocks:10,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:45},{numBlocks:23,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:24},{numBlocks:31,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:31,dataCodewordsPerBlock:16}]}]},{infoBits:119615,versionNumber:29,alignmentPatternCenters:[6,30,54,78,102,126],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:116},{numBlocks:7,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:21,dataCodewordsPerBlock:45},{numBlocks:7,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:23},{numBlocks:37,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:26,dataCodewordsPerBlock:16}]}]},{infoBits:126325,versionNumber:30,alignmentPatternCenters:[6,26,52,78,104,130],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:115},{numBlocks:10,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:47},{numBlocks:10,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:25,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:25,dataCodewordsPerBlock:16}]}]},{infoBits:127568,versionNumber:31,alignmentPatternCenters:[6,30,56,82,108,134],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:3,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:46},{numBlocks:29,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:24},{numBlocks:1,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:133589,versionNumber:32,alignmentPatternCenters:[6,34,60,86,112,138],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:24},{numBlocks:35,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:35,dataCodewordsPerBlock:16}]}]},{infoBits:136944,versionNumber:33,alignmentPatternCenters:[6,30,58,86,114,142],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:21,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:24},{numBlocks:19,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:141498,versionNumber:34,alignmentPatternCenters:[6,34,62,90,118,146],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:6,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:44,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:59,dataCodewordsPerBlock:16},{numBlocks:1,dataCodewordsPerBlock:17}]}]},{infoBits:145311,versionNumber:35,alignmentPatternCenters:[6,30,54,78,102,126,150],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:121},{numBlocks:7,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:47},{numBlocks:26,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:39,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:41,dataCodewordsPerBlock:16}]}]},{infoBits:150283,versionNumber:36,alignmentPatternCenters:[6,24,50,76,102,128,154],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:121},{numBlocks:14,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:47},{numBlocks:34,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:46,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:64,dataCodewordsPerBlock:16}]}]},{infoBits:152622,versionNumber:37,alignmentPatternCenters:[6,28,54,80,106,132,158],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:46},{numBlocks:14,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:49,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:24,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:158308,versionNumber:38,alignmentPatternCenters:[6,32,58,84,110,136,162],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:122},{numBlocks:18,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:46},{numBlocks:32,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:48,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:15},{numBlocks:32,dataCodewordsPerBlock:16}]}]},{infoBits:161089,versionNumber:39,alignmentPatternCenters:[6,26,54,82,110,138,166],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:40,dataCodewordsPerBlock:47},{numBlocks:7,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:43,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:15},{numBlocks:67,dataCodewordsPerBlock:16}]}]},{infoBits:167017,versionNumber:40,alignmentPatternCenters:[6,30,58,86,114,142,170],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:118},{numBlocks:6,dataCodewordsPerBlock:119}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:18,dataCodewordsPerBlock:47},{numBlocks:31,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:24},{numBlocks:34,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:15},{numBlocks:61,dataCodewordsPerBlock:16}]}]}]}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function i(e,t,n,r){var i=e.x-t.x+n.x-r.x,a=e.y-t.y+n.y-r.y;if(i===0&&a===0)return{a11:t.x-e.x,a12:t.y-e.y,a13:0,a21:n.x-t.x,a22:n.y-t.y,a23:0,a31:e.x,a32:e.y,a33:1};var o=t.x-n.x,s=r.x-n.x,c=t.y-n.y,l=r.y-n.y,u=o*l-s*c,d=(i*l-s*a)/u,f=(o*a-i*c)/u;return{a11:t.x-e.x+d*t.x,a12:t.y-e.y+d*t.y,a13:d,a21:r.x-e.x+f*r.x,a22:r.y-e.y+f*r.y,a23:f,a31:e.x,a32:e.y,a33:1}}function a(e,t,n,r){var a=i(e,t,n,r);return{a11:a.a22*a.a33-a.a23*a.a32,a12:a.a13*a.a32-a.a12*a.a33,a13:a.a12*a.a23-a.a13*a.a22,a21:a.a23*a.a31-a.a21*a.a33,a22:a.a11*a.a33-a.a13*a.a31,a23:a.a13*a.a21-a.a11*a.a23,a31:a.a21*a.a32-a.a22*a.a31,a32:a.a12*a.a31-a.a11*a.a32,a33:a.a11*a.a22-a.a12*a.a21}}function o(e,t){return{a11:e.a11*t.a11+e.a21*t.a12+e.a31*t.a13,a12:e.a12*t.a11+e.a22*t.a12+e.a32*t.a13,a13:e.a13*t.a11+e.a23*t.a12+e.a33*t.a13,a21:e.a11*t.a21+e.a21*t.a22+e.a31*t.a23,a22:e.a12*t.a21+e.a22*t.a22+e.a32*t.a23,a23:e.a13*t.a21+e.a23*t.a22+e.a33*t.a23,a31:e.a11*t.a31+e.a21*t.a32+e.a31*t.a33,a32:e.a12*t.a31+e.a22*t.a32+e.a32*t.a33,a33:e.a13*t.a31+e.a23*t.a32+e.a33*t.a33}}function s(e,t){for(var n=a({x:3.5,y:3.5},{x:t.dimension-3.5,y:3.5},{x:t.dimension-6.5,y:t.dimension-6.5},{x:3.5,y:t.dimension-3.5}),s=o(i(t.topLeft,t.topRight,t.alignmentPattern,t.bottomLeft),n),c=r.BitMatrix.createEmpty(t.dimension,t.dimension),l=function(e,t){var n=s.a13*e+s.a23*t+s.a33;return{x:(s.a11*e+s.a21*t+s.a31)/n,y:(s.a12*e+s.a22*t+s.a32)/n}},u=0;u<t.dimension;u++)for(var d=0;d<t.dimension;d++){var f=l(d+.5,u+.5);c.set(d,u,e.get(Math.floor(f.x),Math.floor(f.y)))}return{matrix:c,mappingFunction:l}}t.extract=s}),(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=4,i=.5,a=1.5,o=function(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)};function s(e){return e.reduce(function(e,t){return e+t})}function c(e,t,n){var r,i,a,s,c=o(e,t),l=o(t,n),u=o(e,n),d,f,p;return l>=c&&l>=u?(r=[t,e,n],d=r[0],f=r[1],p=r[2]):u>=l&&u>=c?(i=[e,t,n],d=i[0],f=i[1],p=i[2]):(a=[e,n,t],d=a[0],f=a[1],p=a[2]),(p.x-f.x)*(d.y-f.y)-(p.y-f.y)*(d.x-f.x)<0&&(s=[p,d],d=s[0],p=s[1]),{bottomLeft:d,topLeft:f,topRight:p}}function l(e,t,n,r){var i=(s(d(e,n,r,5))/7+s(d(e,t,r,5))/7+s(d(n,e,r,5))/7+s(d(t,e,r,5))/7)/4;if(i<1)throw Error(`Invalid module size`);var a=Math.round(o(e,t)/i),c=Math.round(o(e,n)/i),l=Math.floor((a+c)/2)+7;switch(l%4){case 0:l++;break;case 2:l--;break}return{dimension:l,moduleSize:i}}function u(e,t,n,r){var i=[{x:Math.floor(e.x),y:Math.floor(e.y)}],a=Math.abs(t.y-e.y)>Math.abs(t.x-e.x),s,c,l,u;a?(s=Math.floor(e.y),c=Math.floor(e.x),l=Math.floor(t.y),u=Math.floor(t.x)):(s=Math.floor(e.x),c=Math.floor(e.y),l=Math.floor(t.x),u=Math.floor(t.y));for(var d=Math.abs(l-s),f=Math.abs(u-c),p=Math.floor(-d/2),m=s<l?1:-1,h=c<u?1:-1,g=!0,_=s,v=c;_!==l+m;_+=m){var y=a?v:_,b=a?_:v;if(n.get(y,b)!==g&&(g=!g,i.push({x:y,y:b}),i.length===r+1))break;if(p+=f,p>0){if(v===u)break;v+=h,p-=d}}for(var x=[],S=0;S<r;S++)i[S]&&i[S+1]?x.push(o(i[S],i[S+1])):x.push(0);return x}function d(e,t,n,r){var i,a=t.y-e.y,o=t.x-e.x,s=u(e,t,n,Math.ceil(r/2)),c=u(e,{x:e.x-o,y:e.y-a},n,Math.ceil(r/2)),l=s.shift()+c.shift()-1;return(i=c.concat(l)).concat.apply(i,s)}function f(e,t){var n=s(e)/s(t),r=0;return t.forEach(function(t,i){r+=(e[i]-t*n)**2}),{averageSize:n,error:r}}function p(e,t,n){try{var r=d(e,{x:-1,y:e.y},n,t.length),i=d(e,{x:e.x,y:-1},n,t.length),a=d(e,{x:Math.max(0,e.x-e.y)-1,y:Math.max(0,e.y-e.x)-1},n,t.length),o=d(e,{x:Math.min(n.width,e.x+e.y)+1,y:Math.min(n.height,e.y+e.x)+1},n,t.length),s=f(r,t),c=f(i,t),l=f(a,t),u=f(o,t),p=Math.sqrt(s.error*s.error+c.error*c.error+l.error*l.error+u.error*u.error),m=(s.averageSize+c.averageSize+l.averageSize+u.averageSize)/4;return p+((s.averageSize-m)**2+(c.averageSize-m)**2+(l.averageSize-m)**2+(u.averageSize-m)**2)/m}catch{return 1/0}}function m(e,t){for(var n=Math.round(t.x);e.get(n,Math.round(t.y));)n--;for(var r=Math.round(t.x);e.get(r,Math.round(t.y));)r++;for(var i=(n+r)/2,a=Math.round(t.y);e.get(Math.round(i),a);)a--;for(var o=Math.round(t.y);e.get(Math.round(i),o);)o++;return{x:i,y:(a+o)/2}}function h(e){for(var t=[],n=[],o=[],l=[],u=function(r){for(var c=0,u=!1,d=[0,0,0,0,0],f=function(t){var o=e.get(t,r);if(o===u)c++;else{d=[d[1],d[2],d[3],d[4],c],c=1,u=o;var f=s(d)/7,p=Math.abs(d[0]-f)<f&&Math.abs(d[1]-f)<f&&Math.abs(d[2]-3*f)<3*f&&Math.abs(d[3]-f)<f&&Math.abs(d[4]-f)<f&&!o,m=s(d.slice(-3))/3,h=Math.abs(d[2]-m)<m&&Math.abs(d[3]-m)<m&&Math.abs(d[4]-m)<m&&o;if(p){var g=t-d[3]-d[4],_=g-d[2],v={startX:_,endX:g,y:r},y=n.filter(function(e){return _>=e.bottom.startX&&_<=e.bottom.endX||g>=e.bottom.startX&&_<=e.bottom.endX||_<=e.bottom.startX&&g>=e.bottom.endX&&d[2]/(e.bottom.endX-e.bottom.startX)<a&&d[2]/(e.bottom.endX-e.bottom.startX)>i});y.length>0?y[0].bottom=v:n.push({top:v,bottom:v})}if(h){var b=t-d[4],x=b-d[3],v={startX:x,y:r,endX:b},y=l.filter(function(e){return x>=e.bottom.startX&&x<=e.bottom.endX||b>=e.bottom.startX&&x<=e.bottom.endX||x<=e.bottom.startX&&b>=e.bottom.endX&&d[2]/(e.bottom.endX-e.bottom.startX)<a&&d[2]/(e.bottom.endX-e.bottom.startX)>i});y.length>0?y[0].bottom=v:l.push({top:v,bottom:v})}}},p=-1;p<=e.width;p++)f(p);t.push.apply(t,n.filter(function(e){return e.bottom.y!==r&&e.bottom.y-e.top.y>=2})),n=n.filter(function(e){return e.bottom.y===r}),o.push.apply(o,l.filter(function(e){return e.bottom.y!==r})),l=l.filter(function(e){return e.bottom.y===r})},d=0;d<=e.height;d++)u(d);t.push.apply(t,n.filter(function(e){return e.bottom.y-e.top.y>=2})),o.push.apply(o,l);var f=t.filter(function(e){return e.bottom.y-e.top.y>=2}).map(function(t){var n=(t.top.startX+t.top.endX+t.bottom.startX+t.bottom.endX)/4,r=(t.top.y+t.bottom.y+1)/2;if(e.get(Math.round(n),Math.round(r))){var i=[t.top.endX-t.top.startX,t.bottom.endX-t.bottom.startX,t.bottom.y-t.top.y+1],a=s(i)/i.length;return{score:p({x:Math.round(n),y:Math.round(r)},[1,1,3,1,1],e),x:n,y:r,size:a}}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score}).map(function(e,t,n){if(t>r)return null;var i=n.filter(function(e,n){return t!==n}).map(function(t){return{x:t.x,y:t.y,score:t.score+(t.size-e.size)**2/e.size,size:t.size}}).sort(function(e,t){return e.score-t.score});if(i.length<2)return null;var a=e.score+i[0].score+i[1].score;return{points:[e].concat(i.slice(0,2)),score:a}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score});if(f.length===0)return null;var h=c(f[0].points[0],f[0].points[1],f[0].points[2]),_=h.topRight,v=h.topLeft,y=h.bottomLeft,b=g(e,o,_,v,y),x=[];b&&x.push({alignmentPattern:{x:b.alignmentPattern.x,y:b.alignmentPattern.y},bottomLeft:{x:y.x,y:y.y},dimension:b.dimension,topLeft:{x:v.x,y:v.y},topRight:{x:_.x,y:_.y}});var S=m(e,_),C=m(e,v),w=m(e,y),T=g(e,o,S,C,w);return T&&x.push({alignmentPattern:{x:T.alignmentPattern.x,y:T.alignmentPattern.y},bottomLeft:{x:w.x,y:w.y},topLeft:{x:C.x,y:C.y},topRight:{x:S.x,y:S.y},dimension:T.dimension}),x.length===0?null:x}t.locate=h;function g(e,t,n,r,i){var a,c,u;try{a=l(r,n,i,e),c=a.dimension,u=a.moduleSize}catch{return null}var d={x:n.x-r.x+i.x,y:n.y-r.y+i.y},f=(o(r,i)+o(r,n))/2/u,m=1-3/f,h={x:r.x+m*(d.x-r.x),y:r.y+m*(d.y-r.y)},g=t.map(function(t){var n=(t.top.startX+t.top.endX+t.bottom.startX+t.bottom.endX)/4,r=(t.top.y+t.bottom.y+1)/2;if(e.get(Math.floor(n),Math.floor(r))){var i=[t.top.endX-t.top.startX,t.bottom.endX-t.bottom.startX,t.bottom.y-t.top.y+1];return s(i)/i.length,{x:n,y:r,score:p({x:Math.floor(n),y:Math.floor(r)},[1,1,1],e)+o({x:n,y:r},h)}}}).filter(function(e){return!!e}).sort(function(e,t){return e.score-t.score});return{alignmentPattern:f>=15&&g.length?g[0]:h,dimension:c}}})]).default})}))(),1);function LW(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function RW(e){let t=e.length%4,n=(e+(t?`=`.repeat(4-t):``)).replace(/-/g,`+`).replace(/_/g,`/`),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}async function zW(e,t){let n=t.writable.getWriter();n.write(e),n.close();let r=t.readable.getReader(),i=[],a=0;for(;;){let{value:e,done:t}=await r.read();if(t)break;e&&(i.push(e),a+=e.length)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return o}async function BW(e){let t=new TextEncoder().encode(e),n=await zW(t,new CompressionStream(`deflate-raw`));return n.length<t.length?`D`+LW(n):`R`+LW(t)}async function VW(e){let t=e.trim();if(!t)throw Error(`empty signal token`);let n=RW(t.slice(1));if(t[0]===`D`)return new TextDecoder().decode(await zW(n,new DecompressionStream(`deflate-raw`)));if(t[0]===`R`)return new TextDecoder().decode(n);throw Error(`unknown signal codec tag: ${t[0]}`)}async function HW(e){return BW(JSON.stringify({k:`offer`,v:2,hub:e.hubInstanceId,name:e.hubName,sdp:e.sdp,sec:e.secret}))}async function UW(e){try{let t=JSON.parse(await VW(e.trim()));return t.k!==`answer`||typeof t.sdp!=`string`?null:{sdp:t.sdp,deviceName:typeof t.dev==`string`?t.dev:`Mobile device`,platform:typeof t.plat==`string`?t.plat:`web`,secret:typeof t.sec==`string`?t.sec:``}}catch{return null}}function WW({open:e,onClose:t,onPaired:n}){let{t:r}=K(`settings`),[i,a]=(0,Q.useState)(`loading`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useCallback)(()=>{f.current!=null&&(cancelAnimationFrame(f.current),f.current=null),d.current?.getTracks().forEach(e=>e.stop()),d.current=null},[]),m=(0,Q.useCallback)(()=>{p(),a(`loading`),s(``),l(null),t()},[t,p]),h=(0,Q.useCallback)(async e=>{let t=await UW(e);if(!t){J.error(r(`pairWeb.notAnswer`));return}p(),a(`connecting`);try{let e=await fetch(`/api/mobile/webrtc/answer`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sdp:t.sdp})}),i=await e.json().catch(()=>({}));if(!e.ok||!i.ok)throw Error(`rejected`);a(`paired`),J.success(r(`pairWeb.pairedToast`)),n();let o=0,s=setInterval(()=>{n(),++o>=3&&(clearInterval(s),m())},1500)}catch{l(r(`pairWeb.answerRejected`)),a(`offer`)}},[r,p,n,m]);(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return l(null),a(`loading`),(async()=>{try{let e=await fetch(`/api/mobile/webrtc/offer`,{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json(),r=await HW({hubInstanceId:n.hubInstanceId,hubName:n.hubName,sdp:n.sdp,secret:n.secret});t||(s(r),a(`offer`))}catch(e){t||(l(e.message),a(`offer`))}})(),()=>{t=!0}},[e]),(0,Q.useEffect)(()=>{if(i!==`scanning`)return;let e=d.current,t=u.current;if(!e||!t)return;t.srcObject=e,t.play().catch(()=>{});let n=document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)return;let a=()=>{if(d.current){if(t.videoWidth){n.width=t.videoWidth,n.height=t.videoHeight,r.drawImage(t,0,0);let e=r.getImageData(0,0,n.width,n.height),i=(0,IW.default)(e.data,e.width,e.height);if(i){h(i.data);return}}f.current=requestAnimationFrame(a)}};f.current=requestAnimationFrame(a)},[i,h]),(0,Q.useEffect)(()=>()=>p(),[p]);async function g(){if(l(null),!navigator.mediaDevices?.getUserMedia){J.error(r(`pairWeb.cameraFailed`,{message:`unsupported`}));return}try{d.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),a(`scanning`)}catch(e){J.error(r(`pairWeb.cameraFailed`,{message:e.message})),a(`offer`)}}return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||m()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-md`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:r(`pairWeb.title`)}),(0,$.jsx)(Mn,{children:r(`pairWeb.description`)})]}),c&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:r(`pairWeb.startFailed`,{error:c})}),i===`loading`&&(0,$.jsx)(`div`,{className:`h-56 bg-muted/30 rounded-lg animate-pulse`}),i===`offer`&&o&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,children:[(0,$.jsx)(`div`,{className:`bg-white p-3 rounded-lg`,children:(0,$.jsx)(FW,{value:o,size:220})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:r(`pairWeb.showThenScan`)}),(0,$.jsx)(Z,{onClick:()=>void g(),className:`gap-2`,children:r(`pairWeb.scanAnswer`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent-info underline`,onClick:()=>{navigator.clipboard?.writeText(o),J.success(r(`pairWeb.codeCopied`))},children:r(`pairWeb.copyCode`)})]}),i===`scanning`&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,children:[(0,$.jsx)(`video`,{ref:u,playsInline:!0,className:`w-full max-h-72 rounded-lg bg-black`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:r(`pairWeb.scanning`)}),(0,$.jsx)(Z,{variant:`outline`,onClick:()=>{p(),a(`offer`)},children:r(`pairWeb.cancel`)})]}),i===`connecting`&&(0,$.jsx)(`p`,{className:`py-6 text-center text-muted-foreground`,children:r(`pairWeb.connecting`)}),i===`paired`&&(0,$.jsx)(`p`,{className:`py-6 text-center text-accent-success font-medium`,children:r(`pairWeb.paired`)})]})})}var GW=typeof navigator<`u`&&/Win/i.test(navigator.platform);function KW(e){return!e||e.length<16?e??`—`:`${e.slice(0,8)}…${e.slice(-8)}`}function qW(){let{t:e}=K(`settings`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/mobile/status`);e.ok&&n(await e.json())}catch{}},[]),u=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/mobile/devices`);e.ok&&i((await e.json()).devices)}catch{}},[]);(0,Q.useEffect)(()=>{l(),u()},[l,u]);let{registerHandler:d,unregisterHandler:f}=qe();(0,Q.useEffect)(()=>{let e=`mobile-access-devices`;return d(e,e=>{let t=e?.type;(t===`mobile.device_paired`||t===`mobile.device_revoked`)&&u()}),()=>f(e)},[d,f,u]);async function p(){if(t){o(!0);try{let e=t.enabled?`disable`:`enable`,r=await fetch(`/api/mobile/${e}`,{method:`POST`});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}n(await r.json())}catch(n){J.error(t.enabled?e(`mobile.disableFailed`,{message:n.message}):e(`mobile.enableFailed`,{message:n.message}))}finally{o(!1)}}}async function m(e){await fetch(`/api/mobile/devices/${e}`,{method:`DELETE`}).catch(()=>{}),u()}async function h(){if(window.confirm(e(`mobile.resetConfirm`))){o(!0);try{let t=await fetch(`/api/mobile/cert/rotate`,{method:`POST`});t.ok&&n(await t.json()),u(),J.success(e(`mobile.identityReset`))}finally{o(!1)}}}return t?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2`,children:[(0,$.jsx)(oc,{className:`h-3.5 w-3.5`}),` `,e(`mobile.heading`)]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`mobile.description`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:t.enabled?e(`mobile.accessOn`):e(`mobile.accessOff`)}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.running?e(`mobile.listeningOnPort`,{port:t.port}):e(`mobile.notListening`)})]}),(0,$.jsx)(Z,{variant:t.enabled?`outline`:`default`,disabled:a,onClick:p,children:t.enabled?e(`mobile.turnOff`):e(`mobile.turnOn`)})]}),t.enabled&&t.running&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(Z,{onClick:()=>c(!0),className:`gap-2`,children:[(0,$.jsx)(E,{className:`h-4 w-4`}),` `,e(`mobile.pairWebDevice`)]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(ic,{className:`h-3.5 w-3.5 text-accent-success`}),(0,$.jsx)(`span`,{title:t.certFingerprint??``,children:KW(t.certFingerprint)}),(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:h,disabled:a,children:e(`mobile.reset`)})]})]}),GW&&(0,$.jsx)(`p`,{className:`text-xs text-accent-warning`,children:e(`mobile.windowsFirewall`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground`,children:e(`mobile.pairedDevices`)}),r.filter(e=>!e.revoked).length===0?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e(`mobile.noDevices`)}):r.filter(e=>!e.revoked).map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-muted/30 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`text-sm`,children:[t.name,` `,(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,t.platform]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`mobile.revokeDevice`,{name:t.name}),className:`text-muted-foreground hover:text-destructive`,onClick:()=>m(t.id),children:(0,$.jsx)(dn,{className:`h-4 w-4`})})]},t.id))]})]}),(0,$.jsx)(WW,{open:s,onClose:()=>c(!1),onPaired:u})]}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})}var JW=[`claude`,`codex`,`gemini`,`kimi`],YW=[`claude`,`gemini`,`kimi`],XW=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function ZW(e){return`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium transition-all duration-150 disabled:opacity-50 ${e?`border-accent-primary/50 bg-accent-primary/15 text-accent-primary shadow-[0_0_8px_-2px] shadow-accent-primary/30`:`border-border/60 bg-transparent text-muted-foreground/70 hover:border-border hover:text-foreground hover:bg-muted/30`}`}function QW(){let{t:e}=K(`mcp`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)({}),[_,v]=(0,Q.useState)(null),y=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/external-mcp`);if(!e.ok)return;let t=await e.json();t?.settings?.servers&&t?.discovered?.orphanIds&&n(t)}catch{}},[]);(0,Q.useEffect)(()=>{y()},[y]);let b=(0,Q.useCallback)(async r=>{if(!t)return;let a=t;n({...t,settings:{version:1,servers:r}}),i(!0);try{let e=await fetch(`${He}/api/external-mcp`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({servers:r})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`HTTP ${e.status}`)}let t=await e.json();return t?.settings?.servers&&t?.discovered?.orphanIds&&n(t),!0}catch(t){n(a);let r=t.message;return J.error(e([`external.errors.${r}`,`external.updateFailed`])),!1}finally{i(!1)}},[t,e]),x=(0,Q.useMemo)(()=>{if(!t)return[];let{settings:e,discovered:n}=t,r=[],i=new Set(Object.keys(e.servers));for(let[t,i]of Object.entries(e.servers))r.push({id:t,name:i.name,source:i.source,sourceProvider:i.sourceProvider,providers:i.providers,orphan:n.orphanIds.includes(t),stored:!0});for(let e of YW)for(let t of n[e])i.has(t.id)||r.push({id:t.id,name:t.name,source:`discovered`,sourceProvider:e,providers:{},orphan:!1,stored:!1});return r.sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))},[t]),S=(0,Q.useCallback)((e,n)=>{if(!t)return;let r={...t.settings.servers},i=r[e.id],a={...i?.providers??{}};a[n]?delete a[n]:a[n]=!0,e.source===`discovered`&&Object.keys(a).length===0?delete r[e.id]:r[e.id]=i?{...i,providers:a}:{source:`discovered`,sourceProvider:e.sourceProvider,name:e.name,providers:a},b(r)},[t,b]),C=(0,Q.useCallback)(e=>{if(!t)return;let n={...t.settings.servers};delete n[e],b(n)},[t,b]),w=s.trim(),T=w!==``&&(!XW.test(w)||w===`specrails`),D=w!==``&&!T&&`c:${w}`!==_&&!!t?.settings.servers[`c:${w}`],O=w!==``&&!T&&!D&&l.trim()!==``,k=(0,Q.useCallback)(()=>{o(!1),v(null),c(``),u(``),f(``),m([]),g({})},[]),A=(0,Q.useCallback)(()=>{v(null),c(``),u(``),f(``),m([]),g({}),o(!0)},[]),j=(0,Q.useCallback)(e=>{let n=t?.settings.servers[e];!n||n.source!==`custom`||!n.transport||(v(e),c(n.name),u(n.transport.command),f(n.transport.args.join(` `)),m(Object.entries(n.transport.env).map(([e,t])=>({key:e,value:t}))),g({...n.providers}),o(!0))},[t]),M=(0,Q.useCallback)(async()=>{if(!t||!O)return;let e=w,n={};for(let e of p){let t=e.key.trim();t&&(n[t]=e.value)}let r={};for(let[e,t]of Object.entries(h))t&&(r[e]=!0);let i={...t.settings.servers};_&&_!==`c:${e}`&&delete i[_],i[`c:${e}`]={source:`custom`,name:e,providers:r,transport:{command:l.trim(),args:d.trim()?d.trim().split(/\s+/):[],env:n}},await b(i)&&k()},[t,O,w,l,d,p,h,_,b,k]);return t?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,"data-testid":`external-mcp-card`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`text-xs font-semibold text-foreground flex items-center gap-1.5`,children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),` `,e(`external.heading`)]}),(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-[11px]`,disabled:r,onClick:()=>a&&!_?o(!1):A(),"data-testid":`external-mcp-add`,children:[(0,$.jsx)(cn,{className:`h-3 w-3`}),` `,e(`external.addCustom`)]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`external.description`)}),(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] text-accent-warning`,children:[(0,$.jsx)(fn,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),e(`external.warning`)]}),a&&(0,$.jsxs)(`div`,{className:`space-y-2.5 rounded-md border border-border/70 bg-muted/20 p-3`,"data-testid":`external-mcp-form`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-name`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.nameLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-name`,autoFocus:!0,value:s,onChange:e=>c(e.target.value),placeholder:e(`external.form.name`),className:`w-full rounded-md border bg-background px-2 py-1 text-xs transition-colors ${T||D?`border-destructive/60 focus:outline-destructive`:`border-border`}`}),(T||D)&&(0,$.jsx)(`p`,{className:`text-[10px] text-destructive`,"data-testid":`external-mcp-name-hint`,children:e(T?`external.form.nameInvalid`:`external.form.nameTaken`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-command`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.commandLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-command`,value:l,onChange:e=>u(e.target.value),placeholder:e(`external.form.command`),className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{htmlFor:`ext-mcp-args`,className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.argsLabel`)}),(0,$.jsx)(`input`,{id:`ext-mcp-args`,value:d,onChange:e=>f(e.target.value),placeholder:e(`external.form.args`),className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.envLabel`)}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>[...e,{key:``,value:``}]),className:`inline-flex items-center gap-1 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors`,"data-testid":`external-mcp-env-add`,children:[(0,$.jsx)(cn,{className:`h-2.5 w-2.5`}),` `,e(`external.form.addVar`)]})]}),p.map((t,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`input`,{value:t.key,onChange:e=>m(t=>t.map((t,r)=>r===n?{...t,key:e.target.value}:t)),placeholder:e(`external.form.envKey`),"aria-label":`${e(`external.form.envKey`)} ${n+1}`,className:`w-2/5 rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`=`}),(0,$.jsx)(`input`,{value:t.value,onChange:e=>m(t=>t.map((t,r)=>r===n?{...t,value:e.target.value}:t)),placeholder:e(`external.form.envValue`),"aria-label":`${e(`external.form.envValue`)} ${n+1}`,className:`flex-1 rounded-md border border-border bg-background px-2 py-1 text-xs font-mono`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e=>e.filter((e,t)=>t!==n)),className:`text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`${e(`external.remove`)} ${n+1}`,children:(0,$.jsx)(dn,{className:`h-3 w-3`})})]},n))]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`span`,{className:`block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`external.form.enableFor`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:JW.map(e=>{let t=h[e]===!0;return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":`custom · ${e}`,onClick:()=>g(t=>({...t,[e]:!t[e]})),className:ZW(t),"data-testid":`external-mcp-form-provider-${e}`,children:[t&&(0,$.jsx)(Ht,{className:`h-2.5 w-2.5`,strokeWidth:3}),e]},e)})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-1.5 pt-0.5`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px]`,onClick:k,children:e(`external.form.cancel`)}),(0,$.jsx)(Z,{size:`sm`,className:`h-7 text-[11px]`,disabled:r||!O,onClick:()=>void M(),"data-testid":`external-mcp-form-save`,children:e(`external.form.save`)})]})]}),x.length===0&&t.discovered.codexNative.length===0?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:e(`external.empty`)}):(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[x.map(t=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-border/60 px-2 py-1.5`,"data-testid":`external-mcp-row-${t.id}`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground min-w-0 truncate`,children:t.name}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-1.5 py-px text-[10px] text-muted-foreground`,children:t.source===`custom`?e(`external.sourceCustom`):e(`external.sourceDiscovered`,{provider:t.sourceProvider})}),t.orphan&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-accent-warning/15 px-1.5 py-px text-[10px] text-accent-warning`,"data-testid":`external-mcp-orphan`,children:[(0,$.jsx)(fn,{className:`h-2.5 w-2.5`}),` `,e(`external.orphan`)]}),(0,$.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex items-center gap-1`,children:JW.map(e=>{let n=t.providers[e]===!0;return(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":`${t.name} · ${e}`,disabled:r,onClick:()=>S(t,e),className:ZW(n),children:[n&&(0,$.jsx)(Ht,{className:`h-2.5 w-2.5`,strokeWidth:3}),e]},e)})}),t.stored&&t.source===`custom`&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(t.id),disabled:r,className:`text-muted-foreground hover:text-foreground`,"aria-label":e(`external.edit`),"data-testid":`external-mcp-edit-${t.id}`,children:(0,$.jsx)(an,{className:`h-3 w-3`})}),t.stored&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t.id),disabled:r,className:`text-muted-foreground hover:text-destructive`,"aria-label":e(`external.remove`),"data-testid":`external-mcp-remove-${t.id}`,children:(0,$.jsx)(dn,{className:`h-3 w-3`})})]})]},t.id)),t.discovered.codexNative.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border/40 px-2 py-1.5 opacity-70`,"data-testid":`external-mcp-codex-${t}`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground min-w-0 truncate`,children:t}),(0,$.jsx)(`span`,{className:`rounded-full bg-muted/60 px-1.5 py-px text-[10px] text-muted-foreground`,children:e(`external.codexNative`)})]},`codex:${t}`))]})]}):(0,$.jsx)(`div`,{className:`h-16 bg-muted/30 rounded-lg animate-pulse`,"data-testid":`external-mcp-skeleton`})}async function $W(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 eG(e){return JSON.stringify({mcpServers:{specrails:{command:e.bridgeCommand}}},null,2)}function tG(){let{t:e}=K(`mcp`),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/mcp-admin/status`);e.ok&&n(await e.json())}catch{}},[]),u=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${He}/api/mcp-admin/config`);e.ok&&i(await e.json())}catch{}},[]);(0,Q.useEffect)(()=>{l(),u()},[l,u]);let d=(0,Q.useCallback)(async()=>{if(t){o(!0);try{let e=t.enabled?`disable`:`enable`,n=await fetch(`${He}/api/mcp-admin/${e}`,{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}await l()}catch(n){J.error(t.enabled?e(`enable.disableFailed`,{message:n.message}):e(`enable.enableFailed`,{message:n.message}))}finally{o(!1)}}},[t,l,e]),f=(0,Q.useCallback)(async r=>{if(!t)return;o(!0);let i=!t.tiers[r];try{let e=await fetch(`${He}/api/mcp-admin/tiers`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({[r]:i})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`HTTP ${e.status}`)}let t=await e.json();n(e=>e&&{...e,tiers:t.tiers})}catch(t){J.error(e(`tiers.updateFailed`,{message:t.message}))}finally{o(!1)}},[t,e]),p=(0,Q.useCallback)(async()=>{r&&(await $W(eG(r))?(c(`config`),window.setTimeout(()=>c(e=>e===`config`?null:e),1500)):J.error(e(`config.copyFailed`)))},[r,e]),m=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${He}/api/mcp-admin/token`);if(!t.ok)throw Error(`HTTP ${t.status}`);let{token:n}=await t.json();await $W(n)?(c(`token`),window.setTimeout(()=>c(e=>e===`token`?null:e),1500)):J.error(e(`config.copyFailed`))}catch{J.error(e(`config.copyFailed`))}},[e]),h=(0,Q.useCallback)(async()=>{if(window.confirm(e(`token.regenerateConfirm`))){o(!0);try{let t=await fetch(`${He}/api/mcp-admin/regenerate-token`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}`);await l(),J.success(e(`token.regenerated`))}catch(t){J.error(e(`token.regenerateFailed`,{message:t.message}))}finally{o(!1)}}},[l,e]);if(!t)return(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`});let g=[{key:`write`,label:e(`tiers.write`),help:e(`tiers.writeHelp`)},{key:`aiSpawn`,label:e(`tiers.aiSpawn`),help:e(`tiers.aiSpawnHelp`)},{key:`destructive`,label:e(`tiers.destructive`),help:e(`tiers.destructiveHelp`)}];return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2`,children:[(0,$.jsx)(Us,{className:`h-3.5 w-3.5`}),` `,e(`heading`)]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`explainer.what`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80`,children:e(`explainer.how`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:t.enabled?e(`enable.on`):e(`enable.off`)}),(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[t.running?e(`enable.running`,{count:t.toolCount}):e(`enable.stopped`),t.enabled&&t.activeSessions>0&&(0,$.jsxs)($.Fragment,{children:[` · `,e(`enable.activeSessions`,{count:t.activeSessions})]})]})]}),(0,$.jsx)(Z,{variant:t.enabled?`outline`:`default`,disabled:a,onClick:()=>void d(),children:t.enabled?e(`enable.turnOff`):e(`enable.turnOn`)})]}),t.enabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`tiers.heading`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`explainer.grants`)}),(0,$.jsxs)(`label`,{className:`flex items-start gap-2 opacity-70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!0,className:`mt-0.5`,"aria-label":e(`tiers.read`)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e(`tiers.read`)}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:e(`tiers.readHelp`)})]})]}),g.map(e=>(0,$.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.tiers[e.key],disabled:a,onChange:()=>void f(e.key),className:`mt-0.5`,"aria-label":e.label}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),(0,$.jsx)(`span`,{className:`block text-[10px] text-muted-foreground`,children:e.help})]})]},e.key))]}),r&&(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`config.heading`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,"data-testid":`mcp-copy-config`,children:s===`config`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`h-3 w-3 text-accent-success`}),` `,e(`config.configCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`h-3 w-3`}),` `,e(`config.copyConfig`)]})})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`config.description`)}),(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-muted/40 p-2 text-[10px] leading-relaxed text-foreground`,children:eG(r)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`token.heading`)}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:e(`token.description`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:e(`token.hint`,{hint:t.tokenHint})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,"data-testid":`mcp-copy-token`,children:s===`token`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`h-3 w-3 text-accent-success`}),` `,e(`token.tokenCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`h-3 w-3`}),` `,e(`token.copyToken`)]})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void h(),disabled:a,className:`inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-[11px] font-medium text-muted-foreground hover:text-foreground disabled:opacity-50`,"data-testid":`mcp-regenerate-token`,children:[(0,$.jsx)(Js,{className:`h-3 w-3`}),` `,e(`token.regenerate`)]})]})]})]})]}),(0,$.jsx)(QW,{})]})}var nG=`specrails-os-notifications`,rG={enabled:!0,filter:`all`};function iG(){try{let e=localStorage.getItem(nG);if(!e)return rG;let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:rG.enabled,filter:t.filter===`completed`||t.filter===`failed`?t.filter:rG.filter}}catch{return rG}}function aG(e){localStorage.setItem(nG,JSON.stringify(e))}function oG({setActiveProjectId:e,projectsById:t}={}){let n=v(),r=(0,Q.useRef)(n);(0,Q.useEffect)(()=>{r.current=n},[n]);let i=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{i.current=e},[e]);let a=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{a.current=t},[t]);let o=(0,Q.useRef)(new Map),s=(0,Q.useRef)(new Map),{registerHandler:c,unregisterHandler:l}=qe(),u=(0,Q.useCallback)(e=>{let t=e;if(!t)return;if(t.type===`job.stuck`&&typeof t.jobId==`string`){let e=Array.isArray(t.actions)?t.actions.filter(e=>e===`stop`):[];f(t.jobId,t.projectId??null,t.staleMs??0,e);return}if(t.type===`loop.provider_limit`&&typeof t.runId==`string`){d(t.runId,t.projectId??null,typeof t.provider==`string`?t.provider:``,typeof t.resetsAt==`string`&&t.resetsAt?t.resetsAt:null,typeof t.message==`string`?t.message:``);return}if(t.type!==`queue`||!Array.isArray(t.jobs))return;let n=t.projectId??null;for(let e of t.jobs){let t=o.current.get(e.id),r=e.status;n&&s.current.set(e.id,n),t===`running`&&(r===`completed`||r===`failed`)&&m(e,n),o.current.set(e.id,r)}},[]);function d(e,t,n,r,i){let o=iG();if(!o.enabled||o.filter===`completed`)return;let s=t?a.current?.get(t)??``:``,c=n?n.charAt(0).toUpperCase()+n.slice(1):`AI`,l=r?G.t(`commands:notifications.providerLimitBody`,{provider:c,resetsAt:r}):G.t(`commands:notifications.providerLimitBodyNoReset`,{provider:c}),u=G.t(`commands:notifications.providerLimit`);J.error(u,{id:`provider-limit:${e}`,description:`${s?`[${s}] `:``}${l}${i?` · ${i}`:``}`,duration:6e4}),!(typeof Notification>`u`)&&Notification.permission===`granted`&&(()=>{let t=new Notification(u,{body:s?`[${s}] ${l}`:l,tag:`specrails-provider-limit:${e}`});t.onclick=()=>{window.focus(),t.close()}})()}function f(e,t,n,o=[]){let s=iG();if(!s.enabled||s.filter===`completed`)return;let c=Math.max(1,Math.round(n/6e4)),l=t?a.current?.get(t)??``:``,u=G.t(`commands:notifications.jobStuckBody`,{count:c});if(t&&o.includes(`stop`)&&J.warning(G.t(`commands:notifications.jobStuck`),{id:`job-stuck:${e}`,description:l?`[${l}] ${u}`:u,duration:2e4,action:{label:G.t(`commands:notifications.jobStuckStop`),onClick:()=>{p(t,e)}}}),typeof Notification>`u`)return;function d(){let n=new Notification(G.t(`commands:notifications.jobStuck`),{body:l?`[${l}] ${u}`:u,tag:`specrails-job-stuck:${e}`});n.onclick=()=>{window.focus(),t&&i.current?(i.current(t),setTimeout(()=>{r.current(`/jobs/${e}`)},100)):r.current(`/jobs/${e}`),n.close()}}Notification.permission===`granted`?d():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&d()})}async function p(e,t){try{let n=await fetch(`/api/projects/${e}/jobs/${t}/cancel`,{method:`POST`});if(!n.ok)throw Error(`HTTP ${n.status}`);J.success(G.t(`commands:notifications.jobStuckStopped`),{id:`job-stuck:${t}`})}catch{J.error(G.t(`commands:notifications.jobStuckStopFailed`),{id:`job-stuck:${t}`})}}function m(e,t){if(typeof Notification>`u`||typeof document<`u`&&!document.hidden)return;let n=iG();if(!n.enabled||n.filter===`completed`&&e.status!==`completed`||n.filter===`failed`&&e.status!==`failed`)return;function o(){let n=e.status===`completed`?G.t(`commands:notifications.jobCompleted`):G.t(`commands:notifications.jobFailed`),o=t?a.current?.get(t)??``:``,s=e.command?e.command.slice(0,80):G.t(`commands:notifications.unknownCommand`),c=o?`[${o}] ${s}`:s,l=new Notification(n,{body:c,tag:`specrails-job:${e.id}:${e.status}`}),u=e.id,d=t;l.onclick=()=>{window.focus(),d&&i.current?(i.current(d),setTimeout(()=>{r.current(`/jobs/${u}`)},100)):r.current(`/jobs/${u}`),l.close()}}Notification.permission===`granted`?o():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&o()})}(0,Q.useLayoutEffect)(()=>(c(`os-notifications`,u),()=>l(`os-notifications`)),[u,c,l])}var sG=[{value:`job.completed`,labelKey:`webhooks.eventJobCompleted`},{value:`job.failed`,labelKey:`webhooks.eventJobFailed`},{value:`daily_budget_exceeded`,labelKey:`webhooks.eventDailyBudgetExceeded`}];function cG({project:e,onRemove:t}){let{t:n}=K(`settings`);return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 p-2.5 rounded-md border border-border`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:e.path})]}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,className:`h-6 px-2 text-[10px] text-muted-foreground hover:text-destructive shrink-0`,onClick:()=>t(e.id),children:n(`common:actions.remove`)})]})}var lG=[{id:`appearance`,icon:Fs,labelKey:`desktop.nav.appearance`},{id:`effects`,icon:un,labelKey:`desktop.nav.effects`},{id:`specrailsAgents`,icon:wo,labelKey:`desktop.nav.specrailsAgents`},{id:`code`,icon:Lo,labelKey:`desktop.nav.code`},{id:`terminal`,icon:sc,labelKey:`desktop.nav.terminal`},{id:`updates`,icon:Js,labelKey:`desktop.nav.updates`},{id:`mobile`,icon:oc,labelKey:`desktop.nav.mobile`},{id:`mcp`,icon:So,labelKey:`desktop.nav.mcp`},{id:`projects`,icon:as,labelKey:`desktop.nav.projects`},{id:`advanced`,icon:ac,labelKey:`desktop.nav.advanced`},{id:`webhooks`,icon:hc,labelKey:`desktop.nav.webhooks`},{id:`about`,icon:vs,labelKey:`desktop.nav.about`}];function uG({open:e,onClose:t,onOpenOnboarding:n}){let{t:r}=K(`settings`),{projects:i,removeProject:a}=at(),[o,s]=(0,Q.useState)(`appearance`),c=e=>X(`space-y-5`,o===e?``:`hidden`),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!0),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)([]),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)([`job.completed`,`job.failed`]),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(()=>iG().enabled),[N,P]=(0,Q.useState)(()=>iG().filter);function F(e){M(e),aG({enabled:e,filter:N}),J.success(r(e?`notifications.enabledToast`:`notifications.disabledToast`))}function I(e){P(e),aG({enabled:j,filter:e})}let L=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/webhooks`);if(e.ok){let t=await e.json();S(t.webhooks)}}catch{}},[]);(0,Q.useEffect)(()=>{if(!e)return;f(!0);async function t(){try{let e=await fetch(`/api/settings`);if(e.ok){let t=await e.json();u(t),m(t.costAlertThresholdUsd==null?``:String(t.costAlertThresholdUsd))}}catch{}finally{f(!1)}}t(),L()},[e,L]),(0,Q.useEffect)(()=>{e&&fetch(`/api/budget`).then(e=>e.json()).then(e=>{e.desktopDailyBudgetUsd==null?v(``):v(String(e.desktopDailyBudgetUsd))}).catch(()=>{})},[e]);async function R(){g(!0);try{let e=p.trim()===``?null:parseFloat(p);if(e!==null&&(isNaN(e)||e<=0)){J.error(r(`budget.invalidNumber`));return}(await fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({costAlertThresholdUsd:e})})).ok?J.success(e==null?r(`desktop.costAlertsDisabled`):r(`budget.alertSet`,{amount:e})):J.error(r(`budget.saveThresholdFailed`))}catch{J.error(r(`budget.saveThresholdFailed`))}finally{g(!1)}}async function z(){b(!0);try{let e=_.trim()===``?null:parseFloat(_);if(e!==null&&(isNaN(e)||e<=0)){J.error(r(`budget.invalidNumber`));return}(await fetch(`/api/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({desktopDailyBudgetUsd:e})})).ok?J.success(e==null?r(`desktop.dailyBudgetRemoved`):r(`desktop.dailyBudgetSet`,{amount:e})):J.error(r(`desktop.dailyBudgetSaveFailed`))}catch{J.error(r(`desktop.dailyBudgetSaveFailed`))}finally{b(!1)}}async function B(e){try{await a(e),J.success(r(`desktop.projectRemoved`))}catch(e){J.error(r(`desktop.projectRemoveFailed`),{description:e.message})}}async function ee(){if(!C.trim()){J.error(r(`webhooks.urlRequired`));return}if(D.length===0){J.error(r(`webhooks.selectEvent`));return}A(!0);try{let e=await fetch(`/api/webhooks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:C.trim(),secret:T.trim(),events:D})});if(e.ok)J.success(r(`webhooks.added`)),w(``),E(``),O([`job.completed`,`job.failed`]),await L();else{let t=await e.json();J.error(t.error??r(`webhooks.addFailed`))}}catch{J.error(r(`webhooks.addFailed`))}finally{A(!1)}}async function V(e,t){try{await fetch(`/api/webhooks/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})}),await L()}catch{J.error(r(`webhooks.updateFailed`))}}async function H(e){try{(await fetch(`/api/webhooks/${e}`,{method:`DELETE`})).ok&&(J.success(r(`webhooks.removed`)),await L())}catch{J.error(r(`webhooks.removeFailed`))}}async function te(e){try{(await fetch(`/api/webhooks/${e}/test`,{method:`POST`})).ok&&J.success(r(`webhooks.testPingSent`))}catch{J.error(r(`webhooks.testPingFailed`))}}function ne(e){O(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(nc,{className:`w-4 h-4`}),r(`desktop.title`)]}),(0,$.jsx)(Mn,{children:r(`desktop.description`)})]}),d?(0,$.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,$.jsx)(`div`,{className:`h-16 bg-muted/30 rounded-lg animate-pulse`})]}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,$.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:lG.map(e=>{if(e.id===`mcp`&&!xe)return null;let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:X(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,$.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:r(e.labelKey)})]},e.id)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,$.jsxs)(`div`,{className:c(`appearance`),children:[(0,$.jsx)(xU,{}),(0,$.jsx)(kU,{})]}),(0,$.jsx)(`div`,{className:c(`effects`),children:(0,$.jsx)(yU,{})}),(0,$.jsx)(`div`,{className:c(`specrailsAgents`),children:(0,$.jsx)(PU,{})}),(0,$.jsx)(`div`,{className:c(`code`),children:(0,$.jsx)(AU,{})}),(0,$.jsxs)(`div`,{className:c(`updates`),children:[(0,$.jsx)(cW,{}),(0,$.jsx)(RU,{})]}),(0,$.jsx)(`div`,{className:c(`mobile`),children:(0,$.jsx)(qW,{})}),xe&&(0,$.jsx)(`div`,{className:c(`mcp`),children:(0,$.jsx)(tG,{})}),(0,$.jsx)(`div`,{className:c(`projects`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.registeredProjects`)}),i.length===0?(0,$.jsx)(`div`,{className:`rounded-md border border-dashed border-border p-4 text-center`,children:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`desktop.noProjects`)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:i.map(e=>(0,$.jsx)(cG,{project:e,onRemove:B},e.id))})]})}),(0,$.jsxs)(`div`,{className:c(`advanced`),children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.budgetAlertsHeading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`desktop.dailyBudgetLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.dailyBudgetHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:_,onChange:e=>v(e.target.value),placeholder:r(`desktop.dailyBudgetPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:y,onClick:()=>void z(),children:r(`common:actions.save`)})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`budget.perJobLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.perJobHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{type:`number`,min:`0`,step:`0.01`,value:p,onChange:e=>m(e.target.value),placeholder:r(`budget.perJobPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:h,onClick:R,children:r(`common:actions.save`)})]})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`notifications.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`notifications.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:j,onChange:e=>F(e.target.checked),className:`w-3.5 h-3.5`,"data-testid":`notif-toggle`}),(0,$.jsx)(bo,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs`,children:r(`notifications.enableLabel`)})]}),j&&(0,$.jsxs)(`div`,{className:`space-y-1.5 pl-6`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`notifications.notifyOn`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:[{value:`all`,label:r(`notifications.filterAll`)},{value:`completed`,label:r(`notifications.filterCompleted`)},{value:`failed`,label:r(`notifications.filterFailed`)}].map(({value:e,label:t})=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`notif-filter`,checked:N===e,onChange:()=>I(e),className:`w-3 h-3`}),t]},e))})]})]})]})]}),(0,$.jsx)(`div`,{className:c(`webhooks`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`webhooks.heading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`settings`,i18nKey:`webhooks.description`,components:{code:(0,$.jsx)(`code`,{className:`font-mono`})}})}),x.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>{let t=(()=>{try{return JSON.parse(e.events)}catch{return[]}})();return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border p-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-mono truncate`,children:e.url}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:t.join(`, `)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{onClick:()=>void V(e.id,!e.enabled),className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${e.enabled?`bg-green-500/10 aurora-light:bg-accent-success/10 text-green-600 aurora-light:text-accent-success dark:text-green-400`:`bg-muted text-muted-foreground`}`,title:e.enabled?r(`webhooks.disable`):r(`webhooks.enable`),children:e.enabled?r(`webhooks.statusOn`):r(`webhooks.statusOff`)}),(0,$.jsx)(`button`,{onClick:()=>void te(e.id),className:`text-muted-foreground hover:text-foreground p-0.5`,title:r(`webhooks.sendTestPing`),children:(0,$.jsx)(hn,{className:`w-3 h-3`})}),(0,$.jsx)(`button`,{onClick:()=>void H(e.id),className:`text-muted-foreground hover:text-destructive p-0.5`,title:r(`common:actions.remove`),children:(0,$.jsx)(dn,{className:`w-3 h-3`})})]})]},e.id)})}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium text-muted-foreground`,children:r(`webhooks.addHeading`)}),(0,$.jsx)(Qk,{value:C,onChange:e=>w(e.target.value),placeholder:`https://hooks.example.com/...`,className:`h-7 text-xs font-mono`}),(0,$.jsx)(Qk,{value:T,onChange:e=>E(e.target.value),placeholder:r(`webhooks.secretPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:sG.map(({value:e,labelKey:t})=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:D.includes(e),onChange:()=>ne(e),className:`w-3 h-3`}),r(t)]},e))}),(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs w-full`,disabled:k||!C.trim(),onClick:()=>void ee(),children:[(0,$.jsx)(cn,{className:`w-3 h-3 mr-1`}),r(`webhooks.addButton`)]})]})]})]})}),(0,$.jsx)(`div`,{className:c(`about`),children:n&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.onboardingHeading`)}),(0,$.jsx)(`div`,{className:`rounded-md border border-border p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`desktop.platformTour`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`desktop.platformTourDescription`)})]}),(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,onClick:n,"data-testid":`replay-onboarding`,children:[(0,$.jsx)(ds,{className:`w-3 h-3 mr-1`}),r(`desktop.replayTour`)]})]})})]})}),(0,$.jsx)(`div`,{className:c(`terminal`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.terminalPanelHeading`)}),(0,$.jsx)(rU,{mode:`desktop`})]})}),(0,$.jsx)(`div`,{className:c(`about`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`desktop.infoHeading`)}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoPort`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:l?.port??4200})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoProjects`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:i.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r(`desktop.infoDb`)}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:`~/.specrails/desktop.sqlite`})]})]})]})})]})]})]})})}var dG=[{keys:`?`,descriptionKey:`shortcuts.items.showCheatsheet`,category:`general`},{keys:`Esc`,descriptionKey:`shortcuts.items.closeModal`,category:`general`},{keys:`⌘B`,descriptionKey:`shortcuts.items.toggleRightSidebar`,category:`general`},{keys:`⌥⌘B`,descriptionKey:`shortcuts.items.toggleLeftSidebar`,category:`general`},{keys:`⌘J`,descriptionKey:`shortcuts.items.toggleTerminal`,category:`general`},...P?[{keys:`⌘⇧A`,descriptionKey:`shortcuts.items.toggleAgent`,category:`general`}]:[],{keys:V?`⌘1–5`:`⌘1–4`,descriptionKey:V?`shortcuts.items.navigateProjectPageWithAgents`:`shortcuts.items.navigateProjectPage`,category:`general`},{keys:`⌥⌘1–9`,descriptionKey:`shortcuts.items.switchProject`,category:`general`},{keys:`G D`,descriptionKey:`shortcuts.items.goDashboard`,category:`navigation`},{keys:`G J`,descriptionKey:`shortcuts.items.goActivity`,category:`navigation`},{keys:`G A`,descriptionKey:`shortcuts.items.goAnalytics`,category:`navigation`},{keys:`G S`,descriptionKey:`shortcuts.items.goSettings`,category:`navigation`},{keys:`J`,descriptionKey:`shortcuts.items.nextItem`,category:`actions`},{keys:`K`,descriptionKey:`shortcuts.items.prevItem`,category:`actions`}];function fG(e){let t=e.target;if(!t)return!1;let n=t.tagName;return!!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable)}function pG(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`[role="dialog"]`)}function mG(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`.specrails-xterm-container, .xterm`)}function hG({onOpenCheatsheet:e,onListNavigate:t,onToggleLeftSidebar:n,onToggleRightSidebar:r,onSwitchProject:i,onSwitchProjectPage:a,onToggleTerminalPanel:o,onToggleAgentChat:s}){let c=v(),l=p(),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(e);f.current=e;let m=(0,Q.useRef)(t);m.current=t;let h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(r);g.current=r;let _=(0,Q.useRef)(i);_.current=i;let y=(0,Q.useRef)(a);y.current=a;let b=(0,Q.useRef)(o);b.current=o;let x=(0,Q.useRef)(s);x.current=s;let S=(0,Q.useRef)(l);S.current=l,(0,Q.useEffect)(()=>{function e(e){if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.code===`KeyJ`){if(pG(e))return;e.preventDefault(),b.current?.();return}if((e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.code===`KeyA`){if(pG(e))return;e.preventDefault(),x.current?.();return}if(fG(e)||mG(e)||pG(e))return;if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.code===`KeyB`){e.preventDefault(),g.current?.();return}if((e.metaKey||e.ctrlKey)&&e.altKey&&e.code===`KeyB`){e.preventDefault(),h.current?.();return}if((e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey){let t=e.code.match(/^Digit([1-9])$/);if(t){e.preventDefault(),y.current?.(parseInt(t[1],10));return}}if((e.metaKey||e.ctrlKey)&&e.altKey&&!e.shiftKey){let t=e.code.match(/^Digit([1-9])$/);if(t){e.preventDefault(),_.current?.(parseInt(t[1],10));return}}if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.key;if(u.current===`g`){d.current&&clearTimeout(d.current),u.current=null;let n=t.toUpperCase(),r={D:`/`,P:`/`,J:`/activity`,A:`/analytics`,S:`/settings`};if(r[n]){e.preventDefault(),c(r[n]);return}return}if(t===`?`){e.preventDefault(),f.current();return}if(t===`g`){e.preventDefault(),u.current=`g`,d.current=setTimeout(()=>{u.current=null},800);return}if(t===`j`){m.current?.(`down`);return}if(t===`k`){m.current?.(`up`);return}}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),d.current&&clearTimeout(d.current)}},[c])}function gG(){let[e,t]=(0,Q.useState)(!1);return{cheatsheetOpen:e,setCheatsheetOpen:t,openCheatsheet:(0,Q.useCallback)(()=>t(!0),[]),closeCheatsheet:(0,Q.useCallback)(()=>t(!1),[])}}var _G={general:`shortcuts.categories.general`,navigation:`shortcuts.categories.navigation`,actions:`shortcuts.categories.actions`},vG=[`general`,`navigation`,`actions`];function yG({children:e}){return(0,$.jsx)(`kbd`,{className:`inline-flex items-center justify-center min-w-[1.5rem] h-6 px-1.5 rounded border border-border/50 bg-card/80 font-mono text-xs text-foreground`,children:e})}function bG({shortcut:e}){let{t}=K(`commands`),n=jH(e.keys).split(` `);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:t(e.descriptionKey)}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 ml-4 shrink-0`,children:n.map((e,t)=>(0,$.jsx)(yG,{children:e},t))})]})}function xG({open:e,onOpenChange:t}){let{t:n}=K(`commands`),r=vG.map(e=>({category:e,label:n(_G[e]),shortcuts:dG.filter(t=>t.category===e)})).filter(e=>e.shortcuts.length>0);return(0,$.jsx)(Hn,{open:e,onOpenChange:t,children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-md`,"data-testid":`shortcuts-cheatsheet`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:n(`shortcuts.title`)}),(0,$.jsx)(Mn,{children:(0,$.jsxs)(tt,{i18nKey:`shortcuts.subtitle`,ns:`commands`,children:[`Press `,(0,$.jsx)(yG,{children:`?`}),` anywhere to toggle this panel`]})})]}),(0,$.jsx)(`div`,{className:`space-y-4 mt-2`,children:r.map(e=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-accent-primary mb-2`,children:e.label}),(0,$.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.shortcuts.map(e=>(0,$.jsx)(bG,{shortcut:e},e.keys))})]},e.category))})]})})}function SG(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function CG(){return SG()&&/mac/i.test(navigator.platform)}function wG({onClick:e,icon:t,hoverColor:n=`var(--color-accent)`,hoverTextColor:r=`var(--color-accent-foreground)`,ariaLabel:i}){let[a,o]=(0,Q.useState)(!1);return(0,$.jsx)(`button`,{onClick:e,"aria-label":i,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{width:34,height:28,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:7,border:`none`,cursor:`pointer`,background:a?n:`transparent`,color:a?r:`var(--color-muted-foreground)`,transition:`background 0.12s ease, color 0.12s ease`,WebkitAppRegion:`no-drag`},children:t})}function TG({projectName:e,hidden:t=!1}){let{t:n}=K(`nav`),[r,i]=(0,Q.useState)(!1);function a(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,bubbles:!0}))}return(0,$.jsxs)(`button`,{onClick:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"aria-label":n(`titleBar.searchShortcut`),"aria-hidden":t||void 0,tabIndex:t?-1:void 0,style:{position:`absolute`,left:`50%`,top:`50%`,transform:`translate(-50%, -50%) scale(${t?.96:1})`,width:`40%`,maxWidth:360,minWidth:160,height:20,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,paddingLeft:8,paddingRight:8,borderRadius:9999,border:`1px solid color-mix(in srgb, var(--color-border) 70%, transparent)`,cursor:`pointer`,background:r?`color-mix(in srgb, var(--color-accent) 82%, transparent)`:`color-mix(in srgb, var(--color-surface) 72%, transparent)`,color:e?`var(--color-foreground)`:`var(--color-muted-foreground)`,fontSize:12,fontWeight:400,letterSpacing:0,opacity:+!t,pointerEvents:t?`none`:`auto`,transition:`background 0.12s ease, opacity 0.22s ease, transform 0.22s ease`,WebkitAppRegion:`no-drag`,overflow:`hidden`,whiteSpace:`nowrap`},children:[(0,$.jsx)(ln,{size:11,style:{flexShrink:0,opacity:e?.72:.48}}),(0,$.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e??n(`titleBar.searchPlaceholder`)})]})}function EG(){return SG()?CG()?(0,$.jsx)(DG,{}):(0,$.jsx)(OG,{}):null}function DG(){let{projects:e,activeProjectId:t}=at(),{uiMode:n}=Ij();return(0,$.jsx)(`div`,{"data-tauri-drag-region":!0,style:{position:`relative`,height:28,minHeight:28,background:`var(--color-background-deep)`,display:`flex`,alignItems:`center`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--color-border)`},children:(0,$.jsx)(TG,{projectName:(e.find(e=>e.id===t)??null)?.name??null,hidden:n===`agent`})})}function OG(){let{t:e}=K(`nav`),{projects:t,activeProjectId:n}=at(),{uiMode:r}=Ij(),i=t.find(e=>e.id===n)??null,a=(0,Q.useMemo)(()=>xM(),[]),[o,s]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1,t=0,n,r=async()=>{let n=++t;try{let r=await a.isMaximized?.();!e&&n===t&&s(r===!0)}catch{}};return r(),a.onResized?.(()=>{r()}).then(t=>{e?t():n=t}).catch(()=>{}),()=>{e=!0,n?.()}},[a]);let c=(0,Q.useCallback)(()=>{a.minimize()},[a]),l=(0,Q.useCallback)(()=>{a.toggleMaximize()},[a]),u=(0,Q.useCallback)(()=>{a.close()},[a]);return(0,$.jsxs)(`div`,{"data-tauri-drag-region":!0,style:{position:`relative`,height:36,minHeight:36,background:`var(--color-background-deep)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`0 10px`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--color-border)`},children:[(0,$.jsx)(TG,{projectName:i?.name??null,hidden:r===`agent`}),(0,$.jsx)(`div`,{"data-tauri-drag-region":!0,style:{minWidth:116,height:`100%`}}),(0,$.jsxs)(`div`,{style:{minWidth:116,display:`flex`,justifyContent:`flex-end`,gap:2,alignItems:`center`,WebkitAppRegion:`no-drag`},children:[(0,$.jsx)(wG,{onClick:c,icon:(0,$.jsx)(As,{size:14,strokeWidth:1.8}),ariaLabel:e(`titleBar.minimizeWindow`)}),(0,$.jsx)(wG,{onClick:l,icon:o?(0,$.jsx)(Ho,{size:12,strokeWidth:1.8}):(0,$.jsx)(sn,{size:12,strokeWidth:1.8}),ariaLabel:e(o?`titleBar.restoreWindow`:`titleBar.maximizeWindow`)}),(0,$.jsx)(wG,{onClick:u,icon:(0,$.jsx)(mn,{size:15,strokeWidth:1.8}),hoverColor:`var(--color-destructive)`,hoverTextColor:`var(--color-destructive-foreground)`,ariaLabel:e(`titleBar.closeWindow`)})]})]})}var kG=`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン0123456789ABCDEF`,AG=16,jG=AG,MG=AG*1.1,NG=180,PG=340,FG=.07,IG=.22,LG=18,RG=600,zG=48,BG=160,VG=360;function HG(){return kG[Math.floor(Math.random()*61)]??` `}function UG(e){return{head:-Math.random()*Math.max(e,12),speed:FG+Math.random()*(IG-FG),glyphs:Array.from({length:LG},()=>HG()),nextSwapAt:0}}function WG(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=null,s=[],c=0,l=0,u=!document.hidden;function d(){let e=window.devicePixelRatio||1,t=window.innerWidth,n=window.innerHeight;r.width=Math.max(1,Math.floor(t*e)),r.height=Math.max(1,Math.floor(n*e)),r.style.width=`${t}px`,r.style.height=`${n}px`,i.setTransform(e,0,0,e,0,0),i.font=`${AG}px "DM Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace`,i.textBaseline=`top`;let o=Math.ceil(t/jG),s=Math.ceil(n/MG);if(a.length===0)a=Array.from({length:o},()=>UG(s));else if(a.length<o){let e=Array.from({length:o-a.length},()=>UG(s));a=a.concat(e)}else a.length>o&&(a=a.slice(0,o))}function f(e){let t=performance.now();o&&(Math.abs(o.x-e.clientX)>=2||Math.abs(o.y-e.clientY)>=2)&&(s.push({x:o.x,y:o.y,t}),s.length>zG&&s.splice(0,s.length-zG)),o={x:e.clientX,y:e.clientY}}function p(){o=null}function m(){u=!document.hidden,u?(l=0,c=requestAnimationFrame(h)):cancelAnimationFrame(c)}function h(e){if(!u)return;let t=l===0?1:Math.min(2.5,(e-l)/16.67);l=e;let n=performance.now();for(;s.length>0&&n-s[0].t>RG;)s.shift();let r=window.innerWidth,d=window.innerHeight;i.clearRect(0,0,r,d);let f=Math.ceil(d/MG),p=o!==null||s.length>0;for(let r=0;r<a.length;r++){let c=a[r];if(c.head+=c.speed*t,c.head-LG>f+4&&(c.head=-Math.random()*12,c.speed=FG+Math.random()*(IG-FG)),e>c.nextSwapAt&&(c.glyphs[Math.floor(Math.random()*LG)]=HG(),c.nextSwapAt=e+BG+Math.random()*VG),!p)continue;let l=r*jG+jG/2,u=o===null?1/0:Math.abs(l-o.x);for(let e of s){let t=Math.abs(l-e.x);if(t<u&&(u=t),u===0)break}if(!(u>PG))for(let e=0;e<LG;e++){let t=c.head-e;if(t<-1||t>f+2)continue;let a=t*MG,u=0;if(o!==null){let e=l-o.x,t=a-o.y,n=Math.sqrt(e*e+t*t);if(n<=PG){let e=n<NG?1:1-(n-NG)/(PG-NG);e>u&&(u=e)}}if(u<.999)for(let e of s){let t=l-e.x,r=a-e.y,i=Math.sqrt(t*t+r*r);if(i>PG)continue;let o=i<NG?1:1-(i-NG)/(PG-NG),s=n-e.t,c=o*(s>RG?0:1-s/RG);if(c>u&&(u=c),u>=.999)break}if(u<.02)continue;let d=1-e/LG,p=u*d*.85;p<.02||(i.fillStyle=e===0?`hsla(150, 100%, 92%, ${p.toFixed(3)})`:`hsla(144, 100%, 55%, ${p.toFixed(3)})`,i.fillText(c.glyphs[e],r*jG,a))}}c=requestAnimationFrame(h)}return d(),window.addEventListener(`resize`,d),window.addEventListener(`pointermove`,f),document.addEventListener(`mouseleave`,p),document.addEventListener(`visibilitychange`,m),c=requestAnimationFrame(h),()=>{cancelAnimationFrame(c),window.removeEventListener(`resize`,d),window.removeEventListener(`pointermove`,f),document.removeEventListener(`mouseleave`,p),document.removeEventListener(`visibilitychange`,m)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`fixed inset-0 pointer-events-none`,style:{zIndex:-1}})}var GG=24,KG=200,qG=3.5,JG=10,YG=`hsl(210, 60%, 96%)`,XG=`hsl(212, 100%, 62%)`;function ZG(){let e=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.current;if(!t)return;let n=t.getContext(`2d`,{alpha:!0});if(!n)return;let r=t,i=n,a=[],o=0,s=!document.hidden;function c(){let e=window.devicePixelRatio||1,t=window.innerWidth,n=window.innerHeight;r.width=Math.max(1,Math.floor(t*e)),r.height=Math.max(1,Math.floor(n*e)),r.style.width=`${t}px`,r.style.height=`${n}px`,i.setTransform(e,0,0,e,0,0)}function l(e){let t=performance.now();a.push({x:e.clientX,y:e.clientY,t}),a.length>GG&&a.splice(0,a.length-GG)}function u(){a=[]}function d(){s=!document.hidden,s?o=requestAnimationFrame(f):cancelAnimationFrame(o)}function f(){if(!s)return;let e=performance.now();for(;a.length>0&&e-a[0].t>KG;)a.shift();let t=window.innerWidth,n=window.innerHeight;if(i.clearRect(0,0,t,n),a.length>=2){i.lineCap=`round`,i.lineJoin=`round`,i.shadowColor=XG;for(let t=1;t<a.length;t++){let n=a[t-1],r=a[t],o=e-r.t,s=Math.max(0,1-o/KG);if(s<=0)continue;let c=t/a.length;i.globalAlpha=s*(.25+.75*c),i.lineWidth=Math.max(.5,qG*c),i.shadowBlur=JG*c,i.strokeStyle=c>.6?YG:XG,i.beginPath(),i.moveTo(n.x,n.y),i.lineTo(r.x,r.y),i.stroke()}i.globalAlpha=1,i.shadowBlur=0}o=requestAnimationFrame(f)}return c(),window.addEventListener(`resize`,c),window.addEventListener(`pointermove`,l),document.addEventListener(`mouseleave`,u),document.addEventListener(`visibilitychange`,d),o=requestAnimationFrame(f),()=>{cancelAnimationFrame(o),window.removeEventListener(`resize`,c),window.removeEventListener(`pointermove`,l),document.removeEventListener(`mouseleave`,u),document.removeEventListener(`visibilitychange`,d)}},[]),(0,$.jsx)(`canvas`,{ref:e,"aria-hidden":!0,className:`fixed inset-0 pointer-events-none`,style:{zIndex:-1}})}var QG={"code-rain":WG,galaxy:ZG};function $G(){let e=QG[ca().id];return e?(0,$.jsx)(e,{}):null}function eK({project:e}){let{t}=K(`nav`),n=sB(),{registerHandler:r,unregisterHandler:i}=qe(),[a,o]=(0,Q.useState)(null),s=(0,Q.useRef)(e.id);return s.current=e.id,(0,Q.useEffect)(()=>{let n=`cost-alerts-${e.id}`;return r(n,e=>{let n=e;n.projectId!==void 0&&n.projectId!==``&&n.projectId!==s.current||(n.type===`cost_alert`?J.warning(t(`costAlerts.costAlertTitle`),{description:t(`costAlerts.costAlertDescription`,{cost:(n.cost??0).toFixed(4),threshold:(n.threshold??0).toFixed(2)})}):n.type===`daily_budget_exceeded`?(J.error(t(`costAlerts.dailyBudgetTitle`),{description:t(`costAlerts.dailyBudgetDescription`,{spent:(n.dailySpend??0).toFixed(2),budget:(n.budget??0).toFixed(2)}),duration:1/0}),o({dailySpend:n.dailySpend??0,budget:n.budget??0})):n.type===`desktop_daily_budget_exceeded`&&J.error(t(`costAlerts.desktopBudgetTitle`),{description:t(`costAlerts.desktopBudgetDescription`,{spent:(n.desktopDailySpend??0).toFixed(2),budget:(n.desktopBudget??0).toFixed(2)}),duration:1/0}))}),()=>i(n)},[e.id,r,i,t]),(0,$.jsx)(TO,{delayDuration:400,children:(0,$.jsx)(aB.Provider,{value:n,children:(0,$.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[a&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-destructive/10 border-b border-destructive/20 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-destructive font-medium`,children:t(`costAlerts.bannerMessage`,{spent:a.dailySpend.toFixed(2),budget:a.budget.toFixed(2)})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`text-muted-foreground hover:text-foreground ml-4 shrink-0`,children:t(`costAlerts.dismiss`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden min-h-0`,children:[(0,$.jsx)(`main`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(l,{})}),!1]})]})})})}function tK({projectName:e,errorMessage:t,onRetry:n}){let{t:r}=K(`nav`);return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 p-8`,children:[(0,$.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`errorBoundary.title`)}),e&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(tt,{ns:`nav`,i18nKey:`errorBoundary.occurredIn`,values:{name:e},components:{strong:(0,$.jsx)(`span`,{className:`font-medium`})}})}),t&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60 font-mono`,children:t})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,children:[(0,$.jsx)(Js,{className:`w-3.5 h-3.5`}),r(`common:actions.retry`)]})]})}var nK=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ProjectErrorBoundary]`,e,t.componentStack)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,$.jsx)(tK,{projectName:this.props.projectName,errorMessage:this.state.error?.message??null,onRetry:this.handleRetry}):this.props.children}};function rK({onAddProject:e}){let{t}=K(`setup`);return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full min-h-[400px] gap-6 px-8 text-center`,children:[(0,$.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-muted/50 flex items-center justify-center`,children:(0,$.jsx)(dc,{className:`w-7 h-7 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,$.jsx)(tt,{t,i18nKey:`welcome.title`,components:{spec:(0,$.jsx)(`span`,{className:`text-accent-primary`}),rails:(0,$.jsx)(`span`,{className:`text-accent-secondary`})}})}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-sm`,children:t(`welcome.description`)}),we&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.jiraHint`)}),xe&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.mcpHint`)}),P&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.agentChatHint`)})]}),(0,$.jsxs)(Z,{onClick:e,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(as,{className:`w-3.5 h-3.5`}),t(`welcome.addFirstProject`)]})]})}var iK=`https://specrails.dev/companion-app`,aK=`specrails-desktop:onboarding-dismissed`;function oK(){try{return localStorage.getItem(aK)===`true`}catch{return!1}}function sK(){try{localStorage.setItem(aK,`true`)}catch{}}var cK=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||``),lK=cK?`⌘`:`Ctrl`,uK=cK?`⌥`:`Alt`,dK={primary:{text:`text-accent-primary`,bar:`bg-accent-primary`,glow:`glow-primary`,btn:`bg-accent-primary hover:bg-accent-primary/90 text-primary-foreground`,softBorder:`border-accent-primary/30`,softBg:`bg-accent-primary/5`,chipBg:`bg-accent-primary/10 text-accent-primary`},info:{text:`text-accent-info`,bar:`bg-accent-info`,glow:`glow-info`,btn:`bg-accent-info hover:bg-accent-info/90 text-primary-foreground`,softBorder:`border-accent-info/30`,softBg:`bg-accent-info/5`,chipBg:`bg-accent-info/10 text-accent-info`},success:{text:`text-accent-success`,bar:`bg-accent-success`,glow:`glow-success`,btn:`bg-accent-success hover:bg-accent-success/90 text-primary-foreground`,softBorder:`border-accent-success/30`,softBg:`bg-accent-success/5`,chipBg:`bg-accent-success/10 text-accent-success`},secondary:{text:`text-accent-secondary`,bar:`bg-accent-secondary`,glow:`glow-secondary`,btn:`bg-accent-secondary hover:bg-accent-secondary/90 text-primary-foreground`,softBorder:`border-accent-secondary/30`,softBg:`bg-accent-secondary/5`,chipBg:`bg-accent-secondary/10 text-accent-secondary`},warning:{text:`text-accent-warning`,bar:`bg-accent-warning`,glow:`glow-warning`,btn:`bg-accent-warning hover:bg-accent-warning/90 text-primary-foreground`,softBorder:`border-accent-warning/30`,softBg:`bg-accent-warning/5`,chipBg:`bg-accent-warning/10 text-accent-warning`},highlight:{text:`text-accent-highlight`,bar:`bg-accent-highlight`,glow:`glow-highlight`,btn:`bg-accent-highlight hover:bg-accent-highlight/90 text-primary-foreground`,softBorder:`border-accent-highlight/30`,softBg:`bg-accent-highlight/5`,chipBg:`bg-accent-highlight/10 text-accent-highlight`}};function fK({children:e}){return(0,$.jsx)(`kbd`,{className:`inline-flex items-center justify-center min-w-[1.5rem] h-5 px-1.5 rounded border border-border/60 bg-card/80 font-mono text-[11px] text-foreground shadow-sm`,children:e})}function pK({icon:e,label:t,children:n,accent:r}){return(0,$.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,$.jsx)(`div`,{className:X(`mt-0.5 shrink-0 grid place-items-center w-7 h-7 rounded-md border border-border/40`,r.softBg,r.text),children:e}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground leading-tight`,children:t}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground leading-relaxed`,children:n})]})]})}function mK({accent:e,label:t,children:n}){return(0,$.jsxs)(`div`,{className:X(`rounded-lg border p-3`,e.softBorder,e.softBg),children:[t&&(0,$.jsx)(`p`,{className:X(`text-[10px] font-semibold uppercase tracking-wider mb-1.5`,e.text),children:t}),(0,$.jsx)(`div`,{className:`text-xs text-foreground/90 leading-relaxed`,children:n})]})}function hK({steps:e}){return(0,$.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap text-[13px] font-medium`,children:e.map((t,n)=>(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:t.cls,children:t.label}),n<e.length-1&&(0,$.jsx)(B,{className:`w-3.5 h-3.5 text-muted-foreground`})]},t.label))})}function gK(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e(`onboarding.language.intro`)}),(0,$.jsx)(OU,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.language.note`)})]})}function _K(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:e(`onboarding.theme.intro`)}),(0,$.jsx)(bU,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.theme.note`)})]})}function vK({icon:e,url:t,label:n,testId:r}){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border/40 bg-card/40 p-3`,children:[(0,$.jsx)(`div`,{className:`shrink-0 rounded-md bg-white p-1.5`,"aria-hidden":`true`,children:(0,$.jsx)(FW,{value:t,size:72})}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[13px] font-semibold text-foreground leading-tight`,children:[e,n]}),(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,"data-testid":r,"aria-label":n,className:`inline-flex items-center gap-1 text-xs text-accent-info hover:underline break-all`,children:[t.replace(`https://`,``),(0,$.jsx)(Vt,{className:`w-3 h-3 shrink-0`,"aria-hidden":`true`})]})]})]})}function yK(){let{t:e}=K(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.companion.intro`,components:{b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,$.jsx)(mK,{accent:dK.success,label:e(`onboarding.companion.localLabel`),children:e(`onboarding.companion.localBody`)}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:e(`onboarding.companion.downloadLabel`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`onboarding.companion.downloadHint`)}),(0,$.jsx)(vK,{icon:(0,$.jsx)(oc,{className:`w-4 h-4 shrink-0`,"aria-hidden":`true`}),url:iK,label:e(`onboarding.companion.open`),testId:`companion-web-link`})]}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Gs,{className:`w-4 h-4`}),label:e(`onboarding.companion.pairLabel`),accent:dK.success,children:e(`onboarding.companion.pairBody`)})]})}function bK(e){let t={b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})};return[{navLabel:e(`onboarding.language.nav`),icon:(0,$.jsx)(bs,{className:`w-6 h-6`}),accent:dK.info,title:e(`onboarding.language.title`),subtitle:e(`onboarding.language.subtitle`),content:(0,$.jsx)(gK,{})},{navLabel:e(`onboarding.theme.nav`),icon:(0,$.jsx)(Fs,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.theme.title`),subtitle:e(`onboarding.theme.subtitle`),content:(0,$.jsx)(_K,{})},{navLabel:e(`onboarding.welcome.nav`),icon:(0,$.jsx)(un,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.welcome.title`),subtitle:e(`onboarding.welcome.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.intro`,components:t})}),(0,$.jsxs)(mK,{accent:dK.primary,label:e(`onboarding.welcome.coreLoopLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.describe`),cls:`text-accent-info`},{label:e(`onboarding.flow.specs`),cls:`text-accent-success`},{label:e(`onboarding.flow.rails`),cls:`text-accent-warning`},{label:e(`onboarding.flow.review`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.flowCaption`,components:t})})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.welcome.missionLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.missionBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Ss,{className:`w-4 h-4`}),label:e(`onboarding.welcome.boardLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.boardBody`,components:t})})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,$.jsx)(ic,{className:`w-4 h-4 mt-0.5 shrink-0 text-accent-success`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.welcome.localNote`,components:{...t,i:(0,$.jsx)(`span`,{className:`italic`})}})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.welcome.tourNote`)})]})},...P?[{navLabel:e(`onboarding.mission.nav`),icon:(0,$.jsx)(So,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.mission.title`),subtitle:e(`onboarding.mission.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.mission.missionsLabel`),accent:dK.primary,children:e(`onboarding.mission.missionsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ic,{className:`w-4 h-4`}),label:e(`onboarding.mission.levelsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.levelsBody`,components:{...t,shift:(0,$.jsx)(fK,{children:`Shift`}),tab:(0,$.jsx)(fK,{children:`Tab`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(xs,{className:`w-4 h-4`}),label:e(`onboarding.mission.cardsLabel`),accent:dK.primary,children:e(`onboarding.mission.cardsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Co,{className:`w-4 h-4`}),label:e(`onboarding.mission.workspaceLabel`),accent:dK.primary,children:e(`onboarding.mission.workspaceBody`)})]}),(0,$.jsx)(mK,{accent:dK.primary,label:e(`onboarding.mission.mcpLabel`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.mission.mcpBody`,components:t})})]})}]:[],...ne?[{navLabel:e(`onboarding.builder.nav`),icon:(0,$.jsx)(ps,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.builder.title`),subtitle:e(`onboarding.builder.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.builder.intro`,components:t})}),(0,$.jsxs)(mK,{accent:dK.highlight,label:e(`onboarding.builder.flowLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.blueprint`),cls:`text-accent-info`},{label:e(`onboarding.flow.approve`),cls:`text-accent-success`},{label:e(`onboarding.flow.m1Specs`),cls:`text-accent-warning`},{label:e(`onboarding.flow.milestones`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:e(`onboarding.builder.flowCaption`)})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(mc,{className:`w-4 h-4`}),label:e(`onboarding.builder.cardsLabel`),accent:dK.highlight,children:e(`onboarding.builder.cardsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(es,{className:`w-4 h-4`}),label:e(`onboarding.builder.specsLabel`),accent:dK.highlight,children:e(`onboarding.builder.specsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Xs,{className:`w-4 h-4`}),label:e(`onboarding.builder.milestonesLabel`),accent:dK.highlight,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.builder.milestonesBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ss,{className:`w-4 h-4`}),label:e(`onboarding.builder.progressLabel`),accent:dK.highlight,children:e(`onboarding.builder.progressBody`)})]})]})}]:[],{navLabel:e(`onboarding.authorSpecs.nav`),icon:(0,$.jsx)(x,{className:`w-6 h-6`}),accent:dK.info,title:e(`onboarding.authorSpecs.title`),subtitle:e(`onboarding.authorSpecs.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.authorSpecs.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.agentLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.agentBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.exploreLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.exploreBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(hn,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.quickLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.quickBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(E,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.websiteLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.websiteBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Qs,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.smashLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.smashBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(zt,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.draftsLabel`),accent:dK.info,children:e(`onboarding.authorSpecs.draftsBody`)})]}),we&&(0,$.jsx)(mK,{accent:dK.info,label:e(`onboarding.jira.label`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.jira.body`,components:t})})]})},{navLabel:e(`onboarding.rails.nav`),icon:(0,$.jsx)(gc,{className:`w-6 h-6`}),accent:dK.success,title:e(`onboarding.rails.title`),subtitle:e(`onboarding.rails.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.intro`,components:{...t,play:(0,$.jsx)(`span`,{className:`text-accent-warning font-medium`})}})}),(0,$.jsxs)(mK,{accent:dK.success,label:e(`onboarding.rails.jobLabel`),children:[(0,$.jsx)(hK,{steps:[{label:e(`onboarding.flow.architect`),cls:`text-accent-info`},{label:e(`onboarding.flow.developer`),cls:`text-accent-success`},{label:e(`onboarding.flow.reviewer`),cls:`text-accent-warning`},{label:e(`onboarding.flow.yourReview`),cls:`text-accent-secondary`}]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:e(`onboarding.rails.flowCaption`)})]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(nn,{className:`w-4 h-4`}),label:e(`onboarding.rails.reviewLabel`),accent:dK.success,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.reviewBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Qo,{className:`w-4 h-4`}),label:e(`onboarding.rails.packetLabel`),accent:dK.success,children:e(`onboarding.rails.packetBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.rails.steerLabel`),accent:dK.success,children:e(`onboarding.rails.steerBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Ys,{className:`w-4 h-4`}),label:e(`onboarding.rails.loopsLabel`),accent:dK.success,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.rails.loopsBody`,components:t})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.rails.profilesLabel`),accent:dK.success,children:e(`onboarding.rails.profilesBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(as,{className:`w-4 h-4`}),label:e(`onboarding.rails.isolationLabel`),accent:dK.success,children:e(`onboarding.rails.isolationBody`)})]})]})},{navLabel:e(`onboarding.providers.nav`),icon:(0,$.jsx)(So,{className:`w-6 h-6`}),accent:dK.secondary,title:e(`onboarding.providers.title`),subtitle:e(`onboarding.providers.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.providers.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 overflow-hidden text-xs`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[1.4fr_1fr_1fr_1fr_1fr] bg-card/40`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-muted-foreground`,children:e(`onboarding.providers.table.capability`)}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-secondary text-center`,children:`Claude Code`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-success text-center`,children:`Codex CLI`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-accent-info text-center`,children:`Gemini CLI`}),(0,$.jsx)(`div`,{className:`px-3 py-2 font-semibold text-purple-300 text-center`,children:`Kimi Code`})]}),[[e(`onboarding.providers.table.streamingResume`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.native`)],[e(`onboarding.providers.table.costReporting`),e(`onboarding.providers.table.providerBilled`),e(`onboarding.providers.table.estimated`),e(`onboarding.providers.table.estimated`),e(`onboarding.providers.table.unavailable`)],[e(`onboarding.providers.table.telemetry`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.synthesized`),e(`onboarding.providers.table.native`),e(`onboarding.providers.table.synthesized`)],[e(`onboarding.providers.table.agentProfiles`),e(`common:states.yes`),`—`,`—`,e(`common:states.yes`)]].map(e=>(0,$.jsxs)(`div`,{className:`grid grid-cols-[1.4fr_1fr_1fr_1fr_1fr] border-t border-border/30`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 text-foreground/90`,children:e[0]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[1]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[2]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[3]}),(0,$.jsx)(`div`,{className:`px-3 py-2 text-center text-muted-foreground`,children:e[4]})]},e[0]))]}),(0,$.jsx)(mK,{accent:dK.secondary,label:e(`onboarding.providers.calloutLabel`),children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.providers.calloutBody`,components:{...t,mono:(0,$.jsx)(`span`,{className:`font-mono`})}})})]})},{navLabel:e(`onboarding.cost.nav`),icon:(0,$.jsx)(zo,{className:`w-6 h-6`}),accent:dK.warning,title:e(`onboarding.cost.title`),subtitle:e(`onboarding.cost.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.cost.intro`,components:t})}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(ss,{className:`w-4 h-4`}),label:e(`onboarding.cost.analyticsLabel`),accent:dK.warning,children:e(`onboarding.cost.analyticsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(qs,{className:`w-4 h-4`}),label:e(`onboarding.cost.perTicketLabel`),accent:dK.warning,children:e(`onboarding.cost.perTicketBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Jo,{className:`w-4 h-4`}),label:e(`onboarding.cost.honestLabel`),accent:dK.warning,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.cost.honestBody`,components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(pc,{className:`w-4 h-4`}),label:e(`onboarding.cost.budgetsLabel`),accent:dK.warning,children:e(`onboarding.cost.budgetsBody`)})]})]})},{navLabel:e(`onboarding.workspace.nav`),icon:(0,$.jsx)(Co,{className:`w-6 h-6`}),accent:dK.highlight,title:e(`onboarding.workspace.title`),subtitle:e(`onboarding.workspace.subtitle`),content:(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-4`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(dc,{className:`w-4 h-4`}),label:e(`onboarding.workspace.terminalLabel`),accent:dK.highlight,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.workspace.terminalBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),j:(0,$.jsx)(fK,{children:`J`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(es,{className:`w-4 h-4`}),label:e(`onboarding.workspace.codeLabel`),accent:dK.highlight,children:e(`onboarding.workspace.codeBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(E,{className:`w-4 h-4`}),label:e(`onboarding.workspace.browserLabel`),accent:dK.highlight,children:e(`onboarding.workspace.browserBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Us,{className:`w-4 h-4`}),label:e(`onboarding.workspace.integrationsLabel`),accent:dK.highlight,children:e(`onboarding.workspace.integrationsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Fs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.themesLabel`),accent:dK.highlight,children:e(`onboarding.workspace.themesBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(xs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.chatsLabel`),accent:dK.highlight,children:e(`onboarding.workspace.chatsBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(U,{className:`w-4 h-4`}),label:e(`onboarding.workspace.compareLabel`),accent:dK.highlight,children:e(`onboarding.workspace.compareBody`)}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Xs,{className:`w-4 h-4`}),label:e(`onboarding.workspace.desktopLabel`),accent:dK.highlight,children:e(`onboarding.workspace.desktopBody`)})]})})},{navLabel:e(`onboarding.companion.nav`),icon:(0,$.jsx)(oc,{className:`w-6 h-6`}),accent:dK.success,title:e(`onboarding.companion.title`),subtitle:e(`onboarding.companion.subtitle`),content:(0,$.jsx)(yK,{})},{navLabel:e(`onboarding.moveFast.nav`),icon:(0,$.jsx)(Vo,{className:`w-6 h-6`}),accent:dK.primary,title:e(`onboarding.moveFast.title`),subtitle:e(`onboarding.moveFast.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(mK,{accent:dK.primary,label:e(`onboarding.moveFast.paletteLabel`),children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.paletteShortcut`,values:{mod:lK},components:{f:(0,$.jsx)(`span`,{className:`text-foreground`}),m:(0,$.jsx)(`span`,{className:`text-muted-foreground`}),mod:(0,$.jsx)(fK,{children:lK}),k:(0,$.jsx)(fK,{children:`K`})}})}),e(`onboarding.moveFast.paletteBody`)]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-3`,children:[(0,$.jsx)(pK,{icon:(0,$.jsx)(So,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.agentLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.agentBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),shift:(0,$.jsx)(fK,{children:`Shift`}),a:(0,$.jsx)(fK,{children:`A`}),tab:(0,$.jsx)(fK,{children:`Tab`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(dc,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.terminalLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.terminalBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),j:(0,$.jsx)(fK,{children:`J`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(ys,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.shortcutsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.shortcutsBody`,components:{q:(0,$.jsx)(fK,{children:`?`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(x,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.chatLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.chatBody`,values:{mod:lK},components:{mod:(0,$.jsx)(fK,{children:lK}),bkey:(0,$.jsx)(fK,{children:`B`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(as,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.projectsLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.projectsBody`,values:{alt:uK,mod:lK},components:{alt:(0,$.jsx)(fK,{children:uK}),mod:(0,$.jsx)(fK,{children:lK}),bkey:(0,$.jsx)(fK,{children:`B`})}})}),(0,$.jsx)(pK,{icon:(0,$.jsx)(Vo,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.pagesLabel`),accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.pagesBody`,values:{alt:uK,mod:lK},components:{alt:(0,$.jsx)(fK,{children:uK}),mod:(0,$.jsx)(fK,{children:lK}),n:(0,$.jsx)(fK,{children:`1–9`})}})})]}),(0,$.jsx)(mK,{accent:dK.primary,children:(0,$.jsx)(tt,{t:e,i18nKey:`onboarding.moveFast.outro`,components:t})})]})}]}function xK({open:e,onClose:t}){let{t:n}=K(`setup`),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),s=(0,Q.useMemo)(()=>bK(n),[n]),c=s[r],l=r===0,u=r===s.length-1,d=(0,Q.useCallback)(()=>{a&&sK(),i(0),t()},[a,t]),f=(0,Q.useCallback)(()=>{sK(),i(0),t()},[t]),p=(0,Q.useCallback)(()=>{u?f():i(e=>e+1)},[u,f]),m=(0,Q.useCallback)(()=>i(e=>Math.max(0,e-1)),[]);return(0,$.jsx)(zn,{open:e,onOpenChange:e=>{e||d()},children:(0,$.jsxs)(kn,{children:[(0,$.jsx)(On,{className:`fixed inset-0 z-50 bg-black/70 backdrop-blur-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),(0,$.jsxs)(Un,{className:`fixed left-[50%] top-[50%] z-50 flex flex-col w-[calc(100vw-2rem)] max-w-5xl h-[min(88vh,820px)] translate-x-[-50%] translate-y-[-50%] overflow-hidden border border-border/30 bg-popover shadow-2xl backdrop-blur-xl sm:rounded-2xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,"data-testid":`onboarding-wizard`,"aria-describedby":`onboarding-description`,children:[(0,$.jsx)(`div`,{className:X(`h-1 w-full shrink-0 transition-all duration-500`,c.accent.bar)}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`nav`,{className:`hidden md:flex w-60 shrink-0 flex-col border-r border-border/30 bg-card/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`px-2 mb-5`,children:[(0,$.jsxs)(`p`,{className:`text-sm font-bold tracking-tight`,children:[(0,$.jsx)(`span`,{className:`text-accent-primary`,children:`spec`}),(0,$.jsx)(`span`,{className:`text-accent-secondary`,children:`rails`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:n(`onboarding.productTour`)})]}),(0,$.jsx)(`ol`,{className:`space-y-0.5 min-h-0 overflow-y-auto`,children:s.map((e,t)=>{let a=t===r,o=t<r;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":n(`onboarding.goToStep`,{step:t+1,label:e.navLabel}),"aria-current":a?`step`:void 0,className:X(`w-full flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors`,a?X(`bg-card/70`,e.accent.text):`text-muted-foreground hover:bg-card/40 hover:text-foreground`),children:[(0,$.jsx)(`span`,{className:X(`grid place-items-center w-5 h-5 shrink-0 rounded-full text-[10px] font-bold border`,a?X(e.accent.bar,`text-primary-foreground border-transparent`):o?`bg-accent-success/15 text-accent-success border-accent-success/30`:`border-border/50 text-muted-foreground`),children:o?(0,$.jsx)(Ht,{className:`w-3 h-3`}):t+1}),(0,$.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.navLabel})]})},e.navLabel)})}),(0,$.jsx)(`div`,{className:`mt-auto px-2.5 pt-4 text-[10px] text-muted-foreground`,children:n(`onboarding.stepCount`,{current:r+1,total:s.length})})]}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 sm:p-7`,children:[(0,$.jsxs)(`div`,{className:X(`flex items-center gap-3.5 mb-5`,c.accent.text),children:[(0,$.jsx)(`div`,{className:X(`grid place-items-center w-12 h-12 shrink-0 rounded-xl border border-border/30 bg-card/40`,c.accent.glow),children:c.icon}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(In,{className:`text-lg font-bold leading-tight text-foreground`,children:c.title}),(0,$.jsx)(`p`,{id:`onboarding-description`,className:`text-xs text-muted-foreground mt-0.5`,children:c.subtitle})]})]}),(0,$.jsx)(`div`,{className:`md:hidden flex items-center gap-1.5 mb-5`,children:s.map((e,t)=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":n(`onboarding.stepLabel`,{step:t+1}),"aria-current":t===r?`step`:void 0,className:X(`h-1.5 rounded-full transition-all`,t===r?X(`w-6`,e.accent.bar):`w-1.5 bg-muted-foreground/30`)},e.navLabel))}),(0,$.jsx)(`div`,{className:`min-h-[300px]`,children:c.content})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border/30 px-6 sm:px-7 py-3.5`,children:[(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:l&&(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-2 cursor-pointer group`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`w-3.5 h-3.5 rounded`,"data-testid":`onboarding-dismiss-checkbox`}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground group-hover:text-foreground transition-colors`,children:n(`onboarding.dontShowAgain`)})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:d,className:`text-xs text-muted-foreground`,"data-testid":`onboarding-skip`,children:n(`onboarding.skipTour`)}):(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:m,className:`text-xs`,"data-testid":`onboarding-back`,children:[(0,$.jsx)(Rt,{className:`w-3.5 h-3.5 mr-1`}),n(`common:actions.back`)]}),(0,$.jsxs)(Z,{size:`sm`,onClick:p,className:X(`text-xs`,c.accent.btn),"data-testid":`onboarding-next`,children:[n(u?`onboarding.getStarted`:`common:actions.next`),!u&&(0,$.jsx)(B,{className:`w-3.5 h-3.5 ml-1`})]})]})]})]})]})]})]})})}function SK(){let[e,t]=(0,Q.useState)(new Map),n=(0,Q.useContext)(Ye);return(0,Q.useEffect)(()=>n?(n.registerHandler(`assemble-progress`,e=>{let n=e;if(n.type!==`project.assemble_progress`||typeof n.projectId!=`string`||typeof n.provider!=`string`)return;let{projectId:r,provider:i,status:a}=n;t(e=>{let t=new Map(e),n=t.get(r)?{running:new Set(t.get(r).running),failed:new Set(t.get(r).failed)}:{running:new Set,failed:new Set};return a===`running`?(n.running.add(i),n.failed.delete(i)):a===`done`?(n.running.delete(i),n.failed.delete(i)):a===`failed`&&(n.running.delete(i),n.failed.add(i)),t.set(r,n),t})}),()=>n.unregisterHandler(`assemble-progress`)):void 0,[n]),{statusFor:(0,Q.useCallback)(t=>{let n=e.get(t);return n?n.running.size>0?`assembling`:n.failed.size>0?`failed`:`ready`:`ready`},[e]),retry:(0,Q.useCallback)(async e=>{await fetch(`${He}/api/projects/${e}/assemble-retry`,{method:`POST`})},[])}}var CK=(0,Q.lazy)(()=>c(()=>import(`./ProjectSettingsDialog-DeL8md1s.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([84,1,7,42,44,8,12,10,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,53,63,49,64,65]))),wK=`specrails-desktop:agentTreeExpanded`;function TK(){try{let e=localStorage.getItem(wK);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 EK(e){try{localStorage.setItem(wK,JSON.stringify([...e]))}catch{}}function DK(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var OK=`__home__`,kK=`__favorites__`;function AK({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=K(`agent`),u=e.title?.trim()||l(`untitled`),[d,f]=(0,Q.useState)(!1),p=(0,Q.useRef)(null),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(r);(0,Q.useEffect)(()=>{if(g.current&&!r){h(!0);let e=setTimeout(()=>h(!1),900);return g.current=r,()=>clearTimeout(e)}g.current=r},[r]),(0,Q.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,$.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,$.jsx)(x,{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,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`relative text-[11px] truncate flex-1 text-left`,children:[u,(r||m)&&(0,$.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,$.jsx)(`span`,{className:X(`flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/45`,d?`hidden`:`group-hover:hidden`),title:Ob(e.updated_at),children:Db(e.updated_at)}),(0,$.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,$.jsx)(ms,{className:`w-2.5 h-2.5`,fill:a?`currentColor`:`none`})}),(0,$.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,$.jsx)(mn,{className:`w-2.5 h-2.5`})})]})]})}function jK({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,assembleStatus:_=`ready`,onRetryAssemble:v}){let{t:y}=K(`nav`),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);function C(e){e.stopPropagation(),b?(S.current&&clearTimeout(S.current),x(!1),i()):(x(!0),S.current=setTimeout(()=>{x(!1),S.current=null},3e3))}function w(e){e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))}let T=a&&o&&n,E=(0,$.jsx)(as,{className:X(`flex-shrink-0 w-4 h-4`,t&&`text-accent-primary`)});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:w,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:[T?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(`span`,{className:`flex transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:E}),(0,$.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":y(s?`projects.collapse`:`projects.expand`,{name:e.name}),"aria-expanded":s,children:s?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):E,n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:e.name}),_===`assembling`&&(0,$.jsx)(`span`,{className:`flex-shrink-0 h-1.5 w-1.5 rounded-full bg-accent-info animate-pulse`,title:y(`projects.assembling`),"data-testid":`assemble-indicator`,"aria-label":y(`projects.assembling`)}),_===`failed`&&(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v?.()},className:`flex-shrink-0 h-2 w-2 rounded-full bg-accent-warning hover:ring-2 hover:ring-accent-warning/40 transition-shadow`,title:y(`projects.assembleFailed`),"data-testid":`assemble-retry`,"aria-label":y(`projects.assembleFailed`)}),g&&(0,$.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":y(`projects.settings`,{name:e.name}),title:y(`projects.settings`,{name:e.name}),children:(0,$.jsx)(nc,{className:`w-2.5 h-2.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:C,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`,b?`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":y(b?`projects.confirmRemove`:`projects.remove`,{name:e.name}),children:b?y(`projects.confirmShort`):(0,$.jsx)(mn,{className:`w-2.5 h-2.5`})})]})]}),a&&s&&n&&l.length>0&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:l.map(e=>(0,$.jsx)(AK,{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 MK={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function NK({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a}){let{t:o}=K(`nav`),{t:s}=K(`agent`),{projects:c,activeProjectId:l,setActiveProjectId:u,removeProject:d}=at(),f=SK(),m=v(),h=p(),g=h.pathname.startsWith(`/loops`),_=h.pathname.startsWith(`/plugins`),b=g||_||h.pathname.startsWith(`/docs`),{leftMode:x,cycleLeftMode:S}=eN(),{uiMode:C,toggleUiMode:w}=Ij(),T=lM(),E=C===`agent`,D=(0,Q.useMemo)(()=>{let e=new Map,t=new Set(c.map(e=>e.id));for(let n of T.conversations){if(T.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:OK,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[T.conversations,T.favoriteConversationIds,c]),O=(0,Q.useMemo)(()=>T.conversations.filter(e=>T.favoriteConversationIds.has(e.id)),[T.conversations,T.favoriteConversationIds]),k=D.get(OK)??[],[A,j]=(0,Q.useState)(TK),M=A.has(kK),[N,P]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!E||!l||j(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),EK(t),t})},[E,l]);let F=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),EK(n),n})},I=e=>{T.selectConversation(e),b&&m(`/`)},L=e=>{T.deleteConversation(e).catch(()=>{})},R=e=>{T.toggleFavoriteConversation(e)};function z(e){if(E){u(e),F(e);return}if(e===l){b&&m(`/`);return}u(e)}let[B,ee]=(0,Q.useState)(!1),V=x===`pinned-open`||x===`unpinned`&&B,H=UM(`left-arc`,{side:`left`,defaultWidth:240,min:200,max:460,collapsedWidth:44,expanded:V}),te=x!==`unpinned`,ne=o(MK[x]),re=[{label:o(`arcSidebar.docs`),icon:xo,action:i},{label:o(`arcSidebar.analytics`),icon:Oo,action:r},{label:o(`arcSidebar.settings`),icon:nc,action:a}];async function ie(e){try{await d(e.id)}catch{}}return(0,$.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:()=>{x===`unpinned`&&ee(!0)},onMouseLeave:()=>{x===`unpinned`&&!H.dragging&&ee(!1)},children:[V&&(0,$.jsx)(WM,{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,$.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,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:o(`arcSidebar.desktopTitle`)}),(0,$.jsx)(`button`,{type:`button`,onClick:S,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,te?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":ne,title:o(`sidebarPin.withShortcut`,{label:ne,shortcut:jH(`⌥⌘B`)}),children:(0,$.jsx)(Is,{className:`w-4 h-4`})})]}),y&&(0,$.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[E&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{T.startNewConversation(l),b&&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,$.jsx)(cn,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`newAgent`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:w,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(E?`switchToKanban`:`switchToAgent`),title:s(E?`switchToKanban`:`switchToAgent`),children:[E?(0,$.jsx)(Ss,{className:`w-4 h-4 flex-shrink-0`}):(0,$.jsx)(So,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),V&&(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:s(E?`switchToKanban`:`switchToAgent`)})]}),E&&(0,$.jsxs)(`button`,{type:`button`,onClick:DK,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,$.jsx)(ln,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`search`)})]})]}),ge&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`py-2 px-1.5`,children:[(0,$.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,$.jsx)(gc,{className:X(`w-4 h-4 flex-shrink-0`,g&&`text-accent-primary`)}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.loops`)})]}),(0,$.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,$.jsx)(Ws,{className:X(`w-4 h-4 flex-shrink-0`,_&&`text-accent-primary`)}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`arcSidebar.plugins`)})]})]}),(0,$.jsx)(`div`,{className:`border-t border-border`,"aria-hidden":!0})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1.5 space-y-0.5`,children:[E&&O.length>0&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-0.5 border-b border-border/70 pb-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>F(kK),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":M,title:V?void 0:s(`favoriteMissions`),children:[V?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(ms,{className:`h-4 w-4 fill-current text-accent-primary transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,$.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:M?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(ms,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),V&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`favoriteMissions`)})]}),M&&V&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:O.map(e=>(0,$.jsx)(AK,{conversation:e,active:e.id===T.active?.id,streaming:T.streamingConversationIds.has(e.id),unread:T.unreadConversationIds.has(e.id),favorite:!0,expanded:V,onSelect:()=>I(e.id),onToggleFavorite:()=>R(e.id),onDelete:()=>L(e.id)},e.id))})]}),E&&k.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>F(OK),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":A.has(OK),title:V?void 0:s(`home`),children:[V?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(gs,{className:`h-4 w-4 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`}),(0,$.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center group-hover:flex group-focus-visible:flex`,children:A.has(OK)?(0,$.jsx)(Zt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Qt,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(gs,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:s(`home`)})]}),A.has(OK)&&V&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:k.map(e=>(0,$.jsx)(AK,{conversation:e,active:e.id===T.active?.id,streaming:T.streamingConversationIds.has(e.id),unread:T.unreadConversationIds.has(e.id),expanded:V,onSelect:()=>I(e.id),onToggleFavorite:()=>R(e.id),onDelete:()=>L(e.id)},e.id))})]}),c.map(e=>{let t=D.get(e.id)??[];return(0,$.jsx)(jK,{project:e,isActive:e.id===l&&!b,expanded:V,onSelect:()=>z(e.id),onRemove:()=>ie(e),agentMode:E,hasTree:t.length>0,treeOpen:A.has(e.id),onToggleTree:()=>F(e.id),conversations:t,activeConversationId:T.active?.id??null,streamingConversationIds:T.streamingConversationIds,unreadConversationIds:T.unreadConversationIds,onSelectConversation:I,onToggleConversationFavorite:R,onDeleteConversation:L,assembleStatus:f.statusFor(e.id),onRetryAssemble:()=>{f.retry(e.id)},onOpenProjectSettings:E?()=>{u(e.id),P(!0)}:void 0},e.id)}),(0,$.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,$.jsx)(cn,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:o(`projects.addProject`)})]})]}),(0,$.jsx)(`div`,{className:`border-t border-border py-2 px-1.5 space-y-0.5`,children:re.map(({label:e,icon:t,action:n})=>(0,$.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,$.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),V&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:e})]},e))}),N&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(CK,{open:!0,onClose:()=>P(!1)})})]})}var PK={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function FK(){let{t:e}=K(`nav`),{rightMode:t,cycleRightMode:n}=eN(),[r,i]=(0,Q.useState)(!1),a=t===`pinned-open`||t===`unpinned`&&r,o=t!==`unpinned`,s=e(PK[t]),c=[{to:`/`,end:!0,icon:Cs,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:Eo,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:Do,label:e(`rightSidebar.analytics`)},...se?[{to:`/code`,end:!1,icon:Lo,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:nc,label:e(`rightSidebar.settings`)}];return(0,$.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`,a?`w-44`:`w-11`),onMouseEnter:()=>{t===`unpinned`&&i(!0)},onMouseLeave:()=>{t===`unpinned`&&i(!1)},children:[(0,$.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,a?`px-3 justify-between`:`justify-center`),children:[a&&(0,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-secondary`,children:e(`rightSidebar.projectTitle`)}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors`,o?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":s,title:e(`sidebarPin.withShortcut`,{label:s,shortcut:jH(`⌘B`)}),children:(0,$.jsx)(Ls,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,$.jsx)(nN,{expanded:a}),c.map(({to:e,end:t,icon:n,label:r})=>(0,$.jsxs)(h,{to:e,end:t,className:({isActive:e})=>X(`flex items-center gap-2 w-full h-8 rounded-md transition-colors`,a?`px-2`:`px-0 justify-center`,e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),title:a?void 0:r,children:[(0,$.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}),a&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:r})]},e))]})]})}function IK(e,t){return e.error===`corrupted-bundle`?t(`setup:prerequisites.corruptedBundle`):e.installed?e.executable===!1?e.resolvedPath&&e.executionError?t(`setup:prerequisites.failedToExecuteAtWithError`,{path:e.resolvedPath,error:e.executionError}):e.resolvedPath?t(`setup:prerequisites.failedToExecuteAt`,{path:e.resolvedPath}):e.executionError?t(`setup:prerequisites.failedToExecuteWithError`,{error:e.executionError}):t(`setup:prerequisites.failedToExecute`):!e.meetsMinimum&&e.minVersion?t(`setup:prerequisites.needsMinimum`,{version:e.version??t(`setup:prerequisites.unknownVersion`),minVersion:e.minVersion}):e.version??t(`setup:prerequisites.installedLabel`):t(`setup:prerequisites.notInstalled`)}function LK({status:e,isLoading:t,error:n,onRefresh:r,onMoreInfo:i}){let{t:a}=K(`setup`);if(t&&!e)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`loading`,className:`rounded-lg border border-border/30 bg-background/30 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-muted-foreground/20 animate-pulse`}),(0,$.jsx)(`div`,{className:`h-3 w-32 rounded bg-muted-foreground/15 animate-pulse`})]})});if(n&&!e)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`error`,className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`prerequisites.verifyError`)})});if(!e)return null;if(e.ok)return(0,$.jsx)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`ok`,className:`rounded-lg border border-accent-success/25 bg-accent-success/5 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Mo,{className:`w-4 h-4 text-accent-success flex-shrink-0`}),(0,$.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:a(`prerequisites.allDetected`)})]}),r&&(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:t,className:`h-7 px-2 gap-1.5 text-[11px] flex-shrink-0`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,t&&`animate-spin`)}),a(`common:actions.refresh`)]})]})});let o=e.missingRequired?.length??0,s=o>0&&(e.missingRequired??[]).every(e=>e.error===`corrupted-bundle`),c=(e.missingRequired??[]).some(e=>e.error===`corrupted-bundle`);return(0,$.jsxs)(`div`,{"data-testid":`prerequisites-panel`,"data-state":`missing`,className:X(`rounded-lg border px-3 py-2`,c?`border-destructive/40 bg-destructive/10`:`border-accent-primary/40 bg-accent-primary/10`),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(fn,{className:X(`w-4 h-4 flex-shrink-0`,c?`text-destructive`:`text-accent-primary`)}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:s?a(`prerequisites.bundleCorruptedTitle`):a(`prerequisites.toolsRequired`,{count:o})}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a(s?`prerequisites.reinstallHint`:`prerequisites.installMissingHint`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[i&&!s&&(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-7 px-2 gap-1.5 text-[11px]`,"data-testid":`prerequisites-more-info`,children:a(`prerequisites.moreInfo`)}),r&&(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:t,className:`h-7 px-2 gap-1.5 text-[11px]`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,t&&`animate-spin`)}),a(`common:actions.refresh`)]})]})]}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1`,children:e.prerequisites.map(e=>{let t=e.error===`corrupted-bundle`,n=e.bundled===!0&&e.executable===!0&&!t,r=!t&&e.installed&&e.meetsMinimum,i=e.key===`gh`||e.key===`uv`,o=!r&&!t&&i;return(0,$.jsxs)(`li`,{"data-testid":`prereq-row-${e.key}`,"data-ok":r?`true`:`false`,"data-bundled":e.bundled?`true`:void 0,"data-corrupted":t?`true`:void 0,className:X(`flex items-center gap-2 rounded-md border px-2 py-1.5 text-[11px]`,t?`border-destructive/40 bg-destructive/10 text-foreground`:r||o?`border-border/30 bg-background/30 text-muted-foreground`:`border-accent-primary/30 bg-background/50 text-foreground`),children:[t?(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-destructive flex-shrink-0`}):n||r?(0,$.jsx)(Mo,{className:`w-3.5 h-3.5 text-accent-success flex-shrink-0`}):o?(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(en,{className:`w-3.5 h-3.5 text-accent-primary flex-shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),i&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:a(`prerequisites.optional`)}),e.key===`gh`&&e.executable&&e.authenticated===!1&&(0,$.jsx)(`span`,{"data-testid":`prereq-gh-noauth`,className:`inline-flex items-center rounded px-1 py-0.5 text-[10px] font-medium bg-accent-warning/15 text-accent-warning border border-accent-warning/30`,children:a(`prerequisites.ghNoAuth`)}),n&&(0,$.jsxs)(`span`,{"data-testid":`prereq-bundled-badge-${e.key}`,className:`inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium bg-accent-secondary/20 text-accent-secondary border border-accent-secondary/30`,children:[(0,$.jsx)(Ps,{className:`w-2.5 h-2.5`}),a(`prerequisites.bundledBadge`)]}),(0,$.jsxs)(`span`,{className:X(`text-muted-foreground`,t&&`text-destructive/80`),children:[`— `,IK(e,a)]})]},e.key)})})]})}function RK(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 zK=[`darwin`,`win32`,`linux`];async function BK(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 VK({command:e}){let{t}=K(`setup`),[n,r]=(0,Q.useState)(!1);return(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await BK(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,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ht,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ho,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function HK({platform:e,primary:t}){let{t:n}=K(`setup`),r=RK(n)[e];return(0,$.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,$.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r.title}),r.intro&&(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r.intro}),(0,$.jsx)(`div`,{className:`mt-2 space-y-2`,children:r.commands.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-border/30 bg-background/60 px-2 py-2`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-1`,children:e.label}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`code`,{className:`text-xs text-foreground font-mono break-all`,children:e.command}),(0,$.jsx)(VK,{command:e.command})]})]},e.command))}),r.links.length>0&&(0,$.jsx)(`ul`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1`,children:r.links.map(e=>(0,$.jsx)(`li`,{children:(0,$.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,$.jsx)(Vt,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function UK(){let{t:e}=K(`setup`),[t,n]=(0,Q.useState)(`idle`);return(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{n(`copying`);try{let e=await fetch(`${He}/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,$.jsx)(Ht,{className:`w-3 h-3 text-accent-success`}):(0,$.jsx)(Fo,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function WK({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=K(`setup`),[o,s]=(0,Q.useState)(!1),c=n?.platform??`darwin`,l=zK.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:a(`instructions.corrupted.title`)}),(0,$.jsx)(Mn,{children:a(`instructions.corrupted.description`)})]}),(0,$.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`instructions.corrupted.body`)}),(0,$.jsx)(`div`,{className:`flex justify-end mt-2`,children:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,"data-testid":`install-corrupted-close-button`,children:a(`common:actions.close`)})})]})}):(0,$.jsx)(Hn,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-w-xl`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsx)(Fn,{children:a(`instructions.title`)}),(0,$.jsx)(Mn,{children:a(`instructions.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(HK,{platform:c,primary:!0}),(0,$.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,$.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,$.jsx)(HK,{platform:e,primary:!1},e))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,$.jsx)(UK,{}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:a(`common:actions.close`)}),(0,$.jsxs)(Z,{type:`button`,variant:`default`,size:`sm`,onClick:r,disabled:i,className:`gap-1.5`,"data-testid":`install-recheck-button`,children:[(0,$.jsx)(Js,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var GK=typeof window<`u`&&`__TAURI_INTERNALS__`in window;function KK({open:e,onClose:t,onOpenBuilder:n}){let r=ne&&!!n,[i,a]=(0,Q.useState)(r?`choose`:`existing`),[o,s]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)({claude:!0}),[_,v]=(0,Q.useState)(!1),{t:y}=K(`setup`),{addProject:b}=at(),{status:x,isLoading:S,error:C,recheck:w}=sA(),T=(0,Q.useMemo)(()=>{if(!x||x.ok)return null;let e=x.missingRequired.map(e=>e.label);return e.length===0?null:y(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[x,y]),E=x!==null&&!x.ok&&!C;(0,Q.useEffect)(()=>{e&&fetch(`/api/available-providers`).then(e=>e.json()).then(e=>{let t={};for(let[n,r]of Object.entries(e))n===`tiers`||n===`providerIssues`||n===`launchDescriptors`||typeof r==`boolean`&&(t[n]=r);g(t)}).catch(()=>{})},[e]);async function D(){let e=o.trim();if(!e){J.error(y(`addProject.errors.pathRequired`));return}m(!0);try{let t=d.map(e=>({path:e.trim()})).filter(e=>e.path),n=t.length?await b(e,l.trim()||void 0,void 0,t):await b(e,l.trim()||void 0);if(!n)return;J.success(y(`addProject.toasts.registered`,{name:n.project.name})),O()}catch(e){J.error(y(`addProject.errors.addFailed`),{description:e.message})}finally{m(!1)}}function O(){s(``),u(``),f([]),a(r?`choose`:`existing`),t()}function k(e){e||O()}let A=!Object.values(h).some(Boolean);return i===`choose`?(0,$.jsx)(Hn,{open:e,onOpenChange:k,children:(0,$.jsxs)(Bn,{className:`max-w-md`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(as,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,$.jsx)(Mn,{children:y(`addProject.chooser.description`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 py-2`,children:[(0,$.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,$.jsx)(is,{className:`h-5 w-5 text-accent-info`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.existingTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.existingDescription`)})]}),(0,$.jsxs)(`button`,{type:`button`,"data-testid":`chooser-new`,onClick:()=>{O(),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,$.jsx)(un,{className:`h-5 w-5 text-accent-highlight`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:y(`addProject.chooser.newTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:y(`addProject.chooser.newDescription`)})]})]})]})}):(0,$.jsx)(Hn,{open:e,onOpenChange:k,children:(0,$.jsxs)(Bn,{movableResizable:!0,className:`max-h-[calc(100vh-2rem)] w-[calc(100vw-2rem)] max-w-2xl overflow-x-hidden`,"data-testid":`existing-project-dialog`,children:[(0,$.jsxs)(Rn,{children:[(0,$.jsxs)(Fn,{className:`flex items-center gap-2`,children:[(0,$.jsx)(as,{className:`w-4 h-4`}),y(`addProject.title`)]}),(0,$.jsx)(Mn,{children:y(`addProject.description`)})]}),A&&(0,$.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:y(`addProject.noProviderDetected`)}),(0,$.jsx)(LK,{status:x,isLoading:S,error:C,onMoreInfo:()=>v(!0),onRefresh:w}),(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.pathLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{placeholder:y(`addProject.pathPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()},autoFocus:!0,className:`flex-1`}),GK&&(0,$.jsx)(Z,{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-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!1,title:y(`addProject.selectProjectFolder`)});typeof t==`string`&&t&&(s(t),l||u(t.split(`/`).filter(Boolean).pop()??``))}catch{}},children:(0,$.jsx)(as,{className:`w-4 h-4`})})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.pathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[y(`addProject.nameLabel`),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:y(`addProject.optional`)})]}),(0,$.jsx)(Qk,{placeholder:y(`addProject.namePlaceholder`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&D()}}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:y(`addProject.nameHint`)})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2`,disabled:p,children:[(0,$.jsx)(`legend`,{className:`text-xs font-medium`,children:y(`common:repositories.additional`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:y(`common:repositories.sharedBacklog`)}),d.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Qk,{"aria-label":y(`common:repositories.folderNumber`,{number:t+2}),value:e,placeholder:y(`addProject.pathPlaceholder`),onChange:e=>f(n=>n.map((n,r)=>r===t?e.target.value:n))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":y(`common:repositories.removeFolder`),onClick:()=>f(e=>e.filter((e,n)=>n!==t)),children:(0,$.jsx)(mn,{className:`h-4 w-4`})})]},t)),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(GK)try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([83,0,1])),t=await e({directory:!0,multiple:!0});t&&f(e=>[...e,...Array.isArray(t)?t:[t]]);return}catch{}f(e=>[...e,``])},children:[(0,$.jsx)(cn,{className:`mr-1 h-3.5 w-3.5`}),y(`common:repositories.addFolder`)]})]})]}),(0,$.jsxs)(Tn,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:O,disabled:p,children:y(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,onClick:D,disabled:p||!o.trim()||E||S,title:E?T??void 0:void 0,"data-testid":`add-project-submit`,children:y(p?`addProject.adding`:`addProject.submit`)})]}),(0,$.jsx)(WK,{open:_,onClose:()=>v(!1),status:x,onRecheck:w,isRechecking:S})]})})}var qK=1,JK=.9,YK=.8,XK=.17,ZK=.1,QK=.999,$K=.9999,eq=.99,tq=/[\\\/_+.#"@\[\(\{&]/,nq=/[\\\/_+.#"@\[\(\{&]/g,rq=/[\s-]/,iq=/[\s-]/g;function aq(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?qK:eq;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=aq(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=qK:tq.test(e.charAt(l-1))?(d*=YK,p=e.slice(i,l-1).match(nq),p&&i>0&&(d*=QK**+p.length)):rq.test(e.charAt(l-1))?(d*=JK,m=e.slice(i,l-1).match(iq),m&&i>0&&(d*=QK**+m.length)):(d*=XK,i>0&&(d*=QK**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=$K)),(d<ZK&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=aq(e,t,n,r,l+1,a+2,o),f*ZK>d&&(d=f*ZK)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function oq(e){return e.toLowerCase().replace(iq,` `)}function sq(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,aq(e,t,oq(e),oq(t),0,0,{})}var cq=`[cmdk-group=""]`,lq=`[cmdk-group-items=""]`,uq=`[cmdk-group-heading=""]`,dq=`[cmdk-item=""]`,fq=`${dq}:not([aria-disabled="true"])`,pq=`cmdk-item-select`,mq=`data-value`,hq=(e,t,n)=>sq(e,t,n),gq=Q.createContext(void 0),_q=()=>Q.useContext(gq),vq=Q.createContext(void 0),yq=()=>Q.useContext(vq),bq=Q.createContext(void 0),xq=Q.forwardRef((e,t)=>{let n=Fq(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Fq(()=>new Set),i=Fq(()=>new Map),a=Fq(()=>new Map),o=Fq(()=>new Set),s=Nq(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Cn(),y=Cn(),b=Cn(),x=Q.useRef(null),S=Rq();Pq(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Pq(()=>{S(6,k)},[]);let C=Q.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=Q.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??hq;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(lq);t?t.appendChild(e.parentElement===t?e:e.closest(`${lq} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${lq} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${cq}[${mq}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(mq);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(cq)?.querySelector(uq))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${dq}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(fq)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(mq))}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(mq))}function P(e){let t=A()?.closest(cq),n;for(;t&&!n;)t=e>0?jq(t,cq):Mq(t,cq),n=t?.querySelector(fq);n?C.setState(`value`,n.getAttribute(mq)):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 Q.createElement(_n.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(pq);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Vq},c),Bq(e,e=>Q.createElement(vq.Provider,{value:C},Q.createElement(gq.Provider,{value:w},e))))}),Sq=Q.forwardRef((e,t)=>{let n=Cn(),r=Q.useRef(null),i=Q.useContext(bq),a=_q(),o=Nq(e),s=o.current?.forceMount??i?.forceMount;Pq(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Lq(n,r,[e.value,e.children,r],e.keywords),l=yq(),u=Iq(e=>e.value&&e.value===c.current),d=Iq(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);Q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(pq,f),()=>t.removeEventListener(pq,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 Q.createElement(_n.div,{ref:Pn(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)}),Cq=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Cn(),s=Q.useRef(null),c=Q.useRef(null),l=Cn(),u=_q(),d=Iq(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Pq(()=>u.group(o),[]),Lq(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(_n.div,{ref:Pn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&Q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Bq(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(bq.Provider,{value:f},e))))}),wq=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=Iq(e=>!e.search);return!n&&!a?null:Q.createElement(_n.div,{ref:Pn(i,t),...r,"cmdk-separator":``,role:`separator`})}),Tq=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=yq(),o=Iq(e=>e.search),s=Iq(e=>e.selectedItemId),c=_q();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(_n.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)}})}),Eq=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=Iq(e=>e.selectedItemId),c=_q();return Q.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)}}},[]),Q.createElement(_n.div,{ref:Pn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Bq(e,e=>Q.createElement(`div`,{ref:Pn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Dq=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(zn,{open:n,onOpenChange:r},Q.createElement(kn,{container:o},Q.createElement(On,{"cmdk-overlay":``,className:i}),Q.createElement(Un,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement(xq,{ref:t,...s}))))}),Oq=Q.forwardRef((e,t)=>Iq(e=>e.filtered.count===0)?Q.createElement(_n.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),kq=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(_n.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Bq(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),Aq=Object.assign(xq,{List:Eq,Item:Sq,Input:Tq,Group:Cq,Separator:wq,Dialog:Dq,Empty:Oq,Loading:kq});function jq(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Mq(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Nq(e){let t=Q.useRef(e);return Pq(()=>{t.current=e}),t}var Pq=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Fq(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function Iq(e){let t=yq(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function Lq(e,t,n,r=[]){let i=Q.useRef(),a=_q();return Pq(()=>{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(mq,s),i.current=s}),i}var Rq=()=>{let[e,t]=Q.useState(),n=Fq(()=>new Map);return Pq(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function zq(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Bq({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(zq(t),{ref:t.ref},n(t.props.children)):n(t)}var Vq={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Hq(e){return e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase()}function Uq(e,t,n=[]){let r=Hq(e.trim());return!r||Hq(t).includes(r)?!0:n.some(e=>e&&Hq(e).includes(r))}function Wq(e,t){return Tb(t.updated_at)-Tb(e.updated_at)}function Gq(e,t=8){return[...e].sort(Wq).slice(0,Math.max(0,t)).map(e=>({conversation:e,match:`recent`,messageId:null,snippet:null}))}function Kq(e,t,n,r=20){let i=Hq(t.trim());if(!i)return[];let a=Hq(n);return[...e].sort(Wq).filter(e=>Hq(e.title?.trim()||``).includes(i)||!e.title?.trim()&&a.includes(i)).slice(0,Math.max(0,r)).map(e=>({conversation:e,match:`title`,messageId:null,snippet:null}))}function qq(e,t,n=20){let r=new Map;for(let e of t)r.has(e.conversation.id)||r.set(e.conversation.id,e);let i=[],a=new Set;for(let t of e){let e=r.get(t.conversation.id);i.push(e?{conversation:e.conversation,match:`title`,messageId:e.messageId,snippet:e.snippet}:t),a.add(t.conversation.id)}for(let e of[`title`,`content`])for(let n of t)n.match!==e||a.has(n.conversation.id)||(a.add(n.conversation.id),i.push({conversation:n.conversation,match:n.match,messageId:n.messageId,snippet:n.snippet}));return i.slice(0,Math.max(0,n))}function Jq(e){return e===`agent`?[`missions`,`projects`,`spec`,`jobs`,`navigation`]:[`projects`,`missions`,`spec`,`jobs`,`navigation`]}var Yq=[];function Xq(e){let t=[],n=0;return e.ranges.forEach(([r,i],a)=>{r>n&&t.push(e.text.slice(n,r)),t.push((0,$.jsx)(`mark`,{className:`rounded-sm bg-accent-primary/20 px-0.5 text-foreground`,children:e.text.slice(r,i)},a)),n=i}),n<e.text.length&&t.push(e.text.slice(n)),t}function Zq({onOpenSettings:e,onOpenAnalytics:t,onOpenDocs:n}){let{t:r}=K(`commands`),{t:i}=K(`agent`),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)({query:``,hits:Yq}),{projects:h,activeProjectId:g,setActiveProjectId:_}=at(),{leftMode:y,rightMode:b,cycleLeftMode:x,cycleRightMode:S}=eN(),{uiMode:C}=Ij(),{conversations:w,liveByConversation:T,selectConversation:E,open:D}=lM(),O=r(y===`pinned-open`?`palette.sidebar.collapseLeftKeepPinned`:y===`pinned-collapsed`?`palette.sidebar.unpinLeft`:`palette.sidebar.pinLeftOpen`),k=r(b===`pinned-open`?`palette.sidebar.collapseRightKeepPinned`:b===`pinned-collapsed`?`palette.sidebar.unpinRight`:`palette.sidebar.pinRightOpen`),A=v(),j=(0,Q.useRef)(!1),M=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{function e(e){e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),o(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,Q.useEffect)(()=>{if(!a){j.current=!1,c(``);return}if(j.current)return;j.current=!0;async function e(){try{let[e,t]=await Promise.all([fetch(`${nt()}/config`),fetch(`${nt()}/jobs?limit=10`)]);if(e.ok){let t=await e.json();u(t.commands)}if(t.ok){let e=await t.json();f(e.jobs)}}catch{}}e()},[a]),(0,Q.useEffect)(()=>{let e=s.trim(),t=++M.current;if(!a||!e)return;let n=new AbortController,r=setTimeout(()=>{za(e,20,n.signal).then(n=>{t===M.current&&m({query:e,hits:n})}).catch(()=>{})},80);return()=>{clearTimeout(r),n.abort()}},[s,a]);let N=i(`mission.untitled`),P=(0,Q.useMemo)(()=>{let e=s.trim();return e?qq(Kq(w,e,N),p.query===e?p.hits:Yq):Gq(w)},[w,s,p,N]),F=(0,Q.useMemo)(()=>new Map(h.map(e=>[e.id,e.name])),[h]),I=(0,Q.useCallback)(e=>{_(e),o(!1)},[_]),L=(0,Q.useCallback)(e=>{o(!1),E(e),C!==`agent`&&D()},[E,D,C]),R=(0,Q.useCallback)(async e=>{o(!1);try{let t=await fetch(`${nt()}/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`));J.success(r(`toasts.queued`,{name:e})),A(`/jobs/${n.jobId}`)}catch(e){J.error(e instanceof Error?e.message:r(`errors.spawnFailed`))}},[A,r]),z=(0,Q.useCallback)(e=>{o(!1),A(`/jobs/${e}`)},[A]),B=(0,Q.useCallback)(e=>{o(!1),A(e)},[A]),ee=(0,Q.useCallback)(e=>{e&&(o(!1),e())},[]),V=`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`,H=h.filter(e=>Uq(s,e.name,[e.slug])),te=l.filter(e=>Uq(s,e.name,[e.slug,e.description??``])),ne=d.filter(e=>Uq(s,`${e.command} ${e.id}`,[e.status])),re=[{key:`dashboard`,label:r(`palette.nav.dashboard`),keywords:[`home`],icon:(0,$.jsx)(Cs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/`)},...t?[{key:`desktopAnalytics`,label:r(`palette.nav.desktopAnalytics`),keywords:[`cross-project`,`desktop`],icon:(0,$.jsx)(ko,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>ee(t)}]:[],{key:`projectAnalytics`,label:r(`palette.nav.projectAnalytics`),keywords:[`metrics`],icon:(0,$.jsx)(Do,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/analytics`)},{key:`activityFeed`,label:r(`palette.nav.activityFeed`),keywords:[`log`],icon:(0,$.jsx)(po,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>B(`/activity`)},{key:`desktopSettings`,label:r(`palette.nav.desktopSettings`),keywords:[`configuration`],icon:(0,$.jsx)(nc,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>e?ee(e):B(`/settings`)},{key:`docs`,label:r(`palette.nav.docs`),keywords:[`documentation`],icon:(0,$.jsx)($t,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>n?ee(n):B(`/docs`)},{key:`leftSidebar`,label:O,keywords:[`sidebar`,`panel`,`left`,`pin`,`collapse`,`unpin`,`cycle`],icon:(0,$.jsx)(Is,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>{x(),o(!1)}},{key:`rightSidebar`,label:k,keywords:[`sidebar`,`panel`,`right`,`nav`,`pin`,`collapse`,`unpin`,`cycle`],icon:(0,$.jsx)(Ls,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>{S(),o(!1)}}].filter(e=>Uq(s,e.label,e.keywords)),ie={missions:P.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.missions`),"data-testid":`palette-group-missions`,children:P.map(e=>{let{conversation:t}=e,n=T.get(t.id)?.isStreaming===!0,a=t.pinned_project_id?F.get(t.pinned_project_id)??null:null;return(0,$.jsxs)(Aq.Item,{value:`mission:${t.id}`,onSelect:()=>L(t.id),className:X(V,`items-start`),"data-testid":`palette-mission-${t.id}`,children:[(0,$.jsx)(Yt,{className:`w-4 h-4 mt-0.5 text-accent-primary shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:t.title?.trim()||N}),n&&(0,$.jsxs)(`span`,{"aria-label":i(`mission.working`),"data-testid":`palette-mission-live-${t.id}`,className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-primary opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-accent-primary`})]}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] tabular-nums text-muted-foreground/60`,title:Ob(t.updated_at),children:Db(t.updated_at)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 text-[11px] text-muted-foreground/60`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:a??r(`palette.missions.home`)}),e.snippet&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsx)(`span`,{className:`truncate`,"data-testid":`palette-mission-snippet-${t.id}`,children:Xq(e.snippet)})]})]})]})]},t.id)})},`missions`),projects:H.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.projects`),"data-testid":`palette-group-projects`,children:H.map(e=>(0,$.jsxs)(Aq.Item,{value:e.name,keywords:[e.slug],onSelect:()=>I(e.id),className:X(V,e.id===g&&`text-accent-primary`),children:[(0,$.jsx)(as,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),e.id===g&&(0,$.jsx)(`span`,{className:`text-[10px] text-accent-primary font-medium`,children:r(`palette.activeBadge`)})]},e.id))},`projects`),spec:te.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.spec`),children:te.map(e=>(0,$.jsxs)(Aq.Item,{value:e.name,keywords:[e.slug,e.description??``],onSelect:()=>R(e.slug),className:V,children:[(0,$.jsx)(hn,{className:`w-4 h-4 text-accent-info shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.description&&(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60 ml-2 truncate`,children:e.description})]})]},e.id))},`spec`),jobs:ne.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.jobs`),children:ne.map(e=>(0,$.jsxs)(Aq.Item,{value:`${e.command} ${e.id}`,keywords:[e.status],onSelect:()=>z(e.id),className:V,children:[(0,$.jsx)(Eo,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.command}),(0,$.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))},`jobs`),navigation:re.length>0&&(0,$.jsx)(Aq.Group,{heading:r(`palette.groups.navigation`),children:re.map(e=>(0,$.jsxs)(Aq.Item,{value:e.label,keywords:e.keywords,onSelect:e.onSelect,className:V,children:[e.icon,(0,$.jsx)(`span`,{children:e.label})]},e.key))},`navigation`)};return(0,$.jsxs)(Aq.Dialog,{open:a,onOpenChange:o,shouldFilter:!1,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,$.jsx)(`span`,{className:`sr-only`,children:r(`palette.label`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border/30`,children:[(0,$.jsx)(ln,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(Aq.Input,{value:s,onValueChange:c,placeholder:r(C===`agent`?`palette.searchPlaceholderAgent`:`palette.searchPlaceholder`),className:`flex-1 h-11 bg-transparent text-sm outline-none placeholder:text-muted-foreground/50`}),(0,$.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,$.jsxs)(Aq.List,{className:`max-h-80 overflow-y-auto p-2`,children:[(0,$.jsx)(Aq.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`palette.noResults`)}),Jq(C).map(e=>ie[e])]}),(0,$.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,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`↑↓`}),` `,r(`palette.footer.navigate`)]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`↵`}),` `,r(`palette.footer.select`)]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`kbd`,{className:`font-mono`,children:`esc`}),` `,r(`palette.footer.close`)]})]})})]})}var Qq=`
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
74
74
|
## Contract Layer
|
|
75
75
|
|
|
76
|
-
`;function $q(e){return`contract-refine:${e}`}async function eJ(e,t){try{let n=await fetch(`${He}/api/projects/${e}/tickets/${t}/contract-refine`,{method:`POST`});if(n.ok)J.loading(G.t(`activity:contractRefine.refining`),{id:$q(t)});else{let e=await n.json().catch(()=>({}));J.error(e.error?G.t(`activity:contractRefine.retryRejectedWithError`,{error:e.error}):G.t(`activity:contractRefine.retryRejected`),{id:$q(t)})}}catch(e){J.error(G.t(`activity:contractRefine.retryFailed`,{message:e.message}),{id:$q(t)})}}function tJ({children:e}){let{registerHandler:t,unregisterHandler:n}=qe(),r=(0,Q.useRef)(new Map),i=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`explore.contract_refine_failed`)return;let n=t.ticketId,i=t.projectId,a=typeof t.provider==`string`?t.provider:void 0,o=t.reason??`unknown`;if(typeof n!=`number`||!i)return;r.current.set(n,i);let s=pr(a)?{label:G.t(`common:actions.retry`),onClick:()=>void eJ(i,n)}:void 0;J.error(G.t(`activity:contractRefine.skipped`),{id:$q(n),description:G.t(`activity:contractRefine.reason`,{reason:o}),...s?{action:s}:{},duration:15e3})},[]),a=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`ticket_updated`)return;let n=t.ticket;n&&typeof n.description==`string`&&n.description.includes(Qq)&&J.success(G.t(`activity:contractRefine.added`,{title:n.title||`#${n.id}`}),{id:$q(n.id),duration:3500})},[]);return(0,Q.useLayoutEffect)(()=>(t(`_contract_refine_failed`,i),t(`_contract_refine_ticket_updated`,a),()=>{n(`_contract_refine_failed`),n(`_contract_refine_ticket_updated`)}),[t,n,i,a]),(0,Q.useEffect)(()=>()=>r.current.clear(),[]),(0,$.jsx)($.Fragment,{children:e})}function nJ(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function rJ(){let{t:e}=K(`mcp`),t=DU()?.languageId;(0,Q.useEffect)(()=>{nJ()&&Y(`set_tray_labels`,{open:e(`tray.open`),exit:e(`tray.exit`)}).catch(()=>{})},[e,t])}var iJ=`input, textarea, select, [contenteditable="true"], [contenteditable=""], .monaco-editor, .xterm, [data-native-menu]`;function aJ(e){return e instanceof Element&&e.closest(iJ)!==null}function oJ(e){aJ(e.target)||e.preventDefault()}function sJ(){(0,Q.useEffect)(()=>(document.addEventListener(`contextmenu`,oJ),()=>document.removeEventListener(`contextmenu`,oJ)),[])}var cJ={jobs:[],activeJobId:null,paused:!1};function lJ(e){let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)({}),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(cJ),[p,m]=(0,Q.useState)(0),h=(0,Q.useRef)(e);h.current=e;let g=(0,Q.useRef)(new Map),_=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{if(_.current&&_.current,_.current=e,e){let t=g.current.get(e);t?(n(t.phaseDefinitions),i(t.phases),o(t.projectName),u(t.recentJobs),f(t.queueState)):(n([]),i({}),o(``),u([]),f(cJ))}c([])},[e]);let v=(0,Q.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`)return;let r=h.current;if(!(r&&t.projectId&&t.projectId!==r))if(t.type===`desktop.project_recovered`)t.projectId===r&&m(e=>e+1);else 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??cJ;o(e),n(a),i(s),c(t.logBuffer??[]),u(l),f(d),r&&g.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:y,unregisterHandler:b,connectionStatus:x}=qe();return(0,Q.useLayoutEffect)(()=>(y(`pipeline`,v),()=>b(`pipeline`)),[v,y,b]),(0,Q.useEffect)(()=>{if(!e)return;let t=!1;async function r(){try{let e=await fetch(`${nt()}/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,p]),{phases:r,phaseDefinitions:t,projectName:a,logLines:s,connectionStatus:x,recentJobs:l,queueState:d}}function uJ({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=K(`nav`),{t:i}=K(`analytics`),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(`connecting`),u=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{let t=l.current;if(e===`connected`&&!u.current&&t!==`connected`){J.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,Q.useEffect)(()=>{u.current&&=!1},[]),(0,Q.useEffect)(()=>{if(n)return;async function e(){try{let e=await fetch(`${nt()}/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,$.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,$.jsxs)(`div`,{className:X(`flex items-center gap-1.5 transition-opacity duration-300`,!d&&`opacity-0`),"aria-hidden":!d||void 0,children:[(0,$.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,$.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,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!n&&a&&(a.totalCostUsd>0||(a.unpricedRuns??0)>0)&&(()=>{let e=a.includesEstimated??((a.estimatedCostUsd??0)>0||(a.estimatedCostToday??0)>0),t=a.unpricedRuns??0,n=a.pricedRuns??Math.max(0,(a.totalJobs??0)-t),r=a.totalCostUsd===0&&t>0&&n===0,o=t>0&&(n>0||a.totalCostUsd>0);return(0,$.jsx)(`span`,{"data-estimated":e?`true`:void 0,"data-testid":r?`statusbar-cost-unavailable`:void 0,title:r?i(`desktop.costUnavailable`):o?i(`desktop.costPartiallyUnavailable`,{count:t}):e?i(`desktop.statusBarEstimatedTooltip`):void 0,children:r?i(`desktop.costUnavailableShort`):`${e?`~`:``}${o?`≥`:``}$${a.totalCostUsd.toFixed(2)}`})})(),t]})]})}var dJ=(0,Q.lazy)(()=>c(()=>import(`./AgentBrowserCapture-C6BVsTfo.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([85,1,7,9,8,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])));function fJ(){let{browserOpen:e}=Ux(),{active:t}=lM(),n=si(),r=!n.current&&n.transfers.some(e=>e.conversationId===t?.id&&e.state===`detached`),{activeProjectId:i}=at();return!e||!i||r?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(dJ,{projectId:i,conversationId:t?.id??null})})}function pJ(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=he(),{tickets:i}=T(),a=p(),o=v(),s=(0,Q.useRef)(!1);(0,Q.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,Q.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 mJ(e){let{key:t,detail:n}=jt(e);return[`chunk_failed`,`chunk_stalled`,`chunk_stopped`,`provider_limit`,`launch_rejected`,`head_missing`,`head_discarded`,`run_lost`].includes(t)?G.t(`builder:milestoneProgress.chain.reasons.${t}`,{detail:n}):e??``}function hJ({setActiveProjectId:e}={}){let t=v(),n=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{n.current=t},[t]);let r=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{r.current=e},[e]);let i=(0,Q.useRef)(new Map),a=(0,Q.useRef)(new Map),{registerHandler:o,unregisterHandler:s}=qe();(0,Q.useEffect)(()=>{let e=`milestone-notifications`;return o(e,e=>{let t=e;if(!t||typeof t.projectId!=`string`)return;let o=t.projectId;if(t.type===`milestone.chain_changed`){let e=yt(t.chain);if(!e)return;let n=i.current.get(e.id);i.current.set(e.id,e);let r=xt(e.milestoneN);if(e.status===`running`&&e.nextChunk>1&&(!n||n.nextChunk<e.nextChunk)&&J.success(G.t(`builder:milestoneProgress.toast.chunkLaunched`,{milestone:r,k:e.nextChunk,n:e.totalChunks}),{id:`chain-launch:${e.id}:${e.nextChunk}`}),e.status===`awaiting_approval`&&(!n||n.status!==`awaiting_approval`||n.nextChunk!==e.nextChunk)){let t=`chain-checkpoint:${e.id}:${e.nextChunk}`;J.success(G.t(`builder:milestoneProgress.toast.checkpoint`,{milestone:r,k:e.nextChunk,n:e.totalChunks}),{id:t,duration:6e4,action:{label:G.t(`builder:milestoneProgress.toast.launchNext`),onClick:()=>{OA(o,e.id).then(e=>{e.ok?J.success(G.t(`builder:milestoneProgress.chain.nextLaunched`),{id:t}):J.error(G.t(`builder:milestoneProgress.chain.resumeFailed`),{id:t,description:e.detail??e.error})})}},cancel:{label:G.t(`builder:milestoneProgress.toast.autoContinue`),onClick:()=>{AA(o,e.id,!0).then(e=>{e.ok?J.success(G.t(`builder:milestoneProgress.chain.autoOn`),{id:t}):J.error(G.t(`builder:milestoneProgress.chain.autoFailed`),{id:t,description:e.detail??e.error})})}}})}e.status===`paused`&&(!n||n.status!==`paused`||n.pauseReason!==e.pauseReason)&&J.warning(G.t(`builder:milestoneProgress.toast.paused`,{milestone:r,reason:mJ(e.pauseReason)}),{id:`chain-paused:${e.id}`,duration:3e4,action:{label:G.t(`builder:milestoneProgress.toast.resume`),onClick:()=>{OA(o,e.id).then(t=>{t.ok?J.success(G.t(`builder:milestoneProgress.chain.resumed`),{id:`chain-paused:${e.id}`}):J.error(G.t(`builder:milestoneProgress.chain.resumeFailed`),{id:`chain-paused:${e.id}`,description:t.detail??t.error})})}}});return}if(t.type===`blueprint.milestone_progress`){for(let e of Tt(t.progress)){let t=`${o}:${e.id}`,i=a.current.get(t);if(a.current.set(t,e.state),!(i===void 0||i===e.state)&&e.state===`delivered`){let i=Et(e);J.success(G.t(`builder:milestoneProgress.toast.delivered`,{milestone:xt(e.n),count:e.counts.onReview}),{id:`milestone-delivered:${t}`,duration:3e4,...i?{action:{label:G.t(`builder:milestoneProgress.toast.review`),onClick:()=>{r.current?.(o);let e=ve?`/review/${i.id}`:`/`;setTimeout(()=>{n.current(e)},50)}}}:{}})}}return}t.type===`blueprint.milestone_completed`&&typeof t.n==`number`&&J.success(G.t(`builder:milestoneProgress.toast.completed`,{milestone:xt(t.n)}),{id:`milestone-completed:${o}:${t.milestoneId??t.n}`,duration:15e3})}),()=>s(e)},[o,s])}function gJ(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:_J(e)?`review`:null}function _J(e){let t=/^\/review\/([^/]+)\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function vJ(e){let t=/^\/loops\/([^/]+)\/edit\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function yJ({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r,reviewOpen:i=null}){if(e===`agent`){let e=gJ(t);if(!e)return null;if(e===`review`)return{kind:`modalize`,surface:e,backgroundPath:`/`,reviewDeliveryId:_J(t)??void 0};let n=e===`loops`?vJ(t):null;return n?{kind:`modalize`,surface:e,backgroundPath:`/`,loopBuilderId:n}:{kind:`modalize`,surface:e,backgroundPath:`/`}}return n?{kind:`route`,surface:`loops`,path:`/loops`}:r?{kind:`route`,surface:`plugins`,path:`/plugins`}:i?{kind:`route`,surface:`review`,path:`/review/${encodeURIComponent(i)}`}:null}var bJ=(0,Q.lazy)(()=>c(()=>import(`./JobDetailPage-CAILeuTY.js`),__vite__mapDeps([86,1,7,11,10,9,8,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,76,81]))),xJ=(0,Q.lazy)(()=>c(()=>import(`./ReviewPacketPage-BPG3cVpM.js`),__vite__mapDeps([87,1,7,11,10,9,8,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,88]))),SJ=(0,Q.lazy)(()=>c(()=>import(`./JobsPage-CzOmMhkp.js`),__vite__mapDeps([89,1,7,11,10,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,44,8,51,59,60,49,63,64,65,66,67,68,69,76,81,90,52]))),CJ=(0,Q.lazy)(()=>c(()=>import(`./AnalyticsPage-BZRZpWTe.js`),__vite__mapDeps([91,1,7,11,10,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,8,46,65,67,68,72,90,52,92,93]))),wJ=(0,Q.lazy)(()=>c(()=>import(`./ActivityFeedPage-CG2fhd_k.js`),__vite__mapDeps([94,1,7,12,10,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,44,8,51,54,62]))),TJ=(0,Q.lazy)(()=>c(()=>import(`./AgentsPage-DgF8yxlz.js`),__vite__mapDeps([95,1,7,8,12,10,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,47,11,48,49,50,54,55,57,58,59,60,63,64,65,69,72,81]))),EJ=(0,Q.lazy)(()=>c(()=>import(`./CodePage-CobZpY2J.js`),__vite__mapDeps([96,1,7,8,10,11,9,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]))),DJ=(0,Q.lazy)(()=>c(()=>import(`./IntegrationsPage-Bhy58lnQ.js`),__vite__mapDeps([97,7,1,11,10]))),OJ=(0,Q.lazy)(()=>c(()=>import(`./PluginsPage-pPmHG9nI.js`),__vite__mapDeps([98,1,7,12,10,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,44,8,52,54,58,59,60,61,63,49,64,65,69,72]))),kJ=(0,Q.lazy)(()=>c(()=>import(`./DesktopAnalyticsPage-B75I8Hyl.js`),__vite__mapDeps([99,1,7,12,10,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,65,64,92,8,93]))),AJ=(0,Q.lazy)(()=>c(()=>import(`./DocsPage-Dn2j2nSl.js`),__vite__mapDeps([100,1,7,11,10,42,50,54,64,65,66,75,101,102]))),jJ=(0,Q.lazy)(()=>c(()=>import(`./DocsDialog-AEU1MV8y.js`),__vite__mapDeps([103,1,7,42,50,54,63,8,49,64,65,66,75,101,102]))),MJ=(0,Q.lazy)(()=>c(()=>import(`./LoopsPage-C4GXI81g.js`),__vite__mapDeps([104,1,7,11,10,42,44,8,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,52,55,56,57,48,59,105,63,49,64,65,69,70,71,72,78,74,53]))),NJ=(0,Q.lazy)(()=>c(()=>import(`./LoopBuilderPage-_Snk4Cv7.js`),__vite__mapDeps([106,1,7,8,11,10,42,44,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,45,74,53,56,57,59,60,105,63,49,64,65,69,71,93,107]))),PJ=28;function FJ({surface:e,onClose:t}){let{t:n}=K(`nav`),r=n(e===`loops`?`arcSidebar.loops`:e===`review`?`arcSidebar.review`:`arcSidebar.plugins`);return(0,$.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,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.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,$.jsx)(e===`loops`?gc:e===`review`?Qo:Ws,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`truncate text-xs font-medium text-foreground`,children:r})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,$.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,$.jsx)(mn,{className:`h-4 w-4`})})})]})}var IJ=new Set([`/settings`,`/loops`,`/plugins`]);function LJ(e){return IJ.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var RJ=`specrails-desktop:routeMemory`;try{localStorage.removeItem(RJ)}catch{}function zJ(e){let t=p(),n=v(),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{hk((e,t)=>{r.current.set(e,t)})},[]),(0,Q.useEffect)(()=>{a.current||(a.current=!0,t.pathname!==`/`&&n(`/`,{replace:!0}))},[]),(0,Q.useEffect)(()=>{if(i.current&&i.current!==e&&!LJ(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!LJ(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,Q.useEffect)(()=>{e&&t.pathname!==`/`&&!LJ(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function BJ(){let{t:e}=K(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setActiveProjectId:a}=at(),{cycleLeftMode:o,cycleRightMode:s}=eN(),c=v(),l=p(),u=Ca(),d=lM(),{startNewConversation:h}=d,{uiMode:_}=Ij();pJ();let[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,F]=(0,Q.useState)(!1),I=(0,Q.useCallback)(()=>F(!1),[]),[L,R]=(0,Q.useState)(()=>!oK());zJ(n),rJ();let{cheatsheetOpen:z,setCheatsheetOpen:B,openCheatsheet:ee}=gG(),H=[`/`,`/jobs`,`/analytics`,...V?[`/agents`]:[],...se?[`/code`]:[],`/integrations`,`/settings`];hG({onOpenCheatsheet:ee,onToggleLeftSidebar:o,onToggleRightSidebar:s,onSwitchProject:e=>{let n=t[e-1];n&&a(n.id)},onSwitchProjectPage:e=>{let t=H[e-1];t&&c(t)},onToggleTerminalPanel:Ce?()=>{n&&(u.togglePanel(n),u.getState(n).visibility===`hidden`?queueMicrotask(()=>u.focusActive(n)):u.focusActive(n))}:void 0,onToggleAgentChat:P&&_!==`agent`?()=>d.toggle():void 0}),oG({setActiveProjectId:a,projectsById:(0,Q.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])}),hJ({setActiveProjectId:a}),(0,Q.useEffect)(()=>{SA()},[]);let te=t.find(e=>e.id===n),ne=l.pathname.startsWith(`/loops`),re=l.pathname.startsWith(`/plugins`),ie=l.pathname.startsWith(`/docs`)||_!==`agent`&&(ne||re);(0,Q.useLayoutEffect)(()=>{let e=yJ({uiMode:_,pathname:l.pathname,loopsOpen:T,pluginsOpen:k,reviewOpen:j});if(e){if(e.kind===`modalize`){if(e.surface===`review`){e.reviewDeliveryId&&M(e.reviewDeliveryId),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}e.surface===`loops`?(A(!1),E(!0),e.loopBuilderId&&O(e.loopBuilderId)):(E(!1),A(!0)),h(n),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}E(!1),A(!1),M(null),l.pathname!==e.path&&c(e.path,{replace:!0})}},[n,l.pathname,T,c,k,j,h,_]);let{connectionStatus:ae}=lJ(),oe=wa(n),ce=_===`agent`?0:PJ,le=(0,Q.useRef)(null),[ue,de]=(0,Q.useState)(typeof window<`u`?window.innerHeight:820);(0,Q.useLayoutEffect)(()=>{if(!Ce)return;let e=le.current;if(!e)return;let t=()=>de(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,Q.useEffect)(()=>{!Ce||!n||u.ensureProject(n)},[n,u]);let fe=Ce&&_===`kanban`&&oe.visibility===`hidden`?(0,$.jsx)(CN,{isOpen:!1,onClick:()=>n&&u.setVisibility(n,`restored`)}):null;return r?(0,$.jsxs)(`div`,{className:`flex h-full`,children:[(0,$.jsx)(`div`,{className:`w-11 border-r border-border bg-card/50 animate-pulse flex-shrink-0`}),(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})})]}):(0,$.jsxs)(`div`,{className:`flex h-full overflow-hidden font-sans`,children:[(0,$.jsx)(NK,{onAddProject:()=>b(!0),onOpenLoops:()=>{_===`agent`?E(!0):c(`/loops`)},onOpenPlugins:()=>{_===`agent`?A(!0):c(`/plugins`)},onOpenAnalytics:()=>w(!0),onOpenDocs:()=>F(!0),onOpenSettings:()=>S(!0)}),(0,$.jsxs)(`div`,{ref:le,className:`flex flex-col flex-1 overflow-hidden`,children:[i&&(0,$.jsx)(`div`,{className:`h-0.5 w-full bg-accent-primary/70 animate-pulse shrink-0`,"data-testid":`project-switching-bar`}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:_===`agent`&&!ie?(0,$.jsx)(BM,{}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsxs)(g,{children:[(0,$.jsx)(m,{path:`/docs`,element:(0,$.jsx)(AJ,{})}),(0,$.jsx)(m,{path:`/docs/:category/:slug`,element:(0,$.jsx)(AJ,{})}),ge&&(0,$.jsx)(m,{path:`/loops`,element:(0,$.jsx)(MJ,{})}),ge&&(0,$.jsx)(m,{path:`/loops/:id/edit`,element:(0,$.jsx)(NJ,{})}),(0,$.jsx)(m,{path:`/plugins`,element:(0,$.jsx)(OJ,{})}),t.length===0?(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(rK,{onAddProject:()=>b(!0)})}):te?(0,$.jsxs)(m,{element:(0,$.jsx)(nK,{projectName:te.name,children:(0,$.jsx)(eK,{project:te})},te.id),children:[(0,$.jsx)(m,{path:`/`,element:(0,$.jsx)(YH,{})}),(0,$.jsx)(m,{path:`/jobs`,element:(0,$.jsx)(SJ,{})}),(0,$.jsx)(m,{path:`/jobs/:id`,element:(0,$.jsx)(bJ,{})}),ve&&(0,$.jsx)(m,{path:`/review/:prDeliveryId`,element:(0,$.jsx)(xJ,{})}),(0,$.jsx)(m,{path:`/analytics`,element:(0,$.jsx)(CJ,{})}),(0,$.jsx)(m,{path:`/activity`,element:(0,$.jsx)(wJ,{})}),(0,$.jsx)(m,{path:`/agents`,element:(0,$.jsx)(TJ,{})}),(0,$.jsx)(m,{path:`/code`,element:se?(0,$.jsx)(EJ,{}):(0,$.jsx)(f,{to:`/`,replace:!0})}),(0,$.jsx)(m,{path:`/integrations`,element:(0,$.jsx)(DJ,{})}),(0,$.jsx)(m,{path:`/settings`,element:(0,$.jsx)(vU,{})}),(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(f,{to:`/`,replace:!0})})]}):(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(rK,{onAddProject:()=>b(!0)})})]})})}),Ce&&n&&te&&(0,$.jsx)(WN,{projectId:n,provider:te.provider,providers:rt(te),state:oe,viewportHeight:ue,statusBarHeight:ce}),_!==`agent`&&(0,$.jsx)(uJ,{connectionStatus:ae,rightSlot:fe})]}),_===`agent`?!ie&&(0,$.jsx)(iN,{}):te&&!ie&&(0,$.jsx)(FK,{}),(0,$.jsx)(KK,{open:y,onClose:()=>b(!1),onOpenBuilder:()=>d.builderMode.enter()}),(0,$.jsx)(uG,{open:x,onClose:()=>S(!1),onOpenOnboarding:()=>{S(!1),R(!0)}}),(0,$.jsx)(Hn,{open:C,onOpenChange:w,children:(0,$.jsx)(Bn,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsx)(kJ,{})})})})}),(0,$.jsx)(Hn,{open:T,onOpenChange:e=>{E(e),e||O(null)},children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,$.jsx)(FJ,{surface:`loops`,onClose:()=>{E(!1),O(null)}}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:D?(0,$.jsx)(`div`,{className:`h-full`,children:(0,$.jsx)(NJ,{loopId:D,onExit:()=>O(null)})}):(0,$.jsx)(MJ,{onOpenBuilder:O})})})]})}),ve&&(0,$.jsx)(Hn,{open:j!==null,onOpenChange:e=>{e||M(null)},children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,"data-testid":`review-packet-modal`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.review`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.reviewDescription`)}),(0,$.jsx)(FJ,{surface:`review`,onClose:()=>M(null)}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:j&&(0,$.jsx)(xJ,{prDeliveryId:j,onClose:()=>M(null)})})})]})}),(0,$.jsx)(Hn,{open:k,onOpenChange:A,children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,$.jsx)(FJ,{surface:`plugins`,onClose:()=>A(!1)}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsx)(OJ,{})})})]})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(jJ,{open:N,onClose:I})}),(0,$.jsx)(Zq,{onOpenSettings:()=>S(!0),onOpenAnalytics:()=>w(!0),onOpenDocs:()=>F(!0)}),(0,$.jsx)(xG,{open:z,onOpenChange:B}),(0,$.jsx)(xK,{open:L,onClose:()=>R(!1)})]})}function VJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(xa,{activeProjectId:t,children:e})}function HJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(fH,{activeProjectId:t,children:e})}function UJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(yH,{activeProjectId:t,children:e})}function WJ(){return(0,$.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function GJ(){let{theme:e}=oa(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,xb.createPortal)((0,$.jsx)(it,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,$.jsx)(WJ,{})},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:``}}}),document.body)}function KJ(){return sW(),null}function qJ(){let e=$r();return sJ(),(0,$.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:(0,$.jsx)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:(0,$.jsx)(We,{url:ae,children:(0,$.jsx)(aa,{children:(0,$.jsxs)(EU,{children:[(0,$.jsx)($G,{}),(0,$.jsx)(ot,{isolated:e,children:(0,$.jsxs)(Pj,{initialMode:e?`agent`:void 0,persist:!e,children:[!e&&(0,$.jsx)(KJ,{}),(0,$.jsx)(EG,{}),(0,$.jsx)($R,{children:(0,$.jsx)(tJ,{children:(0,$.jsx)(te,{children:(0,$.jsx)($M,{children:(0,$.jsx)(VJ,{children:(0,$.jsx)(HJ,{children:(0,$.jsx)(UJ,{children:(0,$.jsx)(Xt,{children:(0,$.jsx)(Vx,{children:(0,$.jsx)(oi,{secondary:e,children:(0,$.jsx)(sM,{children:(0,$.jsx)(rS,{children:(0,$.jsx)(W,{children:(0,$.jsxs)(_e,{children:[(0,$.jsx)(dM,{}),(0,$.jsx)(vc,{}),e?(0,$.jsx)(GN,{}):(0,$.jsx)(BJ,{}),(0,$.jsx)(fJ,{}),(0,$.jsx)(GJ,{})]})})})})})})})})})})})})})})]})})]})})})})})}async function JJ(){await Ge(),Je(),await Be(),(0,Cr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(_,{children:(0,$.jsx)(qJ,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}JJ();export{Cy as $,HP as A,Fo as At,TO as B,Ka as Bt,nL as C,fs as Ct,FI as D,ts as Dt,lL as E,ns as Et,Qk as F,So as Ft,ax as G,_D as H,si as Ht,pk as I,xo as It,_b as J,ox as K,uk as L,yo as Lt,NP as M,jo as Mt,_P as N,Do as Nt,NF as O,Qo as Ot,lM as P,Eo as Pt,hy as Q,EO as R,_o as Rt,pL as S,hs as St,xL as T,as as Tt,gD as U,DO as V,ca as Vt,Ux as W,wy as X,pb as Y,my as Z,aV as _,Os as _t,lU as a,sc as at,fz as b,vs as bt,rU as c,nc as ct,ZV as d,Ys as dt,gc as et,lH as f,Js as ft,kV as g,ks as gt,TV as h,As as ht,gU as i,uc as it,MP as j,Mo as jt,RF as k,Ho as kt,jH as l,tc as lt,MV as m,Vs as mt,_U as n,pc as nt,mU as o,ac as ot,cH as p,Ws as pt,bx as q,uU as r,dc as rt,oU as s,ic as st,lJ as t,mc as tt,mH as u,Zs as ut,Wz as v,Ds as vt,TL as w,os as wt,kL as x,gs as xt,pz as y,ws as yt,OO as z,po as zt};
|
|
76
|
+
`;function $q(e){return`contract-refine:${e}`}async function eJ(e,t){try{let n=await fetch(`${He}/api/projects/${e}/tickets/${t}/contract-refine`,{method:`POST`});if(n.ok)J.loading(G.t(`activity:contractRefine.refining`),{id:$q(t)});else{let e=await n.json().catch(()=>({}));J.error(e.error?G.t(`activity:contractRefine.retryRejectedWithError`,{error:e.error}):G.t(`activity:contractRefine.retryRejected`),{id:$q(t)})}}catch(e){J.error(G.t(`activity:contractRefine.retryFailed`,{message:e.message}),{id:$q(t)})}}function tJ({children:e}){let{registerHandler:t,unregisterHandler:n}=qe(),r=(0,Q.useRef)(new Map),i=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`explore.contract_refine_failed`)return;let n=t.ticketId,i=t.projectId,a=typeof t.provider==`string`?t.provider:void 0,o=t.reason??`unknown`;if(typeof n!=`number`||!i)return;r.current.set(n,i);let s=pr(a)?{label:G.t(`common:actions.retry`),onClick:()=>void eJ(i,n)}:void 0;J.error(G.t(`activity:contractRefine.skipped`),{id:$q(n),description:G.t(`activity:contractRefine.reason`,{reason:o}),...s?{action:s}:{},duration:15e3})},[]),a=(0,Q.useCallback)(e=>{let t=e;if(!t||t.type!==`ticket_updated`)return;let n=t.ticket;n&&typeof n.description==`string`&&n.description.includes(Qq)&&J.success(G.t(`activity:contractRefine.added`,{title:n.title||`#${n.id}`}),{id:$q(n.id),duration:3500})},[]);return(0,Q.useLayoutEffect)(()=>(t(`_contract_refine_failed`,i),t(`_contract_refine_ticket_updated`,a),()=>{n(`_contract_refine_failed`),n(`_contract_refine_ticket_updated`)}),[t,n,i,a]),(0,Q.useEffect)(()=>()=>r.current.clear(),[]),(0,$.jsx)($.Fragment,{children:e})}function nJ(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function rJ(){let{t:e}=K(`mcp`),t=DU()?.languageId;(0,Q.useEffect)(()=>{nJ()&&Y(`set_tray_labels`,{open:e(`tray.open`),exit:e(`tray.exit`)}).catch(()=>{})},[e,t])}var iJ=`input, textarea, select, [contenteditable="true"], [contenteditable=""], .monaco-editor, .xterm, [data-native-menu]`;function aJ(e){return e instanceof Element&&e.closest(iJ)!==null}function oJ(e){aJ(e.target)||e.preventDefault()}function sJ(){(0,Q.useEffect)(()=>(document.addEventListener(`contextmenu`,oJ),()=>document.removeEventListener(`contextmenu`,oJ)),[])}var cJ={jobs:[],activeJobId:null,paused:!1};function lJ(e){let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)({}),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(cJ),[p,m]=(0,Q.useState)(0),h=(0,Q.useRef)(e);h.current=e;let g=(0,Q.useRef)(new Map),_=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{if(_.current&&_.current,_.current=e,e){let t=g.current.get(e);t?(n(t.phaseDefinitions),i(t.phases),o(t.projectName),u(t.recentJobs),f(t.queueState)):(n([]),i({}),o(``),u([]),f(cJ))}c([])},[e]);let v=(0,Q.useCallback)(e=>{let t=e;if(!t||typeof t.type!=`string`)return;let r=h.current;if(!(r&&t.projectId&&t.projectId!==r))if(t.type===`desktop.project_recovered`)t.projectId===r&&m(e=>e+1);else 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??cJ;o(e),n(a),i(s),c(t.logBuffer??[]),u(l),f(d),r&&g.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:y,unregisterHandler:b,connectionStatus:x}=qe();return(0,Q.useLayoutEffect)(()=>(y(`pipeline`,v),()=>b(`pipeline`)),[v,y,b]),(0,Q.useEffect)(()=>{if(!e)return;let t=!1;async function r(){try{let e=await fetch(`${nt()}/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,p]),{phases:r,phaseDefinitions:t,projectName:a,logLines:s,connectionStatus:x,recentJobs:l,queueState:d}}function uJ({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=K(`nav`),{t:i}=K(`analytics`),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(`connecting`),u=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{let t=l.current;if(e===`connected`&&!u.current&&t!==`connected`){J.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,Q.useEffect)(()=>{u.current&&=!1},[]),(0,Q.useEffect)(()=>{if(n)return;async function e(){try{let e=await fetch(`${nt()}/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,$.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,$.jsxs)(`div`,{className:X(`flex items-center gap-1.5 transition-opacity duration-300`,!d&&`opacity-0`),"aria-hidden":!d||void 0,children:[(0,$.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,$.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,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!n&&a&&(a.totalCostUsd>0||(a.unpricedRuns??0)>0)&&(()=>{let e=a.includesEstimated??((a.estimatedCostUsd??0)>0||(a.estimatedCostToday??0)>0),t=a.unpricedRuns??0,n=a.pricedRuns??Math.max(0,(a.totalJobs??0)-t),r=a.totalCostUsd===0&&t>0&&n===0,o=t>0&&(n>0||a.totalCostUsd>0);return(0,$.jsx)(`span`,{"data-estimated":e?`true`:void 0,"data-testid":r?`statusbar-cost-unavailable`:void 0,title:r?i(`desktop.costUnavailable`):o?i(`desktop.costPartiallyUnavailable`,{count:t}):e?i(`desktop.statusBarEstimatedTooltip`):void 0,children:r?i(`desktop.costUnavailableShort`):`${e?`~`:``}${o?`≥`:``}$${a.totalCostUsd.toFixed(2)}`})})(),t]})]})}var dJ=(0,Q.lazy)(()=>c(()=>import(`./AgentBrowserCapture-BQem50z4.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([85,1,7,9,8,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])));function fJ(){let{browserOpen:e}=Ux(),{active:t}=lM(),n=si(),r=!n.current&&n.transfers.some(e=>e.conversationId===t?.id&&e.state===`detached`),{activeProjectId:i}=at();return!e||!i||r?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(dJ,{projectId:i,conversationId:t?.id??null})})}function pJ(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=he(),{tickets:i}=T(),a=p(),o=v(),s=(0,Q.useRef)(!1);(0,Q.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,Q.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 mJ(e){let{key:t,detail:n}=jt(e);return[`chunk_failed`,`chunk_stalled`,`chunk_stopped`,`provider_limit`,`launch_rejected`,`head_missing`,`head_discarded`,`run_lost`].includes(t)?G.t(`builder:milestoneProgress.chain.reasons.${t}`,{detail:n}):e??``}function hJ({setActiveProjectId:e}={}){let t=v(),n=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{n.current=t},[t]);let r=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{r.current=e},[e]);let i=(0,Q.useRef)(new Map),a=(0,Q.useRef)(new Map),{registerHandler:o,unregisterHandler:s}=qe();(0,Q.useEffect)(()=>{let e=`milestone-notifications`;return o(e,e=>{let t=e;if(!t||typeof t.projectId!=`string`)return;let o=t.projectId;if(t.type===`milestone.chain_changed`){let e=yt(t.chain);if(!e)return;let n=i.current.get(e.id);i.current.set(e.id,e);let r=xt(e.milestoneN);if(e.status===`running`&&e.nextChunk>1&&(!n||n.nextChunk<e.nextChunk)&&J.success(G.t(`builder:milestoneProgress.toast.chunkLaunched`,{milestone:r,k:e.nextChunk,n:e.totalChunks}),{id:`chain-launch:${e.id}:${e.nextChunk}`}),e.status===`awaiting_approval`&&(!n||n.status!==`awaiting_approval`||n.nextChunk!==e.nextChunk)){let t=`chain-checkpoint:${e.id}:${e.nextChunk}`;J.success(G.t(`builder:milestoneProgress.toast.checkpoint`,{milestone:r,k:e.nextChunk,n:e.totalChunks}),{id:t,duration:6e4,action:{label:G.t(`builder:milestoneProgress.toast.launchNext`),onClick:()=>{OA(o,e.id).then(e=>{e.ok?J.success(G.t(`builder:milestoneProgress.chain.nextLaunched`),{id:t}):J.error(G.t(`builder:milestoneProgress.chain.resumeFailed`),{id:t,description:e.detail??e.error})})}},cancel:{label:G.t(`builder:milestoneProgress.toast.autoContinue`),onClick:()=>{AA(o,e.id,!0).then(e=>{e.ok?J.success(G.t(`builder:milestoneProgress.chain.autoOn`),{id:t}):J.error(G.t(`builder:milestoneProgress.chain.autoFailed`),{id:t,description:e.detail??e.error})})}}})}e.status===`paused`&&(!n||n.status!==`paused`||n.pauseReason!==e.pauseReason)&&J.warning(G.t(`builder:milestoneProgress.toast.paused`,{milestone:r,reason:mJ(e.pauseReason)}),{id:`chain-paused:${e.id}`,duration:3e4,action:{label:G.t(`builder:milestoneProgress.toast.resume`),onClick:()=>{OA(o,e.id).then(t=>{t.ok?J.success(G.t(`builder:milestoneProgress.chain.resumed`),{id:`chain-paused:${e.id}`}):J.error(G.t(`builder:milestoneProgress.chain.resumeFailed`),{id:`chain-paused:${e.id}`,description:t.detail??t.error})})}}});return}if(t.type===`blueprint.milestone_progress`){for(let e of Tt(t.progress)){let t=`${o}:${e.id}`,i=a.current.get(t);if(a.current.set(t,e.state),!(i===void 0||i===e.state)&&e.state===`delivered`){let i=Et(e);J.success(G.t(`builder:milestoneProgress.toast.delivered`,{milestone:xt(e.n),count:e.counts.onReview}),{id:`milestone-delivered:${t}`,duration:3e4,...i?{action:{label:G.t(`builder:milestoneProgress.toast.review`),onClick:()=>{r.current?.(o);let e=ve?`/review/${i.id}`:`/`;setTimeout(()=>{n.current(e)},50)}}}:{}})}}return}t.type===`blueprint.milestone_completed`&&typeof t.n==`number`&&J.success(G.t(`builder:milestoneProgress.toast.completed`,{milestone:xt(t.n)}),{id:`milestone-completed:${o}:${t.milestoneId??t.n}`,duration:15e3})}),()=>s(e)},[o,s])}function gJ(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:_J(e)?`review`:null}function _J(e){let t=/^\/review\/([^/]+)\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function vJ(e){let t=/^\/loops\/([^/]+)\/edit\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function yJ({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r,reviewOpen:i=null}){if(e===`agent`){let e=gJ(t);if(!e)return null;if(e===`review`)return{kind:`modalize`,surface:e,backgroundPath:`/`,reviewDeliveryId:_J(t)??void 0};let n=e===`loops`?vJ(t):null;return n?{kind:`modalize`,surface:e,backgroundPath:`/`,loopBuilderId:n}:{kind:`modalize`,surface:e,backgroundPath:`/`}}return n?{kind:`route`,surface:`loops`,path:`/loops`}:r?{kind:`route`,surface:`plugins`,path:`/plugins`}:i?{kind:`route`,surface:`review`,path:`/review/${encodeURIComponent(i)}`}:null}var bJ=(0,Q.lazy)(()=>c(()=>import(`./JobDetailPage-vaOcE-cI.js`),__vite__mapDeps([86,1,7,11,10,9,8,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,76,81]))),xJ=(0,Q.lazy)(()=>c(()=>import(`./ReviewPacketPage-DbKO6pT8.js`),__vite__mapDeps([87,1,7,11,10,9,8,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,88]))),SJ=(0,Q.lazy)(()=>c(()=>import(`./JobsPage-Bwoe-Fb0.js`),__vite__mapDeps([89,1,7,11,10,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,44,8,51,59,60,49,63,64,65,66,67,68,69,76,81,90,52]))),CJ=(0,Q.lazy)(()=>c(()=>import(`./AnalyticsPage-DTsg-N5z.js`),__vite__mapDeps([91,1,7,11,10,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,8,46,65,67,68,72,90,52,92,93]))),wJ=(0,Q.lazy)(()=>c(()=>import(`./ActivityFeedPage-CL1BUXoj.js`),__vite__mapDeps([94,1,7,12,10,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,44,8,51,54,62]))),TJ=(0,Q.lazy)(()=>c(()=>import(`./AgentsPage-DbLezyI6.js`),__vite__mapDeps([95,1,7,8,12,10,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,47,11,48,49,50,54,55,57,58,59,60,63,64,65,69,72,81]))),EJ=(0,Q.lazy)(()=>c(()=>import(`./CodePage-DwgbeqQ_.js`),__vite__mapDeps([96,1,7,8,10,11,9,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]))),DJ=(0,Q.lazy)(()=>c(()=>import(`./IntegrationsPage-Bhy58lnQ.js`),__vite__mapDeps([97,7,1,11,10]))),OJ=(0,Q.lazy)(()=>c(()=>import(`./PluginsPage-CTUHX_Lu.js`),__vite__mapDeps([98,1,7,12,10,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,44,8,52,54,58,59,60,61,63,49,64,65,69,72]))),kJ=(0,Q.lazy)(()=>c(()=>import(`./DesktopAnalyticsPage-Y0Z1ryQr.js`),__vite__mapDeps([99,1,7,12,10,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,65,64,92,8,93]))),AJ=(0,Q.lazy)(()=>c(()=>import(`./DocsPage-Bt1PgYPO.js`),__vite__mapDeps([100,1,7,11,10,42,50,54,64,65,66,75,101,102]))),jJ=(0,Q.lazy)(()=>c(()=>import(`./DocsDialog-KeCOxvGH.js`),__vite__mapDeps([103,1,7,42,50,54,63,8,49,64,65,66,75,101,102]))),MJ=(0,Q.lazy)(()=>c(()=>import(`./LoopsPage-DrQGcZv2.js`),__vite__mapDeps([104,1,7,11,10,42,44,8,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,52,55,56,57,48,59,105,63,49,64,65,69,70,71,72,78,74,53]))),NJ=(0,Q.lazy)(()=>c(()=>import(`./LoopBuilderPage-CqC4hbXb.js`),__vite__mapDeps([106,1,7,8,11,10,42,44,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,45,74,53,56,57,59,60,105,63,49,64,65,69,71,93,107]))),PJ=28;function FJ({surface:e,onClose:t}){let{t:n}=K(`nav`),r=n(e===`loops`?`arcSidebar.loops`:e===`review`?`arcSidebar.review`:`arcSidebar.plugins`);return(0,$.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,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.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,$.jsx)(e===`loops`?gc:e===`review`?Qo:Ws,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`truncate text-xs font-medium text-foreground`,children:r})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,$.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,$.jsx)(mn,{className:`h-4 w-4`})})})]})}var IJ=new Set([`/settings`,`/loops`,`/plugins`]);function LJ(e){return IJ.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var RJ=`specrails-desktop:routeMemory`;try{localStorage.removeItem(RJ)}catch{}function zJ(e){let t=p(),n=v(),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{hk((e,t)=>{r.current.set(e,t)})},[]),(0,Q.useEffect)(()=>{a.current||(a.current=!0,t.pathname!==`/`&&n(`/`,{replace:!0}))},[]),(0,Q.useEffect)(()=>{if(i.current&&i.current!==e&&!LJ(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!LJ(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,Q.useEffect)(()=>{e&&t.pathname!==`/`&&!LJ(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function BJ(){let{t:e}=K(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setActiveProjectId:a}=at(),{cycleLeftMode:o,cycleRightMode:s}=eN(),c=v(),l=p(),u=Ca(),d=lM(),{startNewConversation:h}=d,{uiMode:_}=Ij();pJ();let[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,F]=(0,Q.useState)(!1),I=(0,Q.useCallback)(()=>F(!1),[]),[L,R]=(0,Q.useState)(()=>!oK());zJ(n),rJ();let{cheatsheetOpen:z,setCheatsheetOpen:B,openCheatsheet:ee}=gG(),H=[`/`,`/jobs`,`/analytics`,...V?[`/agents`]:[],...se?[`/code`]:[],`/integrations`,`/settings`];hG({onOpenCheatsheet:ee,onToggleLeftSidebar:o,onToggleRightSidebar:s,onSwitchProject:e=>{let n=t[e-1];n&&a(n.id)},onSwitchProjectPage:e=>{let t=H[e-1];t&&c(t)},onToggleTerminalPanel:Ce?()=>{n&&(u.togglePanel(n),u.getState(n).visibility===`hidden`?queueMicrotask(()=>u.focusActive(n)):u.focusActive(n))}:void 0,onToggleAgentChat:P&&_!==`agent`?()=>d.toggle():void 0}),oG({setActiveProjectId:a,projectsById:(0,Q.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])}),hJ({setActiveProjectId:a}),(0,Q.useEffect)(()=>{SA()},[]);let te=t.find(e=>e.id===n),ne=l.pathname.startsWith(`/loops`),re=l.pathname.startsWith(`/plugins`),ie=l.pathname.startsWith(`/docs`)||_!==`agent`&&(ne||re);(0,Q.useLayoutEffect)(()=>{let e=yJ({uiMode:_,pathname:l.pathname,loopsOpen:T,pluginsOpen:k,reviewOpen:j});if(e){if(e.kind===`modalize`){if(e.surface===`review`){e.reviewDeliveryId&&M(e.reviewDeliveryId),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}e.surface===`loops`?(A(!1),E(!0),e.loopBuilderId&&O(e.loopBuilderId)):(E(!1),A(!0)),h(n),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}E(!1),A(!1),M(null),l.pathname!==e.path&&c(e.path,{replace:!0})}},[n,l.pathname,T,c,k,j,h,_]);let{connectionStatus:ae}=lJ(),oe=wa(n),ce=_===`agent`?0:PJ,le=(0,Q.useRef)(null),[ue,de]=(0,Q.useState)(typeof window<`u`?window.innerHeight:820);(0,Q.useLayoutEffect)(()=>{if(!Ce)return;let e=le.current;if(!e)return;let t=()=>de(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,Q.useEffect)(()=>{!Ce||!n||u.ensureProject(n)},[n,u]);let fe=Ce&&_===`kanban`&&oe.visibility===`hidden`?(0,$.jsx)(CN,{isOpen:!1,onClick:()=>n&&u.setVisibility(n,`restored`)}):null;return r?(0,$.jsxs)(`div`,{className:`flex h-full`,children:[(0,$.jsx)(`div`,{className:`w-11 border-r border-border bg-card/50 animate-pulse flex-shrink-0`}),(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})})]}):(0,$.jsxs)(`div`,{className:`flex h-full overflow-hidden font-sans`,children:[(0,$.jsx)(NK,{onAddProject:()=>b(!0),onOpenLoops:()=>{_===`agent`?E(!0):c(`/loops`)},onOpenPlugins:()=>{_===`agent`?A(!0):c(`/plugins`)},onOpenAnalytics:()=>w(!0),onOpenDocs:()=>F(!0),onOpenSettings:()=>S(!0)}),(0,$.jsxs)(`div`,{ref:le,className:`flex flex-col flex-1 overflow-hidden`,children:[i&&(0,$.jsx)(`div`,{className:`h-0.5 w-full bg-accent-primary/70 animate-pulse shrink-0`,"data-testid":`project-switching-bar`}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:_===`agent`&&!ie?(0,$.jsx)(BM,{}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsxs)(g,{children:[(0,$.jsx)(m,{path:`/docs`,element:(0,$.jsx)(AJ,{})}),(0,$.jsx)(m,{path:`/docs/:category/:slug`,element:(0,$.jsx)(AJ,{})}),ge&&(0,$.jsx)(m,{path:`/loops`,element:(0,$.jsx)(MJ,{})}),ge&&(0,$.jsx)(m,{path:`/loops/:id/edit`,element:(0,$.jsx)(NJ,{})}),(0,$.jsx)(m,{path:`/plugins`,element:(0,$.jsx)(OJ,{})}),t.length===0?(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(rK,{onAddProject:()=>b(!0)})}):te?(0,$.jsxs)(m,{element:(0,$.jsx)(nK,{projectName:te.name,children:(0,$.jsx)(eK,{project:te})},te.id),children:[(0,$.jsx)(m,{path:`/`,element:(0,$.jsx)(YH,{})}),(0,$.jsx)(m,{path:`/jobs`,element:(0,$.jsx)(SJ,{})}),(0,$.jsx)(m,{path:`/jobs/:id`,element:(0,$.jsx)(bJ,{})}),ve&&(0,$.jsx)(m,{path:`/review/:prDeliveryId`,element:(0,$.jsx)(xJ,{})}),(0,$.jsx)(m,{path:`/analytics`,element:(0,$.jsx)(CJ,{})}),(0,$.jsx)(m,{path:`/activity`,element:(0,$.jsx)(wJ,{})}),(0,$.jsx)(m,{path:`/agents`,element:(0,$.jsx)(TJ,{})}),(0,$.jsx)(m,{path:`/code`,element:se?(0,$.jsx)(EJ,{}):(0,$.jsx)(f,{to:`/`,replace:!0})}),(0,$.jsx)(m,{path:`/integrations`,element:(0,$.jsx)(DJ,{})}),(0,$.jsx)(m,{path:`/settings`,element:(0,$.jsx)(vU,{})}),(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(f,{to:`/`,replace:!0})})]}):(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(rK,{onAddProject:()=>b(!0)})})]})})}),Ce&&n&&te&&(0,$.jsx)(WN,{projectId:n,provider:te.provider,providers:rt(te),state:oe,viewportHeight:ue,statusBarHeight:ce}),_!==`agent`&&(0,$.jsx)(uJ,{connectionStatus:ae,rightSlot:fe})]}),_===`agent`?!ie&&(0,$.jsx)(iN,{}):te&&!ie&&(0,$.jsx)(FK,{}),(0,$.jsx)(KK,{open:y,onClose:()=>b(!1),onOpenBuilder:()=>d.builderMode.enter()}),(0,$.jsx)(uG,{open:x,onClose:()=>S(!1),onOpenOnboarding:()=>{S(!1),R(!0)}}),(0,$.jsx)(Hn,{open:C,onOpenChange:w,children:(0,$.jsx)(Bn,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsx)(kJ,{})})})})}),(0,$.jsx)(Hn,{open:T,onOpenChange:e=>{E(e),e||O(null)},children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,$.jsx)(FJ,{surface:`loops`,onClose:()=>{E(!1),O(null)}}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:D?(0,$.jsx)(`div`,{className:`h-full`,children:(0,$.jsx)(NJ,{loopId:D,onExit:()=>O(null)})}):(0,$.jsx)(MJ,{onOpenBuilder:O})})})]})}),ve&&(0,$.jsx)(Hn,{open:j!==null,onOpenChange:e=>{e||M(null)},children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,"data-testid":`review-packet-modal`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.review`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.reviewDescription`)}),(0,$.jsx)(FJ,{surface:`review`,onClose:()=>M(null)}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:j&&(0,$.jsx)(xJ,{prDeliveryId:j,onClose:()=>M(null)})})})]})}),(0,$.jsx)(Hn,{open:k,onOpenChange:A,children:(0,$.jsxs)(Bn,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,children:[(0,$.jsx)(Fn,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,$.jsx)(Mn,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,$.jsx)(FJ,{surface:`plugins`,onClose:()=>A(!1)}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`states.loading`)})}),children:(0,$.jsx)(OJ,{})})})]})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(jJ,{open:N,onClose:I})}),(0,$.jsx)(Zq,{onOpenSettings:()=>S(!0),onOpenAnalytics:()=>w(!0),onOpenDocs:()=>F(!0)}),(0,$.jsx)(xG,{open:z,onOpenChange:B}),(0,$.jsx)(xK,{open:L,onClose:()=>R(!1)})]})}function VJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(xa,{activeProjectId:t,children:e})}function HJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(fH,{activeProjectId:t,children:e})}function UJ({children:e}){let{activeProjectId:t}=at();return(0,$.jsx)(yH,{activeProjectId:t,children:e})}function WJ(){return(0,$.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function GJ(){let{theme:e}=oa(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,xb.createPortal)((0,$.jsx)(it,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,$.jsx)(WJ,{})},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:``}}}),document.body)}function KJ(){return sW(),null}function qJ(){let e=$r();return sJ(),(0,$.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:(0,$.jsx)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:(0,$.jsx)(We,{url:ae,children:(0,$.jsx)(aa,{children:(0,$.jsxs)(EU,{children:[(0,$.jsx)($G,{}),(0,$.jsx)(ot,{isolated:e,children:(0,$.jsxs)(Pj,{initialMode:e?`agent`:void 0,persist:!e,children:[!e&&(0,$.jsx)(KJ,{}),(0,$.jsx)(EG,{}),(0,$.jsx)($R,{children:(0,$.jsx)(tJ,{children:(0,$.jsx)(te,{children:(0,$.jsx)($M,{children:(0,$.jsx)(VJ,{children:(0,$.jsx)(HJ,{children:(0,$.jsx)(UJ,{children:(0,$.jsx)(Xt,{children:(0,$.jsx)(Vx,{children:(0,$.jsx)(oi,{secondary:e,children:(0,$.jsx)(sM,{children:(0,$.jsx)(rS,{children:(0,$.jsx)(W,{children:(0,$.jsxs)(_e,{children:[(0,$.jsx)(dM,{}),(0,$.jsx)(vc,{}),e?(0,$.jsx)(GN,{}):(0,$.jsx)(BJ,{}),(0,$.jsx)(fJ,{}),(0,$.jsx)(GJ,{})]})})})})})})})})})})})})})})]})})]})})})})})}async function JJ(){await Ge(),Je(),await Be(),(0,Cr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(_,{children:(0,$.jsx)(qJ,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}JJ();export{Cy as $,HP as A,Fo as At,TO as B,Ka as Bt,nL as C,fs as Ct,FI as D,ts as Dt,lL as E,ns as Et,Qk as F,So as Ft,ax as G,_D as H,si as Ht,pk as I,xo as It,_b as J,ox as K,uk as L,yo as Lt,NP as M,jo as Mt,_P as N,Do as Nt,NF as O,Qo as Ot,lM as P,Eo as Pt,hy as Q,EO as R,_o as Rt,pL as S,hs as St,xL as T,as as Tt,gD as U,DO as V,ca as Vt,Ux as W,wy as X,pb as Y,my as Z,aV as _,Os as _t,lU as a,sc as at,fz as b,vs as bt,rU as c,nc as ct,ZV as d,Ys as dt,gc as et,lH as f,Js as ft,kV as g,ks as gt,TV as h,As as ht,gU as i,uc as it,MP as j,Mo as jt,RF as k,Ho as kt,jH as l,tc as lt,MV as m,Vs as mt,_U as n,pc as nt,mU as o,ac as ot,cH as p,Ws as pt,bx as q,uU as r,dc as rt,oU as s,ic as st,lJ as t,mc as tt,mH as u,Zs as ut,Wz as v,Ds as vt,TL as w,os as wt,kL as x,gs as xt,pz as y,ws as yt,OO as z,po as zt};
|