specrails-desktop 2.63.0 → 2.63.1
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-Bn2MpG5M.js → ActivityFeedPage-B1bpTy7O.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-CHlXWdXq.js → AgentBrowserCapture-BussBbN3.js} +1 -1
- package/client/dist/assets/{AgentModeAnalyticsPane-yj-YCgrK.js → AgentModeAnalyticsPane-BiT1n3BU.js} +2 -2
- package/client/dist/assets/{AgentModeCodePane-Xczcyghb.js → AgentModeCodePane-CUjNfeKa.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-DtOW01ln.js → AgentModeJobsPane-RVEwyS59.js} +1 -1
- package/client/dist/assets/{AgentsPage-BMfJ4mzU.js → AgentsPage-DKE-eMC5.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-CGn5cgtc.js → AnalyticsPage-Bser2Ly3.js} +1 -1
- package/client/dist/assets/{CodePage-C8NIginr.js → CodePage-BK0grm6e.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-C87r4y26.js → DesktopAnalyticsPage-DEBidZbs.js} +1 -1
- package/client/dist/assets/{DocsDialog-Z50a_KPv.js → DocsDialog-Dhyo57n9.js} +1 -1
- package/client/dist/assets/{DocsPage-DIArbEPl.js → DocsPage-BcEkPXd6.js} +1 -1
- package/client/dist/assets/{ExportDropdown-CJdCqYd7.js → ExportDropdown-mRmqdkjr.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-BxLh4me-.js → InteractiveJobComposer-BlCe3vrU.js} +1 -1
- package/client/dist/assets/{JobDetailModal-C7dWoRu6.js → JobDetailModal-CkAejD1F.js} +1 -1
- package/client/dist/assets/{JobDetailPage-Ilu294WS.js → JobDetailPage-P-FS_lKz.js} +1 -1
- package/client/dist/assets/{JobsPage-fPq1hefb.js → JobsPage-CoUXgYse.js} +1 -1
- package/client/dist/assets/LoopBuilderPage-iFylNk68.js +1 -0
- package/client/dist/assets/{LoopPreviewModal-ChI3NQC7.js → LoopPreviewModal-4obS_Ptg.js} +1 -1
- package/client/dist/assets/{LoopWindowSurface-D1WB9i-9.js → LoopWindowSurface-CLr5OPqj.js} +1 -1
- package/client/dist/assets/{LoopsPage-CCwc0Biu.js → LoopsPage-eKpWFtCp.js} +1 -1
- package/client/dist/assets/{MinimizedChatsContext-eH_KaAZ1.js → MinimizedChatsContext-BHIUPVmC.js} +1 -1
- package/client/dist/assets/{PluginsPage-DfDfEfbW.js → PluginsPage-BgTC2CQx.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-9NHnG8JQ.js → ProjectSettingsDialog-B4chTfU8.js} +1 -1
- package/client/dist/assets/{RepositoryDeliveries-DgzNnJmn.js → RepositoryDeliveries-DAIxIYsl.js} +1 -1
- package/client/dist/assets/{RepositoryScopeSelector-BSgUqk_u.js → RepositoryScopeSelector-DeCoUsRN.js} +1 -1
- package/client/dist/assets/{ReviewPacketPage-D34bGpSA.js → ReviewPacketPage-Cktv0-9b.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-CcfSxWQ7.js → TemplatePreviewModal-BZTV1TM1.js} +1 -1
- package/client/dist/assets/{TicketDetailModalContext-BoafEcm4.js → TicketDetailModalContext-DiPngt2g.js} +1 -1
- package/client/dist/assets/{Trans-CVSryAL1.js → Trans-ZiXIfj50.js} +1 -1
- package/client/dist/assets/{agentRuntime-TKQyg137.js → agentRuntime-BDvbJMmS.js} +1 -1
- package/client/dist/assets/{agentRuntime-DvhEe1um.js → agentRuntime-BKJfv5YD.js} +1 -1
- package/client/dist/assets/{agentRuntime-DxC6-9rN.js → agentRuntime-BxF81z52.js} +1 -1
- package/client/dist/assets/{agentRuntime-C_yLPKDy.js → agentRuntime-BxYS5V7u.js} +1 -1
- package/client/dist/assets/{agentRuntime-WSv8G0pW.js → agentRuntime-BzuwQQgn.js} +1 -1
- package/client/dist/assets/{agentRuntime-D2kYQqNO.js → agentRuntime-Dc9HG3BA.js} +1 -1
- package/client/dist/assets/{agentRuntime-Bjt7Ij6_.js → agentRuntime-DiCldqGG.js} +1 -1
- package/client/dist/assets/{agentRuntime-B-myNBUP.js → agentRuntime-es2ymSl-.js} +1 -1
- package/client/dist/assets/{formatDistanceToNow-NVM6rK3i.js → formatDistanceToNow-CdN5lTyD.js} +1 -1
- package/client/dist/assets/{getTimezoneOffsetInMilliseconds-ZHg7WpdH.js → getTimezoneOffsetInMilliseconds-62h40I4t.js} +1 -1
- package/client/dist/assets/index-BgbCbIua.css +2 -0
- package/client/dist/assets/{index-Culan6y7.js → index-CECj3joE.js} +7 -7
- package/client/dist/assets/{jira-api-Bl8xEIpk.js → jira-api-C_D_RDhl.js} +1 -1
- package/client/dist/assets/{project-repositories-CvJf1a6H.js → project-repositories-Be0CWklo.js} +1 -1
- package/client/dist/assets/{spending-BfjSJjBd.js → spending-eWiZGhC_.js} +1 -1
- package/client/dist/assets/{useDesktop-C5JVBeur.js → useDesktop-C0mRIlHT.js} +1 -1
- package/client/dist/assets/{useRuntimeRuns-DohBmeg8.js → useRuntimeRuns-B1a6GChu.js} +1 -1
- package/client/dist/assets/{useSharedWebSocket-CNOvmgTr.js → useSharedWebSocket-CcsE5986.js} +2 -2
- package/client/dist/index.html +16 -16
- package/docs/internals/core-runtime-updates.md +3 -3
- package/docs/internals/desktop-owned-workflows.md +10 -0
- package/docs/internals/programmatic-agent-runtime.md +16 -0
- package/docs/internals/source-map.md +4 -1
- package/package.json +1 -1
- package/server/dist/mcp/tools/loops.js +1 -1
- package/server/dist/modules/agent-runtime/runtime/agent-runtime-bridge.js +13 -3
- package/server/dist/modules/delivery/runtime/rail-isolated-launch.js +1 -1
- package/server/dist/modules/loops/runtime/loop-implement-recipe.js +13 -6
- package/server/dist/modules/loops/runtime/loop-turn-limits.js +64 -0
- package/server/dist/modules/loops/runtime/loops-router.js +3 -1
- package/server/dist/modules/missions/runtime/agent-operator-prompt.js +8 -0
- package/server/dist/schemas/agent-runtime.schema.json +1 -1
- package/client/dist/assets/LoopBuilderPage-5M7IypEP.js +0 -1
- package/client/dist/assets/index-D1v33giW.css +0 -2
|
@@ -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-BbYvbtY8.js";import{t as s}from"./react-dom-DDD8FYaU.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,n as m,o as h,r as g,s as _,t as v,u as y}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as b,r as x,t as S}from"./tauri-shell-DE6LfGPw.js";import{C,O as w,S as T,T as E,_ as D,a as O,b as k,d as A,f as j,g as M,h as N,i as P,l as F,m as I,n as ee,o as te,p as L,r as R,s as z,t as B,u as ne,v as V,w as re,x as ie,y as ae}from"./useSharedWebSocket-CNOvmgTr.js";import{t as H}from"./Trans-CVSryAL1.js";import{n as U,t as W}from"./createLucideIcon-DtODIU64.js";import{a as G,n as oe,o as se,r as ce,s as K,t as le}from"./useDesktop-C5JVBeur.js";import{$ as ue,A as de,B as fe,C as pe,D as q,E as me,F as he,G as ge,H as _e,I as J,K as ve,L as ye,M as be,N as xe,O as Se,P as Ce,Q as we,R as Te,S as Ee,T as De,U as Oe,V as ke,W as Ae,X as je,Z as Me,_ as Ne,a as Pe,at as Fe,b as Ie,c as Le,ct as Re,dt as ze,et as Be,ft as Ve,g as He,h as Ue,ht as We,i as Ge,it as Ke,j as qe,k as Je,l as Ye,lt as Xe,mt as Ze,n as Qe,nt as $e,o as et,ot as tt,p as nt,pt as rt,r as it,rt as at,s as ot,st,t as ct,tt as lt,v as ut,w as dt,x as ft,y as pt,z as mt}from"./TicketDetailModalContext-BoafEcm4.js";import{a as Y,n as ht,r as gt,t as _t}from"./core-B3mKBIh5.js";import{C as vt,D as yt,E as bt,O as xt,S as St,T as Ct,_ as wt,a as Tt,b as Et,c as Dt,d as Ot,f as kt,g as At,h as jt,i as Mt,k as Nt,l as Pt,m as Ft,n as It,o as Lt,p as Rt,r as zt,s as Bt,t as Vt,u as Ht,v as Ut,w as Wt,x as Gt,y as Kt}from"./RepositoryDeliveries-DgzNnJmn.js";import{_ as qt,a as Jt,d as Yt,f as Xt,g as Zt,h as Qt,i as $t,l as en,m as tn,n as nn,o as rn,p as an,r as on,s as sn,t as cn,u as ln}from"./provider-capabilities-lePfeT_Y.js";import{n as un,t as dn}from"./save-LmPSfsvZ.js";import{a as fn,c as pn,i as mn,n as hn,o as gn,r as _n,s as vn,t as yn}from"./MinimizedChatsContext-eH_KaAZ1.js";import{t as bn}from"./ban-wqfdzoXt.js";import{n as xn,t as Sn}from"./chevron-up-6EFqEHBj.js";import{n as Cn,t as wn}from"./file-text-C0blZHLh.js";import{t as Tn}from"./circle-x-D2ttKotB.js";import{t as En}from"./download-C9wP_42h.js";import{t as Dn}from"./external-link-CZ6Q-v1-.js";import{t as On}from"./git-branch-yf6LE1Bw.js";import{t as kn}from"./layers-BCLTgHXO.js";import{t as An}from"./loader-circle-BqV9xYGf.js";import{t as jn}from"./pencil-CxrRbDwb.js";import{n as Mn,t as Nn}from"./square-D0JTbRSR.js";import{t as Pn}from"./plus-fHDdjBk1.js";import{t as Fn}from"./rotate-ccw-DalJAQQX.js";import{t as In}from"./search-BDVp3fkH.js";import{t as Ln}from"./sparkles-CCfUdFGY.js";import{t as Rn}from"./trash-D8zYUmTg.js";import{t as zn}from"./triangle-alert-Cxpn8bqr.js";import{n as Bn}from"./jira-api-Bl8xEIpk.js";import{t as Vn}from"./x-Bu7X_eR2.js";import{t as Hn}from"./zap-bugHyWzQ.js";import{A as Un,C as Wn,D as Gn,E as Kn,F as qn,M as Jn,N as Yn,O as Xn,P as Zn,S as Qn,T as $n,_ as er,a as tr,b as nr,c as rr,d as ir,f as ar,g as or,h as sr,i as cr,j as lr,k as ur,l as dr,m as fr,n as pr,o as mr,p as hr,r as gr,s as _r,t as vr,v as yr,w as br,x as xr,y as Sr}from"./dialog-DtdR05v1.js";import{t as X}from"./utils-BC4DHlz2.js";import{n as Cr,t as wr}from"./lib-DWJfei6y.js";import{t as Tr}from"./getTimezoneOffsetInMilliseconds-ZHg7WpdH.js";import{t as Er}from"./formatDistanceToNow-NVM6rK3i.js";import{n as Dr,t as Z}from"./button-4FS1ZDTp.js";import{n as Or,t as kr}from"./project-repositories-CvJf1a6H.js";import{t as Ar}from"./RepositoryScopeSelector-BSgUqk_u.js";import{n as jr,t as Mr}from"./useRuntimeRuns-DohBmeg8.js";import{a as Nr,n as Pr,o as Fr,r as Ir,t as Lr}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 Rr=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}}}})),zr=i(((e,t)=>{t.exports=Rr()})),Br=i((e=>{var t=zr(),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){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e: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}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function h(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function g(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),!(e.tag===3||e.tag===5||e.tag===27));)e=e.return;return t}function _(e){var t=[null,null],n=h(e);return n===null||v(t,e,n.child,{foundSelf:!1}),t}function v(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&v(e,t,n.child,r))return!0;n=n.sibling}return!1}function y(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var b=null,x=null;function S(e,t,n){return e===n?!0:e===t?(b=e,!0):!1}function C(e,t,n){return e===n?(x=e,!1):e===t?(x!==null&&(b=e),!0):!1}function w(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function T(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var E=Object.assign,D=Symbol.for(`react.element`),O=Symbol.for(`react.transitional.element`),k=Symbol.for(`react.portal`),A=Symbol.for(`react.fragment`),j=Symbol.for(`react.strict_mode`),M=Symbol.for(`react.profiler`),N=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),F=Symbol.for(`react.forward_ref`),I=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),L=Symbol.for(`react.lazy`),R=Symbol.for(`react.activity`),z=Symbol.for(`react.legacy_hidden`),B=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.for(`react.view_transition`),V=Symbol.for(`react.recoverable`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function H(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case A:return`Fragment`;case M:return`Profiler`;case j:return`StrictMode`;case I:return`Suspense`;case ee:return`SuspenseList`;case R:return`Activity`;case ne:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case k:return`Portal`;case P:return e.displayName||`Context`;case N:return(e._context.displayName||`Context`)+`.Consumer`;case F:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case te:return t=e.displayName||null,t===null?H(e.type)||`Memo`:t;case L:t=e._payload,e=e._init;try{return H(e(t))}catch{}}return null}var U=Array.isArray,W=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},se=[],ce=-1;function K(e){return{current:e}}function le(e){0>ce||(e.current=se[ce],se[ce]=null,ce--)}function ue(e,t){ce++,se[ce]=e.current,e.current=t}var de=K(null),fe=K(null),pe=K(null),q=K(null);function me(e,t){switch(ue(pe,t),ue(fe,e),ue(de,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}le(de),ue(de,e)}function he(){le(de),le(fe),le(pe)}function ge(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,ue(q,e)),t=de.current;var n=dp(t,e.type);t!==n&&(ue(fe,e),ue(de,n))}function _e(e){fe.current===e&&(le(de),le(fe)),q.current===e&&(le(q),sh._currentValue=oe)}var J,ve;function ye(e){if(J===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);J=t&&t[1]||``,ve=-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-CkAejD1F.js","assets/jsx-runtime-BbYvbtY8.js","assets/react-dom-DDD8FYaU.js","assets/useSharedWebSocket-CcsE5986.js","assets/preload-helper-Czpn1I53.js","assets/activity-DiyjsgQV.js","assets/addspec-BOvgmcgk.js","assets/agent-Dip4h2YE.js","assets/agentRuntime-BxYS5V7u.js","assets/agents-Doe1sHY5.js","assets/agentstudio-BzugqB_N.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-BWynXPEm.js","assets/attachments-B53PG733.js","assets/browser-CG0PE1j_.js","assets/builder-CpS9liE9.js","assets/chat-BGD7MXAy.js","assets/code-DaZ-ZwCT.js","assets/commands-BAWSYHjQ.js","assets/common-Bdi0qN4S.js","assets/dashboard-XGdQ5mjw.js","assets/explore-DgBACn39.js","assets/integrations-Dwl9KQp0.js","assets/jira-FXr7u2lh.js","assets/jobs-De3EqaO0.js","assets/loops-WyWDkhok.js","assets/mcp-CUAN6ORK.js","assets/narration-DbHnz0qV.js","assets/nav--u7iPYlS.js","assets/packet-B0H15elv.js","assets/settings-nryN6wuS.js","assets/setup-CKGUxKr-.js","assets/specs-DfIdoU5L.js","assets/subscriptionUsage-CdlE5Mg1.js","assets/terminal-BAzpHtpY.js","assets/tickets-D41ZMQpf.js","assets/createLucideIcon-DtODIU64.js","assets/useDesktop-C0mRIlHT.js","assets/TicketDetailModalContext-DiPngt2g.js","assets/chunk-OB3PAWPO-B1EMk45A.js","assets/tauri-shell-DE6LfGPw.js","assets/Trans-ZiXIfj50.js","assets/provider-capabilities-lePfeT_Y.js","assets/save-LmPSfsvZ.js","assets/spending-eWiZGhC_.js","assets/MinimizedChatsContext-BHIUPVmC.js","assets/chevron-up-6EFqEHBj.js","assets/sparkles-CCfUdFGY.js","assets/x-Bu7X_eR2.js","assets/ban-wqfdzoXt.js","assets/file-text-C0blZHLh.js","assets/circle-x-D2ttKotB.js","assets/download-C9wP_42h.js","assets/external-link-CZ6Q-v1-.js","assets/git-branch-yf6LE1Bw.js","assets/layers-BCLTgHXO.js","assets/loader-circle-BqV9xYGf.js","assets/pencil-CxrRbDwb.js","assets/square-D0JTbRSR.js","assets/plus-fHDdjBk1.js","assets/rotate-ccw-DalJAQQX.js","assets/search-BDVp3fkH.js","assets/trash-D8zYUmTg.js","assets/triangle-alert-Cxpn8bqr.js","assets/jira-api-C_D_RDhl.js","assets/zap-bugHyWzQ.js","assets/dialog-DtdR05v1.js","assets/utils-BC4DHlz2.js","assets/clsx-CjueKrWZ.js","assets/lib-DWJfei6y.js","assets/formatDistanceToNow-CdN5lTyD.js","assets/getTimezoneOffsetInMilliseconds-62h40I4t.js","assets/button-4FS1ZDTp.js","assets/RepositoryScopeSelector-DeCoUsRN.js","assets/project-repositories-Be0CWklo.js","assets/InteractiveJobComposer-BlCe3vrU.js","assets/useRuntimeRuns-B1a6GChu.js","assets/loop-layout-CyXj9223.js","assets/value-DtOOK0wQ.js","assets/loop-layout-DtxX27Jz.css","assets/lib-CQJT8S6Q.js","assets/job-time-BCL7wee9.js","assets/LoopPreviewModal-4obS_Ptg.js","assets/TemplatePreviewModal-BZTV1TM1.js","assets/AgentBrowserCapture-BussBbN3.js","assets/AgentModeCodePane-CUjNfeKa.js","assets/AgentModeJobsPane-RVEwyS59.js","assets/format-command-C0D9IPmV.js","assets/AgentModeAnalyticsPane-BiT1n3BU.js","assets/dist-js-CJ_2XX1Y.js","assets/ProjectSettingsDialog-B4chTfU8.js","assets/JobDetailPage-P-FS_lKz.js","assets/ReviewPacketPage-Cktv0-9b.js","assets/RepositoryDeliveries-DAIxIYsl.js","assets/JobsPage-CoUXgYse.js","assets/ExportDropdown-mRmqdkjr.js","assets/AnalyticsPage-Bser2Ly3.js","assets/BarChart-BDMqVFJy.js","assets/ActivityFeedPage-B1bpTy7O.js","assets/AgentsPage-DKE-eMC5.js","assets/CodePage-BK0grm6e.js","assets/IntegrationsPage-EAipiDWm.js","assets/PluginsPage-BgTC2CQx.js","assets/DesktopAnalyticsPage-DEBidZbs.js","assets/DocsPage-BcEkPXd6.js","assets/atom-one-dark-qiGhVQxg.js","assets/atom-one-dark-B-oHczHB.css","assets/DocsDialog-Dhyo57n9.js","assets/LoopWindowSurface-CLr5OPqj.js","assets/LoopsPage-eKpWFtCp.js","assets/upload-CCHvUkRs.js","assets/LoopBuilderPage-iFylNk68.js"])))=>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-BbYvbtY8.js";import{t as s}from"./react-dom-DDD8FYaU.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,n as m,o as h,r as g,s as _,t as v,u as y}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as b,r as x,t as S}from"./tauri-shell-DE6LfGPw.js";import{C,O as w,S as T,T as E,_ as D,a as O,b as k,d as A,f as j,g as M,h as N,i as P,l as F,m as I,n as ee,o as te,p as L,r as R,s as z,t as B,u as ne,v as V,w as re,x as ie,y as ae}from"./useSharedWebSocket-CcsE5986.js";import{t as H}from"./Trans-ZiXIfj50.js";import{n as U,t as W}from"./createLucideIcon-DtODIU64.js";import{a as G,n as oe,o as se,r as ce,s as K,t as le}from"./useDesktop-C0mRIlHT.js";import{$ as ue,A as de,B as fe,C as pe,D as q,E as me,F as he,G as ge,H as _e,I as J,K as ve,L as ye,M as be,N as xe,O as Se,P as Ce,Q as we,R as Te,S as Ee,T as De,U as Oe,V as ke,W as Ae,X as je,Z as Me,_ as Ne,a as Pe,at as Fe,b as Ie,c as Le,ct as Re,dt as ze,et as Be,ft as Ve,g as He,h as Ue,ht as We,i as Ge,it as Ke,j as qe,k as Je,l as Ye,lt as Xe,mt as Ze,n as Qe,nt as $e,o as et,ot as tt,p as nt,pt as rt,r as it,rt as at,s as ot,st,t as ct,tt as lt,v as ut,w as dt,x as ft,y as pt,z as mt}from"./TicketDetailModalContext-DiPngt2g.js";import{a as Y,n as ht,r as gt,t as _t}from"./core-B3mKBIh5.js";import{C as vt,D as yt,E as bt,O as xt,S as St,T as Ct,_ as wt,a as Tt,b as Et,c as Dt,d as Ot,f as kt,g as At,h as jt,i as Mt,k as Nt,l as Pt,m as Ft,n as It,o as Lt,p as Rt,r as zt,s as Bt,t as Vt,u as Ht,v as Ut,w as Wt,x as Gt,y as Kt}from"./RepositoryDeliveries-DAIxIYsl.js";import{_ as qt,a as Jt,d as Yt,f as Xt,g as Zt,h as Qt,i as $t,l as en,m as tn,n as nn,o as rn,p as an,r as on,s as sn,t as cn,u as ln}from"./provider-capabilities-lePfeT_Y.js";import{n as un,t as dn}from"./save-LmPSfsvZ.js";import{a as fn,c as pn,i as mn,n as hn,o as gn,r as _n,s as vn,t as yn}from"./MinimizedChatsContext-BHIUPVmC.js";import{t as bn}from"./ban-wqfdzoXt.js";import{n as xn,t as Sn}from"./chevron-up-6EFqEHBj.js";import{n as Cn,t as wn}from"./file-text-C0blZHLh.js";import{t as Tn}from"./circle-x-D2ttKotB.js";import{t as En}from"./download-C9wP_42h.js";import{t as Dn}from"./external-link-CZ6Q-v1-.js";import{t as On}from"./git-branch-yf6LE1Bw.js";import{t as kn}from"./layers-BCLTgHXO.js";import{t as An}from"./loader-circle-BqV9xYGf.js";import{t as jn}from"./pencil-CxrRbDwb.js";import{n as Mn,t as Nn}from"./square-D0JTbRSR.js";import{t as Pn}from"./plus-fHDdjBk1.js";import{t as Fn}from"./rotate-ccw-DalJAQQX.js";import{t as In}from"./search-BDVp3fkH.js";import{t as Ln}from"./sparkles-CCfUdFGY.js";import{t as Rn}from"./trash-D8zYUmTg.js";import{t as zn}from"./triangle-alert-Cxpn8bqr.js";import{n as Bn}from"./jira-api-C_D_RDhl.js";import{t as Vn}from"./x-Bu7X_eR2.js";import{t as Hn}from"./zap-bugHyWzQ.js";import{A as Un,C as Wn,D as Gn,E as Kn,F as qn,M as Jn,N as Yn,O as Xn,P as Zn,S as Qn,T as $n,_ as er,a as tr,b as nr,c as rr,d as ir,f as ar,g as or,h as sr,i as cr,j as lr,k as ur,l as dr,m as fr,n as pr,o as mr,p as hr,r as gr,s as _r,t as vr,v as yr,w as br,x as xr,y as Sr}from"./dialog-DtdR05v1.js";import{t as X}from"./utils-BC4DHlz2.js";import{n as Cr,t as wr}from"./lib-DWJfei6y.js";import{t as Tr}from"./getTimezoneOffsetInMilliseconds-62h40I4t.js";import{t as Er}from"./formatDistanceToNow-CdN5lTyD.js";import{n as Dr,t as Z}from"./button-4FS1ZDTp.js";import{n as Or,t as kr}from"./project-repositories-Be0CWklo.js";import{t as Ar}from"./RepositoryScopeSelector-DeCoUsRN.js";import{n as jr,t as Mr}from"./useRuntimeRuns-B1a6GChu.js";import{a as Nr,n as Pr,o as Fr,r as Ir,t as Lr}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 Rr=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}}}})),zr=i(((e,t)=>{t.exports=Rr()})),Br=i((e=>{var t=zr(),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){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e: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}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function h(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function g(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),!(e.tag===3||e.tag===5||e.tag===27));)e=e.return;return t}function _(e){var t=[null,null],n=h(e);return n===null||v(t,e,n.child,{foundSelf:!1}),t}function v(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&v(e,t,n.child,r))return!0;n=n.sibling}return!1}function y(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var b=null,x=null;function S(e,t,n){return e===n?!0:e===t?(b=e,!0):!1}function C(e,t,n){return e===n?(x=e,!1):e===t?(x!==null&&(b=e),!0):!1}function w(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function T(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var E=Object.assign,D=Symbol.for(`react.element`),O=Symbol.for(`react.transitional.element`),k=Symbol.for(`react.portal`),A=Symbol.for(`react.fragment`),j=Symbol.for(`react.strict_mode`),M=Symbol.for(`react.profiler`),N=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),F=Symbol.for(`react.forward_ref`),I=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),L=Symbol.for(`react.lazy`),R=Symbol.for(`react.activity`),z=Symbol.for(`react.legacy_hidden`),B=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.for(`react.view_transition`),V=Symbol.for(`react.recoverable`),re=Symbol.iterator;function ie(e){return typeof e!=`object`||!e?null:(e=re&&e[re]||e[`@@iterator`],typeof e==`function`?e:null)}var ae=Symbol.for(`react.client.reference`);function H(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case A:return`Fragment`;case M:return`Profiler`;case j:return`StrictMode`;case I:return`Suspense`;case ee:return`SuspenseList`;case R:return`Activity`;case ne:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case k:return`Portal`;case P:return e.displayName||`Context`;case N:return(e._context.displayName||`Context`)+`.Consumer`;case F:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case te:return t=e.displayName||null,t===null?H(e.type)||`Memo`:t;case L:t=e._payload,e=e._init;try{return H(e(t))}catch{}}return null}var U=Array.isArray,W=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},se=[],ce=-1;function K(e){return{current:e}}function le(e){0>ce||(e.current=se[ce],se[ce]=null,ce--)}function ue(e,t){ce++,se[ce]=e.current,e.current=t}var de=K(null),fe=K(null),pe=K(null),q=K(null);function me(e,t){switch(ue(pe,t),ue(fe,e),ue(de,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}le(de),ue(de,e)}function he(){le(de),le(fe),le(pe)}function ge(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,ue(q,e)),t=de.current;var n=dp(t,e.type);t!==n&&(ue(fe,e),ue(de,n))}function _e(e){fe.current===e&&(le(de),le(fe)),q.current===e&&(le(q),sh._currentValue=oe)}var J,ve;function ye(e){if(J===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);J=t&&t[1]||``,ve=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+J+e+ve}var be=!1;function xe(e,t){if(!e||be)return``;be=!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}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}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(`
|
|
@@ -30,7 +30,7 @@ Error generating stack: `+e.message+`
|
|
|
30
30
|
`).trim()}function uw(e,t=!1){if(!e.includes(aw))return{body:e,draft:null,pending:!1};let n=null,r=``,i=0;iw.lastIndex=0;let a;for(;(a=iw.exec(e))!==null;){r+=e.slice(i,a.index),i=a.index+a[0].length;let t=cw(a[1]);t&&(n=t)}r+=e.slice(i);let o=!1,s=r.indexOf(aw);if(s!==-1){let e=cw(r.slice(s+13).replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``));e?(n=e,r=r.slice(0,s)):t&&(r=r.slice(0,s),o=!0)}return{body:lw(r),draft:n,pending:o}}var dw={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`},fw=X(`text-xs leading-6 text-foreground/85`,`[&_p]:my-2 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0`,`[&_h2]:mt-3 [&_h2]:mb-1 [&_h2]:text-[11px] [&_h2]:font-semibold [&_h2]:uppercase [&_h2]:tracking-wider [&_h2]:text-foreground/60 [&_h2:first-child]:mt-0`,`[&_h3]:mt-2 [&_h3]:mb-1 [&_h3]:text-xs [&_h3]:font-semibold`,`[&_ul]:my-1.5 [&_ul]:list-disc [&_ul]:pl-4 [&_ol]:my-1.5 [&_ol]:list-decimal [&_ol]:pl-4 [&_li]:my-0.5`,`[&_code]:rounded [&_code]:bg-surface [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-accent-info`,`[&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-surface [&_pre]:p-2`,`[&_strong]:font-semibold`);function pw({draft:e}){let{t}=U(`agent`),[n,r]=(0,Q.useState)(!1),i=e.description.trim().length>0,a=e.acceptanceCriteria;return(0,$.jsxs)(`div`,{"data-testid":`agent-spec-draft-card`,className:`my-1 overflow-hidden rounded-xl border border-accent-primary/25 bg-card/80 shadow-lg backdrop-blur`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/40 bg-accent-primary/[0.06] px-3.5 py-2`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest text-accent-primary/90`,children:[(0,$.jsx)(Ln,{className:`h-3 w-3`}),t(`specDraft.heading`)]}),(0,$.jsx)(`span`,{className:X(`rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,dw[e.priority]),children:t(`explore:priority.${e.priority}`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-3.5 py-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold leading-snug text-foreground`,children:e.title.trim()||t(`specDraft.untitled`)}),e.labels.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.labels.map((e,t)=>(0,$.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/70 px-2 py-0.5 text-[10px] text-foreground/70`,children:e},`${t}-${e}`))}),i&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:X(`relative`,!n&&`max-h-28 overflow-hidden`),children:[(0,$.jsx)(`div`,{className:fw,children:(0,$.jsx)(Cr,{remarkPlugins:[wr],children:e.description})}),!n&&(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-card to-transparent`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"data-agent-interactive":!0,className:`mt-1 flex items-center gap-1 text-[11px] text-accent-info transition-colors hover:text-foreground`,children:[n?(0,$.jsx)(Sn,{className:`h-3 w-3`}):(0,$.jsx)(rc,{className:`h-3 w-3`}),t(n?`specDraft.collapse`:`specDraft.expand`)]})]}),a.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wider text-foreground/50`,children:[t(`specDraft.acceptanceCriteria`),` · `,a.length]}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:a.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-xs leading-5 text-foreground/85`,children:[(0,$.jsx)(sc,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-success/80`}),(0,$.jsx)(`span`,{children:e})]},`${t}-${e}`))})]})]})]})}function mw(){let{t:e}=U(`agent`);return(0,$.jsxs)(`span`,{"data-testid":`agent-spec-draft-pending`,className:`inline-flex w-fit items-center gap-1.5 rounded-full border border-accent-primary/25 bg-accent-primary/10 px-2.5 py-1 text-[11px] text-accent-primary/90`,children:[(0,$.jsx)(Ln,{className:`h-3 w-3 animate-pulse`}),e(`specDraft.drafting`)]})}var hw=`pr-review-fix`,gw=4e3,_w=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`FollowUpValidationError`}};function vw(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yw(e,t,n,r){if(e==null)return null;if(typeof e!=`string`)throw new _w(n,`${r} must be a string`);let i=e.trim();if(!i)return null;if(i.length>t)throw new _w(n,`${r} exceeds ${t} characters`);return i}function bw(e,t){if(e==null)return[];if(!Array.isArray(e))throw new _w(`list_too_long`,`${t} must be an array of strings`);if(e.length>20)throw new _w(`list_too_long`,`${t} has more than 20 items`);let n=[];for(let r of e){let e=yw(r,400,`item_too_long`,`${t} item`);e&&n.push(e)}return n}var xw=/^[^\0\r\n]{1,512}$/,Sw=/^[a-z0-9][a-z0-9-]{0,79}$/;function Cw(e){if(!vw(e))throw new _w(`not_object`,`followUp must be an object`);if((e.version===void 0?1:e.version)!==1)throw new _w(`unsupported_version`,`followUp.version must be 1`);if((e.kind===void 0?`pr-review-fix`:e.kind)!==`pr-review-fix`)throw new _w(`unsupported_kind`,`followUp.kind must be "${hw}"`);if(!Array.isArray(e.comments)||e.comments.length===0)throw new _w(`comments_required`,`followUp.comments must list at least one review comment`);if(e.comments.length>20)throw new _w(`too_many_comments`,`followUp.comments has more than 20 entries`);let t=new Set,n=e.comments.map((e,n)=>{if(!vw(e))throw new _w(`invalid_comment`,`followUp.comments[${n}] must be an object`);let r=yw(e.body??e.text,gw,`comment_too_long`,`followUp.comments[${n}].body`);if(!r)throw new _w(`comment_body_required`,`followUp.comments[${n}].body is required`);let i=yw(e.id,80,`invalid_comment`,`followUp.comments[${n}].id`)??`c${n+1}`;if(!/^[A-Za-z0-9_.:-]{1,80}$/.test(i))throw new _w(`invalid_comment`,`followUp.comments[${n}].id has unsupported characters`);for(;t.has(i);)i=`${i}-${n+1}`;t.add(i);let a=e.source===`github`?`github`:`user-paste`,o=yw(e.path,512,`invalid_comment`,`followUp.comments[${n}].path`);if(o&&!xw.test(o))throw new _w(`invalid_comment`,`followUp.comments[${n}].path is not a path`);let s=e.line,c=s==null?null:typeof s==`number`&&Number.isSafeInteger(s)&&s>0?s:(()=>{throw new _w(`invalid_comment`,`followUp.comments[${n}].line must be a positive integer`)})();return{id:i,source:a,author:yw(e.author,120,`invalid_comment`,`followUp.comments[${n}].author`),path:o,line:c,body:r}}),r=vw(e.scope)?e.scope:e,i={objective:yw(r.objective,800,`objective_too_long`,`followUp.scope.objective`)??`Resolve only the selected review comments on this pull request.`,requiredOutcomes:bw(r.requiredOutcomes,`followUp.scope.requiredOutcomes`),excludedChanges:bw(r.excludedChanges,`followUp.scope.excludedChanges`),verification:bw(r.verification,`followUp.scope.verification`)},a=yw(e.openspecChangeName,80,`invalid_openspec_change_name`,`followUp.openspecChangeName`);if(a&&!Sw.test(a))throw new _w(`invalid_openspec_change_name`,`followUp.openspecChangeName must be a kebab-case OpenSpec change name`);return{version:1,kind:hw,comments:n,scope:i,openspecChangeName:a}}var ww=[`implement`,`freestyle`,`loop`],Tw=/```rail-launch[^\S\n]*\n([\s\S]*?)\n[^\S\n]*```/g,Ew="```rail-launch",Dw=160;function Ow(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function kw(e,t=200){if(typeof e!=`string`)return null;let n=e.trim();return n?n.slice(0,t):null}function Aw(e,t=0){if(typeof e==`number`&&Number.isInteger(e)&&e>=t)return e;if(typeof e==`string`&&/^\d+$/.test(e.trim())){let n=Number(e.trim());return n>=t?n:null}return null}function jw(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=typeof n==`number`?n:typeof n==`string`?Number(n.trim().replace(/^#/,``)):NaN;Number.isInteger(e)&&e>0&&!t.includes(e)&&t.push(e)}return t}function Mw(e){let t=e.replace(/\s+/g,` `).trim();return t.length>Dw?`${t.slice(0,Dw-1)}…`:t}function Nw(e){if(!Ow(e))return{ok:!1,reason:`not_object`};let t=Aw(e.version,1)??Aw(e.blueprintVersion,1);if(t!==null&&t!==1)return{ok:!1,reason:`unsupported_version`};let n=jw(e.ticketIds??e.specs??e.tickets);if(n.length===0)return{ok:!1,reason:`no_tickets`};let r=kw(e.mode)?.toLowerCase().replace(/_/g,`-`)??`implement`,i=r===`batch`||r===`batch-implement`?`implement`:r;if(!ww.includes(i))return{ok:!1,reason:`invalid_mode`};let a=e.repositoryIds,o=e.workspaceSelection;if(a!==void 0&&(!Array.isArray(a)||!a.length||a.length>50||a.some(e=>typeof e!=`string`||!e.trim())||new Set(a).size!==a.length)||o!==void 0&&(!Ow(o)||!Object.keys(o).length||Object.keys(o).length>50||Object.entries(o).some(([e,t])=>!e.trim()||!Array.isArray(t)||!t.length||t.length>50||t.some(e=>typeof e!=`string`||!e.trim()||e.length>4096)||new Set(t).size!==t.length)))return{ok:!1,reason:`invalid_workspace_selection`};let s=e.newRail,c=s===!0?{name:null}:Ow(s)?{name:kw(s.name,80)}:null;return{ok:!0,proposal:{version:1,railIndex:c?null:Aw(e.railIndex,0),newRail:c,ticketIds:n,...a===void 0?{}:{repositoryIds:a},...o===void 0?{}:{workspaceSelection:o},mode:i,loopId:kw(e.loopId,120),aiEngine:kw(e.aiEngine??e.provider??e.engine,80),model:kw(e.model,120),reasoningEffort:kw(e.reasoningEffort??e.reasoning_effort??e.effort,20),profileName:kw(e.profileName??e.profile,80),targetPrNumber:Aw(e.targetPrNumber,1),baseBranch:kw(e.baseBranch,200),railName:kw(e.railName??e.name,80),rationale:kw(e.rationale??e.reason??e.why,400),followUp:Pw(e.followUp)}}}function Pw(e){if(e==null)return null;try{return Cw(e)}catch{return null}}function Fw(e){return e.replace(/\n{3,}/g,`
|
|
31
31
|
|
|
32
32
|
`).trim()}function Iw(e,t=!1){let n={body:e??``,proposals:[],rejected:[],pending:!1,truncated:!1,repaired:!1};if(!e||!e.includes(Ew))return n;let r=[],i=[],a=!1,o=``,s=0;Tw.lastIndex=0;let c,l=e=>{let t=St(e);if(!t.ok){i.push({reason:`invalid_json`,excerpt:Mw(e)});return}t.repaired&&(a=!0);let n=Nw(t.value);n.ok?r.push(n.proposal):i.push({reason:n.reason,excerpt:Mw(e)})};for(;(c=Tw.exec(e))!==null;)o+=e.slice(s,c.index),s=c.index+c[0].length,l(c[1]);o+=e.slice(s);let u=!1,d=!1,f=o.indexOf(Ew);if(f!==-1){let e=o.slice(f+14).replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``),n=e.trim()?St(e):null;if(n&&n.ok){n.repaired&&(a=!0);let t=Nw(n.value);t.ok?r.push(t.proposal):i.push({reason:t.reason,excerpt:Mw(e)}),o=o.slice(0,f)}else t?(o=o.slice(0,f),u=!0):(o=o.slice(0,f),d=!0,i.push({reason:`invalid_json`,excerpt:Mw(e)}))}return{body:Fw(o),proposals:r,rejected:i,pending:u,truncated:d,repaired:a}}var Lw=new Map,Rw=new Set;function zw(e,t){let n=new Map(Lw),r=n.get(e)??[];n.set(e,[...r.filter(e=>e.proposalIndex!==t.proposalIndex),t]),Lw=n;for(let e of Rw)e()}function Bw(e){return Rw.add(e),()=>{Rw.delete(e)}}function Vw(){return(0,Q.useSyncExternalStore)(Bw,()=>Lw,()=>Lw)}function Hw(e,t,n,r){return e.get(t)?.find(e=>e.proposalIndex===r)??n?.find(e=>e.proposalIndex===r)??null}var Uw={claude:[{value:`sonnet`,label:`Sonnet 5.5`},{value:`fable`,label:`Fable 5.1`},{value:`opus`,label:`Claude Opus 5.5`},{value:`haiku`,label:`Claude Haiku 5.5`}],codex:[{value:`gpt-6.1-sol`,label:`GPT-6.1 Sol`},{value:`gpt-6-astra`,label:`GPT-6 Astra`},{value:`gpt-5.6-sol`,label:`GPT-5.6 Sol`},{value:`gpt-5.6-terra`,label:`GPT-5.6 Terra`},{value:`gpt-5.6-luna`,label:`GPT-5.6 Luna`}],gemini:[{value:`gemini-3.5-flash`,label:`Gemini 3.5 Flash`},{value:`gemini-3.1-pro-preview`,label:`Gemini 3.1 Pro (preview)`},{value:`gemini-3.1-flash-lite`,label:`Gemini 3.1 Flash Lite`},{value:`gemini-2.5-flash-lite`,label:`Gemini 2.5 Flash Lite`}],kimi:[{value:`k3`,label:`Kimi K3`},{value:`kimi-for-coding`,label:`Kimi for Coding`},{value:`kimi-for-coding-highspeed`,label:`Kimi for Coding Highspeed`}]},Ww=new Map;function Gw(e,t){if(!e)return;let n=Array.from(new Set(t.filter(e=>typeof e==`string`&&e.trim())));if(n.length===0){Ww.delete(e);return}Ww.set(e,n.map(e=>({value:e,label:e})))}function Kw(e){return e?Uw[e]??Ww.get(e)??[]:[]}function qw(e){return Kw(e)[0]?.value??``}function Jw(e){for(let[t,n]of Object.entries(e))n?.kind===`local`&&Array.isArray(n.models)&&Gw(t,n.models)}function Yw(){let[e,t]=(0,Q.useState)({detected:[],providers:{},loading:!0}),n=(0,Q.useContext)(B);return(0,Q.useEffect)(()=>{let e=!0;return fetch(`${F}/api/providers/detected`).then(e=>e.ok?e.json():null).then(n=>{!e||!n||(Jw(n.providers??{}),t({detected:Array.isArray(n.detected)?n.detected.filter(on):[],providers:Object.fromEntries(Object.entries(n.providers??{}).filter(([e])=>on(e))),loading:!1}))}).catch(()=>{e&&t(e=>({...e,loading:!1}))}),()=>{e=!1}},[]),(0,Q.useEffect)(()=>{let e=e=>{let n=e;n.type===`providers.detected_changed`&&(Jw(n.providers??{}),window.dispatchEvent(new Event(`specrails:providers-detected-changed`)),t({detected:Array.isArray(n.detected)?n.detected.filter(on):[],providers:Object.fromEntries(Object.entries(n.providers??{}).filter(([e])=>on(e))),loading:!1}))};if(n)return n.registerHandler(`provider-detection`,e),()=>n.unregisterHandler(`provider-detection`)},[n]),e}var Xw={implement:`factory:implement`,freestyle:`factory:freestyle`},Zw=[{id:`factory:implement`,labelKey:`railControls.implement`},{id:`factory:freestyle`,labelKey:`railControls.freestyle`,requiresFreestyle:!0},{id:`factory:sdd-quick-openspec`,labelKey:`railControls.openspec`,requiresLoops:!0}];function Qw(e){return e===`loop`?``:Xw[e]}function $w(e){return e===`factory:implement`||e===`factory:batch`?`implement`:e===`factory:freestyle`?`freestyle`:`loop`}function eT(e,t,n=!1){return!e&&n||e===`factory:revision`?`factory:sdd-quick-openspec`:e===`factory:batch`?`factory:implement`:e||Qw(t)}function tT(e){return e&&!e.startsWith(`factory:`)?e:void 0}var nT=class extends Error{errors;constructor(e){super(`Loop graph is invalid`),this.name=`LoopPublishError`,this.errors=e}},rT=`/api`;async function iT(e){if(!e.ok){let t;try{t=await e.json()}catch{t=void 0}if((e.status===422||e.status===400)&&t&&typeof t==`object`&&`errors`in t)throw new nT(t.errors??[]);let n=t&&typeof t==`object`&&`error`in t?String(t.error):`Request failed (${e.status})`;throw Error(n)}return e.json()}async function aT(e,t,n){return iT(await fetch(`${rT}${t}`,{method:e,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}))}var oT={async migration(){return aT(`GET`,`/loops/migration`)},async catalog(){return aT(`GET`,`/loops/catalog`)},async list(){return(await aT(`GET`,`/loops`)).loops},async get(e){return(await aT(`GET`,`/loops/${e}`)).loop},async legacyGraph(e){return aT(`GET`,`/loops/${encodeURIComponent(e)}/legacy-graph`)},async convert(e,t){return aT(`POST`,`/loops/${encodeURIComponent(e)}/convert`,{...t?{repositoryId:t}:{}})},async create(e){return(await aT(`POST`,`/loops`,e)).loop},async update(e,t){return(await aT(`PUT`,`/loops/${e}`,t)).loop},async publish(e){return(await aT(`POST`,`/loops/${e}/publish`)).loop},async unpublish(e){return(await aT(`POST`,`/loops/${e}/unpublish`)).loop},async duplicate(e,t){return(await aT(`POST`,`/loops/${e}/duplicate`,t?{name:t}:{})).loop},async remove(e){let t=await fetch(`${rT}/loops/${e}`,{method:`DELETE`});!t.ok&&t.status!==204&&await iT(t)},async templates(){return(await aT(`GET`,`/loop-templates`)).templates},async fromTemplate(e,t){return(await aT(`POST`,`/loops/from-template/${e}`,t?{name:t}:{})).loop},async loopCommands(){return(await aT(`GET`,`/loops/commands`)).commands},async restoreBuiltin(e){return(await aT(`POST`,`/loops/${encodeURIComponent(e)}/restore-builtin`)).loop},async loopConstants(){return(await aT(`GET`,`/loops/constants`)).constants},async createConstant(e,t){return(await aT(`POST`,`/loops/constants`,{name:e,value:t})).constant},async updateConstant(e,t){return(await aT(`PUT`,`/loops/constants/${e}`,{value:t})).constant},async deleteConstant(e){await aT(`DELETE`,`/loops/constants/${e}`)},async importLoops(e){return aT(`POST`,`/loops/import`,{loops:e})},async previewLoop(e,t){return aT(`POST`,`/loops/preview`,{graph:e,provider:t})},async runStandalone(e,t,n={}){return iT(await fetch(`/api/projects/${e}/loop-runs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({loopId:t,...n})}))}},sT=/\{\{\s*spec\./,cT=/\{\{\s*cmd:(implement|batch|freestyle)\b/;function lT(e){if(!e)return!1;for(let t of e.nodes){if(t.type===`core`&&[`implementation`,`implementation-step`].includes(String(t.data?.kind)))return!0;let e=[t.data?.prompt,t.data?.command,t.data?.goal,t.type===`core`?JSON.stringify(t.data?.params??{}):``].filter(e=>typeof e==`string`).join(`
|
|
33
|
-
`);if(sT.test(e)||cT.test(e))return!0}return Object.values(e.components??{}).some(e=>lT(e))}function uT(e,[t,n]){return Math.min(n,Math.max(t,e))}function dT(e){let t=fT(e),n=Q.forwardRef((e,n)=>{let{children:r,...i}=e,a=Q.Children.toArray(r),o=a.find(mT);if(o){let e=o.props.children,r=a.map(t=>t===o?Q.Children.count(e)>1?Q.Children.only(null):Q.isValidElement(e)?e.props.children:null:t);return(0,$.jsx)(t,{...i,ref:n,children:Q.isValidElement(e)?Q.cloneElement(e,void 0,r):null})}return(0,$.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function fT(e){let t=Q.forwardRef((e,t)=>{let{children:n,...r}=e;if(Q.isValidElement(n)){let e=gT(n),i=hT(r,n.props);return n.type!==Q.Fragment&&(i.ref=t?Jn(t,e):e),Q.cloneElement(n,i)}return Q.Children.count(n)>1?Q.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pT=Symbol(`radix.slottable`);function mT(e){return Q.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===pT}function hT(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function gT(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function _T(e){let t=e+`CollectionProvider`,[n,r]=Un(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=Q.useRef(null),a=Q.useRef(new Map).current;return(0,$.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=dT(s),l=Q.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Yn(t,a(s,n).collectionRef);return(0,$.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=dT(u),p=Q.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=Q.useRef(null),s=Yn(t,o),c=a(u,n);return Q.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,$.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return Q.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var vT=Q.createContext(void 0);function yT(e){let t=Q.useContext(vT);return e||t||`ltr`}var bT=[`top`,`right`,`bottom`,`left`],xT=Math.min,ST=Math.max,CT=Math.round,wT=Math.floor,TT=e=>({x:e,y:e}),ET={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function DT(e,t,n){return ST(e,xT(t,n))}function OT(e,t){return typeof e==`function`?e(t):e}function kT(e){return e.split(`-`)[0]}function AT(e){return e.split(`-`)[1]}function jT(e){return e===`x`?`y`:`x`}function MT(e){return e===`y`?`height`:`width`}function NT(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function PT(e){return jT(NT(e))}function FT(e,t,n){n===void 0&&(n=!1);let r=AT(e),i=PT(e),a=MT(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=WT(o)),[o,WT(o)]}function IT(e){let t=WT(e);return[LT(e),t,LT(t)]}function LT(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var RT=[`left`,`right`],zT=[`right`,`left`],BT=[`top`,`bottom`],VT=[`bottom`,`top`];function HT(e,t,n){switch(e){case`top`:case`bottom`:return n?t?zT:RT:t?RT:zT;case`left`:case`right`:return t?BT:VT;default:return[]}}function UT(e,t,n,r){let i=AT(e),a=HT(kT(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(LT)))),a}function WT(e){let t=kT(e);return ET[t]+e.slice(t.length)}function GT(e){return{top:0,right:0,bottom:0,left:0,...e}}function KT(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:GT(e)}function qT(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function JT(e,t,n){let{reference:r,floating:i}=e,a=NT(t),o=PT(t),s=MT(o),c=kT(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(AT(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function YT(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=OT(t,e),p=KT(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=qT(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=qT(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var XT=50,ZT=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:YT},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=JT(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<XT&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=JT(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},QT=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=OT(e,t)||{};if(l==null)return{};let d=KT(u),f={x:n,y:r},p=PT(i),m=MT(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=xT(d[_],T),D=xT(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=DT(O,A,k),M=!c.arrow&&AT(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),$T=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=OT(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=kT(r),_=NT(o),v=kT(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[WT(o)]:IT(o)),x=p!==`none`;!d&&x&&b.push(...UT(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=FT(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==NT(t))||T.every(e=>NT(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=NT(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function eE(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function tE(e){return bT.some(t=>e[t]>=0)}var nE=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=OT(e,t);switch(i){case`referenceHidden`:{let e=eE(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:tE(e)}}}case`escaped`:{let e=eE(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:tE(e)}}}default:return{}}}}},rE=new Set([`left`,`top`]);async function iE(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=kT(n),s=AT(n),c=NT(n)===`y`,l=rE.has(o)?-1:1,u=a&&c?-1:1,d=OT(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var aE=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await iE(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},oE=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=OT(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=NT(kT(i)),p=jT(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=DT(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=DT(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},sE=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=OT(e,t),u={x:n,y:r},d=NT(i),f=jT(d),p=u[f],m=u[d],h=OT(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=rE.has(kT(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},cE=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=OT(e,t),u=await o.detectOverflow(t,l),d=kT(i),f=AT(i),p=NT(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=xT(h-u[g],v),x=xT(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=ST(u.left,0),t=ST(u.right,0),n=ST(u.top,0),r=ST(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:ST(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:ST(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function lE(){return typeof window<`u`}function uE(e){return pE(e)?(e.nodeName||``).toLowerCase():`#document`}function dE(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function fE(e){return((pE(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function pE(e){return lE()?e instanceof Node||e instanceof dE(e).Node:!1}function mE(e){return lE()?e instanceof Element||e instanceof dE(e).Element:!1}function hE(e){return lE()?e instanceof HTMLElement||e instanceof dE(e).HTMLElement:!1}function gE(e){return!lE()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof dE(e).ShadowRoot}function _E(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=OE(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function vE(e){return/^(table|td|th)$/.test(uE(e))}function yE(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var bE=/transform|translate|scale|rotate|perspective|filter/,xE=/paint|layout|strict|content/,SE=e=>!!e&&e!==`none`,CE;function wE(e){let t=mE(e)?OE(e):e;return SE(t.transform)||SE(t.translate)||SE(t.scale)||SE(t.rotate)||SE(t.perspective)||!EE()&&(SE(t.backdropFilter)||SE(t.filter))||bE.test(t.willChange||``)||xE.test(t.contain||``)}function TE(e){let t=AE(e);for(;hE(t)&&!DE(t);){if(wE(t))return t;if(yE(t))return null;t=AE(t)}return null}function EE(){return CE??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),CE}function DE(e){return/^(html|body|#document)$/.test(uE(e))}function OE(e){return dE(e).getComputedStyle(e)}function kE(e){return mE(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function AE(e){if(uE(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||gE(e)&&e.host||fE(e);return gE(t)?t.host:t}function jE(e){let t=AE(e);return DE(t)?e.ownerDocument?e.ownerDocument.body:e.body:hE(t)&&_E(t)?t:jE(t)}function ME(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=jE(e),i=r===e.ownerDocument?.body,a=dE(r);if(i){let e=NE(a);return t.concat(a,a.visualViewport||[],_E(r)?r:[],e&&n?ME(e):[])}else return t.concat(r,ME(r,[],n))}function NE(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function PE(e){let t=OE(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=hE(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=CT(n)!==a||CT(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function FE(e){return mE(e)?e:e.contextElement}function IE(e){let t=FE(e);if(!hE(t))return TT(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=PE(t),o=(a?CT(n.width):n.width)/r,s=(a?CT(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var LE=TT(0);function RE(e){let t=dE(e);return!EE()||!t.visualViewport?LE:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function zE(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==dE(e)?!1:t}function BE(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=FE(e),o=TT(1);t&&(r?mE(r)&&(o=IE(r)):o=IE(e));let s=zE(a,n,r)?RE(a):TT(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=dE(a),t=r&&mE(r)?dE(r):r,n=e,i=NE(n);for(;i&&r&&t!==n;){let e=IE(i),t=i.getBoundingClientRect(),r=OE(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=dE(i),i=NE(n)}}return qT({width:u,height:d,x:c,y:l})}function VE(e,t){let n=kE(e).scrollLeft;return t?t.left+n:BE(fE(e)).left+n}function HE(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-VE(e,n),y:n.top+t.scrollTop}}function UE(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=fE(r),s=t?yE(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=TT(1),u=TT(0),d=hE(r);if((d||!d&&!a)&&((uE(r)!==`body`||_E(o))&&(c=kE(r)),d)){let e=BE(r);l=IE(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?HE(o,c):TT(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function WE(e){return Array.from(e.getClientRects())}function GE(e){let t=fE(e),n=kE(e),r=e.ownerDocument.body,i=ST(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=ST(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+VE(e),s=-n.scrollTop;return OE(r).direction===`rtl`&&(o+=ST(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var KE=25;function qE(e,t){let n=dE(e),r=fE(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=EE();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=VE(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=KE&&(a-=o)}else l<=KE&&(a+=l);return{width:a,height:o,x:s,y:c}}function JE(e,t){let n=BE(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=hE(e)?IE(e):TT(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function YE(e,t,n){let r;if(t===`viewport`)r=qE(e,n);else if(t===`document`)r=GE(fE(e));else if(mE(t))r=JE(t,n);else{let n=RE(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return qT(r)}function XE(e,t){let n=AE(e);return n===t||!mE(n)||DE(n)?!1:OE(n).position===`fixed`||XE(n,t)}function ZE(e,t){let n=t.get(e);if(n)return n;let r=ME(e,[],!1).filter(e=>mE(e)&&uE(e)!==`body`),i=null,a=OE(e).position===`fixed`,o=a?AE(e):e;for(;mE(o)&&!DE(o);){let t=OE(o),n=wE(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||_E(o)&&!n&&XE(e,o))?r=r.filter(e=>e!==o):i=t,o=AE(o)}return t.set(e,r),r}function QE(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?yE(t)?[]:ZE(t,this._c):[].concat(n),r],o=YE(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=YE(t,a[e],i);s=ST(n.top,s),c=xT(n.right,c),l=xT(n.bottom,l),u=ST(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function $E(e){let{width:t,height:n}=PE(e);return{width:t,height:n}}function eD(e,t,n){let r=hE(t),i=fE(t),a=n===`fixed`,o=BE(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=TT(0);function l(){c.x=VE(i)}if(r||!r&&!a)if((uE(t)!==`body`||_E(i))&&(s=kE(t)),r){let e=BE(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?HE(i,s):TT(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function tD(e){return OE(e).position===`static`}function nD(e,t){if(!hE(e)||OE(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return fE(e)===n&&(n=n.ownerDocument.body),n}function rD(e,t){let n=dE(e);if(yE(e))return n;if(!hE(e)){let t=AE(e);for(;t&&!DE(t);){if(mE(t)&&!tD(t))return t;t=AE(t)}return n}let r=nD(e,t);for(;r&&vE(r)&&tD(r);)r=nD(r,t);return r&&DE(r)&&tD(r)&&!wE(r)?n:r||TE(e)||n}var iD=async function(e){let t=this.getOffsetParent||rD,n=this.getDimensions,r=await n(e.floating);return{reference:eD(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function aD(e){return OE(e).direction===`rtl`}var oD={convertOffsetParentRelativeRectToViewportRelativeRect:UE,getDocumentElement:fE,getClippingRect:QE,getOffsetParent:rD,getElementRects:iD,getClientRects:WE,getDimensions:$E,getScale:IE,isElement:mE,isRTL:aD};function sD(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cD(e,t){let n=null,r,i=fE(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=wT(d),h=wT(i.clientWidth-(u+f)),g=wT(i.clientHeight-(d+p)),_=wT(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:ST(0,xT(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!sD(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function lD(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=FE(e),u=i||a?[...l?ME(l):[],...t?ME(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?cD(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?BE(e):null;c&&g();function g(){let t=BE(e);h&&!sD(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var uD=aE,dD=oE,fD=$T,pD=cE,mD=nE,hD=QT,gD=sE,_D=(e,t,n)=>{let r=new Map,i={platform:oD,...n},a={...i.platform,_c:r};return ZT(e,t,{...i,platform:a})},vD=typeof document<`u`?Q.useLayoutEffect:function(){};function yD(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!yD(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!yD(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function bD(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xD(e,t){let n=bD(e);return Math.round(t*n)/n}function SD(e){let t=Q.useRef(e);return vD(()=>{t.current=e}),t}function CD(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=Q.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=Q.useState(r);yD(f,r)||p(r);let[m,h]=Q.useState(null),[g,_]=Q.useState(null),v=Q.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=Q.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=Q.useRef(null),C=Q.useRef(null),w=Q.useRef(u),T=c!=null,E=SD(c),D=SD(i),O=SD(l),k=Q.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),_D(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!yD(w.current,t)&&(w.current=t,BC.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);vD(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Q.useRef(!1);vD(()=>(A.current=!0,()=>{A.current=!1}),[]),vD(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=Q.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=Q.useMemo(()=>({reference:b,floating:x}),[b,x]),N=Q.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=xD(M.floating,u.x),r=xD(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...bD(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return Q.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var wD=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:hD({element:r.current,padding:i}).fn(n):r?hD({element:r,padding:i}).fn(n):{}}}},TD=(e,t)=>{let n=uD(e);return{name:n.name,fn:n.fn,options:[e,t]}},ED=(e,t)=>{let n=dD(e);return{name:n.name,fn:n.fn,options:[e,t]}},DD=(e,t)=>({fn:gD(e).fn,options:[e,t]}),OD=(e,t)=>{let n=fD(e);return{name:n.name,fn:n.fn,options:[e,t]}},kD=(e,t)=>{let n=pD(e);return{name:n.name,fn:n.fn,options:[e,t]}},AD=(e,t)=>{let n=mD(e);return{name:n.name,fn:n.fn,options:[e,t]}},jD=(e,t)=>{let n=wD(e);return{name:n.name,fn:n.fn,options:[e,t]}},MD=`Arrow`,ND=Q.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(Kn.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});ND.displayName=MD;var PD=ND;function FD(e){let[t,n]=Q.useState(void 0);return ur(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var ID=`Popper`,[LD,RD]=Un(ID),[zD,BD]=LD(ID),VD=e=>{let{__scopePopper:t,children:n}=e,[r,i]=Q.useState(null);return(0,$.jsx)(zD,{scope:t,anchor:r,onAnchorChange:i,children:n})};VD.displayName=ID;var HD=`PopperAnchor`,UD=Q.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=BD(HD,n),o=Q.useRef(null),s=Yn(t,o),c=Q.useRef(null);return Q.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,$.jsx)(Kn.div,{...i,ref:s})});UD.displayName=HD;var WD=`PopperContent`,[GD,KD]=LD(WD),qD=Q.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=BD(WD,n),[_,v]=Q.useState(null),y=Yn(t,e=>v(e)),[b,x]=Q.useState(null),S=FD(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(ZD),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=CD({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>lD(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[TD({mainAxis:i+w,alignmentAxis:o}),c&&ED({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?DD():void 0,...k}),c&&OD({...k}),kD({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&jD({element:b,padding:s}),QD({arrowWidth:C,arrowHeight:w}),f&&AD({strategy:`referenceHidden`,...k})]}),[F,I]=$D(M),ee=$n(m);ur(()=>{N&&ee?.()},[N,ee]);let te=P.arrow?.x,L=P.arrow?.y,R=P.arrow?.centerOffset!==0,[z,B]=Q.useState();return ur(()=>{_&&B(window.getComputedStyle(_).zIndex)},[_]),(0,$.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:z,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(GD,{scope:n,placedSide:F,onArrowChange:x,arrowX:te,arrowY:L,shouldHideArrow:R,children:(0,$.jsx)(Kn.div,{"data-side":F,"data-align":I,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});qD.displayName=WD;var JD=`PopperArrow`,YD={top:`bottom`,right:`left`,bottom:`top`,left:`right`},XD=Q.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=KD(JD,n),a=YD[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(PD,{...r,ref:t,style:{...r.style,display:`block`}})})});XD.displayName=JD;function ZD(e){return e!==null}var QD=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=$D(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function $D(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var eO=VD,tO=UD,nO=qD,rO=XD;function iO(e){let t=aO(e),n=Q.forwardRef((e,n)=>{let{children:r,...i}=e,a=Q.Children.toArray(r),o=a.find(sO);if(o){let e=o.props.children,r=a.map(t=>t===o?Q.Children.count(e)>1?Q.Children.only(null):Q.isValidElement(e)?e.props.children:null:t);return(0,$.jsx)(t,{...i,ref:n,children:Q.isValidElement(e)?Q.cloneElement(e,void 0,r):null})}return(0,$.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function aO(e){let t=Q.forwardRef((e,t)=>{let{children:n,...r}=e;if(Q.isValidElement(n)){let e=lO(n),i=cO(r,n.props);return n.type!==Q.Fragment&&(i.ref=t?Jn(t,e):e),Q.cloneElement(n,i)}return Q.Children.count(n)>1?Q.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var oO=Symbol(`radix.slottable`);function sO(e){return Q.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===oO}function cO(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function lO(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function uO(e){let t=Q.useRef({value:e,previous:e});return Q.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var dO=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),fO=`VisuallyHidden`,pO=Q.forwardRef((e,t)=>(0,$.jsx)(Kn.span,{...e,ref:t,style:{...dO,...e.style}}));pO.displayName=fO;var mO=pO,hO=[` `,`Enter`,`ArrowUp`,`ArrowDown`],gO=[` `,`Enter`],_O=`Select`,[vO,yO,bO]=_T(_O),[xO,SO]=Un(_O,[bO,RD]),CO=RD(),[wO,TO]=xO(_O),[EO,DO]=xO(_O),OO=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=CO(t),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S=yT(l),[C,w]=Gn({prop:r,defaultProp:i??!1,onChange:a,caller:_O}),[T,E]=Gn({prop:o,defaultProp:s,onChange:c,caller:_O}),D=Q.useRef(null),O=!g||m||!!g.closest(`form`),[k,A]=Q.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,$.jsx)(eO,{...h,children:(0,$.jsxs)(wO,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Xn(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,$.jsx)(vO.Provider,{scope:t,children:(0,$.jsx)(EO,{scope:e.__scopeSelect,onNativeOptionAdd:Q.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Q.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,$.jsxs)(Ck,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,$.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};OO.displayName=_O;var kO=`SelectTrigger`,AO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=CO(n),o=TO(kO,n),s=o.disabled||r,c=Yn(t,o.onTriggerChange),l=yO(n),u=Q.useRef(`touch`),[d,f,p]=Tk(e=>{let t=l().filter(e=>!e.disabled),n=Ek(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,$.jsx)(tO,{asChild:!0,...a,children:(0,$.jsx)(Kn.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":wk(o.value)?``:void 0,...i,ref:c,onClick:lr(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:lr(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:lr(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&hO.includes(e.key)&&(m(),e.preventDefault())})})})});AO.displayName=kO;var jO=`SelectValue`,MO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=TO(jO,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Yn(t,c.onValueNodeChange);return ur(()=>{l(u)},[l,u]),(0,$.jsx)(Kn.span,{...s,ref:d,style:{pointerEvents:`none`},children:wk(c.value)?(0,$.jsx)($.Fragment,{children:o}):a})});MO.displayName=jO;var NO=`SelectIcon`,PO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,$.jsx)(Kn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});PO.displayName=NO;var FO=`SelectPortal`,IO=e=>(0,$.jsx)(Qn,{asChild:!0,...e});IO.displayName=FO;var LO=`SelectContent`,RO=Q.forwardRef((e,t)=>{let n=TO(LO,e.__scopeSelect),[r,i]=Q.useState();if(ur(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?BC.createPortal((0,$.jsx)(BO,{scope:e.__scopeSelect,children:(0,$.jsx)(vO.Slot,{scope:e.__scopeSelect,children:(0,$.jsx)(`div`,{children:e.children})})}),t):null}return(0,$.jsx)(WO,{...e,ref:t})});RO.displayName=LO;var zO=10,[BO,VO]=xO(LO),HO=`SelectContentImpl`,UO=iO(`SelectContent.RemoveScroll`),WO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=TO(LO,n),[y,b]=Q.useState(null),[x,S]=Q.useState(null),C=Yn(t,e=>b(e)),[w,T]=Q.useState(null),[E,D]=Q.useState(null),O=yO(n),[k,A]=Q.useState(!1),j=Q.useRef(!1);Q.useEffect(()=>{if(y)return yr(y)},[y]),nr();let M=Q.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=Q.useCallback(()=>M([w,y]),[M,w,y]);Q.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Q.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),Q.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,ee]=Tk(e=>{let t=O().filter(e=>!e.disabled),n=Ek(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),te=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),L=Q.useCallback(()=>y?.focus(),[y]),R=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),z=r===`popper`?JO:KO,B=z===JO?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,$.jsx)(BO,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:te,selectedItem:w,onItemLeave:L,itemTextRefCallback:R,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,$.jsx)(Sr,{as:UO,allowPinchZoom:!0,children:(0,$.jsx)(Wn,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:lr(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,$.jsx)(br,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,$.jsx)(z,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:lr(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ee(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});WO.displayName=HO;var GO=`SelectItemAlignedPosition`,KO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=TO(LO,n),o=VO(LO,n),[s,c]=Q.useState(null),[l,u]=Q.useState(null),d=Yn(t,e=>u(e)),f=yO(n),p=Q.useRef(!1),m=Q.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Q.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zO,d=uT(a,[zO,Math.max(zO,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zO,d=uT(a,[zO,Math.max(zO,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-zO*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-zO,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${zO}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);ur(()=>y(),[y]);let[b,x]=Q.useState();return ur(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,$.jsx)(YO,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Q.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,$.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,$.jsx)(Kn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});KO.displayName=GO;var qO=`SelectPopperPosition`,JO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=zO,...a}=e,o=CO(n);return(0,$.jsx)(nO,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});JO.displayName=qO;var[YO,XO]=xO(LO,{}),ZO=`SelectViewport`,QO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=VO(ZO,n),o=XO(ZO,n),s=Yn(t,a.onViewportChange),c=Q.useRef(0);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,$.jsx)(vO.Slot,{scope:n,children:(0,$.jsx)(Kn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:lr(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-zO*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});QO.displayName=ZO;var $O=`SelectGroup`,[ek,tk]=xO($O),nk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Xn();return(0,$.jsx)(ek,{scope:n,id:i,children:(0,$.jsx)(Kn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});nk.displayName=$O;var rk=`SelectLabel`,ik=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=tk(rk,n);return(0,$.jsx)(Kn.div,{id:i.id,...r,ref:t})});ik.displayName=rk;var ak=`SelectItem`,[ok,sk]=xO(ak),ck=Q.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=TO(ak,n),c=VO(ak,n),l=s.value===r,[u,d]=Q.useState(a??``),[f,p]=Q.useState(!1),m=Yn(t,e=>c.itemRefCallback?.(e,r,i)),h=Xn(),g=Q.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,$.jsx)(ok,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Q.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,$.jsx)(vO.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,$.jsx)(Kn.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:lr(o.onFocus,()=>p(!0)),onBlur:lr(o.onBlur,()=>p(!1)),onClick:lr(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:lr(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:lr(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:lr(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:lr(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:lr(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(gO.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});ck.displayName=ak;var lk=`SelectItemText`,uk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=TO(lk,n),s=VO(lk,n),c=sk(lk,n),l=DO(lk,n),[u,d]=Q.useState(null),f=Yn(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Q.useMemo(()=>(0,$.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return ur(()=>(h(m),()=>g(m)),[h,g,m]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Kn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?BC.createPortal(a.children,o.valueNode):null]})});uk.displayName=lk;var dk=`SelectItemIndicator`,fk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return sk(dk,n).isSelected?(0,$.jsx)(Kn.span,{"aria-hidden":!0,...r,ref:t}):null});fk.displayName=dk;var pk=`SelectScrollUpButton`,mk=Q.forwardRef((e,t)=>{let n=VO(pk,e.__scopeSelect),r=XO(pk,e.__scopeSelect),[i,a]=Q.useState(!1),o=Yn(t,r.onScrollButtonChange);return ur(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,$.jsx)(_k,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});mk.displayName=pk;var hk=`SelectScrollDownButton`,gk=Q.forwardRef((e,t)=>{let n=VO(hk,e.__scopeSelect),r=XO(hk,e.__scopeSelect),[i,a]=Q.useState(!1),o=Yn(t,r.onScrollButtonChange);return ur(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,$.jsx)(_k,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});gk.displayName=hk;var _k=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=VO(`SelectScrollButton`,n),o=Q.useRef(null),s=yO(n),c=Q.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Q.useEffect(()=>()=>c(),[c]),ur(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,$.jsx)(Kn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:lr(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:lr(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:lr(i.onPointerLeave,()=>{c()})})}),vk=`SelectSeparator`,yk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,$.jsx)(Kn.div,{"aria-hidden":!0,...r,ref:t})});yk.displayName=vk;var bk=`SelectArrow`,xk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=CO(n),a=TO(bk,n),o=VO(bk,n);return a.open&&o.position===`popper`?(0,$.jsx)(rO,{...i,...r,ref:t}):null});xk.displayName=bk;var Sk=`SelectBubbleInput`,Ck=Q.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Q.useRef(null),a=Yn(r,i),o=uO(t);return Q.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,$.jsx)(Kn.select,{...n,style:{...dO,...n.style},ref:a,defaultValue:t})});Ck.displayName=Sk;function wk(e){return e===``||e===void 0}function Tk(e){let t=$n(e),n=Q.useRef(``),r=Q.useRef(0),i=Q.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Q.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Q.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Ek(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Dk(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Dk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ok=OO,kk=AO,Ak=MO,jk=PO,Mk=IO,Nk=RO,Pk=QO,Fk=ik,Ik=ck,Lk=uk,Rk=fk,zk=mk,Bk=gk,Vk=yk,Hk=`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground outline-none transition-colors hover:bg-surface/70 focus-visible:ring-2 focus-visible:ring-accent-primary/50 disabled:cursor-not-allowed disabled:opacity-50`,Uk=`overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,Wk=`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground outline-none hover:bg-surface/70 focus-visible:bg-surface/70`;function Gk({label:e,value:t,options:n,icon:r,onSelect:i,placeholder:a,disabled:o=!1,testId:s}){return(0,$.jsxs)(Ok,{value:t,onValueChange:i,disabled:o||n.length===0,children:[(0,$.jsxs)(kk,{"aria-label":e,title:e,"data-agent-interactive":!0,"data-testid":s,className:Hk,children:[(0,$.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(Ak,{placeholder:a??e,className:`max-w-[160px] truncate`}),(0,$.jsx)(jk,{asChild:!0,children:(0,$.jsx)(rc,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})})]}),(0,$.jsx)(Mk,{children:(0,$.jsxs)(Nk,{position:`popper`,side:`top`,align:`start`,sideOffset:4,collisionPadding:8,className:`z-[80] min-w-[12rem] max-w-[20rem] ${Uk} data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1`,children:[(0,$.jsx)(zk,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,$.jsx)(Sn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Pk,{className:`max-h-72 py-1`,children:n.map(e=>{let t=e.icon??r;return(0,$.jsxs)(Ik,{value:e.value,className:`${Wk} relative cursor-default select-none pr-9 data-[highlighted]:bg-surface/70 data-[state=checked]:font-medium`,children:[(0,$.jsx)(t,{className:`h-4 w-4 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(Lk,{children:(0,$.jsx)(`span`,{className:`truncate`,children:e.label})}),(0,$.jsx)(Rk,{className:`absolute right-3 flex items-center`,children:(0,$.jsx)(xn,{className:`h-3.5 w-3.5 text-accent-primary`})})]},e.value)})}),(0,$.jsx)(Bk,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,$.jsx)(rc,{className:`h-3.5 w-3.5`})})]})})]})}var Kk=`__new__`,qk=`__legacy__`,Jk=`__default__`,Yk=12,Xk=`specrails:focus-pr-card`,Zk=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-C7dWoRu6.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,77,78,79,80,81,82,83,84,85,86,87])));function Qk(e,t,n){if(e.availability)return e.availability;let r=String(e.railIndex);if(t.activeJobs?.[r]||t.activeLoopRuns?.[r])return`busy`;let i=t.prDeliveries?.[r];return i&&i.decision&&![`merged`,`discarded`,`completed`,`superseded`,`pr_ready`].includes(i.decision)?`pending_decision`:e.ticketIds.some(e=>n.find(t=>t.id===e)?.status===`on_review`)?`on_review`:`free`}function $k(e,t){let n=e(`railCard.rail`,{index:t.railIndex+1});return t.name?`${n} · ${t.name}`:n}function eA(e,t){return e.repositoryIds??t.filter(e=>e.isPrimary).map(e=>e.id)}function tA(e,t,n){return[...new Set(e.filter(e=>t.includes(e.id)).flatMap(e=>eA(e,n)))]}function nA(e,t,n){return[...new Set([...e.filter(e=>!t.includes(e)||n.includes(e)),...n])]}function rA(e,t){if(!e)return;let n=Object.entries(e).filter(([e])=>t.includes(e));return n.length?Object.fromEntries(n):void 0}function iA({proposal:e,proposalIndex:t,messageId:n,conversationId:r,projectId:i,intent:a,compact:o=!1}){let{t:s}=U(`agent`),c=AS(),l=Yw(),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)([]),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(0),[w,T]=(0,Q.useState)(-1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),P=(0,Q.useRef)(i);P.current=i,(0,Q.useEffect)(()=>{if(!i||a)return;let t=!1;D(!1),j(null),N(null),k(null);let n=Or(i);return Promise.all([fetch(`${n}/rails`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))),fetch(`${n}/tickets`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))),fetch(`${n}/repositories`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status))))]).then(([n,r,a])=>{if(t)return;if(!Array.isArray(a.repositories)||!a.repositories.some(e=>e.isPrimary))throw Error(`Missing project repositories`);let o=Array.isArray(r?.tickets)?r.tickets:[];d(n&&typeof n==`object`?n:{}),p(o),y(a.repositories),x(i),T(S),I(t=>{let n=b===i?tA(f??[],t.ticketIds,v):[],r=nA(b===i?t.repositoryIds??n:e.repositoryIds??[],n,tA(o,t.ticketIds,a.repositories));return{...t,repositoryIds:r,workspaceSelection:rA(t.workspaceSelection,r)}})}).catch(()=>{t||D(!0)}),st&&oT.list().then(e=>{t||_(e.filter(e=>e.status===`published`&&lT(e.graph)))}).catch(()=>{}),()=>{t=!0}},[i,a,S]);let[F,I]=(0,Q.useState)(()=>({railIndex:e.railIndex,newRail:!!e.newRail,railName:e.newRail?.name??e.railName??``,ticketIds:e.ticketIds,repositoryIds:e.repositoryIds,workspaceSelection:e.workspaceSelection,loopId:e.loopId??eT(null,e.mode),aiEngine:e.aiEngine,model:e.model,reasoningEffort:e.reasoningEffort,profileName:e.profileName,targetPrNumber:e.targetPrNumber,baseBranch:e.baseBranch??``,followUp:e.followUp??null})),ee=(0,Q.useCallback)(e=>I(t=>({...t,...e})),[]),te=l.detected,L=!l.loading,R=(0,Q.useMemo)(()=>F.aiEngine&&($t(F.aiEngine)||te.includes(F.aiEngine))?F.aiEngine:te[0]??null,[F.aiEngine,te]),z=!!F.aiEngine&&L&&R!==F.aiEngine,B=!!R&&$t(R),ne=R&&!$t(R)?R:te[0]??null,V=(0,Q.useMemo)(()=>Kw(ne),[ne]),re=(0,Q.useMemo)(()=>F.model&&V.some(e=>e.value===F.model)?F.model:qw(ne)||null,[F.model,V,ne]),ie=!!F.model&&V.length>0&&re!==F.model,ae=(0,Q.useMemo)(()=>qt(ne,re),[ne,re]),H=F.reasoningEffort&&ae.includes(F.reasoningEffort)?F.reasoningEffort:null,W=!!f?.some(e=>F.ticketIds.includes(e.id)&&qe(e.addenda).length>0),G=$w(eT(F.loopId,`loop`,W)),oe=!B&&G!==`loop`&&Xt(ne);(0,Q.useEffect)(()=>{if(!i||a||!ne||!oe){h([]);return}let e=!1;return fetch(`${Or(i)}/profiles?provider=${encodeURIComponent(ne)}`).then(e=>e.ok?e.json():{profiles:[]}).then(t=>{if(e)return;let n=Array.isArray(t.profiles)?t.profiles.filter(e=>!e.provider||e.provider===ne):[];h(n)}).catch(()=>{e||h([])}),()=>{e=!0}},[i,a,ne,oe]);let se=F.profileName&&m.some(e=>e.name===F.profileName)?F.profileName:null,ce=(0,Q.useMemo)(()=>u?.rails??[],[u]),K=(0,Q.useMemo)(()=>{let e=new Map;if(!u)return e;for(let t of ce)e.set(t.railIndex,Qk(t,u,f??[]));return e},[ce,u,f]),le=F.railIndex===null?void 0:ce.find(e=>e.railIndex===F.railIndex),ue=u!==null&&F.railIndex!==null&&!F.newRail&&!le,de=!!le&&!F.newRail&&K.get(le.railIndex)!==`free`&&K.get(le.railIndex)!==void 0&&!(W&&K.get(le.railIndex)!==`busy`&&le.ticketIds.length===F.ticketIds.length&&le.ticketIds.every(e=>F.ticketIds.includes(e))),fe=ce.length>=Yk,pe=(W?ce.find(e=>K.get(e.railIndex)!==`busy`&&e.ticketIds.length===F.ticketIds.length&&e.ticketIds.every(e=>F.ticketIds.includes(e))):void 0)??ce.find(e=>K.get(e.railIndex)===`free`),q=F.newRail?Kk:F.railIndex!==null&&le?String(F.railIndex):pe?String(pe.railIndex):fe?``:Kk,me=F.newRail||q===Kk||q===``?null:Number(q),he=q===Kk,ge=(0,Q.useMemo)(()=>new Map((f??[]).map(e=>[e.id,e])),[f]),_e=(0,Q.useMemo)(()=>f?F.ticketIds.filter(e=>ge.has(e)):F.ticketIds,[F.ticketIds,ge,f]),J=f?F.ticketIds.filter(e=>!ge.has(e)):[],ye=tA(f??[],_e,v),be=F.repositoryIds??ye,xe=e=>v.find(t=>t.id===e)?.name??e,Se=ye.filter(e=>!be.includes(e)),Ce=be.filter(e=>{let t=v.find(t=>t.id===e);return!t||t.available===!1||t.kind===`folder`&&!t.isPrimary}),we=!!i&&!E&&(b!==i||w!==S||u===null||f===null),Te=Ce.length?s(`railCard.repositories.unavailable`,{names:Ce.map(xe).join(`, `)}):Se.length?s(`railCard.repositories.missing`,{names:Se.map(xe).join(`, `)}):null,Ee=e=>{ee({repositoryIds:e,workspaceSelection:rA(F.workspaceSelection,e)}),N(null)},De=e=>{let t=tA(f??[],e,v),n=nA(be,ye,t);ee({ticketIds:e,repositoryIds:n,workspaceSelection:rA(F.workspaceSelection,n)}),j(null),N(null)},ke=(0,Q.useMemo)(()=>_e.flatMap(e=>qe(ge.get(e)?.addenda).map(t=>({ticketId:e,title:t.title}))),[_e,ge]),Ae=ke.length,je=ke.slice(0,3).map(e=>`#${e.ticketId} ${e.title}`),Me=(0,Q.useMemo)(()=>(f??[]).filter(e=>(e.status===`todo`||e.status===`draft`)&&!F.ticketIds.includes(e.id)),[f,F.ticketIds]),Ne=!B&&Yt(ne),Pe=(0,Q.useMemo)(()=>[...Zw.filter(e=>(!e.requiresFreestyle||Ne)&&(!e.requiresLoops||st)).map(e=>({value:e.id,label:s(`dashboard:${e.labelKey}`)})),...g.map(e=>({value:e.id,label:e.name}))],[g,Ne,s]),Fe=eT(Pe.some(e=>e.value===F.loopId)?F.loopId:Pe[0]?.value??F.loopId,G,W),[Ie,Le]=(0,Q.useState)(null),Re=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(Re.current=!0,()=>{Re.current=!1}),[]);let ze=a??Ie,Be=i?E?s(`railCard.block.loadFailed`):we?s(`railCard.status.loading`):A?s(`railCard.repositories.finishEditing`):_e.length===0?s(`railCard.block.noSpecs`):Te?s(`railCard.repositories.checkScope`):q===``?s(`railCard.block.railLimit`,{max:Yk}):null:s(`railCard.block.noProject`),Ve=async()=>{if(!A||!i||O||we)return;let e=i,t=A;k(`scope`),N(null);try{let n=await fetch(`${Or(e)}/tickets/${t.ticketId}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({repositoryIds:t.repositoryIds})}),r=await n.json();if(!n.ok)throw Error(r.detail??r.error??`HTTP ${n.status}`);if(r.ticket?.id!==t.ticketId)throw Error(s(`railCard.errors.invalid_response`));if(!Re.current||P.current!==e)return;let i=(f??[]).map(e=>e.id===t.ticketId?r.ticket:e),a=tA(i,_e,v),o=nA(be,ye,a);p(i),ee({repositoryIds:o,workspaceSelection:rA(F.workspaceSelection,o)}),j(null)}catch(t){Re.current&&P.current===e&&N({error:`scope_save_failed`,detail:t instanceof Error?t.message:void 0})}finally{Re.current&&P.current===e&&k(null)}},He=(0,Q.useCallback)(async e=>{let t=await ts(r,n,e),i=t.ok?t.intent:{...e,at:new Date().toISOString()};zw(n,i),Re.current&&Le(i)},[r,n]),Ue=(0,Q.useCallback)(async()=>{if(!i||Be||O)return;k(`launch`),N(null);let e=`${Or(i)}/rails`,n={"content-type":`application/json`},a=async e=>{let t={};try{t=await e.json()}catch{}return{error:typeof t.error==`string`?t.error:`HTTP ${e.status}`,detail:typeof t.detail==`string`?t.detail:void 0,action:typeof t.action==`string`?t.action:void 0}};try{let o=me,s=F.railName.trim().slice(0,60);if(o===null){let t=await fetch(e,{method:`POST`,headers:n,body:JSON.stringify({name:s||null})});if(!t.ok){N(await a(t));return}let r=await t.json();if(typeof r.rail?.railIndex!=`number`){N({error:`invalid_response`});return}o=r.rail.railIndex}else if(s&&s!==(le?.name??``)){let t=await fetch(`${e}/${o}/name`,{method:`PUT`,headers:n,body:JSON.stringify({name:s})});if(!t.ok){N(await a(t));return}}let c=R&&te.length>1?R:void 0,l=await fetch(`${e}/${o}/tickets`,{method:`PUT`,headers:n,body:JSON.stringify({ticketIds:_e,mode:G,profileName:oe?se:null,...c?{aiEngine:c}:{}})});if(!l.ok){N(await a(l));return}let u={mode:G,loopId:Fe,originConversationId:r,originSurface:`agent-chat`,repositoryIds:be,...F.workspaceSelection?{workspaceSelection:rA(F.workspaceSelection,be)}:{},...c?{aiEngine:c}:{},...!B&&re?{model:re}:{},...!B&&H?{reasoning_effort:H}:{},...oe&&se?{profileName:se}:{},...F.targetPrNumber?{targetPrNumber:F.targetPrNumber}:{},...F.baseBranch.trim()?{baseBranch:F.baseBranch.trim()}:{},...F.followUp?{followUp:F.followUp}:{}},d=await fetch(`${e}/${o}/launch`,{method:`POST`,headers:n,body:JSON.stringify(u)});if(!d.ok){N(await a(d));return}let f=await d.json(),p=Array.isArray(f.loopRunIds)&&f.loopRunIds.length?f.loopRunIds:Array.isArray(f.jobIds)&&f.jobIds.length?f.jobIds:f.jobId?[f.jobId]:[];Et(i),await He({kind:`rail-launch`,proposalIndex:t,status:`launched`,railIndex:o,runIds:p,prDeliveryId:typeof f.prDeliveryId==`string`?f.prDeliveryId:null,config:{...u,ticketIds:_e,railName:s||null}})}catch(e){N({error:e instanceof Error?e.message:`network`})}finally{Re.current&&k(null)}},[i,Be,O,me,F,be,le,R,B,te.length,_e,G,oe,se,Fe,re,H,r,t,He]),We=(0,Q.useCallback)(async()=>{if(!O){k(`dismiss`);try{await He({kind:`rail-launch`,proposalIndex:t,status:`dismissed`})}finally{Re.current&&k(null)}}},[O,He,t]),[Ge,Ke]=(0,Q.useState)(null);if(ze){let t=ze.status===`launched`,n=ze.runIds?.[0]??null;return(0,$.jsxs)(`div`,{"data-testid":t?`agent-rail-launch-stub-launched`:`agent-rail-launch-stub-dismissed`,className:X(`my-1 flex items-center gap-2 rounded-xl border px-3 py-2 text-xs backdrop-blur`,t?`border-accent-success/30 bg-accent-success/[0.06] text-foreground/80`:`border-border/50 bg-surface/40 text-foreground/50`),children:[t?(0,$.jsx)(sc,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(bn,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t?s(`railCard.stub.launched`,{rail:typeof ze.railIndex==`number`?ze.railIndex+1:`?`}):s(`railCard.stub.dismissed`),` `,(0,$.jsx)(`span`,{className:`text-foreground/50`,children:e.ticketIds.map(e=>`#${e}`).join(` `)})]}),t&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-rail-launch-focus-card`,title:s(`railCard.stub.goToCardTitle`),onClick:()=>{window.dispatchEvent(new CustomEvent(Xk,{detail:{prDeliveryId:ze.prDeliveryId??null,runIds:ze.runIds??[]}}))},className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-border/60 bg-card/70 px-2 py-0.5 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:text-foreground`,children:[(0,$.jsx)(xu,{className:`h-3 w-3`}),s(`railCard.stub.goToCard`)]}),t&&i&&n&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-rail-launch-view-run`,title:s(`railCard.stub.viewRunTitle`),onClick:()=>Ke(n),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-accent-primary/40 bg-accent-primary/10 px-2 py-0.5 text-[11px] font-medium text-accent-primary transition-colors hover:bg-accent-primary/20`,children:[(0,$.jsx)(Dn,{className:`h-3 w-3`}),s(`railCard.stub.viewRun`)]}),Ge&&i&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zk,{jobId:Ge,projectId:i,onClose:()=>Ke(null)})})]})}let Je=[...ce.map(e=>{let t=K.get(e.railIndex),n=t&&t!==`free`?` · ${s(`railCard.availability.${t}`)}`:``;return{value:String(e.railIndex),label:`${$k(s,e)}${n}`}}),...fe?[]:[{value:Kk,label:s(`railCard.newRail`),icon:Pn}]],Ye=[...te.map(e=>({value:e,label:l.providers[e]?.displayName??sn(e)}))],Xe=V.map(e=>({value:e.value,label:e.label??e.value})),Ze=[{value:Jk,label:s(`railCard.effortDefault`)},...ae.map(e=>({value:e,label:s(`effort.${e}`,{defaultValue:e})}))],Qe=[{value:qk,label:s(`railCard.profileNone`)},...m.map(e=>({value:e.name,label:e.name}))],$e=we?{tone:`border-border/60 bg-surface/60 text-foreground/50`,label:s(`railCard.status.loading`)}:Be?{tone:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,label:s(`railCard.status.blocked`)}:{tone:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,label:s(`railCard.status.ready`)};return(0,$.jsxs)(jS.div,{initial:!c&&{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.22,ease:`easeOut`},"data-testid":`agent-rail-launch-card`,className:X(`my-1 overflow-hidden rounded-xl border border-accent-primary/25 bg-card/80 shadow-lg backdrop-blur`,o&&`my-0`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/40 bg-accent-primary/[0.06] px-3.5 py-2`,children:[(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest text-accent-primary/90`,children:[(0,$.jsx)(Vu,{className:`h-3 w-3`}),s(`railCard.heading`)]}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-foreground/55`,children:_e.map(e=>`#${e}`).join(` `)}),(0,$.jsx)(`span`,{className:X(`inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,$e.tone),children:$e.label})]}),(0,$.jsxs)(`div`,{className:`space-y-2.5 px-3.5 py-3`,children:[e.rationale&&(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs italic text-foreground/60`,children:[(0,$.jsx)(Ln,{className:`mt-0.5 h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{children:e.rationale})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(Gk,{label:s(`railCard.fields.rail`),icon:Td,value:q,options:Je,disabled:we||!!O,testId:`rail-card-rail`,onSelect:e=>ee(e===Kk?{newRail:!0,railIndex:null}:{newRail:!1,railIndex:Number(e)})}),(he||le)&&(0,$.jsx)(`input`,{type:`text`,"data-agent-interactive":!0,"data-testid":`rail-card-name`,value:F.railName,maxLength:60,placeholder:s(he?`railCard.fields.newRailName`:`railCard.fields.railName`),onChange:e=>ee({railName:e.target.value}),className:`h-7 min-w-[120px] flex-1 rounded-md border border-border/60 bg-surface/50 px-2 text-xs text-foreground outline-none placeholder:text-foreground/35 focus:border-accent-primary/50`})]}),ue&&(0,$.jsx)(aA,{tone:`warning`,text:s(`railCard.notes.railMissing`,{index:(F.railIndex??0)+1})}),de&&le&&(0,$.jsx)(aA,{tone:`warning`,text:s(`railCard.notes.railBusy`,{index:le.railIndex+1,state:s(`railCard.availability.${K.get(le.railIndex)??`busy`}`)}),action:pe?{label:s(`railCard.notes.useFree`,{index:pe.railIndex+1}),onClick:()=>ee({newRail:!1,railIndex:pe.railIndex})}:void 0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`rail-card-specs`,children:[_e.map(e=>{let t=ge.get(e);return(0,$.jsxs)(`span`,{title:t?.title,className:`inline-flex max-w-[220px] items-center gap-1 rounded-full border border-accent-primary/35 bg-accent-primary/10 py-0.5 pl-2 pr-1 text-[11px] font-medium text-accent-primary`,children:[(0,$.jsxs)(`span`,{className:`truncate`,children:[`#`,e,t?` ${t.title}`:``]}),(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,"aria-label":s(`railCard.fields.removeSpec`,{id:e}),disabled:we||!!O,onClick:()=>De(F.ticketIds.filter(t=>t!==e)),className:`rounded-full p-0.5 text-accent-primary/60 hover:bg-accent-primary/20 hover:text-accent-primary`,children:(0,$.jsx)(Vn,{className:`h-3 w-3`})})]},e)}),Me.length>0&&(0,$.jsx)(Gk,{label:s(`railCard.fields.addSpec`),icon:Pn,value:``,placeholder:s(`railCard.fields.addSpec`),options:Me.slice(0,40).map(e=>({value:String(e.id),label:`#${e.id} ${e.title}`})),disabled:we||!!O,testId:`rail-card-add-spec`,onSelect:e=>De([...F.ticketIds,Number(e)])})]}),!we&&!E&&i&&(0,$.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border border-border/50 bg-surface/30 p-2.5`,"data-testid":`rail-card-repositories`,children:[(0,$.jsx)(Ar,{showSingle:!0,repositories:v,value:be,onChange:Ee,disabled:!!O||!!A,label:s(`railCard.repositories.launch`),hint:s(`railCard.repositories.launchHint`)}),(0,$.jsxs)(`div`,{className:`space-y-1.5 border-t border-border/40 pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-foreground/55`,children:s(`railCard.repositories.assignments`)}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:!!O||!!A,className:`inline-flex items-center gap-1 text-[11px] text-foreground/60 hover:text-accent-primary disabled:opacity-40`,onClick:()=>C(e=>e+1),children:[(0,$.jsx)(Lu,{className:`h-3 w-3`}),s(`railCard.repositories.refresh`)]})]}),_e.map(e=>{let t=ge.get(e),n=A?.ticketId===e,r=!!A?.repositoryIds.length&&A.repositoryIds.every(e=>v.some(t=>t.id===e&&t.available!==!1&&(t.kind===`git`||t.isPrimary)));return(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`rail-card-spec-scope-${e}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,$.jsxs)(`span`,{className:`shrink-0 text-accent-primary`,title:t.title,children:[`#`,e]}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-foreground/75`,children:eA(t,v).map(xe).join(` · `)}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"aria-label":s(`railCard.repositories.editSpec`,{id:e}),disabled:!!O||!!A,className:`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-1 text-foreground/60 hover:bg-accent-primary/10 hover:text-accent-primary disabled:opacity-40`,onClick:()=>{j({ticketId:e,repositoryIds:eA(t,v)}),N(null)},children:[(0,$.jsx)(jn,{className:`h-3 w-3`}),s(`railCard.repositories.edit`)]})]}),n&&A&&(0,$.jsxs)(`div`,{className:`space-y-2 rounded-md border border-accent-primary/25 p-2`,"data-testid":`rail-card-scope-editor`,children:[(0,$.jsx)(Ar,{showSingle:!0,repositories:v,value:A.repositoryIds,onChange:t=>j({ticketId:e,repositoryIds:t}),disabled:!!O,label:s(`railCard.repositories.spec`,{id:e}),hint:s(`railCard.repositories.saveHint`)}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:!!O,className:`rounded px-2 py-1 text-xs text-foreground/65 hover:bg-surface`,onClick:()=>{j(null),N(null)},children:s(`railCard.repositories.cancel`)}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:!!O||!r,className:`inline-flex items-center gap-1 rounded bg-accent-primary/15 px-2 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-40`,onClick:()=>void Ve(),children:[O===`scope`&&(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}),s(`railCard.repositories.save`)]})]})]})]},e)})]}),(0,$.jsx)(Ar,{workspaceOnly:!0,repositories:v,value:be,onChange:()=>{},workspaceSelection:F.workspaceSelection,onWorkspaceChange:e=>ee({workspaceSelection:e}),disabled:!!O||!!A}),Te&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:Te})]}),J.length>0&&(0,$.jsx)(aA,{tone:`muted`,text:s(`railCard.notes.specsDropped`,{ids:J.map(e=>`#${e}`).join(`, `)})}),Ae>0&&(0,$.jsxs)(`div`,{"data-testid":`rail-card-addenda`,className:`flex items-start gap-1.5 rounded-lg border border-accent-primary/25 bg-accent-primary/[0.05] px-2.5 py-1.5 text-[11px] text-foreground/75`,children:[(0,$.jsx)(kn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary/80`}),(0,$.jsxs)(`span`,{children:[s(`railCard.addenda.rides`,{count:Ae}),` `,(0,$.jsx)(`span`,{className:`text-foreground/50`,children:je.join(` · `)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1 gap-y-1`,children:[(0,$.jsx)(Gk,{label:s(`railCard.fields.loop`),icon:Fd,value:Fe,options:Pe,disabled:!!O,testId:`rail-card-loop`,onSelect:e=>ee({loopId:e})}),Ye.length>1&&(0,$.jsx)(Gk,{label:s(`railCard.fields.engine`),icon:Fc,value:R??``,options:Ye,disabled:!!O,testId:`rail-card-engine`,onSelect:e=>ee({aiEngine:e,model:null,reasoningEffort:null,profileName:null})}),!B&&Xe.length>0&&(0,$.jsx)(Gk,{label:s(`railCard.fields.model`),icon:Us,value:re??``,options:Xe,disabled:!!O,testId:`rail-card-model`,onSelect:e=>ee({model:e})}),!B&&ae.length>0&&(0,$.jsx)(Gk,{label:s(`railCard.fields.effort`),icon:dl,value:H??Jk,options:Ze,disabled:!!O,testId:`rail-card-effort`,onSelect:e=>ee({reasoningEffort:e===Jk?null:e})}),oe&&m.length>0&&(0,$.jsx)(Gk,{label:s(`railCard.fields.profile`),icon:Dd,value:se??qk,options:Qe,disabled:!!O,testId:`rail-card-profile`,onSelect:e=>ee({profileName:e===qk?null:e})})]}),z&&(0,$.jsx)(aA,{tone:`muted`,text:s(`railCard.notes.engineStale`,{engine:F.aiEngine,fallback:R?sn(R):``})}),ie&&(0,$.jsx)(aA,{tone:`muted`,text:s(`railCard.notes.modelStale`,{model:F.model,fallback:re})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-foreground/60`,children:[(0,$.jsx)(ve,{className:`h-3.5 w-3.5 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`sr-only`,children:s(`railCard.fields.targetPr`)}),(0,$.jsx)(`input`,{type:`number`,min:1,inputMode:`numeric`,"data-agent-interactive":!0,"data-testid":`rail-card-target-pr`,value:F.targetPrNumber??``,placeholder:s(`railCard.fields.targetPr`),disabled:!!O,onChange:e=>ee({targetPrNumber:e.target.value?Math.max(1,Math.floor(Number(e.target.value))):null}),className:`h-7 w-28 rounded-md border border-border/60 bg-surface/50 px-2 text-xs text-foreground outline-none placeholder:text-foreground/35 focus:border-accent-primary/50`})]}),(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-foreground/60`,children:[(0,$.jsx)(On,{className:`h-3.5 w-3.5 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`sr-only`,children:s(`railCard.fields.baseBranch`)}),(0,$.jsx)(`input`,{type:`text`,"data-agent-interactive":!0,"data-testid":`rail-card-base-branch`,value:F.baseBranch,placeholder:s(`railCard.fields.baseBranch`),disabled:!!O,onChange:e=>ee({baseBranch:e.target.value}),className:`h-7 w-40 rounded-md border border-border/60 bg-surface/50 px-2 text-xs text-foreground outline-none placeholder:text-foreground/35 focus:border-accent-primary/50`})]})]}),F.followUp&&(0,$.jsxs)(`div`,{"data-testid":`rail-card-follow-up`,className:`rounded-lg border border-accent-primary/25 bg-accent-primary/[0.05] px-2.5 py-2 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-foreground/85`,children:[(0,$.jsx)(Oe,{className:`h-3.5 w-3.5 text-accent-primary/80`}),s(`railCard.followUp.title`,{count:F.followUp.comments.length})]}),(0,$.jsx)(`span`,{className:`text-foreground/55`,children:F.followUp.scope.objective})]}),(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:F.followUp.comments.map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2 text-foreground/75`,children:[(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface/70 px-1 font-mono text-[10px] text-foreground/60`,children:e.id}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[e.path?(0,$.jsxs)(`span`,{className:`font-mono text-[11px] text-accent-info`,children:[e.path,e.line?`:${e.line}`:``,` · `]}):null,(0,$.jsx)(`span`,{className:`line-clamp-2`,children:e.body}),(0,$.jsx)(`span`,{className:`ml-1 text-[10px] text-foreground/45`,children:s(`railCard.followUp.source.${e.source===`github`?`github`:`pasted`}`)})]})]},e.id))}),F.followUp.scope.excludedChanges.length>0&&(0,$.jsxs)(`div`,{className:`mt-1.5 text-foreground/60`,children:[(0,$.jsxs)(`span`,{className:`font-medium`,children:[s(`railCard.followUp.excluded`),`:`]}),` `,F.followUp.scope.excludedChanges.join(` · `)]}),F.followUp.scope.verification.length>0&&(0,$.jsxs)(`div`,{className:`mt-1 text-foreground/60`,children:[(0,$.jsxs)(`span`,{className:`font-medium`,children:[s(`railCard.followUp.verification`),`:`]}),` `,F.followUp.scope.verification.join(` · `)]}),(0,$.jsx)(`div`,{className:`mt-1.5 text-[11px] text-foreground/45`,children:s(`railCard.followUp.specUntouched`)})]}),M&&(0,$.jsxs)(`div`,{"data-testid":`rail-card-error`,className:`flex items-start gap-2 rounded-lg border border-destructive/35 bg-destructive/10 px-2.5 py-1.5 text-xs text-destructive`,children:[(0,$.jsx)(zn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:s(`railCard.errors.${M.error}`,{defaultValue:M.error})}),M.detail&&(0,$.jsx)(`div`,{className:`text-destructive/80`,children:M.detail}),M.action&&(0,$.jsx)(`div`,{className:`text-foreground/70`,children:M.action})]})]}),E&&i&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:!!O,className:`inline-flex items-center gap-1 text-xs text-accent-primary`,onClick:()=>C(e=>e+1),children:[(0,$.jsx)(Lu,{className:`h-3 w-3`}),s(`railCard.repositories.retry`)]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-0.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-[11px] text-foreground/45`,children:Be??s(`railCard.playHint`)}),(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`rail-card-dismiss`,disabled:!!O,onClick:()=>void We(),className:`rounded-md px-2 py-1 text-xs text-foreground/60 transition-colors hover:bg-surface hover:text-foreground disabled:opacity-50`,children:s(`railCard.dismiss`)}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`rail-card-play`,disabled:!!O||we||!!Be,onClick:()=>void Ue(),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-3 py-1 text-xs font-semibold text-white shadow transition-colors hover:bg-accent-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[O===`launch`?(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Mn,{className:`h-3.5 w-3.5`}),s(O===`launch`?`railCard.launching`:`railCard.play`)]})]})]})]})}function aA({tone:e,text:t,action:n}){return(0,$.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-lg border px-2.5 py-1 text-[11px]`,e===`warning`?`border-accent-warning/35 bg-accent-warning/10 text-accent-warning`:`border-border/50 bg-surface/40 text-foreground/55`),children:[e===`warning`&&(0,$.jsx)(zn,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),n&&(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:n.onClick,className:`shrink-0 rounded px-1.5 py-0.5 font-medium underline-offset-2 hover:underline`,children:n.label})]})}function oA(){let{t:e}=U(`agent`);return(0,$.jsxs)(`div`,{"data-testid":`agent-rail-launch-pending`,className:`my-1 inline-flex items-center gap-1.5 rounded-full border border-accent-primary/30 bg-accent-primary/10 px-2.5 py-1 text-[11px] text-accent-primary`,children:[(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}),e(`railCard.pending`)]})}function sA({excerpts:e}){let{t}=U(`agent`);return(0,$.jsxs)(`div`,{"data-testid":`agent-rail-launch-unreadable`,title:e.join(`
|
|
33
|
+
`);if(sT.test(e)||cT.test(e))return!0}return Object.values(e.components??{}).some(e=>lT(e))}function uT(e,[t,n]){return Math.min(n,Math.max(t,e))}function dT(e){let t=fT(e),n=Q.forwardRef((e,n)=>{let{children:r,...i}=e,a=Q.Children.toArray(r),o=a.find(mT);if(o){let e=o.props.children,r=a.map(t=>t===o?Q.Children.count(e)>1?Q.Children.only(null):Q.isValidElement(e)?e.props.children:null:t);return(0,$.jsx)(t,{...i,ref:n,children:Q.isValidElement(e)?Q.cloneElement(e,void 0,r):null})}return(0,$.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function fT(e){let t=Q.forwardRef((e,t)=>{let{children:n,...r}=e;if(Q.isValidElement(n)){let e=gT(n),i=hT(r,n.props);return n.type!==Q.Fragment&&(i.ref=t?Jn(t,e):e),Q.cloneElement(n,i)}return Q.Children.count(n)>1?Q.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pT=Symbol(`radix.slottable`);function mT(e){return Q.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===pT}function hT(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function gT(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function _T(e){let t=e+`CollectionProvider`,[n,r]=Un(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=Q.useRef(null),a=Q.useRef(new Map).current;return(0,$.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=dT(s),l=Q.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Yn(t,a(s,n).collectionRef);return(0,$.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=dT(u),p=Q.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=Q.useRef(null),s=Yn(t,o),c=a(u,n);return Q.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,$.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return Q.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var vT=Q.createContext(void 0);function yT(e){let t=Q.useContext(vT);return e||t||`ltr`}var bT=[`top`,`right`,`bottom`,`left`],xT=Math.min,ST=Math.max,CT=Math.round,wT=Math.floor,TT=e=>({x:e,y:e}),ET={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function DT(e,t,n){return ST(e,xT(t,n))}function OT(e,t){return typeof e==`function`?e(t):e}function kT(e){return e.split(`-`)[0]}function AT(e){return e.split(`-`)[1]}function jT(e){return e===`x`?`y`:`x`}function MT(e){return e===`y`?`height`:`width`}function NT(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function PT(e){return jT(NT(e))}function FT(e,t,n){n===void 0&&(n=!1);let r=AT(e),i=PT(e),a=MT(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=WT(o)),[o,WT(o)]}function IT(e){let t=WT(e);return[LT(e),t,LT(t)]}function LT(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var RT=[`left`,`right`],zT=[`right`,`left`],BT=[`top`,`bottom`],VT=[`bottom`,`top`];function HT(e,t,n){switch(e){case`top`:case`bottom`:return n?t?zT:RT:t?RT:zT;case`left`:case`right`:return t?BT:VT;default:return[]}}function UT(e,t,n,r){let i=AT(e),a=HT(kT(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(LT)))),a}function WT(e){let t=kT(e);return ET[t]+e.slice(t.length)}function GT(e){return{top:0,right:0,bottom:0,left:0,...e}}function KT(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:GT(e)}function qT(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function JT(e,t,n){let{reference:r,floating:i}=e,a=NT(t),o=PT(t),s=MT(o),c=kT(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(AT(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function YT(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=OT(t,e),p=KT(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=qT(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=qT(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var XT=50,ZT=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:YT},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=JT(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<XT&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=JT(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},QT=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=OT(e,t)||{};if(l==null)return{};let d=KT(u),f={x:n,y:r},p=PT(i),m=MT(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=xT(d[_],T),D=xT(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=DT(O,A,k),M=!c.arrow&&AT(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),$T=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=OT(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=kT(r),_=NT(o),v=kT(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[WT(o)]:IT(o)),x=p!==`none`;!d&&x&&b.push(...UT(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=FT(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==NT(t))||T.every(e=>NT(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=NT(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function eE(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function tE(e){return bT.some(t=>e[t]>=0)}var nE=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=OT(e,t);switch(i){case`referenceHidden`:{let e=eE(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:tE(e)}}}case`escaped`:{let e=eE(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:tE(e)}}}default:return{}}}}},rE=new Set([`left`,`top`]);async function iE(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=kT(n),s=AT(n),c=NT(n)===`y`,l=rE.has(o)?-1:1,u=a&&c?-1:1,d=OT(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var aE=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await iE(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},oE=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=OT(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=NT(kT(i)),p=jT(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=DT(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=DT(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},sE=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=OT(e,t),u={x:n,y:r},d=NT(i),f=jT(d),p=u[f],m=u[d],h=OT(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=rE.has(kT(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},cE=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=OT(e,t),u=await o.detectOverflow(t,l),d=kT(i),f=AT(i),p=NT(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=xT(h-u[g],v),x=xT(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=ST(u.left,0),t=ST(u.right,0),n=ST(u.top,0),r=ST(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:ST(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:ST(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function lE(){return typeof window<`u`}function uE(e){return pE(e)?(e.nodeName||``).toLowerCase():`#document`}function dE(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function fE(e){return((pE(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function pE(e){return lE()?e instanceof Node||e instanceof dE(e).Node:!1}function mE(e){return lE()?e instanceof Element||e instanceof dE(e).Element:!1}function hE(e){return lE()?e instanceof HTMLElement||e instanceof dE(e).HTMLElement:!1}function gE(e){return!lE()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof dE(e).ShadowRoot}function _E(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=OE(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function vE(e){return/^(table|td|th)$/.test(uE(e))}function yE(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var bE=/transform|translate|scale|rotate|perspective|filter/,xE=/paint|layout|strict|content/,SE=e=>!!e&&e!==`none`,CE;function wE(e){let t=mE(e)?OE(e):e;return SE(t.transform)||SE(t.translate)||SE(t.scale)||SE(t.rotate)||SE(t.perspective)||!EE()&&(SE(t.backdropFilter)||SE(t.filter))||bE.test(t.willChange||``)||xE.test(t.contain||``)}function TE(e){let t=AE(e);for(;hE(t)&&!DE(t);){if(wE(t))return t;if(yE(t))return null;t=AE(t)}return null}function EE(){return CE??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),CE}function DE(e){return/^(html|body|#document)$/.test(uE(e))}function OE(e){return dE(e).getComputedStyle(e)}function kE(e){return mE(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function AE(e){if(uE(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||gE(e)&&e.host||fE(e);return gE(t)?t.host:t}function jE(e){let t=AE(e);return DE(t)?e.ownerDocument?e.ownerDocument.body:e.body:hE(t)&&_E(t)?t:jE(t)}function ME(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=jE(e),i=r===e.ownerDocument?.body,a=dE(r);if(i){let e=NE(a);return t.concat(a,a.visualViewport||[],_E(r)?r:[],e&&n?ME(e):[])}else return t.concat(r,ME(r,[],n))}function NE(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function PE(e){let t=OE(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=hE(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=CT(n)!==a||CT(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function FE(e){return mE(e)?e:e.contextElement}function IE(e){let t=FE(e);if(!hE(t))return TT(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=PE(t),o=(a?CT(n.width):n.width)/r,s=(a?CT(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var LE=TT(0);function RE(e){let t=dE(e);return!EE()||!t.visualViewport?LE:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function zE(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==dE(e)?!1:t}function BE(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=FE(e),o=TT(1);t&&(r?mE(r)&&(o=IE(r)):o=IE(e));let s=zE(a,n,r)?RE(a):TT(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=dE(a),t=r&&mE(r)?dE(r):r,n=e,i=NE(n);for(;i&&r&&t!==n;){let e=IE(i),t=i.getBoundingClientRect(),r=OE(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=dE(i),i=NE(n)}}return qT({width:u,height:d,x:c,y:l})}function VE(e,t){let n=kE(e).scrollLeft;return t?t.left+n:BE(fE(e)).left+n}function HE(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-VE(e,n),y:n.top+t.scrollTop}}function UE(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=fE(r),s=t?yE(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=TT(1),u=TT(0),d=hE(r);if((d||!d&&!a)&&((uE(r)!==`body`||_E(o))&&(c=kE(r)),d)){let e=BE(r);l=IE(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?HE(o,c):TT(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function WE(e){return Array.from(e.getClientRects())}function GE(e){let t=fE(e),n=kE(e),r=e.ownerDocument.body,i=ST(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=ST(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+VE(e),s=-n.scrollTop;return OE(r).direction===`rtl`&&(o+=ST(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var KE=25;function qE(e,t){let n=dE(e),r=fE(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=EE();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=VE(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=KE&&(a-=o)}else l<=KE&&(a+=l);return{width:a,height:o,x:s,y:c}}function JE(e,t){let n=BE(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=hE(e)?IE(e):TT(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function YE(e,t,n){let r;if(t===`viewport`)r=qE(e,n);else if(t===`document`)r=GE(fE(e));else if(mE(t))r=JE(t,n);else{let n=RE(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return qT(r)}function XE(e,t){let n=AE(e);return n===t||!mE(n)||DE(n)?!1:OE(n).position===`fixed`||XE(n,t)}function ZE(e,t){let n=t.get(e);if(n)return n;let r=ME(e,[],!1).filter(e=>mE(e)&&uE(e)!==`body`),i=null,a=OE(e).position===`fixed`,o=a?AE(e):e;for(;mE(o)&&!DE(o);){let t=OE(o),n=wE(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||_E(o)&&!n&&XE(e,o))?r=r.filter(e=>e!==o):i=t,o=AE(o)}return t.set(e,r),r}function QE(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?yE(t)?[]:ZE(t,this._c):[].concat(n),r],o=YE(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=YE(t,a[e],i);s=ST(n.top,s),c=xT(n.right,c),l=xT(n.bottom,l),u=ST(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function $E(e){let{width:t,height:n}=PE(e);return{width:t,height:n}}function eD(e,t,n){let r=hE(t),i=fE(t),a=n===`fixed`,o=BE(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=TT(0);function l(){c.x=VE(i)}if(r||!r&&!a)if((uE(t)!==`body`||_E(i))&&(s=kE(t)),r){let e=BE(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?HE(i,s):TT(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function tD(e){return OE(e).position===`static`}function nD(e,t){if(!hE(e)||OE(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return fE(e)===n&&(n=n.ownerDocument.body),n}function rD(e,t){let n=dE(e);if(yE(e))return n;if(!hE(e)){let t=AE(e);for(;t&&!DE(t);){if(mE(t)&&!tD(t))return t;t=AE(t)}return n}let r=nD(e,t);for(;r&&vE(r)&&tD(r);)r=nD(r,t);return r&&DE(r)&&tD(r)&&!wE(r)?n:r||TE(e)||n}var iD=async function(e){let t=this.getOffsetParent||rD,n=this.getDimensions,r=await n(e.floating);return{reference:eD(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function aD(e){return OE(e).direction===`rtl`}var oD={convertOffsetParentRelativeRectToViewportRelativeRect:UE,getDocumentElement:fE,getClippingRect:QE,getOffsetParent:rD,getElementRects:iD,getClientRects:WE,getDimensions:$E,getScale:IE,isElement:mE,isRTL:aD};function sD(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cD(e,t){let n=null,r,i=fE(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=wT(d),h=wT(i.clientWidth-(u+f)),g=wT(i.clientHeight-(d+p)),_=wT(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:ST(0,xT(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!sD(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function lD(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=FE(e),u=i||a?[...l?ME(l):[],...t?ME(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?cD(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?BE(e):null;c&&g();function g(){let t=BE(e);h&&!sD(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var uD=aE,dD=oE,fD=$T,pD=cE,mD=nE,hD=QT,gD=sE,_D=(e,t,n)=>{let r=new Map,i={platform:oD,...n},a={...i.platform,_c:r};return ZT(e,t,{...i,platform:a})},vD=typeof document<`u`?Q.useLayoutEffect:function(){};function yD(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!yD(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!yD(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function bD(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xD(e,t){let n=bD(e);return Math.round(t*n)/n}function SD(e){let t=Q.useRef(e);return vD(()=>{t.current=e}),t}function CD(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=Q.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=Q.useState(r);yD(f,r)||p(r);let[m,h]=Q.useState(null),[g,_]=Q.useState(null),v=Q.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=Q.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=Q.useRef(null),C=Q.useRef(null),w=Q.useRef(u),T=c!=null,E=SD(c),D=SD(i),O=SD(l),k=Q.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),_D(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!yD(w.current,t)&&(w.current=t,BC.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);vD(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Q.useRef(!1);vD(()=>(A.current=!0,()=>{A.current=!1}),[]),vD(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=Q.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=Q.useMemo(()=>({reference:b,floating:x}),[b,x]),N=Q.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=xD(M.floating,u.x),r=xD(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...bD(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return Q.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var wD=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:hD({element:r.current,padding:i}).fn(n):r?hD({element:r,padding:i}).fn(n):{}}}},TD=(e,t)=>{let n=uD(e);return{name:n.name,fn:n.fn,options:[e,t]}},ED=(e,t)=>{let n=dD(e);return{name:n.name,fn:n.fn,options:[e,t]}},DD=(e,t)=>({fn:gD(e).fn,options:[e,t]}),OD=(e,t)=>{let n=fD(e);return{name:n.name,fn:n.fn,options:[e,t]}},kD=(e,t)=>{let n=pD(e);return{name:n.name,fn:n.fn,options:[e,t]}},AD=(e,t)=>{let n=mD(e);return{name:n.name,fn:n.fn,options:[e,t]}},jD=(e,t)=>{let n=wD(e);return{name:n.name,fn:n.fn,options:[e,t]}},MD=`Arrow`,ND=Q.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(Kn.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});ND.displayName=MD;var PD=ND;function FD(e){let[t,n]=Q.useState(void 0);return ur(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var ID=`Popper`,[LD,RD]=Un(ID),[zD,BD]=LD(ID),VD=e=>{let{__scopePopper:t,children:n}=e,[r,i]=Q.useState(null);return(0,$.jsx)(zD,{scope:t,anchor:r,onAnchorChange:i,children:n})};VD.displayName=ID;var HD=`PopperAnchor`,UD=Q.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=BD(HD,n),o=Q.useRef(null),s=Yn(t,o),c=Q.useRef(null);return Q.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,$.jsx)(Kn.div,{...i,ref:s})});UD.displayName=HD;var WD=`PopperContent`,[GD,KD]=LD(WD),qD=Q.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=BD(WD,n),[_,v]=Q.useState(null),y=Yn(t,e=>v(e)),[b,x]=Q.useState(null),S=FD(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(ZD),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=CD({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>lD(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[TD({mainAxis:i+w,alignmentAxis:o}),c&&ED({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?DD():void 0,...k}),c&&OD({...k}),kD({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&jD({element:b,padding:s}),QD({arrowWidth:C,arrowHeight:w}),f&&AD({strategy:`referenceHidden`,...k})]}),[F,I]=$D(M),ee=$n(m);ur(()=>{N&&ee?.()},[N,ee]);let te=P.arrow?.x,L=P.arrow?.y,R=P.arrow?.centerOffset!==0,[z,B]=Q.useState();return ur(()=>{_&&B(window.getComputedStyle(_).zIndex)},[_]),(0,$.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:z,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(GD,{scope:n,placedSide:F,onArrowChange:x,arrowX:te,arrowY:L,shouldHideArrow:R,children:(0,$.jsx)(Kn.div,{"data-side":F,"data-align":I,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});qD.displayName=WD;var JD=`PopperArrow`,YD={top:`bottom`,right:`left`,bottom:`top`,left:`right`},XD=Q.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=KD(JD,n),a=YD[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(PD,{...r,ref:t,style:{...r.style,display:`block`}})})});XD.displayName=JD;function ZD(e){return e!==null}var QD=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=$D(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function $D(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var eO=VD,tO=UD,nO=qD,rO=XD;function iO(e){let t=aO(e),n=Q.forwardRef((e,n)=>{let{children:r,...i}=e,a=Q.Children.toArray(r),o=a.find(sO);if(o){let e=o.props.children,r=a.map(t=>t===o?Q.Children.count(e)>1?Q.Children.only(null):Q.isValidElement(e)?e.props.children:null:t);return(0,$.jsx)(t,{...i,ref:n,children:Q.isValidElement(e)?Q.cloneElement(e,void 0,r):null})}return(0,$.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function aO(e){let t=Q.forwardRef((e,t)=>{let{children:n,...r}=e;if(Q.isValidElement(n)){let e=lO(n),i=cO(r,n.props);return n.type!==Q.Fragment&&(i.ref=t?Jn(t,e):e),Q.cloneElement(n,i)}return Q.Children.count(n)>1?Q.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var oO=Symbol(`radix.slottable`);function sO(e){return Q.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===oO}function cO(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function lO(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function uO(e){let t=Q.useRef({value:e,previous:e});return Q.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var dO=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),fO=`VisuallyHidden`,pO=Q.forwardRef((e,t)=>(0,$.jsx)(Kn.span,{...e,ref:t,style:{...dO,...e.style}}));pO.displayName=fO;var mO=pO,hO=[` `,`Enter`,`ArrowUp`,`ArrowDown`],gO=[` `,`Enter`],_O=`Select`,[vO,yO,bO]=_T(_O),[xO,SO]=Un(_O,[bO,RD]),CO=RD(),[wO,TO]=xO(_O),[EO,DO]=xO(_O),OO=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=CO(t),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S=yT(l),[C,w]=Gn({prop:r,defaultProp:i??!1,onChange:a,caller:_O}),[T,E]=Gn({prop:o,defaultProp:s,onChange:c,caller:_O}),D=Q.useRef(null),O=!g||m||!!g.closest(`form`),[k,A]=Q.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,$.jsx)(eO,{...h,children:(0,$.jsxs)(wO,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Xn(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,$.jsx)(vO.Provider,{scope:t,children:(0,$.jsx)(EO,{scope:e.__scopeSelect,onNativeOptionAdd:Q.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Q.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,$.jsxs)(Ck,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,$.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};OO.displayName=_O;var kO=`SelectTrigger`,AO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=CO(n),o=TO(kO,n),s=o.disabled||r,c=Yn(t,o.onTriggerChange),l=yO(n),u=Q.useRef(`touch`),[d,f,p]=Tk(e=>{let t=l().filter(e=>!e.disabled),n=Ek(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,$.jsx)(tO,{asChild:!0,...a,children:(0,$.jsx)(Kn.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":wk(o.value)?``:void 0,...i,ref:c,onClick:lr(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:lr(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:lr(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&hO.includes(e.key)&&(m(),e.preventDefault())})})})});AO.displayName=kO;var jO=`SelectValue`,MO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=TO(jO,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Yn(t,c.onValueNodeChange);return ur(()=>{l(u)},[l,u]),(0,$.jsx)(Kn.span,{...s,ref:d,style:{pointerEvents:`none`},children:wk(c.value)?(0,$.jsx)($.Fragment,{children:o}):a})});MO.displayName=jO;var NO=`SelectIcon`,PO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,$.jsx)(Kn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});PO.displayName=NO;var FO=`SelectPortal`,IO=e=>(0,$.jsx)(Qn,{asChild:!0,...e});IO.displayName=FO;var LO=`SelectContent`,RO=Q.forwardRef((e,t)=>{let n=TO(LO,e.__scopeSelect),[r,i]=Q.useState();if(ur(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?BC.createPortal((0,$.jsx)(BO,{scope:e.__scopeSelect,children:(0,$.jsx)(vO.Slot,{scope:e.__scopeSelect,children:(0,$.jsx)(`div`,{children:e.children})})}),t):null}return(0,$.jsx)(WO,{...e,ref:t})});RO.displayName=LO;var zO=10,[BO,VO]=xO(LO),HO=`SelectContentImpl`,UO=iO(`SelectContent.RemoveScroll`),WO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=TO(LO,n),[y,b]=Q.useState(null),[x,S]=Q.useState(null),C=Yn(t,e=>b(e)),[w,T]=Q.useState(null),[E,D]=Q.useState(null),O=yO(n),[k,A]=Q.useState(!1),j=Q.useRef(!1);Q.useEffect(()=>{if(y)return yr(y)},[y]),nr();let M=Q.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=Q.useCallback(()=>M([w,y]),[M,w,y]);Q.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Q.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),Q.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,ee]=Tk(e=>{let t=O().filter(e=>!e.disabled),n=Ek(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),te=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),L=Q.useCallback(()=>y?.focus(),[y]),R=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),z=r===`popper`?JO:KO,B=z===JO?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,$.jsx)(BO,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:te,selectedItem:w,onItemLeave:L,itemTextRefCallback:R,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,$.jsx)(Sr,{as:UO,allowPinchZoom:!0,children:(0,$.jsx)(Wn,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:lr(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,$.jsx)(br,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,$.jsx)(z,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:lr(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ee(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});WO.displayName=HO;var GO=`SelectItemAlignedPosition`,KO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=TO(LO,n),o=VO(LO,n),[s,c]=Q.useState(null),[l,u]=Q.useState(null),d=Yn(t,e=>u(e)),f=yO(n),p=Q.useRef(!1),m=Q.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Q.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zO,d=uT(a,[zO,Math.max(zO,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zO,d=uT(a,[zO,Math.max(zO,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-zO*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-zO,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${zO}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);ur(()=>y(),[y]);let[b,x]=Q.useState();return ur(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,$.jsx)(YO,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Q.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,$.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,$.jsx)(Kn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});KO.displayName=GO;var qO=`SelectPopperPosition`,JO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=zO,...a}=e,o=CO(n);return(0,$.jsx)(nO,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});JO.displayName=qO;var[YO,XO]=xO(LO,{}),ZO=`SelectViewport`,QO=Q.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=VO(ZO,n),o=XO(ZO,n),s=Yn(t,a.onViewportChange),c=Q.useRef(0);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,$.jsx)(vO.Slot,{scope:n,children:(0,$.jsx)(Kn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:lr(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-zO*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});QO.displayName=ZO;var $O=`SelectGroup`,[ek,tk]=xO($O),nk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Xn();return(0,$.jsx)(ek,{scope:n,id:i,children:(0,$.jsx)(Kn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});nk.displayName=$O;var rk=`SelectLabel`,ik=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=tk(rk,n);return(0,$.jsx)(Kn.div,{id:i.id,...r,ref:t})});ik.displayName=rk;var ak=`SelectItem`,[ok,sk]=xO(ak),ck=Q.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=TO(ak,n),c=VO(ak,n),l=s.value===r,[u,d]=Q.useState(a??``),[f,p]=Q.useState(!1),m=Yn(t,e=>c.itemRefCallback?.(e,r,i)),h=Xn(),g=Q.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,$.jsx)(ok,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Q.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,$.jsx)(vO.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,$.jsx)(Kn.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:lr(o.onFocus,()=>p(!0)),onBlur:lr(o.onBlur,()=>p(!1)),onClick:lr(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:lr(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:lr(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:lr(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:lr(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:lr(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(gO.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});ck.displayName=ak;var lk=`SelectItemText`,uk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=TO(lk,n),s=VO(lk,n),c=sk(lk,n),l=DO(lk,n),[u,d]=Q.useState(null),f=Yn(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Q.useMemo(()=>(0,$.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return ur(()=>(h(m),()=>g(m)),[h,g,m]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Kn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?BC.createPortal(a.children,o.valueNode):null]})});uk.displayName=lk;var dk=`SelectItemIndicator`,fk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return sk(dk,n).isSelected?(0,$.jsx)(Kn.span,{"aria-hidden":!0,...r,ref:t}):null});fk.displayName=dk;var pk=`SelectScrollUpButton`,mk=Q.forwardRef((e,t)=>{let n=VO(pk,e.__scopeSelect),r=XO(pk,e.__scopeSelect),[i,a]=Q.useState(!1),o=Yn(t,r.onScrollButtonChange);return ur(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,$.jsx)(_k,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});mk.displayName=pk;var hk=`SelectScrollDownButton`,gk=Q.forwardRef((e,t)=>{let n=VO(hk,e.__scopeSelect),r=XO(hk,e.__scopeSelect),[i,a]=Q.useState(!1),o=Yn(t,r.onScrollButtonChange);return ur(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,$.jsx)(_k,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});gk.displayName=hk;var _k=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=VO(`SelectScrollButton`,n),o=Q.useRef(null),s=yO(n),c=Q.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Q.useEffect(()=>()=>c(),[c]),ur(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,$.jsx)(Kn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:lr(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:lr(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:lr(i.onPointerLeave,()=>{c()})})}),vk=`SelectSeparator`,yk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,$.jsx)(Kn.div,{"aria-hidden":!0,...r,ref:t})});yk.displayName=vk;var bk=`SelectArrow`,xk=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=CO(n),a=TO(bk,n),o=VO(bk,n);return a.open&&o.position===`popper`?(0,$.jsx)(rO,{...i,...r,ref:t}):null});xk.displayName=bk;var Sk=`SelectBubbleInput`,Ck=Q.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Q.useRef(null),a=Yn(r,i),o=uO(t);return Q.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,$.jsx)(Kn.select,{...n,style:{...dO,...n.style},ref:a,defaultValue:t})});Ck.displayName=Sk;function wk(e){return e===``||e===void 0}function Tk(e){let t=$n(e),n=Q.useRef(``),r=Q.useRef(0),i=Q.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Q.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Q.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Ek(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Dk(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Dk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ok=OO,kk=AO,Ak=MO,jk=PO,Mk=IO,Nk=RO,Pk=QO,Fk=ik,Ik=ck,Lk=uk,Rk=fk,zk=mk,Bk=gk,Vk=yk,Hk=`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground outline-none transition-colors hover:bg-surface/70 focus-visible:ring-2 focus-visible:ring-accent-primary/50 disabled:cursor-not-allowed disabled:opacity-50`,Uk=`overflow-hidden rounded-xl border border-border/60 bg-card/95 shadow-2xl backdrop-blur-xl`,Wk=`flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-sm text-foreground outline-none hover:bg-surface/70 focus-visible:bg-surface/70`;function Gk({label:e,value:t,options:n,icon:r,onSelect:i,placeholder:a,disabled:o=!1,testId:s}){return(0,$.jsxs)(Ok,{value:t,onValueChange:i,disabled:o||n.length===0,children:[(0,$.jsxs)(kk,{"aria-label":e,title:e,"data-agent-interactive":!0,"data-testid":s,className:Hk,children:[(0,$.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(Ak,{placeholder:a??e,className:`max-w-[160px] truncate`}),(0,$.jsx)(jk,{asChild:!0,children:(0,$.jsx)(rc,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})})]}),(0,$.jsx)(Mk,{children:(0,$.jsxs)(Nk,{position:`popper`,side:`top`,align:`start`,sideOffset:4,collisionPadding:8,className:`z-[80] min-w-[12rem] max-w-[20rem] ${Uk} data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1`,children:[(0,$.jsx)(zk,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,$.jsx)(Sn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Pk,{className:`max-h-72 py-1`,children:n.map(e=>{let t=e.icon??r;return(0,$.jsxs)(Ik,{value:e.value,className:`${Wk} relative cursor-default select-none pr-9 data-[highlighted]:bg-surface/70 data-[state=checked]:font-medium`,children:[(0,$.jsx)(t,{className:`h-4 w-4 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(Lk,{children:(0,$.jsx)(`span`,{className:`truncate`,children:e.label})}),(0,$.jsx)(Rk,{className:`absolute right-3 flex items-center`,children:(0,$.jsx)(xn,{className:`h-3.5 w-3.5 text-accent-primary`})})]},e.value)})}),(0,$.jsx)(Bk,{className:`flex items-center justify-center py-1 text-foreground/50`,children:(0,$.jsx)(rc,{className:`h-3.5 w-3.5`})})]})})]})}var Kk=`__new__`,qk=`__legacy__`,Jk=`__default__`,Yk=12,Xk=`specrails:focus-pr-card`,Zk=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-CkAejD1F.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,77,78,79,80,81,82,83,84,85,86,87])));function Qk(e,t,n){if(e.availability)return e.availability;let r=String(e.railIndex);if(t.activeJobs?.[r]||t.activeLoopRuns?.[r])return`busy`;let i=t.prDeliveries?.[r];return i&&i.decision&&![`merged`,`discarded`,`completed`,`superseded`,`pr_ready`].includes(i.decision)?`pending_decision`:e.ticketIds.some(e=>n.find(t=>t.id===e)?.status===`on_review`)?`on_review`:`free`}function $k(e,t){let n=e(`railCard.rail`,{index:t.railIndex+1});return t.name?`${n} · ${t.name}`:n}function eA(e,t){return e.repositoryIds??t.filter(e=>e.isPrimary).map(e=>e.id)}function tA(e,t,n){return[...new Set(e.filter(e=>t.includes(e.id)).flatMap(e=>eA(e,n)))]}function nA(e,t,n){return[...new Set([...e.filter(e=>!t.includes(e)||n.includes(e)),...n])]}function rA(e,t){if(!e)return;let n=Object.entries(e).filter(([e])=>t.includes(e));return n.length?Object.fromEntries(n):void 0}function iA({proposal:e,proposalIndex:t,messageId:n,conversationId:r,projectId:i,intent:a,compact:o=!1}){let{t:s}=U(`agent`),c=AS(),l=Yw(),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)([]),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(0),[w,T]=(0,Q.useState)(-1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),P=(0,Q.useRef)(i);P.current=i,(0,Q.useEffect)(()=>{if(!i||a)return;let t=!1;D(!1),j(null),N(null),k(null);let n=Or(i);return Promise.all([fetch(`${n}/rails`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))),fetch(`${n}/tickets`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))),fetch(`${n}/repositories`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status))))]).then(([n,r,a])=>{if(t)return;if(!Array.isArray(a.repositories)||!a.repositories.some(e=>e.isPrimary))throw Error(`Missing project repositories`);let o=Array.isArray(r?.tickets)?r.tickets:[];d(n&&typeof n==`object`?n:{}),p(o),y(a.repositories),x(i),T(S),I(t=>{let n=b===i?tA(f??[],t.ticketIds,v):[],r=nA(b===i?t.repositoryIds??n:e.repositoryIds??[],n,tA(o,t.ticketIds,a.repositories));return{...t,repositoryIds:r,workspaceSelection:rA(t.workspaceSelection,r)}})}).catch(()=>{t||D(!0)}),st&&oT.list().then(e=>{t||_(e.filter(e=>e.status===`published`&&lT(e.graph)))}).catch(()=>{}),()=>{t=!0}},[i,a,S]);let[F,I]=(0,Q.useState)(()=>({railIndex:e.railIndex,newRail:!!e.newRail,railName:e.newRail?.name??e.railName??``,ticketIds:e.ticketIds,repositoryIds:e.repositoryIds,workspaceSelection:e.workspaceSelection,loopId:e.loopId??eT(null,e.mode),aiEngine:e.aiEngine,model:e.model,reasoningEffort:e.reasoningEffort,profileName:e.profileName,targetPrNumber:e.targetPrNumber,baseBranch:e.baseBranch??``,followUp:e.followUp??null})),ee=(0,Q.useCallback)(e=>I(t=>({...t,...e})),[]),te=l.detected,L=!l.loading,R=(0,Q.useMemo)(()=>F.aiEngine&&($t(F.aiEngine)||te.includes(F.aiEngine))?F.aiEngine:te[0]??null,[F.aiEngine,te]),z=!!F.aiEngine&&L&&R!==F.aiEngine,B=!!R&&$t(R),ne=R&&!$t(R)?R:te[0]??null,V=(0,Q.useMemo)(()=>Kw(ne),[ne]),re=(0,Q.useMemo)(()=>F.model&&V.some(e=>e.value===F.model)?F.model:qw(ne)||null,[F.model,V,ne]),ie=!!F.model&&V.length>0&&re!==F.model,ae=(0,Q.useMemo)(()=>qt(ne,re),[ne,re]),H=F.reasoningEffort&&ae.includes(F.reasoningEffort)?F.reasoningEffort:null,W=!!f?.some(e=>F.ticketIds.includes(e.id)&&qe(e.addenda).length>0),G=$w(eT(F.loopId,`loop`,W)),oe=!B&&G!==`loop`&&Xt(ne);(0,Q.useEffect)(()=>{if(!i||a||!ne||!oe){h([]);return}let e=!1;return fetch(`${Or(i)}/profiles?provider=${encodeURIComponent(ne)}`).then(e=>e.ok?e.json():{profiles:[]}).then(t=>{if(e)return;let n=Array.isArray(t.profiles)?t.profiles.filter(e=>!e.provider||e.provider===ne):[];h(n)}).catch(()=>{e||h([])}),()=>{e=!0}},[i,a,ne,oe]);let se=F.profileName&&m.some(e=>e.name===F.profileName)?F.profileName:null,ce=(0,Q.useMemo)(()=>u?.rails??[],[u]),K=(0,Q.useMemo)(()=>{let e=new Map;if(!u)return e;for(let t of ce)e.set(t.railIndex,Qk(t,u,f??[]));return e},[ce,u,f]),le=F.railIndex===null?void 0:ce.find(e=>e.railIndex===F.railIndex),ue=u!==null&&F.railIndex!==null&&!F.newRail&&!le,de=!!le&&!F.newRail&&K.get(le.railIndex)!==`free`&&K.get(le.railIndex)!==void 0&&!(W&&K.get(le.railIndex)!==`busy`&&le.ticketIds.length===F.ticketIds.length&&le.ticketIds.every(e=>F.ticketIds.includes(e))),fe=ce.length>=Yk,pe=(W?ce.find(e=>K.get(e.railIndex)!==`busy`&&e.ticketIds.length===F.ticketIds.length&&e.ticketIds.every(e=>F.ticketIds.includes(e))):void 0)??ce.find(e=>K.get(e.railIndex)===`free`),q=F.newRail?Kk:F.railIndex!==null&&le?String(F.railIndex):pe?String(pe.railIndex):fe?``:Kk,me=F.newRail||q===Kk||q===``?null:Number(q),he=q===Kk,ge=(0,Q.useMemo)(()=>new Map((f??[]).map(e=>[e.id,e])),[f]),_e=(0,Q.useMemo)(()=>f?F.ticketIds.filter(e=>ge.has(e)):F.ticketIds,[F.ticketIds,ge,f]),J=f?F.ticketIds.filter(e=>!ge.has(e)):[],ye=tA(f??[],_e,v),be=F.repositoryIds??ye,xe=e=>v.find(t=>t.id===e)?.name??e,Se=ye.filter(e=>!be.includes(e)),Ce=be.filter(e=>{let t=v.find(t=>t.id===e);return!t||t.available===!1||t.kind===`folder`&&!t.isPrimary}),we=!!i&&!E&&(b!==i||w!==S||u===null||f===null),Te=Ce.length?s(`railCard.repositories.unavailable`,{names:Ce.map(xe).join(`, `)}):Se.length?s(`railCard.repositories.missing`,{names:Se.map(xe).join(`, `)}):null,Ee=e=>{ee({repositoryIds:e,workspaceSelection:rA(F.workspaceSelection,e)}),N(null)},De=e=>{let t=tA(f??[],e,v),n=nA(be,ye,t);ee({ticketIds:e,repositoryIds:n,workspaceSelection:rA(F.workspaceSelection,n)}),j(null),N(null)},ke=(0,Q.useMemo)(()=>_e.flatMap(e=>qe(ge.get(e)?.addenda).map(t=>({ticketId:e,title:t.title}))),[_e,ge]),Ae=ke.length,je=ke.slice(0,3).map(e=>`#${e.ticketId} ${e.title}`),Me=(0,Q.useMemo)(()=>(f??[]).filter(e=>(e.status===`todo`||e.status===`draft`)&&!F.ticketIds.includes(e.id)),[f,F.ticketIds]),Ne=!B&&Yt(ne),Pe=(0,Q.useMemo)(()=>[...Zw.filter(e=>(!e.requiresFreestyle||Ne)&&(!e.requiresLoops||st)).map(e=>({value:e.id,label:s(`dashboard:${e.labelKey}`)})),...g.map(e=>({value:e.id,label:e.name}))],[g,Ne,s]),Fe=eT(Pe.some(e=>e.value===F.loopId)?F.loopId:Pe[0]?.value??F.loopId,G,W),[Ie,Le]=(0,Q.useState)(null),Re=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(Re.current=!0,()=>{Re.current=!1}),[]);let ze=a??Ie,Be=i?E?s(`railCard.block.loadFailed`):we?s(`railCard.status.loading`):A?s(`railCard.repositories.finishEditing`):_e.length===0?s(`railCard.block.noSpecs`):Te?s(`railCard.repositories.checkScope`):q===``?s(`railCard.block.railLimit`,{max:Yk}):null:s(`railCard.block.noProject`),Ve=async()=>{if(!A||!i||O||we)return;let e=i,t=A;k(`scope`),N(null);try{let n=await fetch(`${Or(e)}/tickets/${t.ticketId}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({repositoryIds:t.repositoryIds})}),r=await n.json();if(!n.ok)throw Error(r.detail??r.error??`HTTP ${n.status}`);if(r.ticket?.id!==t.ticketId)throw Error(s(`railCard.errors.invalid_response`));if(!Re.current||P.current!==e)return;let i=(f??[]).map(e=>e.id===t.ticketId?r.ticket:e),a=tA(i,_e,v),o=nA(be,ye,a);p(i),ee({repositoryIds:o,workspaceSelection:rA(F.workspaceSelection,o)}),j(null)}catch(t){Re.current&&P.current===e&&N({error:`scope_save_failed`,detail:t instanceof Error?t.message:void 0})}finally{Re.current&&P.current===e&&k(null)}},He=(0,Q.useCallback)(async e=>{let t=await ts(r,n,e),i=t.ok?t.intent:{...e,at:new Date().toISOString()};zw(n,i),Re.current&&Le(i)},[r,n]),Ue=(0,Q.useCallback)(async()=>{if(!i||Be||O)return;k(`launch`),N(null);let e=`${Or(i)}/rails`,n={"content-type":`application/json`},a=async e=>{let t={};try{t=await e.json()}catch{}return{error:typeof t.error==`string`?t.error:`HTTP ${e.status}`,detail:typeof t.detail==`string`?t.detail:void 0,action:typeof t.action==`string`?t.action:void 0}};try{let o=me,s=F.railName.trim().slice(0,60);if(o===null){let t=await fetch(e,{method:`POST`,headers:n,body:JSON.stringify({name:s||null})});if(!t.ok){N(await a(t));return}let r=await t.json();if(typeof r.rail?.railIndex!=`number`){N({error:`invalid_response`});return}o=r.rail.railIndex}else if(s&&s!==(le?.name??``)){let t=await fetch(`${e}/${o}/name`,{method:`PUT`,headers:n,body:JSON.stringify({name:s})});if(!t.ok){N(await a(t));return}}let c=R&&te.length>1?R:void 0,l=await fetch(`${e}/${o}/tickets`,{method:`PUT`,headers:n,body:JSON.stringify({ticketIds:_e,mode:G,profileName:oe?se:null,...c?{aiEngine:c}:{}})});if(!l.ok){N(await a(l));return}let u={mode:G,loopId:Fe,originConversationId:r,originSurface:`agent-chat`,repositoryIds:be,...F.workspaceSelection?{workspaceSelection:rA(F.workspaceSelection,be)}:{},...c?{aiEngine:c}:{},...!B&&re?{model:re}:{},...!B&&H?{reasoning_effort:H}:{},...oe&&se?{profileName:se}:{},...F.targetPrNumber?{targetPrNumber:F.targetPrNumber}:{},...F.baseBranch.trim()?{baseBranch:F.baseBranch.trim()}:{},...F.followUp?{followUp:F.followUp}:{}},d=await fetch(`${e}/${o}/launch`,{method:`POST`,headers:n,body:JSON.stringify(u)});if(!d.ok){N(await a(d));return}let f=await d.json(),p=Array.isArray(f.loopRunIds)&&f.loopRunIds.length?f.loopRunIds:Array.isArray(f.jobIds)&&f.jobIds.length?f.jobIds:f.jobId?[f.jobId]:[];Et(i),await He({kind:`rail-launch`,proposalIndex:t,status:`launched`,railIndex:o,runIds:p,prDeliveryId:typeof f.prDeliveryId==`string`?f.prDeliveryId:null,config:{...u,ticketIds:_e,railName:s||null}})}catch(e){N({error:e instanceof Error?e.message:`network`})}finally{Re.current&&k(null)}},[i,Be,O,me,F,be,le,R,B,te.length,_e,G,oe,se,Fe,re,H,r,t,He]),We=(0,Q.useCallback)(async()=>{if(!O){k(`dismiss`);try{await He({kind:`rail-launch`,proposalIndex:t,status:`dismissed`})}finally{Re.current&&k(null)}}},[O,He,t]),[Ge,Ke]=(0,Q.useState)(null);if(ze){let t=ze.status===`launched`,n=ze.runIds?.[0]??null;return(0,$.jsxs)(`div`,{"data-testid":t?`agent-rail-launch-stub-launched`:`agent-rail-launch-stub-dismissed`,className:X(`my-1 flex items-center gap-2 rounded-xl border px-3 py-2 text-xs backdrop-blur`,t?`border-accent-success/30 bg-accent-success/[0.06] text-foreground/80`:`border-border/50 bg-surface/40 text-foreground/50`),children:[t?(0,$.jsx)(sc,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(bn,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t?s(`railCard.stub.launched`,{rail:typeof ze.railIndex==`number`?ze.railIndex+1:`?`}):s(`railCard.stub.dismissed`),` `,(0,$.jsx)(`span`,{className:`text-foreground/50`,children:e.ticketIds.map(e=>`#${e}`).join(` `)})]}),t&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-rail-launch-focus-card`,title:s(`railCard.stub.goToCardTitle`),onClick:()=>{window.dispatchEvent(new CustomEvent(Xk,{detail:{prDeliveryId:ze.prDeliveryId??null,runIds:ze.runIds??[]}}))},className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-border/60 bg-card/70 px-2 py-0.5 text-[11px] font-medium text-foreground/70 transition-colors hover:border-accent-primary/40 hover:text-foreground`,children:[(0,$.jsx)(xu,{className:`h-3 w-3`}),s(`railCard.stub.goToCard`)]}),t&&i&&n&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-rail-launch-view-run`,title:s(`railCard.stub.viewRunTitle`),onClick:()=>Ke(n),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-accent-primary/40 bg-accent-primary/10 px-2 py-0.5 text-[11px] font-medium text-accent-primary transition-colors hover:bg-accent-primary/20`,children:[(0,$.jsx)(Dn,{className:`h-3 w-3`}),s(`railCard.stub.viewRun`)]}),Ge&&i&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zk,{jobId:Ge,projectId:i,onClose:()=>Ke(null)})})]})}let Je=[...ce.map(e=>{let t=K.get(e.railIndex),n=t&&t!==`free`?` · ${s(`railCard.availability.${t}`)}`:``;return{value:String(e.railIndex),label:`${$k(s,e)}${n}`}}),...fe?[]:[{value:Kk,label:s(`railCard.newRail`),icon:Pn}]],Ye=[...te.map(e=>({value:e,label:l.providers[e]?.displayName??sn(e)}))],Xe=V.map(e=>({value:e.value,label:e.label??e.value})),Ze=[{value:Jk,label:s(`railCard.effortDefault`)},...ae.map(e=>({value:e,label:s(`effort.${e}`,{defaultValue:e})}))],Qe=[{value:qk,label:s(`railCard.profileNone`)},...m.map(e=>({value:e.name,label:e.name}))],$e=we?{tone:`border-border/60 bg-surface/60 text-foreground/50`,label:s(`railCard.status.loading`)}:Be?{tone:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,label:s(`railCard.status.blocked`)}:{tone:`border-accent-primary/40 bg-accent-primary/10 text-accent-primary`,label:s(`railCard.status.ready`)};return(0,$.jsxs)(jS.div,{initial:!c&&{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.22,ease:`easeOut`},"data-testid":`agent-rail-launch-card`,className:X(`my-1 overflow-hidden rounded-xl border border-accent-primary/25 bg-card/80 shadow-lg backdrop-blur`,o&&`my-0`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/40 bg-accent-primary/[0.06] px-3.5 py-2`,children:[(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[10px] font-semibold uppercase tracking-widest text-accent-primary/90`,children:[(0,$.jsx)(Vu,{className:`h-3 w-3`}),s(`railCard.heading`)]}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-foreground/55`,children:_e.map(e=>`#${e}`).join(` `)}),(0,$.jsx)(`span`,{className:X(`inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,$e.tone),children:$e.label})]}),(0,$.jsxs)(`div`,{className:`space-y-2.5 px-3.5 py-3`,children:[e.rationale&&(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs italic text-foreground/60`,children:[(0,$.jsx)(Ln,{className:`mt-0.5 h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{children:e.rationale})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(Gk,{label:s(`railCard.fields.rail`),icon:Td,value:q,options:Je,disabled:we||!!O,testId:`rail-card-rail`,onSelect:e=>ee(e===Kk?{newRail:!0,railIndex:null}:{newRail:!1,railIndex:Number(e)})}),(he||le)&&(0,$.jsx)(`input`,{type:`text`,"data-agent-interactive":!0,"data-testid":`rail-card-name`,value:F.railName,maxLength:60,placeholder:s(he?`railCard.fields.newRailName`:`railCard.fields.railName`),onChange:e=>ee({railName:e.target.value}),className:`h-7 min-w-[120px] flex-1 rounded-md border border-border/60 bg-surface/50 px-2 text-xs text-foreground outline-none placeholder:text-foreground/35 focus:border-accent-primary/50`})]}),ue&&(0,$.jsx)(aA,{tone:`warning`,text:s(`railCard.notes.railMissing`,{index:(F.railIndex??0)+1})}),de&&le&&(0,$.jsx)(aA,{tone:`warning`,text:s(`railCard.notes.railBusy`,{index:le.railIndex+1,state:s(`railCard.availability.${K.get(le.railIndex)??`busy`}`)}),action:pe?{label:s(`railCard.notes.useFree`,{index:pe.railIndex+1}),onClick:()=>ee({newRail:!1,railIndex:pe.railIndex})}:void 0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`rail-card-specs`,children:[_e.map(e=>{let t=ge.get(e);return(0,$.jsxs)(`span`,{title:t?.title,className:`inline-flex max-w-[220px] items-center gap-1 rounded-full border border-accent-primary/35 bg-accent-primary/10 py-0.5 pl-2 pr-1 text-[11px] font-medium text-accent-primary`,children:[(0,$.jsxs)(`span`,{className:`truncate`,children:[`#`,e,t?` ${t.title}`:``]}),(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,"aria-label":s(`railCard.fields.removeSpec`,{id:e}),disabled:we||!!O,onClick:()=>De(F.ticketIds.filter(t=>t!==e)),className:`rounded-full p-0.5 text-accent-primary/60 hover:bg-accent-primary/20 hover:text-accent-primary`,children:(0,$.jsx)(Vn,{className:`h-3 w-3`})})]},e)}),Me.length>0&&(0,$.jsx)(Gk,{label:s(`railCard.fields.addSpec`),icon:Pn,value:``,placeholder:s(`railCard.fields.addSpec`),options:Me.slice(0,40).map(e=>({value:String(e.id),label:`#${e.id} ${e.title}`})),disabled:we||!!O,testId:`rail-card-add-spec`,onSelect:e=>De([...F.ticketIds,Number(e)])})]}),!we&&!E&&i&&(0,$.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border border-border/50 bg-surface/30 p-2.5`,"data-testid":`rail-card-repositories`,children:[(0,$.jsx)(Ar,{showSingle:!0,repositories:v,value:be,onChange:Ee,disabled:!!O||!!A,label:s(`railCard.repositories.launch`),hint:s(`railCard.repositories.launchHint`)}),(0,$.jsxs)(`div`,{className:`space-y-1.5 border-t border-border/40 pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-foreground/55`,children:s(`railCard.repositories.assignments`)}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:!!O||!!A,className:`inline-flex items-center gap-1 text-[11px] text-foreground/60 hover:text-accent-primary disabled:opacity-40`,onClick:()=>C(e=>e+1),children:[(0,$.jsx)(Lu,{className:`h-3 w-3`}),s(`railCard.repositories.refresh`)]})]}),_e.map(e=>{let t=ge.get(e),n=A?.ticketId===e,r=!!A?.repositoryIds.length&&A.repositoryIds.every(e=>v.some(t=>t.id===e&&t.available!==!1&&(t.kind===`git`||t.isPrimary)));return(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`rail-card-spec-scope-${e}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,$.jsxs)(`span`,{className:`shrink-0 text-accent-primary`,title:t.title,children:[`#`,e]}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-foreground/75`,children:eA(t,v).map(xe).join(` · `)}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"aria-label":s(`railCard.repositories.editSpec`,{id:e}),disabled:!!O||!!A,className:`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-1 text-foreground/60 hover:bg-accent-primary/10 hover:text-accent-primary disabled:opacity-40`,onClick:()=>{j({ticketId:e,repositoryIds:eA(t,v)}),N(null)},children:[(0,$.jsx)(jn,{className:`h-3 w-3`}),s(`railCard.repositories.edit`)]})]}),n&&A&&(0,$.jsxs)(`div`,{className:`space-y-2 rounded-md border border-accent-primary/25 p-2`,"data-testid":`rail-card-scope-editor`,children:[(0,$.jsx)(Ar,{showSingle:!0,repositories:v,value:A.repositoryIds,onChange:t=>j({ticketId:e,repositoryIds:t}),disabled:!!O,label:s(`railCard.repositories.spec`,{id:e}),hint:s(`railCard.repositories.saveHint`)}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:!!O,className:`rounded px-2 py-1 text-xs text-foreground/65 hover:bg-surface`,onClick:()=>{j(null),N(null)},children:s(`railCard.repositories.cancel`)}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:!!O||!r,className:`inline-flex items-center gap-1 rounded bg-accent-primary/15 px-2 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-40`,onClick:()=>void Ve(),children:[O===`scope`&&(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}),s(`railCard.repositories.save`)]})]})]})]},e)})]}),(0,$.jsx)(Ar,{workspaceOnly:!0,repositories:v,value:be,onChange:()=>{},workspaceSelection:F.workspaceSelection,onWorkspaceChange:e=>ee({workspaceSelection:e}),disabled:!!O||!!A}),Te&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-accent-warning`,children:Te})]}),J.length>0&&(0,$.jsx)(aA,{tone:`muted`,text:s(`railCard.notes.specsDropped`,{ids:J.map(e=>`#${e}`).join(`, `)})}),Ae>0&&(0,$.jsxs)(`div`,{"data-testid":`rail-card-addenda`,className:`flex items-start gap-1.5 rounded-lg border border-accent-primary/25 bg-accent-primary/[0.05] px-2.5 py-1.5 text-[11px] text-foreground/75`,children:[(0,$.jsx)(kn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary/80`}),(0,$.jsxs)(`span`,{children:[s(`railCard.addenda.rides`,{count:Ae}),` `,(0,$.jsx)(`span`,{className:`text-foreground/50`,children:je.join(` · `)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1 gap-y-1`,children:[(0,$.jsx)(Gk,{label:s(`railCard.fields.loop`),icon:Fd,value:Fe,options:Pe,disabled:!!O,testId:`rail-card-loop`,onSelect:e=>ee({loopId:e})}),Ye.length>1&&(0,$.jsx)(Gk,{label:s(`railCard.fields.engine`),icon:Fc,value:R??``,options:Ye,disabled:!!O,testId:`rail-card-engine`,onSelect:e=>ee({aiEngine:e,model:null,reasoningEffort:null,profileName:null})}),!B&&Xe.length>0&&(0,$.jsx)(Gk,{label:s(`railCard.fields.model`),icon:Us,value:re??``,options:Xe,disabled:!!O,testId:`rail-card-model`,onSelect:e=>ee({model:e})}),!B&&ae.length>0&&(0,$.jsx)(Gk,{label:s(`railCard.fields.effort`),icon:dl,value:H??Jk,options:Ze,disabled:!!O,testId:`rail-card-effort`,onSelect:e=>ee({reasoningEffort:e===Jk?null:e})}),oe&&m.length>0&&(0,$.jsx)(Gk,{label:s(`railCard.fields.profile`),icon:Dd,value:se??qk,options:Qe,disabled:!!O,testId:`rail-card-profile`,onSelect:e=>ee({profileName:e===qk?null:e})})]}),z&&(0,$.jsx)(aA,{tone:`muted`,text:s(`railCard.notes.engineStale`,{engine:F.aiEngine,fallback:R?sn(R):``})}),ie&&(0,$.jsx)(aA,{tone:`muted`,text:s(`railCard.notes.modelStale`,{model:F.model,fallback:re})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-foreground/60`,children:[(0,$.jsx)(ve,{className:`h-3.5 w-3.5 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`sr-only`,children:s(`railCard.fields.targetPr`)}),(0,$.jsx)(`input`,{type:`number`,min:1,inputMode:`numeric`,"data-agent-interactive":!0,"data-testid":`rail-card-target-pr`,value:F.targetPrNumber??``,placeholder:s(`railCard.fields.targetPr`),disabled:!!O,onChange:e=>ee({targetPrNumber:e.target.value?Math.max(1,Math.floor(Number(e.target.value))):null}),className:`h-7 w-28 rounded-md border border-border/60 bg-surface/50 px-2 text-xs text-foreground outline-none placeholder:text-foreground/35 focus:border-accent-primary/50`})]}),(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-foreground/60`,children:[(0,$.jsx)(On,{className:`h-3.5 w-3.5 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`sr-only`,children:s(`railCard.fields.baseBranch`)}),(0,$.jsx)(`input`,{type:`text`,"data-agent-interactive":!0,"data-testid":`rail-card-base-branch`,value:F.baseBranch,placeholder:s(`railCard.fields.baseBranch`),disabled:!!O,onChange:e=>ee({baseBranch:e.target.value}),className:`h-7 w-40 rounded-md border border-border/60 bg-surface/50 px-2 text-xs text-foreground outline-none placeholder:text-foreground/35 focus:border-accent-primary/50`})]})]}),F.followUp&&(0,$.jsxs)(`div`,{"data-testid":`rail-card-follow-up`,className:`rounded-lg border border-accent-primary/25 bg-accent-primary/[0.05] px-2.5 py-2 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-foreground/85`,children:[(0,$.jsx)(Oe,{className:`h-3.5 w-3.5 text-accent-primary/80`}),s(`railCard.followUp.title`,{count:F.followUp.comments.length})]}),(0,$.jsx)(`span`,{className:`text-foreground/55`,children:F.followUp.scope.objective})]}),(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:F.followUp.comments.map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2 text-foreground/75`,children:[(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface/70 px-1 font-mono text-[10px] text-foreground/60`,children:e.id}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[e.path?(0,$.jsxs)(`span`,{className:`font-mono text-[11px] text-accent-info`,children:[e.path,e.line?`:${e.line}`:``,` · `]}):null,(0,$.jsx)(`span`,{className:`line-clamp-2`,children:e.body}),(0,$.jsx)(`span`,{className:`ml-1 text-[10px] text-foreground/45`,children:s(`railCard.followUp.source.${e.source===`github`?`github`:`pasted`}`)})]})]},e.id))}),F.followUp.scope.excludedChanges.length>0&&(0,$.jsxs)(`div`,{className:`mt-1.5 text-foreground/60`,children:[(0,$.jsxs)(`span`,{className:`font-medium`,children:[s(`railCard.followUp.excluded`),`:`]}),` `,F.followUp.scope.excludedChanges.join(` · `)]}),F.followUp.scope.verification.length>0&&(0,$.jsxs)(`div`,{className:`mt-1 text-foreground/60`,children:[(0,$.jsxs)(`span`,{className:`font-medium`,children:[s(`railCard.followUp.verification`),`:`]}),` `,F.followUp.scope.verification.join(` · `)]}),(0,$.jsx)(`div`,{className:`mt-1.5 text-[11px] text-foreground/45`,children:s(`railCard.followUp.specUntouched`)})]}),M&&(0,$.jsxs)(`div`,{"data-testid":`rail-card-error`,className:`flex items-start gap-2 rounded-lg border border-destructive/35 bg-destructive/10 px-2.5 py-1.5 text-xs text-destructive`,children:[(0,$.jsx)(zn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:s(`railCard.errors.${M.error}`,{defaultValue:M.error})}),M.detail&&(0,$.jsx)(`div`,{className:`text-destructive/80`,children:M.detail}),M.action&&(0,$.jsx)(`div`,{className:`text-foreground/70`,children:M.action})]})]}),E&&i&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:!!O,className:`inline-flex items-center gap-1 text-xs text-accent-primary`,onClick:()=>C(e=>e+1),children:[(0,$.jsx)(Lu,{className:`h-3 w-3`}),s(`railCard.repositories.retry`)]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-0.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-[11px] text-foreground/45`,children:Be??s(`railCard.playHint`)}),(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`rail-card-dismiss`,disabled:!!O,onClick:()=>void We(),className:`rounded-md px-2 py-1 text-xs text-foreground/60 transition-colors hover:bg-surface hover:text-foreground disabled:opacity-50`,children:s(`railCard.dismiss`)}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`rail-card-play`,disabled:!!O||we||!!Be,onClick:()=>void Ue(),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-3 py-1 text-xs font-semibold text-white shadow transition-colors hover:bg-accent-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[O===`launch`?(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Mn,{className:`h-3.5 w-3.5`}),s(O===`launch`?`railCard.launching`:`railCard.play`)]})]})]})]})}function aA({tone:e,text:t,action:n}){return(0,$.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-lg border px-2.5 py-1 text-[11px]`,e===`warning`?`border-accent-warning/35 bg-accent-warning/10 text-accent-warning`:`border-border/50 bg-surface/40 text-foreground/55`),children:[e===`warning`&&(0,$.jsx)(zn,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),n&&(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:n.onClick,className:`shrink-0 rounded px-1.5 py-0.5 font-medium underline-offset-2 hover:underline`,children:n.label})]})}function oA(){let{t:e}=U(`agent`);return(0,$.jsxs)(`div`,{"data-testid":`agent-rail-launch-pending`,className:`my-1 inline-flex items-center gap-1.5 rounded-full border border-accent-primary/30 bg-accent-primary/10 px-2.5 py-1 text-[11px] text-accent-primary`,children:[(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}),e(`railCard.pending`)]})}function sA({excerpts:e}){let{t}=U(`agent`);return(0,$.jsxs)(`div`,{"data-testid":`agent-rail-launch-unreadable`,title:e.join(`
|
|
34
34
|
`),className:`my-1 inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-surface/40 px-2.5 py-1 text-[11px] text-foreground/55`,children:[(0,$.jsx)(zn,{className:`h-3 w-3 shrink-0 text-accent-warning/80`}),t(`railCard.unreadable`,{count:e.length})]})}var cA=/```problem-frame[^\S\n]*\n([\s\S]*?)\n[^\S\n]*```/g,lA="```problem-frame";function uA(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function dA(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.reading!=`string`||!t.reading.trim()?null:{reading:t.reading,touches:uA(t.touches)}}function fA(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=dA(n.restated),i=dA(n.alternative);return!r||!i||typeof n.discriminator!=`string`||!n.discriminator.trim()||r.reading.trim()===i.reading.trim()?null:{restated:r,alternative:i,discriminator:n.discriminator,assumptions:uA(n.assumptions),unknowns:uA(n.unknowns)}}function pA(e){return e.replace(/\n{3,}/g,`
|
|
35
35
|
|
|
36
36
|
`).trim()}function mA(e,t=!1){if(!e.includes(lA))return{body:e,frame:null,pending:!1};let n=null,r=``,i=0;cA.lastIndex=0;let a;for(;(a=cA.exec(e))!==null;){r+=e.slice(i,a.index),i=a.index+a[0].length;let t=fA(a[1]);t&&(n=t)}r+=e.slice(i);let o=!1,s=r.indexOf(lA);if(s!==-1){let e=fA(r.slice(s+16).replace(/^[^\S\n]*\n?/,``).replace(/\s*(?:```)?\s*$/,``));e?(n=e,r=r.slice(0,s)):t&&(r=r.slice(0,s),o=!0)}return{body:pA(r),frame:n,pending:o}}var hA=`flex min-w-0 flex-col gap-1.5 rounded-lg border border-border/50 bg-surface/50 p-2.5 text-left`;function gA({label:e,value:t,testId:n,onSelect:r,disabled:i}){let{t:a}=U(`agent`),o=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground/50`,children:e}),(0,$.jsx)(`div`,{className:`text-xs leading-5 text-foreground/90`,children:t.reading}),t.touches.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 pt-0.5`,children:[(0,$.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground/40`,children:a(`problemFrame.touches`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.touches.map((e,t)=>(0,$.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded border border-border/50 bg-background-deep/40 px-1.5 py-0.5 font-mono text-[10px] text-foreground/65`,children:[(0,$.jsx)(Yc,{className:`h-2.5 w-2.5 shrink-0 text-accent-info/70`}),(0,$.jsx)(`span`,{className:`truncate`,children:e})]},`${t}-${e}`))})]})]});return r?(0,$.jsxs)(`button`,{type:`button`,"data-testid":n,"data-agent-interactive":!0,disabled:i,title:a(`problemFrame.pick`),onClick:()=>r(t.reading),className:X(hA,`group/reading transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50`,i?`cursor-default`:`cursor-pointer hover:border-accent-primary/45 hover:bg-accent-primary/[0.09]`),children:[o,(0,$.jsxs)(`span`,{"aria-hidden":!0,className:X(`mt-0.5 inline-flex items-center gap-1 text-[10px] font-medium text-accent-primary/80 transition-opacity`,i?`opacity-0`:`opacity-0 group-hover/reading:opacity-100 group-focus-visible/reading:opacity-100`),children:[(0,$.jsx)(jc,{className:`h-2.5 w-2.5`}),a(`problemFrame.pick`)]})]}):(0,$.jsx)(`div`,{"data-testid":n,className:hA,children:o})}function _A({label:e,items:t}){return t.length===0?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground/45`,children:e}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:t.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px] leading-5 text-foreground/70`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-foreground/30`}),(0,$.jsx)(`span`,{className:`min-w-0`,children:e})]},`${t}-${e}`))})]})}function vA({frame:e,isLatest:t,isStreaming:n,onSelect:r}){let{t:i}=U(`agent`),a=e.assumptions.length>0||e.unknowns.length>0,o=r&&t?r:void 0;return(0,$.jsxs)(`div`,{"data-testid":`agent-problem-frame-card`,className:`my-1 overflow-hidden rounded-xl border border-accent-info/25 bg-card/80 shadow-lg backdrop-blur`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/40 bg-accent-info/[0.06] px-3.5 py-2 text-[10px] font-semibold uppercase tracking-widest text-accent-info/90`,children:[(0,$.jsx)(Dc,{className:`h-3 w-3`}),i(`problemFrame.heading`)]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-3.5 py-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,$.jsx)(gA,{label:i(`problemFrame.restated`),value:e.restated,testId:`agent-problem-frame-reading-restated`,onSelect:o,disabled:n}),(0,$.jsx)(gA,{label:i(`problemFrame.alternative`),value:e.alternative,testId:`agent-problem-frame-reading-alternative`,onSelect:o,disabled:n})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-accent-primary/25 bg-accent-primary/[0.07] px-2.5 py-2`,children:[(0,$.jsx)(we,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary/80`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-accent-primary/80`,children:i(`problemFrame.discriminator`)}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs leading-5 text-foreground/90`,children:e.discriminator})]})]}),a&&(0,$.jsxs)(`div`,{className:`grid gap-2 border-t border-border/40 pt-2.5 sm:grid-cols-2`,children:[(0,$.jsx)(_A,{label:i(`problemFrame.assumptions`),items:e.assumptions}),(0,$.jsx)(_A,{label:i(`problemFrame.unknowns`),items:e.unknowns})]})]})]})}function yA(){let{t:e}=U(`agent`);return(0,$.jsxs)(`span`,{"data-testid":`agent-problem-frame-pending`,className:`inline-flex w-fit items-center gap-1.5 rounded-full border border-accent-info/25 bg-accent-info/10 px-2.5 py-1 text-[11px] text-accent-info/90`,children:[(0,$.jsx)(Dc,{className:`h-3 w-3 animate-pulse`}),e(`problemFrame.framing`)]})}var bA=`#agentref:`;function xA(e){return e.kind===`ticket`?`${bA}ticket:${e.ticketId}`:e.kind===`pull-request`?`${bA}pr:${e.prNumber}${e.prUrl?`:${encodeURIComponent(e.prUrl)}`:``}`:e.kind===`loop`?`${bA}loop:${e.loopId}`:`${bA}job:${e.jobId}`}function SA(e){if(!e||!e.startsWith(bA))return null;let t=e.slice(10);if(t.startsWith(`ticket:`)){let e=Number.parseInt(t.slice(7),10);return Number.isInteger(e)&&e>0?{kind:`ticket`,ticketId:e}:null}if(t.startsWith(`pr:`)){let[,e,n]=/^pr:(\d+)(?::(.+))?$/.exec(t)??[],r=Number.parseInt(e??``,10);if(!Number.isInteger(r)||r<=0)return null;let i=n?decodeURIComponent(n):void 0;return i?{kind:`pull-request`,prNumber:r,prUrl:i}:{kind:`pull-request`,prNumber:r}}if(t.startsWith(`job:`)){let e=t.slice(4);return wA.test(e)?{kind:`job`,jobId:e}:null}if(t.startsWith(`loop:`)){let e=t.slice(5);return EA.test(e)||wA.test(e)?{kind:`loop`,loopId:e}:null}return null}var CA=`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`,wA=RegExp(`^${CA}$`),TA=`factory:(?:implement|batch|freestyle)`,EA=RegExp(`^${TA}$`),DA=/\b(jobs?|runs?|loops?|rails?|ejecuci[oó]n(?:es)?|trabajos?|bucles?)\b|(?:loop|job|run)[a-z]*id/i;function OA(e){let t=new Set;for(let n of e.split(`
|
|
@@ -41,11 +41,11 @@ Error generating stack: `+e.message+`
|
|
|
41
41
|
`),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 AM(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 jM(e,t){let n=e.ownerDocument.getSelection();if(!n?.anchorNode||!n.focusNode||!e.contains(n.anchorNode)||!e.contains(n.focusNode))return null;let r=AM(t,n.anchorNode,n.anchorOffset),i=AM(t,n.focusNode,n.focusOffset);return[Math.min(r,i),Math.max(r,i)]}function MM(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(OM)?[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 NM(e,t,n,r){let[i,a]=MM(e,t,n),[o,s]=MM(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 PM(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 FM(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 IM(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`:e===`rail`?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:`border-border/60 bg-surface/70 text-foreground/80`}function LM(e,t,n,r,i){let a=e.createDocumentFragment(),o=0;for(let s of n){a.append(e.createTextNode(`${o>0?OM:``}${t.slice(o,s.start)}${OM}`));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 ${IM(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?OM:``}${t.slice(o)}`)),a}var RM=(0,Q.forwardRef)(function(e,t){let{t:n}=U(`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:PM(e.value,e.references),selection:[e.value.length,e.value.length]}],index:0,typing:null}),p=()=>kM(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&&FM(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(LM(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&&(NM(s,p(),...o),m(jM(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=jM(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=jM(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&&(NM(r.current,p(),e,t),m(jM(r.current,p())??[e,t]))},get selectionStart(){return r.current?(jM(r.current,p())??c.current)[0]:0},get selectionEnd(){return r.current?(jM(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=PM(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=jM(t,i)??c.current;i.value===e.value&&FM(i.references,n)&&FM(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(jM(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(),NM(t,n,a.start,a.end),x(``,`deleteAtomic`))},C=(e,t)=>{let n=r.current;if(!n)return;let a=p(),o=jM(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||!FM(e.references,t.references))){let e=PM(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(jM(r.current,p())??c.current),i.current.onKeyDown(e),!(e.defaultPrevented||i.current.disabled)){if(e.key===`Enter`)e.preventDefault(),x(`
|
|
42
42
|
`,`insertLineBreak`);else if(e.key===`Backspace`||e.key===`Delete`){let t=r.current,n=p(),i=jM(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,`
|
|
43
43
|
`),`insertFromPaste`))},onCopy:e=>C(e,!1),onCut:e=>C(e,!0)})}),zM=Symbol(`radix.slottable`);function BM(e){let t=({children:e})=>(0,$.jsx)($.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=zM,t}var[VM,HM]=Un(`Tooltip`,[RD]),UM=RD(),WM=`TooltipProvider`,GM=700,KM=`tooltip.open`,[qM,JM]=VM(WM),YM=e=>{let{__scopeTooltip:t,delayDuration:n=GM,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)(qM,{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})};YM.displayName=WM;var XM=`Tooltip`,[ZM,QM]=VM(XM),$M=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=JM(XM,e.__scopeTooltip),l=UM(t),[u,d]=Q.useState(null),f=Xn(),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(KM))):c.onClose(),a?.(e)},caller:XM}),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)(eO,{...l,children:(0,$.jsx)(ZM,{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})})};$M.displayName=XM;var eN=`TooltipTrigger`,tN=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=QM(eN,n),a=JM(eN,n),o=UM(n),s=Yn(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)(tO,{asChild:!0,...o,children:(0,$.jsx)(Kn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:lr(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:lr(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:lr(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:lr(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:lr(e.onBlur,i.onClose),onClick:lr(e.onClick,i.onClose)})})});tN.displayName=eN;var nN=`TooltipPortal`,[rN,iN]=VM(nN,{forceMount:void 0}),aN=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=QM(nN,t);return(0,$.jsx)(rN,{scope:t,forceMount:n,children:(0,$.jsx)(xr,{present:n||a.open,children:(0,$.jsx)(Qn,{asChild:!0,container:i,children:r})})})};aN.displayName=nN;var oN=`TooltipContent`,sN=Q.forwardRef((e,t)=>{let n=iN(oN,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=QM(oN,e.__scopeTooltip);return(0,$.jsx)(xr,{present:r||o.open,children:o.disableHoverableContent?(0,$.jsx)(fN,{side:i,...a,ref:t}):(0,$.jsx)(cN,{side:i,...a,ref:t})})}),cN=Q.forwardRef((e,t)=>{let n=QM(oN,e.__scopeTooltip),r=JM(oN,e.__scopeTooltip),i=Q.useRef(null),a=Yn(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=gN(r,hN(r,n.getBoundingClientRect())),a=_N(t.getBoundingClientRect()),o=yN([...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=!vN(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,$.jsx)(fN,{...e,ref:a})}),[lN,uN]=VM(XM,{isInside:!1}),dN=BM(`TooltipContent`),fN=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=QM(oN,n),l=UM(n),{onClose:u}=c;return Q.useEffect(()=>(document.addEventListener(KM,u),()=>document.removeEventListener(KM,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)(br,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,$.jsxs)(nO,{"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)(dN,{children:r}),(0,$.jsx)(lN,{scope:n,isInside:!0,children:(0,$.jsx)(mO,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});sN.displayName=oN;var pN=`TooltipArrow`,mN=Q.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=UM(n);return uN(pN,n).isInside?null:(0,$.jsx)(rO,{...i,...r,ref:t})});mN.displayName=pN;function hN(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 gN(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 _N(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 vN(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 yN(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)),bN(t)}function bN(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 xN=YM,SN=$M,CN=tN,wN=sN,TN=xN,EN=SN,DN=CN,ON=Q.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,$.jsx)(wN,{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}));ON.displayName=wN.displayName;var kN={"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 AN({process:e,accentVariant:t,onKill:n,onOpen:r}){let{t:i}=U(`agent`),a=MN(e),o=jN(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)(TN,{delayDuration:150,children:(0,$.jsxs)(`span`,{"data-testid":`background-process-chip`,className:`inline-flex max-w-full items-center rounded-lg border text-[11px] ${kN[t]}`,children:[(0,$.jsxs)(EN,{children:[(0,$.jsx)(DN,{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)(xd,{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)(ON,{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)(ac,{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)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Vn,{className:`h-3 w-3`,"aria-hidden":!0})})]})})}function jN(e){return e.status===`exited`||e.status===`failed`||e.status===`killed`||e.status===`interrupted`}function MN(e){let[t,n]=(0,Q.useState)(Date.now()),r=jN(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]),jr(Math.max(0,(e.endedAt??e.recoveredAt??t)-e.startedAt))}var NN=2e3,PN=512*1024,FN=1e3;function IN(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 LN(e){let t=[],n=0,r=e.length>NN;for(let i=e.length-1;i>=0&&t.length<NN;i--){let a=e[i],o=IN(a.line),s=o.slice(-4e3);if(o.length>s.length&&(r=!0),n+s.length>PN){r=!0;break}n+=s.length,t.push({...a,line:s})}return{lines:t.reverse(),truncated:r}}function RN(e){let t=new Date(e.at);return`[${Number.isNaN(t.getTime())?`—`:t.toLocaleTimeString(void 0,{hour12:!1})}] [${e.source}] ${e.line}`}function zN({process:e,onClose:t,onKill:n,onBack:r}){return(0,$.jsx)(BN,{process:e,onClose:t,onKill:n,onBack:r},mj(e))}function BN({process:e,onClose:t,onKill:n,onBack:r}){let{t:i}=U(`agent`),a=mj(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=jN(e)?e:jN(s)?s:e.status===`stopping`&&s.status!==`stopping`?e:s,I=jN(F);(0,Q.useEffect)(()=>{I&&v(!1)},[I]);let ee=D||F.status===`stopping`&&!F.error&&!e.stopError,te=MN(F);(0,Q.useEffect)(()=>{if(_){f(!1);return}let e=new AbortController,t,n=async()=>{try{let r=await xj(o.current,{limit:NN,signal:e.signal});if(e.signal.aborted)return;if(mj(r.process)!==a)throw Error(`Unexpected process identity`);let i=LN(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),jN(r.process)||(t=setTimeout(()=>{n()},FN))}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 L=(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]),R=(0,Q.useMemo)(()=>L.map(RN).join(`
|
|
44
|
-
`),[L]);(0,Q.useEffect)(()=>{y&&!_&&N.current&&(N.current.scrollTop=N.current.scrollHeight)},[L,y,_]);let z=async()=>{if(!(ee||I)){O(!0),A(!1);try{await n(o.current)}catch{P.current&&A(!0)}finally{P.current&&O(!1)}}},B=async()=>{try{await navigator.clipboard.writeText(R),P.current&&M(`copied`)}catch{P.current&&M(`failed`)}},ne=()=>{let t;try{t=URL.createObjectURL(new Blob([R],{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)}},V=`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)(vr,{open:!0,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(rr,{children:[(0,$.jsx)(_r,{className:`z-[80]`}),(0,$.jsxs)(ir,{"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)(un,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsx)(xd,{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)(dr,{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.${ee?`stopping`:F.status}`)}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:te})]}),(0,$.jsx)(cr,{className:`mt-1 text-xs text-muted-foreground`,children:i(`backgroundProcess.logsDescription`)})]}),(0,$.jsx)(pr,{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)(Vn,{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:IN(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:IN(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:IN(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:IN(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)(In,{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:V,"aria-pressed":_,onClick:()=>v(e=>!e),children:[_?(0,$.jsx)(Mn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,$.jsx)(_u,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(_?`backgroundProcess.resume`:`backgroundProcess.pause`)]}),(0,$.jsxs)(`button`,{type:`button`,className:`${V} ${y?`border-accent-info/40 text-accent-info`:``}`,"aria-pressed":y,onClick:()=>b(e=>!e),children:[(0,$.jsx)(ks,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`backgroundProcess.follow`)]}),(0,$.jsx)(`button`,{type:`button`,className:V,disabled:!L.length,onClick:()=>void B(),"aria-label":i(`backgroundProcess.copy`),title:i(`backgroundProcess.copy`),children:j===`copied`?(0,$.jsx)(xn,{className:`h-3.5 w-3.5`}):(0,$.jsx)(kc,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:V,disabled:!L.length,onClick:ne,"aria-label":i(`backgroundProcess.download`),title:i(`backgroundProcess.download`),children:(0,$.jsx)(En,{className:`h-3.5 w-3.5`})}),!I&&(0,$.jsxs)(`button`,{type:`button`,className:`${V} text-destructive`,disabled:ee,onClick:()=>void z(),children:[ee?(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Nn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(ee?`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)(ac,{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:V,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)(An,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),i(`backgroundProcess.loading`)]}):L.length?L.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:L.length,total:l.length})}),(0,$.jsx)(`span`,{children:i(`backgroundProcess.exportHint`)})]})]})]})})}function VN({processes:e,loading:t,error:n,onRefresh:r,onClose:i,onKill:a}){let{t:o}=U(`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(jN(e))-Number(jN(t))||t.startedAt-e.startedAt)},[e,s,o]);if(d)return(0,$.jsx)(zN,{process:e.find(e=>mj(e)===mj(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)(vr,{open:!0,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(rr,{children:[(0,$.jsx)(_r,{className:`z-[80]`}),(0,$.jsxs)(ir,{"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)(xd,{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)(dr,{className:`text-sm font-semibold`,children:o(`backgroundProcess.history.title`)}),(0,$.jsx)(cr,{className:`mt-1 text-xs text-muted-foreground`,children:o(`backgroundProcess.history.description`)})]}),(0,$.jsx)(pr,{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)(Vn,{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)(In,{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)(Lu,{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)(ac,{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)(xd,{className:`h-4 w-4 shrink-0 ${jN(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:IN(e.command)}),(0,$.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:[IN(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`:jN(e)?`bg-muted text-muted-foreground`:`bg-accent-info/10 text-accent-info`}`,children:o(`backgroundProcess.status.${e.status}`)}),(0,$.jsx)(Cn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]},mj(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)(An,{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 HN(e={}){let t=e.enabled!==!1,[n,r]=(0,Q.useState)({available:{},availableIds:[],issues:{},launchDescriptors:{},labels:{},loading:!0}),[i,a]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{if(!t)return;let e=0,n=()=>{let t=Date.now();t-e<3e4||(e=t,a(e=>e+1))},r=()=>{e=0,n()};return window.addEventListener(`focus`,n),window.addEventListener(`specrails:providers-detected-changed`,r),()=>{window.removeEventListener(`focus`,n),window.removeEventListener(`specrails:providers-detected-changed`,r)}},[t]),(0,Q.useEffect)(()=>{if(!t)return;let e=!0;return fetch(`${F}/api/available-providers`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{if(!e)return;let n={};for(let[e,r]of Object.entries(t))e===`tiers`||e===`providerIssues`||e===`launchDescriptors`||e===`labels`||typeof r==`boolean`&&on(e)&&(n[e]=r);let i=t.providerIssues&&typeof t.providerIssues==`object`?t.providerIssues:{},a=t.launchDescriptors&&typeof t.launchDescriptors==`object`?t.launchDescriptors:{},o={};if(t.labels&&typeof t.labels==`object`)for(let[e,n]of Object.entries(t.labels))typeof n==`string`&&(o[e]=n);r({available:n,availableIds:Object.keys(n).filter(e=>n[e]),issues:i,launchDescriptors:a,labels:o,loading:!1})}).catch(()=>{e&&r(e=>({...e,loading:!1}))}),()=>{e=!1}},[t,i]),n}function UN(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 WN=[],GN=[];function KN({autoFocus:e=!1,hideProjectSelector:t=!1,queueEditRequest:n}){let{t:r}=U(`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}=OL(),T=(0,Q.useMemo)(()=>S.filter(e=>e.deliveryMode!==`steer`),[S]),{pendingCaptures:E,consumePendingCaptures:D,openBrowser:O}=fj(),{processes:k,history:A=k,historyLoading:j=!1,historyError:M=null,refreshHistory:N,kill:P}=Dj(),[I,ee]=(0,Q.useState)(null),[te,L]=(0,Q.useState)(null),R=(0,Q.useMemo)(()=>[...k].sort((e,t)=>Number(jN(e))-Number(jN(t))||t.startedAt-e.startedAt).slice(0,4),[k]),{projects:z,activeProjectId:B}=ce(),ne=i?.pinned_project_id??l??B,V=i?.id??`__new-mission__`,re=(0,Q.useMemo)(()=>Math.floor(Math.random()*20),[V]),ie=Mi(),ae=(0,Q.useRef)(null);ae.current!==V&&(bi(V),ae.current=V),ai(V);let[H,W]=(0,Q.useState)(null),G=H&&H.key===V?H:null,oe=G?G.text:Xr.get(V)??``,se=G?WN:Qr.get(V)??WN,le=Zr.get(V)??GN,ue=(e,t=[])=>oi(V,e,t),[de,fe]=(0,Q.useState)(null),pe=(e,t)=>{let n=Zr.get(e)??GN;si(e,typeof t==`function`?t(n):t)},[q,me]=(0,Q.useState)(!1),[he,ge]=(0,Q.useState)(!1),_e=(0,Q.useRef)(!1),J=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useMemo)(()=>[...new Map(se.map(({chip:e})=>[JSON.stringify([e.projectId,Fj(e)]),e])).values()],[se]),[be,xe]=(0,Q.useState)(null),[Se,Ce]=(0,Q.useState)(0),[we,Te]=(0,Q.useState)(!1),[Ee,De]=(0,Q.useState)([]),[Oe,ke]=(0,Q.useState)([]),[Ae,je]=(0,Q.useState)([]),Me=de!==null,Ne=(0,Q.useMemo)(()=>a.filter(e=>e.role===`user`).map(e=>e.content),[a]),Pe=G?.queueId??null,Fe=(0,Q.useRef)(``),Ie=Pe===null?-1:T.findIndex(e=>e.queueId===Pe),Le=Ie>=0?T[Ie]:null,Re=G!==null;(0,Q.useEffect)(()=>{if(q||he||Re)return US(V)},[V,q,he,Re]);let ze=c===!1||(i?!ie.isEditable(i.id):!!ie.current),Be=!ze&&!Re,Ve=i?.provider??u,{availableIds:He,labels:Ue}=HN(),We=(0,Q.useMemo)(()=>[Ve,...He].filter((e,t,n)=>on(e)&&n.indexOf(e)===t),[Ve,He]),Ge=e=>r(`provider.${e}`,{defaultValue:Ue?.[e]??e}),Ke=i?i.pinned_project_id:l,qe=Ke,Je=be?.mode===`reference`?be.query.trim():``,Ye=`${qe??``}:${Je}`,[Xe,Ze]=(0,Q.useState)({key:``,items:[]});(0,Q.useEffect)(()=>{let e=z.find(e=>e.id===qe);if(!e||Je.length<2)return;let t=new AbortController,n=setTimeout(()=>{let n=new URLSearchParams({kind:`find`,q:Je,limit:`20`});fetch(`${F}/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||Ze({key:Ye,items:Aj(e,r.matches??[])})}).catch(()=>{})},180);return()=>{clearTimeout(n),t.abort()}},[qe,z,Je,Ye]);let Qe=(0,Q.useMemo)(()=>({projects:z,conversations:o,activeConversation:i,pinnedProjectId:qe,activeProjectId:B,tickets:Ee,jobs:Oe,rails:Ae,chips:ye}),[z,o,i,qe,B,Ee,Oe,Ae,ye]),$e=(0,Q.useMemo)(()=>be?[...Zj(be.mode,Qe),...be.mode===`reference`&&Je.length>=2&&Xe.key===Ye?Xe.items:[]]:[],[be,Qe,Xe,Ye,Je]),et=(0,Q.useMemo)(()=>{if(!be)return[];let e=Gj($e,be.query);return e.length>0?e:Qj(be.mode,be.query)},[$e,be]),tt=be!==null&&!Re,nt=oe.trim().length>0||ye.length>0,rt=[`accent-primary`,`accent-info`,`accent-highlight`],it=i?.id??null;(0,Q.useEffect)(()=>{ee(null),L(null)},[it,ne]),(0,Q.useEffect)(()=>{fe(null),xe(null),Te(!1),W(null)},[it]),(0,Q.useEffect)(()=>{if(!qe){De([]),ke([]),je([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${F}/api/projects/${encodeURIComponent(qe)}/tickets`),fetch(`${F}/api/projects/${encodeURIComponent(qe)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;De(Array.isArray(r.tickets)?r.tickets:[]),ke(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;De([]),ke([])}try{let t=await fetch(`${F}/api/projects/${encodeURIComponent(qe)}/rails`),n=t.ok?await t.json():null;if(!e)return;je(jj(n))}catch{e&&je([])}})(),()=>{e=!1}},[qe]),(0,Q.useEffect)(()=>{Ce(0)},[be?.mode,be?.query]),(0,Q.useEffect)(()=>{Se>=et.length&&Ce(Math.max(0,et.length-1))},[Se,et.length]),(0,Q.useEffect)(()=>{if(E.length===0)return;let e=D();e.length&&pe(V,t=>[...t,...e])},[E,D,V]);let at=bM(Ve),{models:ot,efforts:st,supportsImageInput:ct,customModelAliases:lt}=at,ut=(i?i.model:d)??ot.find(e=>e.default)?.value??ot[0]?.value??``,dt=qt(Ve,ut),ft=st.filter(e=>dt.includes(e)),mt=i?i.reasoning_effort:p,Y=mt&&ft.includes(mt)?mt:cn(Ve,ut)??``,ht=e=>{Si(e)},gt=async e=>{if(e.length===0)return;me(!0);let t=i;if(!t)try{t=await x(),ht(t.id)}catch(e){K.error(e instanceof Error?e.message:r(`workspace.uploadFailed`)),me(!1);return}for(let n of e){if(!ct&&n.type.startsWith(`image/`)){K.error(r(`imagesUnsupported`));continue}try{let e=await Mo(t.id,n);pe(t.id,t=>[...t,e])}catch(e){K.error(e instanceof Error?e.message:r(`workspace.uploadFailed`))}}me(!1)},_t=async e=>{try{i&&await Io(i.id,e),pe(V,t=>t.filter(t=>t.id!==e))}catch(e){K.error(e instanceof Error?e.message:`Failed to remove attachment.`)}},yt=(e,t,n=se)=>{if(n.some(e=>t>e.start&&t<=e.end)){xe(null);return}let r=Pj(e,t);xe(r),r&&Te(!1)},bt=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,xt=e=>{requestAnimationFrame(()=>{ve.current?.focus(),ve.current?.setSelectionRange(e,e)})},St=e=>{if(Re)return;let t=bt(e),n=ve.current,r=n?.selectionStart??oe.length,i=n?.selectionEnd??r,a=UN(oe,se,r,i,t);ue(a.text,a.references),fe(null),Te(!1),xe({mode:e,trigger:t,query:``,start:r,end:r+1}),xt(r+1)},Ct=e=>{ve.current?.focus();let t=$j(oe,be,e),n=be?.start??oe.length,r=be?.end??n,i=t.text.slice(n,t.caret),{references:a}=UN(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)}ue(t.text,a),fe(null),xe(null),Te(!1),xt(t.caret)},wt=e=>{let t=T[e];t&&(Fe.current=t.text,W({key:V,queueId:t.queueId,text:t.text}))},Tt=e=>{Me&&ue(``),fe(null),wt(e)};(0,Q.useEffect)(()=>{if(!n||n.conversationId!==i?.id)return;let e=T.findIndex(e=>e.queueId===n.queueId);e<0||(Re?wt(e):Tt(e),xt(T[e].text.length))},[n]);let Et=(e,t)=>{let n=t??oe;W(null),e===`keep`&&ue(n)},Dt=async()=>{let e=Le,t=oe.trim();if(!(!e||!t))try{await C(e.queueId,t)===`saved`?Et(`restore`):(K.info(r(`queueEdit.dispatched`)),Et(`keep`))}catch{K.error(r(`queueEdit.saveFailed`))}};(0,Q.useEffect)(()=>{if(!G||T.some(e=>e.queueId===G.queueId))return;let e=oe!==Fe.current;w(G.queueId)&&K.info(r(`queueEdit.dispatched`)),Et(e?`keep`:`restore`)},[Pe,T,Re]);let Ot=async()=>{if(ze||!nt||_e.current)return;let e=oe.trim()||ye.map(e=>e.token).join(` `),t={...le.length?{attachmentIds:le.map(e=>e.id)}:{},...ye.length?{contextRefs:ye.map(Ij)}:{}},n=JSON.stringify([e,t]),i=$r.get(V),a=i?.signature===n?i:{signature:n,queueId:`q-${crypto.randomUUID()}`},o={text:oe,references:se,attachments:le,submission:a};ci(V,a),di(V,o),xe(null),Te(!1),fe(null),_e.current=!0,ge(!0);try{let n=await h(e,{...t,queueId:a.queueId}),r=n.conversationId??V;if(!n.accepted){ci(r,a),fi(r,o);return}ci(V,null),ci(r,null)}catch(e){fi(V,o),K.error(e instanceof Error?e.message:r(`queueEdit.saveFailed`))}finally{_e.current=!1,ge(!1)}},kt=e=>{if(Ne[e]===void 0){fe(null);return}fe(e),ue(Ne[e])};return(0,$.jsxs)(`div`,{className:`@container shrink-0`,children:[Re&&Le&&(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)(jn,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:r(`queueEdit.editing`,{n:Ie+1,m:T.length})}),(0,$.jsx)(`span`,{className:`truncate text-foreground/45`,children:r(`queueEdit.hint`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Et(`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)(Vn,{className:`h-3 w-3`})})]}),Me&&(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,$.jsx)(Uu,{className:`h-3 w-3`}),r(`history.hint`)]}),le.length>0&&(0,$.jsx)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:le.map(e=>(0,$.jsx)(kj,{conversationId:it,attachment:e,removeLabel:r(`close`),onRemove:()=>_t(e.id)},e.id))}),R.length>0&&(0,$.jsx)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:R.map((e,t)=>(0,$.jsx)(AN,{process:e,accentVariant:rt[t%rt.length],onKill:P,onOpen:ee},mj(e)))}),(0,$.jsxs)(`div`,{"data-testid":`agent-composer-box`,"data-mission-composer":!0,className:`relative flex flex-col gap-2 rounded-3xl border bg-card px-3 py-3 ${Re?`border-accent-highlight/50`:Me?`border-accent-info/40`:`border-border/30`}`,onDragOver:e=>{Be&&e.preventDefault()},onDrop:e=>{if(!Be)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&>(t)},children:[(0,$.jsx)(mM,{active:s,radius:`1.5rem`,inset:-1}),tt&&(0,$.jsx)(TM,{items:et,mode:be.mode,query:be.query,activeIndex:Se,onActiveIndexChange:Ce,onSelect:Ct}),Be&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`input`,{ref:J,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&>(t),e.target.value=``}})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(RM,{ref:ve,value:oe,references:Re?[]:se,autoFocus:e,onChange:(e,t,n)=>{if(Re){W(t=>t&&{...t,text:e});return}Me&&fe(null),ue(e,t),yt(e,n,t)},onSelect:e=>{Re||yt(ve.current?.value??oe,e)},onKeyDown:e=>{if(e.nativeEvent.isComposing)return;if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),_();return}if(tt){if(e.key===`ArrowDown`){e.preventDefault(),et.length>0&&Ce(e=>Math.min(et.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),et.length>0&&Ce(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=et[Se]??et[0];t&&Ct(t);return}if(e.key===`Escape`){e.preventDefault(),xe(null);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),Re?Dt():Ot();return}if(e.key===`Escape`&&Re){e.preventDefault(),e.stopPropagation(),Et(`restore`);return}let t=ve.current,n=t?.selectionStart===0&&t?.selectionEnd===0,r=t?.selectionStart===oe.length&&t?.selectionEnd===oe.length;if(e.key===`ArrowUp`){if(Re){Le!==null&&oe===Le.text&&n&&Ie>0&&(e.preventDefault(),wt(Ie-1));return}if(T.length>0){n&&(e.preventDefault(),Tt(T.length-1));return}!Me&&oe===``&&Ne.length>0?(e.preventDefault(),kt(Ne.length-1)):Me&&(e.preventDefault(),kt(Math.max(0,de-1)));return}if(e.key===`ArrowDown`){if(Re){Le!==null&&oe===Le.text&&r&&(e.preventDefault(),Ie<T.length-1?wt(Ie+1):Et(`restore`));return}if(T.length>0)return;Me&&(e.preventDefault(),de<Ne.length-1?kt(de+1):(fe(null),ue(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&Me&&fe(null)},onPaste:e=>{if(!Be)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),gt(t))},disabled:ze,placeholder:ze?r(`noProvider.placeholder`):s?r(`queue.placeholder`):r(`missionPlaceholders.${re}`,{defaultValue:r(`composerPlaceholder`)}),title:Re?r(`queueEdit.hint`):Me?r(`history.hint`):void 0,className:`min-h-[2.5rem] max-h-64 min-w-0 w-full resize-none overflow-y-auto bg-transparent text-sm outline-none ${Me?`italic text-foreground/50`:`text-foreground`}`},V)}),(0,$.jsxs)(`div`,{className:`flex w-full items-center gap-1`,"data-testid":`agent-composer-controls`,children:[!Re&&(0,$.jsx)(EM,{open:we,canAttach:Be,uploading:q,onToggle:()=>{Te(e=>!e),xe(null)},onClose:()=>Te(!1),onOpenMode:St,onAttachFile:()=>{Te(!1),J.current?.click()},canBrowserCapture:pt()&&!!(qe??B),onOpenBrowser:()=>{Te(!1),O()}}),(0,$.jsx)(rM,{compact:!0,level:i?.tier_level??f,onCycle:()=>void _()}),it&&ne&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>L({chatId:it,projectId:ne}),"aria-label":r(`backgroundProcess.history.open`),title:r(`backgroundProcess.history.open`),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md p-1.5 text-xs 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)(xd,{className:`h-4 w-4`,"aria-hidden":!0})}),` `,i===null&&!t&&(0,$.jsx)(`div`,{className:`flex min-w-0 items-center overflow-hidden [&_button]:h-8 [&_button]:text-sm [&_button_span]:max-w-20 @max-[640px]:[&_button_span]:hidden`,children:(0,$.jsx)(eM,{pinnedProjectId:l,onSelect:e=>void b(e)})}),(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 max-w-[60%] items-center gap-1`,children:[(0,$.jsx)(vM,{provider:Ve,providers:We.map(e=>({value:e,label:Ge(e)})),models:ot,model:ut,efforts:ft,effort:Y,defaultEffort:cn(Ve,ut)??``,status:at.status,customModelAliases:lt,onProvider:e=>{v(e).catch(()=>K.error(r(`error.generic`)))},onModel:e=>{y(e).catch(()=>K.error(r(`error.generic`)))},onEffort:e=>{m(e).catch(()=>K.error(r(`error.generic`)))}}),s&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":r(`stop`),title:r(`stop`),className:`inline-flex h-8 w-8 items-center justify-center shrink-0 rounded-full bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(Nn,{className:`h-4 w-4`,fill:`currentColor`})}),Re?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Dt(),disabled:ze||!oe.trim(),"aria-label":r(`queueEdit.save`),title:r(`queueEdit.save`),className:`inline-flex h-8 w-8 items-center justify-center shrink-0 rounded-full bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,$.jsx)(xn,{className:`h-4 w-4`})}):s?(0,$.jsx)(`button`,{type:`button`,onClick:Ot,disabled:ze||!nt||he,"aria-label":r(`queue.send`),title:r(`queue.sendHint`),className:`relative inline-flex h-8 w-8 items-center justify-center shrink-0 rounded-full bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(vt,{className:`h-4 w-4`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Ot,disabled:ze||!nt||he,"aria-label":r(`send`),className:`inline-flex h-8 w-8 items-center justify-center shrink-0 rounded-full bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,$.jsx)(vt,{className:`h-4 w-4`})})]})]})]}),Ke&&(0,$.jsx)(xM,{projectId:Ke}),I&&I.chatId===it&&I.projectId===ne&&(0,$.jsx)(zN,{process:A.find(e=>mj(e)===mj(I))??I,onClose:()=>ee(null),onKill:P}),te&&te.chatId===it&&te.projectId===ne&&(0,$.jsx)(VN,{processes:A,loading:j,error:M,onRefresh:N,onClose:()=>L(null),onKill:P})]})}var qN=e=>e===`running`||e===`queued`;function JN(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 YN(){try{return R()}catch{return null}}var XN=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function ZN(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(`${F}/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(XN(t.started_at)),d(XN(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=qN(o)&&u===null,C=YN(),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(XN(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 QN(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var $N=15e3;function eP(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function tP(e){let{projectId:t,jobId:n,timeoutMs:r=$N}=e,i=t?`${F}/api/projects/${t}`:G(),a;try{a=await fetch(`${i}/jobs/${n}/cancel`,{method:`POST`,signal:eP(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 nP=null;function rP(e){nP=e}function iP(e,t){nP?.(e,t)}var aP=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-C7dWoRu6.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,77,78,79,80,81,82,83,84,85,86,87]))),oP={building:On,on_review:On,pr_draft:ve,pr_ready:ve,no_changes:sc,completed:sc,pr_closed:Tn,superseded:ve,implementation_failed:zn,pr_failed:zn,merged:hl,discarded:Tn},sP={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 cP({envelope:e}){let{t}=U(`agent`),n=bt(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 lP({prDeliveryId:e,projectId:t}){let{t:n}=U(`agent`),r=y(),{activeProjectId:i,setActiveProjectId:a}=ce();return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let n=`/review/${e}`;i!==t&&(iP(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)(qc,{className:`h-3 w-3`}),n(`prCard.openReview`)]})}function uP(e,t,n){if(e.decision===`building`)return n?`paused`:t?.status===`stalled`?`stalled`:`running`;if(t?.active)return`running`;let r=e.runtime?.status;return r===`running`?`running`:r===`failed`||r===`stalled`||r===`cancelled`||r===`succeeded`?r:e.runtime?.failure?e.runtime.failure.code===`stalled`||e.runtime.failure.code===`stuck`?`stalled`:`failed`:e.decision===`implementation_failed`||e.implementationOutcome===`failed`?`failed`:e.decision===`discarded`?`cancelled`:e.decision===`completed`||e.decision===`merged`||e.decision===`on_review`||e.decision===`pr_draft`||e.decision===`pr_ready`||e.decision===`no_changes`?`succeeded`:`unknown`}var dP={running:`border-accent-info/40 bg-accent-info/10 text-accent-info`,paused:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,succeeded:`border-accent-success/40 bg-accent-success/10 text-accent-success`,failed:`border-destructive/40 bg-destructive/10 text-destructive`,stalled:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,cancelled:`border-border/60 bg-surface/60 text-foreground/55`,unknown:`border-border/60 bg-surface/60 text-foreground/55`};function fP({status:e}){let{t}=U(`agent`);return(0,$.jsxs)(`span`,{"data-testid":`mission-run-status`,"data-status":e,className:X(`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,dP[e]),children:[(e===`running`||e===`paused`)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 rounded-full`,e===`running`?`animate-pulse bg-accent-info`:`bg-accent-warning`)}),t(`runCard.status.${e}`)]})}function pP({envelope:e}){let{t}=U(`agent`),n=e.runtime?.failure??null,r=n?.code??e.statusCode??null,i=n?.detail??e.statusDetail??null,a=(e.units??[]).filter(e=>e.failureCode).map(e=>({ticketId:e.ticketId,code:e.failureCode}));return!r&&!i&&a.length===0?null:(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-destructive/30 bg-destructive/[0.06] px-2.5 py-2 text-[11px]`,"data-testid":`mission-run-failure`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(zn,{className:`h-3.5 w-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`font-medium text-destructive`,children:t(`runCard.failure.title`)}),r&&(0,$.jsx)(`span`,{className:`rounded-full border border-destructive/40 bg-destructive/10 px-2 py-px font-mono text-[10px] text-destructive`,"data-testid":`mission-run-failure-code`,children:r}),n?.stepId&&(0,$.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/60 px-2 py-px font-mono text-[10px] text-foreground/60`,children:t(`runCard.failure.step`,{step:n.stepId})})]}),i&&(0,$.jsx)(`p`,{className:`mt-1 break-words leading-4 text-foreground/70`,"data-testid":`mission-run-failure-detail`,children:i}),a.length>0&&(0,$.jsx)(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[10px] text-foreground/55`,children:a.map(e=>(0,$.jsx)(`li`,{children:t(`runCard.failure.unit`,{ticket:e.ticketId,code:e.code})},`${e.ticketId}-${e.code}`))})]})}function mP(e,t){let n=e.runtime;return n?{runId:t,status:n.status,nextStep:n.currentStep,recoverableSteps:n.recoverableSteps,active:n.status===`running`,canResume:n.canResume,canCancel:n.status===`running`,...n.pendingApproval&&n.failure?.stepId?{pendingApproval:{stepId:n.failure.stepId}}:{}}:null}function hP(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function gP({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=U(`agent`),s=ZN(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:JN(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)(Yu,{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 _P({envelope:e,conversationId:t}){let{t:n}=U(`agent`),r=u(),{projects:i}=ce(),{applyPrDecisionSnapshot:a}=OL(),{openWebView:o,canOpenWebView:s}=ot(),{openRef:c}=IC(),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(null),M=A??e,N=zt(M.projectId).has(M.prDeliveryId),[P,I]=(0,Q.useState)(null),[ee,te]=(0,Q.useState)({}),[L,R]=(0,Q.useState)(null),{decision:z,prUrl:B,prState:ne}=M,V=Xe&&M.hasDelivery===!1,re=Xe?M.runtime?.failure??null:null,ie=(M.runIds??[])[0]??null,ae=Xe&&!!ie&&(z===`building`||!!re||z===`implementation_failed`||M.runtime?.status===`running`),H=Mr(M.projectId,{jobId:ie??void 0,enabled:ae}),W=H.runs.find(e=>e.runId===ie)??H.runs[0]??null,G=W??(ie?mP(M,ie):null),[oe,se]=(0,Q.useState)(!1),le=(0,Q.useRef)(!1),[ue,de]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{de(!1),pe(null)},[M.prDeliveryId]);let q=(0,Q.useRef)(null),[me,he]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!Xe)return;let e=e=>{let n=e.detail;oj(n,{prDeliveryId:M.prDeliveryId,runIds:M.runIds})&&(q.current?.scrollIntoView?.({behavior:`smooth`,block:`center`}),he(!0),t&&clearTimeout(t),t=setTimeout(()=>he(!1),1400))},t=null;return window.addEventListener(ij,e),()=>{window.removeEventListener(ij,e),t&&clearTimeout(t)}},[M.prDeliveryId,M.runIds]);let ge=me?`ring-2 ring-accent-primary/50 ring-offset-1 ring-offset-background`:``,_e=!!M.repositoryDeliveries?.length,J=bt(M),ye=yt(M.statusCode,M.statusDetail),be=M.operation==null&&ye,xe=i.find(e=>e.id===M.projectId)?.name??M.projectId,Se=z===`pr_draft`&&!B,Ce=z===`building`&&ne===`pr-created`&&!!M.branch,we=M.prNumber?`#${M.prNumber}`:B?hP(B):null,Te=J.terminal,Ee=xt(M.statusCode)?n(`common:prDeliveryStatus.${M.statusCode}`):null,De=J.partial&&J.deliverableCount>0&&(z===`on_review`||z===`pr_draft`&&!B);(0,Q.useEffect)(()=>{j(null)},[e]);let Oe=(0,Q.useRef)(!1);Oe.current=l!==null||f||M.operation!=null||H.busy!==null,(0,Q.useEffect)(()=>{d(null),h(!1),_(!1),y(!1),C(!1),T(!1),D(!1),k(!1)},[z,B,M.prDeliveryId]);let ke=(0,Q.useCallback)((e,t)=>{te(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),Ae=async e=>{if(!L){R(e);try{let t=await tP({projectId:M.projectId,jobId:e,kind:`loop-run`});t.ok?K.info(n(`prCard.stopExecutionSent`)):K.error(n(`prCard.stopExecutionFailed`),{description:t.error})}finally{R(null)}}},je=async(e,r)=>{if(f||l||M.operation||_e&&!r&&[`create-pr`,`merge-local`,`publish`,`poll-merge`,`reopen`,`acknowledge-no-changes`].includes(e))return;let i=M.repositoryDeliveries?.find(e=>e.repositoryId===r),o=i?.integrationBranch??i?.baseBranch??M.baseBranch;d(e);try{let i=await Yo(M.projectId,{prDeliveryId:M.prDeliveryId,action:e,expectedDecision:z,...r?{repositoryId:r}:{},...V&&t?{conversationId:t}:{}}),s=null;if(i.snapshot){let e=Xo(M,i.snapshot);s=a(e),s!==`stale`&&j(e)}if(s===`stale`){K.info(n(`prCard.alreadyResolved`));return}if(i.kind===`recovering`)K.info(n(`common:prRecovery.inProgress`));else if(i.kind===`busy`)K.info(n(`prCard.operation.${i.operation??`inProgress`}`));else if(i.kind===`stale`)K.info(n(`prCard.alreadyResolved`));else if(i.kind===`blocked`)K.warning(i.reason===`dirty`?n(`prCard.mergeLocalBlockedDirty`,{base:i.base||o}):n(`prCard.mergeLocalBlockedBranch`,{base:i.base||o,current:i.current??`?`}));else if(i.kind===`failed`)K.error(n(`prCard.actionFailed`),{description:i.detail});else if(i.kind===`ok`&&e===`recover-and-retry`)if(i.deliveryVerified){let e=(i.verifiedSha??i.snapshot?.deliverySha??``).slice(0,8);K.success(n(`prCard.recoverAndRetryVerified`,{sha:e}))}else i.recoveryUnavailable||i.snapshot?.statusCode===`recovery_unavailable`?K.info(n(`prCard.recoveryUnavailable`),{description:n(`prCard.recoveryUnavailableBody`)}):K.warning(n(`prCard.recoveryStillBlocked`),{description:i.detail??void 0});else if(i.kind===`ok`&&e===`create-pr`&&J.retryablePush&&i.deliveryVerified){let e=(i.verifiedSha??i.snapshot?.deliverySha??M.deliverySha??``).slice(0,8);K.success(n(i.pushed?`prCard.retryPushVerified`:`prCard.commitAlreadyVerified`,{sha:e}))}else if(i.kind===`ok`&&e===`create-pr`&&i.detail)K.error(n(`prCard.deliveryNeedsAttention`),{description:i.detail});else if(i.kind===`ok`&&e===`poll-merge`&&i.deliveryVerified===!1)K.warning(n(`prCard.commitMissingRetry`));else if(i.kind===`ok`&&e===`poll-merge`&&i.deliveryVerified&&!i.merged){let e=(i.verifiedSha??i.snapshot?.deliverySha??M.deliverySha??``).slice(0,8);K.success(n(`prCard.prVerifiedWaiting`,{sha:e}))}else e===`poll-merge`&&!i.merged&&i.decision!==`pr_closed`?K.info(n(`prCard.notMergedYet`)):e===`merge-local`&&i.kind===`ok`&&i.decision===`merged`&&K.success(n(`prCard.mergedLocally`,{base:o}));i.kind===`ok`&&(e===`create-pr`||e===`discard`||e===`merge-local`||e===`recover-and-retry`)&&Et(M.projectId)}catch(e){K.error(n(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{d(null)}},Me=async e=>{if(!(_e&&!e)&&!(l||f||M.operation)){p(!0);try{let t=await(e?Zo(M.projectId,M.prDeliveryId,e):Zo(M.projectId,M.prDeliveryId));t.kind===`ok`?(K.success(n(`prCard.checkoutSuccess`,{branch:t.branch??Nt(M)??``})),t.cleanupWarnings.length>0&&K.warning(n(`prCard.cleanupIncomplete`,{count:t.cleanupWarnings.length}),{description:t.cleanupWarnings.join(`
|
|
44
|
+
`),[L]);(0,Q.useEffect)(()=>{y&&!_&&N.current&&(N.current.scrollTop=N.current.scrollHeight)},[L,y,_]);let z=async()=>{if(!(ee||I)){O(!0),A(!1);try{await n(o.current)}catch{P.current&&A(!0)}finally{P.current&&O(!1)}}},B=async()=>{try{await navigator.clipboard.writeText(R),P.current&&M(`copied`)}catch{P.current&&M(`failed`)}},ne=()=>{let t;try{t=URL.createObjectURL(new Blob([R],{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)}},V=`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)(vr,{open:!0,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(rr,{children:[(0,$.jsx)(_r,{className:`z-[80]`}),(0,$.jsxs)(ir,{"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)(un,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsx)(xd,{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)(dr,{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.${ee?`stopping`:F.status}`)}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:te})]}),(0,$.jsx)(cr,{className:`mt-1 text-xs text-muted-foreground`,children:i(`backgroundProcess.logsDescription`)})]}),(0,$.jsx)(pr,{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)(Vn,{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:IN(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:IN(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:IN(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:IN(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)(In,{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:V,"aria-pressed":_,onClick:()=>v(e=>!e),children:[_?(0,$.jsx)(Mn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,$.jsx)(_u,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(_?`backgroundProcess.resume`:`backgroundProcess.pause`)]}),(0,$.jsxs)(`button`,{type:`button`,className:`${V} ${y?`border-accent-info/40 text-accent-info`:``}`,"aria-pressed":y,onClick:()=>b(e=>!e),children:[(0,$.jsx)(ks,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`backgroundProcess.follow`)]}),(0,$.jsx)(`button`,{type:`button`,className:V,disabled:!L.length,onClick:()=>void B(),"aria-label":i(`backgroundProcess.copy`),title:i(`backgroundProcess.copy`),children:j===`copied`?(0,$.jsx)(xn,{className:`h-3.5 w-3.5`}):(0,$.jsx)(kc,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,className:V,disabled:!L.length,onClick:ne,"aria-label":i(`backgroundProcess.download`),title:i(`backgroundProcess.download`),children:(0,$.jsx)(En,{className:`h-3.5 w-3.5`})}),!I&&(0,$.jsxs)(`button`,{type:`button`,className:`${V} text-destructive`,disabled:ee,onClick:()=>void z(),children:[ee?(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Nn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(ee?`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)(ac,{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:V,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)(An,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),i(`backgroundProcess.loading`)]}):L.length?L.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:L.length,total:l.length})}),(0,$.jsx)(`span`,{children:i(`backgroundProcess.exportHint`)})]})]})]})})}function VN({processes:e,loading:t,error:n,onRefresh:r,onClose:i,onKill:a}){let{t:o}=U(`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(jN(e))-Number(jN(t))||t.startedAt-e.startedAt)},[e,s,o]);if(d)return(0,$.jsx)(zN,{process:e.find(e=>mj(e)===mj(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)(vr,{open:!0,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(rr,{children:[(0,$.jsx)(_r,{className:`z-[80]`}),(0,$.jsxs)(ir,{"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)(xd,{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)(dr,{className:`text-sm font-semibold`,children:o(`backgroundProcess.history.title`)}),(0,$.jsx)(cr,{className:`mt-1 text-xs text-muted-foreground`,children:o(`backgroundProcess.history.description`)})]}),(0,$.jsx)(pr,{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)(Vn,{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)(In,{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)(Lu,{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)(ac,{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)(xd,{className:`h-4 w-4 shrink-0 ${jN(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:IN(e.command)}),(0,$.jsxs)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:[IN(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`:jN(e)?`bg-muted text-muted-foreground`:`bg-accent-info/10 text-accent-info`}`,children:o(`backgroundProcess.status.${e.status}`)}),(0,$.jsx)(Cn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]},mj(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)(An,{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 HN(e={}){let t=e.enabled!==!1,[n,r]=(0,Q.useState)({available:{},availableIds:[],issues:{},launchDescriptors:{},labels:{},loading:!0}),[i,a]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{if(!t)return;let e=0,n=()=>{let t=Date.now();t-e<3e4||(e=t,a(e=>e+1))},r=()=>{e=0,n()};return window.addEventListener(`focus`,n),window.addEventListener(`specrails:providers-detected-changed`,r),()=>{window.removeEventListener(`focus`,n),window.removeEventListener(`specrails:providers-detected-changed`,r)}},[t]),(0,Q.useEffect)(()=>{if(!t)return;let e=!0;return fetch(`${F}/api/available-providers`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{if(!e)return;let n={};for(let[e,r]of Object.entries(t))e===`tiers`||e===`providerIssues`||e===`launchDescriptors`||e===`labels`||typeof r==`boolean`&&on(e)&&(n[e]=r);let i=t.providerIssues&&typeof t.providerIssues==`object`?t.providerIssues:{},a=t.launchDescriptors&&typeof t.launchDescriptors==`object`?t.launchDescriptors:{},o={};if(t.labels&&typeof t.labels==`object`)for(let[e,n]of Object.entries(t.labels))typeof n==`string`&&(o[e]=n);r({available:n,availableIds:Object.keys(n).filter(e=>n[e]),issues:i,launchDescriptors:a,labels:o,loading:!1})}).catch(()=>{e&&r(e=>({...e,loading:!1}))}),()=>{e=!1}},[t,i]),n}function UN(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 WN=[],GN=[];function KN({autoFocus:e=!1,hideProjectSelector:t=!1,queueEditRequest:n}){let{t:r}=U(`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}=OL(),T=(0,Q.useMemo)(()=>S.filter(e=>e.deliveryMode!==`steer`),[S]),{pendingCaptures:E,consumePendingCaptures:D,openBrowser:O}=fj(),{processes:k,history:A=k,historyLoading:j=!1,historyError:M=null,refreshHistory:N,kill:P}=Dj(),[I,ee]=(0,Q.useState)(null),[te,L]=(0,Q.useState)(null),R=(0,Q.useMemo)(()=>[...k].sort((e,t)=>Number(jN(e))-Number(jN(t))||t.startedAt-e.startedAt).slice(0,4),[k]),{projects:z,activeProjectId:B}=ce(),ne=i?.pinned_project_id??l??B,V=i?.id??`__new-mission__`,re=(0,Q.useMemo)(()=>Math.floor(Math.random()*20),[V]),ie=Mi(),ae=(0,Q.useRef)(null);ae.current!==V&&(bi(V),ae.current=V),ai(V);let[H,W]=(0,Q.useState)(null),G=H&&H.key===V?H:null,oe=G?G.text:Xr.get(V)??``,se=G?WN:Qr.get(V)??WN,le=Zr.get(V)??GN,ue=(e,t=[])=>oi(V,e,t),[de,fe]=(0,Q.useState)(null),pe=(e,t)=>{let n=Zr.get(e)??GN;si(e,typeof t==`function`?t(n):t)},[q,me]=(0,Q.useState)(!1),[he,ge]=(0,Q.useState)(!1),_e=(0,Q.useRef)(!1),J=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useMemo)(()=>[...new Map(se.map(({chip:e})=>[JSON.stringify([e.projectId,Fj(e)]),e])).values()],[se]),[be,xe]=(0,Q.useState)(null),[Se,Ce]=(0,Q.useState)(0),[we,Te]=(0,Q.useState)(!1),[Ee,De]=(0,Q.useState)([]),[Oe,ke]=(0,Q.useState)([]),[Ae,je]=(0,Q.useState)([]),Me=de!==null,Ne=(0,Q.useMemo)(()=>a.filter(e=>e.role===`user`).map(e=>e.content),[a]),Pe=G?.queueId??null,Fe=(0,Q.useRef)(``),Ie=Pe===null?-1:T.findIndex(e=>e.queueId===Pe),Le=Ie>=0?T[Ie]:null,Re=G!==null;(0,Q.useEffect)(()=>{if(q||he||Re)return US(V)},[V,q,he,Re]);let ze=c===!1||(i?!ie.isEditable(i.id):!!ie.current),Be=!ze&&!Re,Ve=i?.provider??u,{availableIds:He,labels:Ue}=HN(),We=(0,Q.useMemo)(()=>[Ve,...He].filter((e,t,n)=>on(e)&&n.indexOf(e)===t),[Ve,He]),Ge=e=>r(`provider.${e}`,{defaultValue:Ue?.[e]??e}),Ke=i?i.pinned_project_id:l,qe=Ke,Je=be?.mode===`reference`?be.query.trim():``,Ye=`${qe??``}:${Je}`,[Xe,Ze]=(0,Q.useState)({key:``,items:[]});(0,Q.useEffect)(()=>{let e=z.find(e=>e.id===qe);if(!e||Je.length<2)return;let t=new AbortController,n=setTimeout(()=>{let n=new URLSearchParams({kind:`find`,q:Je,limit:`20`});fetch(`${F}/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||Ze({key:Ye,items:Aj(e,r.matches??[])})}).catch(()=>{})},180);return()=>{clearTimeout(n),t.abort()}},[qe,z,Je,Ye]);let Qe=(0,Q.useMemo)(()=>({projects:z,conversations:o,activeConversation:i,pinnedProjectId:qe,activeProjectId:B,tickets:Ee,jobs:Oe,rails:Ae,chips:ye}),[z,o,i,qe,B,Ee,Oe,Ae,ye]),$e=(0,Q.useMemo)(()=>be?[...Zj(be.mode,Qe),...be.mode===`reference`&&Je.length>=2&&Xe.key===Ye?Xe.items:[]]:[],[be,Qe,Xe,Ye,Je]),et=(0,Q.useMemo)(()=>{if(!be)return[];let e=Gj($e,be.query);return e.length>0?e:Qj(be.mode,be.query)},[$e,be]),tt=be!==null&&!Re,nt=oe.trim().length>0||ye.length>0,rt=[`accent-primary`,`accent-info`,`accent-highlight`],it=i?.id??null;(0,Q.useEffect)(()=>{ee(null),L(null)},[it,ne]),(0,Q.useEffect)(()=>{fe(null),xe(null),Te(!1),W(null)},[it]),(0,Q.useEffect)(()=>{if(!qe){De([]),ke([]),je([]);return}let e=!0;return(async()=>{try{let[t,n]=await Promise.all([fetch(`${F}/api/projects/${encodeURIComponent(qe)}/tickets`),fetch(`${F}/api/projects/${encodeURIComponent(qe)}/jobs?limit=25`)]),r=await t.json(),i=await n.json();if(!e)return;De(Array.isArray(r.tickets)?r.tickets:[]),ke(Array.isArray(i.jobs)?i.jobs:[])}catch{if(!e)return;De([]),ke([])}try{let t=await fetch(`${F}/api/projects/${encodeURIComponent(qe)}/rails`),n=t.ok?await t.json():null;if(!e)return;je(jj(n))}catch{e&&je([])}})(),()=>{e=!1}},[qe]),(0,Q.useEffect)(()=>{Ce(0)},[be?.mode,be?.query]),(0,Q.useEffect)(()=>{Se>=et.length&&Ce(Math.max(0,et.length-1))},[Se,et.length]),(0,Q.useEffect)(()=>{if(E.length===0)return;let e=D();e.length&&pe(V,t=>[...t,...e])},[E,D,V]);let at=bM(Ve),{models:ot,efforts:st,supportsImageInput:ct,customModelAliases:lt}=at,ut=(i?i.model:d)??ot.find(e=>e.default)?.value??ot[0]?.value??``,dt=qt(Ve,ut),ft=st.filter(e=>dt.includes(e)),mt=i?i.reasoning_effort:p,Y=mt&&ft.includes(mt)?mt:cn(Ve,ut)??``,ht=e=>{Si(e)},gt=async e=>{if(e.length===0)return;me(!0);let t=i;if(!t)try{t=await x(),ht(t.id)}catch(e){K.error(e instanceof Error?e.message:r(`workspace.uploadFailed`)),me(!1);return}for(let n of e){if(!ct&&n.type.startsWith(`image/`)){K.error(r(`imagesUnsupported`));continue}try{let e=await Mo(t.id,n);pe(t.id,t=>[...t,e])}catch(e){K.error(e instanceof Error?e.message:r(`workspace.uploadFailed`))}}me(!1)},_t=async e=>{try{i&&await Io(i.id,e),pe(V,t=>t.filter(t=>t.id!==e))}catch(e){K.error(e instanceof Error?e.message:`Failed to remove attachment.`)}},yt=(e,t,n=se)=>{if(n.some(e=>t>e.start&&t<=e.end)){xe(null);return}let r=Pj(e,t);xe(r),r&&Te(!1)},bt=e=>e===`reference`?`@`:e===`trace`?`#`:`/`,xt=e=>{requestAnimationFrame(()=>{ve.current?.focus(),ve.current?.setSelectionRange(e,e)})},St=e=>{if(Re)return;let t=bt(e),n=ve.current,r=n?.selectionStart??oe.length,i=n?.selectionEnd??r,a=UN(oe,se,r,i,t);ue(a.text,a.references),fe(null),Te(!1),xe({mode:e,trigger:t,query:``,start:r,end:r+1}),xt(r+1)},Ct=e=>{ve.current?.focus();let t=$j(oe,be,e),n=be?.start??oe.length,r=be?.end??n,i=t.text.slice(n,t.caret),{references:a}=UN(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)}ue(t.text,a),fe(null),xe(null),Te(!1),xt(t.caret)},wt=e=>{let t=T[e];t&&(Fe.current=t.text,W({key:V,queueId:t.queueId,text:t.text}))},Tt=e=>{Me&&ue(``),fe(null),wt(e)};(0,Q.useEffect)(()=>{if(!n||n.conversationId!==i?.id)return;let e=T.findIndex(e=>e.queueId===n.queueId);e<0||(Re?wt(e):Tt(e),xt(T[e].text.length))},[n]);let Et=(e,t)=>{let n=t??oe;W(null),e===`keep`&&ue(n)},Dt=async()=>{let e=Le,t=oe.trim();if(!(!e||!t))try{await C(e.queueId,t)===`saved`?Et(`restore`):(K.info(r(`queueEdit.dispatched`)),Et(`keep`))}catch{K.error(r(`queueEdit.saveFailed`))}};(0,Q.useEffect)(()=>{if(!G||T.some(e=>e.queueId===G.queueId))return;let e=oe!==Fe.current;w(G.queueId)&&K.info(r(`queueEdit.dispatched`)),Et(e?`keep`:`restore`)},[Pe,T,Re]);let Ot=async()=>{if(ze||!nt||_e.current)return;let e=oe.trim()||ye.map(e=>e.token).join(` `),t={...le.length?{attachmentIds:le.map(e=>e.id)}:{},...ye.length?{contextRefs:ye.map(Ij)}:{}},n=JSON.stringify([e,t]),i=$r.get(V),a=i?.signature===n?i:{signature:n,queueId:`q-${crypto.randomUUID()}`},o={text:oe,references:se,attachments:le,submission:a};ci(V,a),di(V,o),xe(null),Te(!1),fe(null),_e.current=!0,ge(!0);try{let n=await h(e,{...t,queueId:a.queueId}),r=n.conversationId??V;if(!n.accepted){ci(r,a),fi(r,o);return}ci(V,null),ci(r,null)}catch(e){fi(V,o),K.error(e instanceof Error?e.message:r(`queueEdit.saveFailed`))}finally{_e.current=!1,ge(!1)}},kt=e=>{if(Ne[e]===void 0){fe(null);return}fe(e),ue(Ne[e])};return(0,$.jsxs)(`div`,{className:`@container shrink-0`,children:[Re&&Le&&(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)(jn,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:r(`queueEdit.editing`,{n:Ie+1,m:T.length})}),(0,$.jsx)(`span`,{className:`truncate text-foreground/45`,children:r(`queueEdit.hint`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Et(`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)(Vn,{className:`h-3 w-3`})})]}),Me&&(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-[11px] text-foreground/50`,children:[(0,$.jsx)(Uu,{className:`h-3 w-3`}),r(`history.hint`)]}),le.length>0&&(0,$.jsx)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:le.map(e=>(0,$.jsx)(kj,{conversationId:it,attachment:e,removeLabel:r(`close`),onRemove:()=>_t(e.id)},e.id))}),R.length>0&&(0,$.jsx)(`div`,{className:`mb-1.5 flex flex-wrap items-center gap-1.5`,children:R.map((e,t)=>(0,$.jsx)(AN,{process:e,accentVariant:rt[t%rt.length],onKill:P,onOpen:ee},mj(e)))}),(0,$.jsxs)(`div`,{"data-testid":`agent-composer-box`,"data-mission-composer":!0,className:`relative flex flex-col gap-2 rounded-3xl border bg-card px-3 py-3 ${Re?`border-accent-highlight/50`:Me?`border-accent-info/40`:`border-border/30`}`,onDragOver:e=>{Be&&e.preventDefault()},onDrop:e=>{if(!Be)return;e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&>(t)},children:[(0,$.jsx)(mM,{active:s,radius:`1.5rem`,inset:-1}),tt&&(0,$.jsx)(TM,{items:et,mode:be.mode,query:be.query,activeIndex:Se,onActiveIndexChange:Ce,onSelect:Ct}),Be&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`input`,{ref:J,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);t.length&>(t),e.target.value=``}})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(RM,{ref:ve,value:oe,references:Re?[]:se,autoFocus:e,onChange:(e,t,n)=>{if(Re){W(t=>t&&{...t,text:e});return}Me&&fe(null),ue(e,t),yt(e,n,t)},onSelect:e=>{Re||yt(ve.current?.value??oe,e)},onKeyDown:e=>{if(e.nativeEvent.isComposing)return;if(e.key===`Tab`&&e.shiftKey){e.preventDefault(),e.stopPropagation(),_();return}if(tt){if(e.key===`ArrowDown`){e.preventDefault(),et.length>0&&Ce(e=>Math.min(et.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),et.length>0&&Ce(e=>Math.max(0,e-1));return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=et[Se]??et[0];t&&Ct(t);return}if(e.key===`Escape`){e.preventDefault(),xe(null);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),Re?Dt():Ot();return}if(e.key===`Escape`&&Re){e.preventDefault(),e.stopPropagation(),Et(`restore`);return}let t=ve.current,n=t?.selectionStart===0&&t?.selectionEnd===0,r=t?.selectionStart===oe.length&&t?.selectionEnd===oe.length;if(e.key===`ArrowUp`){if(Re){Le!==null&&oe===Le.text&&n&&Ie>0&&(e.preventDefault(),wt(Ie-1));return}if(T.length>0){n&&(e.preventDefault(),Tt(T.length-1));return}!Me&&oe===``&&Ne.length>0?(e.preventDefault(),kt(Ne.length-1)):Me&&(e.preventDefault(),kt(Math.max(0,de-1)));return}if(e.key===`ArrowDown`){if(Re){Le!==null&&oe===Le.text&&r&&(e.preventDefault(),Ie<T.length-1?wt(Ie+1):Et(`restore`));return}if(T.length>0)return;Me&&(e.preventDefault(),de<Ne.length-1?kt(de+1):(fe(null),ue(``)));return}(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&Me&&fe(null)},onPaste:e=>{if(!Be)return;let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),gt(t))},disabled:ze,placeholder:ze?r(`noProvider.placeholder`):s?r(`queue.placeholder`):r(`missionPlaceholders.${re}`,{defaultValue:r(`composerPlaceholder`)}),title:Re?r(`queueEdit.hint`):Me?r(`history.hint`):void 0,className:`min-h-[2.5rem] max-h-64 min-w-0 w-full resize-none overflow-y-auto bg-transparent text-sm outline-none ${Me?`italic text-foreground/50`:`text-foreground`}`},V)}),(0,$.jsxs)(`div`,{className:`flex w-full items-center gap-1`,"data-testid":`agent-composer-controls`,children:[!Re&&(0,$.jsx)(EM,{open:we,canAttach:Be,uploading:q,onToggle:()=>{Te(e=>!e),xe(null)},onClose:()=>Te(!1),onOpenMode:St,onAttachFile:()=>{Te(!1),J.current?.click()},canBrowserCapture:pt()&&!!(qe??B),onOpenBrowser:()=>{Te(!1),O()}}),(0,$.jsx)(rM,{compact:!0,level:i?.tier_level??f,onCycle:()=>void _()}),it&&ne&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>L({chatId:it,projectId:ne}),"aria-label":r(`backgroundProcess.history.open`),title:r(`backgroundProcess.history.open`),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md p-1.5 text-xs 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)(xd,{className:`h-4 w-4`,"aria-hidden":!0})}),` `,i===null&&!t&&(0,$.jsx)(`div`,{className:`flex min-w-0 items-center overflow-hidden [&_button]:h-8 [&_button]:text-sm [&_button_span]:max-w-20 @max-[640px]:[&_button_span]:hidden`,children:(0,$.jsx)(eM,{pinnedProjectId:l,onSelect:e=>void b(e)})}),(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 max-w-[60%] items-center gap-1`,children:[(0,$.jsx)(vM,{provider:Ve,providers:We.map(e=>({value:e,label:Ge(e)})),models:ot,model:ut,efforts:ft,effort:Y,defaultEffort:cn(Ve,ut)??``,status:at.status,customModelAliases:lt,onProvider:e=>{v(e).catch(()=>K.error(r(`error.generic`)))},onModel:e=>{y(e).catch(()=>K.error(r(`error.generic`)))},onEffort:e=>{m(e).catch(()=>K.error(r(`error.generic`)))}}),s&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void g(),"aria-label":r(`stop`),title:r(`stop`),className:`inline-flex h-8 w-8 items-center justify-center shrink-0 rounded-full bg-destructive p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(Nn,{className:`h-4 w-4`,fill:`currentColor`})}),Re?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Dt(),disabled:ze||!oe.trim(),"aria-label":r(`queueEdit.save`),title:r(`queueEdit.save`),className:`inline-flex h-8 w-8 items-center justify-center shrink-0 rounded-full bg-accent-highlight p-1.5 text-white transition-opacity hover:opacity-90 disabled:opacity-40`,children:(0,$.jsx)(xn,{className:`h-4 w-4`})}):s?(0,$.jsx)(`button`,{type:`button`,onClick:Ot,disabled:ze||!nt||he,"aria-label":r(`queue.send`),title:r(`queue.sendHint`),className:`relative inline-flex h-8 w-8 items-center justify-center shrink-0 rounded-full bg-accent-info p-1.5 text-white transition-colors hover:opacity-90`,children:(0,$.jsx)(vt,{className:`h-4 w-4`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Ot,disabled:ze||!nt||he,"aria-label":r(`send`),className:`inline-flex h-8 w-8 items-center justify-center shrink-0 rounded-full bg-accent-primary p-1.5 text-white transition-opacity disabled:opacity-40`,children:(0,$.jsx)(vt,{className:`h-4 w-4`})})]})]})]}),Ke&&(0,$.jsx)(xM,{projectId:Ke}),I&&I.chatId===it&&I.projectId===ne&&(0,$.jsx)(zN,{process:A.find(e=>mj(e)===mj(I))??I,onClose:()=>ee(null),onKill:P}),te&&te.chatId===it&&te.projectId===ne&&(0,$.jsx)(VN,{processes:A,loading:j,error:M,onRefresh:N,onClose:()=>L(null),onKill:P})]})}var qN=e=>e===`running`||e===`queued`;function JN(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 YN(){try{return R()}catch{return null}}var XN=e=>{if(!e)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null};function ZN(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(`${F}/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(XN(t.started_at)),d(XN(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=qN(o)&&u===null,C=YN(),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(XN(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 QN(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var $N=15e3;function eP(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function tP(e){let{projectId:t,jobId:n,timeoutMs:r=$N}=e,i=t?`${F}/api/projects/${t}`:G(),a;try{a=await fetch(`${i}/jobs/${n}/cancel`,{method:`POST`,signal:eP(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 nP=null;function rP(e){nP=e}function iP(e,t){nP?.(e,t)}var aP=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-CkAejD1F.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,77,78,79,80,81,82,83,84,85,86,87]))),oP={building:On,on_review:On,pr_draft:ve,pr_ready:ve,no_changes:sc,completed:sc,pr_closed:Tn,superseded:ve,implementation_failed:zn,pr_failed:zn,merged:hl,discarded:Tn},sP={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 cP({envelope:e}){let{t}=U(`agent`),n=bt(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 lP({prDeliveryId:e,projectId:t}){let{t:n}=U(`agent`),r=y(),{activeProjectId:i,setActiveProjectId:a}=ce();return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let n=`/review/${e}`;i!==t&&(iP(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)(qc,{className:`h-3 w-3`}),n(`prCard.openReview`)]})}function uP(e,t,n){if(e.decision===`building`)return n?`paused`:t?.status===`stalled`?`stalled`:`running`;if(t?.active)return`running`;let r=e.runtime?.status;return r===`running`?`running`:r===`failed`||r===`stalled`||r===`cancelled`||r===`succeeded`?r:e.runtime?.failure?e.runtime.failure.code===`stalled`||e.runtime.failure.code===`stuck`?`stalled`:`failed`:e.decision===`implementation_failed`||e.implementationOutcome===`failed`?`failed`:e.decision===`discarded`?`cancelled`:e.decision===`completed`||e.decision===`merged`||e.decision===`on_review`||e.decision===`pr_draft`||e.decision===`pr_ready`||e.decision===`no_changes`?`succeeded`:`unknown`}var dP={running:`border-accent-info/40 bg-accent-info/10 text-accent-info`,paused:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,succeeded:`border-accent-success/40 bg-accent-success/10 text-accent-success`,failed:`border-destructive/40 bg-destructive/10 text-destructive`,stalled:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,cancelled:`border-border/60 bg-surface/60 text-foreground/55`,unknown:`border-border/60 bg-surface/60 text-foreground/55`};function fP({status:e}){let{t}=U(`agent`);return(0,$.jsxs)(`span`,{"data-testid":`mission-run-status`,"data-status":e,className:X(`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,dP[e]),children:[(e===`running`||e===`paused`)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 rounded-full`,e===`running`?`animate-pulse bg-accent-info`:`bg-accent-warning`)}),t(`runCard.status.${e}`)]})}function pP({envelope:e}){let{t}=U(`agent`),n=e.runtime?.failure??null,r=n?.code??e.statusCode??null,i=n?.detail??e.statusDetail??null,a=(e.units??[]).filter(e=>e.failureCode).map(e=>({ticketId:e.ticketId,code:e.failureCode}));return!r&&!i&&a.length===0?null:(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-destructive/30 bg-destructive/[0.06] px-2.5 py-2 text-[11px]`,"data-testid":`mission-run-failure`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(zn,{className:`h-3.5 w-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`font-medium text-destructive`,children:t(`runCard.failure.title`)}),r&&(0,$.jsx)(`span`,{className:`rounded-full border border-destructive/40 bg-destructive/10 px-2 py-px font-mono text-[10px] text-destructive`,"data-testid":`mission-run-failure-code`,children:r}),n?.stepId&&(0,$.jsx)(`span`,{className:`rounded-full border border-border/60 bg-surface/60 px-2 py-px font-mono text-[10px] text-foreground/60`,children:t(`runCard.failure.step`,{step:n.stepId})})]}),i&&(0,$.jsx)(`p`,{className:`mt-1 break-words leading-4 text-foreground/70`,"data-testid":`mission-run-failure-detail`,children:i}),a.length>0&&(0,$.jsx)(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[10px] text-foreground/55`,children:a.map(e=>(0,$.jsx)(`li`,{children:t(`runCard.failure.unit`,{ticket:e.ticketId,code:e.code})},`${e.ticketId}-${e.code}`))})]})}function mP(e,t){let n=e.runtime;return n?{runId:t,status:n.status,nextStep:n.currentStep,recoverableSteps:n.recoverableSteps,active:n.status===`running`,canResume:n.canResume,canCancel:n.status===`running`,...n.pendingApproval&&n.failure?.stepId?{pendingApproval:{stepId:n.failure.stepId}}:{}}:null}function hP(e){let t=/\/pull\/(\d+)/.exec(e);return t?`#${t[1]}`:null}function gP({projectId:e,runId:t,ticketLabel:n,live:r,onOpen:i,onVitals:a}){let{t:o}=U(`agent`),s=ZN(e,t,{live:r}),c=n??t.slice(0,8),l=s.elapsedMs==null?null:JN(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)(Yu,{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 _P({envelope:e,conversationId:t}){let{t:n}=U(`agent`),r=u(),{projects:i}=ce(),{applyPrDecisionSnapshot:a}=OL(),{openWebView:o,canOpenWebView:s}=ot(),{openRef:c}=IC(),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(null),M=A??e,N=zt(M.projectId).has(M.prDeliveryId),[P,I]=(0,Q.useState)(null),[ee,te]=(0,Q.useState)({}),[L,R]=(0,Q.useState)(null),{decision:z,prUrl:B,prState:ne}=M,V=Xe&&M.hasDelivery===!1,re=Xe?M.runtime?.failure??null:null,ie=(M.runIds??[])[0]??null,ae=Xe&&!!ie&&(z===`building`||!!re||z===`implementation_failed`||M.runtime?.status===`running`),H=Mr(M.projectId,{jobId:ie??void 0,enabled:ae}),W=H.runs.find(e=>e.runId===ie)??H.runs[0]??null,G=W??(ie?mP(M,ie):null),[oe,se]=(0,Q.useState)(!1),le=(0,Q.useRef)(!1),[ue,de]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{de(!1),pe(null)},[M.prDeliveryId]);let q=(0,Q.useRef)(null),[me,he]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!Xe)return;let e=e=>{let n=e.detail;oj(n,{prDeliveryId:M.prDeliveryId,runIds:M.runIds})&&(q.current?.scrollIntoView?.({behavior:`smooth`,block:`center`}),he(!0),t&&clearTimeout(t),t=setTimeout(()=>he(!1),1400))},t=null;return window.addEventListener(ij,e),()=>{window.removeEventListener(ij,e),t&&clearTimeout(t)}},[M.prDeliveryId,M.runIds]);let ge=me?`ring-2 ring-accent-primary/50 ring-offset-1 ring-offset-background`:``,_e=!!M.repositoryDeliveries?.length,J=bt(M),ye=yt(M.statusCode,M.statusDetail),be=M.operation==null&&ye,xe=i.find(e=>e.id===M.projectId)?.name??M.projectId,Se=z===`pr_draft`&&!B,Ce=z===`building`&&ne===`pr-created`&&!!M.branch,we=M.prNumber?`#${M.prNumber}`:B?hP(B):null,Te=J.terminal,Ee=xt(M.statusCode)?n(`common:prDeliveryStatus.${M.statusCode}`):null,De=J.partial&&J.deliverableCount>0&&(z===`on_review`||z===`pr_draft`&&!B);(0,Q.useEffect)(()=>{j(null)},[e]);let Oe=(0,Q.useRef)(!1);Oe.current=l!==null||f||M.operation!=null||H.busy!==null,(0,Q.useEffect)(()=>{d(null),h(!1),_(!1),y(!1),C(!1),T(!1),D(!1),k(!1)},[z,B,M.prDeliveryId]);let ke=(0,Q.useCallback)((e,t)=>{te(n=>{let r=n[e];return r?.paused===t.paused&&r?.pausedReason===t.pausedReason?n:{...n,[e]:t}})},[]),Ae=async e=>{if(!L){R(e);try{let t=await tP({projectId:M.projectId,jobId:e,kind:`loop-run`});t.ok?K.info(n(`prCard.stopExecutionSent`)):K.error(n(`prCard.stopExecutionFailed`),{description:t.error})}finally{R(null)}}},je=async(e,r)=>{if(f||l||M.operation||_e&&!r&&[`create-pr`,`merge-local`,`publish`,`poll-merge`,`reopen`,`acknowledge-no-changes`].includes(e))return;let i=M.repositoryDeliveries?.find(e=>e.repositoryId===r),o=i?.integrationBranch??i?.baseBranch??M.baseBranch;d(e);try{let i=await Yo(M.projectId,{prDeliveryId:M.prDeliveryId,action:e,expectedDecision:z,...r?{repositoryId:r}:{},...V&&t?{conversationId:t}:{}}),s=null;if(i.snapshot){let e=Xo(M,i.snapshot);s=a(e),s!==`stale`&&j(e)}if(s===`stale`){K.info(n(`prCard.alreadyResolved`));return}if(i.kind===`recovering`)K.info(n(`common:prRecovery.inProgress`));else if(i.kind===`busy`)K.info(n(`prCard.operation.${i.operation??`inProgress`}`));else if(i.kind===`stale`)K.info(n(`prCard.alreadyResolved`));else if(i.kind===`blocked`)K.warning(i.reason===`dirty`?n(`prCard.mergeLocalBlockedDirty`,{base:i.base||o}):n(`prCard.mergeLocalBlockedBranch`,{base:i.base||o,current:i.current??`?`}));else if(i.kind===`failed`)K.error(n(`prCard.actionFailed`),{description:i.detail});else if(i.kind===`ok`&&e===`recover-and-retry`)if(i.deliveryVerified){let e=(i.verifiedSha??i.snapshot?.deliverySha??``).slice(0,8);K.success(n(`prCard.recoverAndRetryVerified`,{sha:e}))}else i.recoveryUnavailable||i.snapshot?.statusCode===`recovery_unavailable`?K.info(n(`prCard.recoveryUnavailable`),{description:n(`prCard.recoveryUnavailableBody`)}):K.warning(n(`prCard.recoveryStillBlocked`),{description:i.detail??void 0});else if(i.kind===`ok`&&e===`create-pr`&&J.retryablePush&&i.deliveryVerified){let e=(i.verifiedSha??i.snapshot?.deliverySha??M.deliverySha??``).slice(0,8);K.success(n(i.pushed?`prCard.retryPushVerified`:`prCard.commitAlreadyVerified`,{sha:e}))}else if(i.kind===`ok`&&e===`create-pr`&&i.detail)K.error(n(`prCard.deliveryNeedsAttention`),{description:i.detail});else if(i.kind===`ok`&&e===`poll-merge`&&i.deliveryVerified===!1)K.warning(n(`prCard.commitMissingRetry`));else if(i.kind===`ok`&&e===`poll-merge`&&i.deliveryVerified&&!i.merged){let e=(i.verifiedSha??i.snapshot?.deliverySha??M.deliverySha??``).slice(0,8);K.success(n(`prCard.prVerifiedWaiting`,{sha:e}))}else e===`poll-merge`&&!i.merged&&i.decision!==`pr_closed`?K.info(n(`prCard.notMergedYet`)):e===`merge-local`&&i.kind===`ok`&&i.decision===`merged`&&K.success(n(`prCard.mergedLocally`,{base:o}));i.kind===`ok`&&(e===`create-pr`||e===`discard`||e===`merge-local`||e===`recover-and-retry`)&&Et(M.projectId)}catch(e){K.error(n(`prCard.actionFailed`),{description:e instanceof Error?e.message:void 0})}finally{d(null)}},Me=async e=>{if(!(_e&&!e)&&!(l||f||M.operation)){p(!0);try{let t=await(e?Zo(M.projectId,M.prDeliveryId,e):Zo(M.projectId,M.prDeliveryId));t.kind===`ok`?(K.success(n(`prCard.checkoutSuccess`,{branch:t.branch??Nt(M)??``})),t.cleanupWarnings.length>0&&K.warning(n(`prCard.cleanupIncomplete`,{count:t.cleanupWarnings.length}),{description:t.cleanupWarnings.join(`
|
|
45
45
|
`)}),Et(M.projectId)):t.kind===`recovering`?K.info(n(`common:prRecovery.inProgress`)):t.error===`checkout_dirty`?K.warning(n(`prCard.checkoutDirtyTitle`),{description:n(`prCard.checkoutDirtyBody`)}):t.error===`checkout_not_deliverable`?K.warning(n(`prCard.checkoutNotDeliverableTitle`),{description:n(`prCard.checkoutNotDeliverableBody`)}):t.error===`checkout_safety_unknown`?K.warning(n(`prCard.checkoutSafetyUnknownTitle`),{description:n(`prCard.checkoutSafetyUnknownBody`)}):K.warning(n(`prCard.checkoutFailed`),{description:t.detail})}catch(e){K.error(n(`prCard.checkoutFailed`),{description:e instanceof Error?e.message:void 0})}finally{p(!1)}}},Ne=async()=>{let e=J.recoveryWorktreePaths;if(e.length===0){K.info(n(`prCard.localResultUnavailableHere`));return}let t=e.join(`
|
|
46
46
|
`),r=!1;try{await navigator.clipboard.writeText(t),r=!0}catch{}try{S()&&await x(e[0])}catch{}r?K.success(n(`prCard.localResultPathCopied`),{description:t}):K.info(n(`prCard.localResultPath`),{description:t})},Pe=async()=>{if(!(le.current||ue||Oe.current)){le.current=!0,se(!0),pe(null);try{let e=await fetch(`${F}/api/projects/${encodeURIComponent(M.projectId)}/rails/${M.railIndex}/relaunch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sourceId:M.prDeliveryId,...t?{originConversationId:t,originSurface:`agent-chat`}:{}})});if(e.status===202){de(!0),K.success(n(`runCard.relaunchSent`,{index:M.railIndex+1})),Et(M.projectId);return}let r=await e.json().catch(()=>({})),i=[r.detail??r.error,r.action].filter(Boolean).join(` — `)||`HTTP ${e.status}`;pe(i),K.error(n(`runCard.relaunchFailed`),{description:i})}catch(e){let t=e instanceof Error?e.message:n(`runCard.relaunchFailed`);pe(t),K.error(n(`runCard.relaunchFailed`),{description:t})}finally{le.current=!1,se(!1)}}},Fe=(e,t)=>{s&&(e.preventDefault(),e.stopPropagation(),o(t))},Ie=M.ticketIds.length>0&&(0,$.jsx)($.Fragment,{children:M.ticketIds.map(e=>(0,$.jsxs)(VA,{refTarget:{kind:`ticket`,ticketId:e},onOpen:e=>void c(M.projectId,e),children:[`#`,e]},e))}),Le=M.runIds??[],Re=e=>Le.length===1&&M.ticketIds.length>1?M.ticketIds.map(e=>`#${e}`).join(` `):M.ticketIds[e]==null?null:`#${M.ticketIds[e]}`,ze=Le.find(e=>ee[e]?.paused)??null,Be=ze?ee[ze]?.pausedReason??null:null,He=Le.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,"data-testid":`pr-run-log-chips`,children:Le.map((e,t)=>(0,$.jsx)(gP,{projectId:M.projectId,runId:e,ticketLabel:Re(t),live:z===`building`,onOpen:I,onVitals:ke},e))}),Ue=z===`building`&&ze!==null,We=ze?Re(Le.indexOf(ze))??ze.slice(0,8):null,Ge=ze&&W?.runId===ze&&!W.pendingQuestion&&!W.pendingApproval&&(W.recoverableSteps.length>0||W.canResume)?W:null,Ke=Ge?.recoverableSteps.length?Ge.nextStep:null,qe=uP(M,W,ze!==null),Je=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium transition-colors disabled:pointer-events-none disabled:opacity-50`,Ye=H.busy!==null||oe,Ze=Xe&&G&&(0,$.jsxs)($.Fragment,{children:[G.canResume&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`mission-run-resume`,disabled:Ye||l!==null,onClick:()=>void H.act(G,`resume`),className:X(Je,`border-accent-primary/40 bg-accent-primary/10 text-accent-primary hover:bg-accent-primary/20`),children:[H.busy===G.runId?(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Mn,{className:`h-3 w-3`}),n(`runCard.actions.resume`)]}),G.pendingApproval&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`mission-run-approve`,disabled:Ye||l!==null,onClick:()=>void H.act(G,`approve`),className:X(Je,`border-accent-success/40 bg-accent-success/10 text-accent-success hover:bg-accent-success/20`),children:[(0,$.jsx)(ad,{className:`h-3 w-3`}),n(`runCard.actions.approve`)]}),G.recoverableSteps.length>0&&(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`mission-run-recover`,disabled:Ye||l!==null,onClick:()=>void H.act(G,`recover`),className:X(Je,`border-accent-warning/40 bg-accent-warning/10 text-accent-warning hover:bg-accent-warning/20`),children:[(0,$.jsx)(Bn,{className:`h-3 w-3`}),n(`runCard.actions.recover`)]})]}),Qe=!!W?.active||qe===`running`||qe===`paused`,$e=Xe&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`mission-run-relaunch`,disabled:Ye||l!==null||Qe||ue,title:Qe?n(`runCard.relaunchBlockedActive`):void 0,onClick:()=>void Pe(),className:X(Je,`border-border/60 text-foreground/70 hover:border-accent-primary/40 hover:bg-accent-primary/10`),children:[oe?(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Fn,{className:`h-3 w-3`}),n(`runCard.actions.relaunch`)]}),fe&&(0,$.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,"data-testid":`mission-run-relaunch-error`,children:fe})]}),et=Xe&&H.error&&ae?(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-destructive/80`,"data-testid":`mission-run-runtime-error`,children:H.error}):null,tt=Xe&&W?.nextStep?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1 truncate text-[11px] text-foreground/50`,"data-testid":`mission-run-phase`,children:[(0,$.jsx)(Cs,{className:`h-3 w-3 shrink-0 opacity-60`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:W.nextStep})]}):null,nt=P&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(aP,{jobId:P,projectId:M.projectId,onClose:()=>I(null)})});if(z===`building`)return(0,$.jsxs)(`div`,{ref:q,"data-testid":`agent-pr-decision-card`,className:X(`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 transition-shadow`,ge),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Ue?(0,$.jsx)(zn,{className:`h-3.5 w-3.5 text-accent-warning`}):Ce?(0,$.jsx)(ve,{className:`h-3.5 w-3.5 text-accent-info`}):(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin text-accent-primary/70`}),(0,$.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate`,!Ce&&!Ue&&`animate-pulse`,Ue&&`text-accent-warning`),children:n(Ue?`prCard.title.paused`:Ce?`prCard.title.buildingExistingPr`:V?`prCard.title.buildingInPlace`:`prCard.title.building`)}),Xe&&(0,$.jsx)(fP,{status:qe}),Xe&&(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:M.railName?M.railName:n(`prCard.rail`,{index:M.railIndex+1})})]}),tt&&(0,$.jsx)(`div`,{className:`mt-1 flex items-center pl-[22px]`,children:tt}),Ie&&(0,$.jsx)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-[22px]`,children:Ie}),Ce&&(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=>Fe(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)(ve,{className:`h-3 w-3`}),we??n(`prCard.openPr`),(0,$.jsx)(Dn,{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)(ve,{className:`h-3 w-3`}),we??n(`prCard.existingPr`)]}),(0,$.jsxs)(`span`,{title:n(`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)(On,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsx)(`span`,{className:`truncate`,children:M.branch})]})]}),Ue&&ze&&(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)(zn,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:Be??void 0,children:[We?n(`prCard.pausedForRun`,{ref:We}):n(`prCard.paused`),Be?`: ${Be}`:``]}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`pr-run-paused-resume`,disabled:Ye,title:Ke?n(`prCard.resumeFromStepHint`,{step:Ke}):void 0,onClick:e=>{e.stopPropagation(),Ge?H.act(Ge,Ge.recoverableSteps.length?`recover`:`resume`):I(ze)},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 disabled:pointer-events-none disabled:opacity-50`,children:[H.busy===ze?(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Mn,{className:`h-3 w-3`}),Ke?n(`prCard.resumeFromStep`,{step:Ke}):n(`prCard.resume`)]}),(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,disabled:L===ze,onClick:e=>{e.stopPropagation(),Ae(ze)},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:[L===ze?(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Nn,{className:`h-3 w-3`}),n(`prCard.stopExecution`)]})]}),He&&(0,$.jsx)(`div`,{className:`pl-[22px]`,children:He}),(0,$.jsx)(`p`,{className:`mt-1 pl-[22px] text-[11px] leading-4 text-foreground/40`,children:n(V?`runCard.noDeliveryHint`:Ce?`prCard.buildingExistingPrHint`:`prCard.buildingHint`)}),et,nt]});if(V){let e=qe===`succeeded`?sc:qe===`failed`||qe===`stalled`?zn:qe===`cancelled`?Tn:An,t=l!==null||Ye;return(0,$.jsxs)(`div`,{ref:q,"data-testid":`agent-pr-decision-card`,"data-run-only":`true`,className:X(`rounded-xl border border-border/60 bg-card/80 px-3.5 py-3 shadow-lg backdrop-blur-xl transition-shadow`,qe===`succeeded`&&`border-accent-success/30`,qe===`cancelled`&&`opacity-70`,ge),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(e,{className:X(`h-4 w-4 shrink-0`,qe===`succeeded`?`text-accent-success`:qe===`failed`||qe===`stalled`?`text-destructive`:`text-foreground/50`,qe===`running`&&`animate-spin text-accent-primary/70`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:n(`runCard.title.${qe}`)}),(0,$.jsx)(fP,{status:qe}),(0,$.jsx)(`span`,{className:`max-w-[140px] shrink-0 truncate text-[11px] text-foreground/50`,title:xe,children:xe}),(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:M.railName?M.railName:n(`prCard.rail`,{index:M.railIndex+1})})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[(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)(mt,{className:`h-3 w-3 text-accent-secondary/80`}),n(`prCard.specCount`,{count:M.ticketIds.length})]}),Ie,tt]}),He,(0,$.jsx)(cP,{envelope:M}),(re||qe===`failed`||qe===`stalled`)&&(0,$.jsx)(pP,{envelope:M}),(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-foreground/45`,"data-testid":`mission-run-no-delivery`,children:[(0,$.jsx)(On,{className:`mt-px h-3 w-3 shrink-0 opacity-60`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:n(`runCard.noDeliveryNote`)})]}),et,(0,$.jsxs)(jS.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:`easeOut`},className:`mt-2.5 flex flex-wrap items-center gap-1.5`,children:[Ze,qe!==`running`&&qe!==`paused`&&$e,qe!==`running`&&qe!==`paused`&&z!==`discarded`&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(!0),disabled:t,"data-agent-interactive":!0,"data-testid":`mission-run-dismiss`,className:`inline-flex items-center gap-1.5 rounded-md border border-border/60 px-2.5 py-1 text-xs text-foreground/70 transition-colors hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive disabled:cursor-default disabled:opacity-60`,children:[l===`dismiss`&&(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}),n(`prCard.dismiss`)]})]},`${qe}-${M.updatedAt??``}`),(0,$.jsx)(vr,{open:g,onOpenChange:_,children:(0,$.jsxs)(gr,{className:`max-w-sm`,"data-testid":`agent-pr-dismiss-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(`prCard.confirm.dismissTitle`)}),(0,$.jsx)(cr,{children:n(`prCard.confirm.dismissBody`)})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>_(!1),children:n(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:t,"data-testid":`agent-pr-dismiss-confirm-btn`,onClick:()=>{_(!1),je(`dismiss`)},children:n(`prCard.dismiss`)})]})]})}),nt]})}let rt=oP[z],it=J.superseded?n(`prCard.title.superseded`):J.noChanges?n(`prCard.title.no_changes`):J.deliveryBlocked?n(`prCard.title.delivery_blocked`):J.retryablePush?n(`prCard.title.update_failed`):J.closed?n(`prCard.title.pr_closed`):J.partial?n(`prCard.title.partial`):M.statusCode===`existing_pr_updated`?n(`prCard.title.existing_pr_updated`):n(Se?`prCard.title.pr_draft_degraded`:`prCard.title.${z}`),at=`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`,st=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`),ct=l!==null||f||M.operation!=null,lt=!!M.operation||be||J.partial||J.deliveryBlocked||J.retryablePush||J.retryablePrCreation||J.closed||J.implementationFailed,ut=(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`}),dt=(e,t)=>!_e&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void je(e),disabled:ct,"data-agent-interactive":!0,className:at,children:[l===e&&ut,t]}),ft=Ve&&r&&!J.terminal?(0,$.jsx)(lP,{prDeliveryId:M.prDeliveryId,projectId:M.projectId}):null,pt=Nt(M),Y=pt&&!_e&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Me(),disabled:ct,"data-testid":`agent-pr-checkout`,"data-agent-interactive":!0,title:n(`prCard.checkoutTooltip`,{branch:pt}),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:[f?ut:(0,$.jsx)(On,{className:`h-3 w-3`}),n(`prCard.checkout`)]}),ht=J.recoveryWorktreePaths.length>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Ne(),disabled:ct,"data-testid":`agent-pr-inspect-local-result`,"data-agent-interactive":!0,title:n(`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)(sl,{className:`h-3 w-3`,"aria-hidden":!0}),n(`prCard.inspectLocalResult`)]}),gt=J.recoveryRecheck,_t=(J.manualRecovery||gt)&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k(!0),disabled:ct,"data-testid":gt?`agent-pr-recheck-recovery`:`agent-pr-recover-and-retry`,"data-agent-interactive":!0,className:gt?`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`:at,children:[l===`recover-and-retry`?ut:(0,$.jsx)(Fn,{className:`h-3 w-3`,"aria-hidden":!0}),n(gt?`prCard.recheckRecovery`:`prCard.recoverAndRetry`)]}),vt=!_e&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>C(!0),disabled:ct,"data-testid":`agent-pr-merge-local`,"data-agent-interactive":!0,title:n(`prCard.mergeLocalTooltip`,{base:M.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:[l===`merge-local`&&ut,n(`prCard.mergeLocal`)]}),St=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>h(!0),disabled:ct,"data-agent-interactive":!0,className:st,children:[l===`discard`&&ut,n(`prCard.discard`)]}),Ct=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(!0),disabled:ct,"data-agent-interactive":!0,className:st,children:[l===`dismiss`&&ut,n(`prCard.dismiss`)]}),wt=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>y(!0),disabled:ct,"data-agent-interactive":!0,className:st,children:[l===`discard`&&ut,n(`prCard.discardLocalResult`)]}),Tt=!_e&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T(!0),disabled:ct,"data-agent-interactive":!0,className:at,children:[l===`acknowledge-no-changes`&&ut,n(`prCard.markDone`)]}),Dt=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>D(!0),disabled:ct,"data-agent-interactive":!0,className:st,children:[l===`discard`&&ut,n(`prCard.refine`)]}),Ot=B&&(0,$.jsxs)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,onClick:e=>Fe(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)(ve,{className:`h-3 w-3`}),we??n(`prCard.openPr`),(0,$.jsx)(Dn,{className:`h-2.5 w-2.5 opacity-60`})]}),kt=Xe&&(!!re||z===`implementation_failed`||z===`discarded`&&(!!M.statusDetail||M.statusCode===`delivery_failed`));return(0,$.jsxs)(`div`,{ref:q,"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 transition-shadow`,z===`merged`&&`border-accent-success/30`,z===`completed`&&`border-accent-success/30`,z===`discarded`&&`opacity-70`,ge),children:[lt&&(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-label":M.operation?n(`prCard.operation.${M.operation}`):be?n(`common:prRecovery.interrupted`):it,className:`sr-only`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(rt,{className:X(`h-4 w-4 shrink-0`,sP[z])}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:it}),(0,$.jsx)(`span`,{className:`max-w-[140px] shrink-0 truncate text-[11px] text-foreground/50`,title:xe,children:xe}),(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:n(`prCard.rail`,{index:M.railIndex+1})})]}),(0,$.jsx)(Vt,{deliveryId:M.prDeliveryId,repositories:M.repositoryDeliveries,busy:!!l||f||!!M.operation,onAct:je,onCheckout:Me}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[!_e&&(0,$.jsxs)(`span`,{title:n(`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)(On,{className:`h-3 w-3 text-accent-primary/70`}),`→ `,M.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)(mt,{className:`h-3 w-3 text-accent-secondary/80`}),n(`prCard.specCount`,{count:M.ticketIds.length})]}),Ie,Ot,M.deliverySha&&(0,$.jsxs)(`span`,{"data-testid":`agent-pr-delivery-sha`,title:M.deliverySha,className:X(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,M.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)(sc,{className:`h-3 w-3`}),n(`prCard.deliveryCommit`,{sha:M.deliverySha.slice(0,8)})]})]}),He,M.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)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),n(`prCard.operation.${M.operation}`)]}),be&&(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)(Fn,{className:`mt-px h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:n(`common:prRecovery.interrupted`)})]}),(0,$.jsx)(cP,{envelope:M}),kt&&(0,$.jsx)(pP,{envelope:M}),et,Ee&&(0,$.jsx)(`p`,{className:`mt-2 text-[10px] font-medium uppercase tracking-wide text-foreground/45`,"data-testid":`agent-pr-status-code`,children:Ee}),!Te&&J.deliveryBlocked&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(zn,{className:`mt-px h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[J.recoveryUnavailable?n(`prCard.recoveryUnavailableBody`):n(J.partial?`prCard.partialDeliveryBlockedNote`:`prCard.deliveryBlockedNote`),M.statusDetail&&!ye&&!J.recoveryUnavailable?(0,$.jsx)(`span`,{className:`mt-0.5 block text-foreground/50`,children:M.statusDetail}):null]})]}),!Te&&J.recoveryUnavailable&&M.statusDetail&&!ye&&(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:n(`prCard.recoveryDetailSummary`)}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:M.statusDetail})]}),!Te&&J.retryablePush&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(zn,{className:`mt-px h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[n(`prCard.retryPushNote`),M.statusDetail&&!ye?(0,$.jsx)(`span`,{className:`mt-0.5 block text-foreground/50`,children:M.statusDetail}):null]})]}),M.statusDetail&&!ye&&!J.deliveryBlocked&&!J.retryablePush&&!kt&&(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/45`,"data-testid":`agent-pr-status-detail`,children:M.statusDetail}),!Te&&!B&&(ne===`pushed`||ne===`local-only`)&&(0,$.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-[11px] leading-4 text-accent-warning`,children:[(0,$.jsx)(zn,{className:`mt-px h-3 w-3 shrink-0`}),n(ne===`local-only`?`prCard.degraded.localOnly`:`prCard.degraded.pushed`)]}),J.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:n(`prCard.cleanupIncomplete`,{count:J.cleanupWarnings.length})}),(0,$.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4 text-foreground/60`,children:J.cleanupWarnings.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}-${e}`))})]}),J.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:n(`prCard.safetyArchiveTitle`,{count:J.safetyArchives.length})}),(0,$.jsx)(`p`,{className:`mt-1 leading-4`,children:n(`prCard.safetyArchiveHint`)}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[10px] text-foreground/50`,children:J.safetyArchives.map(e=>(0,$.jsx)(`li`,{className:`break-all`,children:e},e))})]}),(0,$.jsxs)(jS.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:`easeOut`},className:`mt-2.5`,children:[J.noChanges&&!Te&&(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)(sc,{className:`h-3.5 w-3.5`}),J.continuation?n(`prCard.noChangesExisting`):n(`prCard.noChangesNote`)]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:J.continuation?Ct:(0,$.jsxs)($.Fragment,{children:[Tt,Dt]})})]}),!Te&&J.deliveryBlocked&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[ht,_t,J.continuation?J.hasDiscardableRecoveryResult?wt:Ct:St]}),!Te&&J.retryablePush&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y,dt(`create-pr`,n(`prCard.retryPush`)),J.continuation?Ct:St]}),!Te&&J.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y,dt(`create-pr`,n(`prCard.retryPr`)),vt,J.continuation?Ct:St]}),!Te&&J.closed&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y,dt(`reopen`,n(`prCard.reopen`)),J.continuation?Ct:St]}),!Te&&De&&!J.deliveryBlocked&&!J.retryablePush&&!J.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y,dt(`create-pr`,n(`prCard.createPartialPr`,{count:J.deliverableCount})),J.continuation?Ct:St]}),z===`on_review`&&!J.noChanges&&!J.partial&&!J.deliveryBlocked&&!J.retryablePush&&!J.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[ft,Y,dt(`create-pr`,n(`prCard.createPr`)),vt,J.continuation?Ct:St]}),z===`pr_draft`&&!Se&&!J.deliveryBlocked&&!J.retryablePush&&!J.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y,dt(`publish`,n(`prCard.publish`)),J.continuation?Ct:St]}),Se&&!De&&!J.deliveryBlocked&&!J.retryablePush&&!J.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y,dt(`create-pr`,n(`prCard.retryPr`)),vt,J.continuation?Ct:St]}),z===`pr_ready`&&!J.deliveryBlocked&&!J.retryablePush&&!J.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y,dt(`poll-merge`,n(`prCard.verifyPr`)),J.continuation?Ct:St]}),z===`pr_failed`&&!J.deliveryBlocked&&!J.retryablePush&&!J.retryablePrCreation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y,dt(`create-pr`,n(`prCard.retry`)),!B&&vt,J.continuation?Ct:St]}),z===`implementation_failed`&&J.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)(zn,{className:`mt-px h-3 w-3 shrink-0`}),n(`prCard.implementationFailedNote`)]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[Ze,$e,J.continuation?Ct:St]})]}),Xe&&z===`discarded`&&M.statusCode===`delivery_failed`&&(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-1.5`,"data-testid":`mission-run-discarded-actions`,children:$e}),z===`merged`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,$.jsx)(sc,{className:`h-3.5 w-3.5`}),n(`prCard.mergedNote`)]}),z===`discarded`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,$.jsx)(Tn,{className:`h-3.5 w-3.5`}),n(`prCard.discardedNote`)]}),z===`completed`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-accent-success`,children:[(0,$.jsx)(sc,{className:`h-3.5 w-3.5`}),n(`prCard.completedNote`)]}),z===`superseded`&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-foreground/50`,children:[(0,$.jsx)(ve,{className:`h-3.5 w-3.5`}),n(`prCard.supersededNote`)]})]},`${z}-${B??``}`),(0,$.jsx)(vr,{open:!_e&&b,onOpenChange:C,children:(0,$.jsxs)(gr,{className:`max-w-sm`,"data-testid":`agent-pr-merge-local-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(`prCard.confirm.mergeLocalTitle`)}),(0,$.jsx)(cr,{children:n(`prCard.confirm.mergeLocalBody`,{base:M.baseBranch})})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>C(!1),children:n(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:ct,"data-testid":`agent-pr-merge-local-confirm-btn`,onClick:()=>{C(!1),je(`merge-local`)},children:n(`prCard.mergeLocal`)})]})]})}),(0,$.jsx)(vr,{open:O,onOpenChange:k,children:(0,$.jsxs)(gr,{className:`max-w-sm`,"data-testid":`agent-pr-recover-and-retry-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(gt?`prCard.confirm.recheckRecoveryTitle`:`prCard.confirm.recoverAndRetryTitle`)}),(0,$.jsx)(cr,{children:n(gt?`prCard.confirm.recheckRecoveryBody`:`prCard.confirm.recoverAndRetryBody`,{branch:M.branch??``})})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>k(!1),children:n(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:ct,"data-testid":`agent-pr-recover-and-retry-confirm-btn`,onClick:()=>{k(!1),je(`recover-and-retry`)},children:n(gt?`prCard.recheckRecovery`:`prCard.recoverAndRetry`)})]})]})}),(0,$.jsx)(vr,{open:m,onOpenChange:h,children:(0,$.jsxs)(gr,{className:`max-w-sm`,"data-testid":`agent-pr-discard-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(z===`implementation_failed`?`prCard.confirm.implementationFailedDiscardTitle`:`prCard.confirm.freshDiscardTitle`)}),(0,$.jsx)(cr,{children:n(z===`implementation_failed`?`prCard.confirm.implementationFailedDiscardBody`:`prCard.confirm.freshDiscardBody`)}),N&&(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:n(`prCard.discardStackedNote`)})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>h(!1),children:n(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:ct,"data-testid":`agent-pr-discard-confirm-btn`,onClick:()=>{h(!1),je(`discard`)},children:n(`prCard.discard`)})]})]})}),(0,$.jsx)(vr,{open:g,onOpenChange:_,children:(0,$.jsxs)(gr,{className:`max-w-sm`,"data-testid":`agent-pr-dismiss-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(`prCard.confirm.dismissTitle`)}),(0,$.jsx)(cr,{children:n(`prCard.confirm.dismissBody`)})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>_(!1),children:n(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:ct,"data-testid":`agent-pr-dismiss-confirm-btn`,onClick:()=>{_(!1),je(`dismiss`)},children:n(`prCard.dismiss`)})]})]})}),(0,$.jsx)(vr,{open:v,onOpenChange:y,children:(0,$.jsxs)(gr,{className:`max-w-sm`,"data-testid":`agent-pr-discard-local-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(`prCard.confirm.discardLocalTitle`)}),(0,$.jsx)(cr,{children:n(`prCard.confirm.discardLocalBody`)})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>y(!1),children:n(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:ct,"data-testid":`agent-pr-discard-local-confirm-btn`,onClick:()=>{y(!1),je(`discard`)},children:n(`prCard.discardLocalResult`)})]})]})}),(0,$.jsx)(vr,{open:!_e&&w,onOpenChange:T,children:(0,$.jsxs)(gr,{className:`max-w-sm`,"data-testid":`agent-pr-no-changes-done-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(`prCard.confirm.noChangesDoneTitle`)}),(0,$.jsx)(cr,{children:n(`prCard.confirm.noChangesDoneBody`)})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>T(!1),children:n(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,disabled:ct,"data-testid":`agent-pr-no-changes-done-confirm-btn`,onClick:()=>{T(!1),je(`acknowledge-no-changes`)},children:n(`prCard.markDone`)})]})]})}),(0,$.jsx)(vr,{open:E,onOpenChange:D,children:(0,$.jsxs)(gr,{className:`max-w-sm`,"data-testid":`agent-pr-refine-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(`prCard.confirm.refineTitle`)}),(0,$.jsx)(cr,{children:n(`prCard.confirm.refineBody`)})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>D(!1),children:n(`common:actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,disabled:ct,"data-testid":`agent-pr-refine-confirm-btn`,onClick:()=>{D(!1),je(`discard`)},children:n(`prCard.refine`)})]})]})}),nt]})}var vP={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 yP({decision:e}){let{t}=U(`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`,vP[e]),children:t(`prCard.pinned.state.${e}`)})}function bP(){let{t:e}=U(`agent`);return(0,$.jsx)(`span`,{"data-testid":`rail-proposal-pill`,className:`inline-flex shrink-0 items-center rounded-full border border-accent-primary/40 bg-accent-primary/10 px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-accent-primary`,children:e(`railCard.status.proposal`)})}var xP=e=>`specrails-desktop:agent-pr-dock-collapsed:${e}`,SP=e=>`specrails-desktop:agent-pr-dock-card-collapsed:${e}`;function CP(e){try{return sessionStorage.getItem(xP(e))===`1`}catch{return!1}}function wP(e,t){try{t?sessionStorage.setItem(xP(e),`1`):sessionStorage.removeItem(xP(e))}catch{}}function TP(e){try{let t=sessionStorage.getItem(SP(e)),n=t?JSON.parse(t):[];return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}}function EP(e,t){try{t.size===0?sessionStorage.removeItem(SP(e)):sessionStorage.setItem(SP(e),JSON.stringify([...t]))}catch{}}function DP({pinned:e,proposals:t=[],projectId:n=null,conversationId:r,inline:i}){let{t:a}=U(`agent`),[o,s]=(0,Q.useState)(()=>CP(r)),[c,l]=(0,Q.useState)(()=>TP(r));(0,Q.useEffect)(()=>{s(CP(r)),l(TP(r))},[r]);let u=e.length+t.length;if(u===0)return null;let d=e.length>0?e[e.length-1]:null,f=e=>{wP(r,e),s(e)},p=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),EP(r,n),n})},m=e=>{let t=a(`prCard.rail`,{index:e.railIndex+1}),n=e.ticketIds.map(e=>`#${e}`).join(` `);return n?`${t} · ${n}`:t};return(0,$.jsx)(jS.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`,i?`px-4 pb-2`:`px-3 pb-2`),children:(0,$.jsx)(`div`,{className:X(i&&`mx-auto w-full max-w-[680px]`),children:o?(0,$.jsxs)(`button`,{type:`button`,"data-testid":`agent-pr-dock-expand`,"data-agent-interactive":!0,onClick:()=>f(!1),"aria-label":a(`prCard.pinned.expand`),title:a(`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)(xu,{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:a(`prCard.pinned.collapsed`,{count:u})}),d?(0,$.jsx)(yP,{decision:d.envelope.decision}):(0,$.jsx)(bP,{}),(0,$.jsx)(Sn,{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)(xu,{className:`h-3 w-3 text-accent-primary/60`}),a(`prCard.pinned.label`),u>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:u})]}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`agent-pr-dock-collapse`,"data-agent-interactive":!0,onClick:()=>f(!0),"aria-label":a(`prCard.pinned.collapse`),title:a(`prCard.pinned.collapse`),className:`rounded p-0.5 text-foreground/45 transition-colors hover:bg-surface hover:text-foreground`,children:(0,$.jsx)(rc,{className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{"data-testid":`agent-pr-dock-stack`,className:`max-h-[45vh] space-y-1.5 overflow-y-auto overscroll-contain`,children:[t.map(e=>{let t=`proposal:${e.messageId}:${e.proposalIndex}`,i=c.has(t),o=e.proposal.ticketIds.map(e=>`#${e}`).join(` `);return(0,$.jsxs)(`div`,{"data-testid":`agent-rail-launch-dock-card`,className:`space-y-1`,children:[(0,$.jsxs)(`button`,{type:`button`,"data-testid":`agent-rail-launch-dock-card-toggle`,"data-agent-interactive":!0,onClick:()=>p(t),"aria-expanded":!i,"aria-label":a(i?`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`,i?`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)(Vu,{className:`h-3 w-3 shrink-0 text-accent-primary/70`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium`,children:[a(`railCard.heading`),o?` · ${o}`:``]}),(0,$.jsx)(bP,{}),i?(0,$.jsx)(Sn,{className:`h-3 w-3 shrink-0 opacity-60`}):(0,$.jsx)(rc,{className:`h-3 w-3 shrink-0 opacity-60`})]}),!i&&(0,$.jsx)(iA,{proposal:e.proposal,proposalIndex:e.proposalIndex,messageId:e.messageId,conversationId:r,projectId:n,intent:null,compact:!0})]},t)}),e.map(e=>{let t=e.envelope.prDeliveryId,n=c.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:()=>p(t),"aria-expanded":!n,"aria-label":a(n?`prCard.pinned.expandCard`:`prCard.pinned.collapseCard`),title:a(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)(ve,{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:m(e.envelope)}),(0,$.jsx)(yP,{decision:e.envelope.decision}),n?(0,$.jsx)(Sn,{className:`h-3 w-3 shrink-0 opacity-60`}):(0,$.jsx)(rc,{className:`h-3 w-3 shrink-0 opacity-60`})]}),!n&&(0,$.jsx)(_P,{envelope:e.envelope,conversationId:r})]},e.messageId)})]})]})})})}function OP(e){return e?e.charAt(0).toUpperCase()+e.slice(1):`Unknown`}function kP(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(`
|
|
47
47
|
`)):(t.forEach((e,t)=>{t>0&&o.push(``),o.push(`[${e.created_at}] ${OP(e.role)}`,e.content)}),o.join(`
|
|
48
|
-
`))}function AP(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 jP(){let e=po(),{t}=U(`agent`),{active:n,messages:r,renameConversation:i,deleteConversation:a,startNewConversation:o,favoriteConversationIds:s,toggleFavoriteConversation:c}=OL(),{projects:l}=ce(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=n?.pinned_project_id?l.find(e=>e.id===n.pinned_project_id)??null:null,C=n?.title?.trim()||t(`header.untitled`),w=n?s.has(n.id):!1;(0,Q.useEffect)(()=>{if(!u)return;let e=e=>{b.current&&!b.current.contains(e.target)&&d(!1)},t=e=>{e.key===`Escape`&&d(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[u]),(0,Q.useEffect)(()=>{u||y(!1)},[u]),(0,Q.useEffect)(()=>{f&&(x.current?.focus(),x.current?.select())},[f]);let T=(0,Q.useCallback)(()=>{h(n?.title??``),p(!0),d(!1)},[n?.title]),E=(0,Q.useCallback)(async()=>{if(n&&(p(!1),(n.title??``)!==m.trim()))try{await i(n.id,m)}catch{K.error(t(`header.renameFailed`))}},[n,m,i,t]),D=(0,Q.useCallback)(async(e,n)=>{d(!1);try{await navigator.clipboard.writeText(e),_(n),setTimeout(()=>_(e=>e===n?null:e),1400)}catch{K.error(t(`header.copyFailed`))}},[t]),O=(0,Q.useCallback)(async()=>{if(n){d(!1);try{await navigator.clipboard.writeText(kP(n,r,S)),_(`transcript`),K.success(t(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>_(e=>e===`transcript`?null:e),1400)}catch{K.error(t(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[n,r,S,t]),k=(0,Q.useCallback)(()=>{if(n){d(!1);try{let e=kP(n,r,S),i=new Blob([e],{type:`text/plain;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=AP(n.title,n.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),K.success(t(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{K.error(t(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[n,r,S,t]),A=(0,Q.useCallback)(async()=>{if(n){d(!1),y(!1);try{if(await a(n.id),e){e();return}o(n.pinned_project_id)}catch{K.error(t(`header.deleteFailed`))}}},[n,e,a,o,t]),j=(0,Q.useCallback)(()=>{n&&(c(n.id),d(!1))},[n,c]);if(!n)return null;let M=[{id:`name`,label:t(`header.copyName`),value:n.title??C},{id:`id`,label:t(`header.copyId`),value:n.id},...S?[{id:`project`,label:t(`header.copyProject`),value:S.name},{id:`path`,label:t(`header.copyProjectPath`),value:S.path}]:[]];return(0,$.jsxs)(`div`,{ref:b,"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:[S&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:S.path,children:S.path}),(0,$.jsx)(Cn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),f?(0,$.jsx)(`input`,{ref:x,value:m,onChange:e=>h(e.target.value),onBlur:()=>void E(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),E()):e.key===`Escape`&&(e.preventDefault(),p(!1))},placeholder:t(`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:T,title:t(`header.renameHint`),className:`min-w-0 flex-1 truncate text-left font-medium text-foreground/85`,children:C})]}),(0,$.jsx)(Id,{}),e&&(0,$.jsx)(`button`,{type:`button`,onClick:e,title:t(`split.close`),"aria-label":t(`split.close`),className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,$.jsx)(Vn,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-menu-trigger`,"aria-label":t(`header.menu`),"aria-haspopup":`menu`,"aria-expanded":u,onClick:()=>d(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`,u&&`bg-surface text-foreground/80`),children:(0,$.jsx)(Uc,{className:`h-4 w-4`})}),(0,$.jsx)(jb,{children:u&&(0,$.jsx)(jS.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:v?(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:t(`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 A(),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:t(`header.delete`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>y(!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:t(`common:actions.cancel`)})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-rename`,onClick:T,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)(jn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),t(`header.rename`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-favorite`,onClick:j,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)(Cl,{className:X(`h-3.5 w-3.5 shrink-0`,w?`text-accent-primary`:`text-foreground/50`),fill:w?`currentColor`:`none`}),t(w?`header.removeFavorite`:`header.addFavorite`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-delete`,onClick:()=>y(!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)(Rn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),t(`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 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:[g===`transcript`?(0,$.jsx)(xn,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(kc,{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:t(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-export-transcript`,onClick:k,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)(En,{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:t(`header.exportTranscript`,{defaultValue:`Export transcript (.txt)`})})]}),M.map(e=>e===`divider`?null:(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-${e.id}`,onClick:()=>void D(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:[g===e.id?(0,$.jsx)(xn,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(kc,{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 MP=new Set([`building`,`on_review`,`pr_draft`,`no_changes`,`pr_closed`,`implementation_failed`,`pr_failed`]);function NP(e){return MP.has(e)}function PP(e){return!!(NP(e.decision)||e.phase===`launched`||e.phase===`running`||e.runtime?.failure&&e.decision!==`discarded`&&e.decision!==`superseded`)}function FP(e){let t=[];for(let[n,r]of e.entries()){if(r.role!==`system`)continue;let e=qo(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=Ct(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=Ct(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))Ct(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),PP(e.envelope)&&u.push(e)}return{byMessageId:c,duplicateMessageIds:l,pinned:u}}function IP({row:e}){let{t}=U(`agent`);return(0,$.jsxs)(`div`,{"data-testid":`agent-run-failure-marker`,className:`flex items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/[0.06] px-3 py-1.5 text-[11px] text-foreground/70 backdrop-blur-sm`,children:[(0,$.jsx)(zn,{className:`h-3.5 w-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-medium text-destructive`,children:t(`runFailure.marker`,{rail:e.railIndex+1,code:e.code})}),e.detail&&(0,$.jsxs)(`span`,{className:`text-foreground/55`,children:[` · `,e.detail]})]}),(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-run-failure-open`,onClick:()=>aj({prDeliveryId:e.prDeliveryId??null,runIds:[e.runId]}),className:`shrink-0 rounded-md border border-destructive/35 px-2 py-0.5 text-[10px] font-medium text-destructive transition-colors hover:bg-destructive/10`,children:t(`runFailure.openCard`)})]})}function LP({content:e,contextRefs:t}){let{t:n}=U(`agent`),[r,i]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{"data-testid":`agent-system-briefing`,className:`flex flex-col items-end gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:()=>i(e=>!e),"aria-expanded":r,className:X(`inline-flex items-center gap-1.5 rounded-full border border-border/50 bg-surface/50 px-2.5 py-1 text-[11px] text-foreground/60 transition-colors hover:border-accent-primary/40 hover:text-foreground/80`),children:[(0,$.jsx)(Ln,{className:`h-3 w-3 text-accent-primary/70`,"aria-hidden":!0}),n(`runFailure.briefing.title`),r?(0,$.jsx)(rc,{className:`h-3 w-3 opacity-60`,"aria-hidden":!0}):(0,$.jsx)(Cn,{className:`h-3 w-3 opacity-60`,"aria-hidden":!0})]}),r&&(0,$.jsx)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-tr-sm border border-border/40 bg-surface/40 px-3.5 py-2 text-xs text-foreground/70`,"data-testid":`agent-system-briefing-body`,children:(0,$.jsx)($A,{content:e,contextRefs:t})})]})}var RP={pinnedMessageIds:new Set,pinned:[]};function zP(e){let t=Vw();return(0,Q.useMemo)(()=>{if(!Xe)return RP;let n=[],r=new Set;for(let i of e){if(i.role!==`assistant`||!i.content.includes("```rail-launch"))continue;let{proposals:e}=Iw(i.content,!1);e.forEach((e,a)=>{Hw(t,i.id,i.intents,a)||(n.push({messageId:i.id,proposalIndex:a,proposal:e}),r.add(i.id))})}return{pinnedMessageIds:r,pinned:n}},[e,t])}function BP(e){return e.replace(/```[^\n]*\n([\s\S]*?)```/g,`$1`).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/^\s{0,3}>\s?/gm,``).replace(/^\s*(?:[-*+]|\d{1,3}[.)])\s+/gm,``).replace(/(\*\*|__)(.+?)\1/g,`$2`).replace(/(^|[^\w*])\*(?!\s)([^*\n]+?)\*(?!\w)/g,`$1$2`).replace(/(^|[^\w_])_(?!\s)([^_\n]+?)_(?!\w)/g,`$1$2`).replace(/~~(.+?)~~/g,`$1`).replace(/`([^`\n]+)`/g,`$1`).replace(/^\s*(?:-{3,}|\*{3,}|_{3,})\s*$/gm,``).replace(/\s+/g,` `).trim()}function VP(e){let[t,n]=(0,Q.useState)(()=>Date.now()),r=ds(e);(0,Q.useEffect)(()=>{if(!r)return;let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[r]);let i=e.endedAt?Date.parse(e.endedAt):t;return jr(Math.max(0,i-Date.parse(e.startedAt)))}function HP({node:e}){return ds(e)?(0,$.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60 motion-safe:animate-ping`}),(0,$.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full bg-accent-primary`})]}):e.phase===`idle`?(0,$.jsx)(sc,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-hidden":!0}):e.phase===`failed`?(0,$.jsx)(ac,{className:`h-3.5 w-3.5 shrink-0 text-destructive`,"aria-hidden":!0}):(0,$.jsx)(dc,{className:`h-3.5 w-3.5 shrink-0 text-foreground/45`,"aria-hidden":!0})}function UP(e){return e&&e.length>0?e[e.length-1].seq:0}function WP(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function GP({conversationId:e,node:t,liveEvents:n}){let{t:r}=U(`agent`),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let n=!1;return Co(e,t.subagentId,0,500).then(e=>{n||(a(e.events),s(e.hasMore))}).catch(()=>{n||l(!0)}),()=>{n=!0}},[e,t.subagentId]);let u=()=>{let n=UP(i);Co(e,t.subagentId,n,500).then(e=>{a(t=>[...t??[],...e.events]),s(e.hasMore)})},d=(0,Q.useMemo)(()=>{let e=new Set((i??[]).map(e=>e.seq)),t=UP(i);return[...i??[],...n.filter(n=>!e.has(n.seq)&&!o&&n.seq>t)]},[i,n,o]);return c?(0,$.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-destructive`,children:r(`subagents.activityFailed`)}):i?d.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-foreground/50`,children:r(`subagents.noActivity`)}):(0,$.jsxs)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto px-3 py-2 font-mono text-[11px] leading-relaxed`,"data-testid":`agent-subagent-activity`,children:[d.map(e=>e.channel===`tool`&&e.tool?(0,$.jsxs)(`div`,{className:X(`flex items-start gap-1.5 text-foreground/55`,e.tool.isError&&`text-destructive`),children:[(0,$.jsx)(xd,{className:`mt-0.5 h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:e.tool.name}),e.tool.phase===`completed`&&e.tool.output?(0,$.jsxs)(`span`,{className:`text-foreground/40`,children:[` → `,e.tool.output.slice(0,300)]}):null]})]},e.seq):(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words font-sans text-foreground/75`,children:e.delta},e.seq)),o&&(0,$.jsx)(`button`,{type:`button`,onClick:u,className:`text-[11px] font-sans text-accent-primary hover:underline`,children:r(`subagents.moreActivity`)})]}):(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 px-3 py-2 text-[11px] text-foreground/50`,children:[(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),r(`subagents.loadingActivity`)]})}function KP({conversationId:e,node:t,liveEvents:n,depth:r,onStop:i,onRelaunch:a}){let{t:o}=U(`agent`),s=AS(),[c,l]=(0,Q.useState)(!1),u=VP(t),d=ds(t),f=t.agentType===`shell`,p=o(`subagents.phase.${t.phase}`),m=t.reason?o(`subagents.reason.${t.reason}`,{defaultValue:t.reason}):null,h=t.usage?.totalTokens??((t.usage?.inputTokens??0)+(t.usage?.outputTokens??0)||null);return(0,$.jsxs)(`li`,{className:X(`border-t border-border/20 first:border-t-0`,r>0&&`bg-background/30`),"data-testid":`agent-subagent-row`,"data-phase":t.phase,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,style:r>0?{paddingLeft:`${.625+r*1.1}rem`}:void 0,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"aria-label":c?o(`subagents.collapse`):o(`subagents.expand`,{name:t.description}),title:t.resultSummary&&!c?BP(t.resultSummary).slice(0,280):void 0,className:`flex min-w-0 flex-1 items-center gap-2 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(Cn,{className:X(`h-3.5 w-3.5 shrink-0 text-foreground/40 transition-transform`,c&&`rotate-90`),"aria-hidden":!0}),(0,$.jsx)(HP,{node:t}),f?(0,$.jsx)(xd,{className:`h-3.5 w-3.5 shrink-0 text-foreground/45`,"aria-hidden":!0}):(0,$.jsx)(zs,{className:`h-3.5 w-3.5 shrink-0 text-foreground/45`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate text-[12.5px]`,d?`text-foreground`:`text-foreground/75`),children:t.description}),(0,$.jsxs)(`span`,{className:`sr-only`,children:[p,m?` — ${m}`:``]}),t.delegated?(0,$.jsxs)(`span`,{className:`shrink-0 rounded-full border border-accent-primary/30 bg-accent-primary/[0.06] px-1.5 py-0.5 text-[10px] text-accent-primary/80`,title:o(`subagents.delegatedHint`,{provider:sn(t.delegated.driver),model:t.delegated.model}),"data-testid":`agent-subagent-delegated`,children:[sn(t.delegated.driver),` · `,t.delegated.model]}):t.agentType&&!f&&(0,$.jsx)(`span`,{className:`hidden shrink-0 rounded-full border border-border/50 px-1.5 py-0.5 text-[10px] text-foreground/50 sm:inline`,children:t.agentType}),(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[10.5px] tabular-nums text-foreground/45`,"aria-label":o(`subagents.elapsedAria`,{elapsed:u}),children:u})]}),d&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":o(`subagents.stopOne`,{name:t.description}),title:o(`subagents.stop`),className:`shrink-0 rounded p-1 text-foreground/40 transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,children:(0,$.jsx)(Nn,{className:`h-3 w-3`,"aria-hidden":!0})}),fs(t)&&!f&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(t),title:o(`subagents.relaunchHint`),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-border/50 px-1.5 py-0.5 text-[10.5px] text-foreground/60 transition-colors hover:border-accent-primary/50 hover:text-accent-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(Fn,{className:`h-3 w-3`,"aria-hidden":!0}),o(`subagents.relaunch`)]})]}),(0,$.jsx)(jb,{initial:!1,children:c&&(0,$.jsxs)(jS.div,{initial:!s&&{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:s?{opacity:0}:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden border-t border-border/20 bg-background/40`,children:[(m||h!==null)&&(0,$.jsx)(`p`,{className:`border-b border-border/20 px-3 py-1.5 font-mono text-[10.5px] text-foreground/45`,"data-testid":`agent-subagent-meta`,children:[m&&`${p} · ${m}`,!d&&h!==null&&o(`subagents.tokens`,{tokens:WP(h)}),!d&&t.toolUses?o(`subagents.toolUses`,{count:t.toolUses}):null,!d&&t.usage?.costUsd!=null?`${t.usage.costEstimated?`≈ `:``}$${t.usage.costUsd.toFixed(2)}`:null].filter(Boolean).join(` · `)}),t.resultSummary&&(0,$.jsxs)(`section`,{className:`border-b border-border/20 px-3 py-2.5`,"aria-label":o(`subagents.result`),"data-testid":`agent-subagent-result`,children:[(0,$.jsx)(`p`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-widest text-foreground/40`,children:o(`subagents.result`)}),(0,$.jsx)(JP,{text:t.resultSummary})]}),(0,$.jsx)(GP,{conversationId:e,node:t,liveEvents:n})]})})]})}var qP={a:({href:e,children:t})=>(0,$.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-accent-primary underline decoration-accent-primary/40 underline-offset-2 hover:decoration-accent-primary`,children:t}),img:()=>null,code:({className:e,children:t})=>e?(0,$.jsx)(`code`,{className:e,children:t}):(0,$.jsx)(`code`,{className:`rounded border border-border/50 bg-background-deep/60 px-1 py-px font-mono text-[0.9em] text-accent-info`,children:t})};function JP({text:e}){return(0,$.jsx)(`div`,{className:X(`prose prose-invert prose-sm max-w-none text-[12px] leading-relaxed text-foreground/80`,`prose-p:my-1 prose-headings:mb-1 prose-headings:mt-2 prose-headings:text-[12.5px] prose-headings:font-semibold`,`prose-strong:text-foreground prose-ul:my-1 prose-ol:my-1 prose-li:my-0.5 prose-li:marker:text-accent-primary/70`,`prose-pre:my-1.5 prose-pre:rounded-md prose-pre:border prose-pre:border-border/50 prose-pre:bg-background-deep/60 prose-pre:text-[11px]`),children:(0,$.jsx)(Cr,{remarkPlugins:[wr],skipHtml:!0,components:qP,children:e})})}function YP(e){let t=new Map,n=new Set(e.map(e=>e.subagentId));for(let r of e){let e=r.parentId&&n.has(r.parentId)?r.parentId:null;t.set(e,[...t.get(e)??[],r])}let r=[],i=(e,n)=>{for(let a of t.get(e)??[])r.push({node:a,depth:n}),i(a.subagentId,n+1)};return i(null,0),r}function XP(e,t){let n=Math.min(...e.map(e=>Date.parse(e.startedAt))),r=e.some(ds)?t:Math.max(...e.map(e=>e.endedAt?Date.parse(e.endedAt):Date.parse(e.startedAt)));return Math.max(0,r-n)}function ZP(e){return e.usage?.totalTokens??((e.usage?.inputTokens??0)+(e.usage?.outputTokens??0)||null)}function QP({conversationId:e,subagents:t,liveEvents:n,onStop:r,onRelaunch:i}){let{t:a}=U(`agent`),o=AS(),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(()=>Date.now()),p=t.filter(ds).length;if((0,Q.useEffect)(()=>{if(p===0)return;let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[p]),t.length===0)return null;let m=t.filter(e=>e.phase===`idle`).length,h=t.length-p-m,g=l??p>0,_=jr(XP(t,d)),v=p===0?t.reduce((e,t)=>e+(ZP(t)??0),0):0,y=p>0?[a(`subagents.working`,{count:p}),m>0&&a(`subagents.done`,{count:m}),h>0&&a(`subagents.ended`,{count:h})].filter(Boolean).join(` · `):[a(`subagents.finishedIn`,{elapsed:_}),h>0&&a(`subagents.ended`,{count:h}),v>0&&a(`subagents.tokens`,{tokens:WP(v)})].filter(Boolean).join(` · `),b=async e=>{c(!1);try{await r(e)}catch{c(!0)}};return(0,$.jsxs)(jS.section,{initial:!o&&{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:`easeOut`},"data-testid":`agent-subagents-card`,"data-open":g,"aria-label":a(`subagents.title`),className:`my-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(!g),"aria-expanded":g,"data-testid":`agent-subagents-summary`,className:X(`inline-flex min-w-0 max-w-full items-center gap-2 rounded-full border px-3 py-1 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,p>0?`border-accent-primary/40 bg-accent-primary/[0.07] text-foreground/85`:`border-border/50 bg-surface/60 text-foreground/70 hover:border-border hover:text-foreground/85`),children:[p>0?(0,$.jsx)(An,{className:`h-3 w-3 shrink-0 animate-spin text-accent-primary motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(zs,{className:`h-3 w-3 shrink-0 text-foreground/50`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`shrink-0 font-medium`,children:a(`subagents.count`,{count:t.length})}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-foreground/55`,"aria-live":`polite`,children:y}),p>0&&(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[10.5px] tabular-nums text-foreground/45`,children:_}),(0,$.jsx)(Cn,{className:X(`h-3 w-3 shrink-0 text-foreground/40 transition-transform motion-reduce:transition-none`,g&&`rotate-90`),"aria-hidden":!0})]}),p>1&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`shrink-0 rounded-full px-2 py-1 text-[10.5px] text-foreground/45 transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,children:a(`subagents.stopAll`)})]}),s&&(0,$.jsx)(`p`,{role:`alert`,className:`mt-1 px-1 text-[11px] text-destructive`,children:a(`subagents.stopFailed`)}),(0,$.jsx)(jb,{initial:!1,children:g&&(0,$.jsx)(jS.ul,{initial:!o&&{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:o?{opacity:0}:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},className:`ml-3 mt-1 overflow-hidden rounded-lg border border-border/40 bg-card/50`,"data-testid":`agent-subagents-list`,children:YP(t).map(({node:t,depth:r})=>(0,$.jsx)(KP,{conversationId:e,node:t,liveEvents:n[t.subagentId]??[],depth:r,onStop:e=>void b([e.subagentId]),onRelaunch:i},t.subagentId))})})]})}function $P({turn:e}){let{t}=U(`agent`);return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-testid":`agent-background-turn`,children:[(0,$.jsx)(eF,{origin:e.origin}),e.text?(0,$.jsx)(ej,{role:`assistant`,content:e.text,streaming:!0}):(0,$.jsx)(`p`,{className:`title-shimmer px-1 text-[12px] text-foreground/55`,children:t(`subagents.backgroundTurn`)})]})}function eF({origin:e}){let{t}=U(`agent`);return(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 px-1 text-[10.5px] uppercase tracking-wide text-foreground/40`,"data-testid":`agent-turn-origin`,children:[(0,$.jsx)(zs,{className:`h-3 w-3`,"aria-hidden":!0}),t(e===`system`?`subagents.continuationSystem`:`subagents.continuation`)]})}function tF({onApplyNow:e}){let{t}=U(`agent`),[n,r]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{role:`status`,"data-testid":`agent-deferred-change`,className:`flex items-center gap-2 rounded-lg border border-accent-highlight/30 bg-accent-highlight/[0.07] px-3 py-1.5 text-[11.5px] text-foreground/70`,children:[(0,$.jsx)(td,{className:`h-3.5 w-3.5 shrink-0 text-accent-highlight`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:t(`subagents.deferred`)}),(0,$.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(!0),e().finally(()=>r(!1))},className:`shrink-0 rounded-md border border-border/50 px-2 py-0.5 text-[11px] text-foreground/70 transition-colors hover:border-destructive/50 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive disabled:opacity-50`,children:t(`subagents.applyNow`)})]})}var nF=new Set([`host_degraded`,`journal_locked`]),rF=new Set([...nF,`policy.subagent_blocked`,`subagents.delegation_unsupported`,`subagents.driver_unavailable`]);function iF({notices:e,onDismiss:t}){let{t:n}=U(`agent`),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(null);if(e.length===0)return null;let s=async e=>{if(e.scope){i(e.id),o(null);try{let{host:n}=await To(e.scope);n.status===`ready`?t(e.id):o(e.id)}catch{o(e.id)}finally{i(null)}}};return(0,$.jsx)(`div`,{className:`space-y-1.5`,"data-testid":`agent-session-notices`,children:e.map(e=>{let i=rF.has(e.code),o=nF.has(e.code),c=e.level!==`info`;return(0,$.jsxs)(`div`,{role:c?`alert`:`status`,"data-code":e.code,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-[11.5px] ${c?`border-accent-highlight/35 bg-accent-highlight/[0.07] text-foreground/75`:`border-border/40 bg-surface/40 text-foreground/65`}`,children:[c?(0,$.jsx)(zn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-highlight`,"aria-hidden":!0}):(0,$.jsx)(kl,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground/45`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,$.jsx)(`p`,{children:i?n(`sessionNotice.${e.code}`,{provider:sn(e.provider)}):e.message}),a===e.id&&(0,$.jsx)(`p`,{className:`text-destructive`,children:n(`sessionNotice.retryFailed`)})]}),o&&e.scope&&(0,$.jsxs)(`button`,{type:`button`,disabled:r===e.id,onClick:()=>void s(e),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-border/50 px-2 py-0.5 text-[11px] text-foreground/70 transition-colors hover:border-accent-primary/50 hover:text-accent-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary disabled:opacity-50`,children:[r===e.id?(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Fn,{className:`h-3 w-3`,"aria-hidden":!0}),n(`sessionNotice.retry`)]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":n(`sessionNotice.dismiss`),title:n(`sessionNotice.dismiss`),className:`shrink-0 rounded p-0.5 text-foreground/40 transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:(0,$.jsx)(Vn,{className:`h-3 w-3`,"aria-hidden":!0})})]},e.id)})})}var aF=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-C7dWoRu6.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,77,78,79,80,81,82,83,84,85,86,87]))),oF=(0,Q.lazy)(()=>c(()=>import(`./LoopPreviewModal-ChI3NQC7.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([88,1,7,8,45,10,42,63,64,73,74,78,72,54,89,58,60]))),sF=new Set,cF=new Set([`spec-framing.committed`]);function lF(e){if(!e.startsWith(`{`))return!1;try{let t=JSON.parse(e);return typeof t?.kind==`string`&&cF.has(t.kind)}catch{return!1}}function uF({variant:e}){let{t}=U(`agent`),{active:n}=OL(),r=Mi(),i=HS(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)(jP,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,$.jsx)(Dn,{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)(dF,{variant:e},`${n?.id??`__new-mission__`}:${i}`)})}function dF({variant:e}){let t=mo(),{t:n}=U(`agent`),{active:r,messages:i,streamingText:a,isStreaming:o,liveTools:s,turnTools:c,queuedMessages:l,mcpEnabled:u,enablingMcp:d,enableMcpServer:f,providersReady:p,cycleTier:m,send:h}=OL(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(),b=s.length>0?s:c,x=(0,Q.useRef)(null),S=XS(a,o),{openRef:C,jobRef:w,closeJobRef:T,loopRef:E,closeLoopRef:D}=IC(),O=r?.pinned_project_id??null,[k,A]=(0,Q.useState)(new Map),j=(0,Q.useMemo)(()=>{let e=new Set;for(let t of i)for(let n of t.attachment_ids??[])e.add(n);for(let t of l)for(let n of t.attachmentIds??[])e.add(n);return[...e].sort()},[i,l]).join(`\0`);(0,Q.useEffect)(()=>{let e=j?j.split(`\0`):[];if(!r?.id||e.length===0){A(new Map);return}let t=!1,n=new Set(e);return No(r.id).then(e=>{t||A(new Map(e.filter(e=>n.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||A(new Map)}),()=>{t=!0}},[r?.id,j]);let M=(0,Q.useMemo)(()=>O?e=>{C(O,e)}:void 0,[O,C]),N=Pa().id===`code-rain`?n(`emptyTitleCodeRain`):n(`emptyTitle`),P=(0,Q.useMemo)(()=>FP(i),[i]),F=zP(i),I=xs(r?.id),{stopSubagents:ee,dismissNotice:te}=bs(),L=(0,Q.useMemo)(()=>new Set(i.map(e=>e.core_turn_id).filter(e=>!!e)),[i]),R=(0,Q.useMemo)(()=>ms(us(I,L),i.filter(e=>e.role!==`system`&&!(Xe&&rj(e))),o),[I,L,i,o]),z=R.live,B=async e=>{r&&await ee(r.id,e)},ne=e=>{r&&oi(r.id,n(`subagents.relaunchDraft`,{description:e.description}),[])},V=(e,t)=>r&&e.length>0?(0,$.jsx)(QP,{conversationId:r.id,subagents:e,liveEvents:I?.liveEvents??{},onStop:B,onRelaunch:ne},t):null,re=r?BS(r.id):null,ie=(0,Q.useRef)(re?.atBottom??!0);(0,Q.useLayoutEffect)(()=>{let e=x.current;return e&&re&&(e.scrollTop=re.atBottom?e.scrollHeight:re.top),()=>{e&&r&&zS(r.id,{top:e.scrollTop,atBottom:ie.current})}},[r?.id]);let ae=()=>{let e=x.current;e&&(ie.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,r&&zS(r.id,{top:e.scrollTop,atBottom:ie.current}))};(0,Q.useEffect)(()=>{ie.current&&x.current?.scrollTo?.({top:x.current.scrollHeight,behavior:`auto`})},[i.length,S,s.length,l.length]);let H=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),m())},W=e===`inline`,G=W?`mx-auto flex w-full max-w-[1040px] min-h-0 flex-1 flex-col overflow-hidden`:`flex min-h-0 flex-1 flex-col overflow-hidden`;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden `,onKeyDown:H,children:[p===!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)(ru,{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:n(`noProvider.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:n(`noProvider.body`)})]})]}),p!==!1&&!u&&(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)(fe,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,$.jsx)(`span`,{className:`flex-1`,children:n(`degraded.body`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void f(),disabled:d,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:n(d?`degraded.enabling`:`degraded.enable`)})]}),W&&r&&(0,$.jsx)(jP,{}),(0,$.jsxs)(`div`,{className:G,children:[(0,$.jsxs)(jS.div,{ref:x,onScroll:ae,initial:W?{opacity:0,y:8}:!1,animate:{opacity:1,y:0},transition:{duration:.35,ease:`easeOut`},className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[i.length===0&&!o&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,$.jsx)(zs,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:N}),(0,$.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:n(`emptyHint`)})]}),i.map((e,t)=>{if(e.role===`system`){if(lF(e.content))return null;if(Xe){let t=nj(e.content);if(t)return(0,$.jsx)(IP,{row:t},e.id)}let t=P.byMessageId.get(e.id);return t?PP(t)?(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)(xu,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n(`prCard.pinned.marker`)}),(0,$.jsx)(yP,{decision:t.decision})]},e.id):(0,$.jsx)(_P,{envelope:t,conversationId:e.conversation_id},e.id):(P.duplicateMessageIds.has(e.id)||sF.has(e.id)||(sF.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}if(Xe&&rj(e))return(0,$.jsx)(LP,{content:e.content,contextRefs:e.context_refs},e.id);let a=F.pinnedMessageIds.has(e.id),s=e.role===`assistant`?ls(I,e.core_turn_id):[],c=e.role===`assistant`&&(e.turn_origin===`subagent`||e.turn_origin===`system`)?e.turn_origin:null;return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[c&&(0,$.jsx)(eF,{origin:c}),(0,$.jsx)(ej,{role:e.role,content:e.content,messageId:e.id,intents:e.intents??null,railProposalsPinned:a,tolerantFences:nn(r?.provider),createdAt:e.created_at,isLast:!o&&t===i.length-1,isLatest:t===i.length-1,isStreaming:o,onPickOption:e=>void h(e),refsProjectId:O,onOpenRef:M,contextRefs:e.context_refs,deliveryStatus:e.delivery_status,deliveryReceipt:e.delivery_receipt,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>k.get(e)).filter(e=>!!e)}),a&&(0,$.jsxs)(`div`,{"data-testid":`agent-rail-launch-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)(xu,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n(`railCard.pinnedMarker`)})]}),V(s,`subagents:${e.id}`),(R.afterMessage.get(e.id)??[]).map((t,n)=>V(t,`subagents:${e.id}:${n}`))]},e.id)}),o&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[S&&(0,$.jsx)(ej,{role:`assistant`,content:S,streaming:!0,tolerantFences:nn(r?.provider)}),(0,$.jsx)(zC,{tool:s.length?s[s.length-1].tool:null,agentDescription:[...z].reverse().find(e=>e.phase===`running`)?.description??null,onClick:()=>_(!0)})]}),V(z,`subagents:live`),I?.backgroundTurn&&!o&&(0,$.jsx)($P,{turn:I.backgroundTurn}),r&&I&&I.notices.length>0&&(0,$.jsx)(iF,{notices:I.notices,onDismiss:e=>te(r.id,e)}),I?.deferredChanges&&(0,$.jsx)(tF,{onApplyNow:()=>B()}),l.length>0&&(0,$.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:l.map(e=>(0,$.jsx)(tj,{item:e,conversationId:r?.id,onEdit:e=>{r&&y(t=>({conversationId:r.id,queueId:e,revision:(t?.revision??0)+1}))},attachments:(e.attachmentIds??[]).map(e=>k.get(e)).filter(e=>!!e)},`${r?.id}:${e.queueId}`))})]}),(0,$.jsx)(jb,{initial:!1,children:r&&(P.pinned.length>0||F.pinned.length>0)&&(0,$.jsx)(DP,{pinned:P.pinned,proposals:F.pinned,projectId:O,conversationId:r.id,inline:W},`agent-pr-pinned-dock`)}),W?(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsx)(jS.div,{layoutId:t,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`relative mx-auto w-full max-w-[960px]`,"data-testid":`agent-composer-dock`,children:(0,$.jsx)(KN,{queueEditRequest:v})})}):(0,$.jsx)(`div`,{className:`relative shrink-0 border-t border-border/50 bg-surface/30 p-3`,"data-testid":`agent-composer-dock`,children:(0,$.jsx)(KN,{hideProjectSelector:!0,queueEditRequest:v})})]}),w&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(aF,{jobId:w.jobId,projectId:w.projectId,onClose:T})}),E&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(oF,{loop:E,onClose:D})}),g&&(0,$.jsx)(VC,{tools:b,streaming:o,onClose:()=>_(!1)})]})}var fF=8,pF=3e3;function mF(){let{t:e}=U(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=OL(),{backgroundConversationIds:c}=bs(),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(0),[h,g]=(0,Q.useState)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y=(0,Q.useRef)(null),b=(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]),x=t.length>fF,S=(0,Q.useMemo)(()=>{let t=d.trim().toLowerCase();if(!t)return b;let n=e(`mission.untitled`).toLowerCase();return b.filter(e=>(e.title?.trim().toLowerCase()||n).includes(t))},[b,d,e]),C=S.length+1,w=(0,Q.useCallback)(()=>{_.current&&clearTimeout(_.current),_.current=null,g(null)},[]);(0,Q.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]),(0,Q.useEffect)(()=>{if(!l)return;let e=e=>{v.current&&!v.current.contains(e.target)&&E()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let T=()=>{let e=n?b.findIndex(e=>e.id===n.id):-1;m(e>=0?e+1:0),u(!0)},E=()=>{u(!1),f(``),w()},D=e=>{e!==n?.id&&r(e),E()},O=()=>{a(null),E()},k=e=>{_.current&&clearTimeout(_.current),g(e),_.current=setTimeout(()=>{g(null),_.current=null},pF)},A=async t=>{w();let a=n?.id===t,o=b.find(e=>e.id!==t)??null;try{await i(t),a&&o&&await r(o.id)}catch{K.error(e(`mission.deleteFailed`))}},j=()=>{if(p===0)O();else{let e=S[p-1];e&&D(e.id)}},M=e=>{if(!l){e.key===`ArrowDown`&&(e.preventDefault(),T());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;m(e=>(e+t+C)%C)}else e.key===`Home`?(e.preventDefault(),m(0)):e.key===`End`?(e.preventDefault(),m(C-1)):e.key===`Enter`?(e.preventDefault(),j()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),h?w():(E(),y.current?.focus()))},N=n?.title?.trim()||e(`mission.untitled`);return(0,$.jsxs)(`div`,{className:`relative min-w-0`,ref:v,"data-agent-interactive":!0,onKeyDown:M,children:[(0,$.jsxs)(`button`,{ref:y,type:`button`,"data-testid":`mission-trigger`,onClick:()=>l?E():T(),"aria-haspopup":`listbox`,"aria-expanded":l,"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)(vn,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:N}),(0,$.jsx)(rc,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,$.jsx)(jb,{children:l&&(0,$.jsxs)(jS.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:[x&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(In,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,$.jsx)(`input`,{autoFocus:!0,value:d,onChange:e=>{f(e.target.value),m(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-${p}`,className:`max-h-72 overflow-y-auto py-1`,children:[(0,$.jsxs)(jS.div,{id:`agent-mission-opt-0`,role:`option`,"aria-selected":!1,tabIndex:-1,"data-testid":`mission-new`,onClick:O,onMouseEnter:()=>m(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 ${p===0?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,$.jsx)(Pn,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),S.length>0&&(0,$.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),S.length===0&&d.trim()!==``&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),S.map((e,t)=>(0,$.jsx)(hF,{conversation:e,index:t+1,highlighted:p===t+1,activeId:n?.id??null,streaming:o.has(e.id)||c.has(e.id),queuedCount:s.get(e.id)?.queued.length??0,confirming:h===e.id,onHover:()=>m(t+1),onSelect:()=>D(e.id),onArmDelete:()=>k(e.id),onConfirmDelete:()=>void A(e.id),onCancelDelete:w},e.id))]})]})})]})}function hF({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}=U(`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)(Rn,{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)(xn,{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)(Vn,{className:`h-3.5 w-3.5`})})]}):(0,$.jsxs)(jS.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:qC(e.updated_at),children:KC(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)(xn,{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)(Rn,{className:`h-3.5 w-3.5`})})]})}var gF=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}));gF.displayName=`Input`;var _F=6e4,vF={data:null,fetchedAt:0,inFlight:null,error:null},yF=new Set;function bF(){yF.forEach(e=>{try{e()}catch{}})}function xF(){return vF.data!==null&&Date.now()-vF.fetchedAt<_F}async function SF(e){if(vF.inFlight)return vF.inFlight;let t=(async()=>{let t=await fetch(`${F}/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 vF.data=n,vF.fetchedAt=Date.now(),vF.error=null,vF.inFlight=null,bF(),vF.data})().catch(t=>{throw vF.inFlight=null,e?.aborted?t:(vF.error=t instanceof Error?t:Error(String(t)),bF(),vF.error)});return vF.inFlight=t,t}var CF=!1;function wF(){CF||typeof window>`u`||(window.addEventListener(`focus`,()=>{vF.fetchedAt=0,vF.data=null,SF().catch(()=>{})}),CF=!0)}function TF(){let[,e]=(0,Q.useState)(0),[t,n]=(0,Q.useState)(()=>!xF()),[r,i]=(0,Q.useState)(vF.error);(0,Q.useEffect)(()=>{wF();let t=()=>{e(e=>e+1),i(vF.error),n(!1)};yF.add(t);let r=new AbortController;return!xF()&&!vF.inFlight?(n(!0),SF(r.signal).catch(e=>{r.signal.aborted||i(e instanceof Error?e:Error(String(e)))}).finally(()=>{r.signal.aborted||n(!1)})):vF.inFlight&&vF.inFlight.catch(()=>{}).finally(()=>{r.signal.aborted||n(!1)}),()=>{r.abort(),yF.delete(t)}},[]);let a=(0,Q.useCallback)(async()=>{vF.fetchedAt=0,vF.data=null,vF.error=null,n(!0);try{await SF()}catch(e){i(e instanceof Error?e:Error(String(e)))}finally{n(!1)}},[]);return{status:vF.data,isLoading:t,error:r,recheck:a}}var EF=W(`github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),DF={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`},kimi:{icon:`🌙`,label:`Kimi`}};function OF(e){return e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`project`}function kF({blueprint:e,onSubmit:t,onBack:n,submitting:r,error:i,errorDetail:a}){let{t:o}=U(`builder`),{status:s}=TF(),[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/${OF(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`&&on(n)&&(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`,...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)(gF,{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)(gF,{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}=DF[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)(EF,{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)(Vu,{className:`mr-1.5 h-3.5 w-3.5`}),o(r?`commit.creating`:`commit.submit`)]})]})]})}function AF({models:e,model:t,onSelect:n,status:r=`ready`,disabled:i=!1,testId:a=`agent-model-selector`,customModelAliases:o=!1}){let{t:s}=U(`agent`),c=t??e.find(e=>e.default)?.value??e[0]?.value??``,l=s(r===`loading`?`model.loading`:r===`error`?`model.unavailable`:`model.label`);return o?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1`,children:[(0,$.jsx)(Ln,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(_M,{value:c,options:e,onCommit:n,disabled:i||r!==`ready`,ariaLabel:s(`model.label`),testId:a,placeholder:l,className:`h-6 w-48 border-border/40 px-1.5 text-xs`})]}):(0,$.jsx)(Gk,{label:s(`model.label`),value:c,options:e.map(e=>({value:e.value,label:e.label})),icon:Ln,onSelect:n,placeholder:l,disabled:i||r!==`ready`,testId:a})}function jF({session:e,autoFocus:t=!1}){let{t:n}=U(`builder`),{t:r}=U(`agent`),{availableIds:i,labels:a}=HN(),o=an(e.provider),s=[e.provider,...i].filter((e,t,n)=>n.indexOf(e)===t).filter(an),c=e=>r(`provider.${e}`,{defaultValue:a?.[e]??e}),l=()=>{!o||!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)(xl,{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)(Gk,{label:r(`provider.label`),value:e.provider,options:s.map(e=>({value:e,label:c(e)})),icon:zs,onSelect:e.setProvider,disabled:!o||e.busy||!e.conversationReady,testId:`builder-provider-selector`}),(0,$.jsx)(AF,{models:e.models,model:e.model,onSelect:e.setModel,disabled:!o||e.busy||!e.conversationReady,testId:`builder-model-selector`}),e.efforts.length>0&&(0,$.jsx)(Gk,{label:r(`effort.label`),value:e.effort,options:e.efforts.map(e=>({value:e,label:r(`effort.${e}`)})),icon:dl,onSelect:e.setEffort,disabled:!o||e.busy||!e.conversationReady,testId:`builder-effort-selector`}),e.showSurpriseMe&&(0,$.jsxs)(`button`,{type:`button`,onClick:e.surpriseMe,disabled:!o||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)(Ln,{className:`h-3 w-3`}),n(`shell.surpriseMe`)]})]}),!o&&(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:!o,autoFocus:t,onChange:t=>e.setDraft(t.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),l())},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:l,disabled:!o||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)(vt,{className:`h-4 w-4`})})]})]})}function MF(e){let t=Date.parse(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`);return Number.isFinite(t)?Er(new Date(t),{addSuffix:!0,locale:I()}):``}function NF({items:e,loading:t,disabled:n=!1,onResume:r,onDiscard:i}){let{t:a}=U(`builder`),[o,s]=(0,Q.useState)(null);return!t&&e.length===0?null:(0,$.jsxs)(jS.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)(Uu,{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)(An,{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)(jb,{initial:!1,children:e.map(e=>{let t=e.productName||e.title||a(`recent.untitled`),c=o===e.id;return(0,$.jsxs)(jS.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)(Mn,{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)(kn,{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)(zn,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),a(`recent.pendingIssue`)]}),e.updatedAt&&(0,$.jsx)(`span`,{className:`opacity-80`,children:MF(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)(xn,{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)(Vn,{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)(Rn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})})]},e.id)})})})]})}function PF({specsStarted:e,snapshot:t,maxSpecs:n=10}){let{t:r}=U(`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?Bn:Ln,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)(An,{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)(jb,{mode:`wait`,initial:!1,children:(0,$.jsx)(jS.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)(jb,{mode:`wait`,initial:!1,children:(0,$.jsx)(jS.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)(jS.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 FF=`specrails-desktop:milestone-launch-mode`,IF=`specrails-desktop:milestone-sequential-plans`,LF=`specrails-desktop:milestone-auto-advance`;function RF(){try{return localStorage.getItem(LF)!==`false`}catch{return!0}}function zF(e){try{localStorage.setItem(LF,e?`true`:`false`)}catch{}}function BF(){try{return localStorage.removeItem(FF),localStorage.getItem(`specrails-desktop:milestone-sequential-plans`)===null?!1:(localStorage.removeItem(IF),!0)}catch{return!1}}function VF(e){return`M${e}`}function HF(e,t){return t===`chain_active`?`chain_active`:t===`no_tickets`?`no_tickets`:t===`milestone_not_found`?`milestone_not_found`:t===`rail_limit_reached`?`rail_limit_reached`:e===503?`unavailable`:`launch_rejected`}async function UF(e){try{let t=await e.json();return t&&typeof t==`object`?t:{}}catch{return{}}}async function WF(e,t,n={}){let r=typeof n==`function`?{fetchImpl:n}:n,i=r.fetchImpl??fetch,a=r.autoAdvance??RF(),o;try{o=await i(`/api/projects/${e}/blueprint/milestones/${t}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({autoAdvance:a})})}catch(e){return{ok:!1,reason:`network`,error:`network`,detail:e instanceof Error?e.message:String(e)}}let s=await UF(o);if(!o.ok){let e=typeof s.error==`string`?s.error:`http_${o.status}`;return{ok:!1,reason:HF(o.status,e),error:e,...typeof s.detail==`string`?{detail:s.detail}:{},...typeof s.chainId==`string`?{chainId:s.chainId}:{}}}let c=Array.isArray(s.launched)?s.launched.filter(e=>!!e&&typeof e==`object`&&typeof e.chunk==`number`):[],l=Array.isArray(s.pending)?s.pending.filter(e=>Array.isArray(e)):[];return{ok:!0,chainId:typeof s.chainId==`string`?s.chainId:null,launched:c,pending:l,ticketCount:c.reduce((e,t)=>e+(Array.isArray(t.ticketIds)?t.ticketIds.length:0),0),skippedCount:l.reduce((e,t)=>e+t.length,0)}}async function GF(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 UF(i);return i.ok?{ok:!0,chain:Dt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}function KF(e,t,n=fetch){return GF(e,t,`resume`,n)}function qF(e,t,n=fetch){return GF(e,t,`cancel`,n)}async function JF(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 UF(i);return i.ok?{ok:!0,chain:Dt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}var YF=[`Problem Statement`,`Proposed Solution`,`Out of Scope`,`Technical Considerations`,`Estimated Complexity`],XF={problemMinChars:200,solutionMinChars:500,outOfScopeMinBullets:3,technicalMinBullets:5,criteriaMin:6,criteriaMax:10,criterionMinChars:20},ZF=new Set([`scaffold`,`feature`,`verification`]),QF=new Set([`critical`,`high`,`medium`,`low`]),$F=/^(?:todo|tbd|n\/?a|works?|test(?: it)?|criterion|acceptance criterion)$/i;function eI(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function tI(e){return e.trim().toLocaleLowerCase(`en-US`)}function nI(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 rI(e){return e.split(/\r?\n/).filter(e=>/^\s*[-*+]\s+\S/.test(e)).length}function iI(e,t){let n=[],r=eI(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=eI(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:``;ZF.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=tI(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:``;QF.has(d)||o(n,`priority`,`invalid_priority`,`Spec ${i} needs a valid priority.`);let f=typeof r.description==`string`?r.description.trim():``,p=nI(f);(!/^## Problem Statement(?:\r?\n|$)/.test(f)||p.headings.length!==YF.length||p.headings.some((e,t)=>e!==YF[t]))&&o(n,`description`,`canonical_sections`,`Spec ${i} is missing the canonical sections.`);for(let e of YF)(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`,XF.problemMinChars],[`Proposed Solution`,XF.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`,XF.outOfScopeMinBullets],[`Technical Considerations`,XF.technicalMinBullets]]){let r=p.bodies.get(e)??``;r&&rI(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<XF.criteriaMin||h.length>XF.criteriaMax)&&o(n,`acceptanceCriteria`,`criteria_count`,`Spec ${i} needs ${XF.criteriaMin}-${XF.criteriaMax} acceptance criteria.`,{count:h.length,min:XF.criteriaMin,max:XF.criteriaMax});let g=new Set;h.forEach((e,t)=>{let r=typeof e==`string`?e.trim():``;if(r.length<XF.criterionMinChars||$F.test(r)){o(n,`acceptanceCriteria`,`criterion_quality`,`Spec ${i} criterion ${t+1} is not concrete.`,{criterion:t+1});return}let a=tI(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 aI=new Set([`batch_incomplete`,`spec_count`]);function oI(e,t,n,r,i={}){let a=wt(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=>!aI.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 sI(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 cI(e,t){let n={n:t.specIndex===null?``:t.specIndex+1,...t.params??{}};return e(sI(t),{...n,defaultValue:t.message})}var lI=new Set([`gh_not_installed`,`gh_not_authenticated`,`gh_scope`,`gh_repo_exists`,`gh_network`]);function uI(e){return`progress.githubErrors.${e&&lI.has(e)?e:`generic`}`}var dI=[`create-dir`,`git-init`,`assemble`,`blueprint`,`tickets`,`register`,`github`],fI={minSpecs:5,maxSpecs:10};function pI(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 mI(e,t){let n=e&&typeof e==`object`?e:{},r=new Date().toISOString();if(n.continuing){let e=pI(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 hI(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 gI(e,t){let{t:n}=U(`builder`),{registerHandler:r,unregisterHandler:i}=R(),{setActiveProjectId:a}=ce(),[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,ee]=(0,Q.useState)(`claude`),[te,L]=(0,Q.useState)(null),[z,B]=(0,Q.useState)([]),[ne,V]=(0,Q.useState)(``),[re,ie]=(0,Q.useState)([]),[ae,H]=(0,Q.useState)(`medium`),[W,G]=(0,Q.useState)(``),[oe,se]=(0,Q.useState)({status:`idle`}),[le,ue]=(0,Q.useState)([]),[de,fe]=(0,Q.useState)(!1),[pe,q]=(0,Q.useState)(!1),me=te??ne,he=(0,Q.useMemo)(()=>{let e=qt(I,me);return re.filter(t=>e.includes(t))},[me,I,re]),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),J=(0,Q.useRef)(I),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(!1),be=(0,Q.useRef)(ae),xe=(0,Q.useRef)(he),Se=(0,Q.useRef)(te),Ce=(0,Q.useRef)(!1),we=(0,Q.useRef)(t.onFinished);(0,Q.useEffect)(()=>{ge.current=o},[o]),(0,Q.useEffect)(()=>{J.current=I},[I]),(0,Q.useEffect)(()=>{ve.current=w},[w]),(0,Q.useEffect)(()=>{be.current=ae},[ae]),(0,Q.useEffect)(()=>{xe.current=he},[he]),(0,Q.useEffect)(()=>{Se.current=te},[te]),(0,Q.useEffect)(()=>{we.current=t.onFinished},[t.onFinished]);let Te=(0,Q.useCallback)(async()=>{let e=ge.current;if(e)return e;if(_e.current)return _e.current;let t=fetch(`/api/blueprint/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:J.current,...Se.current?{model:Se.current}:{}})}).then(e=>e.json()).then(e=>e.conversation?(ge.current=e.conversation.id,s(e.conversation.id),e.conversation.id):null).catch(()=>null).finally(()=>{_e.current=null});return _e.current=t,t},[]),Ee=(0,Q.useCallback)(async()=>{fe(!0);try{let e=await(await fetch(`/api/blueprint/conversations?resumable=1`)).json();ue(hI(e.conversations))}catch{ue([])}finally{fe(!1)}},[]);(0,Q.useEffect)(()=>{e&&Ee()},[e,Ee]),(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return B([]),V(``),ie([]),H(``),fetch(`/api/blueprint/models?provider=${encodeURIComponent(I)}`).then(e=>e.json()).then(e=>{if(t)return;B(e.models??[]);let n=e.defaultModel??e.models?.[0]?.value??``,r=e.efforts??[],i=qt(I,n),a=r.filter(e=>i.includes(e));V(n),ie(r),H(e=>a.includes(e)?e:cn(I,n)??``)}).catch(()=>{}),()=>{t=!0}},[e,I]);let{availableIds:De}=HN({enabled:e});(0,Q.useEffect)(()=>{if(ge.current||De.length===0||De.includes(I))return;let e=De.filter(an);e.length!==0&&(ee(rn(e)),L(null))},[De,I]);let Oe=(0,Q.useCallback)(e=>{ee(e),L(null);let t=ge.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).catch(()=>{})},[]),ke=(0,Q.useCallback)(e=>{L(e);let t=qt(I,e),n=re.filter(e=>t.includes(e));H(t=>n.includes(t)?t:cn(I,e)??``);let r=ge.current;r&&fetch(`/api/blueprint/conversations/${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:e})}).catch(()=>{})},[I,re]);(0,Q.useEffect)(()=>{if(!e)return;let t=`builder-session`;return r(t,e=>{let t=e,r=ge.current!==null&&t.conversationId===ge.current,i=ve.current!==null&&t.commitId===ve.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),se({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=pI(t);d(null),_(!0),e&&se({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=jt(t.blueprint),i=t.rawBlueprint===void 0?t.blueprint:t.rawBlueprint;if(!r&&t.snapshot===void 0){let e=Kt(n);r=e.blueprint,i=e.rawBlueprint}r&&(p(r),h(i)),se(e=>t.snapshot===void 0?r?{status:`accepted`,repaired:!1,repairAttempted:!1,at:new Date().toISOString()}:e:mI(t.snapshot,e))}else if(t.type===`blueprint.error`&&r)d(null),_(!1),se(e=>e.status===`repairing`||e.status===`generating`?{status:`idle`}:e),K.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`&&!ye.current&&(ye.current=!0,K.warning(n(uI(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&&(Ce.current=!1,F(!1),K.error(n(`errors.commitFailed`),{description:String(t.error??``)}),y(`commit`),x(`commit_failed`),C(String(t.error??``)))}),()=>i(t)},[e,r,i,n]);let Ae=(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=be.current,a=xe.current.includes(i);Te().then(e=>{if(!e){_(!1),K.error(n(`errors.startFailed`));return}return fetch(`/api/blueprint/conversations/${e}/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:r,...Se.current?{model:Se.current}:{},...a?{reasoning_effort:i}:{},...t.intent?{intent:t.intent}:{}})}).then(e=>{!e.ok&&e.status!==202&&(_(!1),K.error(n(`errors.turnFailed`)))}).catch(()=>{_(!1),K.error(n(`errors.turnFailed`))})})},[g,pe,Te,n]),je=(0,Q.useCallback)(async e=>{if(!g){q(!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`);ge.current=n.conversation.id,s(n.conversation.id),n.conversation.provider&&ee(n.conversation.provider),L(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=jt(n.blueprint);p(r),h(r?n.rawBlueprint??n.blueprint:null),se(mI(n.snapshot,{status:`idle`})),d(null),_(!1),y(`chat`),x(null),C(null),D([]),G(``)}catch{K.error(n(`recent.resumeFailed`))}finally{q(!1)}}},[g,n]),Me=(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{K.error(n(`recent.discardFailed`))}},[n]),Ne=(0,Q.useCallback)(async()=>{let e=ge.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(ae?{reasoningEffort:ae}:{})});if(t.status===202)return;let r=await t.json().catch(()=>({}));_(!1),r.error===`nothing_to_repair`?K.info(n(`snapshot.nothingToRepair`)):r.error===`no_session`?K.error(n(`snapshot.noSession`)):r.error===`streaming`?K.info(n(`snapshot.alreadyStreaming`)):K.error(n(`errors.turnFailed`))}catch{_(!1),K.error(n(`errors.turnFailed`))}}},[g,ae,n]),Pe=(0,Q.useCallback)(()=>Ae(n(`prompts.surpriseMe`),{intent:`surprise`}),[Ae,n]),Fe=(0,Q.useCallback)(()=>Ae(n(`prompts.approve`),{intent:`approve`}),[Ae,n]),Ie=(0,Q.useCallback)(e=>{!f||Ce.current||(Ce.current=!0,F(!0),x(null),C(null),D([]),ye.current=!1,fetch(`/api/blueprint/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({blueprint:m??f,...e,...ge.current?{conversationId:ge.current}:{}})}).then(async e=>{let t=await e.json().catch(()=>({}));e.status===202&&t.commitId?(T(t.commitId),ve.current=t.commitId,y(`progress`)):(x(t.error??`generic`),C(t.detail??null)),Ce.current=!1,F(!1)}).catch(()=>{Ce.current=!1,F(!1),x(`generic`),C(null)}))},[f,m]),Le=(0,Q.useCallback)(async()=>{if(!(!O||A)){j(!0);try{let e=RF(),t=await WF(O,1,{autoAdvance:e}),r=VF(1);if(t.ok){let i=t.launched.length+t.pending.length;t.pending.length>0?K.success(n(e?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:r,count:t.ticketCount,n:i})):K.success(n(`milestoneProgress.toast.launchedAll`,{milestone:r,count:t.ticketCount,n:i})),a(O),N(!0)}else t.reason===`chain_active`?(K.info(n(`milestoneProgress.toast.chainActive`,{milestone:r})),a(O),N(!0)):t.reason===`rail_limit_reached`?K.warning(n(`milestoneProgress.toast.railLimitReached`,{milestone:r})):K.error(n(`done.launchFailed`),{description:t.detail??t.error})}finally{j(!1)}}},[O,A,a,n]),Re=(0,Q.useCallback)(()=>{O&&a(O),we.current()},[O,a]),ze=(0,Q.useCallback)(()=>{let e=ge.current;e&&fetch(`/api/blueprint/conversations/${e}/abort`,{method:`POST`}).catch(()=>{}),s(null),ge.current=null,_e.current=null,l([]),d(null),p(null),h(null),se({status:`idle`}),ue([]),q(!1),_(!1),y(`chat`),x(null),C(null),T(null),D([]),ye.current=!1,k(null),N(!1),j(!1),Ce.current=!1,F(!1),ee(`claude`),L(null),B([]),V(``),ie([]),H(`medium`),G(``)},[]),Be=wt(f),Ve=Object.values(Be).some(Boolean)||c.length>0||W.trim().length>0,He=(0,Q.useMemo)(()=>iI(m??f,{milestoneLabel:`M1`,minSpecs:fI.minSpecs,maxSpecs:fI.maxSpecs,requireScaffold:!0}),[f,m]),Ue=oe.status===`generating`,We=(0,Q.useMemo)(()=>oI(f,m??f,He,fI,{generating:Ue}),[f,m,He,Ue]),Ge=(0,Q.useMemo)(()=>{if(He.valid)return null;let e=He.issues[0];return e?cI(n,e):null},[He,n]),Ke=(0,Q.useMemo)(()=>Ut(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:Ve,canProposeCommit:He.valid,specQualityDetail:Ge,readiness:We,snapshot:oe,generation:Ke,recent:le,recentLoading:de,resume:je,discardRecent:Me,repairSnapshot:Ne,showSurpriseMe:c.length<=1&&v===`chat`,provider:I,model:te,models:z,efforts:he,effort:ae,draft:W,setDraft:G,setEffort:H,setProvider:Oe,setModel:ke,send:Ae,surpriseMe:Pe,approveBlueprint:Fe,goToCommit:()=>y(`commit`),backToChat:()=>y(`chat`),submitCommit:Ie,launchM1:Le,openProject:Re,abortAndReset:ze}}var _I={done:`bg-accent-success`,onReview:`bg-accent-warning`,inProgress:`bg-accent-info animate-pulse`,failed:`bg-destructive`,todo:`bg-muted-foreground/25`},vI={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 yI({counts:e,className:t}){let{t:n}=U(`builder`),r=Rt(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:Ht(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`,_I[e.key]),style:{width:`${e.pct}%`},title:`${n(`milestoneProgress.legend.${e.key}`)} · ${e.count}`},e.key))})}function bI({state:e}){let{t}=U(`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`,vI[e]),children:t(`milestoneProgress.state.${e}`)})}function xI(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 SI({rail:e,now:t,onReview:n,onOpenRail:r}){let{t:i}=U(`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&&Mt.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)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),o==null?i(`milestoneProgress.state.running`):i(`milestoneProgress.rail.running`,{elapsed:jr(o)})]}):s?(0,$.jsx)(yP,{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)(qc,{className:`h-3 w-3`,"aria-hidden":!0}),i(`milestoneProgress.rail.review`)]})]})}function CI({checked:e,onChange:t,disabled:n=!1,compact:r=!1,testId:i=`milestone-auto-advance`}){let{t:a}=U(`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)(tl,{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 wI({chain:e,busy:t=!1,onResume:n,onCancel:r,onSetAutoAdvance:i}){let{t:a}=U(`builder`),o=Lt(e),s=e.status===`paused`,c=Tt(e),l=Bt(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)(kn,{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)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Mn,{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)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Mn,{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)(Vn,{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)(_u,{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)(tl,{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)(Be,{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)(bn,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.cancelled`)]}):(0,$.jsx)(`span`,{children:e.pauseReason===`integration_pending`?a(`milestoneProgress.chain.integrating`):a(`milestoneProgress.chain.waiting`,{k:e.nextChunk})})}),d&&i&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(CI,{checked:e.autoAdvance,disabled:t,onChange:t=>i(e.id,t),testId:`milestone-chain-auto-advance`})})]})}function TI({progress:e,actions:t,chainBusy:n,onReview:r,onOpenRail:i,onResume:a,onCancel:o,onSetAutoAdvance:s,className:c}){let{t:l}=U(`builder`),u=e.rails.some(e=>e.active),d=xI(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:kt(e.n)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium`,children:e.title}),(0,$.jsx)(bI,{state:e.state})]}),f.total>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(yI,{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:Ht(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)(wI,{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)(SI,{rail:e,now:d,onReview:r,onOpenRail:i},e.railIndex))})]})}function EI({projectId:e}){let{t}=U(`builder`),n=y(),{setActiveProjectId:r}=ce(),{progress:i,hasBlueprint:a}=It(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 KF(e,n);r.ok?K.success(t(`milestoneProgress.chain.resumed`)):K.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 JF(e,n,r);i.ok?(zF(r),K.success(t(r?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):K.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 qF(e,n);r.ok?K.success(t(`milestoneProgress.chain.cancelledToast`)):K.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)(An,{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)(TI,{progress:c,chainBusy:o,onReview:e=>l(Ve?`/review/${e}`:`/`),onOpenRail:()=>l(`/`),onResume:u,onCancel:f,onSetAutoAdvance:d,className:`bg-card/60`})}):null}var DI={surprise:jd,approve:Vu};function OI({kind:e,mode:t,onAction:n,disabled:r=!1,createdAt:i,className:a}){let{t:o}=U(`builder`),s=AS(),c=t===`settled`,l=c?xn:DI[e],u=i?kI(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)(xn,{className:`h-3 w-3`,"aria-hidden":!0}):(0,$.jsx)(Ln,{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)(Be,{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)(jS.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 kI(e){let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return MC(t,`p`,{locale:I()})}catch{return null}}var AI=`w-full rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`;function jI({variant:e}){let{t}=U(`builder`),{builderMode:n}=OL(),r=n.session,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(()=>RF()),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)(jS.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)(Ln,{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)(iM,{active:!0,inset:-3,radius:`1rem`}),(0,$.jsx)(jS.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:AI,children:(0,$.jsx)(jF,{session:r,autoFocus:!0})})]}),(0,$.jsx)(NF,{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)(OI,{kind:e.intent,mode:`settled`,createdAt:e.createdAt})},`${t}-${e.createdAt}`):(0,$.jsx)(ej,{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)(jb,{initial:!1,children:[p&&(0,$.jsx)(OI,{kind:`surprise`,mode:`offer`,onAction:r.surpriseMe,disabled:!r.conversationReady},`surprise`),m&&(0,$.jsx)(OI,{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&&At(r.streamBuffer)&&(0,$.jsx)(ej,{role:`assistant`,content:At(r.streamBuffer),streaming:!0}),r.generation.generating||r.snapshot.status===`repairing`||r.snapshot.status===`generating`?(0,$.jsx)(PF,{specsStarted:r.generation.specsStarted,snapshot:r.snapshot}):(0,$.jsx)(zC,{tool:null})]})]}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsx)(jS.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(AI,e===`inline`&&`mx-auto max-w-[680px]`),children:(0,$.jsx)(jF,{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)(kF,{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:dI.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)(lc,{className:`h-3.5 w-3.5 text-muted-foreground/40`}),n?.status===`running`&&(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin text-accent-info`}),n?.status===`done`&&(0,$.jsx)(xn,{className:`h-3.5 w-3.5 text-accent-success`}),n?.status===`warning`&&(0,$.jsx)(zn,{className:`h-3.5 w-3.5 text-accent-warning`}),n?.status===`failed`&&(0,$.jsx)(Vn,{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(uI(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)(xn,{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)(EI,{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)(An,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Vu,{className:`mr-1.5 h-3.5 w-3.5`}),t(`done.launchM1`)]}),(0,$.jsx)(CI,{checked:o,onChange:e=>{s(e),zF(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 MI=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`),NI={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 PI({spec:e,index:t,milestoneLabel:n=`M1`,onClose:r}){let{t:i}=U(`builder`),{t:a}=U(`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,BC.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)(wn,{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`,NI[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)(Vn,{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:MI,children:(0,$.jsx)(Cr,{remarkPlugins:[wr],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)(sc,{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 FI={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 II({blueprint:e,milestoneLabel:t=`M1`,snapshot:n}){let{t:r}=U(`builder`),{t:i}=U(`tickets`),a=wt(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)(An,{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)(xn,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-label":`✓`}):(0,$.jsx)(Vn,{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)(kn,{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)(wn,{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`,FI[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)(An,{className:`h-2.5 w-2.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Vl,{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)(Vl,{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)(PI,{spec:e.m1Specs[o],index:o,milestoneLabel:t,onClose:()=>s(null)})]})}var LI={done:xn,pending:lc,blocked:zn,writing:An},RI={done:`text-accent-success`,pending:`text-muted-foreground/50`,blocked:`text-accent-warning`,writing:`text-accent-info animate-spin`};function zI({readiness:e,snapshot:t,busy:n,primaryLabel:r,onPrimary:i,onRepair:a,primaryTestId:o=`builder-create-specs`,showPrimary:s=!0}){let{t:c}=U(`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=LI[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`,RI[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)(jb,{initial:!1,mode:`wait`,children:[d&&(0,$.jsxs)(jS.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)(An,{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)(jS.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)(zn,{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)(Lu,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.rejected.retry`)]})]},`rejected`),p&&(0,$.jsxs)(jS.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)(zn,{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)(Ln,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.halted.resume`)]})]},`halted`),t.status===`accepted`&&t.repaired&&!p&&(0,$.jsxs)(jS.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)(Ln,{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)(Bn,{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)(rc,{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:cI(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)(Bn,{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)(Vu,{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 BI(){let{t:e}=U(`agent`),{t}=U(`builder`),{minimize:n,startNewConversation:r,cycleTier:i,active:a,draftPinnedProjectId:o,setPinnedProject:s,builderMode:c}=OL(),[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}=qn({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(jS.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)(iM,{active:d&&c.session.messages.length===0&&c.session.phase===`chat`,inset:-3}),(0,$.jsx)(zs,{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)(eM,{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)(mF,{})]}),(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)(Pn,{className:`h-4 w-4`})}),(0,$.jsx)(Id,{}),(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)(Yl,{className:`h-4 w-4`}):(0,$.jsx)(ql,{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)(Vn,{className:`h-4 w-4`})})]})]}),d?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsx)(jI,{variant:`floating`}),(0,$.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border/40 lg:w-80`,children:[(0,$.jsx)(II,{blueprint:c.session.blueprint,snapshot:c.session.snapshot}),c.session.phase===`chat`&&(0,$.jsx)(zI,{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)(uF,{variant:`floating`})]}),!l&&(0,$.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,$.jsx)(Zn,{handles:g})})]})}var VI=`specrails-desktop:agent-bubble-pos`,HI=56,UI=12;function WI(){try{let e=localStorage.getItem(VI);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function GI(e){let t=Math.max(UI,window.innerWidth-HI-UI),n=Math.max(UI,window.innerHeight-HI-UI);return{left:Math.min(Math.max(UI,e.left),t),top:Math.min(Math.max(UI,e.top),n)}}function KI(){return{left:Math.round(window.innerWidth/2-HI/2),top:window.innerHeight-HI-20}}function qI(){let{t:e}=U(`agent`),{t}=U(`builder`),{open:n,isStreaming:r,active:i,builderMode:a}=OL(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(()=>GI(WI()??KI())),u=kS(0),d=kS(0),f=(0,Q.useRef)(!1),p=a.active?a.session.busy:r;(0,Q.useEffect)(()=>{let e=()=>l(e=>GI(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,Q.useCallback)(e=>{try{localStorage.setItem(VI,JSON.stringify(e))}catch{}},[]);return(0,$.jsxs)(jS.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=GI({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)(iM,{active:a.active&&a.session.messages.length===0&&a.session.phase===`chat`,inset:-4}),(0,$.jsx)(zs,{className:`h-5 w-5 text-accent-primary`}),p&&(0,$.jsx)(jS.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)(jb,{initial:!1,children:(o||p)&&(0,$.jsx)(jS.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 JI=`specrails-desktop:uiMode`;function YI(){if(!at)return`kanban`;try{return localStorage.getItem(JI)===`kanban`?`kanban`:`agent`}catch{return`agent`}}function XI(e){try{localStorage.setItem(JI,e)}catch{}}var ZI=(0,Q.createContext)(null);function QI({children:e,initialMode:t,persist:n=!0}){let[r,i]=(0,Q.useState)(()=>t??YI()),a=(0,Q.useCallback)(e=>{at&&(i(e),n&&XI(e))},[n]),o=(0,Q.useCallback)(()=>{i(e=>{if(!at)return`kanban`;let t=e===`kanban`?`agent`:`kanban`;return n&&XI(t),t})},[n]),s=(0,Q.useMemo)(()=>({uiMode:r,setUiMode:a,toggleUiMode:o}),[r,a,o]);return(0,$.jsx)(ZI.Provider,{value:s,children:e})}var $I={uiMode:`kanban`,setUiMode:()=>{},toggleUiMode:()=>{}};function eL(){return(0,Q.useContext)(ZI)??$I}var tL={streamingText:``,isStreaming:!1,liveTools:[],turnTools:[],queued:[]},nL=`specrails-desktop:favorite-agent-conversations`;function rL(){try{let e=localStorage.getItem(nL);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 iL(e){try{localStorage.setItem(nL,JSON.stringify([...e]))}catch{}}function aL(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var oL=`specrails-desktop:agent-tier-last`;function sL(){try{let e=localStorage.getItem(oL),t=e===null?0:Number.parseInt(e,10);return t===0||t===1||t===2||t===3?t:0}catch{return 0}}function cL(e){try{localStorage.setItem(oL,String(e))}catch{}}var lL=new Set([`completed`,`merged`,`discarded`,`superseded`]);function uL(e,t){return JSON.stringify(e)===JSON.stringify(t)}function dL(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 fL(e,t){if(t.supersedesDeliveryId===e.prDeliveryId)return 1;if(e.supersedesDeliveryId===t.prDeliveryId)return-1;let n=dL(e),r=dL(t);return n==null||r==null?null:r<n?-1:+(r>n)}function pL(e,t){let n=null;for(let r of e){if(r.supersedesDeliveryId!==t)continue;if(!n){n=r;continue}let e=dL(n),i=dL(r);(e==null||i==null||i>=e)&&(n=r)}return n}function mL(e,t){let n=t.restoredFromDeliveryId;if(!n)return!1;let r=pL(e,t.prDeliveryId);return!r||r.prDeliveryId===n}function hL(e,t){let n=e.filter(e=>e.role===`system`).map(e=>qo(e.content)).filter(e=>e!==null),r=[...n].reverse().find(e=>e.prDeliveryId===t.prDeliveryId),i=mL(n,t);if(r){let e=lL.has(r.decision),n=lL.has(t.decision),a=Ct(r.updatedAt,t.updatedAt);if(a===-1||a===0&&!uL(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=fL(e,t);if(n===-1||(n===0||n===null)&&!lL.has(e.decision)&&t.supersedesDeliveryId!==e.prDeliveryId)return!0}return!1}function gL(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=qo(e.content);return!t||t.prDeliveryId!==n||lL.has(t.decision)?e:(r=!0,{...e,content:JSON.stringify({...t,decision:`discarded`})})});return r?i:e}function _L(e,t){let n=e.filter(e=>e.role===`system`).map(e=>qo(e.content)).filter(e=>e!==null);if(n.some(e=>e.restoredFromDeliveryId===t.prDeliveryId&&mL(n,e)))return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let n=qo(e.content);return!n||n.railIndex!==t.railIndex||n.prDeliveryId===t.prDeliveryId||lL.has(n.decision)||fL(n,t)!==1?e:(r=!0,{...e,content:JSON.stringify({...n,decision:`superseded`})})});return r?i:e}function vL(e,t,n){if(hL(e,n))return e;let r=_L(gL(e,n),n),i=JSON.stringify(n),a=r.flatMap((e,t)=>e.role===`system`&&qo(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 yL=(0,Q.createContext)(null);function bL(e){if(e.code===`policy_unenforceable`){let t=e.provider?e.provider.charAt(0).toUpperCase()+e.provider.slice(1):``;return N.t(`agent:subagents.policyUnenforceable`,{provider:t})}return e.error||`The agent turn failed.`}var xL=0,SL=0,CL={sent:0,received:1,read:2};function wL(e,t){return e&&(!t||CL[e]>=CL[t])?e:t}function TL(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=wL(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 EL({children:e,fixedConversationId:t}){let n=(0,Q.useId)(),r=t?`agent-chat-pane:${n}`:`agent-chat`,{registerHandler:i,unregisterHandler:a,connectionStatus:o}=R(),{uiMode:s}=eL(),{setActiveProjectId:c,activeProjectId:l}=ce(),u=Mi(),d=(0,Q.useRef)(u);d.current=u;let f=wi(),p=e=>e?d.current.isEditable(e):!f,[m,h]=(0,Q.useState)(`hidden`),[g,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)([]),S=(0,Q.useRef)(new Map),C=(0,Q.useRef)(b);C.current=b;let[w,T]=(0,Q.useState)(rL);(0,Q.useEffect)(()=>{let e=e=>{(e.key===nL||e.key===null)&&T(rL())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let[E,D]=(0,Q.useState)(new Set),[O,k]=(0,Q.useState)(new Map),[A,j]=(0,Q.useState)(!0),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(null),[I,ee]=(0,Q.useState)([]),te=(0,Q.useRef)([]);te.current=I;let L=(0,Q.useRef)(!1),[z,B]=(0,Q.useState)(null),ne=(0,Q.useRef)(null);ne.current=z;let[V,re]=(0,Q.useState)(`claude`),[ie,ae]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(()=>sL()),[W,G]=(0,Q.useState)(null),oe=(0,Q.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});oe.current={provider:V,model:ie,tierLevel:H,effort:W};let se=(0,Q.useRef)(null);se.current=v?.id??null;let le=(0,Q.useRef)(O);le.current=O;let ue=(0,Q.useRef)(new Set),de=(0,Q.useRef)(new Set),fe=(0,Q.useRef)(new Map),pe=(0,Q.useRef)(new Map),q=e=>{let t=wL(e.delivery_receipt,fe.current.get(`${e.conversation_id}:m:${e.id}`));return t?{...e,delivery_receipt:t}:e},me=(e,t)=>{let n=wL(t.deliveryReceipt,fe.current.get(`${e}:q:${t.queueId}`));return n?{...t,deliveryReceipt:n}:t},he=(0,Q.useRef)(new Set),ge=(0,Q.useRef)(new Map),_e=(0,Q.useRef)(new Map),J=(0,Q.useRef)(new Map),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(0),be=(0,Q.useRef)(0),xe=(0,Q.useRef)(new Map),Se=(0,Q.useCallback)(e=>{let t=se.current;if(!t)return`untracked`;if(hL(C.current,e))return`stale`;if(!C.current.some(t=>t.role===`system`&&qo(t.content)?.prDeliveryId===e.prDeliveryId))return`untracked`;ye.current++;let n=vL(C.current,t,e);return C.current=n,x(n=>{if(!n.some(t=>t.role===`system`&&qo(t.content)?.prDeliveryId===e.prDeliveryId))return C.current=n,n;let r=vL(n,t,e);return C.current=r,r}),`accepted`},[]),Ce=(0,Q.useCallback)((e,t)=>{k(n=>{let r=t(n.get(e)??tL),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})},[]),we=(0,Q.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===se.current&&!t||D(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Te=(0,Q.useCallback)(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,Q.useEffect)(()=>{if(!$e||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=se.current;e&&Te(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Te]);let Ee=(v?O.get(v.id):void 0)??tL,De=Ee.streamingText,Oe=Ee.isStreaming,ke=Ee.liveTools,Ae=Ee.turnTools,je=Ee.queued,Me=(0,Q.useMemo)(()=>{let e=new Set;for(let[t,n]of O)n.isStreaming&&e.add(t);return e},[O]),Ne=(0,Q.useCallback)(async()=>{try{let e=await bo();_(e),T(t=>{let n=aL(rL(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(iL(n),n)})}catch{}},[]),Pe=(0,Q.useCallback)(async()=>{try{let e=await $o();j(e.enabled)}catch{j(!1)}},[]),Fe=(0,Q.useCallback)(async()=>{try{let{any:e,installed:t}=await Qo();F(e),ee(Array.isArray(t)?t:[])}catch{F(!0)}},[]),[Ie,Le]=(0,Q.useState)(0);(0,Q.useEffect)(()=>$e?(i(r,e=>{let n=e;if(!n||t&&n.conversationId&&n.conversationId!==t)return;if(n.type===`desktop.project_recovered`){Le(e=>e+1);return}if(typeof n.type!=`string`||!n.type.startsWith(`agent_`))return;if(n.type===`agent_conversation_created`){Ne();return}if(n.type===`agent_title`&&n.conversationId){let e=n.title??null;_(t=>t.map(t=>t.id===n.conversationId?{...t,title:e}:t)),y(t=>t&&t.id===n.conversationId?{...t,title:e}:t);return}let r=n.conversationId;if(!r)return;ge.current.set(r,(ge.current.get(r)??0)+1);let i=r===se.current,a=e=>{J.current.set(r,TL(J.current.get(r)??[],e).slice(-500)),i&&(C.current=TL(C.current,e),x(t=>TL(t,e)))};if(n.type===`agent_input_receipt`){if(n.receipt!==`received`&&n.receipt!==`read`)return;let e=`${r}:q:${n.queueId}`,t=n.messageId??pe.current.get(e);if(n.queueId&&fe.current.set(e,wL(fe.current.get(e),n.receipt)),t){let e=`${r}:m:${t}`;fe.current.set(e,wL(fe.current.get(e),n.receipt));let o=(i?C.current:J.current.get(r)??[]).find(e=>e.id===t);o&&a([q(o)])}Ce(r,e=>({...e,queued:e.queued.map(e=>e.queueId===n.queueId?{...e,deliveryReceipt:wL(e.deliveryReceipt,n.receipt)}:e)}))}else if(n.turnId&&(n.type===`agent_stream`||n.type===`agent_tool`||n.type===`agent_tool_result`))n.type===`agent_stream`&&we(r);else if(n.type===`agent_turn_done`)we(r),n.messageId&&n.fullText&&a([{id:n.messageId,conversation_id:r,role:`assistant`,content:n.fullText,created_at:n.timestamp??new Date().toISOString(),...n.turnId?{core_turn_id:n.turnId}:{},...n.origin?{turn_origin:n.origin}:{}}]);else if(n.type===`agent_stream`)we(r),Ce(r,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(n.delta??``)}));else if(n.type===`agent_tool`)Ce(r,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${xL++}`,tool:n.tool??`tool`,...n.input?{input:n.input}:{},...n.toolId?{toolId:n.toolId}:{},...n.timestamp?{at:n.timestamp}:{}}].slice(-200)}));else if(n.type===`agent_tool_result`)Ce(r,e=>{let t=[...e.liveTools],r=n.toolId?t.findIndex(e=>e.toolId===n.toolId):-1;if(r===-1){for(let e=t.length-1;e>=0;e--)if(t[e].output===void 0){r=e;break}}return r===-1?e:(t[r]={...t[r],output:n.output??``,...n.isError?{isError:!0}:{}},{...e,liveTools:t})});else if(n.type===`agent_partial`){let e=n.fullText??``;e&&a([{id:n.messageId??`partial-${r}-${n.timestamp??Date.now()}`,conversation_id:r,role:`assistant`,content:e,created_at:n.timestamp??new Date().toISOString()}])}else if(n.type===`agent_done`){xe.current.delete(r),we(r);let e=n.fullText??``;n.messageId&&e?a([{id:n.messageId,conversation_id:r,role:`assistant`,content:e,created_at:n.timestamp??new Date().toISOString(),...n.coreTurnId?{core_turn_id:n.coreTurnId,turn_origin:`user`}:{}}]):i&&e&&x(t=>{let n=t[t.length-1];return n&&n.role===`assistant`&&n.content===e&&!n.id.startsWith(`local-`)?t:[...t,{id:`local-${Date.now()}`,conversation_id:r,role:`assistant`,content:e,created_at:new Date().toISOString()}]}),Ce(r,e=>({...tL,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}))}else if(n.type===`agent_error`){xe.current.delete(r),we(r),Ce(r,e=>({...tL,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}));let e=bL(n);t||K.error(e),i&&x(t=>[...t,{id:`err-${Date.now()}`,conversation_id:r,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(n.type===`agent_queued`){if(n.queueId&&ue.current.has(n.queueId))return;Ce(r,e=>{let t=wL(n.deliveryReceipt??n.delivery_receipt,fe.current.get(`${r}:q:${n.queueId}`)),i={queueId:n.queueId??`srv-${SL++}`,text:n.text??``,contextRefs:n.contextRefs,attachmentIds:n.attachmentIds,deliveryMode:n.deliveryMode,...t?{deliveryReceipt:t}:{},timestamp:n.timestamp};return n.queueId&&e.queued.some(e=>e.queueId===n.queueId)?{...e,queued:e.queued.map(e=>e.queueId===n.queueId?{...e,...i,deliveryReceipt:wL(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(n.type===`agent_steered`){if(!n.messageId)return;if(he.current.has(n.messageId)){n.queueId&&ue.current.add(n.queueId),Ce(r,e=>({...e,queued:e.queued.filter(e=>e.queueId!==n.queueId)}));return}he.current.add(n.messageId),n.queueId&&ue.current.add(n.queueId),pe.current.set(`${r}:q:${n.queueId}`,n.messageId);let e=wL(n.delivery_receipt??n.deliveryReceipt,fe.current.get(`${r}:q:${n.queueId}`)),t=[];n.assistantSegment&&t.push({...n.assistantSegment,conversation_id:r,role:`assistant`}),t.push(q({id:n.messageId,conversation_id:r,role:`user`,content:n.text??``,context_refs:n.contextRefs??[],attachment_ids:n.attachmentIds??[],delivery_status:n.deliveryStatus??`delivered`,...e?{delivery_receipt:e}:{},created_at:n.timestamp??new Date().toISOString()})),a(t),Ce(r,e=>({...e,queued:e.queued.filter(e=>e.queueId!==n.queueId),streamingText:n.assistantSegment?``:e.streamingText}))}else if(n.type===`agent_dequeued`||n.type===`agent_input_started`){if(i&&n.queueId&&(C.current=C.current.filter(e=>e.id!==`local-u-${n.queueId}`),x(e=>e.filter(e=>e.id!==`local-u-${n.queueId}`))),n.queueId&&ue.current.has(n.queueId))return;if(n.queueId&&ue.current.add(n.queueId),Ce(r,e=>({...e,queued:n.queueId?e.queued.filter(e=>e.queueId!==n.queueId):e.queued.slice(1),isStreaming:!0,streamingText:``,liveTools:[]})),n.text){n.messageId&&pe.current.set(`${r}:q:${n.queueId}`,n.messageId);let e=wL(n.delivery_receipt??n.deliveryReceipt,fe.current.get(`${r}:q:${n.queueId}`));a([q({id:n.messageId??`local-u-${Date.now()}`,conversation_id:r,role:`user`,content:n.text,context_refs:n.contextRefs??[],attachment_ids:n.attachmentIds??[],...n.messageId?{delivery_status:`delivered`}:{},...e?{delivery_receipt:e}:{},created_at:n.timestamp??new Date().toISOString()})])}}else if(n.type===`agent_queue_cleared`)_e.current.set(r,(_e.current.get(r)??0)+1),n.messages?.length&&a(n.messages),Ce(r,e=>({...e,queued:[]}));else if(n.type===`agent_queue_removed`){if(!n.queueId)return;ue.current.add(n.queueId),de.current.add(n.queueId),Ce(r,e=>({...e,queued:e.queued.filter(e=>e.queueId!==n.queueId)}))}else if(n.type===`agent_queue_edited`)Ce(r,e=>({...e,queued:e.queued.map(e=>n.queueId&&e.queueId===n.queueId?{...e,text:n.text??e.text,contextRefs:n.contextRefs??e.contextRefs,deliveryMode:n.deliveryMode??e.deliveryMode}:e)}));else if(n.type===`agent_run_failure`){if(we(r),i){let{type:e,conversationId:t,messageId:i,timestamp:a,...o}=n;if(typeof i==`string`&&!C.current.some(e=>e.id===i)){let e={id:i,conversation_id:r,role:`system`,content:JSON.stringify(o),created_at:typeof a==`string`?a:new Date().toISOString()};C.current=[...C.current,e],x(t=>t.some(e=>e.id===i)?t:[...t,e])}}}else if(n.type===`agent_pr_decision`&&(we(r),i)){let t=Ko(e);if(t){ye.current++;let e=vL(C.current,r,t);C.current=e,x(e=>{let n=vL(e,r,t);return C.current=n,n})}}}),()=>a(r)):void 0,[i,a,Ce,we,Ne,r,t]);let Re=(0,Q.useCallback)(async(e,t)=>{let n=++be.current,r=ge.current.get(e)??0;ye.current++;let{conversation:i,messages:a,pendingMessages:o,live:s}=await Oo(e);if(t?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);if(n!==be.current){if(t)throw new DOMException(`The mission changed during restoration`,`AbortError`);return}ye.current++;let c=TL(a,J.current.get(e)??[]).map(q);for(let e of c)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&he.current.add(e.id);y(i),C.current=c,x(c),Te(e),r===(ge.current.get(e)??0)&&(o!==void 0||s)&&Ce(e,t=>({...t,...s?{isStreaming:s.isStreaming,streamingText:s.streamingText}:{},queued:o?.filter(e=>!ue.current.has(e.queueId)).map(t=>me(e,t))??t.queued}))},[Te,Ce]),ze=(0,Q.useCallback)(async()=>{let e=se.current;if(!e)return;let t=ye.current,n=ge.current.get(e)??0,r=S.current.get(e)??0;try{let i=await Oo(e);if(se.current!==e||ye.current!==t)return;if(r===(S.current.get(e)??0)&&(y(t=>t?.id===e?i.conversation:t),_(t=>t.map(t=>t.id===e?i.conversation:t))),(i.pendingMessages!==void 0||i.live)&&n===(ge.current.get(e)??0)){let t=TL(i.messages,J.current.get(e)??[]).map(q);for(let e of t)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&he.current.add(e.id);x(e=>TL(t,e.filter(e=>e.id.startsWith(`local-u-`)&&!t.some(t=>t.role===`user`&&t.content===e.content)))),Ce(e,t=>({...t,...i.live?{isStreaming:i.live.isStreaming,streamingText:i.live.streamingText}:{},queued:i.pendingMessages?.filter(e=>!ue.current.has(e.queueId)).map(t=>me(e,t))??t.queued}))}let a=i.messages.filter(e=>e.role===`system`).map(e=>qo(e.content)).filter(e=>e!==null);if(a.length===0)return;x(t=>{let n=a.reduce((t,n)=>vL(t,e,n),t);return C.current=n,n})}catch{}},[Ce]),Be=(0,Q.useCallback)(async()=>{try{let e=new Map(ge.current),t=await Eo(),n=new Set(t.turns.map(e=>e.conversationId)),r=Date.parse(t.capturedAt),i=[...le.current].flatMap(([t,i])=>{if(!i.isStreaming||n.has(t)||(e.get(t)??0)!==(ge.current.get(t)??0))return[];let a=xe.current.get(t);return a&&Date.parse(a)>r?[]:[t]});k(i=>{let a=new Map(i);for(let[t,o]of i){if(!o.isStreaming||n.has(t)||(e.get(t)??0)!==(ge.current.get(t)??0))continue;let i=xe.current.get(t);i&&Date.parse(i)>r||a.set(t,{...tL,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)!==(ge.current.get(t)??0))continue;let r=a.get(t)??tL;a.set(t,{...r,isStreaming:!0,streamingText:n.streamingText??r.streamingText,queued:n.pendingMessages?.filter(e=>!ue.current.has(e.queueId)).map(e=>me(t,e))??r.queued})}return a});for(let e of i)xe.current.delete(e);let a=se.current;if(a&&i.includes(a)){let e=`interrupted-${a}-${t.snapshotVersion}`;x(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=()=>{Ne(),ze()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[ze,Ne]),(0,Q.useEffect)(()=>{Ie&&(Ne(),ze())},[Ie,Ne,ze]);let Ve=(0,Q.useRef)(o);(0,Q.useEffect)(()=>{let e=Ve.current;Ve.current=o,o===`connected`&&e!==`connected`&&(Ne(),Pe(),Fe(),ze(),Be())},[o,Ne,Pe,Fe,ze,Be]);let He=(0,Q.useCallback)(async()=>{if(v)return v;if(f||t)throw Error(`This view is reserved for its mission.`);let e=await bo();if(_(e),T(t=>{let n=aL(rL(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(iL(n),n)}),e.length>0)return await Re(e[0].id),e[0];let n=await Do({});return _(e=>[n,...e.filter(e=>e.id!==n.id)]),y(n),x([]),n},[v,Re,f,t]),Ue=(0,Q.useCallback)(()=>{h(`open`),Ne(),Pe(),Fe(),He()},[Ne,Pe,Fe,He]),We=(0,Q.useCallback)(()=>h(`hidden`),[]),Ge=(0,Q.useCallback)(()=>h(`minimized`),[]),[Ke,qe]=(0,Q.useState)(!1),Je=(0,Q.useRef)(null),Ye=(0,Q.useCallback)(()=>{Je.current?.abortAndReset(),qe(!1)},[]),Xe=gI(Ke,{onFinished:Ye});Je.current=Xe;let Ze=(0,Q.useCallback)(()=>{f||t||(qe(!0),s!==`agent`&&Ue())},[s,Ue,f,t]),Qe=(0,Q.useCallback)(()=>{h(e=>e===`open`?`minimized`:`open`),m!==`open`&&(Ne(),Pe(),Fe(),He())},[m,Ne,Pe,Fe,He]),et=(0,Q.useCallback)(async()=>{if(!p(v?.id))throw Error(`This mission is active in another window.`);if(v)return v;if(ve.current)return ve.current;let e=Do({pinnedProjectId:ne.current,provider:oe.current.provider,model:oe.current.model,tierLevel:oe.current.tierLevel,reasoningEffort:oe.current.effort}).then(e=>(Si(e.id),_(t=>[e,...t.filter(t=>t.id!==e.id)]),y(e),x([]),e)).finally(()=>{ve.current=null});return ve.current=e,e},[v]),tt=(0,Q.useCallback)(async(e,t)=>{if(!p(v?.id))return{accepted:!1};let n=e.trim();if(!n)return{accepted:!1};let r=v??await et();ge.current.set(r.id,(ge.current.get(r.id)??0)+1);let i=ge.current.get(r.id),a=_e.current.get(r.id)??0,o=t?.queueId??`q-${Date.now()}-${SL++}`,s=new Date().toISOString();xe.current.set(r.id,s),_(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:s},...e.filter(e=>e.id!==r.id)]),y(e=>e&&e.id===r.id?{...e,updated_at:s}:e);let c={id:`local-u-${o}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],delivery_receipt:`sent`,created_at:s},l=le.current.get(r.id)?.isStreaming===!0,u={queueId:o,text:n,contextRefs:t?.contextRefs,attachmentIds:t?.attachmentIds,deliveryMode:`queue`,deliveryReceipt:`sent`,timestamp:s};l?Ce(r.id,e=>({...e,queued:e.queued.some(e=>e.queueId===o)?e.queued.map(e=>e.queueId===o?{...u,deliveryReceipt:wL(e.deliveryReceipt,u.deliveryReceipt),deliveryMode:e.deliveryMode??u.deliveryMode,timestamp:e.timestamp??u.timestamp}:e):[...e.queued,u]})):(x(e=>[...e,c]),Ce(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let d=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,s=await jo(r.id,n,{tierLevel:r.tier_level,attachments:d,queueId:o,contextRefs:e});if(s.removed){ue.current.add(o),de.current.add(o);let e=!l&&i===ge.current.get(r.id);return se.current===r.id&&x(e=>e.filter(e=>e.id!==c.id)),Ce(r.id,t=>({...t,queued:t.queued.filter(e=>e.queueId!==o),...e?{isStreaming:!1}:{}})),e&&xe.current.delete(r.id),{accepted:!0,conversationId:r.id}}if(s.message){pe.current.set(`${r.id}:q:${o}`,s.message.id);let e=wL(s.message.delivery_receipt,fe.current.get(`${r.id}:q:${o}`)),t=q({...s.message,...e?{delivery_receipt:e}:{}});return ue.current.add(o),J.current.set(r.id,TL(J.current.get(r.id)??[],[t]).slice(-500)),se.current===r.id&&x(e=>TL(e.filter(e=>e.id!==c.id),[t])),Ce(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})),s.duplicate&&Be(),{accepted:!0,conversationId:r.id}}if(a!==(_e.current.get(r.id)??0))return x(e=>e.filter(e=>e.id!==c.id)),{accepted:!0,conversationId:r.id};let f=s?.queued===!0;return f&&!l?(x(e=>e.filter(e=>e.id!==c.id)),ue.current.has(o)||Ce(r.id,e=>e.queued.some(e=>e.queueId===o)?e:{...e,queued:[...e.queued,{...u,deliveryMode:s.deliveryMode??u.deliveryMode}]})):!f&&l&&!ue.current.has(o)&&(Ce(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o),isStreaming:!0})),x(e=>[...e,c])),{accepted:!0,conversationId:r.id}}catch(e){return ue.current.has(o)||a!==(_e.current.get(r.id)??0)?{accepted:!0,conversationId:r.id}:(xe.current.delete(r.id),l?Ce(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})):(Ce(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),x(e=>e.filter(e=>e.id!==c.id))),K.error(e instanceof Error?e.message:`Failed to send message.`),{accepted:!1,conversationId:r.id})}},[v,et,Ce,Be]),nt=(0,Q.useCallback)(async()=>{if(!(!v||!p(v.id)))try{await Lo(v.id),_e.current.set(v.id,(_e.current.get(v.id)??0)+1),ge.current.set(v.id,(ge.current.get(v.id)??0)+1),Ce(v.id,()=>null)}catch(e){K.error(e instanceof Error?e.message:`Failed to stop the agent.`)}},[v,Ce]),rt=(0,Q.useCallback)(async(e,t)=>{let n=v;if(!n||!p(n.id)||le.current.get(n.id)?.queued.find(t=>t.queueId===e)?.deliveryMode===`steer`)return`conflict`;let r=await Ro(n.id,e,t);return r===`saved`&&Ce(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[v,Ce]),it=(0,Q.useCallback)(async e=>{let t=v,n=t&&le.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!p(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await zo(t.id,e);return r===`saved`?(ge.current.set(t.id,(ge.current.get(t.id)??0)+1),Ce(t.id,t=>({...t,queued:t.queued.map(t=>t.queueId===e?{...t,deliveryMode:`steer`}:t)}))):se.current===t.id&&ze(),r},[v,Ce,ze]),at=(0,Q.useCallback)(async e=>{let t=v,n=t&&le.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!p(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await Bo(t.id,e);return r===`saved`?(ue.current.add(e),de.current.add(e),ge.current.set(t.id,(ge.current.get(t.id)??0)+1),Ce(t.id,t=>({...t,queued:t.queued.filter(t=>t.queueId!==e)}))):se.current===t.id&&ze(),r},[v,Ce,ze]),ot=(0,Q.useCallback)(e=>ue.current.has(e)&&!de.current.has(e),[]),st=(0,Q.useCallback)(async e=>{if(!v||!p(v.id))return;let t=(S.current.get(v.id)??0)+1;S.current.set(v.id,t);let n=await ko(v.id,e);S.current.get(v.id)===t&&(y(e=>e?.id===n.id?n:e),_(e=>e.map(e=>e.id===n.id?n:e)))},[v]),ct=(0,Q.useCallback)(async e=>{p(v?.id)&&(cL(e),v?await st({tierLevel:e}):U(e))},[v,st]),lt=(0,Q.useCallback)(async()=>{let e=((v?.tier_level??H)+1)%4;await ct(e)},[v,H,ct]),ut=(0,Q.useCallback)(async e=>{v?await st({provider:e}):(L.current=!0,re(e),ae(null),G(null))},[v,st]);(0,Q.useEffect)(()=>{v||L.current||I.length===0||I.includes(V)||(re(rn(I)),ae(null),G(null))},[v,I,V]);let dt=(0,Q.useCallback)(async e=>{v?await st({model:e}):(ae(e),G(null))},[v,st]),ft=(0,Q.useCallback)(async e=>{v?await st({reasoningEffort:e}):G(e)},[v,st]),pt=(0,Q.useCallback)(async e=>{f||t||!p(v?.id)||(v?await st({pinnedProjectId:e}):B(e),!v&&e&&s===`agent`&&c(e))},[v,st,s,c,f,t]),mt=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let e=mt.current;if(mt.current=l,!(e===void 0||e===l)&&!(f||t||s!==`agent`||!l)){if(!v){B(l);return}C.current.length>0||v.pinned_project_id!==l&&st({pinnedProjectId:l})}},[l,s,v,st,f,t]);let Y=(0,Q.useCallback)(e=>{f||t||(Ye(),y(null),x([]),B(e??null),L.current=!1,re(rn(te.current)),ae(null),U(sL()),G(null))},[Ye,f,t]),ht=(0,Q.useCallback)(async e=>{if(f||t)return;Ye();let n=await Do({pinnedProjectId:e===void 0?v?.pinned_project_id??null:e,tierLevel:sL()});_(e=>[n,...e.filter(e=>e.id!==n.id)]),y(n),x([])},[v,Ye,f,t]),gt=(0,Q.useCallback)(async(e,n)=>{if(!(t&&e!==t)&&!(f&&!t&&!n?.windowRestore&&d.current.current?.conversationId!==e)&&!(!t&&!f&&!n?.windowRestore&&await d.current.focus(e))){if(n?.signal?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);Ye(),await Re(e,n?.signal),n?.windowRestore&&s!==`agent`&&h(`open`)}},[Re,Ye,f,s,t]),_t=(0,Q.useCallback)(async e=>{p(e)&&(await Ao(e),await d.current.discard(e),_(t=>t.filter(t=>t.id!==e)),T(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),iL(n),n}),Ce(e,()=>null),se.current===e&&(y(null),x([])))},[Ce]),vt=(0,Q.useCallback)(async(e,t)=>{if(!p(e))return;let n=t.trim()||null;S.current.set(e,(S.current.get(e)??0)+1);let r;_(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),y(t=>t&&t.id===e?{...t,title:n}:t);try{await ko(e,{title:n})}catch(t){throw _(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),y(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),yt=(0,Q.useCallback)(e=>{T(()=>{let t=new Set(rL());return t.has(e)?t.delete(e):t.add(e),iL(t),t})},[]),bt=(0,Q.useCallback)(async()=>{N(!0);try{await es(),await Pe()}catch(e){K.error(e instanceof Error?e.message:`Failed to enable MCP.`)}finally{N(!1)}},[Pe]),xt=(0,Q.useMemo)(()=>({visibility:m,open:Ue,close:We,minimize:Ge,toggle:Qe,conversations:g,active:v,messages:b,streamingText:De,isStreaming:Oe,liveTools:ke,turnTools:Ae,queuedMessages:je,streamingConversationIds:Me,liveByConversation:O,unreadConversationIds:E,favoriteConversationIds:w,mcpEnabled:A,enablingMcp:M,enableMcpServer:bt,providersReady:P,send:tt,abort:nt,editQueuedMessage:rt,steerQueuedMessage:it,removeQueuedMessage:at,wasQueueConsumed:ot,cycleTier:lt,setTier:ct,setProvider:ut,setModel:dt,setPinnedProject:pt,newConversation:ht,startNewConversation:Y,materializeDraftConversation:et,draftPinnedProjectId:z,draftProvider:V,draftModel:ie,draftTierLevel:H,draftEffort:W,setEffort:ft,selectConversation:gt,deleteConversation:_t,renameConversation:vt,toggleFavoriteConversation:yt,refreshConversations:Ne,applyPrDecisionSnapshot:Se,builderMode:{active:Ke,enter:Ze,exit:Ye,session:Xe}}),[m,Ue,We,Ge,Qe,Ke,Ze,Ye,Xe,g,v,b,De,Oe,ke,Ae,je,Me,O,E,w,A,M,bt,P,tt,nt,rt,it,at,ot,lt,ct,ut,dt,pt,ht,Y,et,z,V,ie,H,W,ft,gt,_t,vt,yt,Ne,Se]),St=!t&&$e&&s!==`agent`;return(0,$.jsxs)(yL.Provider,{value:xt,children:[(0,$.jsx)(_s,{children:t?e:(0,$.jsx)(so,{primaryId:v?.id??null,children:e})}),St&&m===`open`&&(0,$.jsx)(BI,{}),St&&m!==`open`&&(0,$.jsx)(qI,{})]})}var DL={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 OL(){return(0,Q.useContext)(yL)??DL}var kL=new Map;function AL(){let e=OL(),t=fj(),n=ce(),r=Ya(),{registerHandlers:i}=Mi(),{t:a}=U(`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&&kL.set(r,t.captureWorkspace());let i=kL.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){VS(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(WS(e.conversationId))throw Error(i(`window.finishPending`));return{version:1,...e,capturedAt:Date.now(),composer:gi(e.conversationId),scroll:BS(e.conversationId),workspace:{...n.captureWorkspace(),...e.projectId?{codeSelection:NS(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&&kL.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,kL.set(t.conversationId,e.workspace),vi(t.conversationId,e.composer),t.projectId&&(e.workspace.codeSelection&&PS(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),VS(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 jL=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 ML(this.width*e,this.height*e)}[gt](){return{width:this.width,height:this.height}}toJSON(){return this[gt]()}},ML=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 jL(this.width/e,this.height/e)}[gt](){return{width:this.width,height:this.height}}toJSON(){return this[gt]()}},NL=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof jL?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof ML?this.size:this.size.toPhysical(e)}[gt](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[gt]()}},PL=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 FL(this.x*e,this.y*e)}[gt](){return{x:this.x,y:this.y}}toJSON(){return this[gt]()}},FL=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 PL(this.x/e,this.y/e)}[gt](){return{x:this.x,y:this.y}}toJSON(){return this[gt]()}},IL=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof PL?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof FL?this.position:this.position.toPhysical(e)}[gt](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[gt]()}},LL;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(LL||={});var RL=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},zL;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(zL||={});function BL(){return new UL(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function VL(){return Y(`plugin:window|get_all_windows`).then(e=>e.map(e=>new UL(e,{skip:!0})))}var HL=[`tauri://created`,`tauri://error`],UL=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 VL()).find(t=>t.label===e)??null}static getCurrent(){return BL()}static async getAll(){return VL()}static async getFocusedWindow(){for(let e of await VL())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)}:Nr(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)}:Fr(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(HL.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return Pr(e,t)}async emitTo(e,t,n){if(HL.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return Ir(e,t,n)}_handleTauriEvent(e,t){return HL.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 FL(e))}async outerPosition(){return Y(`plugin:window|outer_position`,{label:this.label}).then(e=>new FL(e))}async innerSize(){return Y(`plugin:window|inner_size`,{label:this.label}).then(e=>new ML(e))}async outerSize(){return Y(`plugin:window|outer_size`,{label:this.label}).then(e=>new ML(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===LL.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 NL?e:new NL(e)})}async setMinSize(e){return Y(`plugin:window|set_min_size`,{label:this.label,value:e instanceof NL?e:e?new NL(e):null})}async setMaxSize(e){return Y(`plugin:window|set_max_size`,{label:this.label,value:e instanceof NL?e:e?new NL(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 IL?e:new IL(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:Ia(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 IL?e:new IL(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?Ia(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(Lr.WINDOW_RESIZED,t=>{t.payload=new ML(t.payload),e(t)})}async onMoved(e){return this.listen(Lr.WINDOW_MOVED,t=>{t.payload=new FL(t.payload),e(t)})}async onCloseRequested(e){return this.listen(Lr.WINDOW_CLOSE_REQUESTED,async t=>{let n=new RL(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(Lr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new FL(t.payload.position)}})}),n=await this.listen(Lr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new FL(t.payload.position)}})}),r=await this.listen(Lr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new FL(t.payload.position)}})}),i=await this.listen(Lr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(Lr.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(Lr.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(Lr.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(Lr.WINDOW_THEME_CHANGED,e)}},WL;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(WL||={});var GL;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(GL||={});var KL;(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`})(KL||={});var qL;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(qL||={});var JL=(0,Q.lazy)(()=>c(()=>import(`./AgentBrowserCapture-CHlXWdXq.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([90,1,7,42,43,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,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,77,78,79,80])));function YL(){let{browserOpen:e}=fj(),{active:t}=OL(),n=Mi(),r=!n.current&&n.transfers.some(e=>e.conversationId===t?.id&&e.state===`detached`),{activeProjectId:i}=ce(),a=t?.pinned_project_id??i;return!e||!a||r?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(JL,{projectId:a,conversationId:t?.id??null})})}function XL(e,t){e=Math.max(1,e);let n=e>1&&t>=640?2:1,r=Array.from({length:n},(t,r)=>Math.ceil((e-r)/n)),i=(e,t)=>t?i(t,e%t):e,a=r.reduce((e,t)=>e*t/i(e,t),1),o=a/Math.max(...r);return{columns:n,rows:a,minimumRowHeight:e>1?220/o:0,placements:Array.from({length:e},(e,t)=>{let i=t%n,o=a/r[i];return{gridColumn:i+1,gridRow:`${Math.floor(t/n)*o+1} / span ${o}`}})}}function ZL({id:e,onClose:t}){let{t:n}=U(`agent`),{active:r,selectConversation:i}=OL(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let t=new AbortController;return o(!1),i(e,{windowRestore:!0,signal:t.signal}).catch(()=>{t.signal.aborted||o(!0)}),()=>t.abort()},[e,s,i]),a?(0,$.jsxs)(`div`,{role:`alert`,className:`flex h-full flex-col items-center justify-center gap-3 p-4 text-sm`,children:[(0,$.jsx)(`p`,{children:n(`split.loadFailed`)}),(0,$.jsx)(`button`,{onClick:()=>c(e=>e+1),children:n(`split.retry`)}),(0,$.jsx)(`button`,{onClick:t,children:n(`split.close`)})]}):r?.id===e?(0,$.jsxs)(fo,{paneId:e,onClose:t,children:[(0,$.jsx)(fR,{splitPane:!0}),(0,$.jsx)(YL,{})]}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-sm`,children:[(0,$.jsx)(`span`,{role:`status`,children:n(`window.loading`)}),(0,$.jsx)(`button`,{onClick:t,children:n(`split.close`)})]})}function QL({children:e}){let{t}=U(`agent`),{conversations:n,active:r}=OL(),i=co(),a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(window.innerWidth),c=i.conversationIds.filter(e=>e!==r?.id),l=c.length+ +!!i.primaryVisible,u=XL(l,o);return(0,Q.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{e.clientWidth&&s(e.clientWidth)},n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[]),(0,Q.useEffect)(()=>{i.focusedId&&Array.from(a.current?.querySelectorAll(`[data-split-id]`)??[]).find(e=>e.dataset.splitId===i.focusedId)?.focus()},[i.focusedId]),(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,ref:a,"data-mission-split-layout":!0,children:(0,$.jsxs)(`div`,{className:`grid min-h-0 flex-1 overflow-auto`,"data-split-count":l,"data-split-columns":u.columns,style:{gridTemplateColumns:`repeat(${u.columns}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${u.rows}, minmax(${u.minimumRowHeight}px, 1fr))`},children:[(0,$.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-col overflow-hidden`,style:{...u.placements[0],display:i.primaryVisible?void 0:`none`},children:(0,$.jsx)(fo,{onClose:c.length?i.closePrimary:null,children:e})},`primary`),c.map((e,r)=>(0,$.jsx)(`section`,{"data-split-id":e,tabIndex:-1,"aria-label":n.find(t=>t.id===e)?.title?.trim()||t(`untitled`),className:`relative min-h-0 min-w-0 overflow-hidden border-l border-t border-border outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary`,style:u.placements[r+ +!!i.primaryVisible],onFocusCapture:()=>i.focus(e),children:(0,$.jsx)(Ni,{children:(0,$.jsx)(uj,{children:(0,$.jsx)(EL,{fixedConversationId:e,children:(0,$.jsx)(ZL,{id:e,onClose:()=>i.close(e)})})})})},e))]})})}var $L=12e-5,eR=36,tR=140,nR=1.5,rR=6;function iR(e,t){return{x:Math.random()*e,y:Math.random()*t,radius:.35+Math.random()*1.25,alpha:.22+Math.random()*.5,drift:nR+Math.random()*(rR-nR)}}function aR(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 oR(){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=aR(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(tR,Math.max(eR,Math.floor(o*s*$L)));a=Array.from({length:e},()=>iR(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 sR=(0,Q.lazy)(()=>c(()=>import(`./AgentModeCodePane-Xczcyghb.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([91,1,7,10,42,54]))),cR=(0,Q.lazy)(()=>c(()=>import(`./AgentModeJobsPane-DtOW01ln.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([92,1,7,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,8,62,54,73,74,76,77,80,93,87,6,44,45,46,47,48,49,50,51,52,53,55,56,57,58,59,60,61,63,64,65,66,67,68,69,70,71,72,75,78,79,81,82,83,84,85,86]))),lR=(0,Q.lazy)(()=>c(()=>import(`./AgentModeAnalyticsPane-yj-YCgrK.js`).then(e=>({default:e.AgentModeAnalyticsPane})),__vite__mapDeps([94,1,7,10,42,62,54,73,74])));function uR(){let e=po(),{t}=U(`agent`);return e?(0,$.jsx)(`button`,{type:`button`,"aria-label":t(`split.close`),title:t(`split.close`),onClick:e,className:`absolute right-2 top-2 rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,$.jsx)(Vn,{className:`h-4 w-4`})}):null}function dR({splitPane:e,children:t}){return e?(0,$.jsx)($.Fragment,{children:t}):(0,$.jsx)(QL,{children:t})}function fR({splitPane:e=!1}={}){let t=mo(),{active:n,refreshConversations:r,builderMode:i}=OL(),{codePaneOpen:a,jobsPaneOpen:o,analyticsPaneOpen:s}=fj(),{activeProjectId:c}=ce(),l=Mi(),u=HS(n?.id??`__new-mission__`),d=!l.current&&l.transfers.some(e=>e.conversationId===n?.id&&e.state===`detached`),f=Pa().id===`galaxy`;(0,Q.useEffect)(()=>{r()},[r]);let p=a&&!!c&&!d,m=o&&!!c&&!d,h=s&&!!c&&!d;return(0,$.jsx)(Kb,{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)(oR,{}),(0,$.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(jS.div,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 z-0`,animate:{opacity:+(n===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%)`}}),(0,$.jsx)(dR,{splitPane:e,children:i.active?(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(jI,{variant:`inline`})}):n===null?(0,$.jsxs)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-4`,children:[(0,$.jsx)(uR,{}),(0,$.jsx)(jS.div,{layoutId:t,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-[960px]`,children:(0,$.jsx)(KN,{autoFocus:!0})})]}):(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(uF,{variant:`inline`})})})]}),m&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,$.jsx)(cR,{projectId:c})}),p&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,$.jsx)(sR,{projectId:c,conversationId:n?.id??`__home__`},`${n?.id}:${u}`)}),h&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[560px] border-l border-border`}),children:(0,$.jsx)(lR,{})})]})})}var pR=`specrails:terminal-settings-updated`;function mR(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(pR,{detail:e}))}function hR(){return new vR(BL(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function gR(){return Y(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new vR(new UL(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var _R=[`tauri://created`,`tauri://error`],vR=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 gR()).find(t=>t.label===e)??null}static getCurrent(){return hR()}static async getAll(){return gR()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:Nr(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)}:Fr(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(_R.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return Pr(e,t)}async emitTo(e,t,n){if(_R.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return Ir(e,t,n)}_handleTauriEvent(e,t){return _R.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 FL(e))}async size(){return Y(`plugin:webview|webview_size`,{label:this.label}).then(e=>new ML(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 NL?e:new NL(e)})}async setPosition(e){return Y(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof IL?e:new IL(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(Lr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new FL(t.payload.position)}})}),n=await this.listen(Lr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new FL(t.payload.position)}})}),r=await this.listen(Lr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new FL(t.payload.position)}})}),i=await this.listen(Lr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function yR(e){return`'${e.replace(/'/g,`'\\''`)}'`}function bR(e){if(/[\x00-\x1f"%!]/.test(e))throw Error(`unsafe-cmd-path`);return`"`+e+`"`}function xR(e){return`'${e.replace(/'/g,`''`)}'`}function SR(e,t,n=`powershell`){return t?n===`cmd`?bR(e):xR(e):yR(e)}function CR(e,t,n=`powershell`){return e.map(e=>SR(e,t,n)).join(` `)}function wR(e){return/(?:^|[\\/])cmd(?:\.exe)?$/i.test(e??``)?`cmd`:`powershell`}async function TR(e){if(!S())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&&DR(s,u.viewportEl.getBoundingClientRect(),window.devicePixelRatio||1))try{u.writeText(CR(o,i,wR(u.shell)))}catch{K.error(N.t(`terminal:errors.pathPasteUnsafe`))}},o=ER((()=>{try{return hR()}catch{return null}})());o&&t.push(await o(a));let s=ER((()=>{try{return BL()}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 ER(e){let t=e?.onDragDropEvent;return typeof t==`function`?t.bind(e):null}function DR(e,t,n){let r=Number.isFinite(n)&&n>0?n:1;return OR(e.x/r,e.y/r,t)}function OR(e,t,n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function kR({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 AR({x:e,y:t,providers:n,onSelect:r,onClose:i}){let{t:a}=U(`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:sn(e)})},e))})}var jR=(0,Q.forwardRef)(function({isOpen:e,className:t,...n},r){let{t:i}=U(`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 MR({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}=U(`terminal`),g=!!i&&i.length>1,_=sn(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)(NR,{label:y,disabled:!t,onClick:e=>o(e?{x:e.clientX,y:e.clientY}:void 0),children:(0,$.jsx)(Ln,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{label:h(`topBar.openInBrowser`),onClick:s,onContextMenu:e=>{e.preventDefault(),u({x:e.clientX,y:e.clientY})},children:(0,$.jsx)(ge,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{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)(_c,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{label:t?h(`topBar.newTerminal`):v,disabled:!t,onClick:a,children:(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{label:h(`topBar.killActive`),disabled:!n,onClick:f,children:(0,$.jsx)(Rn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{label:h(e===`maximized`?`topBar.restorePanel`:`topBar.maximizePanel`),onClick:p,children:e===`maximized`?(0,$.jsx)(Yl,{className:`h-3.5 w-3.5`}):(0,$.jsx)(ql,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(jR,{isOpen:!0,onClick:m})]})]})}function NR({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 PR({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)(FR,{session:e,active:e.id===t,onActivate:()=>n(e.id),onRename:t=>r(e.id,t),onKill:()=>i(e.id)},e.id))})})}function FR({session:e,active:t,onActivate:n,onRename:r,onKill:i}){let{t:a}=U(`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)(xd,{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)(jn,{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)(Vn,{className:`h-3 w-3`})})]})})}function IR({search:e,onClose:t}){let{t:n}=U(`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)(Sn,{size:14})}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.next`),onClick:h,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(rc,{size:14})}),(0,$.jsx)(LR,{label:`Aa`,title:n(`search.matchCase`),active:o,onToggle:()=>s(e=>!e)}),(0,$.jsx)(LR,{label:`.*`,title:n(`search.regex`),active:c,onToggle:()=>l(e=>!e)}),(0,$.jsx)(LR,{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)(Vn,{size:14})})]})}function LR({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 RR({x:e,y:t,term:n,cwd:r,hasReveal:i,onClose:a,onOpenSearch:o,onReveal:s,onSaveScrollback:c}){let{t:l}=U(`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&&(Ba(m),a())}function _(){za().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)(zR,{onClick:g,disabled:!h,label:l(`common:actions.copy`),shortcut:p+`C`}),(0,$.jsx)(zR,{onClick:_,label:l(`contextMenu.paste`),shortcut:p+`V`}),(0,$.jsx)(zR,{onClick:v,label:l(`contextMenu.selectAll`),shortcut:p+`A`}),(0,$.jsx)(BR,{}),(0,$.jsx)(zR,{onClick:y,label:l(`contextMenu.clear`),shortcut:p+`K`}),(0,$.jsx)(zR,{onClick:b,label:l(`contextMenu.search`),shortcut:p+`F`}),(0,$.jsx)(zR,{onClick:x,label:l(`contextMenu.saveScrollback`)}),r&&i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(BR,{}),(0,$.jsx)(zR,{onClick:S,label:l(`contextMenu.openPath`,{path:VR(r,40)})})]})]})}function zR({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 BR(){return(0,$.jsx)(`div`,{className:`my-1 border-t border-[#44475a]`})}function VR(e,t){return e.length<=t?e:`…`+e.slice(e.length-t+1)}async function HR(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(`
|
|
48
|
+
`))}function AP(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 jP(){let e=po(),{t}=U(`agent`),{active:n,messages:r,renameConversation:i,deleteConversation:a,startNewConversation:o,favoriteConversationIds:s,toggleFavoriteConversation:c}=OL(),{projects:l}=ce(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=n?.pinned_project_id?l.find(e=>e.id===n.pinned_project_id)??null:null,C=n?.title?.trim()||t(`header.untitled`),w=n?s.has(n.id):!1;(0,Q.useEffect)(()=>{if(!u)return;let e=e=>{b.current&&!b.current.contains(e.target)&&d(!1)},t=e=>{e.key===`Escape`&&d(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[u]),(0,Q.useEffect)(()=>{u||y(!1)},[u]),(0,Q.useEffect)(()=>{f&&(x.current?.focus(),x.current?.select())},[f]);let T=(0,Q.useCallback)(()=>{h(n?.title??``),p(!0),d(!1)},[n?.title]),E=(0,Q.useCallback)(async()=>{if(n&&(p(!1),(n.title??``)!==m.trim()))try{await i(n.id,m)}catch{K.error(t(`header.renameFailed`))}},[n,m,i,t]),D=(0,Q.useCallback)(async(e,n)=>{d(!1);try{await navigator.clipboard.writeText(e),_(n),setTimeout(()=>_(e=>e===n?null:e),1400)}catch{K.error(t(`header.copyFailed`))}},[t]),O=(0,Q.useCallback)(async()=>{if(n){d(!1);try{await navigator.clipboard.writeText(kP(n,r,S)),_(`transcript`),K.success(t(`header.copyTranscriptSuccess`,{defaultValue:`Transcript copied`})),setTimeout(()=>_(e=>e===`transcript`?null:e),1400)}catch{K.error(t(`header.copyTranscriptFailed`,{defaultValue:`Could not copy transcript`}))}}},[n,r,S,t]),k=(0,Q.useCallback)(()=>{if(n){d(!1);try{let e=kP(n,r,S),i=new Blob([e],{type:`text/plain;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=AP(n.title,n.id),document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),K.success(t(`header.exportTranscriptSuccess`,{defaultValue:`Transcript export started`}))}catch{K.error(t(`header.exportTranscriptFailed`,{defaultValue:`Could not export transcript`}))}}},[n,r,S,t]),A=(0,Q.useCallback)(async()=>{if(n){d(!1),y(!1);try{if(await a(n.id),e){e();return}o(n.pinned_project_id)}catch{K.error(t(`header.deleteFailed`))}}},[n,e,a,o,t]),j=(0,Q.useCallback)(()=>{n&&(c(n.id),d(!1))},[n,c]);if(!n)return null;let M=[{id:`name`,label:t(`header.copyName`),value:n.title??C},{id:`id`,label:t(`header.copyId`),value:n.id},...S?[{id:`project`,label:t(`header.copyProject`),value:S.name},{id:`path`,label:t(`header.copyProjectPath`),value:S.path}]:[]];return(0,$.jsxs)(`div`,{ref:b,"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:[S&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`max-w-[42%] shrink-0 truncate font-mono text-[12px] text-foreground/35`,title:S.path,children:S.path}),(0,$.jsx)(Cn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/25`,"aria-hidden":!0})]}),f?(0,$.jsx)(`input`,{ref:x,value:m,onChange:e=>h(e.target.value),onBlur:()=>void E(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),E()):e.key===`Escape`&&(e.preventDefault(),p(!1))},placeholder:t(`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:T,title:t(`header.renameHint`),className:`min-w-0 flex-1 truncate text-left font-medium text-foreground/85`,children:C})]}),(0,$.jsx)(Id,{}),e&&(0,$.jsx)(`button`,{type:`button`,onClick:e,title:t(`split.close`),"aria-label":t(`split.close`),className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,$.jsx)(Vn,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`agent-conv-menu-trigger`,"aria-label":t(`header.menu`),"aria-haspopup":`menu`,"aria-expanded":u,onClick:()=>d(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`,u&&`bg-surface text-foreground/80`),children:(0,$.jsx)(Uc,{className:`h-4 w-4`})}),(0,$.jsx)(jb,{children:u&&(0,$.jsx)(jS.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:v?(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:t(`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 A(),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:t(`header.delete`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>y(!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:t(`common:actions.cancel`)})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-rename`,onClick:T,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)(jn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`}),t(`header.rename`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-favorite`,onClick:j,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)(Cl,{className:X(`h-3.5 w-3.5 shrink-0`,w?`text-accent-primary`:`text-foreground/50`),fill:w?`currentColor`:`none`}),t(w?`header.removeFavorite`:`header.addFavorite`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-delete`,onClick:()=>y(!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)(Rn,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50 group-hover/del:text-destructive`}),t(`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 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:[g===`transcript`?(0,$.jsx)(xn,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(kc,{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:t(`header.copyTranscript`,{defaultValue:`Copy transcript`})})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-export-transcript`,onClick:k,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)(En,{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:t(`header.exportTranscript`,{defaultValue:`Export transcript (.txt)`})})]}),M.map(e=>e===`divider`?null:(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-conv-copy-${e.id}`,onClick:()=>void D(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:[g===e.id?(0,$.jsx)(xn,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`}):(0,$.jsx)(kc,{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 MP=new Set([`building`,`on_review`,`pr_draft`,`no_changes`,`pr_closed`,`implementation_failed`,`pr_failed`]);function NP(e){return MP.has(e)}function PP(e){return!!(NP(e.decision)||e.phase===`launched`||e.phase===`running`||e.runtime?.failure&&e.decision!==`discarded`&&e.decision!==`superseded`)}function FP(e){let t=[];for(let[n,r]of e.entries()){if(r.role!==`system`)continue;let e=qo(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=Ct(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=Ct(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))Ct(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),PP(e.envelope)&&u.push(e)}return{byMessageId:c,duplicateMessageIds:l,pinned:u}}function IP({row:e}){let{t}=U(`agent`);return(0,$.jsxs)(`div`,{"data-testid":`agent-run-failure-marker`,className:`flex items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/[0.06] px-3 py-1.5 text-[11px] text-foreground/70 backdrop-blur-sm`,children:[(0,$.jsx)(zn,{className:`h-3.5 w-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-medium text-destructive`,children:t(`runFailure.marker`,{rail:e.railIndex+1,code:e.code})}),e.detail&&(0,$.jsxs)(`span`,{className:`text-foreground/55`,children:[` · `,e.detail]})]}),(0,$.jsx)(`button`,{type:`button`,"data-agent-interactive":!0,"data-testid":`agent-run-failure-open`,onClick:()=>aj({prDeliveryId:e.prDeliveryId??null,runIds:[e.runId]}),className:`shrink-0 rounded-md border border-destructive/35 px-2 py-0.5 text-[10px] font-medium text-destructive transition-colors hover:bg-destructive/10`,children:t(`runFailure.openCard`)})]})}function LP({content:e,contextRefs:t}){let{t:n}=U(`agent`),[r,i]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{"data-testid":`agent-system-briefing`,className:`flex flex-col items-end gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,"data-agent-interactive":!0,onClick:()=>i(e=>!e),"aria-expanded":r,className:X(`inline-flex items-center gap-1.5 rounded-full border border-border/50 bg-surface/50 px-2.5 py-1 text-[11px] text-foreground/60 transition-colors hover:border-accent-primary/40 hover:text-foreground/80`),children:[(0,$.jsx)(Ln,{className:`h-3 w-3 text-accent-primary/70`,"aria-hidden":!0}),n(`runFailure.briefing.title`),r?(0,$.jsx)(rc,{className:`h-3 w-3 opacity-60`,"aria-hidden":!0}):(0,$.jsx)(Cn,{className:`h-3 w-3 opacity-60`,"aria-hidden":!0})]}),r&&(0,$.jsx)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl rounded-tr-sm border border-border/40 bg-surface/40 px-3.5 py-2 text-xs text-foreground/70`,"data-testid":`agent-system-briefing-body`,children:(0,$.jsx)($A,{content:e,contextRefs:t})})]})}var RP={pinnedMessageIds:new Set,pinned:[]};function zP(e){let t=Vw();return(0,Q.useMemo)(()=>{if(!Xe)return RP;let n=[],r=new Set;for(let i of e){if(i.role!==`assistant`||!i.content.includes("```rail-launch"))continue;let{proposals:e}=Iw(i.content,!1);e.forEach((e,a)=>{Hw(t,i.id,i.intents,a)||(n.push({messageId:i.id,proposalIndex:a,proposal:e}),r.add(i.id))})}return{pinnedMessageIds:r,pinned:n}},[e,t])}function BP(e){return e.replace(/```[^\n]*\n([\s\S]*?)```/g,`$1`).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/^\s{0,3}>\s?/gm,``).replace(/^\s*(?:[-*+]|\d{1,3}[.)])\s+/gm,``).replace(/(\*\*|__)(.+?)\1/g,`$2`).replace(/(^|[^\w*])\*(?!\s)([^*\n]+?)\*(?!\w)/g,`$1$2`).replace(/(^|[^\w_])_(?!\s)([^_\n]+?)_(?!\w)/g,`$1$2`).replace(/~~(.+?)~~/g,`$1`).replace(/`([^`\n]+)`/g,`$1`).replace(/^\s*(?:-{3,}|\*{3,}|_{3,})\s*$/gm,``).replace(/\s+/g,` `).trim()}function VP(e){let[t,n]=(0,Q.useState)(()=>Date.now()),r=ds(e);(0,Q.useEffect)(()=>{if(!r)return;let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[r]);let i=e.endedAt?Date.parse(e.endedAt):t;return jr(Math.max(0,i-Date.parse(e.startedAt)))}function HP({node:e}){return ds(e)?(0,$.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60 motion-safe:animate-ping`}),(0,$.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full bg-accent-primary`})]}):e.phase===`idle`?(0,$.jsx)(sc,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-hidden":!0}):e.phase===`failed`?(0,$.jsx)(ac,{className:`h-3.5 w-3.5 shrink-0 text-destructive`,"aria-hidden":!0}):(0,$.jsx)(dc,{className:`h-3.5 w-3.5 shrink-0 text-foreground/45`,"aria-hidden":!0})}function UP(e){return e&&e.length>0?e[e.length-1].seq:0}function WP(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function GP({conversationId:e,node:t,liveEvents:n}){let{t:r}=U(`agent`),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let n=!1;return Co(e,t.subagentId,0,500).then(e=>{n||(a(e.events),s(e.hasMore))}).catch(()=>{n||l(!0)}),()=>{n=!0}},[e,t.subagentId]);let u=()=>{let n=UP(i);Co(e,t.subagentId,n,500).then(e=>{a(t=>[...t??[],...e.events]),s(e.hasMore)})},d=(0,Q.useMemo)(()=>{let e=new Set((i??[]).map(e=>e.seq)),t=UP(i);return[...i??[],...n.filter(n=>!e.has(n.seq)&&!o&&n.seq>t)]},[i,n,o]);return c?(0,$.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-destructive`,children:r(`subagents.activityFailed`)}):i?d.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-[11px] text-foreground/50`,children:r(`subagents.noActivity`)}):(0,$.jsxs)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto px-3 py-2 font-mono text-[11px] leading-relaxed`,"data-testid":`agent-subagent-activity`,children:[d.map(e=>e.channel===`tool`&&e.tool?(0,$.jsxs)(`div`,{className:X(`flex items-start gap-1.5 text-foreground/55`,e.tool.isError&&`text-destructive`),children:[(0,$.jsx)(xd,{className:`mt-0.5 h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:e.tool.name}),e.tool.phase===`completed`&&e.tool.output?(0,$.jsxs)(`span`,{className:`text-foreground/40`,children:[` → `,e.tool.output.slice(0,300)]}):null]})]},e.seq):(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words font-sans text-foreground/75`,children:e.delta},e.seq)),o&&(0,$.jsx)(`button`,{type:`button`,onClick:u,className:`text-[11px] font-sans text-accent-primary hover:underline`,children:r(`subagents.moreActivity`)})]}):(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 px-3 py-2 text-[11px] text-foreground/50`,children:[(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),r(`subagents.loadingActivity`)]})}function KP({conversationId:e,node:t,liveEvents:n,depth:r,onStop:i,onRelaunch:a}){let{t:o}=U(`agent`),s=AS(),[c,l]=(0,Q.useState)(!1),u=VP(t),d=ds(t),f=t.agentType===`shell`,p=o(`subagents.phase.${t.phase}`),m=t.reason?o(`subagents.reason.${t.reason}`,{defaultValue:t.reason}):null,h=t.usage?.totalTokens??((t.usage?.inputTokens??0)+(t.usage?.outputTokens??0)||null);return(0,$.jsxs)(`li`,{className:X(`border-t border-border/20 first:border-t-0`,r>0&&`bg-background/30`),"data-testid":`agent-subagent-row`,"data-phase":t.phase,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,style:r>0?{paddingLeft:`${.625+r*1.1}rem`}:void 0,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"aria-label":c?o(`subagents.collapse`):o(`subagents.expand`,{name:t.description}),title:t.resultSummary&&!c?BP(t.resultSummary).slice(0,280):void 0,className:`flex min-w-0 flex-1 items-center gap-2 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(Cn,{className:X(`h-3.5 w-3.5 shrink-0 text-foreground/40 transition-transform`,c&&`rotate-90`),"aria-hidden":!0}),(0,$.jsx)(HP,{node:t}),f?(0,$.jsx)(xd,{className:`h-3.5 w-3.5 shrink-0 text-foreground/45`,"aria-hidden":!0}):(0,$.jsx)(zs,{className:`h-3.5 w-3.5 shrink-0 text-foreground/45`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:X(`min-w-0 flex-1 truncate text-[12.5px]`,d?`text-foreground`:`text-foreground/75`),children:t.description}),(0,$.jsxs)(`span`,{className:`sr-only`,children:[p,m?` — ${m}`:``]}),t.delegated?(0,$.jsxs)(`span`,{className:`shrink-0 rounded-full border border-accent-primary/30 bg-accent-primary/[0.06] px-1.5 py-0.5 text-[10px] text-accent-primary/80`,title:o(`subagents.delegatedHint`,{provider:sn(t.delegated.driver),model:t.delegated.model}),"data-testid":`agent-subagent-delegated`,children:[sn(t.delegated.driver),` · `,t.delegated.model]}):t.agentType&&!f&&(0,$.jsx)(`span`,{className:`hidden shrink-0 rounded-full border border-border/50 px-1.5 py-0.5 text-[10px] text-foreground/50 sm:inline`,children:t.agentType}),(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[10.5px] tabular-nums text-foreground/45`,"aria-label":o(`subagents.elapsedAria`,{elapsed:u}),children:u})]}),d&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":o(`subagents.stopOne`,{name:t.description}),title:o(`subagents.stop`),className:`shrink-0 rounded p-1 text-foreground/40 transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,children:(0,$.jsx)(Nn,{className:`h-3 w-3`,"aria-hidden":!0})}),fs(t)&&!f&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(t),title:o(`subagents.relaunchHint`),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-border/50 px-1.5 py-0.5 text-[10.5px] text-foreground/60 transition-colors hover:border-accent-primary/50 hover:text-accent-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:[(0,$.jsx)(Fn,{className:`h-3 w-3`,"aria-hidden":!0}),o(`subagents.relaunch`)]})]}),(0,$.jsx)(jb,{initial:!1,children:c&&(0,$.jsxs)(jS.div,{initial:!s&&{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:s?{opacity:0}:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden border-t border-border/20 bg-background/40`,children:[(m||h!==null)&&(0,$.jsx)(`p`,{className:`border-b border-border/20 px-3 py-1.5 font-mono text-[10.5px] text-foreground/45`,"data-testid":`agent-subagent-meta`,children:[m&&`${p} · ${m}`,!d&&h!==null&&o(`subagents.tokens`,{tokens:WP(h)}),!d&&t.toolUses?o(`subagents.toolUses`,{count:t.toolUses}):null,!d&&t.usage?.costUsd!=null?`${t.usage.costEstimated?`≈ `:``}$${t.usage.costUsd.toFixed(2)}`:null].filter(Boolean).join(` · `)}),t.resultSummary&&(0,$.jsxs)(`section`,{className:`border-b border-border/20 px-3 py-2.5`,"aria-label":o(`subagents.result`),"data-testid":`agent-subagent-result`,children:[(0,$.jsx)(`p`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-widest text-foreground/40`,children:o(`subagents.result`)}),(0,$.jsx)(JP,{text:t.resultSummary})]}),(0,$.jsx)(GP,{conversationId:e,node:t,liveEvents:n})]})})]})}var qP={a:({href:e,children:t})=>(0,$.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-accent-primary underline decoration-accent-primary/40 underline-offset-2 hover:decoration-accent-primary`,children:t}),img:()=>null,code:({className:e,children:t})=>e?(0,$.jsx)(`code`,{className:e,children:t}):(0,$.jsx)(`code`,{className:`rounded border border-border/50 bg-background-deep/60 px-1 py-px font-mono text-[0.9em] text-accent-info`,children:t})};function JP({text:e}){return(0,$.jsx)(`div`,{className:X(`prose prose-invert prose-sm max-w-none text-[12px] leading-relaxed text-foreground/80`,`prose-p:my-1 prose-headings:mb-1 prose-headings:mt-2 prose-headings:text-[12.5px] prose-headings:font-semibold`,`prose-strong:text-foreground prose-ul:my-1 prose-ol:my-1 prose-li:my-0.5 prose-li:marker:text-accent-primary/70`,`prose-pre:my-1.5 prose-pre:rounded-md prose-pre:border prose-pre:border-border/50 prose-pre:bg-background-deep/60 prose-pre:text-[11px]`),children:(0,$.jsx)(Cr,{remarkPlugins:[wr],skipHtml:!0,components:qP,children:e})})}function YP(e){let t=new Map,n=new Set(e.map(e=>e.subagentId));for(let r of e){let e=r.parentId&&n.has(r.parentId)?r.parentId:null;t.set(e,[...t.get(e)??[],r])}let r=[],i=(e,n)=>{for(let a of t.get(e)??[])r.push({node:a,depth:n}),i(a.subagentId,n+1)};return i(null,0),r}function XP(e,t){let n=Math.min(...e.map(e=>Date.parse(e.startedAt))),r=e.some(ds)?t:Math.max(...e.map(e=>e.endedAt?Date.parse(e.endedAt):Date.parse(e.startedAt)));return Math.max(0,r-n)}function ZP(e){return e.usage?.totalTokens??((e.usage?.inputTokens??0)+(e.usage?.outputTokens??0)||null)}function QP({conversationId:e,subagents:t,liveEvents:n,onStop:r,onRelaunch:i}){let{t:a}=U(`agent`),o=AS(),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(()=>Date.now()),p=t.filter(ds).length;if((0,Q.useEffect)(()=>{if(p===0)return;let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[p]),t.length===0)return null;let m=t.filter(e=>e.phase===`idle`).length,h=t.length-p-m,g=l??p>0,_=jr(XP(t,d)),v=p===0?t.reduce((e,t)=>e+(ZP(t)??0),0):0,y=p>0?[a(`subagents.working`,{count:p}),m>0&&a(`subagents.done`,{count:m}),h>0&&a(`subagents.ended`,{count:h})].filter(Boolean).join(` · `):[a(`subagents.finishedIn`,{elapsed:_}),h>0&&a(`subagents.ended`,{count:h}),v>0&&a(`subagents.tokens`,{tokens:WP(v)})].filter(Boolean).join(` · `),b=async e=>{c(!1);try{await r(e)}catch{c(!0)}};return(0,$.jsxs)(jS.section,{initial:!o&&{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:`easeOut`},"data-testid":`agent-subagents-card`,"data-open":g,"aria-label":a(`subagents.title`),className:`my-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(!g),"aria-expanded":g,"data-testid":`agent-subagents-summary`,className:X(`inline-flex min-w-0 max-w-full items-center gap-2 rounded-full border px-3 py-1 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,p>0?`border-accent-primary/40 bg-accent-primary/[0.07] text-foreground/85`:`border-border/50 bg-surface/60 text-foreground/70 hover:border-border hover:text-foreground/85`),children:[p>0?(0,$.jsx)(An,{className:`h-3 w-3 shrink-0 animate-spin text-accent-primary motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(zs,{className:`h-3 w-3 shrink-0 text-foreground/50`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`shrink-0 font-medium`,children:a(`subagents.count`,{count:t.length})}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-foreground/55`,"aria-live":`polite`,children:y}),p>0&&(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[10.5px] tabular-nums text-foreground/45`,children:_}),(0,$.jsx)(Cn,{className:X(`h-3 w-3 shrink-0 text-foreground/40 transition-transform motion-reduce:transition-none`,g&&`rotate-90`),"aria-hidden":!0})]}),p>1&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`shrink-0 rounded-full px-2 py-1 text-[10.5px] text-foreground/45 transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,children:a(`subagents.stopAll`)})]}),s&&(0,$.jsx)(`p`,{role:`alert`,className:`mt-1 px-1 text-[11px] text-destructive`,children:a(`subagents.stopFailed`)}),(0,$.jsx)(jb,{initial:!1,children:g&&(0,$.jsx)(jS.ul,{initial:!o&&{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:o?{opacity:0}:{height:0,opacity:0},transition:{duration:.18,ease:`easeOut`},className:`ml-3 mt-1 overflow-hidden rounded-lg border border-border/40 bg-card/50`,"data-testid":`agent-subagents-list`,children:YP(t).map(({node:t,depth:r})=>(0,$.jsx)(KP,{conversationId:e,node:t,liveEvents:n[t.subagentId]??[],depth:r,onStop:e=>void b([e.subagentId]),onRelaunch:i},t.subagentId))})})]})}function $P({turn:e}){let{t}=U(`agent`);return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-testid":`agent-background-turn`,children:[(0,$.jsx)(eF,{origin:e.origin}),e.text?(0,$.jsx)(ej,{role:`assistant`,content:e.text,streaming:!0}):(0,$.jsx)(`p`,{className:`title-shimmer px-1 text-[12px] text-foreground/55`,children:t(`subagents.backgroundTurn`)})]})}function eF({origin:e}){let{t}=U(`agent`);return(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 px-1 text-[10.5px] uppercase tracking-wide text-foreground/40`,"data-testid":`agent-turn-origin`,children:[(0,$.jsx)(zs,{className:`h-3 w-3`,"aria-hidden":!0}),t(e===`system`?`subagents.continuationSystem`:`subagents.continuation`)]})}function tF({onApplyNow:e}){let{t}=U(`agent`),[n,r]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{role:`status`,"data-testid":`agent-deferred-change`,className:`flex items-center gap-2 rounded-lg border border-accent-highlight/30 bg-accent-highlight/[0.07] px-3 py-1.5 text-[11.5px] text-foreground/70`,children:[(0,$.jsx)(td,{className:`h-3.5 w-3.5 shrink-0 text-accent-highlight`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:t(`subagents.deferred`)}),(0,$.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(!0),e().finally(()=>r(!1))},className:`shrink-0 rounded-md border border-border/50 px-2 py-0.5 text-[11px] text-foreground/70 transition-colors hover:border-destructive/50 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive disabled:opacity-50`,children:t(`subagents.applyNow`)})]})}var nF=new Set([`host_degraded`,`journal_locked`]),rF=new Set([...nF,`policy.subagent_blocked`,`subagents.delegation_unsupported`,`subagents.driver_unavailable`]);function iF({notices:e,onDismiss:t}){let{t:n}=U(`agent`),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(null);if(e.length===0)return null;let s=async e=>{if(e.scope){i(e.id),o(null);try{let{host:n}=await To(e.scope);n.status===`ready`?t(e.id):o(e.id)}catch{o(e.id)}finally{i(null)}}};return(0,$.jsx)(`div`,{className:`space-y-1.5`,"data-testid":`agent-session-notices`,children:e.map(e=>{let i=rF.has(e.code),o=nF.has(e.code),c=e.level!==`info`;return(0,$.jsxs)(`div`,{role:c?`alert`:`status`,"data-code":e.code,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-[11.5px] ${c?`border-accent-highlight/35 bg-accent-highlight/[0.07] text-foreground/75`:`border-border/40 bg-surface/40 text-foreground/65`}`,children:[c?(0,$.jsx)(zn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-highlight`,"aria-hidden":!0}):(0,$.jsx)(kl,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground/45`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,$.jsx)(`p`,{children:i?n(`sessionNotice.${e.code}`,{provider:sn(e.provider)}):e.message}),a===e.id&&(0,$.jsx)(`p`,{className:`text-destructive`,children:n(`sessionNotice.retryFailed`)})]}),o&&e.scope&&(0,$.jsxs)(`button`,{type:`button`,disabled:r===e.id,onClick:()=>void s(e),className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-border/50 px-2 py-0.5 text-[11px] text-foreground/70 transition-colors hover:border-accent-primary/50 hover:text-accent-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary disabled:opacity-50`,children:[r===e.id?(0,$.jsx)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Fn,{className:`h-3 w-3`,"aria-hidden":!0}),n(`sessionNotice.retry`)]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":n(`sessionNotice.dismiss`),title:n(`sessionNotice.dismiss`),className:`shrink-0 rounded p-0.5 text-foreground/40 transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary`,children:(0,$.jsx)(Vn,{className:`h-3 w-3`,"aria-hidden":!0})})]},e.id)})})}var aF=(0,Q.lazy)(()=>c(()=>import(`./JobDetailModal-CkAejD1F.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,77,78,79,80,81,82,83,84,85,86,87]))),oF=(0,Q.lazy)(()=>c(()=>import(`./LoopPreviewModal-4obS_Ptg.js`).then(e=>({default:e.LoopPreviewModal})),__vite__mapDeps([88,1,7,8,45,10,42,63,64,73,74,78,72,54,89,58,60]))),sF=new Set,cF=new Set([`spec-framing.committed`]);function lF(e){if(!e.startsWith(`{`))return!1;try{let t=JSON.parse(e);return typeof t?.kind==`string`&&cF.has(t.kind)}catch{return!1}}function uF({variant:e}){let{t}=U(`agent`),{active:n}=OL(),r=Mi(),i=HS(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)(jP,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,$.jsx)(Dn,{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)(dF,{variant:e},`${n?.id??`__new-mission__`}:${i}`)})}function dF({variant:e}){let t=mo(),{t:n}=U(`agent`),{active:r,messages:i,streamingText:a,isStreaming:o,liveTools:s,turnTools:c,queuedMessages:l,mcpEnabled:u,enablingMcp:d,enableMcpServer:f,providersReady:p,cycleTier:m,send:h}=OL(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(),b=s.length>0?s:c,x=(0,Q.useRef)(null),S=XS(a,o),{openRef:C,jobRef:w,closeJobRef:T,loopRef:E,closeLoopRef:D}=IC(),O=r?.pinned_project_id??null,[k,A]=(0,Q.useState)(new Map),j=(0,Q.useMemo)(()=>{let e=new Set;for(let t of i)for(let n of t.attachment_ids??[])e.add(n);for(let t of l)for(let n of t.attachmentIds??[])e.add(n);return[...e].sort()},[i,l]).join(`\0`);(0,Q.useEffect)(()=>{let e=j?j.split(`\0`):[];if(!r?.id||e.length===0){A(new Map);return}let t=!1,n=new Set(e);return No(r.id).then(e=>{t||A(new Map(e.filter(e=>n.has(e.id)).map(e=>[e.id,e])))}).catch(()=>{t||A(new Map)}),()=>{t=!0}},[r?.id,j]);let M=(0,Q.useMemo)(()=>O?e=>{C(O,e)}:void 0,[O,C]),N=Pa().id===`code-rain`?n(`emptyTitleCodeRain`):n(`emptyTitle`),P=(0,Q.useMemo)(()=>FP(i),[i]),F=zP(i),I=xs(r?.id),{stopSubagents:ee,dismissNotice:te}=bs(),L=(0,Q.useMemo)(()=>new Set(i.map(e=>e.core_turn_id).filter(e=>!!e)),[i]),R=(0,Q.useMemo)(()=>ms(us(I,L),i.filter(e=>e.role!==`system`&&!(Xe&&rj(e))),o),[I,L,i,o]),z=R.live,B=async e=>{r&&await ee(r.id,e)},ne=e=>{r&&oi(r.id,n(`subagents.relaunchDraft`,{description:e.description}),[])},V=(e,t)=>r&&e.length>0?(0,$.jsx)(QP,{conversationId:r.id,subagents:e,liveEvents:I?.liveEvents??{},onStop:B,onRelaunch:ne},t):null,re=r?BS(r.id):null,ie=(0,Q.useRef)(re?.atBottom??!0);(0,Q.useLayoutEffect)(()=>{let e=x.current;return e&&re&&(e.scrollTop=re.atBottom?e.scrollHeight:re.top),()=>{e&&r&&zS(r.id,{top:e.scrollTop,atBottom:ie.current})}},[r?.id]);let ae=()=>{let e=x.current;e&&(ie.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,r&&zS(r.id,{top:e.scrollTop,atBottom:ie.current}))};(0,Q.useEffect)(()=>{ie.current&&x.current?.scrollTo?.({top:x.current.scrollHeight,behavior:`auto`})},[i.length,S,s.length,l.length]);let H=e=>{e.shiftKey&&(e.key===`Tab`||e.code===`Tab`)&&(e.preventDefault(),e.stopPropagation(),m())},W=e===`inline`,G=W?`mx-auto flex w-full max-w-[1040px] min-h-0 flex-1 flex-col overflow-hidden`:`flex min-h-0 flex-1 flex-col overflow-hidden`;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden `,onKeyDown:H,children:[p===!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)(ru,{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:n(`noProvider.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-foreground/70`,children:n(`noProvider.body`)})]})]}),p!==!1&&!u&&(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)(fe,{className:`h-4 w-4 shrink-0 text-accent-warning`}),(0,$.jsx)(`span`,{className:`flex-1`,children:n(`degraded.body`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void f(),disabled:d,className:`rounded-md bg-accent-primary px-2 py-1 text-xs font-medium text-white disabled:opacity-60`,children:n(d?`degraded.enabling`:`degraded.enable`)})]}),W&&r&&(0,$.jsx)(jP,{}),(0,$.jsxs)(`div`,{className:G,children:[(0,$.jsxs)(jS.div,{ref:x,onScroll:ae,initial:W?{opacity:0,y:8}:!1,animate:{opacity:1,y:0},transition:{duration:.35,ease:`easeOut`},className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[i.length===0&&!o&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center text-foreground/50`,children:[(0,$.jsx)(zs,{className:`mb-2 h-8 w-8 text-accent-primary/60`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-foreground/70`,children:N}),(0,$.jsx)(`p`,{className:`mt-1 max-w-[280px] text-xs`,children:n(`emptyHint`)})]}),i.map((e,t)=>{if(e.role===`system`){if(lF(e.content))return null;if(Xe){let t=nj(e.content);if(t)return(0,$.jsx)(IP,{row:t},e.id)}let t=P.byMessageId.get(e.id);return t?PP(t)?(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)(xu,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n(`prCard.pinned.marker`)}),(0,$.jsx)(yP,{decision:t.decision})]},e.id):(0,$.jsx)(_P,{envelope:t,conversationId:e.conversation_id},e.id):(P.duplicateMessageIds.has(e.id)||sF.has(e.id)||(sF.add(e.id),console.warn(`[agent-chat] skipping unrenderable system message ${e.id}`)),null)}if(Xe&&rj(e))return(0,$.jsx)(LP,{content:e.content,contextRefs:e.context_refs},e.id);let a=F.pinnedMessageIds.has(e.id),s=e.role===`assistant`?ls(I,e.core_turn_id):[],c=e.role===`assistant`&&(e.turn_origin===`subagent`||e.turn_origin===`system`)?e.turn_origin:null;return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[c&&(0,$.jsx)(eF,{origin:c}),(0,$.jsx)(ej,{role:e.role,content:e.content,messageId:e.id,intents:e.intents??null,railProposalsPinned:a,tolerantFences:nn(r?.provider),createdAt:e.created_at,isLast:!o&&t===i.length-1,isLatest:t===i.length-1,isStreaming:o,onPickOption:e=>void h(e),refsProjectId:O,onOpenRef:M,contextRefs:e.context_refs,deliveryStatus:e.delivery_status,deliveryReceipt:e.delivery_receipt,conversationId:e.conversation_id,attachments:(e.attachment_ids??[]).map(e=>k.get(e)).filter(e=>!!e)}),a&&(0,$.jsxs)(`div`,{"data-testid":`agent-rail-launch-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)(xu,{className:`h-3 w-3 shrink-0 text-accent-primary/50`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n(`railCard.pinnedMarker`)})]}),V(s,`subagents:${e.id}`),(R.afterMessage.get(e.id)??[]).map((t,n)=>V(t,`subagents:${e.id}:${n}`))]},e.id)}),o&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[S&&(0,$.jsx)(ej,{role:`assistant`,content:S,streaming:!0,tolerantFences:nn(r?.provider)}),(0,$.jsx)(zC,{tool:s.length?s[s.length-1].tool:null,agentDescription:[...z].reverse().find(e=>e.phase===`running`)?.description??null,onClick:()=>_(!0)})]}),V(z,`subagents:live`),I?.backgroundTurn&&!o&&(0,$.jsx)($P,{turn:I.backgroundTurn}),r&&I&&I.notices.length>0&&(0,$.jsx)(iF,{notices:I.notices,onDismiss:e=>te(r.id,e)}),I?.deferredChanges&&(0,$.jsx)(tF,{onApplyNow:()=>B()}),l.length>0&&(0,$.jsx)(`div`,{className:`space-y-2`,"data-testid":`agent-queued-messages`,children:l.map(e=>(0,$.jsx)(tj,{item:e,conversationId:r?.id,onEdit:e=>{r&&y(t=>({conversationId:r.id,queueId:e,revision:(t?.revision??0)+1}))},attachments:(e.attachmentIds??[]).map(e=>k.get(e)).filter(e=>!!e)},`${r?.id}:${e.queueId}`))})]}),(0,$.jsx)(jb,{initial:!1,children:r&&(P.pinned.length>0||F.pinned.length>0)&&(0,$.jsx)(DP,{pinned:P.pinned,proposals:F.pinned,projectId:O,conversationId:r.id,inline:W},`agent-pr-pinned-dock`)}),W?(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsx)(jS.div,{layoutId:t,transition:{layout:{type:`spring`,stiffness:350,damping:34}},className:`relative mx-auto w-full max-w-[960px]`,"data-testid":`agent-composer-dock`,children:(0,$.jsx)(KN,{queueEditRequest:v})})}):(0,$.jsx)(`div`,{className:`relative shrink-0 border-t border-border/50 bg-surface/30 p-3`,"data-testid":`agent-composer-dock`,children:(0,$.jsx)(KN,{hideProjectSelector:!0,queueEditRequest:v})})]}),w&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(aF,{jobId:w.jobId,projectId:w.projectId,onClose:T})}),E&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(oF,{loop:E,onClose:D})}),g&&(0,$.jsx)(VC,{tools:b,streaming:o,onClose:()=>_(!1)})]})}var fF=8,pF=3e3;function mF(){let{t:e}=U(`agent`),{conversations:t,active:n,selectConversation:r,deleteConversation:i,startNewConversation:a,streamingConversationIds:o,liveByConversation:s}=OL(),{backgroundConversationIds:c}=bs(),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(0),[h,g]=(0,Q.useState)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),y=(0,Q.useRef)(null),b=(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]),x=t.length>fF,S=(0,Q.useMemo)(()=>{let t=d.trim().toLowerCase();if(!t)return b;let n=e(`mission.untitled`).toLowerCase();return b.filter(e=>(e.title?.trim().toLowerCase()||n).includes(t))},[b,d,e]),C=S.length+1,w=(0,Q.useCallback)(()=>{_.current&&clearTimeout(_.current),_.current=null,g(null)},[]);(0,Q.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]),(0,Q.useEffect)(()=>{if(!l)return;let e=e=>{v.current&&!v.current.contains(e.target)&&E()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let T=()=>{let e=n?b.findIndex(e=>e.id===n.id):-1;m(e>=0?e+1:0),u(!0)},E=()=>{u(!1),f(``),w()},D=e=>{e!==n?.id&&r(e),E()},O=()=>{a(null),E()},k=e=>{_.current&&clearTimeout(_.current),g(e),_.current=setTimeout(()=>{g(null),_.current=null},pF)},A=async t=>{w();let a=n?.id===t,o=b.find(e=>e.id!==t)??null;try{await i(t),a&&o&&await r(o.id)}catch{K.error(e(`mission.deleteFailed`))}},j=()=>{if(p===0)O();else{let e=S[p-1];e&&D(e.id)}},M=e=>{if(!l){e.key===`ArrowDown`&&(e.preventDefault(),T());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;m(e=>(e+t+C)%C)}else e.key===`Home`?(e.preventDefault(),m(0)):e.key===`End`?(e.preventDefault(),m(C-1)):e.key===`Enter`?(e.preventDefault(),j()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),h?w():(E(),y.current?.focus()))},N=n?.title?.trim()||e(`mission.untitled`);return(0,$.jsxs)(`div`,{className:`relative min-w-0`,ref:v,"data-agent-interactive":!0,onKeyDown:M,children:[(0,$.jsxs)(`button`,{ref:y,type:`button`,"data-testid":`mission-trigger`,onClick:()=>l?E():T(),"aria-haspopup":`listbox`,"aria-expanded":l,"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)(vn,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[150px] truncate`,children:N}),(0,$.jsx)(rc,{className:`h-3.5 w-3.5 shrink-0 text-foreground/50`})]}),(0,$.jsx)(jb,{children:l&&(0,$.jsxs)(jS.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:[x&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(In,{className:`h-3.5 w-3.5 text-foreground/40`}),(0,$.jsx)(`input`,{autoFocus:!0,value:d,onChange:e=>{f(e.target.value),m(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-${p}`,className:`max-h-72 overflow-y-auto py-1`,children:[(0,$.jsxs)(jS.div,{id:`agent-mission-opt-0`,role:`option`,"aria-selected":!1,tabIndex:-1,"data-testid":`mission-new`,onClick:O,onMouseEnter:()=>m(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 ${p===0?`bg-surface/70`:`hover:bg-surface/70`}`,children:[(0,$.jsx)(Pn,{className:`h-4 w-4 text-accent-primary`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e(`mission.new`)})]}),S.length>0&&(0,$.jsx)(`div`,{className:`mx-3 my-1 h-px bg-border/50`,"aria-hidden":!0}),S.length===0&&d.trim()!==``&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground/40`,children:e(`mission.noMatches`)}),S.map((e,t)=>(0,$.jsx)(hF,{conversation:e,index:t+1,highlighted:p===t+1,activeId:n?.id??null,streaming:o.has(e.id)||c.has(e.id),queuedCount:s.get(e.id)?.queued.length??0,confirming:h===e.id,onHover:()=>m(t+1),onSelect:()=>D(e.id),onArmDelete:()=>k(e.id),onConfirmDelete:()=>void A(e.id),onCancelDelete:w},e.id))]})]})})]})}function hF({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}=U(`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)(Rn,{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)(xn,{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)(Vn,{className:`h-3.5 w-3.5`})})]}):(0,$.jsxs)(jS.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:qC(e.updated_at),children:KC(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)(xn,{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)(Rn,{className:`h-3.5 w-3.5`})})]})}var gF=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}));gF.displayName=`Input`;var _F=6e4,vF={data:null,fetchedAt:0,inFlight:null,error:null},yF=new Set;function bF(){yF.forEach(e=>{try{e()}catch{}})}function xF(){return vF.data!==null&&Date.now()-vF.fetchedAt<_F}async function SF(e){if(vF.inFlight)return vF.inFlight;let t=(async()=>{let t=await fetch(`${F}/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 vF.data=n,vF.fetchedAt=Date.now(),vF.error=null,vF.inFlight=null,bF(),vF.data})().catch(t=>{throw vF.inFlight=null,e?.aborted?t:(vF.error=t instanceof Error?t:Error(String(t)),bF(),vF.error)});return vF.inFlight=t,t}var CF=!1;function wF(){CF||typeof window>`u`||(window.addEventListener(`focus`,()=>{vF.fetchedAt=0,vF.data=null,SF().catch(()=>{})}),CF=!0)}function TF(){let[,e]=(0,Q.useState)(0),[t,n]=(0,Q.useState)(()=>!xF()),[r,i]=(0,Q.useState)(vF.error);(0,Q.useEffect)(()=>{wF();let t=()=>{e(e=>e+1),i(vF.error),n(!1)};yF.add(t);let r=new AbortController;return!xF()&&!vF.inFlight?(n(!0),SF(r.signal).catch(e=>{r.signal.aborted||i(e instanceof Error?e:Error(String(e)))}).finally(()=>{r.signal.aborted||n(!1)})):vF.inFlight&&vF.inFlight.catch(()=>{}).finally(()=>{r.signal.aborted||n(!1)}),()=>{r.abort(),yF.delete(t)}},[]);let a=(0,Q.useCallback)(async()=>{vF.fetchedAt=0,vF.data=null,vF.error=null,n(!0);try{await SF()}catch(e){i(e instanceof Error?e:Error(String(e)))}finally{n(!1)}},[]);return{status:vF.data,isLoading:t,error:r,recheck:a}}var EF=W(`github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),DF={claude:{icon:`🤖`,label:`Claude`},codex:{icon:`⚡`,label:`Codex`},gemini:{icon:`✨`,label:`Gemini`},kimi:{icon:`🌙`,label:`Kimi`}};function OF(e){return e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`project`}function kF({blueprint:e,onSubmit:t,onBack:n,submitting:r,error:i,errorDetail:a}){let{t:o}=U(`builder`),{status:s}=TF(),[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/${OF(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`&&on(n)&&(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`,...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)(gF,{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)(gF,{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}=DF[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)(EF,{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)(Vu,{className:`mr-1.5 h-3.5 w-3.5`}),o(r?`commit.creating`:`commit.submit`)]})]})]})}function AF({models:e,model:t,onSelect:n,status:r=`ready`,disabled:i=!1,testId:a=`agent-model-selector`,customModelAliases:o=!1}){let{t:s}=U(`agent`),c=t??e.find(e=>e.default)?.value??e[0]?.value??``,l=s(r===`loading`?`model.loading`:r===`error`?`model.unavailable`:`model.label`);return o?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 rounded-md px-1.5 py-1`,children:[(0,$.jsx)(Ln,{className:`h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),(0,$.jsx)(_M,{value:c,options:e,onCommit:n,disabled:i||r!==`ready`,ariaLabel:s(`model.label`),testId:a,placeholder:l,className:`h-6 w-48 border-border/40 px-1.5 text-xs`})]}):(0,$.jsx)(Gk,{label:s(`model.label`),value:c,options:e.map(e=>({value:e.value,label:e.label})),icon:Ln,onSelect:n,placeholder:l,disabled:i||r!==`ready`,testId:a})}function jF({session:e,autoFocus:t=!1}){let{t:n}=U(`builder`),{t:r}=U(`agent`),{availableIds:i,labels:a}=HN(),o=an(e.provider),s=[e.provider,...i].filter((e,t,n)=>n.indexOf(e)===t).filter(an),c=e=>r(`provider.${e}`,{defaultValue:a?.[e]??e}),l=()=>{!o||!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)(xl,{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)(Gk,{label:r(`provider.label`),value:e.provider,options:s.map(e=>({value:e,label:c(e)})),icon:zs,onSelect:e.setProvider,disabled:!o||e.busy||!e.conversationReady,testId:`builder-provider-selector`}),(0,$.jsx)(AF,{models:e.models,model:e.model,onSelect:e.setModel,disabled:!o||e.busy||!e.conversationReady,testId:`builder-model-selector`}),e.efforts.length>0&&(0,$.jsx)(Gk,{label:r(`effort.label`),value:e.effort,options:e.efforts.map(e=>({value:e,label:r(`effort.${e}`)})),icon:dl,onSelect:e.setEffort,disabled:!o||e.busy||!e.conversationReady,testId:`builder-effort-selector`}),e.showSurpriseMe&&(0,$.jsxs)(`button`,{type:`button`,onClick:e.surpriseMe,disabled:!o||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)(Ln,{className:`h-3 w-3`}),n(`shell.surpriseMe`)]})]}),!o&&(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:!o,autoFocus:t,onChange:t=>e.setDraft(t.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),l())},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:l,disabled:!o||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)(vt,{className:`h-4 w-4`})})]})]})}function MF(e){let t=Date.parse(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`);return Number.isFinite(t)?Er(new Date(t),{addSuffix:!0,locale:I()}):``}function NF({items:e,loading:t,disabled:n=!1,onResume:r,onDiscard:i}){let{t:a}=U(`builder`),[o,s]=(0,Q.useState)(null);return!t&&e.length===0?null:(0,$.jsxs)(jS.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)(Uu,{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)(An,{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)(jb,{initial:!1,children:e.map(e=>{let t=e.productName||e.title||a(`recent.untitled`),c=o===e.id;return(0,$.jsxs)(jS.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)(Mn,{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)(kn,{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)(zn,{className:`h-2.5 w-2.5`,"aria-hidden":!0}),a(`recent.pendingIssue`)]}),e.updatedAt&&(0,$.jsx)(`span`,{className:`opacity-80`,children:MF(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)(xn,{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)(Vn,{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)(Rn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})})]},e.id)})})})]})}function PF({specsStarted:e,snapshot:t,maxSpecs:n=10}){let{t:r}=U(`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?Bn:Ln,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)(An,{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)(jb,{mode:`wait`,initial:!1,children:(0,$.jsx)(jS.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)(jb,{mode:`wait`,initial:!1,children:(0,$.jsx)(jS.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)(jS.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 FF=`specrails-desktop:milestone-launch-mode`,IF=`specrails-desktop:milestone-sequential-plans`,LF=`specrails-desktop:milestone-auto-advance`;function RF(){try{return localStorage.getItem(LF)!==`false`}catch{return!0}}function zF(e){try{localStorage.setItem(LF,e?`true`:`false`)}catch{}}function BF(){try{return localStorage.removeItem(FF),localStorage.getItem(`specrails-desktop:milestone-sequential-plans`)===null?!1:(localStorage.removeItem(IF),!0)}catch{return!1}}function VF(e){return`M${e}`}function HF(e,t){return t===`chain_active`?`chain_active`:t===`no_tickets`?`no_tickets`:t===`milestone_not_found`?`milestone_not_found`:t===`rail_limit_reached`?`rail_limit_reached`:e===503?`unavailable`:`launch_rejected`}async function UF(e){try{let t=await e.json();return t&&typeof t==`object`?t:{}}catch{return{}}}async function WF(e,t,n={}){let r=typeof n==`function`?{fetchImpl:n}:n,i=r.fetchImpl??fetch,a=r.autoAdvance??RF(),o;try{o=await i(`/api/projects/${e}/blueprint/milestones/${t}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({autoAdvance:a})})}catch(e){return{ok:!1,reason:`network`,error:`network`,detail:e instanceof Error?e.message:String(e)}}let s=await UF(o);if(!o.ok){let e=typeof s.error==`string`?s.error:`http_${o.status}`;return{ok:!1,reason:HF(o.status,e),error:e,...typeof s.detail==`string`?{detail:s.detail}:{},...typeof s.chainId==`string`?{chainId:s.chainId}:{}}}let c=Array.isArray(s.launched)?s.launched.filter(e=>!!e&&typeof e==`object`&&typeof e.chunk==`number`):[],l=Array.isArray(s.pending)?s.pending.filter(e=>Array.isArray(e)):[];return{ok:!0,chainId:typeof s.chainId==`string`?s.chainId:null,launched:c,pending:l,ticketCount:c.reduce((e,t)=>e+(Array.isArray(t.ticketIds)?t.ticketIds.length:0),0),skippedCount:l.reduce((e,t)=>e+t.length,0)}}async function GF(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 UF(i);return i.ok?{ok:!0,chain:Dt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}function KF(e,t,n=fetch){return GF(e,t,`resume`,n)}function qF(e,t,n=fetch){return GF(e,t,`cancel`,n)}async function JF(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 UF(i);return i.ok?{ok:!0,chain:Dt(a.chain)}:{ok:!1,error:typeof a.error==`string`?a.error:`http_${i.status}`,...typeof a.detail==`string`?{detail:a.detail}:{}}}var YF=[`Problem Statement`,`Proposed Solution`,`Out of Scope`,`Technical Considerations`,`Estimated Complexity`],XF={problemMinChars:200,solutionMinChars:500,outOfScopeMinBullets:3,technicalMinBullets:5,criteriaMin:6,criteriaMax:10,criterionMinChars:20},ZF=new Set([`scaffold`,`feature`,`verification`]),QF=new Set([`critical`,`high`,`medium`,`low`]),$F=/^(?:todo|tbd|n\/?a|works?|test(?: it)?|criterion|acceptance criterion)$/i;function eI(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function tI(e){return e.trim().toLocaleLowerCase(`en-US`)}function nI(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 rI(e){return e.split(/\r?\n/).filter(e=>/^\s*[-*+]\s+\S/.test(e)).length}function iI(e,t){let n=[],r=eI(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=eI(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:``;ZF.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=tI(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:``;QF.has(d)||o(n,`priority`,`invalid_priority`,`Spec ${i} needs a valid priority.`);let f=typeof r.description==`string`?r.description.trim():``,p=nI(f);(!/^## Problem Statement(?:\r?\n|$)/.test(f)||p.headings.length!==YF.length||p.headings.some((e,t)=>e!==YF[t]))&&o(n,`description`,`canonical_sections`,`Spec ${i} is missing the canonical sections.`);for(let e of YF)(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`,XF.problemMinChars],[`Proposed Solution`,XF.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`,XF.outOfScopeMinBullets],[`Technical Considerations`,XF.technicalMinBullets]]){let r=p.bodies.get(e)??``;r&&rI(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<XF.criteriaMin||h.length>XF.criteriaMax)&&o(n,`acceptanceCriteria`,`criteria_count`,`Spec ${i} needs ${XF.criteriaMin}-${XF.criteriaMax} acceptance criteria.`,{count:h.length,min:XF.criteriaMin,max:XF.criteriaMax});let g=new Set;h.forEach((e,t)=>{let r=typeof e==`string`?e.trim():``;if(r.length<XF.criterionMinChars||$F.test(r)){o(n,`acceptanceCriteria`,`criterion_quality`,`Spec ${i} criterion ${t+1} is not concrete.`,{criterion:t+1});return}let a=tI(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 aI=new Set([`batch_incomplete`,`spec_count`]);function oI(e,t,n,r,i={}){let a=wt(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=>!aI.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 sI(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 cI(e,t){let n={n:t.specIndex===null?``:t.specIndex+1,...t.params??{}};return e(sI(t),{...n,defaultValue:t.message})}var lI=new Set([`gh_not_installed`,`gh_not_authenticated`,`gh_scope`,`gh_repo_exists`,`gh_network`]);function uI(e){return`progress.githubErrors.${e&&lI.has(e)?e:`generic`}`}var dI=[`create-dir`,`git-init`,`assemble`,`blueprint`,`tickets`,`register`,`github`],fI={minSpecs:5,maxSpecs:10};function pI(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 mI(e,t){let n=e&&typeof e==`object`?e:{},r=new Date().toISOString();if(n.continuing){let e=pI(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 hI(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 gI(e,t){let{t:n}=U(`builder`),{registerHandler:r,unregisterHandler:i}=R(),{setActiveProjectId:a}=ce(),[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,ee]=(0,Q.useState)(`claude`),[te,L]=(0,Q.useState)(null),[z,B]=(0,Q.useState)([]),[ne,V]=(0,Q.useState)(``),[re,ie]=(0,Q.useState)([]),[ae,H]=(0,Q.useState)(`medium`),[W,G]=(0,Q.useState)(``),[oe,se]=(0,Q.useState)({status:`idle`}),[le,ue]=(0,Q.useState)([]),[de,fe]=(0,Q.useState)(!1),[pe,q]=(0,Q.useState)(!1),me=te??ne,he=(0,Q.useMemo)(()=>{let e=qt(I,me);return re.filter(t=>e.includes(t))},[me,I,re]),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),J=(0,Q.useRef)(I),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(!1),be=(0,Q.useRef)(ae),xe=(0,Q.useRef)(he),Se=(0,Q.useRef)(te),Ce=(0,Q.useRef)(!1),we=(0,Q.useRef)(t.onFinished);(0,Q.useEffect)(()=>{ge.current=o},[o]),(0,Q.useEffect)(()=>{J.current=I},[I]),(0,Q.useEffect)(()=>{ve.current=w},[w]),(0,Q.useEffect)(()=>{be.current=ae},[ae]),(0,Q.useEffect)(()=>{xe.current=he},[he]),(0,Q.useEffect)(()=>{Se.current=te},[te]),(0,Q.useEffect)(()=>{we.current=t.onFinished},[t.onFinished]);let Te=(0,Q.useCallback)(async()=>{let e=ge.current;if(e)return e;if(_e.current)return _e.current;let t=fetch(`/api/blueprint/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:J.current,...Se.current?{model:Se.current}:{}})}).then(e=>e.json()).then(e=>e.conversation?(ge.current=e.conversation.id,s(e.conversation.id),e.conversation.id):null).catch(()=>null).finally(()=>{_e.current=null});return _e.current=t,t},[]),Ee=(0,Q.useCallback)(async()=>{fe(!0);try{let e=await(await fetch(`/api/blueprint/conversations?resumable=1`)).json();ue(hI(e.conversations))}catch{ue([])}finally{fe(!1)}},[]);(0,Q.useEffect)(()=>{e&&Ee()},[e,Ee]),(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return B([]),V(``),ie([]),H(``),fetch(`/api/blueprint/models?provider=${encodeURIComponent(I)}`).then(e=>e.json()).then(e=>{if(t)return;B(e.models??[]);let n=e.defaultModel??e.models?.[0]?.value??``,r=e.efforts??[],i=qt(I,n),a=r.filter(e=>i.includes(e));V(n),ie(r),H(e=>a.includes(e)?e:cn(I,n)??``)}).catch(()=>{}),()=>{t=!0}},[e,I]);let{availableIds:De}=HN({enabled:e});(0,Q.useEffect)(()=>{if(ge.current||De.length===0||De.includes(I))return;let e=De.filter(an);e.length!==0&&(ee(rn(e)),L(null))},[De,I]);let Oe=(0,Q.useCallback)(e=>{ee(e),L(null);let t=ge.current;t&&fetch(`/api/blueprint/conversations/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).catch(()=>{})},[]),ke=(0,Q.useCallback)(e=>{L(e);let t=qt(I,e),n=re.filter(e=>t.includes(e));H(t=>n.includes(t)?t:cn(I,e)??``);let r=ge.current;r&&fetch(`/api/blueprint/conversations/${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:e})}).catch(()=>{})},[I,re]);(0,Q.useEffect)(()=>{if(!e)return;let t=`builder-session`;return r(t,e=>{let t=e,r=ge.current!==null&&t.conversationId===ge.current,i=ve.current!==null&&t.commitId===ve.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),se({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=pI(t);d(null),_(!0),e&&se({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=jt(t.blueprint),i=t.rawBlueprint===void 0?t.blueprint:t.rawBlueprint;if(!r&&t.snapshot===void 0){let e=Kt(n);r=e.blueprint,i=e.rawBlueprint}r&&(p(r),h(i)),se(e=>t.snapshot===void 0?r?{status:`accepted`,repaired:!1,repairAttempted:!1,at:new Date().toISOString()}:e:mI(t.snapshot,e))}else if(t.type===`blueprint.error`&&r)d(null),_(!1),se(e=>e.status===`repairing`||e.status===`generating`?{status:`idle`}:e),K.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`&&!ye.current&&(ye.current=!0,K.warning(n(uI(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&&(Ce.current=!1,F(!1),K.error(n(`errors.commitFailed`),{description:String(t.error??``)}),y(`commit`),x(`commit_failed`),C(String(t.error??``)))}),()=>i(t)},[e,r,i,n]);let Ae=(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=be.current,a=xe.current.includes(i);Te().then(e=>{if(!e){_(!1),K.error(n(`errors.startFailed`));return}return fetch(`/api/blueprint/conversations/${e}/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:r,...Se.current?{model:Se.current}:{},...a?{reasoning_effort:i}:{},...t.intent?{intent:t.intent}:{}})}).then(e=>{!e.ok&&e.status!==202&&(_(!1),K.error(n(`errors.turnFailed`)))}).catch(()=>{_(!1),K.error(n(`errors.turnFailed`))})})},[g,pe,Te,n]),je=(0,Q.useCallback)(async e=>{if(!g){q(!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`);ge.current=n.conversation.id,s(n.conversation.id),n.conversation.provider&&ee(n.conversation.provider),L(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=jt(n.blueprint);p(r),h(r?n.rawBlueprint??n.blueprint:null),se(mI(n.snapshot,{status:`idle`})),d(null),_(!1),y(`chat`),x(null),C(null),D([]),G(``)}catch{K.error(n(`recent.resumeFailed`))}finally{q(!1)}}},[g,n]),Me=(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{K.error(n(`recent.discardFailed`))}},[n]),Ne=(0,Q.useCallback)(async()=>{let e=ge.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(ae?{reasoningEffort:ae}:{})});if(t.status===202)return;let r=await t.json().catch(()=>({}));_(!1),r.error===`nothing_to_repair`?K.info(n(`snapshot.nothingToRepair`)):r.error===`no_session`?K.error(n(`snapshot.noSession`)):r.error===`streaming`?K.info(n(`snapshot.alreadyStreaming`)):K.error(n(`errors.turnFailed`))}catch{_(!1),K.error(n(`errors.turnFailed`))}}},[g,ae,n]),Pe=(0,Q.useCallback)(()=>Ae(n(`prompts.surpriseMe`),{intent:`surprise`}),[Ae,n]),Fe=(0,Q.useCallback)(()=>Ae(n(`prompts.approve`),{intent:`approve`}),[Ae,n]),Ie=(0,Q.useCallback)(e=>{!f||Ce.current||(Ce.current=!0,F(!0),x(null),C(null),D([]),ye.current=!1,fetch(`/api/blueprint/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({blueprint:m??f,...e,...ge.current?{conversationId:ge.current}:{}})}).then(async e=>{let t=await e.json().catch(()=>({}));e.status===202&&t.commitId?(T(t.commitId),ve.current=t.commitId,y(`progress`)):(x(t.error??`generic`),C(t.detail??null)),Ce.current=!1,F(!1)}).catch(()=>{Ce.current=!1,F(!1),x(`generic`),C(null)}))},[f,m]),Le=(0,Q.useCallback)(async()=>{if(!(!O||A)){j(!0);try{let e=RF(),t=await WF(O,1,{autoAdvance:e}),r=VF(1);if(t.ok){let i=t.launched.length+t.pending.length;t.pending.length>0?K.success(n(e?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:r,count:t.ticketCount,n:i})):K.success(n(`milestoneProgress.toast.launchedAll`,{milestone:r,count:t.ticketCount,n:i})),a(O),N(!0)}else t.reason===`chain_active`?(K.info(n(`milestoneProgress.toast.chainActive`,{milestone:r})),a(O),N(!0)):t.reason===`rail_limit_reached`?K.warning(n(`milestoneProgress.toast.railLimitReached`,{milestone:r})):K.error(n(`done.launchFailed`),{description:t.detail??t.error})}finally{j(!1)}}},[O,A,a,n]),Re=(0,Q.useCallback)(()=>{O&&a(O),we.current()},[O,a]),ze=(0,Q.useCallback)(()=>{let e=ge.current;e&&fetch(`/api/blueprint/conversations/${e}/abort`,{method:`POST`}).catch(()=>{}),s(null),ge.current=null,_e.current=null,l([]),d(null),p(null),h(null),se({status:`idle`}),ue([]),q(!1),_(!1),y(`chat`),x(null),C(null),T(null),D([]),ye.current=!1,k(null),N(!1),j(!1),Ce.current=!1,F(!1),ee(`claude`),L(null),B([]),V(``),ie([]),H(`medium`),G(``)},[]),Be=wt(f),Ve=Object.values(Be).some(Boolean)||c.length>0||W.trim().length>0,He=(0,Q.useMemo)(()=>iI(m??f,{milestoneLabel:`M1`,minSpecs:fI.minSpecs,maxSpecs:fI.maxSpecs,requireScaffold:!0}),[f,m]),Ue=oe.status===`generating`,We=(0,Q.useMemo)(()=>oI(f,m??f,He,fI,{generating:Ue}),[f,m,He,Ue]),Ge=(0,Q.useMemo)(()=>{if(He.valid)return null;let e=He.issues[0];return e?cI(n,e):null},[He,n]),Ke=(0,Q.useMemo)(()=>Ut(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:Ve,canProposeCommit:He.valid,specQualityDetail:Ge,readiness:We,snapshot:oe,generation:Ke,recent:le,recentLoading:de,resume:je,discardRecent:Me,repairSnapshot:Ne,showSurpriseMe:c.length<=1&&v===`chat`,provider:I,model:te,models:z,efforts:he,effort:ae,draft:W,setDraft:G,setEffort:H,setProvider:Oe,setModel:ke,send:Ae,surpriseMe:Pe,approveBlueprint:Fe,goToCommit:()=>y(`commit`),backToChat:()=>y(`chat`),submitCommit:Ie,launchM1:Le,openProject:Re,abortAndReset:ze}}var _I={done:`bg-accent-success`,onReview:`bg-accent-warning`,inProgress:`bg-accent-info animate-pulse`,failed:`bg-destructive`,todo:`bg-muted-foreground/25`},vI={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 yI({counts:e,className:t}){let{t:n}=U(`builder`),r=Rt(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:Ht(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`,_I[e.key]),style:{width:`${e.pct}%`},title:`${n(`milestoneProgress.legend.${e.key}`)} · ${e.count}`},e.key))})}function bI({state:e}){let{t}=U(`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`,vI[e]),children:t(`milestoneProgress.state.${e}`)})}function xI(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 SI({rail:e,now:t,onReview:n,onOpenRail:r}){let{t:i}=U(`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&&Mt.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)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),o==null?i(`milestoneProgress.state.running`):i(`milestoneProgress.rail.running`,{elapsed:jr(o)})]}):s?(0,$.jsx)(yP,{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)(qc,{className:`h-3 w-3`,"aria-hidden":!0}),i(`milestoneProgress.rail.review`)]})]})}function CI({checked:e,onChange:t,disabled:n=!1,compact:r=!1,testId:i=`milestone-auto-advance`}){let{t:a}=U(`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)(tl,{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 wI({chain:e,busy:t=!1,onResume:n,onCancel:r,onSetAutoAdvance:i}){let{t:a}=U(`builder`),o=Lt(e),s=e.status===`paused`,c=Tt(e),l=Bt(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)(kn,{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)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Mn,{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)(An,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Mn,{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)(Vn,{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)(_u,{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)(tl,{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)(Be,{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)(bn,{className:`h-3 w-3`,"aria-hidden":!0}),a(`milestoneProgress.chain.cancelled`)]}):(0,$.jsx)(`span`,{children:e.pauseReason===`integration_pending`?a(`milestoneProgress.chain.integrating`):a(`milestoneProgress.chain.waiting`,{k:e.nextChunk})})}),d&&i&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(CI,{checked:e.autoAdvance,disabled:t,onChange:t=>i(e.id,t),testId:`milestone-chain-auto-advance`})})]})}function TI({progress:e,actions:t,chainBusy:n,onReview:r,onOpenRail:i,onResume:a,onCancel:o,onSetAutoAdvance:s,className:c}){let{t:l}=U(`builder`),u=e.rails.some(e=>e.active),d=xI(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:kt(e.n)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium`,children:e.title}),(0,$.jsx)(bI,{state:e.state})]}),f.total>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(yI,{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:Ht(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)(wI,{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)(SI,{rail:e,now:d,onReview:r,onOpenRail:i},e.railIndex))})]})}function EI({projectId:e}){let{t}=U(`builder`),n=y(),{setActiveProjectId:r}=ce(),{progress:i,hasBlueprint:a}=It(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 KF(e,n);r.ok?K.success(t(`milestoneProgress.chain.resumed`)):K.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 JF(e,n,r);i.ok?(zF(r),K.success(t(r?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):K.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 qF(e,n);r.ok?K.success(t(`milestoneProgress.chain.cancelledToast`)):K.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)(An,{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)(TI,{progress:c,chainBusy:o,onReview:e=>l(Ve?`/review/${e}`:`/`),onOpenRail:()=>l(`/`),onResume:u,onCancel:f,onSetAutoAdvance:d,className:`bg-card/60`})}):null}var DI={surprise:jd,approve:Vu};function OI({kind:e,mode:t,onAction:n,disabled:r=!1,createdAt:i,className:a}){let{t:o}=U(`builder`),s=AS(),c=t===`settled`,l=c?xn:DI[e],u=i?kI(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)(xn,{className:`h-3 w-3`,"aria-hidden":!0}):(0,$.jsx)(Ln,{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)(Be,{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)(jS.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 kI(e){let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return MC(t,`p`,{locale:I()})}catch{return null}}var AI=`w-full rounded-2xl border border-border/60 bg-card/90 p-3 shadow-2xl backdrop-blur-xl`;function jI({variant:e}){let{t}=U(`builder`),{builderMode:n}=OL(),r=n.session,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(()=>RF()),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)(jS.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)(Ln,{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)(iM,{active:!0,inset:-3,radius:`1rem`}),(0,$.jsx)(jS.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:AI,children:(0,$.jsx)(jF,{session:r,autoFocus:!0})})]}),(0,$.jsx)(NF,{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)(OI,{kind:e.intent,mode:`settled`,createdAt:e.createdAt})},`${t}-${e.createdAt}`):(0,$.jsx)(ej,{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)(jb,{initial:!1,children:[p&&(0,$.jsx)(OI,{kind:`surprise`,mode:`offer`,onAction:r.surpriseMe,disabled:!r.conversationReady},`surprise`),m&&(0,$.jsx)(OI,{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&&At(r.streamBuffer)&&(0,$.jsx)(ej,{role:`assistant`,content:At(r.streamBuffer),streaming:!0}),r.generation.generating||r.snapshot.status===`repairing`||r.snapshot.status===`generating`?(0,$.jsx)(PF,{specsStarted:r.generation.specsStarted,snapshot:r.snapshot}):(0,$.jsx)(zC,{tool:null})]})]}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-4`,children:(0,$.jsx)(jS.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(AI,e===`inline`&&`mx-auto max-w-[680px]`),children:(0,$.jsx)(jF,{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)(kF,{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:dI.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)(lc,{className:`h-3.5 w-3.5 text-muted-foreground/40`}),n?.status===`running`&&(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin text-accent-info`}),n?.status===`done`&&(0,$.jsx)(xn,{className:`h-3.5 w-3.5 text-accent-success`}),n?.status===`warning`&&(0,$.jsx)(zn,{className:`h-3.5 w-3.5 text-accent-warning`}),n?.status===`failed`&&(0,$.jsx)(Vn,{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(uI(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)(xn,{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)(EI,{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)(An,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Vu,{className:`mr-1.5 h-3.5 w-3.5`}),t(`done.launchM1`)]}),(0,$.jsx)(CI,{checked:o,onChange:e=>{s(e),zF(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 MI=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`),NI={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 PI({spec:e,index:t,milestoneLabel:n=`M1`,onClose:r}){let{t:i}=U(`builder`),{t:a}=U(`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,BC.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)(wn,{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`,NI[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)(Vn,{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:MI,children:(0,$.jsx)(Cr,{remarkPlugins:[wr],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)(sc,{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 FI={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 II({blueprint:e,milestoneLabel:t=`M1`,snapshot:n}){let{t:r}=U(`builder`),{t:i}=U(`tickets`),a=wt(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)(An,{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)(xn,{className:`h-3.5 w-3.5 shrink-0 text-accent-success`,"aria-label":`✓`}):(0,$.jsx)(Vn,{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)(kn,{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)(wn,{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`,FI[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)(An,{className:`h-2.5 w-2.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Vl,{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)(Vl,{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)(PI,{spec:e.m1Specs[o],index:o,milestoneLabel:t,onClose:()=>s(null)})]})}var LI={done:xn,pending:lc,blocked:zn,writing:An},RI={done:`text-accent-success`,pending:`text-muted-foreground/50`,blocked:`text-accent-warning`,writing:`text-accent-info animate-spin`};function zI({readiness:e,snapshot:t,busy:n,primaryLabel:r,onPrimary:i,onRepair:a,primaryTestId:o=`builder-create-specs`,showPrimary:s=!0}){let{t:c}=U(`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=LI[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`,RI[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)(jb,{initial:!1,mode:`wait`,children:[d&&(0,$.jsxs)(jS.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)(An,{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)(jS.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)(zn,{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)(Lu,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.rejected.retry`)]})]},`rejected`),p&&(0,$.jsxs)(jS.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)(zn,{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)(Ln,{className:`mr-1.5 h-3 w-3`,"aria-hidden":!0}),c(`snapshot.halted.resume`)]})]},`halted`),t.status===`accepted`&&t.repaired&&!p&&(0,$.jsxs)(jS.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)(Ln,{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)(Bn,{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)(rc,{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:cI(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)(Bn,{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)(Vu,{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 BI(){let{t:e}=U(`agent`),{t}=U(`builder`),{minimize:n,startNewConversation:r,cycleTier:i,active:a,draftPinnedProjectId:o,setPinnedProject:s,builderMode:c}=OL(),[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}=qn({enabled:!0,allowMove:!0,minWidth:400,minHeight:420,anchorFromCurrentRect:!0,persistKey:`specrails-desktop:agent-panel-geom`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(jS.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)(iM,{active:d&&c.session.messages.length===0&&c.session.phase===`chat`,inset:-3}),(0,$.jsx)(zs,{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)(eM,{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)(mF,{})]}),(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)(Pn,{className:`h-4 w-4`})}),(0,$.jsx)(Id,{}),(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)(Yl,{className:`h-4 w-4`}):(0,$.jsx)(ql,{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)(Vn,{className:`h-4 w-4`})})]})]}),d?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsx)(jI,{variant:`floating`}),(0,$.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border/40 lg:w-80`,children:[(0,$.jsx)(II,{blueprint:c.session.blueprint,snapshot:c.session.snapshot}),c.session.phase===`chat`&&(0,$.jsx)(zI,{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)(uF,{variant:`floating`})]}),!l&&(0,$.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] [&>*]:pointer-events-auto`,children:(0,$.jsx)(Zn,{handles:g})})]})}var VI=`specrails-desktop:agent-bubble-pos`,HI=56,UI=12;function WI(){try{let e=localStorage.getItem(VI);if(!e)return null;let t=JSON.parse(e);if(typeof t?.left==`number`&&typeof t?.top==`number`)return t}catch{}return null}function GI(e){let t=Math.max(UI,window.innerWidth-HI-UI),n=Math.max(UI,window.innerHeight-HI-UI);return{left:Math.min(Math.max(UI,e.left),t),top:Math.min(Math.max(UI,e.top),n)}}function KI(){return{left:Math.round(window.innerWidth/2-HI/2),top:window.innerHeight-HI-20}}function qI(){let{t:e}=U(`agent`),{t}=U(`builder`),{open:n,isStreaming:r,active:i,builderMode:a}=OL(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(()=>GI(WI()??KI())),u=kS(0),d=kS(0),f=(0,Q.useRef)(!1),p=a.active?a.session.busy:r;(0,Q.useEffect)(()=>{let e=()=>l(e=>GI(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,Q.useCallback)(e=>{try{localStorage.setItem(VI,JSON.stringify(e))}catch{}},[]);return(0,$.jsxs)(jS.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=GI({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)(iM,{active:a.active&&a.session.messages.length===0&&a.session.phase===`chat`,inset:-4}),(0,$.jsx)(zs,{className:`h-5 w-5 text-accent-primary`}),p&&(0,$.jsx)(jS.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)(jb,{initial:!1,children:(o||p)&&(0,$.jsx)(jS.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 JI=`specrails-desktop:uiMode`;function YI(){if(!at)return`kanban`;try{return localStorage.getItem(JI)===`kanban`?`kanban`:`agent`}catch{return`agent`}}function XI(e){try{localStorage.setItem(JI,e)}catch{}}var ZI=(0,Q.createContext)(null);function QI({children:e,initialMode:t,persist:n=!0}){let[r,i]=(0,Q.useState)(()=>t??YI()),a=(0,Q.useCallback)(e=>{at&&(i(e),n&&XI(e))},[n]),o=(0,Q.useCallback)(()=>{i(e=>{if(!at)return`kanban`;let t=e===`kanban`?`agent`:`kanban`;return n&&XI(t),t})},[n]),s=(0,Q.useMemo)(()=>({uiMode:r,setUiMode:a,toggleUiMode:o}),[r,a,o]);return(0,$.jsx)(ZI.Provider,{value:s,children:e})}var $I={uiMode:`kanban`,setUiMode:()=>{},toggleUiMode:()=>{}};function eL(){return(0,Q.useContext)(ZI)??$I}var tL={streamingText:``,isStreaming:!1,liveTools:[],turnTools:[],queued:[]},nL=`specrails-desktop:favorite-agent-conversations`;function rL(){try{let e=localStorage.getItem(nL);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 iL(e){try{localStorage.setItem(nL,JSON.stringify([...e]))}catch{}}function aL(e,t){let n=new Set(t.map(e=>e.id));return new Set([...e].filter(e=>n.has(e)))}var oL=`specrails-desktop:agent-tier-last`;function sL(){try{let e=localStorage.getItem(oL),t=e===null?0:Number.parseInt(e,10);return t===0||t===1||t===2||t===3?t:0}catch{return 0}}function cL(e){try{localStorage.setItem(oL,String(e))}catch{}}var lL=new Set([`completed`,`merged`,`discarded`,`superseded`]);function uL(e,t){return JSON.stringify(e)===JSON.stringify(t)}function dL(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 fL(e,t){if(t.supersedesDeliveryId===e.prDeliveryId)return 1;if(e.supersedesDeliveryId===t.prDeliveryId)return-1;let n=dL(e),r=dL(t);return n==null||r==null?null:r<n?-1:+(r>n)}function pL(e,t){let n=null;for(let r of e){if(r.supersedesDeliveryId!==t)continue;if(!n){n=r;continue}let e=dL(n),i=dL(r);(e==null||i==null||i>=e)&&(n=r)}return n}function mL(e,t){let n=t.restoredFromDeliveryId;if(!n)return!1;let r=pL(e,t.prDeliveryId);return!r||r.prDeliveryId===n}function hL(e,t){let n=e.filter(e=>e.role===`system`).map(e=>qo(e.content)).filter(e=>e!==null),r=[...n].reverse().find(e=>e.prDeliveryId===t.prDeliveryId),i=mL(n,t);if(r){let e=lL.has(r.decision),n=lL.has(t.decision),a=Ct(r.updatedAt,t.updatedAt);if(a===-1||a===0&&!uL(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=fL(e,t);if(n===-1||(n===0||n===null)&&!lL.has(e.decision)&&t.supersedesDeliveryId!==e.prDeliveryId)return!0}return!1}function gL(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=qo(e.content);return!t||t.prDeliveryId!==n||lL.has(t.decision)?e:(r=!0,{...e,content:JSON.stringify({...t,decision:`discarded`})})});return r?i:e}function _L(e,t){let n=e.filter(e=>e.role===`system`).map(e=>qo(e.content)).filter(e=>e!==null);if(n.some(e=>e.restoredFromDeliveryId===t.prDeliveryId&&mL(n,e)))return e;let r=!1,i=e.map(e=>{if(e.role!==`system`)return e;let n=qo(e.content);return!n||n.railIndex!==t.railIndex||n.prDeliveryId===t.prDeliveryId||lL.has(n.decision)||fL(n,t)!==1?e:(r=!0,{...e,content:JSON.stringify({...n,decision:`superseded`})})});return r?i:e}function vL(e,t,n){if(hL(e,n))return e;let r=_L(gL(e,n),n),i=JSON.stringify(n),a=r.flatMap((e,t)=>e.role===`system`&&qo(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 yL=(0,Q.createContext)(null);function bL(e){if(e.code===`policy_unenforceable`){let t=e.provider?e.provider.charAt(0).toUpperCase()+e.provider.slice(1):``;return N.t(`agent:subagents.policyUnenforceable`,{provider:t})}return e.error||`The agent turn failed.`}var xL=0,SL=0,CL={sent:0,received:1,read:2};function wL(e,t){return e&&(!t||CL[e]>=CL[t])?e:t}function TL(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=wL(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 EL({children:e,fixedConversationId:t}){let n=(0,Q.useId)(),r=t?`agent-chat-pane:${n}`:`agent-chat`,{registerHandler:i,unregisterHandler:a,connectionStatus:o}=R(),{uiMode:s}=eL(),{setActiveProjectId:c,activeProjectId:l}=ce(),u=Mi(),d=(0,Q.useRef)(u);d.current=u;let f=wi(),p=e=>e?d.current.isEditable(e):!f,[m,h]=(0,Q.useState)(`hidden`),[g,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)([]),S=(0,Q.useRef)(new Map),C=(0,Q.useRef)(b);C.current=b;let[w,T]=(0,Q.useState)(rL);(0,Q.useEffect)(()=>{let e=e=>{(e.key===nL||e.key===null)&&T(rL())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let[E,D]=(0,Q.useState)(new Set),[O,k]=(0,Q.useState)(new Map),[A,j]=(0,Q.useState)(!0),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(null),[I,ee]=(0,Q.useState)([]),te=(0,Q.useRef)([]);te.current=I;let L=(0,Q.useRef)(!1),[z,B]=(0,Q.useState)(null),ne=(0,Q.useRef)(null);ne.current=z;let[V,re]=(0,Q.useState)(`claude`),[ie,ae]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(()=>sL()),[W,G]=(0,Q.useState)(null),oe=(0,Q.useRef)({provider:`claude`,model:null,tierLevel:0,effort:null});oe.current={provider:V,model:ie,tierLevel:H,effort:W};let se=(0,Q.useRef)(null);se.current=v?.id??null;let le=(0,Q.useRef)(O);le.current=O;let ue=(0,Q.useRef)(new Set),de=(0,Q.useRef)(new Set),fe=(0,Q.useRef)(new Map),pe=(0,Q.useRef)(new Map),q=e=>{let t=wL(e.delivery_receipt,fe.current.get(`${e.conversation_id}:m:${e.id}`));return t?{...e,delivery_receipt:t}:e},me=(e,t)=>{let n=wL(t.deliveryReceipt,fe.current.get(`${e}:q:${t.queueId}`));return n?{...t,deliveryReceipt:n}:t},he=(0,Q.useRef)(new Set),ge=(0,Q.useRef)(new Map),_e=(0,Q.useRef)(new Map),J=(0,Q.useRef)(new Map),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(0),be=(0,Q.useRef)(0),xe=(0,Q.useRef)(new Map),Se=(0,Q.useCallback)(e=>{let t=se.current;if(!t)return`untracked`;if(hL(C.current,e))return`stale`;if(!C.current.some(t=>t.role===`system`&&qo(t.content)?.prDeliveryId===e.prDeliveryId))return`untracked`;ye.current++;let n=vL(C.current,t,e);return C.current=n,x(n=>{if(!n.some(t=>t.role===`system`&&qo(t.content)?.prDeliveryId===e.prDeliveryId))return C.current=n,n;let r=vL(n,t,e);return C.current=r,r}),`accepted`},[]),Ce=(0,Q.useCallback)((e,t)=>{k(n=>{let r=t(n.get(e)??tL),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})},[]),we=(0,Q.useCallback)(e=>{let t=typeof document<`u`&&document.visibilityState===`hidden`;e===se.current&&!t||D(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Te=(0,Q.useCallback)(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,Q.useEffect)(()=>{if(!$e||typeof document>`u`)return;let e=()=>{if(document.visibilityState!==`visible`)return;let e=se.current;e&&Te(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Te]);let Ee=(v?O.get(v.id):void 0)??tL,De=Ee.streamingText,Oe=Ee.isStreaming,ke=Ee.liveTools,Ae=Ee.turnTools,je=Ee.queued,Me=(0,Q.useMemo)(()=>{let e=new Set;for(let[t,n]of O)n.isStreaming&&e.add(t);return e},[O]),Ne=(0,Q.useCallback)(async()=>{try{let e=await bo();_(e),T(t=>{let n=aL(rL(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(iL(n),n)})}catch{}},[]),Pe=(0,Q.useCallback)(async()=>{try{let e=await $o();j(e.enabled)}catch{j(!1)}},[]),Fe=(0,Q.useCallback)(async()=>{try{let{any:e,installed:t}=await Qo();F(e),ee(Array.isArray(t)?t:[])}catch{F(!0)}},[]),[Ie,Le]=(0,Q.useState)(0);(0,Q.useEffect)(()=>$e?(i(r,e=>{let n=e;if(!n||t&&n.conversationId&&n.conversationId!==t)return;if(n.type===`desktop.project_recovered`){Le(e=>e+1);return}if(typeof n.type!=`string`||!n.type.startsWith(`agent_`))return;if(n.type===`agent_conversation_created`){Ne();return}if(n.type===`agent_title`&&n.conversationId){let e=n.title??null;_(t=>t.map(t=>t.id===n.conversationId?{...t,title:e}:t)),y(t=>t&&t.id===n.conversationId?{...t,title:e}:t);return}let r=n.conversationId;if(!r)return;ge.current.set(r,(ge.current.get(r)??0)+1);let i=r===se.current,a=e=>{J.current.set(r,TL(J.current.get(r)??[],e).slice(-500)),i&&(C.current=TL(C.current,e),x(t=>TL(t,e)))};if(n.type===`agent_input_receipt`){if(n.receipt!==`received`&&n.receipt!==`read`)return;let e=`${r}:q:${n.queueId}`,t=n.messageId??pe.current.get(e);if(n.queueId&&fe.current.set(e,wL(fe.current.get(e),n.receipt)),t){let e=`${r}:m:${t}`;fe.current.set(e,wL(fe.current.get(e),n.receipt));let o=(i?C.current:J.current.get(r)??[]).find(e=>e.id===t);o&&a([q(o)])}Ce(r,e=>({...e,queued:e.queued.map(e=>e.queueId===n.queueId?{...e,deliveryReceipt:wL(e.deliveryReceipt,n.receipt)}:e)}))}else if(n.turnId&&(n.type===`agent_stream`||n.type===`agent_tool`||n.type===`agent_tool_result`))n.type===`agent_stream`&&we(r);else if(n.type===`agent_turn_done`)we(r),n.messageId&&n.fullText&&a([{id:n.messageId,conversation_id:r,role:`assistant`,content:n.fullText,created_at:n.timestamp??new Date().toISOString(),...n.turnId?{core_turn_id:n.turnId}:{},...n.origin?{turn_origin:n.origin}:{}}]);else if(n.type===`agent_stream`)we(r),Ce(r,e=>({...e,isStreaming:!0,streamingText:e.streamingText+(n.delta??``)}));else if(n.type===`agent_tool`)Ce(r,e=>({...e,isStreaming:!0,liveTools:[...e.liveTools,{id:`t${xL++}`,tool:n.tool??`tool`,...n.input?{input:n.input}:{},...n.toolId?{toolId:n.toolId}:{},...n.timestamp?{at:n.timestamp}:{}}].slice(-200)}));else if(n.type===`agent_tool_result`)Ce(r,e=>{let t=[...e.liveTools],r=n.toolId?t.findIndex(e=>e.toolId===n.toolId):-1;if(r===-1){for(let e=t.length-1;e>=0;e--)if(t[e].output===void 0){r=e;break}}return r===-1?e:(t[r]={...t[r],output:n.output??``,...n.isError?{isError:!0}:{}},{...e,liveTools:t})});else if(n.type===`agent_partial`){let e=n.fullText??``;e&&a([{id:n.messageId??`partial-${r}-${n.timestamp??Date.now()}`,conversation_id:r,role:`assistant`,content:e,created_at:n.timestamp??new Date().toISOString()}])}else if(n.type===`agent_done`){xe.current.delete(r),we(r);let e=n.fullText??``;n.messageId&&e?a([{id:n.messageId,conversation_id:r,role:`assistant`,content:e,created_at:n.timestamp??new Date().toISOString(),...n.coreTurnId?{core_turn_id:n.coreTurnId,turn_origin:`user`}:{}}]):i&&e&&x(t=>{let n=t[t.length-1];return n&&n.role===`assistant`&&n.content===e&&!n.id.startsWith(`local-`)?t:[...t,{id:`local-${Date.now()}`,conversation_id:r,role:`assistant`,content:e,created_at:new Date().toISOString()}]}),Ce(r,e=>({...tL,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}))}else if(n.type===`agent_error`){xe.current.delete(r),we(r),Ce(r,e=>({...tL,queued:e.queued,turnTools:e.liveTools.length?e.liveTools:e.turnTools}));let e=bL(n);t||K.error(e),i&&x(t=>[...t,{id:`err-${Date.now()}`,conversation_id:r,role:`assistant`,content:`⚠️ ${e}`,created_at:new Date().toISOString()}])}else if(n.type===`agent_queued`){if(n.queueId&&ue.current.has(n.queueId))return;Ce(r,e=>{let t=wL(n.deliveryReceipt??n.delivery_receipt,fe.current.get(`${r}:q:${n.queueId}`)),i={queueId:n.queueId??`srv-${SL++}`,text:n.text??``,contextRefs:n.contextRefs,attachmentIds:n.attachmentIds,deliveryMode:n.deliveryMode,...t?{deliveryReceipt:t}:{},timestamp:n.timestamp};return n.queueId&&e.queued.some(e=>e.queueId===n.queueId)?{...e,queued:e.queued.map(e=>e.queueId===n.queueId?{...e,...i,deliveryReceipt:wL(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(n.type===`agent_steered`){if(!n.messageId)return;if(he.current.has(n.messageId)){n.queueId&&ue.current.add(n.queueId),Ce(r,e=>({...e,queued:e.queued.filter(e=>e.queueId!==n.queueId)}));return}he.current.add(n.messageId),n.queueId&&ue.current.add(n.queueId),pe.current.set(`${r}:q:${n.queueId}`,n.messageId);let e=wL(n.delivery_receipt??n.deliveryReceipt,fe.current.get(`${r}:q:${n.queueId}`)),t=[];n.assistantSegment&&t.push({...n.assistantSegment,conversation_id:r,role:`assistant`}),t.push(q({id:n.messageId,conversation_id:r,role:`user`,content:n.text??``,context_refs:n.contextRefs??[],attachment_ids:n.attachmentIds??[],delivery_status:n.deliveryStatus??`delivered`,...e?{delivery_receipt:e}:{},created_at:n.timestamp??new Date().toISOString()})),a(t),Ce(r,e=>({...e,queued:e.queued.filter(e=>e.queueId!==n.queueId),streamingText:n.assistantSegment?``:e.streamingText}))}else if(n.type===`agent_dequeued`||n.type===`agent_input_started`){if(i&&n.queueId&&(C.current=C.current.filter(e=>e.id!==`local-u-${n.queueId}`),x(e=>e.filter(e=>e.id!==`local-u-${n.queueId}`))),n.queueId&&ue.current.has(n.queueId))return;if(n.queueId&&ue.current.add(n.queueId),Ce(r,e=>({...e,queued:n.queueId?e.queued.filter(e=>e.queueId!==n.queueId):e.queued.slice(1),isStreaming:!0,streamingText:``,liveTools:[]})),n.text){n.messageId&&pe.current.set(`${r}:q:${n.queueId}`,n.messageId);let e=wL(n.delivery_receipt??n.deliveryReceipt,fe.current.get(`${r}:q:${n.queueId}`));a([q({id:n.messageId??`local-u-${Date.now()}`,conversation_id:r,role:`user`,content:n.text,context_refs:n.contextRefs??[],attachment_ids:n.attachmentIds??[],...n.messageId?{delivery_status:`delivered`}:{},...e?{delivery_receipt:e}:{},created_at:n.timestamp??new Date().toISOString()})])}}else if(n.type===`agent_queue_cleared`)_e.current.set(r,(_e.current.get(r)??0)+1),n.messages?.length&&a(n.messages),Ce(r,e=>({...e,queued:[]}));else if(n.type===`agent_queue_removed`){if(!n.queueId)return;ue.current.add(n.queueId),de.current.add(n.queueId),Ce(r,e=>({...e,queued:e.queued.filter(e=>e.queueId!==n.queueId)}))}else if(n.type===`agent_queue_edited`)Ce(r,e=>({...e,queued:e.queued.map(e=>n.queueId&&e.queueId===n.queueId?{...e,text:n.text??e.text,contextRefs:n.contextRefs??e.contextRefs,deliveryMode:n.deliveryMode??e.deliveryMode}:e)}));else if(n.type===`agent_run_failure`){if(we(r),i){let{type:e,conversationId:t,messageId:i,timestamp:a,...o}=n;if(typeof i==`string`&&!C.current.some(e=>e.id===i)){let e={id:i,conversation_id:r,role:`system`,content:JSON.stringify(o),created_at:typeof a==`string`?a:new Date().toISOString()};C.current=[...C.current,e],x(t=>t.some(e=>e.id===i)?t:[...t,e])}}}else if(n.type===`agent_pr_decision`&&(we(r),i)){let t=Ko(e);if(t){ye.current++;let e=vL(C.current,r,t);C.current=e,x(e=>{let n=vL(e,r,t);return C.current=n,n})}}}),()=>a(r)):void 0,[i,a,Ce,we,Ne,r,t]);let Re=(0,Q.useCallback)(async(e,t)=>{let n=++be.current,r=ge.current.get(e)??0;ye.current++;let{conversation:i,messages:a,pendingMessages:o,live:s}=await Oo(e);if(t?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);if(n!==be.current){if(t)throw new DOMException(`The mission changed during restoration`,`AbortError`);return}ye.current++;let c=TL(a,J.current.get(e)??[]).map(q);for(let e of c)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&he.current.add(e.id);y(i),C.current=c,x(c),Te(e),r===(ge.current.get(e)??0)&&(o!==void 0||s)&&Ce(e,t=>({...t,...s?{isStreaming:s.isStreaming,streamingText:s.streamingText}:{},queued:o?.filter(e=>!ue.current.has(e.queueId)).map(t=>me(e,t))??t.queued}))},[Te,Ce]),ze=(0,Q.useCallback)(async()=>{let e=se.current;if(!e)return;let t=ye.current,n=ge.current.get(e)??0,r=S.current.get(e)??0;try{let i=await Oo(e);if(se.current!==e||ye.current!==t)return;if(r===(S.current.get(e)??0)&&(y(t=>t?.id===e?i.conversation:t),_(t=>t.map(t=>t.id===e?i.conversation:t))),(i.pendingMessages!==void 0||i.live)&&n===(ge.current.get(e)??0)){let t=TL(i.messages,J.current.get(e)??[]).map(q);for(let e of t)(e.delivery_status===`delivered`||e.delivery_status===`interrupted`)&&he.current.add(e.id);x(e=>TL(t,e.filter(e=>e.id.startsWith(`local-u-`)&&!t.some(t=>t.role===`user`&&t.content===e.content)))),Ce(e,t=>({...t,...i.live?{isStreaming:i.live.isStreaming,streamingText:i.live.streamingText}:{},queued:i.pendingMessages?.filter(e=>!ue.current.has(e.queueId)).map(t=>me(e,t))??t.queued}))}let a=i.messages.filter(e=>e.role===`system`).map(e=>qo(e.content)).filter(e=>e!==null);if(a.length===0)return;x(t=>{let n=a.reduce((t,n)=>vL(t,e,n),t);return C.current=n,n})}catch{}},[Ce]),Be=(0,Q.useCallback)(async()=>{try{let e=new Map(ge.current),t=await Eo(),n=new Set(t.turns.map(e=>e.conversationId)),r=Date.parse(t.capturedAt),i=[...le.current].flatMap(([t,i])=>{if(!i.isStreaming||n.has(t)||(e.get(t)??0)!==(ge.current.get(t)??0))return[];let a=xe.current.get(t);return a&&Date.parse(a)>r?[]:[t]});k(i=>{let a=new Map(i);for(let[t,o]of i){if(!o.isStreaming||n.has(t)||(e.get(t)??0)!==(ge.current.get(t)??0))continue;let i=xe.current.get(t);i&&Date.parse(i)>r||a.set(t,{...tL,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)!==(ge.current.get(t)??0))continue;let r=a.get(t)??tL;a.set(t,{...r,isStreaming:!0,streamingText:n.streamingText??r.streamingText,queued:n.pendingMessages?.filter(e=>!ue.current.has(e.queueId)).map(e=>me(t,e))??r.queued})}return a});for(let e of i)xe.current.delete(e);let a=se.current;if(a&&i.includes(a)){let e=`interrupted-${a}-${t.snapshotVersion}`;x(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=()=>{Ne(),ze()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[ze,Ne]),(0,Q.useEffect)(()=>{Ie&&(Ne(),ze())},[Ie,Ne,ze]);let Ve=(0,Q.useRef)(o);(0,Q.useEffect)(()=>{let e=Ve.current;Ve.current=o,o===`connected`&&e!==`connected`&&(Ne(),Pe(),Fe(),ze(),Be())},[o,Ne,Pe,Fe,ze,Be]);let He=(0,Q.useCallback)(async()=>{if(v)return v;if(f||t)throw Error(`This view is reserved for its mission.`);let e=await bo();if(_(e),T(t=>{let n=aL(rL(),e);return n.size===t.size&&[...n].every(e=>t.has(e))?t:(iL(n),n)}),e.length>0)return await Re(e[0].id),e[0];let n=await Do({});return _(e=>[n,...e.filter(e=>e.id!==n.id)]),y(n),x([]),n},[v,Re,f,t]),Ue=(0,Q.useCallback)(()=>{h(`open`),Ne(),Pe(),Fe(),He()},[Ne,Pe,Fe,He]),We=(0,Q.useCallback)(()=>h(`hidden`),[]),Ge=(0,Q.useCallback)(()=>h(`minimized`),[]),[Ke,qe]=(0,Q.useState)(!1),Je=(0,Q.useRef)(null),Ye=(0,Q.useCallback)(()=>{Je.current?.abortAndReset(),qe(!1)},[]),Xe=gI(Ke,{onFinished:Ye});Je.current=Xe;let Ze=(0,Q.useCallback)(()=>{f||t||(qe(!0),s!==`agent`&&Ue())},[s,Ue,f,t]),Qe=(0,Q.useCallback)(()=>{h(e=>e===`open`?`minimized`:`open`),m!==`open`&&(Ne(),Pe(),Fe(),He())},[m,Ne,Pe,Fe,He]),et=(0,Q.useCallback)(async()=>{if(!p(v?.id))throw Error(`This mission is active in another window.`);if(v)return v;if(ve.current)return ve.current;let e=Do({pinnedProjectId:ne.current,provider:oe.current.provider,model:oe.current.model,tierLevel:oe.current.tierLevel,reasoningEffort:oe.current.effort}).then(e=>(Si(e.id),_(t=>[e,...t.filter(t=>t.id!==e.id)]),y(e),x([]),e)).finally(()=>{ve.current=null});return ve.current=e,e},[v]),tt=(0,Q.useCallback)(async(e,t)=>{if(!p(v?.id))return{accepted:!1};let n=e.trim();if(!n)return{accepted:!1};let r=v??await et();ge.current.set(r.id,(ge.current.get(r.id)??0)+1);let i=ge.current.get(r.id),a=_e.current.get(r.id)??0,o=t?.queueId??`q-${Date.now()}-${SL++}`,s=new Date().toISOString();xe.current.set(r.id,s),_(e=>[{...e.find(e=>e.id===r.id)??r,updated_at:s},...e.filter(e=>e.id!==r.id)]),y(e=>e&&e.id===r.id?{...e,updated_at:s}:e);let c={id:`local-u-${o}`,conversation_id:r.id,role:`user`,content:n,attachment_ids:t?.attachmentIds??[],context_refs:t?.contextRefs??[],delivery_receipt:`sent`,created_at:s},l=le.current.get(r.id)?.isStreaming===!0,u={queueId:o,text:n,contextRefs:t?.contextRefs,attachmentIds:t?.attachmentIds,deliveryMode:`queue`,deliveryReceipt:`sent`,timestamp:s};l?Ce(r.id,e=>({...e,queued:e.queued.some(e=>e.queueId===o)?e.queued.map(e=>e.queueId===o?{...u,deliveryReceipt:wL(e.deliveryReceipt,u.deliveryReceipt),deliveryMode:e.deliveryMode??u.deliveryMode,timestamp:e.timestamp??u.timestamp}:e):[...e.queued,u]})):(x(e=>[...e,c]),Ce(r.id,e=>({...e,isStreaming:!0,streamingText:``,liveTools:[]})));let d=t?.attachmentIds&&t.attachmentIds.length?{ids:t.attachmentIds}:void 0;try{let e=t?.contextRefs&&t.contextRefs.length?t.contextRefs:void 0,s=await jo(r.id,n,{tierLevel:r.tier_level,attachments:d,queueId:o,contextRefs:e});if(s.removed){ue.current.add(o),de.current.add(o);let e=!l&&i===ge.current.get(r.id);return se.current===r.id&&x(e=>e.filter(e=>e.id!==c.id)),Ce(r.id,t=>({...t,queued:t.queued.filter(e=>e.queueId!==o),...e?{isStreaming:!1}:{}})),e&&xe.current.delete(r.id),{accepted:!0,conversationId:r.id}}if(s.message){pe.current.set(`${r.id}:q:${o}`,s.message.id);let e=wL(s.message.delivery_receipt,fe.current.get(`${r.id}:q:${o}`)),t=q({...s.message,...e?{delivery_receipt:e}:{}});return ue.current.add(o),J.current.set(r.id,TL(J.current.get(r.id)??[],[t]).slice(-500)),se.current===r.id&&x(e=>TL(e.filter(e=>e.id!==c.id),[t])),Ce(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})),s.duplicate&&Be(),{accepted:!0,conversationId:r.id}}if(a!==(_e.current.get(r.id)??0))return x(e=>e.filter(e=>e.id!==c.id)),{accepted:!0,conversationId:r.id};let f=s?.queued===!0;return f&&!l?(x(e=>e.filter(e=>e.id!==c.id)),ue.current.has(o)||Ce(r.id,e=>e.queued.some(e=>e.queueId===o)?e:{...e,queued:[...e.queued,{...u,deliveryMode:s.deliveryMode??u.deliveryMode}]})):!f&&l&&!ue.current.has(o)&&(Ce(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o),isStreaming:!0})),x(e=>[...e,c])),{accepted:!0,conversationId:r.id}}catch(e){return ue.current.has(o)||a!==(_e.current.get(r.id)??0)?{accepted:!0,conversationId:r.id}:(xe.current.delete(r.id),l?Ce(r.id,e=>({...e,queued:e.queued.filter(e=>e.queueId!==o)})):(Ce(r.id,e=>({...e,isStreaming:!1,streamingText:``,liveTools:[]})),x(e=>e.filter(e=>e.id!==c.id))),K.error(e instanceof Error?e.message:`Failed to send message.`),{accepted:!1,conversationId:r.id})}},[v,et,Ce,Be]),nt=(0,Q.useCallback)(async()=>{if(!(!v||!p(v.id)))try{await Lo(v.id),_e.current.set(v.id,(_e.current.get(v.id)??0)+1),ge.current.set(v.id,(ge.current.get(v.id)??0)+1),Ce(v.id,()=>null)}catch(e){K.error(e instanceof Error?e.message:`Failed to stop the agent.`)}},[v,Ce]),rt=(0,Q.useCallback)(async(e,t)=>{let n=v;if(!n||!p(n.id)||le.current.get(n.id)?.queued.find(t=>t.queueId===e)?.deliveryMode===`steer`)return`conflict`;let r=await Ro(n.id,e,t);return r===`saved`&&Ce(n.id,n=>({...n,queued:n.queued.map(n=>n.queueId===e?{...n,text:t}:n)})),r},[v,Ce]),it=(0,Q.useCallback)(async e=>{let t=v,n=t&&le.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!p(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await zo(t.id,e);return r===`saved`?(ge.current.set(t.id,(ge.current.get(t.id)??0)+1),Ce(t.id,t=>({...t,queued:t.queued.map(t=>t.queueId===e?{...t,deliveryMode:`steer`}:t)}))):se.current===t.id&&ze(),r},[v,Ce,ze]),at=(0,Q.useCallback)(async e=>{let t=v,n=t&&le.current.get(t.id)?.queued.find(t=>t.queueId===e);if(!t||!p(t.id)||!n||n.deliveryMode===`steer`)return`conflict`;let r=await Bo(t.id,e);return r===`saved`?(ue.current.add(e),de.current.add(e),ge.current.set(t.id,(ge.current.get(t.id)??0)+1),Ce(t.id,t=>({...t,queued:t.queued.filter(t=>t.queueId!==e)}))):se.current===t.id&&ze(),r},[v,Ce,ze]),ot=(0,Q.useCallback)(e=>ue.current.has(e)&&!de.current.has(e),[]),st=(0,Q.useCallback)(async e=>{if(!v||!p(v.id))return;let t=(S.current.get(v.id)??0)+1;S.current.set(v.id,t);let n=await ko(v.id,e);S.current.get(v.id)===t&&(y(e=>e?.id===n.id?n:e),_(e=>e.map(e=>e.id===n.id?n:e)))},[v]),ct=(0,Q.useCallback)(async e=>{p(v?.id)&&(cL(e),v?await st({tierLevel:e}):U(e))},[v,st]),lt=(0,Q.useCallback)(async()=>{let e=((v?.tier_level??H)+1)%4;await ct(e)},[v,H,ct]),ut=(0,Q.useCallback)(async e=>{v?await st({provider:e}):(L.current=!0,re(e),ae(null),G(null))},[v,st]);(0,Q.useEffect)(()=>{v||L.current||I.length===0||I.includes(V)||(re(rn(I)),ae(null),G(null))},[v,I,V]);let dt=(0,Q.useCallback)(async e=>{v?await st({model:e}):(ae(e),G(null))},[v,st]),ft=(0,Q.useCallback)(async e=>{v?await st({reasoningEffort:e}):G(e)},[v,st]),pt=(0,Q.useCallback)(async e=>{f||t||!p(v?.id)||(v?await st({pinnedProjectId:e}):B(e),!v&&e&&s===`agent`&&c(e))},[v,st,s,c,f,t]),mt=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let e=mt.current;if(mt.current=l,!(e===void 0||e===l)&&!(f||t||s!==`agent`||!l)){if(!v){B(l);return}C.current.length>0||v.pinned_project_id!==l&&st({pinnedProjectId:l})}},[l,s,v,st,f,t]);let Y=(0,Q.useCallback)(e=>{f||t||(Ye(),y(null),x([]),B(e??null),L.current=!1,re(rn(te.current)),ae(null),U(sL()),G(null))},[Ye,f,t]),ht=(0,Q.useCallback)(async e=>{if(f||t)return;Ye();let n=await Do({pinnedProjectId:e===void 0?v?.pinned_project_id??null:e,tierLevel:sL()});_(e=>[n,...e.filter(e=>e.id!==n.id)]),y(n),x([])},[v,Ye,f,t]),gt=(0,Q.useCallback)(async(e,n)=>{if(!(t&&e!==t)&&!(f&&!t&&!n?.windowRestore&&d.current.current?.conversationId!==e)&&!(!t&&!f&&!n?.windowRestore&&await d.current.focus(e))){if(n?.signal?.aborted)throw new DOMException(`Window transfer cancelled`,`AbortError`);Ye(),await Re(e,n?.signal),n?.windowRestore&&s!==`agent`&&h(`open`)}},[Re,Ye,f,s,t]),_t=(0,Q.useCallback)(async e=>{p(e)&&(await Ao(e),await d.current.discard(e),_(t=>t.filter(t=>t.id!==e)),T(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),iL(n),n}),Ce(e,()=>null),se.current===e&&(y(null),x([])))},[Ce]),vt=(0,Q.useCallback)(async(e,t)=>{if(!p(e))return;let n=t.trim()||null;S.current.set(e,(S.current.get(e)??0)+1);let r;_(t=>t.map(t=>t.id===e?(r=t.title,{...t,title:n}):t)),y(t=>t&&t.id===e?{...t,title:n}:t);try{await ko(e,{title:n})}catch(t){throw _(t=>t.map(t=>t.id===e?{...t,title:r??null}:t)),y(t=>t&&t.id===e?{...t,title:r??null}:t),t}},[]),yt=(0,Q.useCallback)(e=>{T(()=>{let t=new Set(rL());return t.has(e)?t.delete(e):t.add(e),iL(t),t})},[]),bt=(0,Q.useCallback)(async()=>{N(!0);try{await es(),await Pe()}catch(e){K.error(e instanceof Error?e.message:`Failed to enable MCP.`)}finally{N(!1)}},[Pe]),xt=(0,Q.useMemo)(()=>({visibility:m,open:Ue,close:We,minimize:Ge,toggle:Qe,conversations:g,active:v,messages:b,streamingText:De,isStreaming:Oe,liveTools:ke,turnTools:Ae,queuedMessages:je,streamingConversationIds:Me,liveByConversation:O,unreadConversationIds:E,favoriteConversationIds:w,mcpEnabled:A,enablingMcp:M,enableMcpServer:bt,providersReady:P,send:tt,abort:nt,editQueuedMessage:rt,steerQueuedMessage:it,removeQueuedMessage:at,wasQueueConsumed:ot,cycleTier:lt,setTier:ct,setProvider:ut,setModel:dt,setPinnedProject:pt,newConversation:ht,startNewConversation:Y,materializeDraftConversation:et,draftPinnedProjectId:z,draftProvider:V,draftModel:ie,draftTierLevel:H,draftEffort:W,setEffort:ft,selectConversation:gt,deleteConversation:_t,renameConversation:vt,toggleFavoriteConversation:yt,refreshConversations:Ne,applyPrDecisionSnapshot:Se,builderMode:{active:Ke,enter:Ze,exit:Ye,session:Xe}}),[m,Ue,We,Ge,Qe,Ke,Ze,Ye,Xe,g,v,b,De,Oe,ke,Ae,je,Me,O,E,w,A,M,bt,P,tt,nt,rt,it,at,ot,lt,ct,ut,dt,pt,ht,Y,et,z,V,ie,H,W,ft,gt,_t,vt,yt,Ne,Se]),St=!t&&$e&&s!==`agent`;return(0,$.jsxs)(yL.Provider,{value:xt,children:[(0,$.jsx)(_s,{children:t?e:(0,$.jsx)(so,{primaryId:v?.id??null,children:e})}),St&&m===`open`&&(0,$.jsx)(BI,{}),St&&m!==`open`&&(0,$.jsx)(qI,{})]})}var DL={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 OL(){return(0,Q.useContext)(yL)??DL}var kL=new Map;function AL(){let e=OL(),t=fj(),n=ce(),r=Ya(),{registerHandlers:i}=Mi(),{t:a}=U(`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&&kL.set(r,t.captureWorkspace());let i=kL.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){VS(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(WS(e.conversationId))throw Error(i(`window.finishPending`));return{version:1,...e,capturedAt:Date.now(),composer:gi(e.conversationId),scroll:BS(e.conversationId),workspace:{...n.captureWorkspace(),...e.projectId?{codeSelection:NS(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&&kL.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,kL.set(t.conversationId,e.workspace),vi(t.conversationId,e.composer),t.projectId&&(e.workspace.codeSelection&&PS(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),VS(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 jL=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 ML(this.width*e,this.height*e)}[gt](){return{width:this.width,height:this.height}}toJSON(){return this[gt]()}},ML=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 jL(this.width/e,this.height/e)}[gt](){return{width:this.width,height:this.height}}toJSON(){return this[gt]()}},NL=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof jL?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof ML?this.size:this.size.toPhysical(e)}[gt](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[gt]()}},PL=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 FL(this.x*e,this.y*e)}[gt](){return{x:this.x,y:this.y}}toJSON(){return this[gt]()}},FL=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 PL(this.x/e,this.y/e)}[gt](){return{x:this.x,y:this.y}}toJSON(){return this[gt]()}},IL=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof PL?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof FL?this.position:this.position.toPhysical(e)}[gt](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[gt]()}},LL;(function(e){e[e.Critical=1]=`Critical`,e[e.Informational=2]=`Informational`})(LL||={});var RL=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},zL;(function(e){e.None=`none`,e.Normal=`normal`,e.Indeterminate=`indeterminate`,e.Paused=`paused`,e.Error=`error`})(zL||={});function BL(){return new UL(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function VL(){return Y(`plugin:window|get_all_windows`).then(e=>e.map(e=>new UL(e,{skip:!0})))}var HL=[`tauri://created`,`tauri://error`],UL=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 VL()).find(t=>t.label===e)??null}static getCurrent(){return BL()}static async getAll(){return VL()}static async getFocusedWindow(){for(let e of await VL())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)}:Nr(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)}:Fr(e,t,{target:{kind:`Window`,label:this.label}})}async emit(e,t){if(HL.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return Pr(e,t)}async emitTo(e,t,n){if(HL.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return Ir(e,t,n)}_handleTauriEvent(e,t){return HL.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 FL(e))}async outerPosition(){return Y(`plugin:window|outer_position`,{label:this.label}).then(e=>new FL(e))}async innerSize(){return Y(`plugin:window|inner_size`,{label:this.label}).then(e=>new ML(e))}async outerSize(){return Y(`plugin:window|outer_size`,{label:this.label}).then(e=>new ML(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===LL.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 NL?e:new NL(e)})}async setMinSize(e){return Y(`plugin:window|set_min_size`,{label:this.label,value:e instanceof NL?e:e?new NL(e):null})}async setMaxSize(e){return Y(`plugin:window|set_max_size`,{label:this.label,value:e instanceof NL?e:e?new NL(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 IL?e:new IL(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:Ia(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 IL?e:new IL(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?Ia(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(Lr.WINDOW_RESIZED,t=>{t.payload=new ML(t.payload),e(t)})}async onMoved(e){return this.listen(Lr.WINDOW_MOVED,t=>{t.payload=new FL(t.payload),e(t)})}async onCloseRequested(e){return this.listen(Lr.WINDOW_CLOSE_REQUESTED,async t=>{let n=new RL(t);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let t=await this.listen(Lr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new FL(t.payload.position)}})}),n=await this.listen(Lr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new FL(t.payload.position)}})}),r=await this.listen(Lr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new FL(t.payload.position)}})}),i=await this.listen(Lr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}async onFocusChanged(e){let t=await this.listen(Lr.WINDOW_FOCUS,t=>{e({...t,payload:!0})}),n=await this.listen(Lr.WINDOW_BLUR,t=>{e({...t,payload:!1})});return()=>{t(),n()}}async onScaleChanged(e){return this.listen(Lr.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(Lr.WINDOW_THEME_CHANGED,e)}},WL;(function(e){e.Disabled=`disabled`,e.Throttle=`throttle`,e.Suspend=`suspend`})(WL||={});var GL;(function(e){e.Default=`default`,e.FluentOverlay=`fluentOverlay`})(GL||={});var KL;(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`})(KL||={});var qL;(function(e){e.FollowsWindowActiveState=`followsWindowActiveState`,e.Active=`active`,e.Inactive=`inactive`})(qL||={});var JL=(0,Q.lazy)(()=>c(()=>import(`./AgentBrowserCapture-BussBbN3.js`).then(e=>({default:e.AgentBrowserCapture})),__vite__mapDeps([90,1,7,42,43,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,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,77,78,79,80])));function YL(){let{browserOpen:e}=fj(),{active:t}=OL(),n=Mi(),r=!n.current&&n.transfers.some(e=>e.conversationId===t?.id&&e.state===`detached`),{activeProjectId:i}=ce(),a=t?.pinned_project_id??i;return!e||!a||r?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(JL,{projectId:a,conversationId:t?.id??null})})}function XL(e,t){e=Math.max(1,e);let n=e>1&&t>=640?2:1,r=Array.from({length:n},(t,r)=>Math.ceil((e-r)/n)),i=(e,t)=>t?i(t,e%t):e,a=r.reduce((e,t)=>e*t/i(e,t),1),o=a/Math.max(...r);return{columns:n,rows:a,minimumRowHeight:e>1?220/o:0,placements:Array.from({length:e},(e,t)=>{let i=t%n,o=a/r[i];return{gridColumn:i+1,gridRow:`${Math.floor(t/n)*o+1} / span ${o}`}})}}function ZL({id:e,onClose:t}){let{t:n}=U(`agent`),{active:r,selectConversation:i}=OL(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let t=new AbortController;return o(!1),i(e,{windowRestore:!0,signal:t.signal}).catch(()=>{t.signal.aborted||o(!0)}),()=>t.abort()},[e,s,i]),a?(0,$.jsxs)(`div`,{role:`alert`,className:`flex h-full flex-col items-center justify-center gap-3 p-4 text-sm`,children:[(0,$.jsx)(`p`,{children:n(`split.loadFailed`)}),(0,$.jsx)(`button`,{onClick:()=>c(e=>e+1),children:n(`split.retry`)}),(0,$.jsx)(`button`,{onClick:t,children:n(`split.close`)})]}):r?.id===e?(0,$.jsxs)(fo,{paneId:e,onClose:t,children:[(0,$.jsx)(fR,{splitPane:!0}),(0,$.jsx)(YL,{})]}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-sm`,children:[(0,$.jsx)(`span`,{role:`status`,children:n(`window.loading`)}),(0,$.jsx)(`button`,{onClick:t,children:n(`split.close`)})]})}function QL({children:e}){let{t}=U(`agent`),{conversations:n,active:r}=OL(),i=co(),a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(window.innerWidth),c=i.conversationIds.filter(e=>e!==r?.id),l=c.length+ +!!i.primaryVisible,u=XL(l,o);return(0,Q.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{e.clientWidth&&s(e.clientWidth)},n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[]),(0,Q.useEffect)(()=>{i.focusedId&&Array.from(a.current?.querySelectorAll(`[data-split-id]`)??[]).find(e=>e.dataset.splitId===i.focusedId)?.focus()},[i.focusedId]),(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,ref:a,"data-mission-split-layout":!0,children:(0,$.jsxs)(`div`,{className:`grid min-h-0 flex-1 overflow-auto`,"data-split-count":l,"data-split-columns":u.columns,style:{gridTemplateColumns:`repeat(${u.columns}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${u.rows}, minmax(${u.minimumRowHeight}px, 1fr))`},children:[(0,$.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-col overflow-hidden`,style:{...u.placements[0],display:i.primaryVisible?void 0:`none`},children:(0,$.jsx)(fo,{onClose:c.length?i.closePrimary:null,children:e})},`primary`),c.map((e,r)=>(0,$.jsx)(`section`,{"data-split-id":e,tabIndex:-1,"aria-label":n.find(t=>t.id===e)?.title?.trim()||t(`untitled`),className:`relative min-h-0 min-w-0 overflow-hidden border-l border-t border-border outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary`,style:u.placements[r+ +!!i.primaryVisible],onFocusCapture:()=>i.focus(e),children:(0,$.jsx)(Ni,{children:(0,$.jsx)(uj,{children:(0,$.jsx)(EL,{fixedConversationId:e,children:(0,$.jsx)(ZL,{id:e,onClose:()=>i.close(e)})})})})},e))]})})}var $L=12e-5,eR=36,tR=140,nR=1.5,rR=6;function iR(e,t){return{x:Math.random()*e,y:Math.random()*t,radius:.35+Math.random()*1.25,alpha:.22+Math.random()*.5,drift:nR+Math.random()*(rR-nR)}}function aR(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 oR(){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=aR(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(tR,Math.max(eR,Math.floor(o*s*$L)));a=Array.from({length:e},()=>iR(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 sR=(0,Q.lazy)(()=>c(()=>import(`./AgentModeCodePane-CUjNfeKa.js`).then(e=>({default:e.AgentModeCodePane})),__vite__mapDeps([91,1,7,10,42,54]))),cR=(0,Q.lazy)(()=>c(()=>import(`./AgentModeJobsPane-RVEwyS59.js`).then(e=>({default:e.AgentModeJobsPane})),__vite__mapDeps([92,1,7,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,8,62,54,73,74,76,77,80,93,87,6,44,45,46,47,48,49,50,51,52,53,55,56,57,58,59,60,61,63,64,65,66,67,68,69,70,71,72,75,78,79,81,82,83,84,85,86]))),lR=(0,Q.lazy)(()=>c(()=>import(`./AgentModeAnalyticsPane-BiT1n3BU.js`).then(e=>({default:e.AgentModeAnalyticsPane})),__vite__mapDeps([94,1,7,10,42,62,54,73,74])));function uR(){let e=po(),{t}=U(`agent`);return e?(0,$.jsx)(`button`,{type:`button`,"aria-label":t(`split.close`),title:t(`split.close`),onClick:e,className:`absolute right-2 top-2 rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,$.jsx)(Vn,{className:`h-4 w-4`})}):null}function dR({splitPane:e,children:t}){return e?(0,$.jsx)($.Fragment,{children:t}):(0,$.jsx)(QL,{children:t})}function fR({splitPane:e=!1}={}){let t=mo(),{active:n,refreshConversations:r,builderMode:i}=OL(),{codePaneOpen:a,jobsPaneOpen:o,analyticsPaneOpen:s}=fj(),{activeProjectId:c}=ce(),l=Mi(),u=HS(n?.id??`__new-mission__`),d=!l.current&&l.transfers.some(e=>e.conversationId===n?.id&&e.state===`detached`),f=Pa().id===`galaxy`;(0,Q.useEffect)(()=>{r()},[r]);let p=a&&!!c&&!d,m=o&&!!c&&!d,h=s&&!!c&&!d;return(0,$.jsx)(Kb,{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)(oR,{}),(0,$.jsxs)(`div`,{className:`relative flex h-full min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(jS.div,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 z-0`,animate:{opacity:+(n===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%)`}}),(0,$.jsx)(dR,{splitPane:e,children:i.active?(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(jI,{variant:`inline`})}):n===null?(0,$.jsxs)(`div`,{className:`relative z-10 flex h-full w-full items-center justify-center px-4`,children:[(0,$.jsx)(uR,{}),(0,$.jsx)(jS.div,{layoutId:t,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-[960px]`,children:(0,$.jsx)(KN,{autoFocus:!0})})]}):(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(uF,{variant:`inline`})})})]}),m&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[480px] border-l border-border`}),children:(0,$.jsx)(cR,{projectId:c})}),p&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[520px] border-l border-border`}),children:(0,$.jsx)(sR,{projectId:c,conversationId:n?.id??`__home__`},`${n?.id}:${u}`)}),h&&(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`w-[560px] border-l border-border`}),children:(0,$.jsx)(lR,{})})]})})}var pR=`specrails:terminal-settings-updated`;function mR(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(pR,{detail:e}))}function hR(){return new vR(BL(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function gR(){return Y(`plugin:webview|get_all_webviews`).then(e=>e.map(e=>new vR(new UL(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var _R=[`tauri://created`,`tauri://error`],vR=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 gR()).find(t=>t.label===e)??null}static getCurrent(){return hR()}static async getAll(){return gR()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{let n=this.listeners[e];n.splice(n.indexOf(t),1)}:Nr(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)}:Fr(e,t,{target:{kind:`Webview`,label:this.label}})}async emit(e,t){if(_R.includes(e)){for(let n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return}return Pr(e,t)}async emitTo(e,t,n){if(_R.includes(t)){for(let e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return}return Ir(e,t,n)}_handleTauriEvent(e,t){return _R.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 FL(e))}async size(){return Y(`plugin:webview|webview_size`,{label:this.label}).then(e=>new ML(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 NL?e:new NL(e)})}async setPosition(e){return Y(`plugin:webview|set_webview_position`,{label:this.label,value:e instanceof IL?e:new IL(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(Lr.DRAG_ENTER,t=>{e({...t,payload:{type:`enter`,paths:t.payload.paths,position:new FL(t.payload.position)}})}),n=await this.listen(Lr.DRAG_OVER,t=>{e({...t,payload:{type:`over`,position:new FL(t.payload.position)}})}),r=await this.listen(Lr.DRAG_DROP,t=>{e({...t,payload:{type:`drop`,paths:t.payload.paths,position:new FL(t.payload.position)}})}),i=await this.listen(Lr.DRAG_LEAVE,t=>{e({...t,payload:{type:`leave`}})});return()=>{t(),r(),n(),i()}}};function yR(e){return`'${e.replace(/'/g,`'\\''`)}'`}function bR(e){if(/[\x00-\x1f"%!]/.test(e))throw Error(`unsafe-cmd-path`);return`"`+e+`"`}function xR(e){return`'${e.replace(/'/g,`''`)}'`}function SR(e,t,n=`powershell`){return t?n===`cmd`?bR(e):xR(e):yR(e)}function CR(e,t,n=`powershell`){return e.map(e=>SR(e,t,n)).join(` `)}function wR(e){return/(?:^|[\\/])cmd(?:\.exe)?$/i.test(e??``)?`cmd`:`powershell`}async function TR(e){if(!S())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&&DR(s,u.viewportEl.getBoundingClientRect(),window.devicePixelRatio||1))try{u.writeText(CR(o,i,wR(u.shell)))}catch{K.error(N.t(`terminal:errors.pathPasteUnsafe`))}},o=ER((()=>{try{return hR()}catch{return null}})());o&&t.push(await o(a));let s=ER((()=>{try{return BL()}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 ER(e){let t=e?.onDragDropEvent;return typeof t==`function`?t.bind(e):null}function DR(e,t,n){let r=Number.isFinite(n)&&n>0?n:1;return OR(e.x/r,e.y/r,t)}function OR(e,t,n){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function kR({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 AR({x:e,y:t,providers:n,onSelect:r,onClose:i}){let{t:a}=U(`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:sn(e)})},e))})}var jR=(0,Q.forwardRef)(function({isOpen:e,className:t,...n},r){let{t:i}=U(`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 MR({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}=U(`terminal`),g=!!i&&i.length>1,_=sn(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)(NR,{label:y,disabled:!t,onClick:e=>o(e?{x:e.clientX,y:e.clientY}:void 0),children:(0,$.jsx)(Ln,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{label:h(`topBar.openInBrowser`),onClick:s,onContextMenu:e=>{e.preventDefault(),u({x:e.clientX,y:e.clientY})},children:(0,$.jsx)(ge,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{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)(_c,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{label:t?h(`topBar.newTerminal`):v,disabled:!t,onClick:a,children:(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{label:h(`topBar.killActive`),disabled:!n,onClick:f,children:(0,$.jsx)(Rn,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(NR,{label:h(e===`maximized`?`topBar.restorePanel`:`topBar.maximizePanel`),onClick:p,children:e===`maximized`?(0,$.jsx)(Yl,{className:`h-3.5 w-3.5`}):(0,$.jsx)(ql,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(jR,{isOpen:!0,onClick:m})]})]})}function NR({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 PR({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)(FR,{session:e,active:e.id===t,onActivate:()=>n(e.id),onRename:t=>r(e.id,t),onKill:()=>i(e.id)},e.id))})})}function FR({session:e,active:t,onActivate:n,onRename:r,onKill:i}){let{t:a}=U(`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)(xd,{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)(jn,{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)(Vn,{className:`h-3 w-3`})})]})})}function IR({search:e,onClose:t}){let{t:n}=U(`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)(Sn,{size:14})}),(0,$.jsx)(`button`,{type:`button`,title:n(`search.next`),onClick:h,className:`text-[#f8f8f2] hover:text-white p-1`,children:(0,$.jsx)(rc,{size:14})}),(0,$.jsx)(LR,{label:`Aa`,title:n(`search.matchCase`),active:o,onToggle:()=>s(e=>!e)}),(0,$.jsx)(LR,{label:`.*`,title:n(`search.regex`),active:c,onToggle:()=>l(e=>!e)}),(0,$.jsx)(LR,{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)(Vn,{size:14})})]})}function LR({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 RR({x:e,y:t,term:n,cwd:r,hasReveal:i,onClose:a,onOpenSearch:o,onReveal:s,onSaveScrollback:c}){let{t:l}=U(`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&&(Ba(m),a())}function _(){za().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)(zR,{onClick:g,disabled:!h,label:l(`common:actions.copy`),shortcut:p+`C`}),(0,$.jsx)(zR,{onClick:_,label:l(`contextMenu.paste`),shortcut:p+`V`}),(0,$.jsx)(zR,{onClick:v,label:l(`contextMenu.selectAll`),shortcut:p+`A`}),(0,$.jsx)(BR,{}),(0,$.jsx)(zR,{onClick:y,label:l(`contextMenu.clear`),shortcut:p+`K`}),(0,$.jsx)(zR,{onClick:b,label:l(`contextMenu.search`),shortcut:p+`F`}),(0,$.jsx)(zR,{onClick:x,label:l(`contextMenu.saveScrollback`)}),r&&i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(BR,{}),(0,$.jsx)(zR,{onClick:S,label:l(`contextMenu.openPath`,{path:VR(r,40)})})]})]})}function zR({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 BR(){return(0,$.jsx)(`div`,{className:`my-1 border-t border-[#44475a]`})}function VR(e,t){return e.length<=t?e:`…`+e.slice(e.length-t+1)}async function HR(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(`
|
|
49
49
|
`);if(S()){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 UR({sessionId:e}){let[t,n]=(0,Q.useState)(()=>Qi(e));return(0,Q.useEffect)(()=>Zi(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 WR({sessionId:e}){let{t}=U(`terminal`),[n,r]=(0,Q.useState)(Qi(e).openPreExec?.startedAt??null),[i,a]=(0,Q.useState)(Date.now());if((0,Q.useEffect)(()=>Zi(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:GR(o,t)})}function GR(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 KR({activeId:e}){let{t}=U(`terminal`),n=(0,Q.useRef)(null),r=Ya(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=S();(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=>qR(e)).filter(e=>!!e);if(i.length===0)return!1;let a=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);try{return m(CR(i,a,wR(e?r.getShell?.(e):null)))}catch{return K.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=>qR(e)).filter(e=>!!e);if(i.length>0){n.preventDefault(),n.stopPropagation();let a=typeof navigator<`u`&&/Win/i.test(navigator.platform||``);try{m(CR(i,a,wR(e?r.getShell?.(e):null)))}catch{K.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(),Ba(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=>{JR(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),p(!0))},onDragOver:e=>{JR(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),p(!0))},onDragLeave:()=>p(!1),onDrop:e=>{JR(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation(),h(e.dataTransfer.files)),p(!1)},children:[e&&(0,$.jsx)(UR,{sessionId:e}),e&&(0,$.jsx)(WR,{sessionId:e}),i&&l&&(0,$.jsx)(IR,{search:l,onClose:()=>a(!1)}),o&&u&&(0,$.jsx)(RR,{x:o.x,y:o.y,term:u,cwd:d,hasReveal:c,onClose:()=>s(null),onOpenSearch:()=>a(!0),onReveal:e=>{x(e).catch(()=>K.error(t(`errors.nativeActionFailed`)))},onSaveScrollback:()=>{u&&HR(u).catch(()=>K.error(t(`errors.nativeActionFailed`)))}})]})}function qR(e){let t=e.path;return typeof t==`string`&&t.length>0?t:null}function JR(e){return e?Array.from(e.types).includes(`Files`):!1}function YR({height:e,maxHeight:t,onHeightCommit:n,onHeightPreview:r,minHeight:i=120}){let{t:a}=U(`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 XR({onCreate:e}){let{t}=U(`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)(xd,{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)(Pn,{className:`h-3 w-3`}),` `,t(`emptyState.newTerminal`)]})]})})}var ZR=300;function QR({projectId:e,provider:t=`claude`,providers:n,state:r,viewportHeight:i,statusBarHeight:a}){let o=Ya(),{t:s}=U(`terminal`),c=y(),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(Wi),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),{launchDescriptors:v}=HN(),x=(0,Q.useRef)(a===0&&r.visibility!==`hidden`),[S,C]=(0,Q.useState)(()=>r.visibility===`hidden`?`hidden`:x.current?`opening`:`open`),w=(0,Q.useRef)(!1),T=n&&n.length>0?n:[t],E=T.length>1,D=(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 D(()=>e),()=>{e=!0}},[D]),(0,Q.useEffect)(()=>{let t=t=>{let n=t.detail;n?.mode===`project`&&n.projectId!==e||D()};return window.addEventListener(pR,t),()=>window.removeEventListener(pR,t)},[D,e]);let O=Math.max(120,i-a-40),k=Math.min(Math.max(r.userHeight||320,120),O),A=r.visibility===`maximized`?Math.max(120,i-a):u??k,j=S===`open`,M=j?A:0,N=a===0,P=r.sessions.length<10,F=r.activeId!==null;(0,Q.useEffect)(()=>{let e=null,t=null,n=null,i=()=>{C(`opening`),t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>C(`open`))})};return w.current?(r.visibility===`hidden`?(C(`closing`),e=setTimeout(()=>C(`hidden`),ZR)):i(),()=>{e&&clearTimeout(e),t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)}):(w.current=!0,x.current&&i(),()=>{t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)})},[r.visibility]),(0,Q.useEffect)(()=>{let e=!1,t=null;return TR(()=>{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 I=(0,Q.useCallback)(()=>{P&&o.create(e)},[P,e,o]),ee=(0,Q.useCallback)(t=>{if(!P)return;let n=v[t]??{command:t,args:[]},i=[n.command,...n.args].join(` `)+`
|
|
50
50
|
`,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})},[P,v,e,r.sessions,o]),te=(0,Q.useCallback)(e=>{if(P){if(E&&e){_(e);return}ee(t)}},[P,E,t,ee]),L=(0,Q.useCallback)(()=>{b(f.browserShortcutUrl)},[f.browserShortcutUrl]),R=(0,Q.useCallback)(()=>{r.activeId&&f.quickScript&&o.writeToSession(r.activeId,f.quickScript)},[f.quickScript,r.activeId,o]),z=(0,Q.useCallback)(e=>{h({...e,kind:`browser`})},[]),B=(0,Q.useCallback)(e=>{h({...e,kind:`script`})},[]),ne=(0,Q.useCallback)(e=>{c(`/settings${e===`browser`?`#terminal-browser-shortcut-url`:`#terminal-quick-script`}`)},[c]),V=(0,Q.useCallback)(()=>{r.activeId&&o.kill(e,r.activeId)},[e,r.activeId,o]),re=(0,Q.useCallback)(()=>{o.setVisibility(e,r.visibility===`maximized`?`restored`:`maximized`)},[e,r.visibility,o]),ie=(0,Q.useCallback)(()=>{o.setVisibility(e,`hidden`)},[e,o]);return(0,Q.useEffect)(()=>{d(null)},[r.visibility]),S===`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:M,opacity:+!!j,transform:j?`translateY(0) scaleY(1)`:`translateY(${N?14:8}px) scaleY(${N?.96:.985})`,clipPath:j?`inset(0 0 0 0)`:`inset(100% 0 0 0)`},"data-testid":`terminal-bottom-panel`,children:[(0,$.jsx)(YR,{height:k,maxHeight:O,onHeightPreview:e=>d(e),onHeightCommit:t=>{d(null),o.setUserHeight(e,t),r.visibility===`maximized`&&o.setVisibility(e,`restored`)}}),(0,$.jsx)(MR,{visibility:r.visibility,canCreate:P,hasActive:F,provider:t,providers:T,onCreate:I,onOpenCli:te,onOpenBrowser:L,onPasteScript:R,pasteScriptDisabled:!F||!f.quickScript,onConfigureBrowser:z,onConfigureScript:B,onKillActive:V,onToggleMaximize:re,onCollapse:ie}),m&&(0,$.jsx)(kR,{x:m.x,y:m.y,label:m.kind===`browser`?s(`shortcutMenu.configureBrowserUrl`):s(`shortcutMenu.editQuickScript`),onSelect:()=>ne(m.kind),onClose:()=>h(null)}),g&&(0,$.jsx)(AR,{x:g.x,y:g.y,providers:T,onSelect:e=>ee(e),onClose:()=>_(null)}),(0,$.jsx)(`div`,{className:`flex-1 flex min-h-0`,children:r.sessions.length===0?(0,$.jsx)(XR,{onCreate:I}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(KR,{activeId:r.activeId}),(0,$.jsx)(PR,{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 $R(){let{t:e}=U(`agent`),{current:t,initialized:n}=Mi(),{active:r}=OL(),{activeProjectId:i,projects:a}=ce(),o=Xa(i),s=a.find(e=>e.id===i),[c,l]=(0,Q.useState)(window.innerHeight);return(0,Q.useEffect)(()=>{!S()||!t||r?.id!==t.conversationId||BL().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,$.jsx)(`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)(fR,{})}),rt&&s&&i&&(0,$.jsx)(QR,{projectId:i,provider:s.provider,providers:oe(s),state:o,viewportHeight:c-36,statusBarHeight:0})]})})}function ez(){var e=[...arguments];return(0,Q.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var tz=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function nz(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function rz(e){return`nodeType`in e}function iz(e){return e?nz(e)?e:rz(e)?e.ownerDocument?.defaultView??window:window:window}function az(e){let{Document:t}=iz(e);return e instanceof t}function oz(e){return!nz(e)&&e instanceof iz(e).HTMLElement}function sz(e){return e instanceof iz(e).SVGElement}function cz(e){return e?nz(e)?e.document:rz(e)?az(e)?e:oz(e)||sz(e)?e.ownerDocument:document:document:document}var lz=tz?Q.useLayoutEffect:Q.useEffect;function uz(e){let t=(0,Q.useRef)(e);return lz(()=>{t.current=e}),(0,Q.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function dz(){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 fz(e,t){t===void 0&&(t=[e]);let n=(0,Q.useRef)(e);return lz(()=>{n.current!==e&&(n.current=e)},t),n}function pz(e,t){let n=(0,Q.useRef)();return(0,Q.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function mz(e){let t=uz(e),n=(0,Q.useRef)(null);return[n,(0,Q.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function hz(e){let t=(0,Q.useRef)();return(0,Q.useEffect)(()=>{t.current=e},[e]),t.current}var gz={};function _z(e,t){return(0,Q.useMemo)(()=>{if(t)return t;let n=gz[e]==null?0:gz[e]+1;return gz[e]=n,e+`-`+n},[e,t])}function vz(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 yz=vz(1),bz=vz(-1);function xz(e){return`clientX`in e&&`clientY`in e}function Sz(e){if(!e)return!1;let{KeyboardEvent:t}=iz(e.target);return t&&e instanceof t}function Cz(e){if(!e)return!1;let{TouchEvent:t}=iz(e.target);return t&&e instanceof t}function wz(e){if(Cz(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 xz(e)?{x:e.clientX,y:e.clientY}:null}var Tz=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[Tz.Translate.toString(e),Tz.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Ez=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Dz(e){return e.matches(Ez)?e:e.querySelector(Ez)}var Oz={display:`none`};function kz(e){let{id:t,value:n}=e;return Q.createElement(`div`,{id:t,style:Oz},n)}function Az(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 jz(){let[e,t]=(0,Q.useState)(``);return{announce:(0,Q.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Mz=(0,Q.createContext)(null);function Nz(e){let t=(0,Q.useContext)(Mz);(0,Q.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Pz(){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 Fz={draggable:`
|
|
51
51
|
To pick up a draggable item, press the space bar.
|
|
@@ -73,11 +73,11 @@ Error generating stack: `+e.message+`
|
|
|
73
73
|
`);K.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(`
|
|
74
74
|
`);K.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`?K.success(n(`railPr.mergedToast`)):e.decision===`discarded`?K.info(n(`railPr.discardedToast`)):e.decision===`completed`&&K.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=hq(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&&!gq.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=Wt(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=Wt(r.snapshot),c;return s&&u.current===o?c=v(s):e.status===409&&r.error===`stale_decision`&&u.current===o&&y(o,!1),{...r,snapshot:s,snapshotApplication:c,busy:e.status===409&&r.error===`operation_in_progress`,operation:s?.operation??(typeof r.operation==`string`&&_q.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,y]),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)(pq.Provider,{value:w,children:t})}function bq(e){return e?`specrails-desktop:dashboard-split:${e}`:null}function xq(e){let t=bq(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 Sq(e,t){let n=bq(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Cq(e,t){let n=Math.max(320,t-280);return Math.min(Math.max(e,320),n)}var wq=.7;function Tq(e){return Cq(Math.round(e*wq),e)}function Eq(e,t){let n=Tq(t);return Math.abs(e-n)<=48?n:e}function Dq(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:Tq(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(Tq(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??xq(e)??Tq(t),a=Cq(r!==null&&Number.isFinite(n)?i+n:i,t);return a!==r&&Sq(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=Cq(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=Cq(Eq(t,n),n);return Sq(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=Tq(n);o(r),Sq(e,r)},[e,t]);return{leftWidth:a,enabled:a!==null&&n>=900,beginDrag:p,resetToDefault:m}}function Oq({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 kq({open:e,allLabels:t,onClose:n,onCreate:r}){let{t:i}=U(`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?(K.success(i(`createModal.toast.created`)),n()):K.error(i(`createModal.toast.createFailed`))},[a,s,l,d,p,h,r,n,i]);return(0,$.jsx)(vr,{open:e,onOpenChange:e=>!e&&n(),children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-lg glass-card`,children:[(0,$.jsx)(mr,{children:(0,$.jsx)(dr,{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)(Ar,{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)(Tn,{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)(tr,{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)(Pn,{className:`w-3.5 h-3.5 mr-1`}),i(y?`createModal.creating`:`createModal.create`)]})]})]})})}function Aq({open:e,railLabel:t,specCount:n,provider:r=`claude`,model:i,onConfirm:a,onCancel:o}){let{t:s}=U(`dashboard`),c=(0,Q.useRef)(null),l=sn(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)(vr,{open:e,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(gr,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},children:[(0,$.jsx)(mr,{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)(Ln,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(dr,{className:`text-base`,children:s(`freestyleDialog.title`)}),(0,$.jsxs)(cr,{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)(On,{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)(zs,{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)(Vc,{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)(tr,{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 jq(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 Mq({open:e,railCount:t,specCount:n,onConfirm:r,onCancel:i}){let{t:a}=U(`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)(vr,{open:e,onOpenChange:e=>{e||i()},children:(0,$.jsxs)(gr,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),o.current?.focus()},children:[(0,$.jsx)(mr,{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)(Vu,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(dr,{className:`text-base`,children:a(`launchAllDialog.title`)}),(0,$.jsxs)(cr,{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)(On,{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)(kn,{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)(Vc,{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)(tr,{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:jq(`⌘↵`)})]})]})]})})}function Nq({open:e,target:t,onConfirm:n,onCancel:r}){let{t:i}=U(`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)(vr,{open:e,onOpenChange:e=>{e||r()},children:(0,$.jsxs)(gr,{movableResizable:!0,showCloseButton:!1,className:`max-w-md gap-5`,onOpenAutoFocus:e=>{e.preventDefault(),a.current?.focus()},children:[(0,$.jsx)(mr,{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)(ve,{className:`h-4.5 w-4.5`})}),(0,$.jsxs)(`div`,{className:`text-left`,children:[(0,$.jsx)(dr,{className:`text-base`,children:i(`targetPr.confirmTitle`)}),(0,$.jsx)(cr,{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)(ve,{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)(On,{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)(tr,{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:jq(`⌘↵`)})]})]})]})}):null}var Pq=`postit`,Fq=e=>`specrails-desktop:specs-view-tier:${e}`;function Iq(e){return e===`row`||e===`postit`}function Lq(e){if(!e)return Pq;try{let t=localStorage.getItem(Fq(e));if(Iq(t))return t}catch{}return Pq}function Rq(e,t){if(e)try{localStorage.setItem(Fq(e),t)}catch{}}function zq(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 Bq(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 Vq=[{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`}],Hq=e=>e===`batch-implement`||e===`batch`?`implement`:e===`implement`||e===`freestyle`||e===`loop`?e:void 0;function Uq(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 Wq(e,t,n=[]){let r=n.some(t=>t.id===e&&t.addenda?.some(e=>e.status===`open`));for(let n of t.values())if(r&&n.decision!==`building`&&n.ticketIds.includes(e)||Uq(n,[e]))return!0;return!1}function Gq(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 Kq(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 qq(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.map(e=>({...e,mode:Hq(e.mode)??`implement`,...e.selectedLoopId===`factory:batch`?{selectedLoopId:`factory:implement`}:{}}))}catch{return null}}function Jq(e,t){if(e)try{localStorage.setItem(`specrails-desktop:rails:${e}`,JSON.stringify(t))}catch{}}function Yq(){let{t:e}=U(`dashboard`),{activeProjectId:t,projects:n}=ce(),r=Pa().id===`galaxy`,i=(()=>{let e=n.find(e=>e.id===t);return e?oe(e):[`claude`]})(),{tickets:a,isLoading:o,error:s,updateTicket:c,updateTicketStatus:l,updateTicketPriority:u,deleteTicket:d,createTicket:f,refetch:p,contractRefiningIds:m}=J(),{registerHandler:h,unregisterHandler:g,connectionStatus:_}=R(),{specToOpen:v,clearSpecToOpen:y}=lW(),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!v||v.projectId!==t||(x(v.ticket),p(),y())},[v,t,p,y]);let[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(()=>Gq(t)),[I,ee]=(0,Q.useState)(()=>qq(t)??Vq),[te,L]=(0,Q.useState)({}),z=dq(),{decisions:B,hydrated:ne,act:V,checkout:re}=mq(),ie=RU(t),[ae,H]=(0,Q.useState)(ie.mode),[W,se]=(0,Q.useState)(ie.dir),[le,ue]=(0,Q.useState)(()=>Lq(t));(0,Q.useEffect)(()=>{F(Gq(t)),ee(qq(t)??Vq),L({});let e=RU(t);H(e.mode),se(e.dir),ue(Lq(t))},[t]);let de=(0,Q.useCallback)((e,n)=>{H(e),se(n),zU(t,e,n)},[t]),fe=(0,Q.useCallback)(e=>{ue(e),Rq(t,e)},[t]);(0,Q.useEffect)(()=>{if(_!==`connected`||!t)return;let e=!1,n=qq(t)??Vq,r=new Map(n.map(e=>[e.id,e]));return fetch(`${G()}/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));ee(e=>{let n=!1,u=new Map,d=e.map((e,t)=>{let s=RK(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=Hq(a)??(l?$w(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,...tT(l?.loopId)?{selectedLoopId:tT(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=LK(e.railIndex);if(f.has(t))continue;let r=a[String(e.railIndex)],s=i[String(e.railIndex)]?.mode,l=Hq(s)??(r?$w(r.loopId):Hq(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,...tT(r?.loopId)?{selectedLoopId:tT(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=RK(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 Jq(t,g),g})}).catch(()=>{}),()=>{e=!0}},[t,_]),(0,Q.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`${G()}/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);ee(e=>{let n=!1,i=e.map((e,t)=>{let i=RK(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?(Jq(t,i),i):e})}).catch(()=>{}),()=>{e=!0}},[t]),(0,Q.useEffect)(()=>{let e=new Set(a.filter(e=>e.status===`done`||ne&&e.status===`on_review`&&!Wq(e.id,B,a)).map(e=>e.id));e.size!==0&&ee(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:(Jq(t,r),r)})},[a,t,I,B,ne]);let pe=(0,Q.useCallback)(e=>{F(n=>{let r=e(n);return Kq(t,r),r})},[t]),q=(0,Q.useCallback)(e=>{ee(n=>{let r=e(n);return Jq(t,r),r})},[t]),me=(0,Q.useMemo)(()=>{let e=new Set([`specs`,`done-specs`]);for(let t of I)e.add(t.id);return e},[I]),he=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${G()}/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=LK(n);q(e=>e.some(e=>e.id===t)?e:[...e,{id:t,label:`Rail ${n+1}`,ticketIds:[],mode:`implement`,status:`idle`}]),K.success(e(`toasts.railAdded`,{n:n+1}));return}}else{let n=await t.json().catch(()=>({error:``}));if(n.error===`rail_limit_reached`){K.error(e(`toasts.railLimitReached`,{max:n.maxRails??12}));return}}}catch{}let t=I.map(e=>RK(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`};q(e=>[...e,r]),K.success(e(`toasts.railAdded`,{n}))},[I,q,e]),ge=(0,Q.useCallback)(async t=>{let n=I.find(e=>e.id===t);if(!n||n.status===`running`)return;let r=()=>{n.ticketIds.length>0&&pe(e=>[...e??[],...n.ticketIds]),q(e=>e.filter(e=>e.id!==t)),K.info(e(`toasts.railRemoved`,{rail:n.label}))},i=RK(t);if(i===null){r();return}try{let t=await fetch(`${G()}/rails/${i}`,{method:`DELETE`});if(t.ok||t.status===404){r();return}K.error(e(`toasts.railDeleteFailed`))}catch{K.error(e(`toasts.railDeleteFailed`))}},[I,q,pe,e]),_e=(0,Q.useCallback)((e,t)=>{q(n=>n.map(n=>n.id===e?{...n,label:`Rail ${t}`}:n));let n=RK(e);n!==null&&fetch(`${G()}/rails/${n}/name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})}).catch(()=>{})},[q]),ve=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{ve.current=t},[t]);let ye=(0,Q.useCallback)(t=>{let n=t;if(n.projectId===ve.current){if(n.type===`runtime.continuation`){if(n.railIndex==null)return;let e=LK(n.railIndex);q(t=>t.map(t=>t.id===e?n.active?{...t,status:`running`,activeJobId:n.jobId}:t.activeJobId===n.jobId?{...t,status:`idle`,activeJobId:void 0}:t:t));return}if(n.type===`rail.job_started`||n.type===`loop.run_started`){if(n.railIndex==null)return;let e=LK(n.railIndex),t=n.jobId??n.loopRunId;q(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=LK(e),r=n.ticketIds??[],i=n.name?`Rail ${n.name}`:`Rail ${e+1}`;q(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:Hq(n.mode)??`implement`,status:`idle`}]);return}if(n.type===`rail.removed`){if(n.railIndex==null)return;let e=LK(n.railIndex);q(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&&(L(e=>VK(e,t,r,i)),i===`needs-review`&&K.error(e(`toasts.railWorktreeNeedsReview`,{n:t+1,ticket:r})));return}if(n.type===`rail.job_completed`){let t=n.railIndex??0;q(e=>qK(e,t,n.ticketIds??[])),n.status===`completed`?K.info(e(`toasts.railCompleted`,{n:t+1})):n.status===`failed`||n.status===`zombie_terminated`?K.error(e(`toasts.railFailed`,{n:t+1})):K.info(e(`toasts.railEnded`,{n:t+1,status:n.status??`finished`}))}if(n.type===`loop.run_completed`){let t=n.railIndex??0;q(e=>qK(e,t,n.ticketIds??[])),n.status===`success`?K.info(e(`toasts.railCompleted`,{n:t+1})):n.status===`failed`||n.status===`max-iterations`?K.error(e(`toasts.railFailed`,{n:t+1})):K.info(e(`toasts.railEnded`,{n:t+1,status:n.status??`finished`}))}}},[q,e]);(0,Q.useEffect)(()=>(h(`dashboard-rails`,ye),()=>g(`dashboard-rails`)),[ye,h,g]);let be=Vz(Bz(KB,{activationConstraint:{distance:5}}),Bz(VB)),xe=(0,Q.useCallback)(e=>{let t=typeof e.active.id==`string`&&GK(e.active.id),n=e.droppableContainers.filter(e=>{let n=e.id;return typeof n==`string`&&GK(n)?t:!t}),r={...e,droppableContainers:n};if(t)return Zz(r);let i=tB(r);if(Jz(i))return i;let a=$z(r);return Jz(a)?a:Zz(r)},[]),Se=(0,Q.useMemo)(()=>new Map(a.map(e=>[e.id,e])),[a]),Ce=(0,Q.useMemo)(()=>{let e=[],t=[];return I.forEach((n,r)=>{let i=RK(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 o=B.get(i),s=o&&o.decision!==`building`&&o.ticketIds.length===n.ticketIds.length&&n.ticketIds.every(e=>o.ticketIds.includes(e))&&n.ticketIds.some(e=>Se.get(e)?.addenda?.some(e=>e.status===`open`));if(o&&!Uq(o,n.ticketIds)&&!s){t.push({rail:n,reason:`pendingDecision`});return}if(n.ticketIds.some(e=>Se.get(e)?.status===`on_review`&&(!ne||!Wq(e,B,a)))){t.push({rail:n,reason:`onReview`});return}e.push(n)}),{eligible:e,skipped:t}},[I,B,ne,Se,a]),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 I)for(let n of t.ticketIds)e.add(n);return e},[I]),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||ae===`jira-key`&&!Ee.some(e=>e.jira_key)&&de(`default`,W)},[o,ae,W,Ee,de]);let De=(0,Q.useMemo)(()=>{let e=Ee.filter(e=>e.status!==`done`);if(ae!=="default")return KU(e,ae,W);if(!P)return e;let t=new Map(e.map(e=>[e.id,e])),n=[];for(let e of P){let r=t.get(e);r&&n.push(r)}for(let t of e)P.includes(t.id)||n.push(t);return n},[Ee,P,ae,W]),Oe=(0,Q.useMemo)(()=>Ee.filter(e=>e.status===`done`),[Ee]),ke=(0,Q.useMemo)(()=>{let e=new Set;if(!ne)return e;for(let t of a)t.status===`on_review`&&Wq(t.id,B,a)&&e.add(t.id);return e},[a,B,ne]),Ae=(0,Q.useCallback)((t,n)=>{let r=I.find(e=>e.id===n);if(r){if(a.find(e=>e.id===t)?.status===`on_review`&&(!ne||!Wq(t,B,a))){K.info(e(`toasts.onReviewCannotMoveToRail`));return}if(r.ticketIds.includes(t)){K.info(e(`toasts.alreadyOnRail`,{rail:r.label}));return}pe(e=>(e??De.map(e=>e.id)).filter(e=>e!==t)),q(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)),K.success(e(`toasts.movedToRail`,{rail:r.label}))}},[I,a,De,q,pe,e,B,ne]),je=(0,Q.useCallback)(t=>{let n=I.find(e=>e.ticketIds.includes(t));if(n){if(n.status===`running`){K.error(e(`toasts.railRunningStopFirst`,{rail:n.label}));return}q(e=>e.map(e=>e.id===n.id?{...e,ticketIds:e.ticketIds.filter(e=>e!==t)}:e)),pe(e=>{let n=e??De.map(e=>e.id);return n.includes(t)?n:[...n,t]}),K.success(e(`toasts.removedFromRail`,{rail:n.label}))}},[I,De,q,pe,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 I)if(t.ticketIds.includes(e))return t.id;return null},[De,Oe,I]);function Ne({active:e}){if(GK(e.id)){let t=KK(e.id),n=I.find(e=>e.id===t);N(n?.label??t);return}j(e.id)}function Pe({active:n,over:r}){if(j(null),N(null),!r)return;if(GK(n.id)){if(!GK(r.id))return;let e=KK(n.id),t=KK(r.id);if(e===t)return;q(n=>{let r=n.findIndex(t=>t.id===e),i=n.findIndex(e=>e.id===t);return r===-1||i===-1?n:uH(n,r,i)});return}let i=n.id,o=r.id,s=Me(i);if(!s)return;let l=Bq(o,me,Me,GK,KK)??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=uH(e,n,r);pe(()=>i),ae!=="default"&&(H(`default`),zU(t,`default`,W))}}else q(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:uH(e.ticketIds,t,n)}:e}));else if(s===`specs`&&l===`done-specs`){if(a.find(e=>e.id===i)?.status===`on_review`){K.info(e(`toasts.onReviewCannotMoveToRail`));return}pe(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`}),pe(e=>zq(e??De.map(e=>e.id),i,o));else if(s===`specs`){if(a.find(e=>e.id===i)?.status===`on_review`&&(!ne||!Wq(i,B,a))){K.info(e(`toasts.onReviewCannotMoveToRail`));return}let t=I.find(e=>e.id===l);pe(e=>(e??De.map(e=>e.id)).filter(e=>e!==i)),q(e=>e.map(e=>e.id===l?{...e,ticketIds:zq(e.ticketIds,i,o)}:e)),t&&(t.status===`running`?K.info(e(`toasts.queuedOnRail`,{rail:t.label}),{description:e(`toasts.queuedOnRailDescription`)}):K.success(e(`toasts.movedToRail`,{rail:t.label})))}else if(l===`specs`){let t=I.find(e=>e.id===s);if(t?.status===`running`){K.error(e(`toasts.railRunningStopFirst`,{rail:t.label}));return}q(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e)),pe(e=>zq(e??De.map(e=>e.id),i,o)),t&&K.success(e(`toasts.removedFromRail`,{rail:t.label}))}else s===`done-specs`?(c(i,{status:`todo`}),q(e=>e.map(e=>e.id===l?{...e,ticketIds:zq(e.ticketIds,i,o)}:e))):l===`done-specs`?(q(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e)),c(i,{status:`done`})):q(e=>e.map(e=>e.id===s?{...e,ticketIds:e.ticketIds.filter(e=>e!==i)}:e.id===l?{...e,ticketIds:zq(e.ticketIds,i,o)}:e))}function Fe(e,t){q(n=>n.map(n=>n.id===e?{...n,mode:t}:n))}function Ie(e){let t=RK(e);return t===null?I.findIndex(t=>t.id===e):t}async function Le(e,t){q(n=>n.map(n=>n.id===e?{...n,profileName:t}:n));let n=Ie(e);if(n!==-1)try{await fetch(`${G()}/rails/${n}/profile`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profileName:t})})}catch{}}function Re(e,t){q(n=>n.map(n=>n.id===e?{...n,freestyleModel:t}:n))}function ze(e,t){let n=$w(t);q(r=>r.map(r=>r.id===e?{...r,selectedLoopId:t,mode:n}:r))}function Be(e){let t=e?.aiEngine;return($t(t)?void 0:t)??i[0]??`claude`}function Ve(e,t){q(n=>n.map(n=>{if(n.id!==e)return n;let r=Be(n),i=qt(r,t);return{...n,loopModel:t,reasoningEffort:n.reasoningEffort&&i.includes(n.reasoningEffort)?n.reasoningEffort:cn(r,t)??null}}))}function He(e,t){q(n=>n.map(n=>n.id===e?{...n,reasoningEffort:t}:n))}async function Ue(t,n){if($t(n)){let r=I.find(e=>e.id===t);if(r&&(r.mode===`freestyle`||r.selectedLoopId===`factory:freestyle`)){K.error(e(`rail.rolesNoFreestyle`));return}q(e=>e.map(e=>e.id===t?{...e,aiEngine:n,profileName:null}:e)),await We(t,n);return}q(e=>e.map(e=>{if(e.id!==t)return e;let r=e.mode===`freestyle`||e.selectedLoopId===`factory:freestyle`,i=!Yt(n)&&r,a=Kw(n),o=e=>!!(e&&(a.some(t=>t.value===e)||ln(n)&&gM(e))),s=o(e.loopModel)?e.loopModel:qw(n),c=qt(n,s);return{...e,aiEngine:n,mode:i?`implement`:e.mode,selectedLoopId:i?`factory:implement`:e.selectedLoopId,profileName:null,freestyleModel:o(e.freestyleModel)?e.freestyleModel:qw(n),loopModel:s,reasoningEffort:e.reasoningEffort&&c.includes(e.reasoningEffort)?e.reasoningEffort:cn(n,s)??null}})),await We(t,n)}async function We(e,t){let n=Ie(e);if(n!==-1)try{await fetch(`${G()}/rails/${n}/engine`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({aiEngine:t})})}catch{}}function Ge(e,t){q(n=>n.map(n=>n.id===e?{...n,targetPr:t}:n))}async function Ke(t){let n=I.find(e=>e.id===t),r=Ie(t);if(!(!n||r===-1)){if(n.status===`running`){try{await fetch(`${G()}/rails/${r}/stop`,{method:`POST`}),q(e=>e.map(e=>e.id===t?{...e,status:`idle`,activeJobId:void 0}:e)),K.info(e(`toasts.railStopped`,{rail:n.label}))}catch{K.error(e(`toasts.stopFailed`))}return}if(n.ticketIds.length!==0){if(n.mode===`freestyle`&&!n.ticketIds.some(e=>Se.get(e)?.addenda?.some(e=>e.status===`open`))){T({railId:t});return}if(n.targetPr){D({railId:t});return}await qe(t)}}}async function qe(t,n){let r=n?.silent??!1,i=I.find(e=>e.id===t),o=Ie(t);if(!i||o===-1)return`failed`;if(i.ticketIds.length===0)return`skipped`;if(i.ticketIds.some(e=>a.find(t=>t.id===e)?.status===`on_review`&&(!ne||!Wq(e,B,a))))return r||K.info(e(`toasts.onReviewNotLaunchable`)),`skipped`;let s=eT(i.selectedLoopId,i.mode,i.ticketIds.some(e=>Se.get(e)?.addenda?.some(e=>e.status===`open`)));if(!s)return r||K.error(e(`railControls.pickLoop`)),`failed`;let c=$w(s),l=$t(i.aiEngine),u=Be(i),d=qt(u,i.loopModel??qw(u)),f=i.reasoningEffort&&d.includes(i.reasoningEffort)?i.reasoningEffort:null,p=G();try{await fetch(`${p}/rails/${o}/tickets`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({ticketIds:i.ticketIds})})}catch{return r||K.error(e(`toasts.syncTicketsFailed`)),`failed`}try{let n=await fetch(`${p}/rails/${o}/launch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:c,...i.workspaceSelection?{workspaceSelection:i.workspaceSelection}:{},...!l&&(i.aiEngine!=null||c===`loop`&&(i.loopModel||f))?{runtimeProviderOverride:{provider:u,...c===`loop`&&i.loopModel?{model:i.loopModel}:{},...c===`loop`&&f?{effort:f}:{}}}:{},...!l&&i.profileName!==void 0?{profileName:i.profileName}:{},...i.aiEngine==null?{}:{aiEngine:i.aiEngine},...!l&&c===`freestyle`&&i.freestyleModel?{model:i.freestyleModel}:{},...!l&&c===`loop`&&i.loopModel?{model:i.loopModel}:{},loopId:s,...!l&&c===`loop`&&f?{reasoning_effort:f}:{},...i.targetPr?{targetPrNumber:i.targetPr.number}:{}})});if(!n.ok){let t=await n.json().catch(()=>({error:``}));return n.status===409&&t.error===`pr_decision_pending`?(r||K.info(e(`railPr.decisionPending`)),`pendingDecision`):n.status===409&&t.error===`tickets_in_flight`?(r||K.info(e(`toasts.launchTicketsInFlight`)),`skipped`):n.status===409&&t.error===`legacy_engine_unavailable`?(r||K.error(e(`toasts.launchLegacyEngineUnavailable`),{duration:1e4}),`failed`):n.status===400&&t.error===`rail_ticket_cap_exceeded`?(r||K.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||K.error(e(`targetPr.errors.${t.error}`),{description:t.detail,duration:1e4}),`failed`):(r||K.error(t.error||e(`toasts.launchFailed`)),`failed`)}let a=await n.json();!r&&a.isolationUnavailable===`no-git`?K.info(e(`toasts.railWorktreesNoGit`)):!r&&a.isolationUnavailable===`no-commits`?K.info(e(`toasts.railWorktreesNoCommits`)):!r&&a.isolationUnavailable===`error`&&K.warning(e(`toasts.railWorktreesError`),{description:a.isolationUnavailableDetail,duration:12e3});let d=a.jobId??a.loopRunIds?.[0];return q(e=>e.map(e=>e.id===t?{...e,status:`running`,activeJobId:d,targetPr:null}:e)),r||K.success(e(`toasts.railLaunched`,{rail:i.label}),{description:e(`toasts.launchDescription`,{mode:i.mode,count:i.ticketIds.length})}),`launched`}catch{return r||K.error(e(`toasts.launchNetworkError`)),`failed`}}function Je(){if(Ce.eligible.length===0){K.info(e(`toasts.launchAllNoneEligible`));return}k(!0)}async function Ye(){k(!1);let{eligible:t,skipped:n}=Ce;if(t.length===0){K.info(e(`toasts.launchAllNoneEligible`));return}let r=await Promise.allSettled(t.map(e=>qe(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?K.success(e(`toasts.launchAllSummary`,{count:i}),d?{description:d}:void 0):K.error(e(`toasts.launchAllFailed`),d?{description:d}:void 0)}let Xe=A===null?void 0:Se.get(A),Ze=(0,Q.useRef)(null),{leftWidth:Qe,enabled:$e,beginDrag:et,resetToDefault:tt}=Dq(t,Ze),nt=typeof window<`u`?window.innerWidth:1200;return(0,$.jsx)(GH,{children:(0,$.jsxs)(UV,{sensors:be,collisionDetection:xe,onDragStart:Ne,onDragEnd:Pe,children:[(0,$.jsxs)(`div`,{ref:Ze,className:`relative z-0 flex h-full overflow-hidden`,children:[r&&(0,$.jsx)(oR,{}),(0,$.jsx)(`div`,{className:`relative z-10 min-w-0 flex flex-col overflow-hidden`,style:$e&&Qe!==null?{width:`${Qe}px`,flex:`0 0 auto`}:{flex:`1 1 0%`},children:(0,$.jsx)(_K,{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:ae,sortDir:W,onSortChange:de,viewTier:le,onViewTierChange:fe,rails:I,onMoveToRail:Ae,continuableReviewTicketIds:ke})}),$e&&Qe!==null&&(0,$.jsx)(Oq,{leftWidth:Qe,viewport:nt,onPointerDown:et,onReset:tt}),(0,$.jsx)(`div`,{className:`relative z-10 flex-1 min-w-0 flex flex-col overflow-hidden`,children:(0,$.jsx)(YK,{rails:I,ticketMap:Se,railWorktrees:te,railMetrics:z,railPrDecisions:B,onPrDecision:V,onPrCheckout:re,providers:i,onModeChange:Fe,onProfileChange:Le,onEngineChange:Ue,onFreestyleModelChange:Re,onLoopModelChange:Ve,loopAvailable:st,onLoopChange:ze,onEffortChange:He,onToggle:Ke,onTargetPrChange:Ge,onWorkspaceSelectionChange:(e,t)=>q(n=>n.map(n=>n.id===e?{...n,workspaceSelection:t}:n)),onTicketClick:x,onAddRail:()=>{he()},onDeleteRail:e=>{ge(e)},onRenameRail:_e,onTicketMoveToSpecs:je,onLaunchAll:Je,launchAllCount:Ce.eligible.length})})]}),(0,$.jsx)(lH,{dropAnimation:{duration:180,easing:`ease`},children:Xe?le===`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:[`#`,Xe.id]}),Xe.priority&&(0,$.jsx)(`span`,{className:`h-4 px-1.5 rounded-full text-[9px] font-medium uppercase bg-muted/40 text-foreground`,children:Xe.priority})]}),(0,$.jsx)(`h3`,{className:`text-sm font-medium leading-snug line-clamp-2 text-foreground`,children:Xe.title}),Xe.short_summary&&Xe.short_summary.trim().length>0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 leading-relaxed line-clamp-3 italic`,children:Xe.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:[`#`,Xe.id]}),(0,$.jsx)(`span`,{className:`flex-1 text-sm truncate max-w-[240px]`,children:Xe.title})]}):M?(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:M})}):null}),b&&(()=>{let e=a.find(e=>e.id===b.id)??b;return(0,$.jsx)(it,{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:I,onMoveToRail:Ae,onRemoveFromRail:je},e.id)})(),(0,$.jsx)(kq,{open:S,allLabels:we,onClose:()=>C(!1),onCreate:f}),(0,$.jsx)(Mq,{open:O,railCount:Ce.eligible.length,specCount:Ce.eligible.reduce((e,t)=>e+t.ticketIds.length,0),onCancel:()=>k(!1),onConfirm:()=>{Ye()}}),(()=>{let e=E?I.find(e=>e.id===E.railId):void 0;return(0,$.jsx)(Nq,{open:!!E&&!!e?.targetPr,target:e?.targetPr??null,onCancel:()=>D(null),onConfirm:()=>{let e=E?.railId;D(null),e&&qe(e)}})})(),(()=>{let e=w?I.find(e=>e.id===w.railId):void 0,t=Be(e);return(0,$.jsx)(Aq,{open:!!w&&!!e,railLabel:e?.label??``,specCount:e?.ticketIds.length??0,provider:t,model:e?.freestyleModel??qw(t),onCancel:()=>T(null),onConfirm:()=>{let e=w?.railId;T(null),e&&qe(e)}})})()]})})}var Xq=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}));Xq.displayName=`Card`;var Zq=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`flex flex-col space-y-1 p-4`,e),...t}));Zq.displayName=`CardHeader`;var Qq=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`h3`,{ref:n,className:X(`text-sm font-semibold leading-none tracking-tight`,e),...t}));Qq.displayName=`CardTitle`;var $q=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`p`,{ref:n,className:X(`text-xs text-muted-foreground`,e),...t}));$q.displayName=`CardDescription`;var eJ=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`p-4 pt-0`,e),...t}));eJ.displayName=`CardContent`;var tJ=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:X(`flex items-center p-4 pt-0`,e),...t}));tJ.displayName=`CardFooter`;var nJ=[`claude`,`codex`],rJ=`__same__`;function iJ(e,t){let{t:n}=U(`settings`),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!e)return;let t=!1;return c(!1),fetch(e).then(e=>e.ok?e.json():null).then(e=>{t||!e||(i(e.allowSubagents===!0),o(e.subagentRuntime??null))}).catch(()=>{}).finally(()=>{t||c(!0)}),()=>{t=!0}},[e]);async function d(n){let r=await fetch(e,{method:t,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok)throw Error(`HTTP ${r.status}`)}async function f(e){u(!0),i(e);try{await d({allowSubagents:e}),K.success(n(e?`subagents.enabled`:`subagents.disabled`))}catch(t){i(!e),K.error(n(`subagents.saveFailed`),{description:t.message})}finally{u(!1)}}async function p(e){let t=a;u(!0),o(e);try{await d({subagentRuntime:e}),(!e||e.provider!==t?.provider)&&K.success(e?n(`subagents.runtime.saved`,{provider:sn(e.provider)}):n(`subagents.runtime.reset`))}catch(e){o(t),K.error(n(`subagents.saveFailed`),{description:e.message})}finally{u(!1)}}return{enabled:r,runtime:a,loaded:s,saving:l,setEnabled:e=>void f(e),setRuntime:e=>void p(e)}}function aJ({runtime:e,saving:t,onChange:n}){let{t:r}=U(`settings`),{detected:i}=Yw(),[a,o]=(0,Q.useState)(null),s=nJ.filter(t=>i.includes(t)||e?.provider===t),c=e?Kw(e.provider):[],l=e?qt(e.provider,e.model):[];function u(e,t=qw(e)){return{provider:e,model:t,effort:cn(e,t)??null}}function d(t){if(t===rJ){n(null);return}if(t!==e?.provider){if(!e){o(t);return}n(u(t))}}function f(t){if(!e)return;let r=qt(e.provider,t),i=e.effort&&r.includes(e.effort)?e.effort:cn(e.provider,t)??null;n({...e,model:t,effort:i})}let p=a?sn(a):``;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border/40 p-3`,"data-testid":`subagent-runtime`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:r(`subagents.runtime.label`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e?r(`subagents.runtime.chosenHint`,{provider:sn(e.provider)}):r(`subagents.runtime.sameHint`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(yU,{value:e?.provider??rJ,onValueChange:d,disabled:t,children:[(0,$.jsx)(xU,{className:`h-8 w-[220px] text-xs`,"aria-label":r(`subagents.runtime.providerLabel`),"data-testid":`subagent-runtime-provider`,children:(0,$.jsx)(bU,{})}),(0,$.jsxs)(wU,{children:[(0,$.jsx)(EU,{value:rJ,className:`text-xs`,children:r(`subagents.runtime.same`)}),s.map(e=>(0,$.jsx)(EU,{value:e,className:`text-xs`,children:sn(e)},e))]})]}),e&&(0,$.jsxs)(yU,{value:e.model,onValueChange:f,disabled:t||c.length===0,children:[(0,$.jsx)(xU,{className:`h-8 w-[170px] text-xs`,"aria-label":r(`subagents.runtime.modelLabel`),"data-testid":`subagent-runtime-model`,children:(0,$.jsx)(bU,{})}),(0,$.jsx)(wU,{children:c.map(e=>(0,$.jsx)(EU,{value:e.value,className:`text-xs`,children:e.label},e.value))})]}),e&&l.length>0&&(0,$.jsxs)(yU,{value:e.effort??``,onValueChange:t=>n({...e,effort:t}),disabled:t,children:[(0,$.jsx)(xU,{className:`h-8 w-[130px] text-xs`,"aria-label":r(`subagents.runtime.effortLabel`),"data-testid":`subagent-runtime-effort`,children:(0,$.jsx)(bU,{})}),(0,$.jsx)(wU,{children:l.map(e=>(0,$.jsx)(EU,{value:e,className:`text-xs`,children:r(`agent:effort.${e}`)},e))})]})]}),e?.provider===`claude`&&l.length>0&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`subagents.runtime.claudeEffortHint`)}),(0,$.jsx)(vr,{open:a!==null,onOpenChange:e=>{e||o(null)},children:(0,$.jsxs)(gr,{className:`max-w-md`,"data-testid":`subagent-runtime-confirm`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:r(`subagents.runtime.confirm.title`,{provider:p})}),(0,$.jsx)(cr,{children:r(`subagents.runtime.confirm.body`,{provider:p})})]}),(0,$.jsxs)(`ul`,{className:`space-y-2 text-[11px] leading-relaxed text-muted-foreground`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(dl,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500`,"aria-hidden":!0}),r(`subagents.runtime.confirm.cost`)]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(sd,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary`,"aria-hidden":!0}),r(`subagents.runtime.confirm.control`)]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(Hn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),r(`subagents.runtime.confirm.native`,{provider:p})]})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>o(null),children:r(`subagents.runtime.confirm.cancel`)}),(0,$.jsx)(Z,{size:`sm`,"data-testid":`subagent-runtime-confirm-accept`,onClick:()=>{let e=a;o(null),n(u(e))},children:r(`subagents.runtime.confirm.accept`,{provider:p})})]})]})})]})}function oJ({scope:e,state:t}){let{t:n}=U(`settings`),{enabled:r,runtime:i,loaded:a,saving:o}=t;if(!a)return(0,$.jsx)(`div`,{className:`h-40 animate-pulse rounded-lg bg-muted/30`,"data-testid":`section-skeleton`});let s=n(`subagents.${e}.toggleLabel`);return(0,$.jsxs)(Xq,{"data-testid":`subagents-settings-${e}`,children:[(0,$.jsxs)(Zq,{children:[(0,$.jsxs)(Qq,{className:`flex items-center gap-2`,children:[(0,$.jsx)(zs,{className:`h-4 w-4 text-accent-primary`,"aria-hidden":!0}),n(`subagents.title`)]}),(0,$.jsx)($q,{children:n(`subagents.${e}.description`)})]}),(0,$.jsxs)(eJ,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium`,children:s}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:n(r?`subagents.stateOn`:`subagents.stateOff`)})]}),(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":s,"aria-checked":r,disabled:o,onClick:()=>t.setEnabled(!r),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 disabled:opacity-50 ${r?`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 motion-reduce:transition-none ${r?`translate-x-4`:`translate-x-0.5`}`})})]}),r&&(0,$.jsx)(aJ,{runtime:i,saving:o,onChange:t.setRuntime}),(0,$.jsxs)(`ul`,{className:`space-y-2 rounded-lg border border-border/40 bg-muted/20 p-3 text-[11px] leading-relaxed text-muted-foreground`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(kn,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),n(`subagents.explainParallel`)]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(Cc,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),n(`subagents.explainCost`)]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(ad,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),n(`subagents.${e}.explainScope`)]})]})]})]})}function sJ(){let{activeProjectId:e}=ce();return(0,$.jsx)(oJ,{scope:`project`,state:iJ(e?`${G()}/settings`:null,`PATCH`)})}function cJ(){return(0,$.jsx)(oJ,{scope:`global`,state:iJ(`${F}/api/settings`,`PUT`)})}var lJ=[`auto`,`canvas`,`webgl`];function uJ({mode:e}){let{t}=U(`settings`),{activeProjectId:n}=ce(),[r,i]=(0,Q.useState)(Wi),[a,o]=(0,Q.useState)({}),[s,c]=(0,Q.useState)(Wi),[l,u]=(0,Q.useState)(Wi),[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){K(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),mR({mode:`desktop`,projectId:null}),K.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),mR({mode:`project`,projectId:n}),K.success(t(`terminal.saved`))}}catch(e){K.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)(Xq,{children:(0,$.jsx)(eJ,{children:t(`common:states.loading`)})}):(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:t(`terminal.title`)}),(0,$.jsx)($q,{children:t(e===`desktop`?`terminal.desktopDescription`:`terminal.projectDescription`)})]}),(0,$.jsxs)(eJ,{className:`space-y-4`,children:[(0,$.jsx)(dJ,{label:t(`terminal.fontFamily`),overridden:S(`fontFamily`),onClear:()=>y(`fontFamily`),mode:e,children:(0,$.jsx)(gF,{value:l.fontFamily,onChange:e=>v(`fontFamily`,e.target.value)})}),(0,$.jsx)(dJ,{label:t(`terminal.fontSize`,{min:8,max:32}),overridden:S(`fontSize`),onClear:()=>y(`fontSize`),mode:e,children:(0,$.jsx)(gF,{type:`number`,min:8,max:32,value:l.fontSize,onChange:e=>v(`fontSize`,parseInt(e.target.value,10)||l.fontSize)})}),(0,$.jsx)(dJ,{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:lJ.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})}),(0,$.jsx)(fJ,{label:t(`terminal.copyOnSelect`),checked:l.copyOnSelect,overridden:S(`copyOnSelect`),onClear:()=>y(`copyOnSelect`),onChange:e=>v(`copyOnSelect`,e),mode:e}),(0,$.jsx)(fJ,{label:t(`terminal.shellIntegration`),checked:l.shellIntegrationEnabled,overridden:S(`shellIntegrationEnabled`),onClear:()=>y(`shellIntegrationEnabled`),onChange:e=>v(`shellIntegrationEnabled`,e),mode:e}),(0,$.jsx)(fJ,{label:t(`terminal.notifyLongRunning`),checked:l.notifyOnCompletion,overridden:S(`notifyOnCompletion`),onClear:()=>y(`notifyOnCompletion`),onChange:e=>v(`notifyOnCompletion`,e),mode:e}),(0,$.jsx)(dJ,{label:t(`terminal.longCommandThreshold`),overridden:S(`longCommandThresholdMs`),onClear:()=>y(`longCommandThresholdMs`),mode:e,children:(0,$.jsx)(gF,{type:`number`,min:1e3,value:l.longCommandThresholdMs,onChange:e=>v(`longCommandThresholdMs`,parseInt(e.target.value,10)||l.longCommandThresholdMs)})}),(0,$.jsx)(fJ,{label:t(`terminal.imageRendering`),checked:l.imageRendering,overridden:S(`imageRendering`),onClear:()=>y(`imageRendering`),onChange:e=>v(`imageRendering`,e),mode:e}),(0,$.jsx)(dJ,{id:`terminal-browser-shortcut-url`,label:t(`terminal.browserShortcutUrl`),overridden:S(`browserShortcutUrl`),onClear:()=>y(`browserShortcutUrl`),mode:e,children:(0,$.jsx)(gF,{type:`url`,value:l.browserShortcutUrl,placeholder:`https://specrails.dev`,onChange:e=>v(`browserShortcutUrl`,e.target.value)})}),(0,$.jsx)(dJ,{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 dJ({id:e,label:t,overridden:n,onClear:r,mode:i,children:a}){let{t:o}=U(`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 fJ({label:e,checked:t,overridden:n,onClear:r,onChange:i,mode:a}){let{t:o}=U(`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 pJ(){let{activeProjectId:e,projects:t,refreshProjects:n}=ce(),r=t.find(t=>t.id===e);return r?(0,$.jsx)(mJ,{project:r,refreshProjects:n},r.id):null}function mJ({project:e,refreshProjects:t}){let{t:n}=U(`common`),[r,i]=(0,Q.useState)(()=>kr(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)(``),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,Q.useEffect)(()=>{i(kr(e))},[e]);let C=`${Or(e.id)}/repositories`;function w(e){x(null),o(e??null),l(!e),d(e?.path??``),p(e?.name??``),h(e?.workspacePaths?.join(`
|
|
75
75
|
`)??e?.workspacePath??``),_(e?.integrationBranch??``)}async function T(e,n){if(!v){y(!0),x(null);try{let r=await fetch(n?`${C}/${encodeURIComponent(n)}`:C,{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:g.trim()||null,workspacePath:null,workspacePaths:m.trim()?m.split(`
|
|
76
|
-
`).map(e=>e.trim()).filter(Boolean):null})}});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let s=await fetch(C,{cache:`no-store`});if(!s.ok)throw Error(`HTTP ${s.status}`);let c=await s.json();S.current&&(i(c.repositories),l(!1),o(null)),await t?.()}catch(e){S.current&&x(e instanceof Error?e.message:String(e))}finally{S.current&&y(!1)}}}return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsxs)(Qq,{className:`flex items-center gap-2`,children:[(0,$.jsx)(al,{className:`h-4 w-4`}),n(`repositories.title`)]}),(0,$.jsx)($q,{children:n(`repositories.sharedBacklog`)})]}),(0,$.jsxs)(eJ,{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:v,onClick:()=>w(e),children:n(`actions.edit`)}),!e.isPrimary&&(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,disabled:v,onClick:()=>void T(`DELETE`,e.id),children:n(`repositories.detach`)})]})]}),(0,$.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:e.path}),e.workspacePaths?.map(e=>(0,$.jsxs)(`p`,{className:`break-all text-xs text-muted-foreground`,children:[n(`repositories.workspacePath`),`: `,e]},e)),!e.workspacePaths&&e.workspacePath&&(0,$.jsxs)(`p`,{className:`break-all text-xs text-muted-foreground`,children:[n(`repositories.workspacePath`),`: `,e.workspacePath]}),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`)}),b&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:b}),s||a?(0,$.jsxs)(`form`,{className:`space-y-3 rounded-lg border border-border p-3`,onSubmit:e=>{e.preventDefault(),T(a?`PATCH`:`POST`,a?.id)},children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.name`),(0,$.jsx)(gF,{value:f,disabled:v,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)(gF,{value:u,required:!0,disabled:v||a?.isPrimary,onChange:e=>d(e.target.value)}),`__TAURI_INTERNALS__`in window&&!a?.isPrimary&&(0,$.jsx)(Z,{type:`button`,variant:`outline`,disabled:v,"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([95,0,1])),t=await e({directory:!0,multiple:!1});typeof t==`string`&&S.current&&d(t)}catch{}},children:(0,$.jsx)(sl,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.workspacePath`),(0,$.jsx)(`textarea`,{className:`flex min-h-20 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:m,disabled:v,placeholder:a?.path??u,onChange:e=>h(e.target.value)}),(0,$.jsx)(`span`,{className:`block text-muted-foreground`,children:n(`repositories.workspaceHint`)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.integrationBranch`),(0,$.jsx)(gF,{value:g,disabled:v,placeholder:n(`repositories.branchDefault`),onChange:e=>_(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`submit`,size:`sm`,disabled:v||!u.trim(),children:n(v?`actions.saving`:`actions.save`)}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`ghost`,disabled:v,onClick:()=>{l(!1),o(null),x(null)},children:n(`actions.cancel`)})]})]}):(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,disabled:v,onClick:()=>w(),children:[(0,$.jsx)(Pn,{className:`mr-1 h-4 w-4`}),n(`repositories.addFolder`)]})]})]})}var hJ=[`claude`,`codex`,`gemini`,`kimi`],gJ=[`architect`,`developer`,`reviewer`];[...gJ];function _J(e){return e.kind===`openai-compatible`&&e.label?.trim()?e.label.trim():e.id}function vJ(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.providers)&&t.providers.every(e=>e&&typeof e.id==`string`&&[`cli`,`openai-compatible`].includes(e.kind))&&(t.status===void 0||typeof t.status==`object`&&t.status!==null)}var yJ=/^[a-z][a-z0-9-]{0,63}$/,bJ=[`architect`,`developer`,`host`];function xJ(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&Array.isArray(t.catalog)&&t.catalog.every(e=>e&&typeof e.id==`string`&&bJ.includes(e.phase))}function SJ(e,t,n){let r={...e};return n?delete r[t]:r[t]=!1,Object.keys(r).length?r:void 0}var CJ=[`type_correctness`,`pattern_adherence`,`test_coverage`,`security`,`architectural_alignment`],wJ={minScore:70,aspects:{type_correctness:60,pattern_adherence:60,test_coverage:60,security:75,architectural_alignment:60}};function TJ(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.config;return typeof t.configured==`boolean`&&typeof t.runtimeAvailable==`boolean`&&n?.schemaVersion===1&&typeof n.enabled==`boolean`&&Array.isArray(n.providers)&&n.providers.every(e=>e&&typeof e.id==`string`&&[`cli`,`openai-compatible`].includes(e.kind))&&Array.isArray(n.verification)&&(n.setup===void 0||Array.isArray(n.setup))&&!!n.agents&&gJ.every(e=>typeof n.agents[e]?.provider==`string`)&&(n.roles===void 0||n.roles!==null&&typeof n.roles==`object`&&!Array.isArray(n.roles)&&Object.entries(n.roles).every(([e,t])=>yJ.test(e)&&e!==`fixer`&&t&&typeof t.provider==`string`&&[`read`,`write`].includes(t.access)&&[`none`,`tasks-checkboxes`,`all`].includes(t.artifacts)))}function EJ(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.repositories)&&Array.isArray(t.suggestions)&&t.suggestions.every(e=>e&&typeof e.repositoryId==`string`&&typeof e.command==`string`&&Array.isArray(e.args))}function DJ(e,t){let n=t,r=2;for(;e.some(({id:e})=>e===n);)n=`${t}-${r++}`;return n}function OJ(e){return[e.command,...e.args].map(e=>/[\s"]/.test(e)?JSON.stringify(e):e).join(` `)}function kJ(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(r){if(o===`\\`&&a+1<e.length){n+=e[++a];continue}if(o===`"`){r=!1;continue}n+=o;continue}if(o===`"`){r=!0,i=!0;continue}if(/\s/.test(o)){i&&=(t.push(n),n=``,!1);continue}n+=o,i=!0}return r||(i&&t.push(n),!t.length||!t[0])?null:{command:t[0],args:t.slice(1)}}var AJ=`h-9 w-full rounded-md border border-input bg-background px-2 text-sm`;function jJ(e){return(e??[]).map(e=>({original:e,label:e.label,repositoryId:e.repositoryId,line:OJ(e)}))}function MJ(e,t){let n=[];for(let r of e){if(!r.line.trim()&&!r.repositoryId)continue;let e=kJ(r.line);if(!e||!r.repositoryId)return t(r.line||`∅`),null;n.push({...r.original,...r.label===void 0?{}:{label:r.label.trim()||void 0},repositoryId:r.repositoryId,...e})}return n}function NJ({rows:e,repositories:t,onChange:n,keys:r,placeholder:i,toolbar:a,testId:o}){let{t:s}=U(`agentRuntime`),c=(t,r)=>n(e.map((e,n)=>n===t?{...e,...r}:e)),l=(t,r)=>{let i=[...e];[i[r],i[t]]=[i[t],i[r]],n(i)};return(0,$.jsxs)(`div`,{className:`space-y-3`,"data-testid":o,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`${r}.hint`)}),a]}),r===`setup`&&e.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`setup.empty`)}),e.map((a,o)=>(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(8rem,1fr)_2fr_auto]`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[s(`${r}.repository`),t.length?(0,$.jsxs)(`select`,{className:AJ,value:a.repositoryId,onChange:e=>c(o,{repositoryId:e.target.value}),children:[!t.some(e=>e.id===a.repositoryId)&&(0,$.jsx)(`option`,{value:a.repositoryId,children:a.repositoryId||`—`}),t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):(0,$.jsx)(gF,{value:a.repositoryId,onChange:e=>c(o,{repositoryId:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[s(`${r}.command`),(0,$.jsx)(gF,{className:`font-mono`,spellCheck:!1,placeholder:i,value:a.line,onChange:e=>c(o,{line:e.target.value,reason:void 0})})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[s(`${r}.label`),(0,$.jsx)(gF,{maxLength:256,value:a.label??``,onChange:e=>c(o,{label:e.target.value})})]}),a.reason&&(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`verification.reason`,{reason:a.reason})})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-1`,children:[(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,"aria-label":`${s(`${r}.moveUp`)} ${o+1}`,disabled:o===0,onClick:()=>l(o,o-1),children:`↑`}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,"aria-label":`${s(`${r}.moveDown`)} ${o+1}`,disabled:o===e.length-1,onClick:()=>l(o,o+1),children:`↓`}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,onClick:()=>n(e.filter((e,t)=>t!==o)),children:s(`${r}.remove`)})]})]},o)),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,onClick:()=>n([...e,{repositoryId:t[0]?.id??``,line:``}]),children:s(`${r}.add`)})]})}function PJ(e){return e.map(e=>({repositoryId:e.repositoryId,line:OJ(e),reason:e.reason}))}function FJ(){let{activeProjectId:e,projects:t}=ce(),n=(0,Q.useRef)(new Map),r=t.find(t=>t.id===e);return e?(0,$.jsx)(IJ,{projectId:e,cache:n.current,repositories:kr(r).map(({id:e,name:t})=>({id:e,name:t}))},e):null}function IJ({projectId:e,cache:t,repositories:n}){let{t:r}=U(`agentRuntime`),i=t.get(e),[a,o]=(0,Q.useState)(i?.config??null),[s,c]=(0,Q.useState)(jJ(i?.config.verification)),[l,u]=(0,Q.useState)(jJ(i?.config.setup)),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!i),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O=(0,Q.useRef)(!0),k=`${Or(e)}/agent-runtime/config`;function A(e){D.current=!0,w(!0),S(!1),c(e)}function j(e){D.current=!0,w(!0),S(!1),u(e)}let M=`${Or(e)}/agent-runtime/verification-suggestions`;async function N(){try{let e=await fetch(M,{cache:`no-store`});if(!e.ok)return null;let t=await e.json();return EJ(t)?t.suggestions:null}catch{return null}}(0,Q.useEffect)(()=>{O.current=!0;let n=!1;return fetch(k,{cache:`no-store`}).then(async i=>{if(!i.ok)throw Error(r(`loadFailed`));let a=await i.json();if(!TJ(a))throw Error(r(`loadFailed`));if(!n){if(t.set(e,a),!D.current&&(o(a.config),c(jJ(a.config.verification)),u(jJ(a.config.setup)),!a.configured&&a.config.verification.length===0)){let e=await N();if(n||D.current)return;e?.length?(c(PJ(e)),g(`some`)):e&&g(`none`)}b(``)}}).catch(()=>{n||b(r(`loadFailed`))}).finally(()=>{n||v(!1)}),()=>{n=!0,O.current=!1}},[k,e,t,T,r]);let P=()=>MJ(s,e=>b(r(`verification.invalidLine`,{line:e}))),F=()=>MJ(l,e=>b(r(`setup.invalidLine`,{line:e})));async function I(){m(!0),b(``);try{let e=await N();if(!O.current)return;if(!e){b(r(`verification.detectFailed`));return}let t=new Set(s.map(e=>`${e.repositoryId}\0${e.line}`)),n=PJ(e).filter(e=>!t.has(`${e.repositoryId}\0${e.line}`));A([...s,...n]),g(e.length?`some`:`none`)}finally{O.current&&m(!1)}}async function ee(){if(!a||d)return;b(``),S(!1);let n=P();if(!n)return;let i=F();if(i){f(!0);try{let s=await fetch(k,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...a,verification:n,setup:i})}),l=await s.json();if(!s.ok)throw Error(l.message??l.error??r(`saveFailed`));if(!TJ(l))throw Error(r(`saveFailed`));if(t.set(e,l),!O.current)return;D.current=!1,w(!1),o(l.config),c(jJ(l.config.verification)),u(jJ(l.config.setup)),S(!0)}catch(e){O.current&&b(e instanceof Error?e.message:r(`saveFailed`))}finally{O.current&&f(!1)}}}function te(){return(0,$.jsx)(NJ,{rows:s,repositories:n,onChange:A,keys:`verification`,placeholder:`npm test`,testId:`verification-commands`,toolbar:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,disabled:p,onClick:()=>void I(),children:r(p?`verification.detecting`:`verification.detect`)}),h===`some`&&!s.some(e=>!e.reason)&&(0,$.jsx)(`p`,{role:`status`,className:`basis-full text-xs text-accent-success`,children:r(`verification.detected`)}),h===`none`&&s.length===0&&(0,$.jsx)(`p`,{role:`status`,className:`basis-full text-xs text-muted-foreground`,children:r(`verification.nothingDetected`)})]})})}function L(){return(0,$.jsxs)(`section`,{className:`space-y-3 border-t pt-4`,"aria-labelledby":`runtime-setup-title`,children:[(0,$.jsx)(`h3`,{id:`runtime-setup-title`,className:`text-sm font-medium`,children:r(`setup.title`)}),(0,$.jsx)(NJ,{rows:l,repositories:n,onChange:j,keys:`setup`,placeholder:`npx playwright install chromium`,testId:`setup-commands`})]})}return(0,$.jsxs)(Xq,{id:`agent-runtime-settings`,children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:r(`verification.title`)}),(0,$.jsx)($q,{children:r(`loopAgents.projectHint`)})]}),(0,$.jsxs)(eJ,{className:`space-y-4`,children:[_&&(0,$.jsx)(`p`,{role:`status`,children:r(`loading`)}),y&&(0,$.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:y}),!a&&!_&&(0,$.jsx)(Z,{onClick:()=>{v(!0),E(e=>e+1)},children:r(`retry`)}),a&&(0,$.jsxs)(`fieldset`,{disabled:d,className:`space-y-3`,children:[te(),L(),(0,$.jsxs)(`div`,{className:`sticky bottom-3 flex items-center justify-end gap-3 rounded border bg-card p-2`,"data-testid":`runtime-save-pill`,"data-unsaved":C,children:[C&&(0,$.jsx)(`span`,{children:r(`unsavedChanges`)}),x&&(0,$.jsx)(`p`,{role:`status`,children:r(`saved`)}),(0,$.jsx)(Z,{disabled:d,onClick:()=>void ee(),children:r(d?`saving`:`save`)})]})]})]})]})}function LJ(){return(0,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-lg bg-muted/30`,"data-testid":`section-skeleton`})}function RJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),[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(`${G()}/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)(LJ,{});async function c(t){a(!0);let i=n;r(t);try{if(!(await fetch(`${G()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pipelineTelemetryEnabled:t})})).ok)throw Error(`Failed to save`);K.success(e(t?`telemetry.enabled`:`telemetry.disabled`))}catch(t){r(i),K.error(e(`telemetry.saveFailed`),{description:t.message})}finally{a(!1)}}return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:e(`telemetry.title`)}),(0,$.jsx)($q,{children:e(`telemetry.description`)})]}),(0,$.jsx)(eJ,{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)(H,{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 zJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),[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(`${G()}/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)(LJ,{});async function d(){s(!0);try{let t=await fetch(`${G()}/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`)}K.success(e(`integrationBranch.saved`)),await u()}catch(t){K.error(e(`integrationBranch.saveFailed`),{description:t.message})}finally{s(!1)}}return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:e(`integrationBranch.title`)}),(0,$.jsx)($q,{children:e(`integrationBranch.description`)})]}),(0,$.jsxs)(eJ,{className:`space-y-3`,children:[(0,$.jsx)(gF,{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)(H,{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 BJ=/^[A-Za-z_][A-Za-z0-9_]*$/,VJ=[`NODE_AUTH_TOKEN`,`NPM_TOKEN`,`AWS_PROFILE`];function HJ(e){return e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}var UJ={inherited:`inherited`,recovered:`recovered`,"not-defined":`notDefined`,"probe-timeout":`probeTimeout`,"probe-failed":`probeFailed`,pending:`pending`},WJ={inherited:`success`,recovered:`success`,"not-defined":`warning`,"probe-timeout":`failed`,"probe-failed":`failed`,pending:`queued`},GJ=e=>e===`not-defined`||e===`probe-timeout`||e===`probe-failed`;function KJ({entry:e,report:t}){let{t:n}=U(`settings`),r=UJ[e.status],i=qJ(n,e,t);return(0,$.jsxs)(EN,{children:[(0,$.jsx)(DN,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:0,className:`inline-flex rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,$.jsx)(LH,{variant:WJ[e.status],className:`font-normal`,"data-testid":`worktree-env-status-${e.name}`,"data-status":e.status,"aria-label":`${e.name}: ${n(`worktreeEnv.status.${r}`)}`,children:n(`worktreeEnv.status.${r}`)})})}),(0,$.jsx)(ON,{className:`max-w-xs leading-relaxed`,children:i})]})}function qJ(e,t,n){let r={name:t.name,shell:t.shell??e(`worktreeEnv.hint.defaultShell`),seconds:Math.round(n.timeoutMs/1e3)};return t.status===`not-defined`&&!n.loginShellRecovery?e(`worktreeEnv.hint.notDefinedInherited`,r):e(`worktreeEnv.hint.${UJ[t.status]}`,r)}function JJ(){let{t:e,i18n:t}=U(`settings`),{activeProjectId:n}=ce(),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(0),b=(0,Q.useRef)(n);b.current=n;async function x(e){let t=++y.current,n=b.current,r=e===`POST`?`env-passthrough/recheck`:`env-passthrough/status`;try{let i=await fetch(`${G()}/${r}`,e===`POST`?{method:`POST`}:void 0);if(!i.ok)throw Error(String(i.status));let a=await i.json();if(t!==y.current||n!==b.current)return;m(a&&Array.isArray(a.names)?a:null),g(!1)}catch{if(t!==y.current||n!==b.current)return;g(!0)}}if((0,Q.useEffect)(()=>{if(!n)return;let e=!1;return f(!1),c(``),m(null),g(!1),v(!1),fetch(`${G()}/settings`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&i(Array.isArray(t.worktreeEnvPassthrough)?t.worktreeEnvPassthrough:[])}).catch(()=>{}).finally(()=>{e||f(!0)}),x(`GET`),()=>{e=!0,y.current+=1}},[n]),!d)return(0,$.jsx)(LJ,{});async function S(){v(!0);let e=b.current;try{await x(`POST`)}finally{e===b.current&&v(!1)}}let C=new Map((p?.names??[]).map(e=>[e.name,e])),w=(p?.names??[]).filter(e=>r.includes(e.name)&&GJ(e.status)),T=(p?.names??[]).map(e=>e.checkedAt).filter(e=>!!e).sort().pop();function E(t){let n=HJ(t);if(n.length===0)return;let a=[...r];for(let t of n){if(t.includes(`=`)){c(e(`worktreeEnv.noValues`));return}if(!BJ.test(t)){c(e(`worktreeEnv.invalidName`,{name:t}));return}a.includes(t)||a.push(t)}i(a),o(``),c(``)}async function D(){u(!0);try{let t=await fetch(`${G()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({worktreeEnvPassthrough:r})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to save`)}let n=await t.json();i(n.settings?.worktreeEnvPassthrough??r),K.success(e(`worktreeEnv.saved`)),x(`GET`)}catch(t){K.error(e(`worktreeEnv.saveFailed`),{description:t.message})}finally{u(!1)}}return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:e(`worktreeEnv.title`)}),(0,$.jsx)($q,{children:e(`worktreeEnv.description`)})]}),(0,$.jsxs)(eJ,{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)(gF,{id:`worktree-env-name`,value:a,onChange:e=>{o(e.target.value),c(``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E(a))},placeholder:e(`worktreeEnv.placeholder`),"aria-invalid":!!s,"data-testid":`worktree-env-input`}),(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`secondary`,className:`h-9 shrink-0`,onClick:()=>E(a),disabled:!a.trim(),"data-testid":`worktree-env-add`,children:[(0,$.jsx)(Pn,{className:`w-3.5 h-3.5`}),e(`worktreeEnv.add`)]})]}),s?(0,$.jsx)(`p`,{className:`text-[10px] text-destructive`,"data-testid":`worktree-env-error`,children:s}):(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`worktreeEnv.helper`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:VJ.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>E(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))}),r.length>0?(0,$.jsx)(TN,{delayDuration:200,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`worktree-env-list`,children:r.map(t=>{let n=C.get(t);return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-background py-1 pl-2 pr-1 font-mono text-[11px]`,children:[t,n&&p&&(0,$.jsx)(KJ,{entry:n,report:p}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(r.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)(Vn,{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`)}),p&&w.length>0&&(0,$.jsxs)(`ul`,{className:`space-y-1.5 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] leading-relaxed text-muted-foreground aurora-light:border-accent-warning/30 aurora-light:bg-accent-warning/5`,"data-testid":`worktree-env-unresolved`,children:[(0,$.jsx)(`li`,{className:`font-medium text-foreground`,children:e(`worktreeEnv.unresolvedTitle`)}),w.map(t=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:t.name}),` — `,qJ(e,t,p)]},t.name))]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`worktree-env-status-meta`,"aria-live":`polite`,children:h?e(`worktreeEnv.statusUnavailable`):_||p?.checking?e(`worktreeEnv.checking`):T?e(`worktreeEnv.lastChecked`,{time:new Date(T).toLocaleTimeString(t.language)}):null}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,onClick:()=>{S()},disabled:_||r.length===0,"data-testid":`worktree-env-recheck`,children:[(0,$.jsx)(Lu,{className:`w-3.5 h-3.5 ${_?`animate-spin`:``}`}),e(_?`worktreeEnv.checking`:`worktreeEnv.recheck`)]}),(0,$.jsx)(Z,{size:`sm`,onClick:D,disabled:l,"data-testid":`worktree-env-save`,children:e(l?`common:states.saving`:`worktreeEnv.save`)})]})]})]})]})}function YJ({value:e,onChange:t,onSave:n,isSaving:r,fieldId:i,i18nRoot:a}){let{t:o}=U(`settings`);return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:o(`${a}.title`)}),(0,$.jsx)($q,{children:o(`${a}.description`)})]}),(0,$.jsxs)(eJ,{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 XJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),[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(`${G()}/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(`${G()}/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),K.success(i.trim()===``?e(`prePrompt.cleared`):e(`prePrompt.saved`))}catch(t){K.error(e(`prePrompt.saveFailed`),{description:t.message})}finally{a(!1)}}async function m(){l(!0);try{let t=await fetch(`${G()}/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),K.success(n.trim()===``?e(`freestylePrePrompt.resetToDefault`):e(`freestylePrePrompt.saved`))}catch(t){K.error(e(`freestylePrePrompt.saveFailed`),{description:t.message})}finally{l(!1)}}return u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(YJ,{value:n,onChange:e=>{f.current.pre=!0,r(e)},onSave:p,isSaving:i,fieldId:`project-pre-prompt`,i18nRoot:`prePrompt`}),(0,$.jsx)(YJ,{value:o,onChange:e=>{f.current.freestyle=!0,s(e)},onSave:m,isSaving:c,fieldId:`project-freestyle-pre-prompt`,i18nRoot:`freestylePrePrompt`})]}):(0,$.jsx)(LJ,{})}function ZJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),[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(`${G()}/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(`${G()}/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`Failed to save`);K.success(n)}catch(t){K.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)){K.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)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:e(`budget.title`)}),(0,$.jsx)($q,{children:e(`budget.description`)})]}),(0,$.jsx)(eJ,{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)(gF,{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)(gF,{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)(LJ,{})}function QJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),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(`${G()}/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)(RJ,{}),(0,$.jsx)(XJ,{}),(0,$.jsx)(pJ,{}),(0,$.jsx)(FJ,{}),(0,$.jsx)(sJ,{}),(0,$.jsx)(zJ,{}),(0,$.jsx)(JJ,{}),(0,$.jsx)(ZJ,{}),(0,$.jsx)(uJ,{mode:`project`})]})}var $J=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{},eY=e=>e===null||typeof e==`string`&&Number.isFinite(Date.parse(e)),tY=e=>e===null||typeof e==`string`;function nY(e){let t=$J(e);if(t.scope!==`machine`||typeof t.instanceId!=`string`||!t.instanceId||!Number.isSafeInteger(t.revision)||t.revision<0||!Array.isArray(t.providers)||t.providers.length!==2)return!1;let n=new Set;for(let e of t.providers){let t=$J(e);if(![`claude`,`codex`].includes(t.providerId)||n.has(t.providerId)||(n.add(t.providerId),typeof t.generation!=`string`||!(t.installed===null||typeof t.installed==`boolean`)||!tY(t.plan)||![`available`,`signed-out`,`unsupported-auth`,`unsupported-cli`,`unsupported-platform`,`unavailable`].includes(t.availability)||![`idle`,`refreshing`,`error`].includes(t.refreshState)||![`unknown`,`fresh`,`stale`].includes(t.freshness)||!(t.source===null||t.source===`oauth`||t.source===`app-server`)||!eY(t.observedAt)||!eY(t.attemptedAt)||!eY(t.retryAt)||!Array.isArray(t.windows)||t.windows.length>64))return!1;if(t.issue!==null){let e=$J(t.issue);if(typeof e.code!=`string`||typeof e.retryable!=`boolean`)return!1}if(t.spend!=null){let e=$J(t.spend),n=e=>e===null||typeof e==`number`&&Number.isFinite(e)&&e>=0;if(t.providerId!==`claude`||t.plan!==`enterprise`||e.kind!==`enterprise-on-demand`||!n(e.usedAmount)||!n(e.limitAmount)||!n(e.usedPercent)||e.usedAmount===null&&e.limitAmount===null||!eY(e.resetsAt)||typeof e.currency!=`string`||!/^[A-Z]{3}$/.test(e.currency)||![`limited`,`unlimited`,`unknown`].includes(e.limitStatus)||e.limitStatus===`limited`!=(e.limitAmount!==null)||e.limitStatus!==`limited`&&e.usedPercent!==null||t.windows.some(e=>{let t=$J(e);return t.usedPercent!==null||t.resetsAt!==null}))return!1}for(let e of t.windows){let t=$J(e);if(typeof t.id!=`string`||typeof t.label!=`string`||!tY(t.model)||![`account`,`model`].includes(t.scope)||!(t.usedPercent===null||typeof t.usedPercent==`number`&&Number.isFinite(t.usedPercent)&&t.usedPercent>=0&&t.usedPercent<=100)||!(t.durationMinutes===null||typeof t.durationMinutes==`number`&&Number.isFinite(t.durationMinutes)&&t.durationMinutes>0)||!eY(t.resetsAt))return!1}}return!0}function rY(e=(...e)=>fetch(...e)){let t={snapshot:null,error:!1,busy:!1},n=new Set,r=new Set,i,a,o=0,s=0,c=0,l=e=>{t=e,n.forEach(e=>e())},u=e=>{if(!nY(e))throw Error(`Invalid usage snapshot`);if(r.has(e.instanceId))return;let n=!!t.snapshot&&e.instanceId!==t.snapshot.instanceId;n&&(r.add(t.snapshot.instanceId),o=0),(!t.snapshot||n||e.revision>=t.snapshot.revision)&&l({...t,snapshot:e,error:!1})},d=()=>n.size>0&&document.visibilityState!==`hidden`;function f(e){clearTimeout(i),d()&&(i=setTimeout(()=>{m()},e))}async function p(n,r=!1){if(t.busy||!d())return;l({...t,busy:!0});let i=c,p=new AbortController;a?.abort(),a=p;try{let t=await e(`${F}/api/subscription-usage/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n?{providerId:n}:{},automatic:r}),signal:AbortSignal.any([p.signal,AbortSignal.timeout(3e4)])});if(!t.ok)throw Error(`Usage refresh failed`);let a=await t.json();if(i!==c||p.signal.aborted)return;u(a.snapshot),s=Date.now(),o=Date.now()+12e4,f(a.scheduled?1e3:3e4)}catch{i===c&&!p.signal.aborted&&(l({...t,error:!0}),f(3e4))}finally{i===c&&l({...t,busy:!1})}}async function m(){if(!d()||t.busy)return;let n=c,r=new AbortController;a?.abort(),a=r;try{let i=await e(`${F}/api/subscription-usage`,{signal:AbortSignal.any([r.signal,AbortSignal.timeout(1e4)])});if(!i.ok)throw Error(`Usage read failed`);let a=await i.json();if(n!==c||r.signal.aborted)return;if(u(a),t.snapshot?.providers.some(e=>e.refreshState===`refreshing`)){if(s||=Date.now(),Date.now()-s<3e4){f(1e3);return}l({...t,error:!0}),f(3e4);return}if(s=0,Date.now()>=o){await p(void 0,!0);return}f(3e4)}catch{n===c&&!r.signal.aborted&&(l({...t,error:!0}),f(3e4))}}function h(){c++,a?.abort(),clearTimeout(i),l({...t,busy:!1}),d()&&(o=0,m())}function g(e){return n.add(e),n.size===1&&(document.addEventListener(`visibilitychange`,h),m()),()=>{n.delete(e),n.size||(c++,a?.abort(),clearTimeout(i),document.removeEventListener(`visibilitychange`,h),t={...t,busy:!1})}}return{subscribe:g,getSnapshot:()=>t,refresh:p}}var iY=rY();function aY(){return{...(0,Q.useSyncExternalStore)(iY.subscribe,iY.getSnapshot),refresh:iY.refresh}}function oY(e,t){return new Intl.NumberFormat(t,{style:`percent`,maximumFractionDigits:1}).format(e/100)}function sY({spend:e,stale:t,now:n,compact:r=!1}){let{t:i,i18n:a}=U(`subscriptionUsage`),o=t=>t===null?`—`:new Intl.NumberFormat(a.language,{style:`currency`,currency:e.currency}).format(t),s=e.limitStatus===`limited`?i(`spend.amounts`,{used:o(e.usedAmount),limit:o(e.limitAmount)}):i(`spend.consumed`,{used:o(e.usedAmount)}),c=e.usedPercent,l=e.resetsAt?new Intl.DateTimeFormat(a.language,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e.resetsAt)):null;return(0,$.jsxs)(`div`,{className:X(`space-y-1.5`,r?`text-[10px]`:`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:i(`spend.monthly`)}),c!==null&&(0,$.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:oY(c,a.language)})]}),(0,$.jsx)(`p`,{className:`font-medium tabular-nums text-foreground`,children:s}),c!==null&&(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":i(`spend.progress`),"aria-valuenow":Math.min(100,c),"aria-valuemin":0,"aria-valuemax":100,"aria-valuetext":s,className:X(`overflow-hidden rounded-full bg-muted`,r?`h-1`:`h-1.5`),children:(0,$.jsx)(`div`,{className:X(`h-full rounded-full`,t?`bg-muted-foreground/50`:c>=90?`bg-destructive`:c>=80?`bg-accent-warning`:`bg-accent-primary`),style:{width:`${Math.min(100,c)}%`}})}),e.limitStatus!==`limited`&&(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:i(e.limitStatus===`unlimited`?`spend.unlimited`:`spend.limitUnknown`)}),(0,$.jsx)(`p`,{className:`tabular-nums text-muted-foreground`,children:e.resetsAt&&Date.parse(e.resetsAt)<=n?i(`resetPassed`):l?i(`spend.resets`,{time:l}):i(`resetUnknown`)}),!t&&(c!==null&&c>=100||e.limitAmount===0)&&(0,$.jsx)(`p`,{className:`text-destructive`,children:i(`limitReached`)})]})}function cY(){let[e,t]=(0,Q.useState)(Date.now);return(0,Q.useEffect)(()=>{let e=setInterval(()=>{document.visibilityState!==`hidden`&&t(Date.now())},6e4);return()=>clearInterval(e)},[]),e}function lY(e,t){return e.freshness===`stale`||!!e.observedAt&&t-Date.parse(e.observedAt)>=3e5||e.windows.some(e=>e.resetsAt&&Date.parse(e.resetsAt)<=t)||!!e.spend?.resetsAt&&Date.parse(e.spend.resetsAt)<=t}function uY(e,t){let n=[`session`,`weekly`,`monthly`].includes(e.label)?t(`windows.${e.label}`):t(`windows.window`);return e.model?`${e.model} · ${n}`:n}function dY(e){return e.installed===!1?`cli-missing`:e.issue?.code??(e.availability===`available`?``:e.availability)}function fY({selectedProvider:e,showDataDetails:t=!1}){let{t:n,i18n:r}=U(`subscriptionUsage`),{snapshot:i,busy:a,error:o,refresh:s}=aY(),c=cY(),l=i?.providers.filter(t=>!e||t.providerId===e)??[],u=a||l.some(e=>e.refreshState===`refreshing`),d=l.length>0&&l.every(e=>e.retryAt&&Date.parse(e.retryAt)>c),f=i?.providers.every(e=>e.installed===!1),p=e=>new Intl.DateTimeFormat(r.language,{dateStyle:`medium`,timeStyle:`long`}).format(new Date(e));function m(e){let t=(Date.parse(e)-c)/6e4,n=Math.abs(t)>=1440?`day`:Math.abs(t)>=60?`hour`:`minute`;return new Intl.RelativeTimeFormat(r.language,{numeric:`auto`}).format(Math.round(t/(n===`day`?1440:n===`hour`?60:1)),n)}return(0,$.jsxs)(`section`,{className:`space-y-4`,"aria-label":n(`title`),children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:n(`title`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`subtitle`)})]}),(0,$.jsx)(Z,{size:`icon`,variant:`ghost`,className:`h-8 w-8 shrink-0`,"aria-label":n(`refresh`),"aria-busy":u,disabled:u||d,onClick:()=>void s(e),children:(0,$.jsx)(Lu,{className:X(`h-4 w-4`,u&&`motion-safe:animate-spin`)})})]}),!i&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(o?`loadFailed`:`loading`)}),f&&(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-3 text-sm text-muted-foreground`,children:n(`empty`)}),l.map(e=>{let r=lY(e,c),i=dY(e);return(0,$.jsxs)(`article`,{className:`space-y-2 border-b border-border pb-4 last:border-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[e.providerId===`claude`?`Claude`:`Codex`,` `,e.plan&&(0,$.jsx)(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] font-normal text-muted-foreground`,children:e.spend?n(`spend.enterprise`):e.plan})]}),e.observedAt&&(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:p(e.observedAt),children:r?n(`stale`):n(`updated`,{time:m(e.observedAt)})})]}),e.spend&&(0,$.jsx)(sY,{spend:e.spend,stale:r,now:c}),e.windows.map(t=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-1 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:uY(t,n)}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:t.usedPercent===null?n(`unknown`):n(`used`,{value:t.usedPercent})})]}),t.usedPercent!==null&&(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":`${e.providerId} ${uY(t,n)}`,"aria-valuenow":t.usedPercent,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:X(`h-full rounded-full`,r?`bg-muted-foreground/50`:t.usedPercent>=90?`bg-destructive`:t.usedPercent>=80?`bg-accent-warning`:`bg-accent-primary`),style:{width:`${t.usedPercent}%`}})}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,title:t.resetsAt?p(t.resetsAt):void 0,children:t.resetsAt?Date.parse(t.resetsAt)<=c?n(`resetPassed`):n(`resets`,{time:m(t.resetsAt)}):n(`resetUnknown`)}),t.usedPercent===100&&!r&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:n(`limitReached`)})]},t.id)),i&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`issues.${i}`,{defaultValue:n(`issues.collection-failed`)})}),e.retryAt&&Date.parse(e.retryAt)>c&&(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:n(`retry`,{time:m(e.retryAt)})}),t&&e.observedAt&&(0,$.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:n(`dataDetails`)}),(0,$.jsx)(`p`,{className:`mt-2`,children:n(`observed`,{time:p(e.observedAt)})}),e.source&&(0,$.jsx)(`p`,{children:n(`source`,{source:e.source})})]})]},e.providerId)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`accountWide`)}),(0,$.jsx)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:u?n(`refreshing`):o?n(`loadFailed`):i?n(`ready`):``}),o&&i&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`loadFailed`)})]})}function pY(){let{t:e}=U(`settings`),t=pM();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:()=>dM({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)(Ln,{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)(iM,{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 mY(){let{t:e}=U(`settings`),t=Na();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){K.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:oa.map(t=>{let r=xa[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)(xn,{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 hY(){let{t:e}=U(`settings`);return Na()?(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)(mY,{})]}):null}function gY(e={}){let t={...e},n=P();return n&&(t[`X-Desktop-Token`]=n),t}var _Y=(0,Q.createContext)(null);function vY(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(j,e)}catch{}}function yY(){if(!(typeof localStorage>`u`))try{localStorage.removeItem(j)}catch{}}function bY({children:e,endpoint:t=`/api/language`}){let[n,r]=(0,Q.useState)(()=>L()),[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:gY()});if(!n.ok)return;let i=await n.json();if(e)return;D(i.language)&&i.language!==L()&&(await V(i.language),vY(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`&&D(localStorage.getItem(`specrails-desktop:ui-language`));await V(e),vY(e),r(e),a(!0);try{let n=await fetch(t,{method:`PATCH`,headers:gY({"Content-Type":`application/json`}),body:JSON.stringify({language:e})});if(!n.ok)throw Error(`server rejected language: ${n.status}`)}catch(e){throw await V(i),o?vY(i):yY(),r(i),e}finally{a(!1)}},[n,t]),c=(0,Q.useMemo)(()=>({languageId:n,language:ne[n],setLanguage:s,isUpdating:i}),[n,s,i]);return(0,$.jsx)(_Y.Provider,{value:c,children:e})}function xY(){return(0,Q.useContext)(_Y)}function SY(){let{t:e}=U(`settings`),t=xY();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){K.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:A.map(e=>{let t=ne[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)(xn,{className:`w-3.5 h-3.5 text-accent-primary shrink-0`,"aria-hidden":`true`})]},e)})})}function CY(){let{t:e}=U(`settings`);return xY()?(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)(SY,{})]}):null}function wY(){if(!Ke)return null;let{t:e}=U(`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){K.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 TY=`h-9 w-full rounded-md border border-input bg-background px-2 text-sm`;function EY({provider:e,onChange:t,onRemove:n}){let{t:r}=U(`agentRuntime`),i=e.kind===`openai-compatible`,a=i?$u:pd;return(0,$.jsxs)(`fieldset`,{className:`rounded-xl border border-border/70 bg-card/60 p-4 shadow-sm transition-colors hover:border-border`,"data-testid":`connection-row-${e.id}`,children:[(0,$.jsxs)(`legend`,{className:`flex items-center gap-2 px-1.5 text-sm font-medium`,children:[(0,$.jsx)(a,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":!0}),_J(e),(0,$.jsx)(`span`,{className:`rounded-full border border-border bg-muted/40 px-2 py-px text-[10px] font-normal uppercase tracking-wide text-muted-foreground`,children:r(i?`providers.localBadge`:`providers.cliBadge`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[r(`providers.id`),(0,$.jsx)(gF,{value:e.id,onChange:n=>t({...e,id:n.target.value})})]}),e.kind===`cli`?(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[r(`providers.command`),(0,$.jsx)(`select`,{className:TY,value:e.cli,onChange:n=>t({...e,cli:n.target.value}),children:hJ.filter(on).map(e=>(0,$.jsx)(`option`,{value:e,children:r(`cliNames.${e}`)},e))})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[r(`providers.baseUrl`),(0,$.jsx)(gF,{type:`url`,value:e.baseUrl,onChange:n=>t({...e,baseUrl:n.target.value})})]}),(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[r(`providers.apiKeyEnv`),(0,$.jsx)(gF,{value:e.apiKeyEnv??``,onChange:n=>t({...e,apiKeyEnv:n.target.value||void 0})})]})]})]}),(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:n,children:r(`providers.remove`)})]})]})}function DY(e,t=!1){if(t)return`probing`;if(!e)return`untested`;let n=e.reachable??e.installed;return n===void 0?`untested`:n?e.authState===`unauthenticated`?`unauthorized`:`reachable`:`unreachable`}var OY={probing:{dot:`bg-accent-info animate-pulse`,pill:`border-accent-info/30 bg-accent-info/10 text-accent-info`},reachable:{dot:`bg-accent-success`,pill:`border-accent-success/30 bg-accent-success/10 text-accent-success`},unauthorized:{dot:`bg-accent-warning`,pill:`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`},unreachable:{dot:`bg-destructive`,pill:`border-destructive/30 bg-destructive/10 text-destructive`},untested:{dot:`bg-muted-foreground/50`,pill:`border-border bg-muted/40 text-muted-foreground`}};function kY({state:e,latencyMs:t,className:n}){let{t:r}=U(`agentRuntime`),i=OY[e];return(0,$.jsxs)(`span`,{"data-testid":`connection-status-pill`,"data-state":e,role:`status`,className:X(`inline-flex h-6 items-center gap-1.5 rounded-full border px-2.5 text-[11px] font-medium transition-colors`,i.pill,n),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 rounded-full`,i.dot)}),r(`providers.status.${e}`),e===`reachable`&&typeof t==`number`&&(0,$.jsxs)(`span`,{className:`text-[10px] font-normal opacity-70 tabular-nums`,children:[`· `,t,` ms`]})]})}function AY({label:e,items:t,trigger:n,triggerClassName:r,align:i=`right`}){let[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useId)();return(0,Q.useEffect)(()=>{if(!a)return;function e(e){s.current&&!s.current.contains(e.target)&&o(!1)}function t(e){if(e.key===`Escape`){o(!1);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(s.current?.querySelectorAll(`[role="menuitem"]`)??[]);if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length]?.focus()}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),(0,$.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":n?void 0:e,title:n?void 0:e,"aria-haspopup":`menu`,"aria-expanded":a,"aria-controls":a?c:void 0,onClick:()=>o(e=>!e),className:X(`inline-flex h-7 items-center justify-center gap-1.5 rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,n?`px-2 text-xs`:`w-7`,a&&`bg-accent text-foreground`,r),children:n??(0,$.jsx)(Gc,{className:`h-4 w-4`,"aria-hidden":!0})}),a&&(0,$.jsx)(`div`,{id:c,role:`menu`,"aria-label":e,className:X(`absolute top-full z-30 mt-1 min-w-40 overflow-hidden rounded-lg border border-border bg-card p-1 shadow-lg`,i===`right`?`right-0`:`left-0`),children:t.map(e=>(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{o(!1),e.onSelect()},className:X(`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none`,e.destructive?`text-destructive`:`text-foreground`),children:[e.icon,e.label]},e.id))})]})}function jY({provider:e,status:t,onRemove:n}){let{t:r}=U(`agentRuntime`),i=!!t;return(0,$.jsxs)(`li`,{"data-testid":`connection-row-${e.id}`,"data-kind":`cli`,className:X(`flex min-h-11 items-center gap-3 px-3 py-1.5 transition-colors`,i?`hover:bg-muted/30`:`opacity-55`),children:[(0,$.jsx)(`span`,{className:X(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,i?`border-accent-info/30 bg-accent-info/10 text-accent-info`:`border-border bg-muted/40 text-muted-foreground`),children:(0,$.jsx)(pd,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:r(`cliNames.${e.cli}`)}),t?.version&&(0,$.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:[`v`,t.version]}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground/60`,children:e.id})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kY,{state:DY(t)}),(0,$.jsx)(`span`,{className:X(`hidden text-[11px] sm:inline`,t?.authState===`authenticated`?`text-muted-foreground`:`text-accent-warning`),children:r(`providers.auth.${t.authState}`)})]}):(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`providers.notDetected`)}),(0,$.jsx)(AY,{label:r(`providers.overflow`),items:[{id:`remove`,label:r(`providers.remove`),icon:(0,$.jsx)(Rn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),destructive:!0,onSelect:n}]})]})]})}function MY(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.reachable==`boolean`&&typeof t.authState==`string`}function NY({baseUrl:e,apiKeyEnv:t,disabled:n,onStart:r,onResult:i,onError:a}){let{t:o}=U(`agentRuntime`),[s,c]=(0,Q.useState)(!1);async function l(){c(!0),r?.();try{let n=await fetch(`/api/runtime-providers/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({baseUrl:e,...t?{apiKeyEnv:t}:{}})}),r=await n.json().catch(()=>null);if(!n.ok||!MY(r))throw Error(r?.message??o(`providers.testFailed`));i({...r,models:Array.isArray(r.models)?r.models:[]})}catch(e){a(e.message||o(`providers.testFailed`))}finally{c(!1)}}return(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,size:`sm`,disabled:n||s||!e.trim(),onClick:()=>void l(),className:`gap-1.5`,children:[s?(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Tu,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(s?`providers.testing`:`providers.test`)]})}function PY(e){return(e.agentLoop??`compact`)===`compact`&&e.supportsReasoningEffort===!0&&(e.contextWindowTokens??0)>=32768}var FY=`__custom__`,IY=`h-9 w-full rounded-md border border-input bg-background px-2 text-sm`,LY=`space-y-1 text-xs text-muted-foreground`;function RY(e){return e===void 0?``:String(e)}function zY(e){if(e.trim()===``)return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:NaN}function BY({provider:e,status:t,persisted:n,onChange:r,onStatus:i,onValidity:a,onRemove:o}){let{t:s}=U(`agentRuntime`),c=(0,Q.useId)(),[l,u]=(0,Q.useState)(!n),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)({input:RY(e.rates?.inputPer1M),output:RY(e.rates?.outputPer1M)}),[_,v]=(0,Q.useState)(!1),y=t?.models??[],b=!e.defaultModel||y.includes(e.defaultModel),x=_||!b,S=zY(h.input),C=zY(h.output),w=Number.isNaN(S)||Number.isNaN(C)||S===null!=(C===null);(0,Q.useEffect)(()=>{a(!w)},[w,a]);function T(t,n){let i={...h,[t]:n};g(i);let a=zY(i.input),o=zY(i.output);a===null&&o===null?r({...e,rates:void 0}):a!==null&&o!==null&&!Number.isNaN(a)&&!Number.isNaN(o)&&r({...e,rates:{inputPer1M:a,outputPer1M:o}})}function E(t){f(!1),m(``),i({reachable:t.reachable,authState:t.authState,models:t.models,latencyMs:t.latencyMs,error:t.error,apiKeyEnvMissing:t.apiKeyEnvMissing}),t.models.length&&Gw(e.id,t.models)}let D=DY(t,d);return(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`local-connection-${e.id}`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(kY,{state:D,latencyMs:t?.latencyMs}),t?.error&&D!==`reachable`&&(0,$.jsx)(`span`,{className:`truncate text-[11px] text-destructive/90`,title:t.error,children:t.error}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(NY,{baseUrl:e.baseUrl,apiKeyEnv:e.apiKeyEnv,onStart:()=>{f(!0),m(``)},onResult:E,onError:e=>{f(!1),m(e)}}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:o,children:s(`providers.remove`)})]})]}),p&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:p}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:LY,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`label`,{htmlFor:`${c}-id`,children:s(`providers.id`)}),n&&!l&&(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent-primary hover:underline`,onClick:()=>u(!0),children:[(0,$.jsx)(jn,{className:`h-3 w-3`,"aria-hidden":!0}),s(`providers.rename`)]})]}),(0,$.jsx)(gF,{id:`${c}-id`,value:e.id,readOnly:!l,"aria-readonly":!l,title:l?void 0:s(`providers.idLocked`),className:X(!l&&`text-muted-foreground`),onChange:t=>r({...e,id:t.target.value})}),l&&n&&(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:s(`providers.renameHint`)})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-label`,children:[s(`providers.label`),(0,$.jsx)(gF,{id:`${c}-label`,value:e.label??``,placeholder:s(`providers.labelPlaceholder`),onChange:t=>r({...e,label:t.target.value||void 0})})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-url`,children:[s(`providers.baseUrl`),(0,$.jsx)(gF,{id:`${c}-url`,type:`url`,value:e.baseUrl,onChange:t=>r({...e,baseUrl:t.target.value})})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-env`,children:[s(`providers.apiKeyEnv`),(0,$.jsx)(gF,{id:`${c}-env`,value:e.apiKeyEnv??``,onChange:t=>r({...e,apiKeyEnv:t.target.value||void 0})}),t?.apiKeyEnvMissing&&e.apiKeyEnv&&(0,$.jsxs)(`span`,{role:`note`,className:`flex items-center gap-1 text-[11px] text-accent-warning`,children:[(0,$.jsx)(zn,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),s(`providers.apiKeyEnvMissing`,{name:e.apiKeyEnv})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`providers.discoveredModels`)}),y.length===0?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:s(`providers.noModels`)}):(0,$.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":s(`providers.discoveredModels`),children:y.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>{v(!1),r({...e,defaultModel:t})},className:X(`rounded-full border px-2.5 py-0.5 font-mono text-[11px] transition-colors`,e.defaultModel===t?`border-accent-primary/50 bg-accent-primary/10 text-foreground`:`border-border bg-muted/30 text-muted-foreground hover:text-foreground`),"aria-pressed":e.defaultModel===t,children:t})},t))}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-default`,children:[s(`providers.defaultModel`),(0,$.jsxs)(`select`,{id:`${c}-default`,className:IY,value:x?FY:e.defaultModel??``,onChange:t=>{if(t.target.value===FY){v(!0);return}v(!1),r({...e,defaultModel:t.target.value||void 0})},children:[(0,$.jsx)(`option`,{value:``,children:s(`providers.defaultModelNone`)}),y.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e)),(0,$.jsx)(`option`,{value:FY,children:s(`providers.customModel`)})]})]}),x&&(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-custom`,children:[s(`providers.customModel`),(0,$.jsx)(gF,{id:`${c}-custom`,value:e.defaultModel??``,placeholder:s(`providers.defaultModelPlaceholder`),onChange:t=>r({...e,defaultModel:t.target.value||void 0})})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s(`providers.rates`),` `,(0,$.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`· `,s(`providers.ratesHint`)]})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-in`,children:[s(`providers.inputRate`),(0,$.jsx)(gF,{id:`${c}-in`,type:`number`,min:`0`,step:`0.01`,inputMode:`decimal`,value:h.input,onChange:e=>T(`input`,e.target.value),"aria-invalid":w})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-out`,children:[s(`providers.outputRate`),(0,$.jsx)(gF,{id:`${c}-out`,type:`number`,min:`0`,step:`0.01`,inputMode:`decimal`,value:h.output,onChange:e=>T(`output`,e.target.value),"aria-invalid":w})]})]}),w&&(0,$.jsx)(`p`,{role:`alert`,className:`text-[11px] text-destructive`,children:s(`providers.ratesInvalid`)})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-xs`,htmlFor:`${c}-effort`,children:[(0,$.jsx)(`input`,{id:`${c}-effort`,type:`checkbox`,role:`switch`,"aria-checked":!!e.supportsReasoningEffort,className:`mt-0.5 accent-accent-primary`,checked:!!e.supportsReasoningEffort,onChange:t=>r({...e,supportsReasoningEffort:t.target.checked||void 0})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-foreground`,children:s(`providers.reasoningEffort`)}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`providers.reasoningEffortHint`)}),!e.supportsReasoningEffort&&(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground/70`,children:s(`providers.reasoningEffortRailHint`)})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 bg-background/40 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`providers.presetTitle`)}),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,size:`sm`,disabled:PY(e),title:s(`providers.presetSmallModelHint`),onClick:()=>r({...e,agentLoop:void 0,supportsReasoningEffort:!0,contextWindowTokens:e.contextWindowTokens??32768}),children:[(0,$.jsx)(Ln,{className:`mr-1 h-3.5 w-3.5`,"aria-hidden":!0}),PY(e)?s(`providers.presetSmallModelApplied`):s(`providers.presetSmallModel`)]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:s(`providers.presetSmallModelHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 bg-background/40 p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s(`providers.agentLoop`),` `,(0,$.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`· `,s(`providers.agentLoopHint`)]})]}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`providers.agentLoop`),className:`grid grid-cols-2 gap-1 rounded-md bg-muted/40 p-1`,children:[`compact`,`free`].map(t=>{let n=(e.agentLoop??`compact`)===t;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,className:X(`rounded px-2 py-1.5 text-xs transition-colors`,n?`bg-accent-primary/15 text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),onClick:()=>r({...e,agentLoop:t===`compact`?void 0:t}),children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:s(`providers.agentLoop_${t}`)}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`providers.agentLoop_${t}Hint`)})]},t)})}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-ctx`,children:[s(`providers.contextWindow`),(0,$.jsx)(gF,{id:`${c}-ctx`,type:`number`,min:4096,step:1024,inputMode:`numeric`,placeholder:`32768`,value:e.contextWindowTokens??``,"aria-invalid":e.contextWindowTokens!==void 0&&e.contextWindowTokens<4096,onChange:t=>{let n=Number.parseInt(t.target.value,10);r({...e,contextWindowTokens:Number.isFinite(n)&&t.target.value!==``?n:void 0})}}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`providers.contextWindowHint`)})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-out`,children:[s(`providers.maxOutput`),(0,$.jsx)(gF,{id:`${c}-out`,type:`number`,min:1024,step:1024,inputMode:`numeric`,placeholder:`8192`,value:e.maxOutputTokens??``,"aria-invalid":e.maxOutputTokens!==void 0&&e.maxOutputTokens<1024,onChange:t=>{let n=Number.parseInt(t.target.value,10);r({...e,maxOutputTokens:Number.isFinite(n)&&t.target.value!==``?n:void 0})}}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`providers.maxOutputHint`)})]})]})]})}function VY(e){let t=e??32768;return t>=1024&&t%1024==0?`${t/1024}k`:t.toLocaleString()}function HY({provider:e,status:t,persisted:n,invalid:r=!1,onChange:i,onStatus:a,onValidity:o,onRemove:s}){let{t:c}=U(`agentRuntime`),[l,u]=(0,Q.useState)(!n),d=l||r,f=t?.models?.length??0,p=e.agentLoop??`compact`,m=_J(e),h=`local-engine-editor-${e.id||`new`}`;return(0,$.jsxs)(`div`,{"data-testid":`connection-row-${e.id}`,"data-kind":`local`,"data-expanded":d,className:X(`rounded-xl border bg-card/60 shadow-sm transition-colors`,d?`border-accent-primary/30`:`border-border/70 hover:border-border`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`,children:(0,$.jsx)($u,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:m}),e.label?.trim()&&(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground/60`,children:e.id}),(0,$.jsx)(kY,{state:DY(t),latencyMs:t?.latencyMs})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`truncate font-mono`,children:e.baseUrl||`—`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/40`,children:`·`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:c(`providers.models`,{count:f})}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/40`,children:`·`}),(0,$.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[10px] font-medium`,p===`compact`?`border-accent-secondary/30 bg-accent-secondary/10 text-accent-secondary`:`border-border bg-muted/40 text-muted-foreground`),"data-testid":`agent-loop-chip`,children:c(`providers.agentLoop_${p}`)}),(0,$.jsxs)(`span`,{className:`tabular-nums`,title:c(`providers.contextWindow`),children:[VY(e.contextWindowTokens),` ctx`]})]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-expanded":d,"aria-controls":h,"aria-label":c(d?`providers.collapse`:`providers.expand`),title:c(d?`providers.collapse`:`providers.expand`),disabled:r,onClick:()=>u(!d),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40`,children:(0,$.jsx)(rc,{className:X(`h-4 w-4 transition-transform duration-200`,d&&`rotate-180`),"aria-hidden":!0})})]}),d&&(0,$.jsx)(`div`,{id:h,className:`border-t border-border/60 px-4 pb-4 pt-3`,children:(0,$.jsx)(BY,{provider:e,status:t,persisted:n,onChange:i,onStatus:a,onValidity:o,onRemove:s})})]})}var UY=1;function WY(e,t){return e.map(e=>({key:UY++,provider:e,persisted:t}))}function GY(){let{t:e}=U(`agentRuntime`),t=!Ze(),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)({}),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(()=>new Set),m=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{m.current=!0;let t=!1;return fetch(`/api/runtime-providers`).then(async n=>{let i=await n.json();if(!n.ok||!vJ(i))throw Error(i?.message??e(`loadFailed`));t||(r(WY(i.providers,!0)),a(i.providers),s(i.status??{}))}).catch(e=>{t||l(e.message)}),()=>{t=!0,m.current=!1}},[e]);let h=(0,Q.useMemo)(()=>n?.map(e=>e.provider)??null,[n]),g=h!==null&&i!==null&&JSON.stringify(h)!==JSON.stringify(i),_=f.size>0,v=(0,Q.useCallback)((e,t)=>{r(n=>n?.map(n=>n.key===e?{...n,provider:t}:n)??n)},[]),y=(0,Q.useCallback)(e=>{r(t=>t?.filter(t=>t.key!==e)??t),p(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),b=(0,Q.useCallback)((e,t)=>{p(n=>{if(n.has(e)===!t)return n;let r=new Set(n);return t?r.delete(e):r.add(e),r})},[]),x=(0,Q.useCallback)((e,t)=>{s(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},[]);function S(){if(!n)return;let e={id:DJ(n.map(e=>e.provider),`local`),kind:`openai-compatible`,baseUrl:`http://127.0.0.1:11434/v1`};r([...n,{key:UY++,provider:e,persisted:!1}])}function C(e){if(!n)return;let t=n.map(e=>e.provider),i=e&&!t.some(t=>t.id===e)?{id:e,kind:`cli`,cli:e}:{id:DJ(t,`cli`),kind:`cli`,cli:e??`claude`};r([...n,{key:UY++,provider:i,persisted:!1}])}async function w(){if(h){d(!0),l(``);try{let t=await fetch(`/api/runtime-providers`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providers:h})}),n=await t.json().catch(()=>null);if(!t.ok||!vJ(n))throw Error(n?.message??e(`saveFailed`));if(!m.current)return;r(WY(n.providers,!0)),a(n.providers),s(n.status??{}),p(new Set),K.success(e(`saved`))}catch(t){let n=t.message||e(`saveFailed`);m.current&&l(n),K.error(e(`saveFailed`),{description:n})}finally{m.current&&d(!1)}}}let T=n?.filter(e=>e.provider.kind===`cli`&&on(e.provider.cli))??[],E=n?.filter(e=>e.provider.kind===`openai-compatible`)??[],D=hJ.filter(on).filter(e=>!T.some(t=>t.provider.cli===e)),O=(0,$.jsxs)(Z,{size:`sm`,className:`gap-1.5`,onClick:S,"data-testid":`add-local-engine`,children:[(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(`providers.addLocalHero`)]});return(0,$.jsxs)(`section`,{className:`space-y-6`,"aria-labelledby":`provider-connections-title`,"data-testid":`provider-connections-card`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-accent-primary/30 bg-accent-primary/10 text-accent-primary shadow-sm`,children:(0,$.jsx)(Fc,{className:`h-5 w-5`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{id:`provider-connections-title`,className:`text-base font-semibold tracking-tight`,children:e(`providers.globalTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:e(`providers.globalHint`)})]})]})}),c&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c}),!n&&!c&&(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:e(`loading`)}),n&&t&&(0,$.jsxs)(`fieldset`,{disabled:u,className:`space-y-3 disabled:opacity-70`,children:[n.length===0&&(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:e(`providers.empty`)}),n.filter(e=>e.provider.kind!==`cli`||on(e.provider.cli)).map(e=>(0,$.jsx)(EY,{provider:e.provider,onChange:t=>v(e.key,t),onRemove:()=>y(e.key)},e.key)),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,className:`gap-1.5`,onClick:()=>C(),children:[(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(`providers.addCli`)]}),(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,className:`gap-1.5`,onClick:S,children:[(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(`providers.addLocal`)]})]})]}),n&&!t&&(0,$.jsxs)(`fieldset`,{disabled:u,className:`space-y-6 disabled:opacity-70`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`cli-group`,children:[(0,$.jsx)(KY,{icon:(0,$.jsx)(pd,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),title:e(`providers.cliGroup`),hint:e(`providers.cliGroupHint`),count:T.length,action:D.length>0&&(0,$.jsx)(AY,{label:e(`providers.addCli`),align:`right`,trigger:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(`providers.addCli`)]}),items:D.map(t=>({id:t,label:e(`cliNames.${t}`),icon:(0,$.jsx)(pd,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":!0}),onSelect:()=>C(t)}))})}),T.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:e(`providers.notDetected`)}):(0,$.jsx)(`ul`,{className:`divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-card/60 shadow-sm`,"aria-label":e(`providers.cliGroup`),children:T.map(e=>(0,$.jsx)(jY,{provider:e.provider,status:o[e.provider.id],onRemove:()=>y(e.key)},e.key))})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`local-group`,children:[(0,$.jsx)(KY,{icon:(0,$.jsx)($u,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),title:e(`providers.localGroup`),hint:e(`providers.localGroupHint`),count:E.length,action:E.length>0?O:void 0}),E.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-xl border border-dashed border-border bg-card/30 px-4 py-8 text-center`,"data-testid":`local-empty`,children:[(0,$.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-xl border border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`,children:(0,$.jsx)($u,{className:`h-5 w-5`,"aria-hidden":!0})}),(0,$.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e(`providers.emptyLocalPitch`)}),O]}):(0,$.jsx)(`div`,{className:`space-y-3`,children:E.map(e=>(0,$.jsx)(HY,{provider:e.provider,status:o[e.provider.id],persisted:e.persisted,invalid:f.has(e.key),onChange:t=>v(e.key,t),onStatus:t=>x(e.provider.id,t),onValidity:t=>b(e.key,t),onRemove:()=>y(e.key)},e.key))})]})]}),n&&(0,$.jsxs)(`div`,{className:X(`flex flex-wrap items-center justify-end gap-3 rounded-xl px-3 py-2 transition-all`,g&&`sticky bottom-0 z-20 border border-accent-warning/30 bg-card/95 shadow-lg backdrop-blur`),"data-testid":`provider-save-bar`,"data-sticky":g,children:[g&&(0,$.jsxs)(`span`,{className:`mr-auto inline-flex h-6 items-center gap-1.5 rounded-full border border-accent-warning/30 bg-accent-warning/10 px-2.5 text-[11px] font-medium text-accent-warning`,role:`status`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 rounded-full bg-accent-warning`}),e(`providers.unsaved`)]}),_&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`providers.fixBeforeSave`)}),(0,$.jsxs)(Z,{disabled:u||_||!g,className:`gap-1.5`,onClick:()=>void w(),children:[(0,$.jsx)(dn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(u?`saving`:`save`)]})]})]})}function KY({icon:e,title:t,hint:n,count:r,action:i}){return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2 px-0.5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[e,t,(0,$.jsx)(`span`,{className:`rounded-full border border-border bg-muted/40 px-1.5 py-px text-[10px] font-medium tabular-nums`,children:r})]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground/80`,children:n})]}),i]})}function qY(){let{t:e}=U(`settings`),{registerHandler:t,unregisterHandler:n}=R(),[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`?(K.success(e(`coreUpdate.toastDone`,{version:String(n.version??``)})),m.current(),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),2500)):r===`error`&&(K.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||K.success(e(`coreUpdate.toastUpToDate`))}catch(t){K.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),K.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)(An,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(En,{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)(An,{className:`h-3.5 w-3.5 animate-spin`}):s===`done`?(0,$.jsx)(sc,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Lu,{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 JY=class extends ht{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){XY(t);let n=new _t;e&&(n.onmessage=e);let r=await Y(`plugin:updater|download`,{onEvent:n,rid:this.rid,...t});this.downloadedBytes=new ht(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){XY(t);let n=new _t;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 YY(e){XY(e);let t=await Y(`plugin:updater|check`,{...e});return t?new JY(t):null}function XY(e){e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}var ZY;(function(e){e.Nsis=`nsis`,e.Msi=`msi`,e.Deb=`deb`,e.Rpm=`rpm`,e.AppImage=`appimage`,e.App=`app`})(ZY||={});async function QY(){return Y(`plugin:app|version`)}async function $Y(){await Y(`plugin:process|restart`)}var eX=`specrails-desktop:dismissedDesktopUpdateVersion`,tX=`specrails-desktop-desktop-update`,nX=360*60*1e3;function rX(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function iX(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE===`true`}function aX(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE_VERSION||`99.0.0-test`}function oX(e){return new Promise(t=>setTimeout(t,e))}function sX(){return{currentVersion:`1.40.1`,version:aX(),isMock:!0,async downloadAndInstall(e){e({event:`Started`,data:{contentLength:18874368}});for(let t=0;t<12;t+=1)await oX(180),e({event:`Progress`,data:{chunkLength:1572864}});e({event:`Finished`})}}}function cX(e){return e<1024*1024?N.t(`commands:update.units.kb`,{value:Math.max(1,Math.round(e/1024))}):N.t(`commands:update.units.mb`,{value:(e/(1024*1024)).toFixed(1)})}function lX(){try{return localStorage.getItem(eX)}catch{return null}}function uX(e){try{localStorage.setItem(eX,e)}catch{}K.dismiss(tX)}function dX(e){switch(e){case`downloading`:return`var(--color-accent-info)`;case`ready`:return`var(--color-accent-success)`;default:return`var(--color-accent-primary)`}}function fX({state:e}){let t=`h-[15px] w-[15px]`;return e===`installing`?(0,$.jsx)(yc,{className:`${t} u-spin`,"aria-hidden":!0}):e===`ready`?(0,$.jsx)(xn,{className:`${t} u-check`,"aria-hidden":!0}):e===`error`?(0,$.jsx)(zn,{className:t,"aria-hidden":!0}):(0,$.jsx)(hc,{className:t,"aria-hidden":!0})}function pX({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 mX({update:e,onClose:t}){let{t:n}=U(`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){K.success(n(`update.mockReady`),{duration:2500}),K.dismiss(tX),t?.();return}Y(`restart_app`).catch(()=>{$Y()})}let p=s&&s>0?Math.min(100,Math.round(a/s*100)):null,m=dX(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:cX(a)}):n(`update.desc.progress`,{percent:p,downloaded:cX(a),total:cX(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)(fX,{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)(pX,{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:()=>{K.dismiss(tX),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:()=>{uX(e.version),t?.()},children:n(`update.actions.dismiss`)})]})})]})}function hX(e){K.custom(()=>(0,$.jsx)(mX,{update:e}),{id:tX,duration:1/0,dismissible:!1,unstyled:!0,closeButton:!1})}function gX(){(0,Q.useEffect)(()=>{let e=iX();if(!e&&!rX())return;let t=!1,n={current:!1};async function r(){if(!(t||n.current))try{let r=e?sX():await YY();if(t||!r||lX()===r.version)return;n.current=!0,K.custom(()=>(0,$.jsx)(mX,{update:r,onClose:()=>{n.current=!1}}),{id:tX,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(),nX);return()=>{t=!0,clearInterval(i)}},[])}function _X(){let{t:e}=U(`settings`),t=iX(),n=rX()||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(!rX())return;let e=!0;return QY().then(t=>{e&&i(t)}).catch(()=>{}),()=>{e=!1}},[]);let d=(0,Q.useCallback)(async()=>{o(!0),c(null);try{let n=t?sX():await YY();n?(c(`update-available`),u(n.version),hX(n)):(c(`up-to-date`),K.success(e(`appUpdate.toastUpToDate`)))}catch(t){K.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)(An,{className:`h-3.5 w-3.5 animate-spin`}):s===`up-to-date`?(0,$.jsx)(sc,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Lu,{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 vX=Object.defineProperty,yX=Object.getOwnPropertySymbols,bX=Object.prototype.hasOwnProperty,xX=Object.prototype.propertyIsEnumerable,SX=(e,t,n)=>t in e?vX(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,CX=(e,t)=>{for(var n in t||={})bX.call(t,n)&&SX(e,n,t[n]);if(yX)for(var n of yX(t))xX.call(t,n)&&SX(e,n,t[n]);return e},wX=(e,t)=>{var n={};for(var r in e)bX.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&yX)for(var r of yX(e))t.indexOf(r)<0&&xX.call(e,r)&&(n[r]=e[r]);return n},TX;(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})(TX||={}),(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||={})})(TX||={}),(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||={})})(TX||={});var EX=TX,DX={L:EX.QrCode.Ecc.LOW,M:EX.QrCode.Ecc.MEDIUM,Q:EX.QrCode.Ecc.QUARTILE,H:EX.QrCode.Ecc.HIGH},OX=128,kX=`L`,AX=`#FFFFFF`,jX=`#000000`,MX=!1,NX=1,PX=4,FX=0,IX=.1;function LX(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 RX(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 zX(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*IX),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 BX(e,t){return t==null?e?PX:FX:Math.max(Math.floor(t),0)}function VX({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(...EX.QrSegment.makeSegments(t)),e),[]);return EX.QrCode.encodeSegments(r,DX[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=BX(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:zX(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var HX=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),UX=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=OX,level:a=kX,bgColor:o=AX,fgColor:s=jX,includeMargin:c=MX,minVersion:l=NX,boostLevel:u,marginSize:d,imageSettings:f}=n,p=wX(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=wX(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}=VX({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=RX(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,HX?t.fill(new Path2D(LX(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=CX({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`,CX({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});UX.displayName=`QRCodeCanvas`;var WX=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=OX,level:a=kX,bgColor:o=AX,fgColor:s=jX,includeMargin:c=MX,minVersion:l=NX,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=wX(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=VX({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=RX(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=LX(y,h);return Q.createElement(`svg`,CX({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)});WX.displayName=`QRCodeSVG`;var GX=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 KX(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function qX(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 JX(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 YX(e){let t=new TextEncoder().encode(e),n=await JX(t,new CompressionStream(`deflate-raw`));return n.length<t.length?`D`+KX(n):`R`+KX(t)}async function XX(e){let t=e.trim();if(!t)throw Error(`empty signal token`);let n=qX(t.slice(1));if(t[0]===`D`)return new TextDecoder().decode(await JX(n,new DecompressionStream(`deflate-raw`)));if(t[0]===`R`)return new TextDecoder().decode(n);throw Error(`unknown signal codec tag: ${t[0]}`)}async function ZX(e){return YX(JSON.stringify({k:`offer`,v:2,hub:e.hubInstanceId,name:e.hubName,sdp:e.sdp,sec:e.secret,language:e.language}))}async function QX(e){try{let t=JSON.parse(await XX(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 $X({open:e,onClose:t,onPaired:n}){let{t:r}=U(`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 QX(e);if(!t){K.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`),K.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 ZX({language:L(),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,GX.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){K.error(r(`pairWeb.cameraFailed`,{message:`unsupported`}));return}try{d.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),a(`scanning`)}catch(e){K.error(r(`pairWeb.cameraFailed`,{message:e.message})),a(`offer`)}}return(0,$.jsx)(vr,{open:e,onOpenChange:e=>{e||m()},children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-md`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:r(`pairWeb.title`)}),(0,$.jsx)(cr,{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)(WX,{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),K.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 eZ=typeof navigator<`u`&&/Win/i.test(navigator.platform);function tZ(e){return!e||e.length<16?e??`—`:`${e.slice(0,8)}…${e.slice(-8)}`}function nZ(){let{t:e}=U(`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}=R();(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){K.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(),K.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)(dd,{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)(ge,{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)(ad,{className:`h-3.5 w-3.5 text-accent-success`}),(0,$.jsx)(`span`,{title:t.certFingerprint??``,children:tZ(t.certFingerprint)}),(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:h,disabled:a,children:e(`mobile.reset`)})]})]}),eZ&&(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)(Rn,{className:`h-4 w-4`})})]},t.id))]})]}),(0,$.jsx)($X,{open:s,onClose:()=>c(!1),onPaired:u})]}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})}var rZ=[`claude`,`codex`],iZ=[`claude`],aZ=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function oZ(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 sZ(){let{t:e}=U(`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(`${F}/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(`${F}/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 K.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 iZ)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!==``&&(!aZ.test(w)||w===`specrails`),E=w!==``&&!T&&`c:${w}`!==_&&!!t?.settings.servers[`c:${w}`],D=w!==``&&!T&&!E&&l.trim()!==``,O=(0,Q.useCallback)(()=>{o(!1),v(null),c(``),u(``),f(``),m([]),g({})},[]),k=(0,Q.useCallback)(()=>{v(null),c(``),u(``),f(``),m([]),g({}),o(!0)},[]),A=(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]),j=(0,Q.useCallback)(async()=>{if(!t||!D)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)&&O()},[t,D,w,l,d,p,h,_,b,O]);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)(ge,{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):k(),"data-testid":`external-mcp-add`,children:[(0,$.jsx)(Pn,{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)(zn,{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||E?`border-destructive/60 focus:outline-destructive`:`border-border`}`}),(T||E)&&(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)(Pn,{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)(Rn,{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:rZ.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:oZ(t),"data-testid":`external-mcp-form-provider-${e}`,children:[t&&(0,$.jsx)(xn,{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:O,children:e(`external.form.cancel`)}),(0,$.jsx)(Z,{size:`sm`,className:`h-7 text-[11px]`,disabled:r||!D,onClick:()=>void j(),"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)(zn,{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:rZ.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:oZ(n),children:[n&&(0,$.jsx)(xn,{className:`h-2.5 w-2.5`,strokeWidth:3}),e]},e)})}),t.stored&&t.source===`custom`&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>A(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)(jn,{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)(Rn,{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 cZ(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 lZ(e){return JSON.stringify({mcpServers:{specrails:{command:e.bridgeCommand}}},null,2)}function uZ(){let{t:e}=U(`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(`${F}/api/mcp-admin/status`);e.ok&&n(await e.json())}catch{}},[]),u=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${F}/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(`${F}/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){K.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(`${F}/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){K.error(e(`tiers.updateFailed`,{message:t.message}))}finally{o(!1)}},[t,e]),p=(0,Q.useCallback)(async()=>{r&&(await cZ(lZ(r))?(c(`config`),window.setTimeout(()=>c(e=>e===`config`?null:e),1500)):K.error(e(`config.copyFailed`)))},[r,e]),m=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${F}/api/mcp-admin/token`);if(!t.ok)throw Error(`HTTP ${t.status}`);let{token:n}=await t.json();await cZ(n)?(c(`token`),window.setTimeout(()=>c(e=>e===`token`?null:e),1500)):K.error(e(`config.copyFailed`))}catch{K.error(e(`config.copyFailed`))}},[e]),h=(0,Q.useCallback)(async()=>{if(window.confirm(e(`token.regenerateConfirm`))){o(!0);try{let t=await fetch(`${F}/api/mcp-admin/regenerate-token`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}`);await l(),K.success(e(`token.regenerated`))}catch(t){K.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)(Du,{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)(xn,{className:`h-3 w-3 text-accent-success`}),` `,e(`config.configCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kc,{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:lZ(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)(xn,{className:`h-3 w-3 text-accent-success`}),` `,e(`token.tokenCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kc,{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)(Lu,{className:`h-3 w-3`}),` `,e(`token.regenerate`)]})]})]})]})]}),(0,$.jsx)(sZ,{})]})}var dZ=`specrails-os-notifications`,fZ={enabled:!0,filter:`all`};function pZ(){try{let e=localStorage.getItem(dZ);if(!e)return fZ;let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:fZ.enabled,filter:t.filter===`completed`||t.filter===`failed`?t.filter:fZ.filter}}catch{return fZ}}function mZ(e){localStorage.setItem(dZ,JSON.stringify(e))}function hZ({setActiveProjectId:e,projectsById:t}={}){let n=y(),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{uiMode:a}=eL(),o=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{o.current=a},[a]);let s=(0,Q.useCallback)((e,t)=>{if(o.current===`agent`){e&&i.current&&i.current(e),cj({projectId:e,jobId:t});return}e&&i.current?(i.current(e),setTimeout(()=>{r.current(`/jobs/${t}`)},100)):r.current(`/jobs/${t}`)},[]),c=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{c.current=t},[t]);let l=(0,Q.useRef)(new Map),u=(0,Q.useRef)(new Map),{registerHandler:d,unregisterHandler:f}=R(),p=(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`):[];h(t.jobId,t.projectId??null,t.staleMs??0,e);return}if(t.type===`loop.provider_limit`&&typeof t.runId==`string`){m(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=l.current.get(e.id),r=e.status;n&&u.current.set(e.id,n),t===`running`&&(r===`completed`||r===`failed`)&&_(e,n),l.current.set(e.id,r)}},[]);function m(e,t,n,r,i){let a=pZ();if(!a.enabled||a.filter===`completed`)return;let o=t?c.current?.get(t)??``:``,s=n?n.charAt(0).toUpperCase()+n.slice(1):`AI`,l=r?N.t(`commands:notifications.providerLimitBody`,{provider:s,resetsAt:r}):N.t(`commands:notifications.providerLimitBodyNoReset`,{provider:s}),u=N.t(`commands:notifications.providerLimit`);K.error(u,{id:`provider-limit:${e}`,description:`${o?`[${o}] `:``}${l}${i?` · ${i}`:``}`,duration:6e4}),!(typeof Notification>`u`)&&Notification.permission===`granted`&&(()=>{let t=new Notification(u,{body:o?`[${o}] ${l}`:l,tag:`specrails-provider-limit:${e}`});t.onclick=()=>{window.focus(),t.close()}})()}function h(e,t,n,r=[]){let i=pZ();if(!i.enabled||i.filter===`completed`)return;let a=Math.max(1,Math.round(n/6e4)),o=t?c.current?.get(t)??``:``,l=N.t(`commands:notifications.jobStuckBody`,{count:a});if(t&&r.includes(`stop`)&&K.warning(N.t(`commands:notifications.jobStuck`),{id:`job-stuck:${e}`,description:o?`[${o}] ${l}`:l,duration:2e4,action:{label:N.t(`commands:notifications.jobStuckStop`),onClick:()=>{g(t,e)}}}),typeof Notification>`u`)return;function u(){let n=new Notification(N.t(`commands:notifications.jobStuck`),{body:o?`[${o}] ${l}`:l,tag:`specrails-job-stuck:${e}`});n.onclick=()=>{window.focus(),s(t,e),n.close()}}Notification.permission===`granted`?u():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&u()})}async function g(e,t){try{let n=await fetch(`/api/projects/${e}/jobs/${t}/cancel`,{method:`POST`});if(!n.ok)throw Error(`HTTP ${n.status}`);K.success(N.t(`commands:notifications.jobStuckStopped`),{id:`job-stuck:${t}`})}catch{K.error(N.t(`commands:notifications.jobStuckStopFailed`),{id:`job-stuck:${t}`})}}function _(e,t){if(typeof Notification>`u`||typeof document<`u`&&!document.hidden)return;let n=pZ();if(!n.enabled||n.filter===`completed`&&e.status!==`completed`||n.filter===`failed`&&e.status!==`failed`)return;function r(){let n=e.status===`completed`?N.t(`commands:notifications.jobCompleted`):N.t(`commands:notifications.jobFailed`),r=t?c.current?.get(t)??``:``,i=e.command?e.command.slice(0,80):N.t(`commands:notifications.unknownCommand`),a=r?`[${r}] ${i}`:i,o=new Notification(n,{body:a,tag:`specrails-job:${e.id}:${e.status}`}),l=e.id,u=t;o.onclick=()=>{window.focus(),s(u,l),o.close()}}Notification.permission===`granted`?r():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&r()})}(0,Q.useLayoutEffect)(()=>(d(`os-notifications`,p),()=>f(`os-notifications`)),[p,d,f])}var gZ=[{value:`job.completed`,labelKey:`webhooks.eventJobCompleted`},{value:`job.failed`,labelKey:`webhooks.eventJobFailed`},{value:`daily_budget_exceeded`,labelKey:`webhooks.eventDailyBudgetExceeded`}];function _Z({project:e,onRemove:t}){let{t:n}=U(`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 vZ=[{id:`appearance`,icon:su,labelKey:`desktop.nav.appearance`},{id:`effects`,icon:Ln,labelKey:`desktop.nav.effects`},{id:`specrailsAgents`,icon:Fc,labelKey:`desktop.nav.specrailsAgents`},{id:`subscriptionUsage`,icon:Fc,labelKey:`desktop.nav.subscriptionUsage`},{id:`code`,icon:_c,labelKey:`desktop.nav.code`},{id:`terminal`,icon:pd,labelKey:`desktop.nav.terminal`},{id:`updates`,icon:Lu,labelKey:`desktop.nav.updates`},{id:`mobile`,icon:dd,labelKey:`desktop.nav.mobile`},{id:`mcp`,icon:zs,labelKey:`desktop.nav.mcp`},{id:`projects`,icon:sl,labelKey:`desktop.nav.projects`},{id:`advanced`,icon:ld,labelKey:`desktop.nav.advanced`},{id:`webhooks`,icon:Nd,labelKey:`desktop.nav.webhooks`},{id:`about`,icon:kl,labelKey:`desktop.nav.about`}];function yZ({open:e,onClose:t,onOpenOnboarding:n,initialSection:r=`appearance`}){let{t:i}=U(`settings`),{projects:a,removeProject:o}=ce(),[s,c]=(0,Q.useState)(`appearance`);(0,Q.useEffect)(()=>{e&&c(r)},[e,r]);let l=e=>X(`space-y-5`,s===e?``:`hidden`),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)([`job.completed`,`job.failed`]),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(()=>pZ().enabled),[P,F]=(0,Q.useState)(()=>pZ().filter);function I(e){N(e),mZ({enabled:e,filter:P}),K.success(i(e?`notifications.enabledToast`:`notifications.disabledToast`))}function ee(e){F(e),mZ({enabled:M,filter:e})}let te=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/webhooks`);if(e.ok){let t=await e.json();C(t.webhooks)}}catch{}},[]);(0,Q.useEffect)(()=>{if(!e)return;p(!0);async function t(){try{let e=await fetch(`/api/settings`);if(e.ok){let t=await e.json();d(t),h(t.costAlertThresholdUsd==null?``:String(t.costAlertThresholdUsd))}}catch{}finally{p(!1)}}t(),te()},[e,te]),(0,Q.useEffect)(()=>{e&&fetch(`/api/budget`).then(e=>e.json()).then(e=>{e.desktopDailyBudgetUsd==null?y(``):y(String(e.desktopDailyBudgetUsd))}).catch(()=>{})},[e]);async function L(){_(!0);try{let e=m.trim()===``?null:parseFloat(m);if(e!==null&&(isNaN(e)||e<=0)){K.error(i(`budget.invalidNumber`));return}(await fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({costAlertThresholdUsd:e})})).ok?K.success(e==null?i(`desktop.costAlertsDisabled`):i(`budget.alertSet`,{amount:e})):K.error(i(`budget.saveThresholdFailed`))}catch{K.error(i(`budget.saveThresholdFailed`))}finally{_(!1)}}async function R(){x(!0);try{let e=v.trim()===``?null:parseFloat(v);if(e!==null&&(isNaN(e)||e<=0)){K.error(i(`budget.invalidNumber`));return}(await fetch(`/api/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({desktopDailyBudgetUsd:e})})).ok?K.success(e==null?i(`desktop.dailyBudgetRemoved`):i(`desktop.dailyBudgetSet`,{amount:e})):K.error(i(`desktop.dailyBudgetSaveFailed`))}catch{K.error(i(`desktop.dailyBudgetSaveFailed`))}finally{x(!1)}}async function z(e){try{await o(e),K.success(i(`desktop.projectRemoved`))}catch(e){K.error(i(`desktop.projectRemoveFailed`),{description:e.message})}}async function B(){if(!w.trim()){K.error(i(`webhooks.urlRequired`));return}if(O.length===0){K.error(i(`webhooks.selectEvent`));return}j(!0);try{let e=await fetch(`/api/webhooks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:w.trim(),secret:E.trim(),events:O})});if(e.ok)K.success(i(`webhooks.added`)),T(``),D(``),k([`job.completed`,`job.failed`]),await te();else{let t=await e.json();K.error(t.error??i(`webhooks.addFailed`))}}catch{K.error(i(`webhooks.addFailed`))}finally{j(!1)}}async function ne(e,t){try{await fetch(`/api/webhooks/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})}),await te()}catch{K.error(i(`webhooks.updateFailed`))}}async function V(e){try{(await fetch(`/api/webhooks/${e}`,{method:`DELETE`})).ok&&(K.success(i(`webhooks.removed`)),await te())}catch{K.error(i(`webhooks.removeFailed`))}}async function re(e){try{(await fetch(`/api/webhooks/${e}/test`,{method:`POST`})).ok&&K.success(i(`webhooks.testPingSent`))}catch{K.error(i(`webhooks.testPingFailed`))}}function ie(e){k(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,$.jsx)(vr,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(gr,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsxs)(dr,{className:`flex items-center gap-2`,children:[(0,$.jsx)(rd,{className:`w-4 h-4`}),i(`desktop.title`)]}),(0,$.jsx)(cr,{children:i(`desktop.description`)})]}),f?(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:vZ.map(e=>{if(e.id===`mcp`&&!Re)return null;let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(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`,s===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:i(e.labelKey)})]},e.id)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,$.jsxs)(`div`,{className:l(`appearance`),children:[(0,$.jsx)(hY,{}),(0,$.jsx)(CY,{})]}),(0,$.jsx)(`div`,{className:l(`effects`),children:(0,$.jsx)(pY,{})}),(0,$.jsxs)(`div`,{className:l(`specrailsAgents`),children:[(0,$.jsx)(GY,{}),(0,$.jsx)(cJ,{})]}),s===`subscriptionUsage`&&(0,$.jsx)(fY,{showDataDetails:!0}),(0,$.jsx)(`div`,{className:l(`code`),children:(0,$.jsx)(wY,{})}),(0,$.jsxs)(`div`,{className:l(`updates`),children:[(0,$.jsx)(_X,{}),(0,$.jsx)(qY,{})]}),(0,$.jsx)(`div`,{className:l(`mobile`),children:(0,$.jsx)(nZ,{})}),Re&&(0,$.jsx)(`div`,{className:l(`mcp`),children:(0,$.jsx)(uZ,{})}),(0,$.jsx)(`div`,{className:l(`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:i(`desktop.registeredProjects`)}),a.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:i(`desktop.noProjects`)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:a.map(e=>(0,$.jsx)(_Z,{project:e,onRemove:z},e.id))})]})}),(0,$.jsxs)(`div`,{className:l(`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:i(`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:i(`desktop.dailyBudgetLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`desktop.dailyBudgetHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(gF,{type:`number`,min:`0`,step:`0.01`,value:v,onChange:e=>y(e.target.value),placeholder:i(`desktop.dailyBudgetPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:b,onClick:()=>void R(),children:i(`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:i(`budget.perJobLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`desktop.perJobHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(gF,{type:`number`,min:`0`,step:`0.01`,value:m,onChange:e=>h(e.target.value),placeholder:i(`budget.perJobPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:g,onClick:L,children:i(`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:i(`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:i(`notifications.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:M,onChange:e=>I(e.target.checked),className:`w-3.5 h-3.5`,"data-testid":`notif-toggle`}),(0,$.jsx)(Fs,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs`,children:i(`notifications.enableLabel`)})]}),M&&(0,$.jsxs)(`div`,{className:`space-y-1.5 pl-6`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`notifications.notifyOn`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:[{value:`all`,label:i(`notifications.filterAll`)},{value:`completed`,label:i(`notifications.filterCompleted`)},{value:`failed`,label:i(`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:P===e,onChange:()=>ee(e),className:`w-3 h-3`}),t]},e))})]})]})]})]}),(0,$.jsx)(`div`,{className:l(`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:i(`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)(H,{ns:`settings`,i18nKey:`webhooks.description`,components:{code:(0,$.jsx)(`code`,{className:`font-mono`})}})}),S.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:S.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 ne(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?i(`webhooks.disable`):i(`webhooks.enable`),children:e.enabled?i(`webhooks.statusOn`):i(`webhooks.statusOff`)}),(0,$.jsx)(`button`,{onClick:()=>void re(e.id),className:`text-muted-foreground hover:text-foreground p-0.5`,title:i(`webhooks.sendTestPing`),children:(0,$.jsx)(Hn,{className:`w-3 h-3`})}),(0,$.jsx)(`button`,{onClick:()=>void V(e.id),className:`text-muted-foreground hover:text-destructive p-0.5`,title:i(`common:actions.remove`),children:(0,$.jsx)(Rn,{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:i(`webhooks.addHeading`)}),(0,$.jsx)(gF,{value:w,onChange:e=>T(e.target.value),placeholder:`https://hooks.example.com/...`,className:`h-7 text-xs font-mono`}),(0,$.jsx)(gF,{value:E,onChange:e=>D(e.target.value),placeholder:i(`webhooks.secretPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:gZ.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:O.includes(e),onChange:()=>ie(e),className:`w-3 h-3`}),i(t)]},e))}),(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs w-full`,disabled:A||!w.trim(),onClick:()=>void B(),children:[(0,$.jsx)(Pn,{className:`w-3 h-3 mr-1`}),i(`webhooks.addButton`)]})]})]})]})}),(0,$.jsx)(`div`,{className:l(`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:i(`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:i(`desktop.platformTour`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`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)(_l,{className:`w-3 h-3 mr-1`}),i(`desktop.replayTour`)]})]})})]})}),(0,$.jsx)(`div`,{className:l(`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:i(`desktop.terminalPanelHeading`)}),(0,$.jsx)(uJ,{mode:`desktop`})]})}),(0,$.jsx)(`div`,{className:l(`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:i(`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:i(`desktop.infoPort`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:u?.port??4200})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i(`desktop.infoProjects`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:a.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i(`desktop.infoDb`)}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:`~/.specrails/desktop.sqlite`})]})]})]})})]})]})]})})}var bZ=[{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`},...$e?[{keys:`⌘⇧A`,descriptionKey:`shortcuts.items.toggleAgent`,category:`general`}]:[],{keys:lt?`⌘1–5`:`⌘1–4`,descriptionKey:lt?`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 xZ(e){let t=e.target;if(!t)return!1;let n=t.tagName;return!!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable)}function SZ(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`[role="dialog"]`)}function CZ(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`.specrails-xterm-container, .xterm`)}function wZ({onOpenCheatsheet:e,onListNavigate:t,onToggleLeftSidebar:n,onToggleRightSidebar:r,onSwitchProject:i,onSwitchProjectPage:a,onToggleTerminalPanel:o,onToggleAgentChat:s}){let c=y(),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 v=(0,Q.useRef)(a);v.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(SZ(e))return;e.preventDefault(),b.current?.();return}if((e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.code===`KeyA`){if(SZ(e))return;e.preventDefault(),x.current?.();return}if(xZ(e)||CZ(e)||SZ(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(),v.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 TZ(){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 EZ={general:`shortcuts.categories.general`,navigation:`shortcuts.categories.navigation`,actions:`shortcuts.categories.actions`},DZ=[`general`,`navigation`,`actions`];function OZ({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 kZ({shortcut:e}){let{t}=U(`commands`),n=jq(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)(OZ,{children:e},t))})]})}function AZ({open:e,onOpenChange:t}){let{t:n}=U(`commands`),r=DZ.map(e=>({category:e,label:n(EZ[e]),shortcuts:bZ.filter(t=>t.category===e)})).filter(e=>e.shortcuts.length>0);return(0,$.jsx)(vr,{open:e,onOpenChange:t,children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-md`,"data-testid":`shortcuts-cheatsheet`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(`shortcuts.title`)}),(0,$.jsx)(cr,{children:(0,$.jsxs)(H,{i18nKey:`shortcuts.subtitle`,ns:`commands`,children:[`Press `,(0,$.jsx)(OZ,{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)(kZ,{shortcut:e},e.keys))})]},e.category))})]})})}var jZ=[`pinned-open`,`pinned-collapsed`,`unpinned`],MZ=`specrails-desktop:sidebar-mode:left`,NZ=`specrails-desktop:sidebar-mode:right`;function PZ(e){return typeof e==`string`&&jZ.includes(e)}function FZ(e){try{let t=window.localStorage.getItem(e);if(PZ(t))return t}catch{}return`unpinned`}function IZ(e,t){try{window.localStorage.setItem(e,t)}catch{}}function LZ(e){switch(e){case`pinned-open`:return`pinned-collapsed`;case`pinned-collapsed`:return`unpinned`;case`unpinned`:return`pinned-open`}}var RZ=(0,Q.createContext)({leftMode:`unpinned`,rightMode:`unpinned`,setLeftMode:()=>{},setRightMode:()=>{},cycleLeftMode:()=>{},cycleRightMode:()=>{}});function zZ({children:e}){let[t,n]=(0,Q.useState)(()=>FZ(MZ)),[r,i]=(0,Q.useState)(()=>FZ(NZ));(0,Q.useEffect)(()=>{IZ(MZ,t)},[t]),(0,Q.useEffect)(()=>{IZ(NZ,r)},[r]);let a=(0,Q.useCallback)(e=>n(e),[]),o=(0,Q.useCallback)(e=>i(e),[]),s=(0,Q.useCallback)(()=>n(e=>LZ(e)),[]),c=(0,Q.useCallback)(()=>i(e=>LZ(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)(RZ.Provider,{value:l,children:e})}function BZ(){return(0,Q.useContext)(RZ)}function VZ(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function HZ(){return VZ()&&/mac/i.test(navigator.platform)}function UZ({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 WZ({projectName:e,hidden:t=!1}){let{t:n}=U(`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)(In,{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 GZ(){return VZ()?HZ()?(0,$.jsx)(qZ,{}):(0,$.jsx)(JZ,{}):null}function KZ({side:e}){let{t}=U(`nav`),{leftMode:n,rightMode:r,cycleLeftMode:i,cycleRightMode:a}=BZ(),o=e===`left`?n:r,s=t(`sidebarPin.${e}.${o===`pinned-open`?`pinnedOpen`:o===`pinned-collapsed`?`pinnedCollapsed`:`unpinned`}`),c=e===`left`?lu:du;return(0,$.jsx)(`button`,{type:`button`,"aria-label":s,title:t(`sidebarPin.withShortcut`,{label:s,shortcut:jq(e===`left`?`⌥⌘B`:`⌘B`)}),onClick:e===`left`?i:a,className:`flex h-6 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline focus-visible:outline-ring`,style:{WebkitAppRegion:`no-drag`},children:(0,$.jsx)(c,{className:`h-4 w-4`})})}function qZ(){let{projects:e,activeProjectId:t}=ce(),{uiMode:n}=eL(),r=e.find(e=>e.id===t)??null;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`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--color-border)`},children:[(0,$.jsx)(`div`,{className:`ml-[80px] flex items-center gap-2`,children:(0,$.jsx)(KZ,{side:`left`})}),(0,$.jsx)(WZ,{projectName:r?.name??null,hidden:n===`agent`}),(0,$.jsx)(`div`,{className:`ml-auto mr-2`,children:(0,$.jsx)(KZ,{side:`right`})})]})}function JZ(){let{t:e}=U(`nav`),{projects:t,activeProjectId:n}=ce(),{uiMode:r}=eL(),i=t.find(e=>e.id===n)??null,a=(0,Q.useMemo)(()=>BL(),[]),[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)(WZ,{projectName:i?.name??null,hidden:r===`agent`}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(KZ,{side:`left`})}),(0,$.jsxs)(`div`,{style:{minWidth:116,display:`flex`,justifyContent:`flex-end`,gap:2,alignItems:`center`,WebkitAppRegion:`no-drag`},children:[(0,$.jsx)(KZ,{side:`right`}),(0,$.jsx)(UZ,{onClick:c,icon:(0,$.jsx)(Zl,{size:14,strokeWidth:1.8}),ariaLabel:e(`titleBar.minimizeWindow`)}),(0,$.jsx)(UZ,{onClick:l,icon:o?(0,$.jsx)(kc,{size:12,strokeWidth:1.8}):(0,$.jsx)(Nn,{size:12,strokeWidth:1.8}),ariaLabel:e(o?`titleBar.restoreWindow`:`titleBar.maximizeWindow`)}),(0,$.jsx)(UZ,{onClick:u,icon:(0,$.jsx)(Vn,{size:15,strokeWidth:1.8}),hoverColor:`var(--color-destructive)`,hoverTextColor:`var(--color-destructive-foreground)`,ariaLabel:e(`titleBar.closeWindow`)})]})]})}var YZ=`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン0123456789ABCDEF`,XZ=16,ZZ=XZ,QZ=XZ*1.1,$Z=180,eQ=340,tQ=.07,nQ=.22,rQ=18,iQ=600,aQ=48,oQ=160,sQ=360;function cQ(){return YZ[Math.floor(Math.random()*61)]??` `}function lQ(e){return{head:-Math.random()*Math.max(e,12),speed:tQ+Math.random()*(nQ-tQ),glyphs:Array.from({length:rQ},()=>cQ()),nextSwapAt:0}}function uQ(){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=`${XZ}px "DM Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace`,i.textBaseline=`top`;let o=Math.ceil(t/ZZ),s=Math.ceil(n/QZ);if(a.length===0)a=Array.from({length:o},()=>lQ(s));else if(a.length<o){let e=Array.from({length:o-a.length},()=>lQ(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>aQ&&s.splice(0,s.length-aQ)),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>iQ;)s.shift();let r=window.innerWidth,d=window.innerHeight;i.clearRect(0,0,r,d);let f=Math.ceil(d/QZ),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-rQ>f+4&&(c.head=-Math.random()*12,c.speed=tQ+Math.random()*(nQ-tQ)),e>c.nextSwapAt&&(c.glyphs[Math.floor(Math.random()*rQ)]=cQ(),c.nextSwapAt=e+oQ+Math.random()*sQ),!p)continue;let l=r*ZZ+ZZ/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>eQ))for(let e=0;e<rQ;e++){let t=c.head-e;if(t<-1||t>f+2)continue;let a=t*QZ,u=0;if(o!==null){let e=l-o.x,t=a-o.y,n=Math.sqrt(e*e+t*t);if(n<=eQ){let e=n<$Z?1:1-(n-$Z)/(eQ-$Z);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>eQ)continue;let o=i<$Z?1:1-(i-$Z)/(eQ-$Z),s=n-e.t,c=o*(s>iQ?0:1-s/iQ);if(c>u&&(u=c),u>=.999)break}if(u<.02)continue;let d=1-e/rQ,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*ZZ,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 dQ=24,fQ=200,pQ=3.5,mQ=10,hQ=`hsl(210, 60%, 96%)`,gQ=`hsl(212, 100%, 62%)`;function _Q(){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>dQ&&a.splice(0,a.length-dQ)}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>fQ;)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=gQ;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/fQ);if(s<=0)continue;let c=t/a.length;i.globalAlpha=s*(.25+.75*c),i.lineWidth=Math.max(.5,pQ*c),i.shadowBlur=mQ*c,i.strokeStyle=c>.6?hQ:gQ,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 vQ={"code-rain":uQ,galaxy:_Q};function yQ(){let e=vQ[Pa().id];return e?(0,$.jsx)(e,{}):null}function bQ({project:e}){let{t}=U(`nav`),n=dG(),{registerHandler:r,unregisterHandler:i}=R(),[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`?K.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`?(K.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`&&K.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)(TN,{delayDuration:400,children:(0,$.jsx)(lG.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 xQ({projectName:e,errorMessage:t,onRetry:n}){let{t:r}=U(`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)(H,{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)(Lu,{className:`w-3.5 h-3.5`}),r(`common:actions.retry`)]})]})}var SQ=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)(xQ,{projectName:this.props.projectName,errorMessage:this.state.error?.message??null,onRetry:this.handleRetry}):this.props.children}};function CQ({onAddProject:e}){let{t}=U(`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)(xd,{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)(H,{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`)}),Fe&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.jiraHint`)}),Re&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.mcpHint`)}),$e&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.agentChatHint`)}),tt&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.localEnginesHint`)})]}),(0,$.jsxs)(Z,{onClick:e,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(sl,{className:`w-3.5 h-3.5`}),t(`welcome.addFirstProject`)]})]})}var wQ=`https://specrails.dev/companion-app/`,TQ=`specrails-desktop:onboarding-dismissed`;function EQ(){try{return localStorage.getItem(TQ)===`true`}catch{return!1}}function DQ(){try{localStorage.setItem(TQ,`true`)}catch{}}var OQ=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||``),kQ=OQ?`⌘`:`Ctrl`,AQ=OQ?`⌥`:`Alt`,jQ={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 MQ({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 NQ({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 PQ({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 FQ({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)(Be,{className:`w-3.5 h-3.5 text-muted-foreground`})]},t.label))})}function IQ(){let{t:e}=U(`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)(SY,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.language.note`)})]})}function LQ(){let{t:e}=U(`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)(mY,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.theme.note`)})]})}function RQ({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)(WX,{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)(Dn,{className:`w-3 h-3 shrink-0`,"aria-hidden":`true`})]})]})]})}function zQ(){let{t:e}=U(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.companion.intro`,components:{b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,$.jsx)(PQ,{accent:jQ.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)(RQ,{icon:(0,$.jsx)(dd,{className:`w-4 h-4 shrink-0`,"aria-hidden":`true`}),url:wQ,label:e(`onboarding.companion.open`),testId:`companion-web-link`})]}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(ju,{className:`w-4 h-4`}),label:e(`onboarding.companion.pairLabel`),accent:jQ.success,children:e(`onboarding.companion.pairBody`)})]})}function BQ(e){let t={b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})};return[{navLabel:e(`onboarding.language.nav`),icon:(0,$.jsx)(Nl,{className:`w-6 h-6`}),accent:jQ.info,title:e(`onboarding.language.title`),subtitle:e(`onboarding.language.subtitle`),content:(0,$.jsx)(IQ,{})},{navLabel:e(`onboarding.theme.nav`),icon:(0,$.jsx)(su,{className:`w-6 h-6`}),accent:jQ.highlight,title:e(`onboarding.theme.title`),subtitle:e(`onboarding.theme.subtitle`),content:(0,$.jsx)(LQ,{})},{navLabel:e(`onboarding.welcome.nav`),icon:(0,$.jsx)(Ln,{className:`w-6 h-6`}),accent:jQ.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)(H,{t:e,i18nKey:`onboarding.welcome.intro`,components:t})}),(0,$.jsxs)(PQ,{accent:jQ.primary,label:e(`onboarding.welcome.coreLoopLabel`),children:[(0,$.jsx)(FQ,{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)(H,{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)(NQ,{icon:(0,$.jsx)(zs,{className:`w-4 h-4`}),label:e(`onboarding.welcome.missionLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.welcome.missionBody`,components:t})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Ll,{className:`w-4 h-4`}),label:e(`onboarding.welcome.boardLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.welcome.boardBody`,components:t})})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,$.jsx)(ad,{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)(H,{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`)})]})},...$e?[{navLabel:e(`onboarding.mission.nav`),icon:(0,$.jsx)(zs,{className:`w-6 h-6`}),accent:jQ.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)(H,{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)(NQ,{icon:(0,$.jsx)(_e,{className:`w-4 h-4`}),label:e(`onboarding.mission.missionsLabel`),accent:jQ.primary,children:e(`onboarding.mission.missionsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(ad,{className:`w-4 h-4`}),label:e(`onboarding.mission.levelsLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.mission.levelsBody`,components:{...t,shift:(0,$.jsx)(MQ,{children:`Shift`}),tab:(0,$.jsx)(MQ,{children:`Tab`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(kn,{className:`w-4 h-4`}),label:e(`onboarding.mission.cardsLabel`),accent:jQ.primary,children:e(`onboarding.mission.cardsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Vs,{className:`w-4 h-4`}),label:e(`onboarding.mission.workspaceLabel`),accent:jQ.primary,children:e(`onboarding.mission.workspaceBody`)})]}),(0,$.jsx)(PQ,{accent:jQ.primary,label:e(`onboarding.mission.mcpLabel`),children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.mission.mcpBody`,components:t})})]})}]:[],...ze?[{navLabel:e(`onboarding.builder.nav`),icon:(0,$.jsx)(xl,{className:`w-6 h-6`}),accent:jQ.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)(H,{t:e,i18nKey:`onboarding.builder.intro`,components:t})}),(0,$.jsxs)(PQ,{accent:jQ.highlight,label:e(`onboarding.builder.flowLabel`),children:[(0,$.jsx)(FQ,{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)(NQ,{icon:(0,$.jsx)(jd,{className:`w-4 h-4`}),label:e(`onboarding.builder.cardsLabel`),accent:jQ.highlight,children:e(`onboarding.builder.cardsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Zc,{className:`w-4 h-4`}),label:e(`onboarding.builder.specsLabel`),accent:jQ.highlight,children:e(`onboarding.builder.specsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Vu,{className:`w-4 h-4`}),label:e(`onboarding.builder.milestonesLabel`),accent:jQ.highlight,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.builder.milestonesBody`,components:t})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(dl,{className:`w-4 h-4`}),label:e(`onboarding.builder.progressLabel`),accent:jQ.highlight,children:e(`onboarding.builder.progressBody`)})]})]})}]:[],{navLabel:e(`onboarding.authorSpecs.nav`),icon:(0,$.jsx)(_e,{className:`w-6 h-6`}),accent:jQ.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)(H,{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)(NQ,{icon:(0,$.jsx)(zs,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.agentLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.agentBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(_e,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.exploreLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.exploreBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Hn,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.quickLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.quickBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(ge,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.websiteLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.websiteBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(qu,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.smashLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.smashBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(dn,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.draftsLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.draftsBody`)})]}),Fe&&(0,$.jsx)(PQ,{accent:jQ.info,label:e(`onboarding.jira.label`),children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.jira.body`,components:t})})]})},{navLabel:e(`onboarding.rails.nav`),icon:(0,$.jsx)(Fd,{className:`w-6 h-6`}),accent:jQ.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)(H,{t:e,i18nKey:`onboarding.rails.intro`,components:{...t,play:(0,$.jsx)(`span`,{className:`text-accent-warning font-medium`})}})}),(0,$.jsxs)(PQ,{accent:jQ.success,label:e(`onboarding.rails.jobLabel`),children:[(0,$.jsx)(FQ,{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)(NQ,{icon:(0,$.jsx)(On,{className:`w-4 h-4`}),label:e(`onboarding.rails.reviewLabel`),accent:jQ.success,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.rails.reviewBody`,components:t})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(qc,{className:`w-4 h-4`}),label:e(`onboarding.rails.packetLabel`),accent:jQ.success,children:e(`onboarding.rails.packetBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(_e,{className:`w-4 h-4`}),label:e(`onboarding.rails.steerLabel`),accent:jQ.success,children:e(`onboarding.rails.steerBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(zu,{className:`w-4 h-4`}),label:e(`onboarding.rails.loopsLabel`),accent:jQ.success,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.rails.loopsBody`,components:t})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(zs,{className:`w-4 h-4`}),label:e(`onboarding.rails.profilesLabel`),accent:jQ.success,children:e(`onboarding.rails.profilesBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(sl,{className:`w-4 h-4`}),label:e(`onboarding.rails.isolationLabel`),accent:jQ.success,children:e(`onboarding.rails.isolationBody`)})]})]})},{navLabel:e(`onboarding.providers.nav`),icon:(0,$.jsx)(zs,{className:`w-6 h-6`}),accent:jQ.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)(H,{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] 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`})]}),[[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] 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]})]},e[0]))]}),(0,$.jsx)(PQ,{accent:jQ.secondary,label:e(`onboarding.providers.calloutLabel`),children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.providers.calloutBody`,components:{...t,mono:(0,$.jsx)(`span`,{className:`font-mono`})}})})]})},{navLabel:e(`onboarding.cost.nav`),icon:(0,$.jsx)(Cc,{className:`w-6 h-6`}),accent:jQ.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)(H,{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)(NQ,{icon:(0,$.jsx)(dl,{className:`w-4 h-4`}),label:e(`onboarding.cost.analyticsLabel`),accent:jQ.warning,children:e(`onboarding.cost.analyticsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Fu,{className:`w-4 h-4`}),label:e(`onboarding.cost.perTicketLabel`),accent:jQ.warning,children:e(`onboarding.cost.perTicketBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Vc,{className:`w-4 h-4`}),label:e(`onboarding.cost.honestLabel`),accent:jQ.warning,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.cost.honestBody`,components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(kd,{className:`w-4 h-4`}),label:e(`onboarding.cost.budgetsLabel`),accent:jQ.warning,children:e(`onboarding.cost.budgetsBody`)})]})]})},{navLabel:e(`onboarding.workspace.nav`),icon:(0,$.jsx)(Vs,{className:`w-6 h-6`}),accent:jQ.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)(NQ,{icon:(0,$.jsx)(xd,{className:`w-4 h-4`}),label:e(`onboarding.workspace.terminalLabel`),accent:jQ.highlight,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.workspace.terminalBody`,values:{mod:kQ},components:{mod:(0,$.jsx)(MQ,{children:kQ}),j:(0,$.jsx)(MQ,{children:`J`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Zc,{className:`w-4 h-4`}),label:e(`onboarding.workspace.codeLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.codeBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(ge,{className:`w-4 h-4`}),label:e(`onboarding.workspace.browserLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.browserBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Du,{className:`w-4 h-4`}),label:e(`onboarding.workspace.integrationsLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.integrationsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(su,{className:`w-4 h-4`}),label:e(`onboarding.workspace.themesLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.themesBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(kn,{className:`w-4 h-4`}),label:e(`onboarding.workspace.chatsLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.chatsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(je,{className:`w-4 h-4`}),label:e(`onboarding.workspace.compareLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.compareBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Vu,{className:`w-4 h-4`}),label:e(`onboarding.workspace.desktopLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.desktopBody`)})]})})},{navLabel:e(`onboarding.companion.nav`),icon:(0,$.jsx)(dd,{className:`w-6 h-6`}),accent:jQ.success,title:e(`onboarding.companion.title`),subtitle:e(`onboarding.companion.subtitle`),content:(0,$.jsx)(zQ,{})},{navLabel:e(`onboarding.moveFast.nav`),icon:(0,$.jsx)(Tc,{className:`w-6 h-6`}),accent:jQ.primary,title:e(`onboarding.moveFast.title`),subtitle:e(`onboarding.moveFast.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(PQ,{accent:jQ.primary,label:e(`onboarding.moveFast.paletteLabel`),children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.paletteShortcut`,values:{mod:kQ},components:{f:(0,$.jsx)(`span`,{className:`text-foreground`}),m:(0,$.jsx)(`span`,{className:`text-muted-foreground`}),mod:(0,$.jsx)(MQ,{children:kQ}),k:(0,$.jsx)(MQ,{children:`K`})}})}),e(`onboarding.moveFast.paletteBody`)]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-3`,children:[(0,$.jsx)(NQ,{icon:(0,$.jsx)(zs,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.agentLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.agentBody`,values:{mod:kQ},components:{mod:(0,$.jsx)(MQ,{children:kQ}),shift:(0,$.jsx)(MQ,{children:`Shift`}),a:(0,$.jsx)(MQ,{children:`A`}),tab:(0,$.jsx)(MQ,{children:`Tab`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(xd,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.terminalLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.terminalBody`,values:{mod:kQ},components:{mod:(0,$.jsx)(MQ,{children:kQ}),j:(0,$.jsx)(MQ,{children:`J`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(jl,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.shortcutsLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.shortcutsBody`,components:{q:(0,$.jsx)(MQ,{children:`?`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(_e,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.chatLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.chatBody`,values:{mod:kQ},components:{mod:(0,$.jsx)(MQ,{children:kQ}),bkey:(0,$.jsx)(MQ,{children:`B`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(sl,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.projectsLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.projectsBody`,values:{alt:AQ,mod:kQ},components:{alt:(0,$.jsx)(MQ,{children:AQ}),mod:(0,$.jsx)(MQ,{children:kQ}),bkey:(0,$.jsx)(MQ,{children:`B`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Tc,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.pagesLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.pagesBody`,values:{alt:AQ,mod:kQ},components:{alt:(0,$.jsx)(MQ,{children:AQ}),mod:(0,$.jsx)(MQ,{children:kQ}),n:(0,$.jsx)(MQ,{children:`1–9`})}})})]}),(0,$.jsx)(PQ,{accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.outro`,components:t})})]})}]}function VQ({open:e,onClose:t}){let{t:n}=U(`setup`),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),s=(0,Q.useMemo)(()=>BQ(n),[n]),c=s[r],l=r===0,u=r===s.length-1,d=(0,Q.useCallback)(()=>{a&&DQ(),i(0),t()},[a,t]),f=(0,Q.useCallback)(()=>{DQ(),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)(sr,{open:e,onOpenChange:e=>{e||d()},children:(0,$.jsxs)(fr,{children:[(0,$.jsx)(hr,{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)(ir,{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)(xn,{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)(or,{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)(un,{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)(Be,{className:`w-3.5 h-3.5 ml-1`})]})]})]})]})]})]})]})})}function HQ({conversationId:e,children:t,onOpen:n}){let{t:r}=U(`agent`),i=co(),a=y(),o=p(),{uiMode:s,toggleUiMode:c}=eL(),{active:l}=OL(),u=s===`agent`&&o.pathname===`/`&&(i.conversationIds.includes(e)||i.primaryVisible&&l?.id===e),[d,f]=(0,Q.useState)(null),m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),_=()=>{f(null),g.current?.focus()};return(0,Q.useEffect)(()=>{if(!d)return;let e=e=>{h.current?.contains(e.target)||f(null)},t=e=>{(e.key===`Escape`||e.key===`Tab`)&&(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation()),_())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[d]),(0,$.jsxs)(`div`,{ref:m,onContextMenu:e=>{if(e.preventDefault(),e.stopPropagation(),g.current=m.current?.querySelector(`[tabindex="0"]`)??null,u){f(null);return}f({x:e.clientX,y:e.clientY})},onKeyDown:e=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;if(e.preventDefault(),e.stopPropagation(),u){f(null);return}g.current=e.target;let t=e.currentTarget.getBoundingClientRect();f({x:t.left,y:t.bottom})},children:[t,d&&!u&&(0,BC.createPortal)((0,$.jsx)(`div`,{ref:h,role:`menu`,"aria-label":r(`split.menu`),className:`fixed z-[100] w-48 rounded-lg border border-border bg-popover p-1 shadow-xl`,style:{left:Math.max(8,Math.min(d.x,window.innerWidth-200)),top:Math.max(8,Math.min(d.y,window.innerHeight-52))},children:(0,$.jsxs)(`button`,{autoFocus:!0,type:`button`,role:`menuitem`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm hover:bg-muted focus:bg-muted focus:outline-none`,onClick:t=>{t.stopPropagation(),i.open(e),s!==`agent`&&c(),o.pathname!==`/`&&a(`/`),n?.(),_()},children:[(0,$.jsx)(pu,{className:`h-4 w-4`}),r(`split.open`)]})}),document.body)]})}var UQ=(e,t,n)=>Math.min(n,Math.max(t,e)),WQ=e=>`specrails-desktop:sidebar-width:${e}`;function GQ(e,t){let n=WQ(e),[r,i]=(0,Q.useState)(()=>{try{let e=localStorage.getItem(n),r=e?Number.parseInt(e,10):NaN;if(Number.isFinite(r))return UQ(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=UQ(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=UQ(c.current+r,t.min,t.max):e.key===o?s=UQ(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 KQ({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`)})})}function qQ(){let[e,t]=(0,Q.useState)(new Map),n=(0,Q.useContext)(B);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(`${F}/api/projects/${e}/assemble-retry`,{method:`POST`})},[])}}var JQ=(0,Q.lazy)(()=>c(()=>import(`./ProjectSettingsDialog-9NHnG8JQ.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([96,1,7,42,43,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,60,72,54,73,74]))),YQ=`specrails-desktop:agentTreeExpanded`;function XQ(){try{let e=localStorage.getItem(YQ);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 ZQ(e){try{localStorage.setItem(YQ,JSON.stringify([...e]))}catch{}}function QQ(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var $Q=`__home__`,e$=`__favorites__`;function t$({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=U(`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,$.jsx)(HQ,{conversationId:e.id,children:(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)(_e,{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:qC(e.updated_at),children:KC(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)(Cl,{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)(Vn,{className:`w-2.5 h-2.5`})})]})]})})}function n$({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}=U(`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)(sl,{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)(rc,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Cn,{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)(rd,{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)(Vn,{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)(t$,{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 r$={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function i$({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a,onOpenCompanion:o}){let{t:s}=U(`nav`),{t:c}=U(`agent`),{projects:l,activeProjectId:u,setActiveProjectId:d,removeProject:f}=ce(),m=qQ(),h=y(),g=p(),_=g.pathname.startsWith(`/loops`),v=g.pathname.startsWith(`/plugins`),b=_||v||g.pathname.startsWith(`/docs`),{leftMode:x,cycleLeftMode:C}=BZ(),{uiMode:w,toggleUiMode:T}=eL(),E=OL(),{backgroundConversationIds:D}=bs(),O=(0,Q.useMemo)(()=>D.size===0?E.streamingConversationIds:new Set([...E.streamingConversationIds,...D]),[E.streamingConversationIds,D]),k=w===`agent`,A=(0,Q.useMemo)(()=>{let e=new Map,t=new Set(l.map(e=>e.id));for(let n of E.conversations){if(E.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:$Q,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[E.conversations,E.favoriteConversationIds,l]),j=(0,Q.useMemo)(()=>E.conversations.filter(e=>E.favoriteConversationIds.has(e.id)),[E.conversations,E.favoriteConversationIds]),M=A.get($Q)??[],[N,P]=(0,Q.useState)(XQ),F=N.has(e$),[I,ee]=(0,Q.useState)(!1),[te,L]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!k||!u||P(e=>{if(e.has(u))return e;let t=new Set(e);return t.add(u),ZQ(t),t})},[k,u]);let R=e=>{P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),ZQ(n),n})},z=co(),B=e=>{z.focusExisting(e)||(z.showPrimary(),E.selectConversation(e)),b&&h(`/`)},ne=e=>{E.deleteConversation(e).catch(()=>{})},V=e=>{E.toggleFavoriteConversation(e)};function re(e){if(k){d(e),R(e);return}if(e===u){b&&h(`/`);return}d(e)}let[ie,ae]=(0,Q.useState)(!1),H=x===`pinned-open`||x===`unpinned`&&ie,W=GQ(`left-arc`,{side:`left`,defaultWidth:300,min:200,max:460,collapsedWidth:44,expanded:H}),G=x!==`unpinned`,oe=s(r$[x]),se=[...o?[{label:s(`arcSidebar.companion`),icon:dd,action:o}]:[],{label:s(`arcSidebar.analytics`),icon:Zs,action:r},{label:s(`arcSidebar.docs`),icon:Ls,action:i}];async function K(e){try{await f(e.id)}catch{}}return(0,$.jsxs)(`div`,{ref:W.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`&&ae(!0)},onMouseLeave:()=>{x===`unpinned`&&!W.dragging&&ae(!1)},children:[H&&(0,$.jsx)(KQ,{side:`left`,dragging:W.dragging,width:W.width,min:200,max:460,label:s(`arcSidebar.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:W.onGripPointerDown,onKeyDown:W.onGripKeyDown}),!S()&&(0,$.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,H?`px-3 justify-between`:`justify-center`),children:[H&&(0,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:s(`arcSidebar.desktopTitle`)}),!S()&&(0,$.jsx)(`button`,{type:`button`,onClick:C,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,G?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":oe,title:s(`sidebarPin.withShortcut`,{label:oe,shortcut:jq(`⌥⌘B`)}),children:(0,$.jsx)(lu,{className:`w-4 h-4`})})]}),at&&(0,$.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[k&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{E.startNewConversation(u),b&&h(`/`)},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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(`newAgent`),title:H?void 0:c(`newAgent`),children:[(0,$.jsx)(Pn,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:c(`newAgent`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:T,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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(k?`switchToKanban`:`switchToAgent`),title:c(k?`switchToKanban`:`switchToAgent`),children:[k?(0,$.jsx)(Ll,{className:`w-4 h-4 flex-shrink-0`}):(0,$.jsx)(zs,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),H&&(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:c(k?`switchToKanban`:`switchToAgent`)})]}),k&&(0,$.jsxs)(`button`,{type:`button`,onClick:QQ,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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(`search`),title:H?void 0:c(`search`),children:[(0,$.jsx)(In,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:c(`search`)})]})]}),st&&(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`,H?`px-2`:`px-0 justify-center`,_?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":s(`arcSidebar.loops`),"aria-current":_?`page`:void 0,title:H?void 0:s(`arcSidebar.loops`),children:[(0,$.jsx)(Fd,{className:X(`w-4 h-4 flex-shrink-0`,_&&`text-accent-primary`)}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`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`,H?`px-2`:`px-0 justify-center`,v?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":s(`arcSidebar.plugins`),"aria-current":v?`page`:void 0,title:H?void 0:s(`arcSidebar.plugins`),children:[(0,$.jsx)(ku,{className:X(`w-4 h-4 flex-shrink-0`,v&&`text-accent-primary`)}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`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:[k&&j.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:()=>R(e$),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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(`favoriteMissions`),"aria-expanded":F,title:H?void 0:c(`favoriteMissions`),children:[H?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(Cl,{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:F?(0,$.jsx)(rc,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Cn,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(Cl,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),H&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:c(`favoriteMissions`)})]}),F&&H&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:j.map(e=>(0,$.jsx)(t$,{conversation:e,active:e.id===E.active?.id,streaming:O.has(e.id),unread:E.unreadConversationIds.has(e.id),favorite:!0,expanded:H,onSelect:()=>B(e.id),onToggleFavorite:()=>V(e.id),onDelete:()=>ne(e.id)},e.id))})]}),k&&M.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>R($Q),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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(`home`),"aria-expanded":N.has($Q),title:H?void 0:c(`home`),children:[H?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(Tl,{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:N.has($Q)?(0,$.jsx)(rc,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Cn,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(Tl,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:c(`home`)})]}),N.has($Q)&&H&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:M.map(e=>(0,$.jsx)(t$,{conversation:e,active:e.id===E.active?.id,streaming:O.has(e.id),unread:E.unreadConversationIds.has(e.id),expanded:H,onSelect:()=>B(e.id),onToggleFavorite:()=>V(e.id),onDelete:()=>ne(e.id)},e.id))})]}),l.map(e=>{let t=A.get(e.id)??[];return(0,$.jsx)(n$,{project:e,isActive:e.id===u&&!b,expanded:H,onSelect:()=>re(e.id),onRemove:()=>K(e),agentMode:k,hasTree:t.length>0,treeOpen:N.has(e.id),onToggleTree:()=>R(e.id),conversations:t,activeConversationId:E.active?.id??null,streamingConversationIds:O,unreadConversationIds:E.unreadConversationIds,onSelectConversation:B,onToggleConversationFavorite:V,onDeleteConversation:ne,assembleStatus:m.statusFor(e.id),onRetryAssemble:()=>{m.retry(e.id)},onOpenProjectSettings:k?()=>{d(e.id),ee(!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`,H?`px-2`:`px-0 justify-center`),"aria-label":s(`projects.addProject`),title:H?void 0:s(`projects.addProject`),children:[(0,$.jsx)(Pn,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`projects.addProject`)})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-border py-2 px-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center rounded-md text-muted-foreground`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":s(`arcSidebar.settings`),title:s(`arcSidebar.settings`),className:X(`flex items-center gap-2 flex-1 min-w-0 h-8 rounded-md hover:text-foreground hover:bg-muted/50 focus-visible:outline focus-visible:outline-ring`,H?`px-2`:`justify-center`),children:[(0,$.jsx)(rd,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-left text-xs`,children:s(`arcSidebar.settings`)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>L(e=>!e),"aria-label":s(te?`common:actions.collapse`:`common:actions.expand`),"aria-expanded":te,"aria-controls":`sidebar-desktop-tools`,title:s(te?`common:actions.collapse`:`common:actions.expand`),className:X(`flex items-center justify-center h-8 shrink-0 rounded-md hover:text-foreground hover:bg-muted/50 focus-visible:outline focus-visible:outline-ring`,H?`w-8`:`w-3.5`),children:(0,$.jsx)(Cn,{className:X(`w-3 h-3 transition-transform`,te&&`rotate-90`)})})]}),te&&(0,$.jsx)(`div`,{id:`sidebar-desktop-tools`,role:`group`,"aria-label":s(`arcSidebar.settings`),className:`flex flex-col gap-0.5 mt-1`,children:se.map(({label:e,icon:t,action:n})=>(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:X(`flex items-center gap-2 h-8 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 focus-visible:outline focus-visible:outline-ring`,H?`pl-5 pr-2`:`w-8 justify-center self-center`),"aria-label":e,title:e,children:[(0,$.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs`,children:e})]},e))})]}),I&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(JQ,{open:!0,onClose:()=>ee(!1)})})]})}function a$({open:e,onClose:t,onCommitted:n,projectId:r,milestoneId:i,blueprint:a,provider:o=`claude`}){let{t:s}=U(`builder`),{registerHandler:c,unregisterHandler:l}=R(),[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=Qt(o,`read-only`),P=(0,Q.useMemo)(()=>iI(v??g,{milestoneLabel:M,minSpecs:1,maxSpecs:10,requireScaffold:!1}),[g,v,M]),F=(0,Q.useMemo)(()=>oI(g,v??g,P,{minSpecs:1,maxSpecs:10}),[g,v,P]),I=(0,Q.useMemo)(()=>Ut(m),[m]);(0,Q.useEffect)(()=>{if(!e||u||!N)return;let t=!1;return fetch(`${G()}/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(`${G()}/chat/conversations/${e.conversation.id}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:i})}).catch(()=>{C(!1),K.error(s(`errors.turnFailed`))})}).catch(()=>{t||K.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=Kt(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),K.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 ee=(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(`${G()}/chat/conversations/${t}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n})}).catch(()=>{C(!1),K.error(s(`errors.turnFailed`))}))},[S,s]),te=(0,Q.useCallback)(()=>{let e=E.status===`rejected`?s(`snapshot.rejected.${E.reason}`):s(`readiness.issuesCount`,{count:F.issues.length});ee(s(`prompts.repairSnapshot`,{reason:e}))},[E,F.issues.length,ee,s]),L=(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(`${G()}/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();K.success(s(`milestone.commitToast`,{count:r.insertedIds.length,label:M})),n?.(),t()}else{let t=await e.json().catch(()=>({}));K.error(s(`milestone.commitFailed`),{description:t.detail??t.error})}}).catch(()=>K.error(s(`milestone.commitFailed`))).finally(()=>T(!1)))},[g,v,P.valid,w,i,M,t,n,s]);if(!e)return null;let z=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)(xl,{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)(Vn,{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:[At(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)(PF,{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(),ee(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:()=>ee(b),disabled:S||!b.trim()||!u,children:S?(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Zu,{className:`h-3.5 w-3.5`})})]})]}),(0,$.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col lg:w-96`,children:[(0,$.jsx)(II,{blueprint:g,milestoneLabel:M,snapshot:E}),(0,$.jsx)(zI,{readiness:F,snapshot:E,busy:S||w,primaryLabel:w?s(`commit.creating`):s(`milestone.commit`,{count:z,label:M}),onPrimary:L,onRepair:te,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)(xl,{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)(Vn,{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 o$({expanded:e}){let{t}=U(`builder`),n=y(),{activeProjectId:r,projects:i}=ce(),{blueprint:a,progress:o,hasBlueprint:s,refresh:c}=It(r),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(()=>RF()),[_,v]=(0,Q.useState)(null),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),[S,C]=(0,Q.useState)(null);(0,Q.useLayoutEffect)(()=>{if(!l){C(null);return}let e=()=>{let e=b.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));C({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;b.current?.contains(t)||x.current?.contains(t)||u(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let w=(0,Q.useCallback)(async()=>{if(!(!r||d)){f(!0);try{let e=await WF(r,1,{autoAdvance:h}),n=VF(1);if(e.ok){let r=e.launched.length+e.pending.length;e.pending.length>0?K.success(t(h?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:n,count:e.ticketCount,n:r})):K.success(t(`milestoneProgress.toast.launchedAll`,{milestone:n,count:e.ticketCount,n:r})),u(!1)}else e.reason===`chain_active`?K.info(t(`milestoneProgress.toast.chainActive`,{milestone:n})):e.reason===`rail_limit_reached`?K.warning(t(`milestoneProgress.toast.railLimitReached`,{milestone:n})):K.error(t(`done.launchFailed`),{description:e.detail??e.error})}finally{f(!1)}}},[r,h,d,t]),T=(0,Q.useCallback)(async(e,n)=>{if(!(!r||p)){m(!0);try{let i=await JF(r,e,n);i.ok?(g(n),zF(n),K.success(t(n?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):K.error(t(`milestoneProgress.chain.autoFailed`),{description:i.detail??i.error})}finally{m(!1)}}},[r,p,t]),E=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await KF(r,e);n.ok?K.success(t(`milestoneProgress.chain.resumed`)):K.error(t(`milestoneProgress.chain.resumeFailed`),{description:n.detail??n.error})}finally{m(!1)}}},[r,p,t]),D=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await qF(r,e);n.ok?K.success(t(`milestoneProgress.chain.cancelledToast`)):K.error(n.detail??n.error)}finally{m(!1)}}},[r,p,t]),O=(0,Q.useCallback)(e=>{u(!1),n(Ve?`/review/${e}`:`/`)},[n]),k=(0,Q.useCallback)(()=>{u(!1),n(`/`)},[n]);if(!r||s===!1||!a)return null;let A=o.find(e=>e.n===1)??null,j=A!==null&&Ot(A),M=o.find(e=>e.state===`planned`&&e.n>1)??null,N=i.find(e=>e.id===r),P=N?.provider??N?.providers?.[0]??`claude`,F=Qt(P,`read-only`),I=j?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`milestone-launch-hint`,children:t(`milestoneProgress.sequentialHint`)}),(0,$.jsx)(CI,{checked:h,onChange:e=>{g(e),zF(e)},testId:`sidebar-auto-advance`}),(0,$.jsxs)(`button`,{type:`button`,onClick:w,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)(An,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Vu,{className:`h-3 w-3`}),t(`sidebar.launchM1`)]})]}):null;return(0,$.jsxs)(`div`,{ref:b,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)(xl,{className:`w-4 h-4 flex-shrink-0`}),e&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:t(`sidebar.title`)})]}),l&&S&&(0,BC.createPortal)((0,$.jsxs)(`div`,{ref:x,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:S.top,left:S.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)(TI,{progress:e,actions:e.n===1?I:void 0,chainBusy:p,onReview:O,onOpenRail:k,onResume:E,onCancel:D,onSetAutoAdvance:T},e.id||e.n))}),M&&(0,$.jsx)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{F&&(v(M.id),u(!1))},disabled:!F,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(F?`sidebar.generateHint`:`sidebar.generateUnavailable`),"data-testid":`sidebar-generate-next`,children:[(0,$.jsx)(Ln,{className:`h-3 w-3`}),t(`sidebar.generateNext`,{n:M.n})]})})]}),document.body),_&&(0,$.jsx)(a$,{open:!0,onClose:()=>v(null),onCommitted:()=>{c()},projectId:r,milestoneId:_,blueprint:a,provider:P})]})}var s$={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function c$(){let{t:e}=U(`nav`),{rightMode:t,cycleRightMode:n}=BZ(),[r,i]=(0,Q.useState)(!1),a=t===`pinned-open`||t===`unpinned`&&r,o=t!==`unpinned`,s=e(s$[t]),c=[{to:`/`,end:!0,icon:Fl,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:qs,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:Ys,label:e(`rightSidebar.analytics`)},...Ke?[{to:`/code`,end:!1,icon:_c,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:rd,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:[!S()&&(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`)}),!S()&&(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:jq(`⌘B`)}),children:(0,$.jsx)(du,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,$.jsx)(o$,{expanded:a}),c.map(({to:e,end:t,icon:n,label:r})=>(0,$.jsxs)(g,{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 l$(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 u$({status:e,isLoading:t,error:n,onRefresh:r,onMoreInfo:i}){let{t:a}=U(`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)(sc,{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)(Lu,{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)(zn,{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)(Lu,{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.filter(e=>on(e.key)).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)(Tn,{className:`w-3.5 h-3.5 text-destructive flex-shrink-0`}):n||r?(0,$.jsx)(sc,{className:`w-3.5 h-3.5 text-accent-success flex-shrink-0`}):o?(0,$.jsx)(Tn,{className:`w-3.5 h-3.5 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(Tn,{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)(au,{className:`w-2.5 h-2.5`}),a(`prerequisites.bundledBadge`)]}),(0,$.jsxs)(`span`,{className:X(`text-muted-foreground`,t&&`text-destructive/80`),children:[`— `,l$(e,a)]})]},e.key)})})]})}function d$(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 f$=[`darwin`,`win32`,`linux`];async function p$(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 m$({command:e}){let{t}=U(`setup`),[n,r]=(0,Q.useState)(!1);return(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await p$(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)(xn,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kc,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function h$({platform:e,primary:t}){let{t:n}=U(`setup`),r=d$(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)(m$,{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)(Dn,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function g$(){let{t:e}=U(`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(`${F}/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)(xn,{className:`w-3 h-3 text-accent-success`}):(0,$.jsx)(pc,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function _$({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=U(`setup`),[o,s]=(0,Q.useState)(!1),c=n?.platform??`darwin`,l=f$.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,$.jsx)(vr,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:a(`instructions.corrupted.title`)}),(0,$.jsx)(cr,{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)(vr,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-xl`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:a(`instructions.title`)}),(0,$.jsx)(cr,{children:a(`instructions.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(h$,{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)(h$,{platform:e,primary:!1},e))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,$.jsx)(g$,{}),(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)(Lu,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var v$=typeof window<`u`&&`__TAURI_INTERNALS__`in window;function y$({open:e,onClose:t,onOpenBuilder:n}){let r=ze&&!!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)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)({claude:!0}),[y,b]=(0,Q.useState)(!1),{t:x}=U(`setup`),{addProject:S}=ce(),{status:C,isLoading:w,error:T,recheck:E}=TF(),D=(0,Q.useMemo)(()=>{if(!C||C.ok)return null;let e=C.missingRequired.map(e=>e.label);return e.length===0?null:x(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[C,x]),O=C!==null&&!C.ok&&!T;(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`&&on(n)&&(t[n]=r);v(t)}).catch(()=>{})},[e]);async function k(){let e=o.trim();if(!e){K.error(x(`addProject.errors.pathRequired`));return}g(!0);try{let t=d.map(e=>({path:e.trim()})).filter(e=>e.path),n=p.trim()?p.split(`
|
|
76
|
+
`).map(e=>e.trim()).filter(Boolean):null})}});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let s=await fetch(C,{cache:`no-store`});if(!s.ok)throw Error(`HTTP ${s.status}`);let c=await s.json();S.current&&(i(c.repositories),l(!1),o(null)),await t?.()}catch(e){S.current&&x(e instanceof Error?e.message:String(e))}finally{S.current&&y(!1)}}}return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsxs)(Qq,{className:`flex items-center gap-2`,children:[(0,$.jsx)(al,{className:`h-4 w-4`}),n(`repositories.title`)]}),(0,$.jsx)($q,{children:n(`repositories.sharedBacklog`)})]}),(0,$.jsxs)(eJ,{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:v,onClick:()=>w(e),children:n(`actions.edit`)}),!e.isPrimary&&(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,disabled:v,onClick:()=>void T(`DELETE`,e.id),children:n(`repositories.detach`)})]})]}),(0,$.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:e.path}),e.workspacePaths?.map(e=>(0,$.jsxs)(`p`,{className:`break-all text-xs text-muted-foreground`,children:[n(`repositories.workspacePath`),`: `,e]},e)),!e.workspacePaths&&e.workspacePath&&(0,$.jsxs)(`p`,{className:`break-all text-xs text-muted-foreground`,children:[n(`repositories.workspacePath`),`: `,e.workspacePath]}),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`)}),b&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:b}),s||a?(0,$.jsxs)(`form`,{className:`space-y-3 rounded-lg border border-border p-3`,onSubmit:e=>{e.preventDefault(),T(a?`PATCH`:`POST`,a?.id)},children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.name`),(0,$.jsx)(gF,{value:f,disabled:v,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)(gF,{value:u,required:!0,disabled:v||a?.isPrimary,onChange:e=>d(e.target.value)}),`__TAURI_INTERNALS__`in window&&!a?.isPrimary&&(0,$.jsx)(Z,{type:`button`,variant:`outline`,disabled:v,"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([95,0,1])),t=await e({directory:!0,multiple:!1});typeof t==`string`&&S.current&&d(t)}catch{}},children:(0,$.jsx)(sl,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.workspacePath`),(0,$.jsx)(`textarea`,{className:`flex min-h-20 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:m,disabled:v,placeholder:a?.path??u,onChange:e=>h(e.target.value)}),(0,$.jsx)(`span`,{className:`block text-muted-foreground`,children:n(`repositories.workspaceHint`)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[n(`repositories.integrationBranch`),(0,$.jsx)(gF,{value:g,disabled:v,placeholder:n(`repositories.branchDefault`),onChange:e=>_(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`submit`,size:`sm`,disabled:v||!u.trim(),children:n(v?`actions.saving`:`actions.save`)}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`ghost`,disabled:v,onClick:()=>{l(!1),o(null),x(null)},children:n(`actions.cancel`)})]})]}):(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,disabled:v,onClick:()=>w(),children:[(0,$.jsx)(Pn,{className:`mr-1 h-4 w-4`}),n(`repositories.addFolder`)]})]})]})}var hJ=[`claude`,`codex`,`gemini`,`kimi`],gJ=[`architect`,`developer`,`reviewer`];[...gJ];function _J(e){return e.kind===`openai-compatible`&&e.label?.trim()?e.label.trim():e.id}function vJ(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.providers)&&t.providers.every(e=>e&&typeof e.id==`string`&&[`cli`,`openai-compatible`].includes(e.kind))&&(t.status===void 0||typeof t.status==`object`&&t.status!==null)}var yJ=/^[a-z][a-z0-9-]{0,63}$/,bJ=[`architect`,`developer`,`host`];function xJ(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&Array.isArray(t.catalog)&&t.catalog.every(e=>e&&typeof e.id==`string`&&bJ.includes(e.phase))}function SJ(e,t,n){let r={...e};return n?delete r[t]:r[t]=!1,Object.keys(r).length?r:void 0}var CJ=[`type_correctness`,`pattern_adherence`,`test_coverage`,`security`,`architectural_alignment`],wJ={minScore:70,aspects:{type_correctness:60,pattern_adherence:60,test_coverage:60,security:75,architectural_alignment:60}};function TJ(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.config;return typeof t.configured==`boolean`&&typeof t.runtimeAvailable==`boolean`&&n?.schemaVersion===1&&typeof n.enabled==`boolean`&&Array.isArray(n.providers)&&n.providers.every(e=>e&&typeof e.id==`string`&&[`cli`,`openai-compatible`].includes(e.kind))&&Array.isArray(n.verification)&&(n.setup===void 0||Array.isArray(n.setup))&&!!n.agents&&gJ.every(e=>typeof n.agents[e]?.provider==`string`)&&(n.roles===void 0||n.roles!==null&&typeof n.roles==`object`&&!Array.isArray(n.roles)&&Object.entries(n.roles).every(([e,t])=>yJ.test(e)&&e!==`fixer`&&t&&typeof t.provider==`string`&&[`read`,`write`].includes(t.access)&&[`none`,`tasks-checkboxes`,`all`].includes(t.artifacts)))}function EJ(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.repositories)&&Array.isArray(t.suggestions)&&t.suggestions.every(e=>e&&typeof e.repositoryId==`string`&&typeof e.command==`string`&&Array.isArray(e.args))}function DJ(e,t){let n=t,r=2;for(;e.some(({id:e})=>e===n);)n=`${t}-${r++}`;return n}function OJ(e){return[e.command,...e.args].map(e=>/[\s"]/.test(e)?JSON.stringify(e):e).join(` `)}function kJ(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(r){if(o===`\\`&&a+1<e.length){n+=e[++a];continue}if(o===`"`){r=!1;continue}n+=o;continue}if(o===`"`){r=!0,i=!0;continue}if(/\s/.test(o)){i&&=(t.push(n),n=``,!1);continue}n+=o,i=!0}return r||(i&&t.push(n),!t.length||!t[0])?null:{command:t[0],args:t.slice(1)}}var AJ=`h-9 w-full rounded-md border border-input bg-background px-2 text-sm`;function jJ(e){return(e??[]).map(e=>({original:e,label:e.label,repositoryId:e.repositoryId,line:OJ(e)}))}function MJ(e,t){let n=[];for(let r of e){if(!r.line.trim()&&!r.repositoryId)continue;let e=kJ(r.line);if(!e||!r.repositoryId)return t(r.line||`∅`),null;n.push({...r.original,...r.label===void 0?{}:{label:r.label.trim()||void 0},repositoryId:r.repositoryId,...e})}return n}function NJ({rows:e,repositories:t,onChange:n,keys:r,placeholder:i,toolbar:a,testId:o}){let{t:s}=U(`agentRuntime`),c=(t,r)=>n(e.map((e,n)=>n===t?{...e,...r}:e)),l=(t,r)=>{let i=[...e];[i[r],i[t]]=[i[t],i[r]],n(i)};return(0,$.jsxs)(`div`,{className:`space-y-3`,"data-testid":o,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`${r}.hint`)}),a]}),r===`setup`&&e.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`setup.empty`)}),e.map((a,o)=>(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(8rem,1fr)_2fr_auto]`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[s(`${r}.repository`),t.length?(0,$.jsxs)(`select`,{className:AJ,value:a.repositoryId,onChange:e=>c(o,{repositoryId:e.target.value}),children:[!t.some(e=>e.id===a.repositoryId)&&(0,$.jsx)(`option`,{value:a.repositoryId,children:a.repositoryId||`—`}),t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):(0,$.jsx)(gF,{value:a.repositoryId,onChange:e=>c(o,{repositoryId:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[s(`${r}.command`),(0,$.jsx)(gF,{className:`font-mono`,spellCheck:!1,placeholder:i,value:a.line,onChange:e=>c(o,{line:e.target.value,reason:void 0})})]}),(0,$.jsxs)(`label`,{className:`block space-y-1`,children:[s(`${r}.label`),(0,$.jsx)(gF,{maxLength:256,value:a.label??``,onChange:e=>c(o,{label:e.target.value})})]}),a.reason&&(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`verification.reason`,{reason:a.reason})})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-1`,children:[(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,"aria-label":`${s(`${r}.moveUp`)} ${o+1}`,disabled:o===0,onClick:()=>l(o,o-1),children:`↑`}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,"aria-label":`${s(`${r}.moveDown`)} ${o+1}`,disabled:o===e.length-1,onClick:()=>l(o,o+1),children:`↓`}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,onClick:()=>n(e.filter((e,t)=>t!==o)),children:s(`${r}.remove`)})]})]},o)),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,onClick:()=>n([...e,{repositoryId:t[0]?.id??``,line:``}]),children:s(`${r}.add`)})]})}function PJ(e){return e.map(e=>({repositoryId:e.repositoryId,line:OJ(e),reason:e.reason}))}function FJ(){let{activeProjectId:e,projects:t}=ce(),n=(0,Q.useRef)(new Map),r=t.find(t=>t.id===e);return e?(0,$.jsx)(IJ,{projectId:e,cache:n.current,repositories:kr(r).map(({id:e,name:t})=>({id:e,name:t}))},e):null}function IJ({projectId:e,cache:t,repositories:n}){let{t:r}=U(`agentRuntime`),i=t.get(e),[a,o]=(0,Q.useState)(i?.config??null),[s,c]=(0,Q.useState)(jJ(i?.config.verification)),[l,u]=(0,Q.useState)(jJ(i?.config.setup)),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!i),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O=(0,Q.useRef)(!0),k=`${Or(e)}/agent-runtime/config`;function A(e){D.current=!0,w(!0),S(!1),c(e)}function j(e){D.current=!0,w(!0),S(!1),u(e)}let M=`${Or(e)}/agent-runtime/verification-suggestions`;async function N(){try{let e=await fetch(M,{cache:`no-store`});if(!e.ok)return null;let t=await e.json();return EJ(t)?t.suggestions:null}catch{return null}}(0,Q.useEffect)(()=>{O.current=!0;let n=!1;return fetch(k,{cache:`no-store`}).then(async i=>{if(!i.ok)throw Error(r(`loadFailed`));let a=await i.json();if(!TJ(a))throw Error(r(`loadFailed`));if(!n){if(t.set(e,a),!D.current&&(o(a.config),c(jJ(a.config.verification)),u(jJ(a.config.setup)),!a.configured&&a.config.verification.length===0)){let e=await N();if(n||D.current)return;e?.length?(c(PJ(e)),g(`some`)):e&&g(`none`)}b(``)}}).catch(()=>{n||b(r(`loadFailed`))}).finally(()=>{n||v(!1)}),()=>{n=!0,O.current=!1}},[k,e,t,T,r]);let P=()=>MJ(s,e=>b(r(`verification.invalidLine`,{line:e}))),F=()=>MJ(l,e=>b(r(`setup.invalidLine`,{line:e})));async function I(){m(!0),b(``);try{let e=await N();if(!O.current)return;if(!e){b(r(`verification.detectFailed`));return}let t=new Set(s.map(e=>`${e.repositoryId}\0${e.line}`)),n=PJ(e).filter(e=>!t.has(`${e.repositoryId}\0${e.line}`));A([...s,...n]),g(e.length?`some`:`none`)}finally{O.current&&m(!1)}}async function ee(){if(!a||d)return;b(``),S(!1);let n=P();if(!n)return;let i=F();if(i){f(!0);try{let s=await fetch(k,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...a,verification:n,setup:i})}),l=await s.json();if(!s.ok)throw Error(l.message??l.error??r(`saveFailed`));if(!TJ(l))throw Error(r(`saveFailed`));if(t.set(e,l),!O.current)return;D.current=!1,w(!1),o(l.config),c(jJ(l.config.verification)),u(jJ(l.config.setup)),S(!0)}catch(e){O.current&&b(e instanceof Error?e.message:r(`saveFailed`))}finally{O.current&&f(!1)}}}function te(){return(0,$.jsx)(NJ,{rows:s,repositories:n,onChange:A,keys:`verification`,placeholder:`npm test`,testId:`verification-commands`,toolbar:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,disabled:p,onClick:()=>void I(),children:r(p?`verification.detecting`:`verification.detect`)}),h===`some`&&!s.some(e=>!e.reason)&&(0,$.jsx)(`p`,{role:`status`,className:`basis-full text-xs text-accent-success`,children:r(`verification.detected`)}),h===`none`&&s.length===0&&(0,$.jsx)(`p`,{role:`status`,className:`basis-full text-xs text-muted-foreground`,children:r(`verification.nothingDetected`)})]})})}function L(){return(0,$.jsxs)(`section`,{className:`space-y-3 border-t pt-4`,"aria-labelledby":`runtime-setup-title`,children:[(0,$.jsx)(`h3`,{id:`runtime-setup-title`,className:`text-sm font-medium`,children:r(`setup.title`)}),(0,$.jsx)(NJ,{rows:l,repositories:n,onChange:j,keys:`setup`,placeholder:`npx playwright install chromium`,testId:`setup-commands`})]})}return(0,$.jsxs)(Xq,{id:`agent-runtime-settings`,children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:r(`verification.title`)}),(0,$.jsx)($q,{children:r(`loopAgents.projectHint`)})]}),(0,$.jsxs)(eJ,{className:`space-y-4`,children:[_&&(0,$.jsx)(`p`,{role:`status`,children:r(`loading`)}),y&&(0,$.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:y}),!a&&!_&&(0,$.jsx)(Z,{onClick:()=>{v(!0),E(e=>e+1)},children:r(`retry`)}),a&&(0,$.jsxs)(`fieldset`,{disabled:d,className:`space-y-3`,children:[te(),L(),(0,$.jsxs)(`div`,{className:`sticky bottom-3 flex items-center justify-end gap-3 rounded border bg-card p-2`,"data-testid":`runtime-save-pill`,"data-unsaved":C,children:[C&&(0,$.jsx)(`span`,{children:r(`unsavedChanges`)}),x&&(0,$.jsx)(`p`,{role:`status`,children:r(`saved`)}),(0,$.jsx)(Z,{disabled:d,onClick:()=>void ee(),children:r(d?`saving`:`save`)})]})]})]})]})}function LJ(){return(0,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-lg bg-muted/30`,"data-testid":`section-skeleton`})}function RJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),[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(`${G()}/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)(LJ,{});async function c(t){a(!0);let i=n;r(t);try{if(!(await fetch(`${G()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pipelineTelemetryEnabled:t})})).ok)throw Error(`Failed to save`);K.success(e(t?`telemetry.enabled`:`telemetry.disabled`))}catch(t){r(i),K.error(e(`telemetry.saveFailed`),{description:t.message})}finally{a(!1)}}return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:e(`telemetry.title`)}),(0,$.jsx)($q,{children:e(`telemetry.description`)})]}),(0,$.jsx)(eJ,{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)(H,{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 zJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),[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(`${G()}/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)(LJ,{});async function d(){s(!0);try{let t=await fetch(`${G()}/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`)}K.success(e(`integrationBranch.saved`)),await u()}catch(t){K.error(e(`integrationBranch.saveFailed`),{description:t.message})}finally{s(!1)}}return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:e(`integrationBranch.title`)}),(0,$.jsx)($q,{children:e(`integrationBranch.description`)})]}),(0,$.jsxs)(eJ,{className:`space-y-3`,children:[(0,$.jsx)(gF,{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)(H,{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 BJ=/^[A-Za-z_][A-Za-z0-9_]*$/,VJ=[`NODE_AUTH_TOKEN`,`NPM_TOKEN`,`AWS_PROFILE`];function HJ(e){return e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}var UJ={inherited:`inherited`,recovered:`recovered`,"not-defined":`notDefined`,"probe-timeout":`probeTimeout`,"probe-failed":`probeFailed`,pending:`pending`},WJ={inherited:`success`,recovered:`success`,"not-defined":`warning`,"probe-timeout":`failed`,"probe-failed":`failed`,pending:`queued`},GJ=e=>e===`not-defined`||e===`probe-timeout`||e===`probe-failed`;function KJ({entry:e,report:t}){let{t:n}=U(`settings`),r=UJ[e.status],i=qJ(n,e,t);return(0,$.jsxs)(EN,{children:[(0,$.jsx)(DN,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:0,className:`inline-flex rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,$.jsx)(LH,{variant:WJ[e.status],className:`font-normal`,"data-testid":`worktree-env-status-${e.name}`,"data-status":e.status,"aria-label":`${e.name}: ${n(`worktreeEnv.status.${r}`)}`,children:n(`worktreeEnv.status.${r}`)})})}),(0,$.jsx)(ON,{className:`max-w-xs leading-relaxed`,children:i})]})}function qJ(e,t,n){let r={name:t.name,shell:t.shell??e(`worktreeEnv.hint.defaultShell`),seconds:Math.round(n.timeoutMs/1e3)};return t.status===`not-defined`&&!n.loginShellRecovery?e(`worktreeEnv.hint.notDefinedInherited`,r):e(`worktreeEnv.hint.${UJ[t.status]}`,r)}function JJ(){let{t:e,i18n:t}=U(`settings`),{activeProjectId:n}=ce(),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(0),b=(0,Q.useRef)(n);b.current=n;async function x(e){let t=++y.current,n=b.current,r=e===`POST`?`env-passthrough/recheck`:`env-passthrough/status`;try{let i=await fetch(`${G()}/${r}`,e===`POST`?{method:`POST`}:void 0);if(!i.ok)throw Error(String(i.status));let a=await i.json();if(t!==y.current||n!==b.current)return;m(a&&Array.isArray(a.names)?a:null),g(!1)}catch{if(t!==y.current||n!==b.current)return;g(!0)}}if((0,Q.useEffect)(()=>{if(!n)return;let e=!1;return f(!1),c(``),m(null),g(!1),v(!1),fetch(`${G()}/settings`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&i(Array.isArray(t.worktreeEnvPassthrough)?t.worktreeEnvPassthrough:[])}).catch(()=>{}).finally(()=>{e||f(!0)}),x(`GET`),()=>{e=!0,y.current+=1}},[n]),!d)return(0,$.jsx)(LJ,{});async function S(){v(!0);let e=b.current;try{await x(`POST`)}finally{e===b.current&&v(!1)}}let C=new Map((p?.names??[]).map(e=>[e.name,e])),w=(p?.names??[]).filter(e=>r.includes(e.name)&&GJ(e.status)),T=(p?.names??[]).map(e=>e.checkedAt).filter(e=>!!e).sort().pop();function E(t){let n=HJ(t);if(n.length===0)return;let a=[...r];for(let t of n){if(t.includes(`=`)){c(e(`worktreeEnv.noValues`));return}if(!BJ.test(t)){c(e(`worktreeEnv.invalidName`,{name:t}));return}a.includes(t)||a.push(t)}i(a),o(``),c(``)}async function D(){u(!0);try{let t=await fetch(`${G()}/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({worktreeEnvPassthrough:r})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to save`)}let n=await t.json();i(n.settings?.worktreeEnvPassthrough??r),K.success(e(`worktreeEnv.saved`)),x(`GET`)}catch(t){K.error(e(`worktreeEnv.saveFailed`),{description:t.message})}finally{u(!1)}}return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:e(`worktreeEnv.title`)}),(0,$.jsx)($q,{children:e(`worktreeEnv.description`)})]}),(0,$.jsxs)(eJ,{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)(gF,{id:`worktree-env-name`,value:a,onChange:e=>{o(e.target.value),c(``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E(a))},placeholder:e(`worktreeEnv.placeholder`),"aria-invalid":!!s,"data-testid":`worktree-env-input`}),(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`secondary`,className:`h-9 shrink-0`,onClick:()=>E(a),disabled:!a.trim(),"data-testid":`worktree-env-add`,children:[(0,$.jsx)(Pn,{className:`w-3.5 h-3.5`}),e(`worktreeEnv.add`)]})]}),s?(0,$.jsx)(`p`,{className:`text-[10px] text-destructive`,"data-testid":`worktree-env-error`,children:s}):(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e(`worktreeEnv.helper`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:VJ.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>E(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))}),r.length>0?(0,$.jsx)(TN,{delayDuration:200,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`worktree-env-list`,children:r.map(t=>{let n=C.get(t);return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-background py-1 pl-2 pr-1 font-mono text-[11px]`,children:[t,n&&p&&(0,$.jsx)(KJ,{entry:n,report:p}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(r.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)(Vn,{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`)}),p&&w.length>0&&(0,$.jsxs)(`ul`,{className:`space-y-1.5 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] leading-relaxed text-muted-foreground aurora-light:border-accent-warning/30 aurora-light:bg-accent-warning/5`,"data-testid":`worktree-env-unresolved`,children:[(0,$.jsx)(`li`,{className:`font-medium text-foreground`,children:e(`worktreeEnv.unresolvedTitle`)}),w.map(t=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:t.name}),` — `,qJ(e,t,p)]},t.name))]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`worktree-env-status-meta`,"aria-live":`polite`,children:h?e(`worktreeEnv.statusUnavailable`):_||p?.checking?e(`worktreeEnv.checking`):T?e(`worktreeEnv.lastChecked`,{time:new Date(T).toLocaleTimeString(t.language)}):null}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,onClick:()=>{S()},disabled:_||r.length===0,"data-testid":`worktree-env-recheck`,children:[(0,$.jsx)(Lu,{className:`w-3.5 h-3.5 ${_?`animate-spin`:``}`}),e(_?`worktreeEnv.checking`:`worktreeEnv.recheck`)]}),(0,$.jsx)(Z,{size:`sm`,onClick:D,disabled:l,"data-testid":`worktree-env-save`,children:e(l?`common:states.saving`:`worktreeEnv.save`)})]})]})]})]})}function YJ({value:e,onChange:t,onSave:n,isSaving:r,fieldId:i,i18nRoot:a}){let{t:o}=U(`settings`);return(0,$.jsxs)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:o(`${a}.title`)}),(0,$.jsx)($q,{children:o(`${a}.description`)})]}),(0,$.jsxs)(eJ,{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 XJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),[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(`${G()}/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(`${G()}/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),K.success(i.trim()===``?e(`prePrompt.cleared`):e(`prePrompt.saved`))}catch(t){K.error(e(`prePrompt.saveFailed`),{description:t.message})}finally{a(!1)}}async function m(){l(!0);try{let t=await fetch(`${G()}/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),K.success(n.trim()===``?e(`freestylePrePrompt.resetToDefault`):e(`freestylePrePrompt.saved`))}catch(t){K.error(e(`freestylePrePrompt.saveFailed`),{description:t.message})}finally{l(!1)}}return u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(YJ,{value:n,onChange:e=>{f.current.pre=!0,r(e)},onSave:p,isSaving:i,fieldId:`project-pre-prompt`,i18nRoot:`prePrompt`}),(0,$.jsx)(YJ,{value:o,onChange:e=>{f.current.freestyle=!0,s(e)},onSave:m,isSaving:c,fieldId:`project-freestyle-pre-prompt`,i18nRoot:`freestylePrePrompt`})]}):(0,$.jsx)(LJ,{})}function ZJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),[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(`${G()}/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(`${G()}/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).ok)throw Error(`Failed to save`);K.success(n)}catch(t){K.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)){K.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)(Xq,{children:[(0,$.jsxs)(Zq,{children:[(0,$.jsx)(Qq,{children:e(`budget.title`)}),(0,$.jsx)($q,{children:e(`budget.description`)})]}),(0,$.jsx)(eJ,{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)(gF,{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)(gF,{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)(LJ,{})}function QJ(){let{t:e}=U(`settings`),{activeProjectId:t}=ce(),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(`${G()}/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)(RJ,{}),(0,$.jsx)(XJ,{}),(0,$.jsx)(pJ,{}),(0,$.jsx)(FJ,{}),(0,$.jsx)(sJ,{}),(0,$.jsx)(zJ,{}),(0,$.jsx)(JJ,{}),(0,$.jsx)(ZJ,{}),(0,$.jsx)(uJ,{mode:`project`})]})}var $J=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{},eY=e=>e===null||typeof e==`string`&&Number.isFinite(Date.parse(e)),tY=e=>e===null||typeof e==`string`;function nY(e){let t=$J(e);if(t.scope!==`machine`||typeof t.instanceId!=`string`||!t.instanceId||!Number.isSafeInteger(t.revision)||t.revision<0||!Array.isArray(t.providers)||t.providers.length!==2)return!1;let n=new Set;for(let e of t.providers){let t=$J(e);if(![`claude`,`codex`].includes(t.providerId)||n.has(t.providerId)||(n.add(t.providerId),typeof t.generation!=`string`||!(t.installed===null||typeof t.installed==`boolean`)||!tY(t.plan)||![`available`,`signed-out`,`unsupported-auth`,`unsupported-cli`,`unsupported-platform`,`unavailable`].includes(t.availability)||![`idle`,`refreshing`,`error`].includes(t.refreshState)||![`unknown`,`fresh`,`stale`].includes(t.freshness)||!(t.source===null||t.source===`oauth`||t.source===`app-server`)||!eY(t.observedAt)||!eY(t.attemptedAt)||!eY(t.retryAt)||!Array.isArray(t.windows)||t.windows.length>64))return!1;if(t.issue!==null){let e=$J(t.issue);if(typeof e.code!=`string`||typeof e.retryable!=`boolean`)return!1}if(t.spend!=null){let e=$J(t.spend),n=e=>e===null||typeof e==`number`&&Number.isFinite(e)&&e>=0;if(t.providerId!==`claude`||t.plan!==`enterprise`||e.kind!==`enterprise-on-demand`||!n(e.usedAmount)||!n(e.limitAmount)||!n(e.usedPercent)||e.usedAmount===null&&e.limitAmount===null||!eY(e.resetsAt)||typeof e.currency!=`string`||!/^[A-Z]{3}$/.test(e.currency)||![`limited`,`unlimited`,`unknown`].includes(e.limitStatus)||e.limitStatus===`limited`!=(e.limitAmount!==null)||e.limitStatus!==`limited`&&e.usedPercent!==null||t.windows.some(e=>{let t=$J(e);return t.usedPercent!==null||t.resetsAt!==null}))return!1}for(let e of t.windows){let t=$J(e);if(typeof t.id!=`string`||typeof t.label!=`string`||!tY(t.model)||![`account`,`model`].includes(t.scope)||!(t.usedPercent===null||typeof t.usedPercent==`number`&&Number.isFinite(t.usedPercent)&&t.usedPercent>=0&&t.usedPercent<=100)||!(t.durationMinutes===null||typeof t.durationMinutes==`number`&&Number.isFinite(t.durationMinutes)&&t.durationMinutes>0)||!eY(t.resetsAt))return!1}}return!0}function rY(e=(...e)=>fetch(...e)){let t={snapshot:null,error:!1,busy:!1},n=new Set,r=new Set,i,a,o=0,s=0,c=0,l=e=>{t=e,n.forEach(e=>e())},u=e=>{if(!nY(e))throw Error(`Invalid usage snapshot`);if(r.has(e.instanceId))return;let n=!!t.snapshot&&e.instanceId!==t.snapshot.instanceId;n&&(r.add(t.snapshot.instanceId),o=0),(!t.snapshot||n||e.revision>=t.snapshot.revision)&&l({...t,snapshot:e,error:!1})},d=()=>n.size>0&&document.visibilityState!==`hidden`;function f(e){clearTimeout(i),d()&&(i=setTimeout(()=>{m()},e))}async function p(n,r=!1){if(t.busy||!d())return;l({...t,busy:!0});let i=c,p=new AbortController;a?.abort(),a=p;try{let t=await e(`${F}/api/subscription-usage/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n?{providerId:n}:{},automatic:r}),signal:AbortSignal.any([p.signal,AbortSignal.timeout(3e4)])});if(!t.ok)throw Error(`Usage refresh failed`);let a=await t.json();if(i!==c||p.signal.aborted)return;u(a.snapshot),s=Date.now(),o=Date.now()+12e4,f(a.scheduled?1e3:3e4)}catch{i===c&&!p.signal.aborted&&(l({...t,error:!0}),f(3e4))}finally{i===c&&l({...t,busy:!1})}}async function m(){if(!d()||t.busy)return;let n=c,r=new AbortController;a?.abort(),a=r;try{let i=await e(`${F}/api/subscription-usage`,{signal:AbortSignal.any([r.signal,AbortSignal.timeout(1e4)])});if(!i.ok)throw Error(`Usage read failed`);let a=await i.json();if(n!==c||r.signal.aborted)return;if(u(a),t.snapshot?.providers.some(e=>e.refreshState===`refreshing`)){if(s||=Date.now(),Date.now()-s<3e4){f(1e3);return}l({...t,error:!0}),f(3e4);return}if(s=0,Date.now()>=o){await p(void 0,!0);return}f(3e4)}catch{n===c&&!r.signal.aborted&&(l({...t,error:!0}),f(3e4))}}function h(){c++,a?.abort(),clearTimeout(i),l({...t,busy:!1}),d()&&(o=0,m())}function g(e){return n.add(e),n.size===1&&(document.addEventListener(`visibilitychange`,h),m()),()=>{n.delete(e),n.size||(c++,a?.abort(),clearTimeout(i),document.removeEventListener(`visibilitychange`,h),t={...t,busy:!1})}}return{subscribe:g,getSnapshot:()=>t,refresh:p}}var iY=rY();function aY(){return{...(0,Q.useSyncExternalStore)(iY.subscribe,iY.getSnapshot),refresh:iY.refresh}}function oY(e,t){return new Intl.NumberFormat(t,{style:`percent`,maximumFractionDigits:1}).format(e/100)}function sY({spend:e,stale:t,now:n,compact:r=!1}){let{t:i,i18n:a}=U(`subscriptionUsage`),o=t=>t===null?`—`:new Intl.NumberFormat(a.language,{style:`currency`,currency:e.currency}).format(t),s=e.limitStatus===`limited`?i(`spend.amounts`,{used:o(e.usedAmount),limit:o(e.limitAmount)}):i(`spend.consumed`,{used:o(e.usedAmount)}),c=e.usedPercent,l=e.resetsAt?new Intl.DateTimeFormat(a.language,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e.resetsAt)):null;return(0,$.jsxs)(`div`,{className:X(`space-y-1.5`,r?`text-[10px]`:`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:i(`spend.monthly`)}),c!==null&&(0,$.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:oY(c,a.language)})]}),(0,$.jsx)(`p`,{className:`font-medium tabular-nums text-foreground`,children:s}),c!==null&&(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":i(`spend.progress`),"aria-valuenow":Math.min(100,c),"aria-valuemin":0,"aria-valuemax":100,"aria-valuetext":s,className:X(`overflow-hidden rounded-full bg-muted`,r?`h-1`:`h-1.5`),children:(0,$.jsx)(`div`,{className:X(`h-full rounded-full`,t?`bg-muted-foreground/50`:c>=90?`bg-destructive`:c>=80?`bg-accent-warning`:`bg-accent-primary`),style:{width:`${Math.min(100,c)}%`}})}),e.limitStatus!==`limited`&&(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:i(e.limitStatus===`unlimited`?`spend.unlimited`:`spend.limitUnknown`)}),(0,$.jsx)(`p`,{className:`tabular-nums text-muted-foreground`,children:e.resetsAt&&Date.parse(e.resetsAt)<=n?i(`resetPassed`):l?i(`spend.resets`,{time:l}):i(`resetUnknown`)}),!t&&(c!==null&&c>=100||e.limitAmount===0)&&(0,$.jsx)(`p`,{className:`text-destructive`,children:i(`limitReached`)})]})}function cY(){let[e,t]=(0,Q.useState)(Date.now);return(0,Q.useEffect)(()=>{let e=setInterval(()=>{document.visibilityState!==`hidden`&&t(Date.now())},6e4);return()=>clearInterval(e)},[]),e}function lY(e,t){return e.freshness===`stale`||!!e.observedAt&&t-Date.parse(e.observedAt)>=3e5||e.windows.some(e=>e.resetsAt&&Date.parse(e.resetsAt)<=t)||!!e.spend?.resetsAt&&Date.parse(e.spend.resetsAt)<=t}function uY(e,t){let n=[`session`,`weekly`,`monthly`].includes(e.label)?t(`windows.${e.label}`):t(`windows.window`);return e.model?`${e.model} · ${n}`:n}function dY(e){return e.installed===!1?`cli-missing`:e.issue?.code??(e.availability===`available`?``:e.availability)}function fY({selectedProvider:e,showDataDetails:t=!1}){let{t:n,i18n:r}=U(`subscriptionUsage`),{snapshot:i,busy:a,error:o,refresh:s}=aY(),c=cY(),l=i?.providers.filter(t=>!e||t.providerId===e)??[],u=a||l.some(e=>e.refreshState===`refreshing`),d=l.length>0&&l.every(e=>e.retryAt&&Date.parse(e.retryAt)>c),f=i?.providers.every(e=>e.installed===!1),p=e=>new Intl.DateTimeFormat(r.language,{dateStyle:`medium`,timeStyle:`long`}).format(new Date(e));function m(e){let t=(Date.parse(e)-c)/6e4,n=Math.abs(t)>=1440?`day`:Math.abs(t)>=60?`hour`:`minute`;return new Intl.RelativeTimeFormat(r.language,{numeric:`auto`}).format(Math.round(t/(n===`day`?1440:n===`hour`?60:1)),n)}return(0,$.jsxs)(`section`,{className:`space-y-4`,"aria-label":n(`title`),children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:n(`title`)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`subtitle`)})]}),(0,$.jsx)(Z,{size:`icon`,variant:`ghost`,className:`h-8 w-8 shrink-0`,"aria-label":n(`refresh`),"aria-busy":u,disabled:u||d,onClick:()=>void s(e),children:(0,$.jsx)(Lu,{className:X(`h-4 w-4`,u&&`motion-safe:animate-spin`)})})]}),!i&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(o?`loadFailed`:`loading`)}),f&&(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-3 text-sm text-muted-foreground`,children:n(`empty`)}),l.map(e=>{let r=lY(e,c),i=dY(e);return(0,$.jsxs)(`article`,{className:`space-y-2 border-b border-border pb-4 last:border-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[e.providerId===`claude`?`Claude`:`Codex`,` `,e.plan&&(0,$.jsx)(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] font-normal text-muted-foreground`,children:e.spend?n(`spend.enterprise`):e.plan})]}),e.observedAt&&(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:p(e.observedAt),children:r?n(`stale`):n(`updated`,{time:m(e.observedAt)})})]}),e.spend&&(0,$.jsx)(sY,{spend:e.spend,stale:r,now:c}),e.windows.map(t=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-1 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:uY(t,n)}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:t.usedPercent===null?n(`unknown`):n(`used`,{value:t.usedPercent})})]}),t.usedPercent!==null&&(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":`${e.providerId} ${uY(t,n)}`,"aria-valuenow":t.usedPercent,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:X(`h-full rounded-full`,r?`bg-muted-foreground/50`:t.usedPercent>=90?`bg-destructive`:t.usedPercent>=80?`bg-accent-warning`:`bg-accent-primary`),style:{width:`${t.usedPercent}%`}})}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,title:t.resetsAt?p(t.resetsAt):void 0,children:t.resetsAt?Date.parse(t.resetsAt)<=c?n(`resetPassed`):n(`resets`,{time:m(t.resetsAt)}):n(`resetUnknown`)}),t.usedPercent===100&&!r&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:n(`limitReached`)})]},t.id)),i&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`issues.${i}`,{defaultValue:n(`issues.collection-failed`)})}),e.retryAt&&Date.parse(e.retryAt)>c&&(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:n(`retry`,{time:m(e.retryAt)})}),t&&e.observedAt&&(0,$.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:n(`dataDetails`)}),(0,$.jsx)(`p`,{className:`mt-2`,children:n(`observed`,{time:p(e.observedAt)})}),e.source&&(0,$.jsx)(`p`,{children:n(`source`,{source:e.source})})]})]},e.providerId)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`accountWide`)}),(0,$.jsx)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:u?n(`refreshing`):o?n(`loadFailed`):i?n(`ready`):``}),o&&i&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`loadFailed`)})]})}function pY(){let{t:e}=U(`settings`),t=pM();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:()=>dM({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)(Ln,{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)(iM,{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 mY(){let{t:e}=U(`settings`),t=Na();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){K.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:oa.map(t=>{let r=xa[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)(xn,{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 hY(){let{t:e}=U(`settings`);return Na()?(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)(mY,{})]}):null}function gY(e={}){let t={...e},n=P();return n&&(t[`X-Desktop-Token`]=n),t}var _Y=(0,Q.createContext)(null);function vY(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(j,e)}catch{}}function yY(){if(!(typeof localStorage>`u`))try{localStorage.removeItem(j)}catch{}}function bY({children:e,endpoint:t=`/api/language`}){let[n,r]=(0,Q.useState)(()=>L()),[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:gY()});if(!n.ok)return;let i=await n.json();if(e)return;D(i.language)&&i.language!==L()&&(await V(i.language),vY(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`&&D(localStorage.getItem(`specrails-desktop:ui-language`));await V(e),vY(e),r(e),a(!0);try{let n=await fetch(t,{method:`PATCH`,headers:gY({"Content-Type":`application/json`}),body:JSON.stringify({language:e})});if(!n.ok)throw Error(`server rejected language: ${n.status}`)}catch(e){throw await V(i),o?vY(i):yY(),r(i),e}finally{a(!1)}},[n,t]),c=(0,Q.useMemo)(()=>({languageId:n,language:ne[n],setLanguage:s,isUpdating:i}),[n,s,i]);return(0,$.jsx)(_Y.Provider,{value:c,children:e})}function xY(){return(0,Q.useContext)(_Y)}function SY(){let{t:e}=U(`settings`),t=xY();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){K.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:A.map(e=>{let t=ne[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)(xn,{className:`w-3.5 h-3.5 text-accent-primary shrink-0`,"aria-hidden":`true`})]},e)})})}function CY(){let{t:e}=U(`settings`);return xY()?(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)(SY,{})]}):null}function wY(){if(!Ke)return null;let{t:e}=U(`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){K.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 TY=`h-9 w-full rounded-md border border-input bg-background px-2 text-sm`;function EY({provider:e,onChange:t,onRemove:n}){let{t:r}=U(`agentRuntime`),i=e.kind===`openai-compatible`,a=i?$u:pd;return(0,$.jsxs)(`fieldset`,{className:`rounded-xl border border-border/70 bg-card/60 p-4 shadow-sm transition-colors hover:border-border`,"data-testid":`connection-row-${e.id}`,children:[(0,$.jsxs)(`legend`,{className:`flex items-center gap-2 px-1.5 text-sm font-medium`,children:[(0,$.jsx)(a,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":!0}),_J(e),(0,$.jsx)(`span`,{className:`rounded-full border border-border bg-muted/40 px-2 py-px text-[10px] font-normal uppercase tracking-wide text-muted-foreground`,children:r(i?`providers.localBadge`:`providers.cliBadge`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[r(`providers.id`),(0,$.jsx)(gF,{value:e.id,onChange:n=>t({...e,id:n.target.value})})]}),e.kind===`cli`?(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[r(`providers.command`),(0,$.jsx)(`select`,{className:TY,value:e.cli,onChange:n=>t({...e,cli:n.target.value}),children:hJ.filter(on).map(e=>(0,$.jsx)(`option`,{value:e,children:r(`cliNames.${e}`)},e))})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[r(`providers.baseUrl`),(0,$.jsx)(gF,{type:`url`,value:e.baseUrl,onChange:n=>t({...e,baseUrl:n.target.value})})]}),(0,$.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[r(`providers.apiKeyEnv`),(0,$.jsx)(gF,{value:e.apiKeyEnv??``,onChange:n=>t({...e,apiKeyEnv:n.target.value||void 0})})]})]})]}),(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:n,children:r(`providers.remove`)})]})]})}function DY(e,t=!1){if(t)return`probing`;if(!e)return`untested`;let n=e.reachable??e.installed;return n===void 0?`untested`:n?e.authState===`unauthenticated`?`unauthorized`:`reachable`:`unreachable`}var OY={probing:{dot:`bg-accent-info animate-pulse`,pill:`border-accent-info/30 bg-accent-info/10 text-accent-info`},reachable:{dot:`bg-accent-success`,pill:`border-accent-success/30 bg-accent-success/10 text-accent-success`},unauthorized:{dot:`bg-accent-warning`,pill:`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`},unreachable:{dot:`bg-destructive`,pill:`border-destructive/30 bg-destructive/10 text-destructive`},untested:{dot:`bg-muted-foreground/50`,pill:`border-border bg-muted/40 text-muted-foreground`}};function kY({state:e,latencyMs:t,className:n}){let{t:r}=U(`agentRuntime`),i=OY[e];return(0,$.jsxs)(`span`,{"data-testid":`connection-status-pill`,"data-state":e,role:`status`,className:X(`inline-flex h-6 items-center gap-1.5 rounded-full border px-2.5 text-[11px] font-medium transition-colors`,i.pill,n),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:X(`h-1.5 w-1.5 rounded-full`,i.dot)}),r(`providers.status.${e}`),e===`reachable`&&typeof t==`number`&&(0,$.jsxs)(`span`,{className:`text-[10px] font-normal opacity-70 tabular-nums`,children:[`· `,t,` ms`]})]})}function AY({label:e,items:t,trigger:n,triggerClassName:r,align:i=`right`}){let[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useId)();return(0,Q.useEffect)(()=>{if(!a)return;function e(e){s.current&&!s.current.contains(e.target)&&o(!1)}function t(e){if(e.key===`Escape`){o(!1);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(s.current?.querySelectorAll(`[role="menuitem"]`)??[]);if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length]?.focus()}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),(0,$.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":n?void 0:e,title:n?void 0:e,"aria-haspopup":`menu`,"aria-expanded":a,"aria-controls":a?c:void 0,onClick:()=>o(e=>!e),className:X(`inline-flex h-7 items-center justify-center gap-1.5 rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,n?`px-2 text-xs`:`w-7`,a&&`bg-accent text-foreground`,r),children:n??(0,$.jsx)(Gc,{className:`h-4 w-4`,"aria-hidden":!0})}),a&&(0,$.jsx)(`div`,{id:c,role:`menu`,"aria-label":e,className:X(`absolute top-full z-30 mt-1 min-w-40 overflow-hidden rounded-lg border border-border bg-card p-1 shadow-lg`,i===`right`?`right-0`:`left-0`),children:t.map(e=>(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{o(!1),e.onSelect()},className:X(`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none`,e.destructive?`text-destructive`:`text-foreground`),children:[e.icon,e.label]},e.id))})]})}function jY({provider:e,status:t,onRemove:n}){let{t:r}=U(`agentRuntime`),i=!!t;return(0,$.jsxs)(`li`,{"data-testid":`connection-row-${e.id}`,"data-kind":`cli`,className:X(`flex min-h-11 items-center gap-3 px-3 py-1.5 transition-colors`,i?`hover:bg-muted/30`:`opacity-55`),children:[(0,$.jsx)(`span`,{className:X(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,i?`border-accent-info/30 bg-accent-info/10 text-accent-info`:`border-border bg-muted/40 text-muted-foreground`),children:(0,$.jsx)(pd,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:r(`cliNames.${e.cli}`)}),t?.version&&(0,$.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:[`v`,t.version]}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground/60`,children:e.id})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kY,{state:DY(t)}),(0,$.jsx)(`span`,{className:X(`hidden text-[11px] sm:inline`,t?.authState===`authenticated`?`text-muted-foreground`:`text-accent-warning`),children:r(`providers.auth.${t.authState}`)})]}):(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`providers.notDetected`)}),(0,$.jsx)(AY,{label:r(`providers.overflow`),items:[{id:`remove`,label:r(`providers.remove`),icon:(0,$.jsx)(Rn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),destructive:!0,onSelect:n}]})]})]})}function MY(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.reachable==`boolean`&&typeof t.authState==`string`}function NY({baseUrl:e,apiKeyEnv:t,disabled:n,onStart:r,onResult:i,onError:a}){let{t:o}=U(`agentRuntime`),[s,c]=(0,Q.useState)(!1);async function l(){c(!0),r?.();try{let n=await fetch(`/api/runtime-providers/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({baseUrl:e,...t?{apiKeyEnv:t}:{}})}),r=await n.json().catch(()=>null);if(!n.ok||!MY(r))throw Error(r?.message??o(`providers.testFailed`));i({...r,models:Array.isArray(r.models)?r.models:[]})}catch(e){a(e.message||o(`providers.testFailed`))}finally{c(!1)}}return(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,size:`sm`,disabled:n||s||!e.trim(),onClick:()=>void l(),className:`gap-1.5`,children:[s?(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Tu,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(s?`providers.testing`:`providers.test`)]})}function PY(e){return(e.agentLoop??`compact`)===`compact`&&e.supportsReasoningEffort===!0&&(e.contextWindowTokens??0)>=32768}var FY=`__custom__`,IY=`h-9 w-full rounded-md border border-input bg-background px-2 text-sm`,LY=`space-y-1 text-xs text-muted-foreground`;function RY(e){return e===void 0?``:String(e)}function zY(e){if(e.trim()===``)return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:NaN}function BY({provider:e,status:t,persisted:n,onChange:r,onStatus:i,onValidity:a,onRemove:o}){let{t:s}=U(`agentRuntime`),c=(0,Q.useId)(),[l,u]=(0,Q.useState)(!n),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)({input:RY(e.rates?.inputPer1M),output:RY(e.rates?.outputPer1M)}),[_,v]=(0,Q.useState)(!1),y=t?.models??[],b=!e.defaultModel||y.includes(e.defaultModel),x=_||!b,S=zY(h.input),C=zY(h.output),w=Number.isNaN(S)||Number.isNaN(C)||S===null!=(C===null);(0,Q.useEffect)(()=>{a(!w)},[w,a]);function T(t,n){let i={...h,[t]:n};g(i);let a=zY(i.input),o=zY(i.output);a===null&&o===null?r({...e,rates:void 0}):a!==null&&o!==null&&!Number.isNaN(a)&&!Number.isNaN(o)&&r({...e,rates:{inputPer1M:a,outputPer1M:o}})}function E(t){f(!1),m(``),i({reachable:t.reachable,authState:t.authState,models:t.models,latencyMs:t.latencyMs,error:t.error,apiKeyEnvMissing:t.apiKeyEnvMissing}),t.models.length&&Gw(e.id,t.models)}let D=DY(t,d);return(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`local-connection-${e.id}`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(kY,{state:D,latencyMs:t?.latencyMs}),t?.error&&D!==`reachable`&&(0,$.jsx)(`span`,{className:`truncate text-[11px] text-destructive/90`,title:t.error,children:t.error}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(NY,{baseUrl:e.baseUrl,apiKeyEnv:e.apiKeyEnv,onStart:()=>{f(!0),m(``)},onResult:E,onError:e=>{f(!1),m(e)}}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:o,children:s(`providers.remove`)})]})]}),p&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:p}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:LY,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`label`,{htmlFor:`${c}-id`,children:s(`providers.id`)}),n&&!l&&(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent-primary hover:underline`,onClick:()=>u(!0),children:[(0,$.jsx)(jn,{className:`h-3 w-3`,"aria-hidden":!0}),s(`providers.rename`)]})]}),(0,$.jsx)(gF,{id:`${c}-id`,value:e.id,readOnly:!l,"aria-readonly":!l,title:l?void 0:s(`providers.idLocked`),className:X(!l&&`text-muted-foreground`),onChange:t=>r({...e,id:t.target.value})}),l&&n&&(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:s(`providers.renameHint`)})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-label`,children:[s(`providers.label`),(0,$.jsx)(gF,{id:`${c}-label`,value:e.label??``,placeholder:s(`providers.labelPlaceholder`),onChange:t=>r({...e,label:t.target.value||void 0})})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-url`,children:[s(`providers.baseUrl`),(0,$.jsx)(gF,{id:`${c}-url`,type:`url`,value:e.baseUrl,onChange:t=>r({...e,baseUrl:t.target.value})})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-env`,children:[s(`providers.apiKeyEnv`),(0,$.jsx)(gF,{id:`${c}-env`,value:e.apiKeyEnv??``,onChange:t=>r({...e,apiKeyEnv:t.target.value||void 0})}),t?.apiKeyEnvMissing&&e.apiKeyEnv&&(0,$.jsxs)(`span`,{role:`note`,className:`flex items-center gap-1 text-[11px] text-accent-warning`,children:[(0,$.jsx)(zn,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),s(`providers.apiKeyEnvMissing`,{name:e.apiKeyEnv})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`providers.discoveredModels`)}),y.length===0?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:s(`providers.noModels`)}):(0,$.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":s(`providers.discoveredModels`),children:y.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>{v(!1),r({...e,defaultModel:t})},className:X(`rounded-full border px-2.5 py-0.5 font-mono text-[11px] transition-colors`,e.defaultModel===t?`border-accent-primary/50 bg-accent-primary/10 text-foreground`:`border-border bg-muted/30 text-muted-foreground hover:text-foreground`),"aria-pressed":e.defaultModel===t,children:t})},t))}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-default`,children:[s(`providers.defaultModel`),(0,$.jsxs)(`select`,{id:`${c}-default`,className:IY,value:x?FY:e.defaultModel??``,onChange:t=>{if(t.target.value===FY){v(!0);return}v(!1),r({...e,defaultModel:t.target.value||void 0})},children:[(0,$.jsx)(`option`,{value:``,children:s(`providers.defaultModelNone`)}),y.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e)),(0,$.jsx)(`option`,{value:FY,children:s(`providers.customModel`)})]})]}),x&&(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-custom`,children:[s(`providers.customModel`),(0,$.jsx)(gF,{id:`${c}-custom`,value:e.defaultModel??``,placeholder:s(`providers.defaultModelPlaceholder`),onChange:t=>r({...e,defaultModel:t.target.value||void 0})})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s(`providers.rates`),` `,(0,$.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`· `,s(`providers.ratesHint`)]})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-in`,children:[s(`providers.inputRate`),(0,$.jsx)(gF,{id:`${c}-in`,type:`number`,min:`0`,step:`0.01`,inputMode:`decimal`,value:h.input,onChange:e=>T(`input`,e.target.value),"aria-invalid":w})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-out`,children:[s(`providers.outputRate`),(0,$.jsx)(gF,{id:`${c}-out`,type:`number`,min:`0`,step:`0.01`,inputMode:`decimal`,value:h.output,onChange:e=>T(`output`,e.target.value),"aria-invalid":w})]})]}),w&&(0,$.jsx)(`p`,{role:`alert`,className:`text-[11px] text-destructive`,children:s(`providers.ratesInvalid`)})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-xs`,htmlFor:`${c}-effort`,children:[(0,$.jsx)(`input`,{id:`${c}-effort`,type:`checkbox`,role:`switch`,"aria-checked":!!e.supportsReasoningEffort,className:`mt-0.5 accent-accent-primary`,checked:!!e.supportsReasoningEffort,onChange:t=>r({...e,supportsReasoningEffort:t.target.checked||void 0})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-foreground`,children:s(`providers.reasoningEffort`)}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`providers.reasoningEffortHint`)}),!e.supportsReasoningEffort&&(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground/70`,children:s(`providers.reasoningEffortRailHint`)})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 bg-background/40 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`providers.presetTitle`)}),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,size:`sm`,disabled:PY(e),title:s(`providers.presetSmallModelHint`),onClick:()=>r({...e,agentLoop:void 0,supportsReasoningEffort:!0,contextWindowTokens:e.contextWindowTokens??32768}),children:[(0,$.jsx)(Ln,{className:`mr-1 h-3.5 w-3.5`,"aria-hidden":!0}),PY(e)?s(`providers.presetSmallModelApplied`):s(`providers.presetSmallModel`)]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:s(`providers.presetSmallModelHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 bg-background/40 p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s(`providers.agentLoop`),` `,(0,$.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`· `,s(`providers.agentLoopHint`)]})]}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":s(`providers.agentLoop`),className:`grid grid-cols-2 gap-1 rounded-md bg-muted/40 p-1`,children:[`compact`,`free`].map(t=>{let n=(e.agentLoop??`compact`)===t;return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,className:X(`rounded px-2 py-1.5 text-xs transition-colors`,n?`bg-accent-primary/15 text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),onClick:()=>r({...e,agentLoop:t===`compact`?void 0:t}),children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:s(`providers.agentLoop_${t}`)}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`providers.agentLoop_${t}Hint`)})]},t)})}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-ctx`,children:[s(`providers.contextWindow`),(0,$.jsx)(gF,{id:`${c}-ctx`,type:`number`,min:4096,step:1024,inputMode:`numeric`,placeholder:`32768`,value:e.contextWindowTokens??``,"aria-invalid":e.contextWindowTokens!==void 0&&e.contextWindowTokens<4096,onChange:t=>{let n=Number.parseInt(t.target.value,10);r({...e,contextWindowTokens:Number.isFinite(n)&&t.target.value!==``?n:void 0})}}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`providers.contextWindowHint`)})]}),(0,$.jsxs)(`label`,{className:LY,htmlFor:`${c}-out`,children:[s(`providers.maxOutput`),(0,$.jsx)(gF,{id:`${c}-out`,type:`number`,min:1024,step:1024,inputMode:`numeric`,placeholder:`8192`,value:e.maxOutputTokens??``,"aria-invalid":e.maxOutputTokens!==void 0&&e.maxOutputTokens<1024,onChange:t=>{let n=Number.parseInt(t.target.value,10);r({...e,maxOutputTokens:Number.isFinite(n)&&t.target.value!==``?n:void 0})}}),(0,$.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:s(`providers.maxOutputHint`)})]})]})]})}function VY(e){let t=e??32768;return t>=1024&&t%1024==0?`${t/1024}k`:t.toLocaleString()}function HY({provider:e,status:t,persisted:n,invalid:r=!1,onChange:i,onStatus:a,onValidity:o,onRemove:s}){let{t:c}=U(`agentRuntime`),[l,u]=(0,Q.useState)(!n),d=l||r,f=t?.models?.length??0,p=e.agentLoop??`compact`,m=_J(e),h=`local-engine-editor-${e.id||`new`}`;return(0,$.jsxs)(`div`,{"data-testid":`connection-row-${e.id}`,"data-kind":`local`,"data-expanded":d,className:X(`rounded-xl border bg-card/60 shadow-sm transition-colors`,d?`border-accent-primary/30`:`border-border/70 hover:border-border`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,$.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`,children:(0,$.jsx)($u,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:m}),e.label?.trim()&&(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground/60`,children:e.id}),(0,$.jsx)(kY,{state:DY(t),latencyMs:t?.latencyMs})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`truncate font-mono`,children:e.baseUrl||`—`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/40`,children:`·`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:c(`providers.models`,{count:f})}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/40`,children:`·`}),(0,$.jsx)(`span`,{className:X(`rounded-full border px-1.5 py-px text-[10px] font-medium`,p===`compact`?`border-accent-secondary/30 bg-accent-secondary/10 text-accent-secondary`:`border-border bg-muted/40 text-muted-foreground`),"data-testid":`agent-loop-chip`,children:c(`providers.agentLoop_${p}`)}),(0,$.jsxs)(`span`,{className:`tabular-nums`,title:c(`providers.contextWindow`),children:[VY(e.contextWindowTokens),` ctx`]})]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-expanded":d,"aria-controls":h,"aria-label":c(d?`providers.collapse`:`providers.expand`),title:c(d?`providers.collapse`:`providers.expand`),disabled:r,onClick:()=>u(!d),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40`,children:(0,$.jsx)(rc,{className:X(`h-4 w-4 transition-transform duration-200`,d&&`rotate-180`),"aria-hidden":!0})})]}),d&&(0,$.jsx)(`div`,{id:h,className:`border-t border-border/60 px-4 pb-4 pt-3`,children:(0,$.jsx)(BY,{provider:e,status:t,persisted:n,onChange:i,onStatus:a,onValidity:o,onRemove:s})})]})}var UY=1;function WY(e,t){return e.map(e=>({key:UY++,provider:e,persisted:t}))}function GY(){let{t:e}=U(`agentRuntime`),t=!Ze(),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)({}),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(()=>new Set),m=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{m.current=!0;let t=!1;return fetch(`/api/runtime-providers`).then(async n=>{let i=await n.json();if(!n.ok||!vJ(i))throw Error(i?.message??e(`loadFailed`));t||(r(WY(i.providers,!0)),a(i.providers),s(i.status??{}))}).catch(e=>{t||l(e.message)}),()=>{t=!0,m.current=!1}},[e]);let h=(0,Q.useMemo)(()=>n?.map(e=>e.provider)??null,[n]),g=h!==null&&i!==null&&JSON.stringify(h)!==JSON.stringify(i),_=f.size>0,v=(0,Q.useCallback)((e,t)=>{r(n=>n?.map(n=>n.key===e?{...n,provider:t}:n)??n)},[]),y=(0,Q.useCallback)(e=>{r(t=>t?.filter(t=>t.key!==e)??t),p(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),b=(0,Q.useCallback)((e,t)=>{p(n=>{if(n.has(e)===!t)return n;let r=new Set(n);return t?r.delete(e):r.add(e),r})},[]),x=(0,Q.useCallback)((e,t)=>{s(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},[]);function S(){if(!n)return;let e={id:DJ(n.map(e=>e.provider),`local`),kind:`openai-compatible`,baseUrl:`http://127.0.0.1:11434/v1`};r([...n,{key:UY++,provider:e,persisted:!1}])}function C(e){if(!n)return;let t=n.map(e=>e.provider),i=e&&!t.some(t=>t.id===e)?{id:e,kind:`cli`,cli:e}:{id:DJ(t,`cli`),kind:`cli`,cli:e??`claude`};r([...n,{key:UY++,provider:i,persisted:!1}])}async function w(){if(h){d(!0),l(``);try{let t=await fetch(`/api/runtime-providers`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providers:h})}),n=await t.json().catch(()=>null);if(!t.ok||!vJ(n))throw Error(n?.message??e(`saveFailed`));if(!m.current)return;r(WY(n.providers,!0)),a(n.providers),s(n.status??{}),p(new Set),K.success(e(`saved`))}catch(t){let n=t.message||e(`saveFailed`);m.current&&l(n),K.error(e(`saveFailed`),{description:n})}finally{m.current&&d(!1)}}}let T=n?.filter(e=>e.provider.kind===`cli`&&on(e.provider.cli))??[],E=n?.filter(e=>e.provider.kind===`openai-compatible`)??[],D=hJ.filter(on).filter(e=>!T.some(t=>t.provider.cli===e)),O=(0,$.jsxs)(Z,{size:`sm`,className:`gap-1.5`,onClick:S,"data-testid":`add-local-engine`,children:[(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(`providers.addLocalHero`)]});return(0,$.jsxs)(`section`,{className:`space-y-6`,"aria-labelledby":`provider-connections-title`,"data-testid":`provider-connections-card`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-accent-primary/30 bg-accent-primary/10 text-accent-primary shadow-sm`,children:(0,$.jsx)(Fc,{className:`h-5 w-5`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{id:`provider-connections-title`,className:`text-base font-semibold tracking-tight`,children:e(`providers.globalTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:e(`providers.globalHint`)})]})]})}),c&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c}),!n&&!c&&(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:e(`loading`)}),n&&t&&(0,$.jsxs)(`fieldset`,{disabled:u,className:`space-y-3 disabled:opacity-70`,children:[n.length===0&&(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:e(`providers.empty`)}),n.filter(e=>e.provider.kind!==`cli`||on(e.provider.cli)).map(e=>(0,$.jsx)(EY,{provider:e.provider,onChange:t=>v(e.key,t),onRemove:()=>y(e.key)},e.key)),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,className:`gap-1.5`,onClick:()=>C(),children:[(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(`providers.addCli`)]}),(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,className:`gap-1.5`,onClick:S,children:[(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(`providers.addLocal`)]})]})]}),n&&!t&&(0,$.jsxs)(`fieldset`,{disabled:u,className:`space-y-6 disabled:opacity-70`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`cli-group`,children:[(0,$.jsx)(KY,{icon:(0,$.jsx)(pd,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),title:e(`providers.cliGroup`),hint:e(`providers.cliGroupHint`),count:T.length,action:D.length>0&&(0,$.jsx)(AY,{label:e(`providers.addCli`),align:`right`,trigger:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(`providers.addCli`)]}),items:D.map(t=>({id:t,label:e(`cliNames.${t}`),icon:(0,$.jsx)(pd,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":!0}),onSelect:()=>C(t)}))})}),T.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:e(`providers.notDetected`)}):(0,$.jsx)(`ul`,{className:`divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-card/60 shadow-sm`,"aria-label":e(`providers.cliGroup`),children:T.map(e=>(0,$.jsx)(jY,{provider:e.provider,status:o[e.provider.id],onRemove:()=>y(e.key)},e.key))})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`local-group`,children:[(0,$.jsx)(KY,{icon:(0,$.jsx)($u,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),title:e(`providers.localGroup`),hint:e(`providers.localGroupHint`),count:E.length,action:E.length>0?O:void 0}),E.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-xl border border-dashed border-border bg-card/30 px-4 py-8 text-center`,"data-testid":`local-empty`,children:[(0,$.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-xl border border-accent-highlight/30 bg-accent-highlight/10 text-accent-highlight`,children:(0,$.jsx)($u,{className:`h-5 w-5`,"aria-hidden":!0})}),(0,$.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e(`providers.emptyLocalPitch`)}),O]}):(0,$.jsx)(`div`,{className:`space-y-3`,children:E.map(e=>(0,$.jsx)(HY,{provider:e.provider,status:o[e.provider.id],persisted:e.persisted,invalid:f.has(e.key),onChange:t=>v(e.key,t),onStatus:t=>x(e.provider.id,t),onValidity:t=>b(e.key,t),onRemove:()=>y(e.key)},e.key))})]})]}),n&&(0,$.jsxs)(`div`,{className:X(`flex flex-wrap items-center justify-end gap-3 rounded-xl px-3 py-2 transition-all`,g&&`sticky bottom-0 z-20 border border-accent-warning/30 bg-card/95 shadow-lg backdrop-blur`),"data-testid":`provider-save-bar`,"data-sticky":g,children:[g&&(0,$.jsxs)(`span`,{className:`mr-auto inline-flex h-6 items-center gap-1.5 rounded-full border border-accent-warning/30 bg-accent-warning/10 px-2.5 text-[11px] font-medium text-accent-warning`,role:`status`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 rounded-full bg-accent-warning`}),e(`providers.unsaved`)]}),_&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`providers.fixBeforeSave`)}),(0,$.jsxs)(Z,{disabled:u||_||!g,className:`gap-1.5`,onClick:()=>void w(),children:[(0,$.jsx)(dn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e(u?`saving`:`save`)]})]})]})}function KY({icon:e,title:t,hint:n,count:r,action:i}){return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2 px-0.5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[e,t,(0,$.jsx)(`span`,{className:`rounded-full border border-border bg-muted/40 px-1.5 py-px text-[10px] font-medium tabular-nums`,children:r})]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground/80`,children:n})]}),i]})}function qY(){let{t:e}=U(`settings`),{registerHandler:t,unregisterHandler:n}=R(),[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`?(K.success(e(`coreUpdate.toastDone`,{version:String(n.version??``)})),m.current(),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),2500)):r===`error`&&(K.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||K.success(e(`coreUpdate.toastUpToDate`))}catch(t){K.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),K.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)(An,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(En,{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)(An,{className:`h-3.5 w-3.5 animate-spin`}):s===`done`?(0,$.jsx)(sc,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Lu,{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 JY=class extends ht{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){XY(t);let n=new _t;e&&(n.onmessage=e);let r=await Y(`plugin:updater|download`,{onEvent:n,rid:this.rid,...t});this.downloadedBytes=new ht(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){XY(t);let n=new _t;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 YY(e){XY(e);let t=await Y(`plugin:updater|check`,{...e});return t?new JY(t):null}function XY(e){e?.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}var ZY;(function(e){e.Nsis=`nsis`,e.Msi=`msi`,e.Deb=`deb`,e.Rpm=`rpm`,e.AppImage=`appimage`,e.App=`app`})(ZY||={});async function QY(){return Y(`plugin:app|version`)}async function $Y(){await Y(`plugin:process|restart`)}var eX=`specrails-desktop:dismissedDesktopUpdateVersion`,tX=`specrails-desktop-desktop-update`,nX=360*60*1e3;function rX(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function iX(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE===`true`}function aX(){return{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_MOCK_DESKTOP_UPDATE_VERSION||`99.0.0-test`}function oX(e){return new Promise(t=>setTimeout(t,e))}function sX(){return{currentVersion:`1.40.1`,version:aX(),isMock:!0,async downloadAndInstall(e){e({event:`Started`,data:{contentLength:18874368}});for(let t=0;t<12;t+=1)await oX(180),e({event:`Progress`,data:{chunkLength:1572864}});e({event:`Finished`})}}}function cX(e){return e<1024*1024?N.t(`commands:update.units.kb`,{value:Math.max(1,Math.round(e/1024))}):N.t(`commands:update.units.mb`,{value:(e/(1024*1024)).toFixed(1)})}function lX(){try{return localStorage.getItem(eX)}catch{return null}}function uX(e){try{localStorage.setItem(eX,e)}catch{}K.dismiss(tX)}function dX(e){switch(e){case`downloading`:return`var(--color-accent-info)`;case`ready`:return`var(--color-accent-success)`;default:return`var(--color-accent-primary)`}}function fX({state:e}){let t=`h-[15px] w-[15px]`;return e===`installing`?(0,$.jsx)(yc,{className:`${t} u-spin`,"aria-hidden":!0}):e===`ready`?(0,$.jsx)(xn,{className:`${t} u-check`,"aria-hidden":!0}):e===`error`?(0,$.jsx)(zn,{className:t,"aria-hidden":!0}):(0,$.jsx)(hc,{className:t,"aria-hidden":!0})}function pX({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 mX({update:e,onClose:t}){let{t:n}=U(`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){K.success(n(`update.mockReady`),{duration:2500}),K.dismiss(tX),t?.();return}Y(`restart_app`).catch(()=>{$Y()})}let p=s&&s>0?Math.min(100,Math.round(a/s*100)):null,m=dX(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:cX(a)}):n(`update.desc.progress`,{percent:p,downloaded:cX(a),total:cX(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)(fX,{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)(pX,{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:()=>{K.dismiss(tX),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:()=>{uX(e.version),t?.()},children:n(`update.actions.dismiss`)})]})})]})}function hX(e){K.custom(()=>(0,$.jsx)(mX,{update:e}),{id:tX,duration:1/0,dismissible:!1,unstyled:!0,closeButton:!1})}function gX(){(0,Q.useEffect)(()=>{let e=iX();if(!e&&!rX())return;let t=!1,n={current:!1};async function r(){if(!(t||n.current))try{let r=e?sX():await YY();if(t||!r||lX()===r.version)return;n.current=!0,K.custom(()=>(0,$.jsx)(mX,{update:r,onClose:()=>{n.current=!1}}),{id:tX,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(),nX);return()=>{t=!0,clearInterval(i)}},[])}function _X(){let{t:e}=U(`settings`),t=iX(),n=rX()||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(!rX())return;let e=!0;return QY().then(t=>{e&&i(t)}).catch(()=>{}),()=>{e=!1}},[]);let d=(0,Q.useCallback)(async()=>{o(!0),c(null);try{let n=t?sX():await YY();n?(c(`update-available`),u(n.version),hX(n)):(c(`up-to-date`),K.success(e(`appUpdate.toastUpToDate`)))}catch(t){K.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)(An,{className:`h-3.5 w-3.5 animate-spin`}):s===`up-to-date`?(0,$.jsx)(sc,{className:`h-3.5 w-3.5 text-accent-success`}):(0,$.jsx)(Lu,{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 vX=Object.defineProperty,yX=Object.getOwnPropertySymbols,bX=Object.prototype.hasOwnProperty,xX=Object.prototype.propertyIsEnumerable,SX=(e,t,n)=>t in e?vX(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,CX=(e,t)=>{for(var n in t||={})bX.call(t,n)&&SX(e,n,t[n]);if(yX)for(var n of yX(t))xX.call(t,n)&&SX(e,n,t[n]);return e},wX=(e,t)=>{var n={};for(var r in e)bX.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&yX)for(var r of yX(e))t.indexOf(r)<0&&xX.call(e,r)&&(n[r]=e[r]);return n},TX;(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})(TX||={}),(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||={})})(TX||={}),(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||={})})(TX||={});var EX=TX,DX={L:EX.QrCode.Ecc.LOW,M:EX.QrCode.Ecc.MEDIUM,Q:EX.QrCode.Ecc.QUARTILE,H:EX.QrCode.Ecc.HIGH},OX=128,kX=`L`,AX=`#FFFFFF`,jX=`#000000`,MX=!1,NX=1,PX=4,FX=0,IX=.1;function LX(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 RX(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 zX(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*IX),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 BX(e,t){return t==null?e?PX:FX:Math.max(Math.floor(t),0)}function VX({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(...EX.QrSegment.makeSegments(t)),e),[]);return EX.QrCode.encodeSegments(r,DX[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=BX(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:zX(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var HX=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),UX=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=OX,level:a=kX,bgColor:o=AX,fgColor:s=jX,includeMargin:c=MX,minVersion:l=NX,boostLevel:u,marginSize:d,imageSettings:f}=n,p=wX(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=wX(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}=VX({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=RX(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,HX?t.fill(new Path2D(LX(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=CX({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`,CX({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});UX.displayName=`QRCodeCanvas`;var WX=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=OX,level:a=kX,bgColor:o=AX,fgColor:s=jX,includeMargin:c=MX,minVersion:l=NX,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=wX(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=VX({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=RX(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=LX(y,h);return Q.createElement(`svg`,CX({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)});WX.displayName=`QRCodeSVG`;var GX=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 KX(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function qX(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 JX(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 YX(e){let t=new TextEncoder().encode(e),n=await JX(t,new CompressionStream(`deflate-raw`));return n.length<t.length?`D`+KX(n):`R`+KX(t)}async function XX(e){let t=e.trim();if(!t)throw Error(`empty signal token`);let n=qX(t.slice(1));if(t[0]===`D`)return new TextDecoder().decode(await JX(n,new DecompressionStream(`deflate-raw`)));if(t[0]===`R`)return new TextDecoder().decode(n);throw Error(`unknown signal codec tag: ${t[0]}`)}async function ZX(e){return YX(JSON.stringify({k:`offer`,v:2,hub:e.hubInstanceId,name:e.hubName,sdp:e.sdp,sec:e.secret,language:e.language}))}async function QX(e){try{let t=JSON.parse(await XX(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 $X({open:e,onClose:t,onPaired:n}){let{t:r}=U(`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 QX(e);if(!t){K.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`),K.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 ZX({language:L(),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,GX.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){K.error(r(`pairWeb.cameraFailed`,{message:`unsupported`}));return}try{d.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),a(`scanning`)}catch(e){K.error(r(`pairWeb.cameraFailed`,{message:e.message})),a(`offer`)}}return(0,$.jsx)(vr,{open:e,onOpenChange:e=>{e||m()},children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-md`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:r(`pairWeb.title`)}),(0,$.jsx)(cr,{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)(WX,{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),K.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 eZ=typeof navigator<`u`&&/Win/i.test(navigator.platform);function tZ(e){return!e||e.length<16?e??`—`:`${e.slice(0,8)}…${e.slice(-8)}`}function nZ(){let{t:e}=U(`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}=R();(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){K.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(),K.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)(dd,{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)(ge,{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)(ad,{className:`h-3.5 w-3.5 text-accent-success`}),(0,$.jsx)(`span`,{title:t.certFingerprint??``,children:tZ(t.certFingerprint)}),(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:h,disabled:a,children:e(`mobile.reset`)})]})]}),eZ&&(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)(Rn,{className:`h-4 w-4`})})]},t.id))]})]}),(0,$.jsx)($X,{open:s,onClose:()=>c(!1),onPaired:u})]}):(0,$.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`})}var rZ=[`claude`,`codex`],iZ=[`claude`],aZ=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function oZ(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 sZ(){let{t:e}=U(`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(`${F}/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(`${F}/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 K.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 iZ)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!==``&&(!aZ.test(w)||w===`specrails`),E=w!==``&&!T&&`c:${w}`!==_&&!!t?.settings.servers[`c:${w}`],D=w!==``&&!T&&!E&&l.trim()!==``,O=(0,Q.useCallback)(()=>{o(!1),v(null),c(``),u(``),f(``),m([]),g({})},[]),k=(0,Q.useCallback)(()=>{v(null),c(``),u(``),f(``),m([]),g({}),o(!0)},[]),A=(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]),j=(0,Q.useCallback)(async()=>{if(!t||!D)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)&&O()},[t,D,w,l,d,p,h,_,b,O]);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)(ge,{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):k(),"data-testid":`external-mcp-add`,children:[(0,$.jsx)(Pn,{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)(zn,{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||E?`border-destructive/60 focus:outline-destructive`:`border-border`}`}),(T||E)&&(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)(Pn,{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)(Rn,{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:rZ.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:oZ(t),"data-testid":`external-mcp-form-provider-${e}`,children:[t&&(0,$.jsx)(xn,{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:O,children:e(`external.form.cancel`)}),(0,$.jsx)(Z,{size:`sm`,className:`h-7 text-[11px]`,disabled:r||!D,onClick:()=>void j(),"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)(zn,{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:rZ.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:oZ(n),children:[n&&(0,$.jsx)(xn,{className:`h-2.5 w-2.5`,strokeWidth:3}),e]},e)})}),t.stored&&t.source===`custom`&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>A(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)(jn,{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)(Rn,{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 cZ(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 lZ(e){return JSON.stringify({mcpServers:{specrails:{command:e.bridgeCommand}}},null,2)}function uZ(){let{t:e}=U(`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(`${F}/api/mcp-admin/status`);e.ok&&n(await e.json())}catch{}},[]),u=(0,Q.useCallback)(async()=>{try{let e=await fetch(`${F}/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(`${F}/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){K.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(`${F}/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){K.error(e(`tiers.updateFailed`,{message:t.message}))}finally{o(!1)}},[t,e]),p=(0,Q.useCallback)(async()=>{r&&(await cZ(lZ(r))?(c(`config`),window.setTimeout(()=>c(e=>e===`config`?null:e),1500)):K.error(e(`config.copyFailed`)))},[r,e]),m=(0,Q.useCallback)(async()=>{try{let t=await fetch(`${F}/api/mcp-admin/token`);if(!t.ok)throw Error(`HTTP ${t.status}`);let{token:n}=await t.json();await cZ(n)?(c(`token`),window.setTimeout(()=>c(e=>e===`token`?null:e),1500)):K.error(e(`config.copyFailed`))}catch{K.error(e(`config.copyFailed`))}},[e]),h=(0,Q.useCallback)(async()=>{if(window.confirm(e(`token.regenerateConfirm`))){o(!0);try{let t=await fetch(`${F}/api/mcp-admin/regenerate-token`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}`);await l(),K.success(e(`token.regenerated`))}catch(t){K.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)(Du,{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)(xn,{className:`h-3 w-3 text-accent-success`}),` `,e(`config.configCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kc,{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:lZ(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)(xn,{className:`h-3 w-3 text-accent-success`}),` `,e(`token.tokenCopied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kc,{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)(Lu,{className:`h-3 w-3`}),` `,e(`token.regenerate`)]})]})]})]})]}),(0,$.jsx)(sZ,{})]})}var dZ=`specrails-os-notifications`,fZ={enabled:!0,filter:`all`};function pZ(){try{let e=localStorage.getItem(dZ);if(!e)return fZ;let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:fZ.enabled,filter:t.filter===`completed`||t.filter===`failed`?t.filter:fZ.filter}}catch{return fZ}}function mZ(e){localStorage.setItem(dZ,JSON.stringify(e))}function hZ({setActiveProjectId:e,projectsById:t}={}){let n=y(),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{uiMode:a}=eL(),o=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{o.current=a},[a]);let s=(0,Q.useCallback)((e,t)=>{if(o.current===`agent`){e&&i.current&&i.current(e),cj({projectId:e,jobId:t});return}e&&i.current?(i.current(e),setTimeout(()=>{r.current(`/jobs/${t}`)},100)):r.current(`/jobs/${t}`)},[]),c=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{c.current=t},[t]);let l=(0,Q.useRef)(new Map),u=(0,Q.useRef)(new Map),{registerHandler:d,unregisterHandler:f}=R(),p=(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`):[];h(t.jobId,t.projectId??null,t.staleMs??0,e);return}if(t.type===`loop.provider_limit`&&typeof t.runId==`string`){m(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=l.current.get(e.id),r=e.status;n&&u.current.set(e.id,n),t===`running`&&(r===`completed`||r===`failed`)&&_(e,n),l.current.set(e.id,r)}},[]);function m(e,t,n,r,i){let a=pZ();if(!a.enabled||a.filter===`completed`)return;let o=t?c.current?.get(t)??``:``,s=n?n.charAt(0).toUpperCase()+n.slice(1):`AI`,l=r?N.t(`commands:notifications.providerLimitBody`,{provider:s,resetsAt:r}):N.t(`commands:notifications.providerLimitBodyNoReset`,{provider:s}),u=N.t(`commands:notifications.providerLimit`);K.error(u,{id:`provider-limit:${e}`,description:`${o?`[${o}] `:``}${l}${i?` · ${i}`:``}`,duration:6e4}),!(typeof Notification>`u`)&&Notification.permission===`granted`&&(()=>{let t=new Notification(u,{body:o?`[${o}] ${l}`:l,tag:`specrails-provider-limit:${e}`});t.onclick=()=>{window.focus(),t.close()}})()}function h(e,t,n,r=[]){let i=pZ();if(!i.enabled||i.filter===`completed`)return;let a=Math.max(1,Math.round(n/6e4)),o=t?c.current?.get(t)??``:``,l=N.t(`commands:notifications.jobStuckBody`,{count:a});if(t&&r.includes(`stop`)&&K.warning(N.t(`commands:notifications.jobStuck`),{id:`job-stuck:${e}`,description:o?`[${o}] ${l}`:l,duration:2e4,action:{label:N.t(`commands:notifications.jobStuckStop`),onClick:()=>{g(t,e)}}}),typeof Notification>`u`)return;function u(){let n=new Notification(N.t(`commands:notifications.jobStuck`),{body:o?`[${o}] ${l}`:l,tag:`specrails-job-stuck:${e}`});n.onclick=()=>{window.focus(),s(t,e),n.close()}}Notification.permission===`granted`?u():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&u()})}async function g(e,t){try{let n=await fetch(`/api/projects/${e}/jobs/${t}/cancel`,{method:`POST`});if(!n.ok)throw Error(`HTTP ${n.status}`);K.success(N.t(`commands:notifications.jobStuckStopped`),{id:`job-stuck:${t}`})}catch{K.error(N.t(`commands:notifications.jobStuckStopFailed`),{id:`job-stuck:${t}`})}}function _(e,t){if(typeof Notification>`u`||typeof document<`u`&&!document.hidden)return;let n=pZ();if(!n.enabled||n.filter===`completed`&&e.status!==`completed`||n.filter===`failed`&&e.status!==`failed`)return;function r(){let n=e.status===`completed`?N.t(`commands:notifications.jobCompleted`):N.t(`commands:notifications.jobFailed`),r=t?c.current?.get(t)??``:``,i=e.command?e.command.slice(0,80):N.t(`commands:notifications.unknownCommand`),a=r?`[${r}] ${i}`:i,o=new Notification(n,{body:a,tag:`specrails-job:${e.id}:${e.status}`}),l=e.id,u=t;o.onclick=()=>{window.focus(),s(u,l),o.close()}}Notification.permission===`granted`?r():Notification.permission==="default"&&Notification.requestPermission().then(e=>{e===`granted`&&r()})}(0,Q.useLayoutEffect)(()=>(d(`os-notifications`,p),()=>f(`os-notifications`)),[p,d,f])}var gZ=[{value:`job.completed`,labelKey:`webhooks.eventJobCompleted`},{value:`job.failed`,labelKey:`webhooks.eventJobFailed`},{value:`daily_budget_exceeded`,labelKey:`webhooks.eventDailyBudgetExceeded`}];function _Z({project:e,onRemove:t}){let{t:n}=U(`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 vZ=[{id:`appearance`,icon:su,labelKey:`desktop.nav.appearance`},{id:`effects`,icon:Ln,labelKey:`desktop.nav.effects`},{id:`specrailsAgents`,icon:Fc,labelKey:`desktop.nav.specrailsAgents`},{id:`subscriptionUsage`,icon:Fc,labelKey:`desktop.nav.subscriptionUsage`},{id:`code`,icon:_c,labelKey:`desktop.nav.code`},{id:`terminal`,icon:pd,labelKey:`desktop.nav.terminal`},{id:`updates`,icon:Lu,labelKey:`desktop.nav.updates`},{id:`mobile`,icon:dd,labelKey:`desktop.nav.mobile`},{id:`mcp`,icon:zs,labelKey:`desktop.nav.mcp`},{id:`projects`,icon:sl,labelKey:`desktop.nav.projects`},{id:`advanced`,icon:ld,labelKey:`desktop.nav.advanced`},{id:`webhooks`,icon:Nd,labelKey:`desktop.nav.webhooks`},{id:`about`,icon:kl,labelKey:`desktop.nav.about`}];function yZ({open:e,onClose:t,onOpenOnboarding:n,initialSection:r=`appearance`}){let{t:i}=U(`settings`),{projects:a,removeProject:o}=ce(),[s,c]=(0,Q.useState)(`appearance`);(0,Q.useEffect)(()=>{e&&c(r)},[e,r]);let l=e=>X(`space-y-5`,s===e?``:`hidden`),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)([`job.completed`,`job.failed`]),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(()=>pZ().enabled),[P,F]=(0,Q.useState)(()=>pZ().filter);function I(e){N(e),mZ({enabled:e,filter:P}),K.success(i(e?`notifications.enabledToast`:`notifications.disabledToast`))}function ee(e){F(e),mZ({enabled:M,filter:e})}let te=(0,Q.useCallback)(async()=>{try{let e=await fetch(`/api/webhooks`);if(e.ok){let t=await e.json();C(t.webhooks)}}catch{}},[]);(0,Q.useEffect)(()=>{if(!e)return;p(!0);async function t(){try{let e=await fetch(`/api/settings`);if(e.ok){let t=await e.json();d(t),h(t.costAlertThresholdUsd==null?``:String(t.costAlertThresholdUsd))}}catch{}finally{p(!1)}}t(),te()},[e,te]),(0,Q.useEffect)(()=>{e&&fetch(`/api/budget`).then(e=>e.json()).then(e=>{e.desktopDailyBudgetUsd==null?y(``):y(String(e.desktopDailyBudgetUsd))}).catch(()=>{})},[e]);async function L(){_(!0);try{let e=m.trim()===``?null:parseFloat(m);if(e!==null&&(isNaN(e)||e<=0)){K.error(i(`budget.invalidNumber`));return}(await fetch(`/api/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({costAlertThresholdUsd:e})})).ok?K.success(e==null?i(`desktop.costAlertsDisabled`):i(`budget.alertSet`,{amount:e})):K.error(i(`budget.saveThresholdFailed`))}catch{K.error(i(`budget.saveThresholdFailed`))}finally{_(!1)}}async function R(){x(!0);try{let e=v.trim()===``?null:parseFloat(v);if(e!==null&&(isNaN(e)||e<=0)){K.error(i(`budget.invalidNumber`));return}(await fetch(`/api/budget`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({desktopDailyBudgetUsd:e})})).ok?K.success(e==null?i(`desktop.dailyBudgetRemoved`):i(`desktop.dailyBudgetSet`,{amount:e})):K.error(i(`desktop.dailyBudgetSaveFailed`))}catch{K.error(i(`desktop.dailyBudgetSaveFailed`))}finally{x(!1)}}async function z(e){try{await o(e),K.success(i(`desktop.projectRemoved`))}catch(e){K.error(i(`desktop.projectRemoveFailed`),{description:e.message})}}async function B(){if(!w.trim()){K.error(i(`webhooks.urlRequired`));return}if(O.length===0){K.error(i(`webhooks.selectEvent`));return}j(!0);try{let e=await fetch(`/api/webhooks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:w.trim(),secret:E.trim(),events:O})});if(e.ok)K.success(i(`webhooks.added`)),T(``),D(``),k([`job.completed`,`job.failed`]),await te();else{let t=await e.json();K.error(t.error??i(`webhooks.addFailed`))}}catch{K.error(i(`webhooks.addFailed`))}finally{j(!1)}}async function ne(e,t){try{await fetch(`/api/webhooks/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})}),await te()}catch{K.error(i(`webhooks.updateFailed`))}}async function V(e){try{(await fetch(`/api/webhooks/${e}`,{method:`DELETE`})).ok&&(K.success(i(`webhooks.removed`)),await te())}catch{K.error(i(`webhooks.removeFailed`))}}async function re(e){try{(await fetch(`/api/webhooks/${e}/test`,{method:`POST`})).ok&&K.success(i(`webhooks.testPingSent`))}catch{K.error(i(`webhooks.testPingFailed`))}}function ie(e){k(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,$.jsx)(vr,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(gr,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsxs)(dr,{className:`flex items-center gap-2`,children:[(0,$.jsx)(rd,{className:`w-4 h-4`}),i(`desktop.title`)]}),(0,$.jsx)(cr,{children:i(`desktop.description`)})]}),f?(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:vZ.map(e=>{if(e.id===`mcp`&&!Re)return null;let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(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`,s===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:i(e.labelKey)})]},e.id)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,$.jsxs)(`div`,{className:l(`appearance`),children:[(0,$.jsx)(hY,{}),(0,$.jsx)(CY,{})]}),(0,$.jsx)(`div`,{className:l(`effects`),children:(0,$.jsx)(pY,{})}),(0,$.jsxs)(`div`,{className:l(`specrailsAgents`),children:[(0,$.jsx)(GY,{}),(0,$.jsx)(cJ,{})]}),s===`subscriptionUsage`&&(0,$.jsx)(fY,{showDataDetails:!0}),(0,$.jsx)(`div`,{className:l(`code`),children:(0,$.jsx)(wY,{})}),(0,$.jsxs)(`div`,{className:l(`updates`),children:[(0,$.jsx)(_X,{}),(0,$.jsx)(qY,{})]}),(0,$.jsx)(`div`,{className:l(`mobile`),children:(0,$.jsx)(nZ,{})}),Re&&(0,$.jsx)(`div`,{className:l(`mcp`),children:(0,$.jsx)(uZ,{})}),(0,$.jsx)(`div`,{className:l(`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:i(`desktop.registeredProjects`)}),a.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:i(`desktop.noProjects`)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:a.map(e=>(0,$.jsx)(_Z,{project:e,onRemove:z},e.id))})]})}),(0,$.jsxs)(`div`,{className:l(`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:i(`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:i(`desktop.dailyBudgetLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`desktop.dailyBudgetHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(gF,{type:`number`,min:`0`,step:`0.01`,value:v,onChange:e=>y(e.target.value),placeholder:i(`desktop.dailyBudgetPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:b,onClick:()=>void R(),children:i(`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:i(`budget.perJobLabel`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`desktop.perJobHelper`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(gF,{type:`number`,min:`0`,step:`0.01`,value:m,onChange:e=>h(e.target.value),placeholder:i(`budget.perJobPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs shrink-0`,disabled:g,onClick:L,children:i(`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:i(`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:i(`notifications.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:M,onChange:e=>I(e.target.checked),className:`w-3.5 h-3.5`,"data-testid":`notif-toggle`}),(0,$.jsx)(Fs,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs`,children:i(`notifications.enableLabel`)})]}),M&&(0,$.jsxs)(`div`,{className:`space-y-1.5 pl-6`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`notifications.notifyOn`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:[{value:`all`,label:i(`notifications.filterAll`)},{value:`completed`,label:i(`notifications.filterCompleted`)},{value:`failed`,label:i(`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:P===e,onChange:()=>ee(e),className:`w-3 h-3`}),t]},e))})]})]})]})]}),(0,$.jsx)(`div`,{className:l(`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:i(`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)(H,{ns:`settings`,i18nKey:`webhooks.description`,components:{code:(0,$.jsx)(`code`,{className:`font-mono`})}})}),S.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:S.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 ne(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?i(`webhooks.disable`):i(`webhooks.enable`),children:e.enabled?i(`webhooks.statusOn`):i(`webhooks.statusOff`)}),(0,$.jsx)(`button`,{onClick:()=>void re(e.id),className:`text-muted-foreground hover:text-foreground p-0.5`,title:i(`webhooks.sendTestPing`),children:(0,$.jsx)(Hn,{className:`w-3 h-3`})}),(0,$.jsx)(`button`,{onClick:()=>void V(e.id),className:`text-muted-foreground hover:text-destructive p-0.5`,title:i(`common:actions.remove`),children:(0,$.jsx)(Rn,{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:i(`webhooks.addHeading`)}),(0,$.jsx)(gF,{value:w,onChange:e=>T(e.target.value),placeholder:`https://hooks.example.com/...`,className:`h-7 text-xs font-mono`}),(0,$.jsx)(gF,{value:E,onChange:e=>D(e.target.value),placeholder:i(`webhooks.secretPlaceholder`),className:`h-7 text-xs font-mono`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:gZ.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:O.includes(e),onChange:()=>ie(e),className:`w-3 h-3`}),i(t)]},e))}),(0,$.jsxs)(Z,{size:`sm`,variant:`secondary`,className:`h-7 text-xs w-full`,disabled:A||!w.trim(),onClick:()=>void B(),children:[(0,$.jsx)(Pn,{className:`w-3 h-3 mr-1`}),i(`webhooks.addButton`)]})]})]})]})}),(0,$.jsx)(`div`,{className:l(`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:i(`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:i(`desktop.platformTour`)}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`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)(_l,{className:`w-3 h-3 mr-1`}),i(`desktop.replayTour`)]})]})})]})}),(0,$.jsx)(`div`,{className:l(`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:i(`desktop.terminalPanelHeading`)}),(0,$.jsx)(uJ,{mode:`desktop`})]})}),(0,$.jsx)(`div`,{className:l(`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:i(`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:i(`desktop.infoPort`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:u?.port??4200})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i(`desktop.infoProjects`)}),(0,$.jsx)(`span`,{className:`font-mono`,children:a.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:i(`desktop.infoDb`)}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:`~/.specrails/desktop.sqlite`})]})]})]})})]})]})]})})}var bZ=[{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`},...$e?[{keys:`⌘⇧A`,descriptionKey:`shortcuts.items.toggleAgent`,category:`general`}]:[],{keys:lt?`⌘1–5`:`⌘1–4`,descriptionKey:lt?`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 xZ(e){let t=e.target;if(!t)return!1;let n=t.tagName;return!!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable)}function SZ(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`[role="dialog"]`)}function CZ(e){let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`.specrails-xterm-container, .xterm`)}function wZ({onOpenCheatsheet:e,onListNavigate:t,onToggleLeftSidebar:n,onToggleRightSidebar:r,onSwitchProject:i,onSwitchProjectPage:a,onToggleTerminalPanel:o,onToggleAgentChat:s}){let c=y(),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 v=(0,Q.useRef)(a);v.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(SZ(e))return;e.preventDefault(),b.current?.();return}if((e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.code===`KeyA`){if(SZ(e))return;e.preventDefault(),x.current?.();return}if(xZ(e)||CZ(e)||SZ(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(),v.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 TZ(){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 EZ={general:`shortcuts.categories.general`,navigation:`shortcuts.categories.navigation`,actions:`shortcuts.categories.actions`},DZ=[`general`,`navigation`,`actions`];function OZ({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 kZ({shortcut:e}){let{t}=U(`commands`),n=jq(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)(OZ,{children:e},t))})]})}function AZ({open:e,onOpenChange:t}){let{t:n}=U(`commands`),r=DZ.map(e=>({category:e,label:n(EZ[e]),shortcuts:bZ.filter(t=>t.category===e)})).filter(e=>e.shortcuts.length>0);return(0,$.jsx)(vr,{open:e,onOpenChange:t,children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-md`,"data-testid":`shortcuts-cheatsheet`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:n(`shortcuts.title`)}),(0,$.jsx)(cr,{children:(0,$.jsxs)(H,{i18nKey:`shortcuts.subtitle`,ns:`commands`,children:[`Press `,(0,$.jsx)(OZ,{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)(kZ,{shortcut:e},e.keys))})]},e.category))})]})})}var jZ=[`pinned-open`,`pinned-collapsed`,`unpinned`],MZ=`specrails-desktop:sidebar-mode:left`,NZ=`specrails-desktop:sidebar-mode:right`;function PZ(e){return typeof e==`string`&&jZ.includes(e)}function FZ(e){try{let t=window.localStorage.getItem(e);if(PZ(t))return t}catch{}return`unpinned`}function IZ(e,t){try{window.localStorage.setItem(e,t)}catch{}}function LZ(e){switch(e){case`pinned-open`:return`pinned-collapsed`;case`pinned-collapsed`:return`unpinned`;case`unpinned`:return`pinned-open`}}var RZ=(0,Q.createContext)({leftMode:`unpinned`,rightMode:`unpinned`,setLeftMode:()=>{},setRightMode:()=>{},cycleLeftMode:()=>{},cycleRightMode:()=>{}});function zZ({children:e}){let[t,n]=(0,Q.useState)(()=>FZ(MZ)),[r,i]=(0,Q.useState)(()=>FZ(NZ));(0,Q.useEffect)(()=>{IZ(MZ,t)},[t]),(0,Q.useEffect)(()=>{IZ(NZ,r)},[r]);let a=(0,Q.useCallback)(e=>n(e),[]),o=(0,Q.useCallback)(e=>i(e),[]),s=(0,Q.useCallback)(()=>n(e=>LZ(e)),[]),c=(0,Q.useCallback)(()=>i(e=>LZ(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)(RZ.Provider,{value:l,children:e})}function BZ(){return(0,Q.useContext)(RZ)}function VZ(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function HZ(){return VZ()&&/mac/i.test(navigator.platform)}function UZ({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 WZ({projectName:e,hidden:t=!1}){let{t:n}=U(`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)(In,{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 GZ(){return VZ()?HZ()?(0,$.jsx)(qZ,{}):(0,$.jsx)(JZ,{}):null}function KZ({side:e}){let{t}=U(`nav`),{leftMode:n,rightMode:r,cycleLeftMode:i,cycleRightMode:a}=BZ(),o=e===`left`?n:r,s=t(`sidebarPin.${e}.${o===`pinned-open`?`pinnedOpen`:o===`pinned-collapsed`?`pinnedCollapsed`:`unpinned`}`),c=e===`left`?lu:du;return(0,$.jsx)(`button`,{type:`button`,"aria-label":s,title:t(`sidebarPin.withShortcut`,{label:s,shortcut:jq(e===`left`?`⌥⌘B`:`⌘B`)}),onClick:e===`left`?i:a,className:`flex h-6 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline focus-visible:outline-ring`,style:{WebkitAppRegion:`no-drag`},children:(0,$.jsx)(c,{className:`h-4 w-4`})})}function qZ(){let{projects:e,activeProjectId:t}=ce(),{uiMode:n}=eL(),r=e.find(e=>e.id===t)??null;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`,userSelect:`none`,flexShrink:0,borderBottom:`1px solid var(--color-border)`},children:[(0,$.jsx)(`div`,{className:`ml-[80px] flex items-center gap-2`,children:(0,$.jsx)(KZ,{side:`left`})}),(0,$.jsx)(WZ,{projectName:r?.name??null,hidden:n===`agent`}),(0,$.jsx)(`div`,{className:`ml-auto mr-2`,children:(0,$.jsx)(KZ,{side:`right`})})]})}function JZ(){let{t:e}=U(`nav`),{projects:t,activeProjectId:n}=ce(),{uiMode:r}=eL(),i=t.find(e=>e.id===n)??null,a=(0,Q.useMemo)(()=>BL(),[]),[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)(WZ,{projectName:i?.name??null,hidden:r===`agent`}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(KZ,{side:`left`})}),(0,$.jsxs)(`div`,{style:{minWidth:116,display:`flex`,justifyContent:`flex-end`,gap:2,alignItems:`center`,WebkitAppRegion:`no-drag`},children:[(0,$.jsx)(KZ,{side:`right`}),(0,$.jsx)(UZ,{onClick:c,icon:(0,$.jsx)(Zl,{size:14,strokeWidth:1.8}),ariaLabel:e(`titleBar.minimizeWindow`)}),(0,$.jsx)(UZ,{onClick:l,icon:o?(0,$.jsx)(kc,{size:12,strokeWidth:1.8}):(0,$.jsx)(Nn,{size:12,strokeWidth:1.8}),ariaLabel:e(o?`titleBar.restoreWindow`:`titleBar.maximizeWindow`)}),(0,$.jsx)(UZ,{onClick:u,icon:(0,$.jsx)(Vn,{size:15,strokeWidth:1.8}),hoverColor:`var(--color-destructive)`,hoverTextColor:`var(--color-destructive-foreground)`,ariaLabel:e(`titleBar.closeWindow`)})]})]})}var YZ=`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン0123456789ABCDEF`,XZ=16,ZZ=XZ,QZ=XZ*1.1,$Z=180,eQ=340,tQ=.07,nQ=.22,rQ=18,iQ=600,aQ=48,oQ=160,sQ=360;function cQ(){return YZ[Math.floor(Math.random()*61)]??` `}function lQ(e){return{head:-Math.random()*Math.max(e,12),speed:tQ+Math.random()*(nQ-tQ),glyphs:Array.from({length:rQ},()=>cQ()),nextSwapAt:0}}function uQ(){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=`${XZ}px "DM Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace`,i.textBaseline=`top`;let o=Math.ceil(t/ZZ),s=Math.ceil(n/QZ);if(a.length===0)a=Array.from({length:o},()=>lQ(s));else if(a.length<o){let e=Array.from({length:o-a.length},()=>lQ(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>aQ&&s.splice(0,s.length-aQ)),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>iQ;)s.shift();let r=window.innerWidth,d=window.innerHeight;i.clearRect(0,0,r,d);let f=Math.ceil(d/QZ),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-rQ>f+4&&(c.head=-Math.random()*12,c.speed=tQ+Math.random()*(nQ-tQ)),e>c.nextSwapAt&&(c.glyphs[Math.floor(Math.random()*rQ)]=cQ(),c.nextSwapAt=e+oQ+Math.random()*sQ),!p)continue;let l=r*ZZ+ZZ/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>eQ))for(let e=0;e<rQ;e++){let t=c.head-e;if(t<-1||t>f+2)continue;let a=t*QZ,u=0;if(o!==null){let e=l-o.x,t=a-o.y,n=Math.sqrt(e*e+t*t);if(n<=eQ){let e=n<$Z?1:1-(n-$Z)/(eQ-$Z);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>eQ)continue;let o=i<$Z?1:1-(i-$Z)/(eQ-$Z),s=n-e.t,c=o*(s>iQ?0:1-s/iQ);if(c>u&&(u=c),u>=.999)break}if(u<.02)continue;let d=1-e/rQ,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*ZZ,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 dQ=24,fQ=200,pQ=3.5,mQ=10,hQ=`hsl(210, 60%, 96%)`,gQ=`hsl(212, 100%, 62%)`;function _Q(){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>dQ&&a.splice(0,a.length-dQ)}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>fQ;)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=gQ;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/fQ);if(s<=0)continue;let c=t/a.length;i.globalAlpha=s*(.25+.75*c),i.lineWidth=Math.max(.5,pQ*c),i.shadowBlur=mQ*c,i.strokeStyle=c>.6?hQ:gQ,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 vQ={"code-rain":uQ,galaxy:_Q};function yQ(){let e=vQ[Pa().id];return e?(0,$.jsx)(e,{}):null}function bQ({project:e}){let{t}=U(`nav`),n=dG(),{registerHandler:r,unregisterHandler:i}=R(),[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`?K.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`?(K.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`&&K.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)(TN,{delayDuration:400,children:(0,$.jsx)(lG.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 xQ({projectName:e,errorMessage:t,onRetry:n}){let{t:r}=U(`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)(H,{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)(Lu,{className:`w-3.5 h-3.5`}),r(`common:actions.retry`)]})]})}var SQ=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)(xQ,{projectName:this.props.projectName,errorMessage:this.state.error?.message??null,onRetry:this.handleRetry}):this.props.children}};function CQ({onAddProject:e}){let{t}=U(`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)(xd,{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)(H,{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`)}),Fe&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.jiraHint`)}),Re&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.mcpHint`)}),$e&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.agentChatHint`)}),tt&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/80 max-w-sm`,children:t(`welcome.localEnginesHint`)})]}),(0,$.jsxs)(Z,{onClick:e,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(sl,{className:`w-3.5 h-3.5`}),t(`welcome.addFirstProject`)]})]})}var wQ=`https://specrails.dev/companion-app/`,TQ=`specrails-desktop:onboarding-dismissed`;function EQ(){try{return localStorage.getItem(TQ)===`true`}catch{return!1}}function DQ(){try{localStorage.setItem(TQ,`true`)}catch{}}var OQ=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||``),kQ=OQ?`⌘`:`Ctrl`,AQ=OQ?`⌥`:`Alt`,jQ={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 MQ({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 NQ({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 PQ({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 FQ({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)(Be,{className:`w-3.5 h-3.5 text-muted-foreground`})]},t.label))})}function IQ(){let{t:e}=U(`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)(SY,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.language.note`)})]})}function LQ(){let{t:e}=U(`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)(mY,{}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:e(`onboarding.theme.note`)})]})}function RQ({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)(WX,{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)(Dn,{className:`w-3 h-3 shrink-0`,"aria-hidden":`true`})]})]})]})}function zQ(){let{t:e}=U(`setup`);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.companion.intro`,components:{b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,$.jsx)(PQ,{accent:jQ.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)(RQ,{icon:(0,$.jsx)(dd,{className:`w-4 h-4 shrink-0`,"aria-hidden":`true`}),url:wQ,label:e(`onboarding.companion.open`),testId:`companion-web-link`})]}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(ju,{className:`w-4 h-4`}),label:e(`onboarding.companion.pairLabel`),accent:jQ.success,children:e(`onboarding.companion.pairBody`)})]})}function BQ(e){let t={b:(0,$.jsx)(`span`,{className:`text-foreground font-medium`})};return[{navLabel:e(`onboarding.language.nav`),icon:(0,$.jsx)(Nl,{className:`w-6 h-6`}),accent:jQ.info,title:e(`onboarding.language.title`),subtitle:e(`onboarding.language.subtitle`),content:(0,$.jsx)(IQ,{})},{navLabel:e(`onboarding.theme.nav`),icon:(0,$.jsx)(su,{className:`w-6 h-6`}),accent:jQ.highlight,title:e(`onboarding.theme.title`),subtitle:e(`onboarding.theme.subtitle`),content:(0,$.jsx)(LQ,{})},{navLabel:e(`onboarding.welcome.nav`),icon:(0,$.jsx)(Ln,{className:`w-6 h-6`}),accent:jQ.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)(H,{t:e,i18nKey:`onboarding.welcome.intro`,components:t})}),(0,$.jsxs)(PQ,{accent:jQ.primary,label:e(`onboarding.welcome.coreLoopLabel`),children:[(0,$.jsx)(FQ,{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)(H,{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)(NQ,{icon:(0,$.jsx)(zs,{className:`w-4 h-4`}),label:e(`onboarding.welcome.missionLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.welcome.missionBody`,components:t})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Ll,{className:`w-4 h-4`}),label:e(`onboarding.welcome.boardLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.welcome.boardBody`,components:t})})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,$.jsx)(ad,{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)(H,{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`)})]})},...$e?[{navLabel:e(`onboarding.mission.nav`),icon:(0,$.jsx)(zs,{className:`w-6 h-6`}),accent:jQ.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)(H,{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)(NQ,{icon:(0,$.jsx)(_e,{className:`w-4 h-4`}),label:e(`onboarding.mission.missionsLabel`),accent:jQ.primary,children:e(`onboarding.mission.missionsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(ad,{className:`w-4 h-4`}),label:e(`onboarding.mission.levelsLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.mission.levelsBody`,components:{...t,shift:(0,$.jsx)(MQ,{children:`Shift`}),tab:(0,$.jsx)(MQ,{children:`Tab`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(kn,{className:`w-4 h-4`}),label:e(`onboarding.mission.cardsLabel`),accent:jQ.primary,children:e(`onboarding.mission.cardsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Vs,{className:`w-4 h-4`}),label:e(`onboarding.mission.workspaceLabel`),accent:jQ.primary,children:e(`onboarding.mission.workspaceBody`)})]}),(0,$.jsx)(PQ,{accent:jQ.primary,label:e(`onboarding.mission.mcpLabel`),children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.mission.mcpBody`,components:t})})]})}]:[],...ze?[{navLabel:e(`onboarding.builder.nav`),icon:(0,$.jsx)(xl,{className:`w-6 h-6`}),accent:jQ.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)(H,{t:e,i18nKey:`onboarding.builder.intro`,components:t})}),(0,$.jsxs)(PQ,{accent:jQ.highlight,label:e(`onboarding.builder.flowLabel`),children:[(0,$.jsx)(FQ,{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)(NQ,{icon:(0,$.jsx)(jd,{className:`w-4 h-4`}),label:e(`onboarding.builder.cardsLabel`),accent:jQ.highlight,children:e(`onboarding.builder.cardsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Zc,{className:`w-4 h-4`}),label:e(`onboarding.builder.specsLabel`),accent:jQ.highlight,children:e(`onboarding.builder.specsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Vu,{className:`w-4 h-4`}),label:e(`onboarding.builder.milestonesLabel`),accent:jQ.highlight,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.builder.milestonesBody`,components:t})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(dl,{className:`w-4 h-4`}),label:e(`onboarding.builder.progressLabel`),accent:jQ.highlight,children:e(`onboarding.builder.progressBody`)})]})]})}]:[],{navLabel:e(`onboarding.authorSpecs.nav`),icon:(0,$.jsx)(_e,{className:`w-6 h-6`}),accent:jQ.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)(H,{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)(NQ,{icon:(0,$.jsx)(zs,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.agentLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.agentBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(_e,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.exploreLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.exploreBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Hn,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.quickLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.quickBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(ge,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.websiteLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.websiteBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(qu,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.smashLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.smashBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(dn,{className:`w-4 h-4`}),label:e(`onboarding.authorSpecs.draftsLabel`),accent:jQ.info,children:e(`onboarding.authorSpecs.draftsBody`)})]}),Fe&&(0,$.jsx)(PQ,{accent:jQ.info,label:e(`onboarding.jira.label`),children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.jira.body`,components:t})})]})},{navLabel:e(`onboarding.rails.nav`),icon:(0,$.jsx)(Fd,{className:`w-6 h-6`}),accent:jQ.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)(H,{t:e,i18nKey:`onboarding.rails.intro`,components:{...t,play:(0,$.jsx)(`span`,{className:`text-accent-warning font-medium`})}})}),(0,$.jsxs)(PQ,{accent:jQ.success,label:e(`onboarding.rails.jobLabel`),children:[(0,$.jsx)(FQ,{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)(NQ,{icon:(0,$.jsx)(On,{className:`w-4 h-4`}),label:e(`onboarding.rails.reviewLabel`),accent:jQ.success,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.rails.reviewBody`,components:t})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(qc,{className:`w-4 h-4`}),label:e(`onboarding.rails.packetLabel`),accent:jQ.success,children:e(`onboarding.rails.packetBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(_e,{className:`w-4 h-4`}),label:e(`onboarding.rails.steerLabel`),accent:jQ.success,children:e(`onboarding.rails.steerBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(zu,{className:`w-4 h-4`}),label:e(`onboarding.rails.loopsLabel`),accent:jQ.success,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.rails.loopsBody`,components:t})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(zs,{className:`w-4 h-4`}),label:e(`onboarding.rails.profilesLabel`),accent:jQ.success,children:e(`onboarding.rails.profilesBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(sl,{className:`w-4 h-4`}),label:e(`onboarding.rails.isolationLabel`),accent:jQ.success,children:e(`onboarding.rails.isolationBody`)})]})]})},{navLabel:e(`onboarding.providers.nav`),icon:(0,$.jsx)(zs,{className:`w-6 h-6`}),accent:jQ.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)(H,{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] 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`})]}),[[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] 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]})]},e[0]))]}),(0,$.jsx)(PQ,{accent:jQ.secondary,label:e(`onboarding.providers.calloutLabel`),children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.providers.calloutBody`,components:{...t,mono:(0,$.jsx)(`span`,{className:`font-mono`})}})})]})},{navLabel:e(`onboarding.cost.nav`),icon:(0,$.jsx)(Cc,{className:`w-6 h-6`}),accent:jQ.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)(H,{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)(NQ,{icon:(0,$.jsx)(dl,{className:`w-4 h-4`}),label:e(`onboarding.cost.analyticsLabel`),accent:jQ.warning,children:e(`onboarding.cost.analyticsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Fu,{className:`w-4 h-4`}),label:e(`onboarding.cost.perTicketLabel`),accent:jQ.warning,children:e(`onboarding.cost.perTicketBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Vc,{className:`w-4 h-4`}),label:e(`onboarding.cost.honestLabel`),accent:jQ.warning,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.cost.honestBody`,components:{mono:(0,$.jsx)(`span`,{className:`font-mono`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(kd,{className:`w-4 h-4`}),label:e(`onboarding.cost.budgetsLabel`),accent:jQ.warning,children:e(`onboarding.cost.budgetsBody`)})]})]})},{navLabel:e(`onboarding.workspace.nav`),icon:(0,$.jsx)(Vs,{className:`w-6 h-6`}),accent:jQ.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)(NQ,{icon:(0,$.jsx)(xd,{className:`w-4 h-4`}),label:e(`onboarding.workspace.terminalLabel`),accent:jQ.highlight,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.workspace.terminalBody`,values:{mod:kQ},components:{mod:(0,$.jsx)(MQ,{children:kQ}),j:(0,$.jsx)(MQ,{children:`J`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Zc,{className:`w-4 h-4`}),label:e(`onboarding.workspace.codeLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.codeBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(ge,{className:`w-4 h-4`}),label:e(`onboarding.workspace.browserLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.browserBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Du,{className:`w-4 h-4`}),label:e(`onboarding.workspace.integrationsLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.integrationsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(su,{className:`w-4 h-4`}),label:e(`onboarding.workspace.themesLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.themesBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(kn,{className:`w-4 h-4`}),label:e(`onboarding.workspace.chatsLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.chatsBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(je,{className:`w-4 h-4`}),label:e(`onboarding.workspace.compareLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.compareBody`)}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Vu,{className:`w-4 h-4`}),label:e(`onboarding.workspace.desktopLabel`),accent:jQ.highlight,children:e(`onboarding.workspace.desktopBody`)})]})})},{navLabel:e(`onboarding.companion.nav`),icon:(0,$.jsx)(dd,{className:`w-6 h-6`}),accent:jQ.success,title:e(`onboarding.companion.title`),subtitle:e(`onboarding.companion.subtitle`),content:(0,$.jsx)(zQ,{})},{navLabel:e(`onboarding.moveFast.nav`),icon:(0,$.jsx)(Tc,{className:`w-6 h-6`}),accent:jQ.primary,title:e(`onboarding.moveFast.title`),subtitle:e(`onboarding.moveFast.subtitle`),content:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(PQ,{accent:jQ.primary,label:e(`onboarding.moveFast.paletteLabel`),children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.paletteShortcut`,values:{mod:kQ},components:{f:(0,$.jsx)(`span`,{className:`text-foreground`}),m:(0,$.jsx)(`span`,{className:`text-muted-foreground`}),mod:(0,$.jsx)(MQ,{children:kQ}),k:(0,$.jsx)(MQ,{children:`K`})}})}),e(`onboarding.moveFast.paletteBody`)]}),(0,$.jsxs)(`div`,{className:`grid sm:grid-cols-2 gap-x-5 gap-y-3`,children:[(0,$.jsx)(NQ,{icon:(0,$.jsx)(zs,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.agentLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.agentBody`,values:{mod:kQ},components:{mod:(0,$.jsx)(MQ,{children:kQ}),shift:(0,$.jsx)(MQ,{children:`Shift`}),a:(0,$.jsx)(MQ,{children:`A`}),tab:(0,$.jsx)(MQ,{children:`Tab`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(xd,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.terminalLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.terminalBody`,values:{mod:kQ},components:{mod:(0,$.jsx)(MQ,{children:kQ}),j:(0,$.jsx)(MQ,{children:`J`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(jl,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.shortcutsLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.shortcutsBody`,components:{q:(0,$.jsx)(MQ,{children:`?`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(_e,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.chatLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.chatBody`,values:{mod:kQ},components:{mod:(0,$.jsx)(MQ,{children:kQ}),bkey:(0,$.jsx)(MQ,{children:`B`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(sl,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.projectsLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.projectsBody`,values:{alt:AQ,mod:kQ},components:{alt:(0,$.jsx)(MQ,{children:AQ}),mod:(0,$.jsx)(MQ,{children:kQ}),bkey:(0,$.jsx)(MQ,{children:`B`})}})}),(0,$.jsx)(NQ,{icon:(0,$.jsx)(Tc,{className:`w-4 h-4`}),label:e(`onboarding.moveFast.pagesLabel`),accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.pagesBody`,values:{alt:AQ,mod:kQ},components:{alt:(0,$.jsx)(MQ,{children:AQ}),mod:(0,$.jsx)(MQ,{children:kQ}),n:(0,$.jsx)(MQ,{children:`1–9`})}})})]}),(0,$.jsx)(PQ,{accent:jQ.primary,children:(0,$.jsx)(H,{t:e,i18nKey:`onboarding.moveFast.outro`,components:t})})]})}]}function VQ({open:e,onClose:t}){let{t:n}=U(`setup`),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),s=(0,Q.useMemo)(()=>BQ(n),[n]),c=s[r],l=r===0,u=r===s.length-1,d=(0,Q.useCallback)(()=>{a&&DQ(),i(0),t()},[a,t]),f=(0,Q.useCallback)(()=>{DQ(),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)(sr,{open:e,onOpenChange:e=>{e||d()},children:(0,$.jsxs)(fr,{children:[(0,$.jsx)(hr,{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)(ir,{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)(xn,{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)(or,{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)(un,{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)(Be,{className:`w-3.5 h-3.5 ml-1`})]})]})]})]})]})]})]})})}function HQ({conversationId:e,children:t,onOpen:n}){let{t:r}=U(`agent`),i=co(),a=y(),o=p(),{uiMode:s,toggleUiMode:c}=eL(),{active:l}=OL(),u=s===`agent`&&o.pathname===`/`&&(i.conversationIds.includes(e)||i.primaryVisible&&l?.id===e),[d,f]=(0,Q.useState)(null),m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),_=()=>{f(null),g.current?.focus()};return(0,Q.useEffect)(()=>{if(!d)return;let e=e=>{h.current?.contains(e.target)||f(null)},t=e=>{(e.key===`Escape`||e.key===`Tab`)&&(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation()),_())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[d]),(0,$.jsxs)(`div`,{ref:m,onContextMenu:e=>{if(e.preventDefault(),e.stopPropagation(),g.current=m.current?.querySelector(`[tabindex="0"]`)??null,u){f(null);return}f({x:e.clientX,y:e.clientY})},onKeyDown:e=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;if(e.preventDefault(),e.stopPropagation(),u){f(null);return}g.current=e.target;let t=e.currentTarget.getBoundingClientRect();f({x:t.left,y:t.bottom})},children:[t,d&&!u&&(0,BC.createPortal)((0,$.jsx)(`div`,{ref:h,role:`menu`,"aria-label":r(`split.menu`),className:`fixed z-[100] w-48 rounded-lg border border-border bg-popover p-1 shadow-xl`,style:{left:Math.max(8,Math.min(d.x,window.innerWidth-200)),top:Math.max(8,Math.min(d.y,window.innerHeight-52))},children:(0,$.jsxs)(`button`,{autoFocus:!0,type:`button`,role:`menuitem`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm hover:bg-muted focus:bg-muted focus:outline-none`,onClick:t=>{t.stopPropagation(),i.open(e),s!==`agent`&&c(),o.pathname!==`/`&&a(`/`),n?.(),_()},children:[(0,$.jsx)(pu,{className:`h-4 w-4`}),r(`split.open`)]})}),document.body)]})}var UQ=(e,t,n)=>Math.min(n,Math.max(t,e)),WQ=e=>`specrails-desktop:sidebar-width:${e}`;function GQ(e,t){let n=WQ(e),[r,i]=(0,Q.useState)(()=>{try{let e=localStorage.getItem(n),r=e?Number.parseInt(e,10):NaN;if(Number.isFinite(r))return UQ(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=UQ(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=UQ(c.current+r,t.min,t.max):e.key===o?s=UQ(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 KQ({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`)})})}function qQ(){let[e,t]=(0,Q.useState)(new Map),n=(0,Q.useContext)(B);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(`${F}/api/projects/${e}/assemble-retry`,{method:`POST`})},[])}}var JQ=(0,Q.lazy)(()=>c(()=>import(`./ProjectSettingsDialog-B4chTfU8.js`).then(e=>({default:e.ProjectSettingsDialog})),__vite__mapDeps([96,1,7,42,43,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,60,72,54,73,74]))),YQ=`specrails-desktop:agentTreeExpanded`;function XQ(){try{let e=localStorage.getItem(YQ);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 ZQ(e){try{localStorage.setItem(YQ,JSON.stringify([...e]))}catch{}}function QQ(){window.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0}))}var $Q=`__home__`,e$=`__favorites__`;function t$({conversation:e,active:t,expanded:n,streaming:r=!1,unread:i=!1,favorite:a=!1,onSelect:o,onToggleFavorite:s,onDelete:c}){let{t:l}=U(`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,$.jsx)(HQ,{conversationId:e.id,children:(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)(_e,{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:qC(e.updated_at),children:KC(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)(Cl,{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)(Vn,{className:`w-2.5 h-2.5`})})]})]})})}function n$({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}=U(`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)(sl,{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)(rc,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Cn,{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)(rd,{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)(Vn,{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)(t$,{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 r$={"pinned-open":`sidebarPin.left.pinnedOpen`,"pinned-collapsed":`sidebarPin.left.pinnedCollapsed`,unpinned:`sidebarPin.left.unpinned`};function i$({onAddProject:e,onOpenLoops:t,onOpenPlugins:n,onOpenAnalytics:r,onOpenDocs:i,onOpenSettings:a,onOpenCompanion:o}){let{t:s}=U(`nav`),{t:c}=U(`agent`),{projects:l,activeProjectId:u,setActiveProjectId:d,removeProject:f}=ce(),m=qQ(),h=y(),g=p(),_=g.pathname.startsWith(`/loops`),v=g.pathname.startsWith(`/plugins`),b=_||v||g.pathname.startsWith(`/docs`),{leftMode:x,cycleLeftMode:C}=BZ(),{uiMode:w,toggleUiMode:T}=eL(),E=OL(),{backgroundConversationIds:D}=bs(),O=(0,Q.useMemo)(()=>D.size===0?E.streamingConversationIds:new Set([...E.streamingConversationIds,...D]),[E.streamingConversationIds,D]),k=w===`agent`,A=(0,Q.useMemo)(()=>{let e=new Map,t=new Set(l.map(e=>e.id));for(let n of E.conversations){if(E.favoriteConversationIds.has(n.id))continue;let r=n.pinned_project_id&&t.has(n.pinned_project_id)?n.pinned_project_id:$Q,i=e.get(r);i?i.push(n):e.set(r,[n])}return e},[E.conversations,E.favoriteConversationIds,l]),j=(0,Q.useMemo)(()=>E.conversations.filter(e=>E.favoriteConversationIds.has(e.id)),[E.conversations,E.favoriteConversationIds]),M=A.get($Q)??[],[N,P]=(0,Q.useState)(XQ),F=N.has(e$),[I,ee]=(0,Q.useState)(!1),[te,L]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{!k||!u||P(e=>{if(e.has(u))return e;let t=new Set(e);return t.add(u),ZQ(t),t})},[k,u]);let R=e=>{P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),ZQ(n),n})},z=co(),B=e=>{z.focusExisting(e)||(z.showPrimary(),E.selectConversation(e)),b&&h(`/`)},ne=e=>{E.deleteConversation(e).catch(()=>{})},V=e=>{E.toggleFavoriteConversation(e)};function re(e){if(k){d(e),R(e);return}if(e===u){b&&h(`/`);return}d(e)}let[ie,ae]=(0,Q.useState)(!1),H=x===`pinned-open`||x===`unpinned`&&ie,W=GQ(`left-arc`,{side:`left`,defaultWidth:300,min:200,max:460,collapsedWidth:44,expanded:H}),G=x!==`unpinned`,oe=s(r$[x]),se=[...o?[{label:s(`arcSidebar.companion`),icon:dd,action:o}]:[],{label:s(`arcSidebar.analytics`),icon:Zs,action:r},{label:s(`arcSidebar.docs`),icon:Ls,action:i}];async function K(e){try{await f(e.id)}catch{}}return(0,$.jsxs)(`div`,{ref:W.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`&&ae(!0)},onMouseLeave:()=>{x===`unpinned`&&!W.dragging&&ae(!1)},children:[H&&(0,$.jsx)(KQ,{side:`left`,dragging:W.dragging,width:W.width,min:200,max:460,label:s(`arcSidebar.resize`,{defaultValue:`Resize sidebar`}),onPointerDown:W.onGripPointerDown,onKeyDown:W.onGripKeyDown}),!S()&&(0,$.jsxs)(`div`,{className:X(`flex items-center h-12 border-b border-border flex-shrink-0`,H?`px-3 justify-between`:`justify-center`),children:[H&&(0,$.jsx)(`span`,{className:`font-mono text-sm font-bold whitespace-nowrap overflow-hidden text-accent-primary`,children:s(`arcSidebar.desktopTitle`)}),!S()&&(0,$.jsx)(`button`,{type:`button`,onClick:C,className:X(`flex items-center justify-center w-7 h-7 rounded-md transition-colors flex-shrink-0`,G?`text-foreground bg-muted`:`text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted/50`),"aria-label":oe,title:s(`sidebarPin.withShortcut`,{label:oe,shortcut:jq(`⌥⌘B`)}),children:(0,$.jsx)(lu,{className:`w-4 h-4`})})]}),at&&(0,$.jsxs)(`div`,{className:`py-2 px-1.5 space-y-0.5 border-b border-border`,children:[k&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{E.startNewConversation(u),b&&h(`/`)},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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(`newAgent`),title:H?void 0:c(`newAgent`),children:[(0,$.jsx)(Pn,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:c(`newAgent`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:T,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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(k?`switchToKanban`:`switchToAgent`),title:c(k?`switchToKanban`:`switchToAgent`),children:[k?(0,$.jsx)(Ll,{className:`w-4 h-4 flex-shrink-0`}):(0,$.jsx)(zs,{className:`w-4 h-4 flex-shrink-0 text-accent-primary`}),H&&(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:c(k?`switchToKanban`:`switchToAgent`)})]}),k&&(0,$.jsxs)(`button`,{type:`button`,onClick:QQ,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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(`search`),title:H?void 0:c(`search`),children:[(0,$.jsx)(In,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:c(`search`)})]})]}),st&&(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`,H?`px-2`:`px-0 justify-center`,_?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":s(`arcSidebar.loops`),"aria-current":_?`page`:void 0,title:H?void 0:s(`arcSidebar.loops`),children:[(0,$.jsx)(Fd,{className:X(`w-4 h-4 flex-shrink-0`,_&&`text-accent-primary`)}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`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`,H?`px-2`:`px-0 justify-center`,v?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-label":s(`arcSidebar.plugins`),"aria-current":v?`page`:void 0,title:H?void 0:s(`arcSidebar.plugins`),children:[(0,$.jsx)(ku,{className:X(`w-4 h-4 flex-shrink-0`,v&&`text-accent-primary`)}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`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:[k&&j.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:()=>R(e$),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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(`favoriteMissions`),"aria-expanded":F,title:H?void 0:c(`favoriteMissions`),children:[H?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(Cl,{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:F?(0,$.jsx)(rc,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Cn,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(Cl,{className:`w-4 h-4 flex-shrink-0 fill-current text-accent-primary`}),H&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:c(`favoriteMissions`)})]}),F&&H&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:j.map(e=>(0,$.jsx)(t$,{conversation:e,active:e.id===E.active?.id,streaming:O.has(e.id),unread:E.unreadConversationIds.has(e.id),favorite:!0,expanded:H,onSelect:()=>B(e.id),onToggleFavorite:()=>V(e.id),onDelete:()=>ne(e.id)},e.id))})]}),k&&M.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>R($Q),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`,H?`px-2`:`px-0 justify-center`),"aria-label":c(`home`),"aria-expanded":N.has($Q),title:H?void 0:c(`home`),children:[H?(0,$.jsxs)(`span`,{className:`relative flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:[(0,$.jsx)(Tl,{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:N.has($Q)?(0,$.jsx)(rc,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Cn,{className:`w-3.5 h-3.5`})})]}):(0,$.jsx)(Tl,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs truncate flex-1 text-left`,children:c(`home`)})]}),N.has($Q)&&H&&(0,$.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:M.map(e=>(0,$.jsx)(t$,{conversation:e,active:e.id===E.active?.id,streaming:O.has(e.id),unread:E.unreadConversationIds.has(e.id),expanded:H,onSelect:()=>B(e.id),onToggleFavorite:()=>V(e.id),onDelete:()=>ne(e.id)},e.id))})]}),l.map(e=>{let t=A.get(e.id)??[];return(0,$.jsx)(n$,{project:e,isActive:e.id===u&&!b,expanded:H,onSelect:()=>re(e.id),onRemove:()=>K(e),agentMode:k,hasTree:t.length>0,treeOpen:N.has(e.id),onToggleTree:()=>R(e.id),conversations:t,activeConversationId:E.active?.id??null,streamingConversationIds:O,unreadConversationIds:E.unreadConversationIds,onSelectConversation:B,onToggleConversationFavorite:V,onDeleteConversation:ne,assembleStatus:m.statusFor(e.id),onRetryAssemble:()=>{m.retry(e.id)},onOpenProjectSettings:k?()=>{d(e.id),ee(!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`,H?`px-2`:`px-0 justify-center`),"aria-label":s(`projects.addProject`),title:H?void 0:s(`projects.addProject`),children:[(0,$.jsx)(Pn,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:s(`projects.addProject`)})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-border py-2 px-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center rounded-md text-muted-foreground`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":s(`arcSidebar.settings`),title:s(`arcSidebar.settings`),className:X(`flex items-center gap-2 flex-1 min-w-0 h-8 rounded-md hover:text-foreground hover:bg-muted/50 focus-visible:outline focus-visible:outline-ring`,H?`px-2`:`justify-center`),children:[(0,$.jsx)(rd,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-left text-xs`,children:s(`arcSidebar.settings`)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>L(e=>!e),"aria-label":s(te?`common:actions.collapse`:`common:actions.expand`),"aria-expanded":te,"aria-controls":`sidebar-desktop-tools`,title:s(te?`common:actions.collapse`:`common:actions.expand`),className:X(`flex items-center justify-center h-8 shrink-0 rounded-md hover:text-foreground hover:bg-muted/50 focus-visible:outline focus-visible:outline-ring`,H?`w-8`:`w-3.5`),children:(0,$.jsx)(Cn,{className:X(`w-3 h-3 transition-transform`,te&&`rotate-90`)})})]}),te&&(0,$.jsx)(`div`,{id:`sidebar-desktop-tools`,role:`group`,"aria-label":s(`arcSidebar.settings`),className:`flex flex-col gap-0.5 mt-1`,children:se.map(({label:e,icon:t,action:n})=>(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:X(`flex items-center gap-2 h-8 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 focus-visible:outline focus-visible:outline-ring`,H?`pl-5 pr-2`:`w-8 justify-center self-center`),"aria-label":e,title:e,children:[(0,$.jsx)(t,{className:`w-4 h-4 flex-shrink-0`}),H&&(0,$.jsx)(`span`,{className:`text-xs`,children:e})]},e))})]}),I&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(JQ,{open:!0,onClose:()=>ee(!1)})})]})}function a$({open:e,onClose:t,onCommitted:n,projectId:r,milestoneId:i,blueprint:a,provider:o=`claude`}){let{t:s}=U(`builder`),{registerHandler:c,unregisterHandler:l}=R(),[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=Qt(o,`read-only`),P=(0,Q.useMemo)(()=>iI(v??g,{milestoneLabel:M,minSpecs:1,maxSpecs:10,requireScaffold:!1}),[g,v,M]),F=(0,Q.useMemo)(()=>oI(g,v??g,P,{minSpecs:1,maxSpecs:10}),[g,v,P]),I=(0,Q.useMemo)(()=>Ut(m),[m]);(0,Q.useEffect)(()=>{if(!e||u||!N)return;let t=!1;return fetch(`${G()}/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(`${G()}/chat/conversations/${e.conversation.id}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:i})}).catch(()=>{C(!1),K.error(s(`errors.turnFailed`))})}).catch(()=>{t||K.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=Kt(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),K.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 ee=(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(`${G()}/chat/conversations/${t}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n})}).catch(()=>{C(!1),K.error(s(`errors.turnFailed`))}))},[S,s]),te=(0,Q.useCallback)(()=>{let e=E.status===`rejected`?s(`snapshot.rejected.${E.reason}`):s(`readiness.issuesCount`,{count:F.issues.length});ee(s(`prompts.repairSnapshot`,{reason:e}))},[E,F.issues.length,ee,s]),L=(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(`${G()}/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();K.success(s(`milestone.commitToast`,{count:r.insertedIds.length,label:M})),n?.(),t()}else{let t=await e.json().catch(()=>({}));K.error(s(`milestone.commitFailed`),{description:t.detail??t.error})}}).catch(()=>K.error(s(`milestone.commitFailed`))).finally(()=>T(!1)))},[g,v,P.valid,w,i,M,t,n,s]);if(!e)return null;let z=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)(xl,{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)(Vn,{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:[At(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)(PF,{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(),ee(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:()=>ee(b),disabled:S||!b.trim()||!u,children:S?(0,$.jsx)(An,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Zu,{className:`h-3.5 w-3.5`})})]})]}),(0,$.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col lg:w-96`,children:[(0,$.jsx)(II,{blueprint:g,milestoneLabel:M,snapshot:E}),(0,$.jsx)(zI,{readiness:F,snapshot:E,busy:S||w,primaryLabel:w?s(`commit.creating`):s(`milestone.commit`,{count:z,label:M}),onPrimary:L,onRepair:te,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)(xl,{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)(Vn,{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 o$({expanded:e}){let{t}=U(`builder`),n=y(),{activeProjectId:r,projects:i}=ce(),{blueprint:a,progress:o,hasBlueprint:s,refresh:c}=It(r),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(()=>RF()),[_,v]=(0,Q.useState)(null),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),[S,C]=(0,Q.useState)(null);(0,Q.useLayoutEffect)(()=>{if(!l){C(null);return}let e=()=>{let e=b.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));C({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;b.current?.contains(t)||x.current?.contains(t)||u(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let w=(0,Q.useCallback)(async()=>{if(!(!r||d)){f(!0);try{let e=await WF(r,1,{autoAdvance:h}),n=VF(1);if(e.ok){let r=e.launched.length+e.pending.length;e.pending.length>0?K.success(t(h?`milestoneProgress.toast.launched`:`milestoneProgress.toast.launchedCheckpoint`,{milestone:n,count:e.ticketCount,n:r})):K.success(t(`milestoneProgress.toast.launchedAll`,{milestone:n,count:e.ticketCount,n:r})),u(!1)}else e.reason===`chain_active`?K.info(t(`milestoneProgress.toast.chainActive`,{milestone:n})):e.reason===`rail_limit_reached`?K.warning(t(`milestoneProgress.toast.railLimitReached`,{milestone:n})):K.error(t(`done.launchFailed`),{description:e.detail??e.error})}finally{f(!1)}}},[r,h,d,t]),T=(0,Q.useCallback)(async(e,n)=>{if(!(!r||p)){m(!0);try{let i=await JF(r,e,n);i.ok?(g(n),zF(n),K.success(t(n?`milestoneProgress.chain.autoOn`:`milestoneProgress.chain.autoOff`))):K.error(t(`milestoneProgress.chain.autoFailed`),{description:i.detail??i.error})}finally{m(!1)}}},[r,p,t]),E=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await KF(r,e);n.ok?K.success(t(`milestoneProgress.chain.resumed`)):K.error(t(`milestoneProgress.chain.resumeFailed`),{description:n.detail??n.error})}finally{m(!1)}}},[r,p,t]),D=(0,Q.useCallback)(async e=>{if(!(!r||p)){m(!0);try{let n=await qF(r,e);n.ok?K.success(t(`milestoneProgress.chain.cancelledToast`)):K.error(n.detail??n.error)}finally{m(!1)}}},[r,p,t]),O=(0,Q.useCallback)(e=>{u(!1),n(Ve?`/review/${e}`:`/`)},[n]),k=(0,Q.useCallback)(()=>{u(!1),n(`/`)},[n]);if(!r||s===!1||!a)return null;let A=o.find(e=>e.n===1)??null,j=A!==null&&Ot(A),M=o.find(e=>e.state===`planned`&&e.n>1)??null,N=i.find(e=>e.id===r),P=N?.provider??N?.providers?.[0]??`claude`,F=Qt(P,`read-only`),I=j?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,"data-testid":`milestone-launch-hint`,children:t(`milestoneProgress.sequentialHint`)}),(0,$.jsx)(CI,{checked:h,onChange:e=>{g(e),zF(e)},testId:`sidebar-auto-advance`}),(0,$.jsxs)(`button`,{type:`button`,onClick:w,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)(An,{className:`h-3 w-3 animate-spin`}):(0,$.jsx)(Vu,{className:`h-3 w-3`}),t(`sidebar.launchM1`)]})]}):null;return(0,$.jsxs)(`div`,{ref:b,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)(xl,{className:`w-4 h-4 flex-shrink-0`}),e&&(0,$.jsx)(`span`,{className:`text-xs truncate`,children:t(`sidebar.title`)})]}),l&&S&&(0,BC.createPortal)((0,$.jsxs)(`div`,{ref:x,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:S.top,left:S.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)(TI,{progress:e,actions:e.n===1?I:void 0,chainBusy:p,onReview:O,onOpenRail:k,onResume:E,onCancel:D,onSetAutoAdvance:T},e.id||e.n))}),M&&(0,$.jsx)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{F&&(v(M.id),u(!1))},disabled:!F,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(F?`sidebar.generateHint`:`sidebar.generateUnavailable`),"data-testid":`sidebar-generate-next`,children:[(0,$.jsx)(Ln,{className:`h-3 w-3`}),t(`sidebar.generateNext`,{n:M.n})]})})]}),document.body),_&&(0,$.jsx)(a$,{open:!0,onClose:()=>v(null),onCommitted:()=>{c()},projectId:r,milestoneId:_,blueprint:a,provider:P})]})}var s$={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function c$(){let{t:e}=U(`nav`),{rightMode:t,cycleRightMode:n}=BZ(),[r,i]=(0,Q.useState)(!1),a=t===`pinned-open`||t===`unpinned`&&r,o=t!==`unpinned`,s=e(s$[t]),c=[{to:`/`,end:!0,icon:Fl,label:e(`rightSidebar.dashboard`)},{to:`/jobs`,end:!1,icon:qs,label:e(`rightSidebar.jobs`)},{to:`/analytics`,end:!1,icon:Ys,label:e(`rightSidebar.analytics`)},...Ke?[{to:`/code`,end:!1,icon:_c,label:e(`rightSidebar.code`)}]:[],{to:`/settings`,end:!1,icon:rd,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:[!S()&&(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`)}),!S()&&(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:jq(`⌘B`)}),children:(0,$.jsx)(du,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`nav`,{className:`flex-1 py-2 px-1.5 space-y-0.5`,children:[(0,$.jsx)(o$,{expanded:a}),c.map(({to:e,end:t,icon:n,label:r})=>(0,$.jsxs)(g,{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 l$(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 u$({status:e,isLoading:t,error:n,onRefresh:r,onMoreInfo:i}){let{t:a}=U(`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)(sc,{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)(Lu,{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)(zn,{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)(Lu,{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.filter(e=>on(e.key)).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)(Tn,{className:`w-3.5 h-3.5 text-destructive flex-shrink-0`}):n||r?(0,$.jsx)(sc,{className:`w-3.5 h-3.5 text-accent-success flex-shrink-0`}):o?(0,$.jsx)(Tn,{className:`w-3.5 h-3.5 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(Tn,{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)(au,{className:`w-2.5 h-2.5`}),a(`prerequisites.bundledBadge`)]}),(0,$.jsxs)(`span`,{className:X(`text-muted-foreground`,t&&`text-destructive/80`),children:[`— `,l$(e,a)]})]},e.key)})})]})}function d$(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 f$=[`darwin`,`win32`,`linux`];async function p$(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 m$({command:e}){let{t}=U(`setup`),[n,r]=(0,Q.useState)(!1);return(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{await p$(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)(xn,{className:`w-3 h-3`}),t(`common:actions.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kc,{className:`w-3 h-3`}),t(`common:actions.copy`)]})})}function h$({platform:e,primary:t}){let{t:n}=U(`setup`),r=d$(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)(m$,{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)(Dn,{className:`w-3 h-3`})]})},e.url))}),r.note&&(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-accent-highlight`,children:r.note})]})}function g$(){let{t:e}=U(`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(`${F}/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)(xn,{className:`w-3 h-3 text-accent-success`}):(0,$.jsx)(pc,{className:`w-3 h-3`}),e(t===`copied`?`instructions.diagnostics.copied`:t===`error`?`instructions.diagnostics.failed`:`instructions.diagnostics.copy`)]})}function _$({open:e,onClose:t,status:n,onRecheck:r,isRechecking:i}){let{t:a}=U(`setup`),[o,s]=(0,Q.useState)(!1),c=n?.platform??`darwin`,l=f$.filter(e=>e!==c);return n?.missingRequired?.some(e=>e.error===`corrupted-bundle`)??!1?(0,$.jsx)(vr,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-xl`,"data-testid":`install-modal-corrupted-bundle`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:a(`instructions.corrupted.title`)}),(0,$.jsx)(cr,{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)(vr,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(gr,{movableResizable:!0,className:`max-w-xl`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsx)(dr,{children:a(`instructions.title`)}),(0,$.jsx)(cr,{children:a(`instructions.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(h$,{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)(h$,{platform:e,primary:!1},e))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-2`,children:[(0,$.jsx)(g$,{}),(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)(Lu,{className:X(`w-3 h-3`,i&&`animate-spin`)}),a(`instructions.recheck`)]})]})]})]})})}var v$=typeof window<`u`&&`__TAURI_INTERNALS__`in window;function y$({open:e,onClose:t,onOpenBuilder:n}){let r=ze&&!!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)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)({claude:!0}),[y,b]=(0,Q.useState)(!1),{t:x}=U(`setup`),{addProject:S}=ce(),{status:C,isLoading:w,error:T,recheck:E}=TF(),D=(0,Q.useMemo)(()=>{if(!C||C.ok)return null;let e=C.missingRequired.map(e=>e.label);return e.length===0?null:x(`addProject.toolsRequired`,{tools:e.join(`, `),count:e.length})},[C,x]),O=C!==null&&!C.ok&&!T;(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`&&on(n)&&(t[n]=r);v(t)}).catch(()=>{})},[e]);async function k(){let e=o.trim();if(!e){K.error(x(`addProject.errors.pathRequired`));return}g(!0);try{let t=d.map(e=>({path:e.trim()})).filter(e=>e.path),n=p.trim()?p.split(`
|
|
77
77
|
`).map(e=>e.trim()).filter(Boolean):void 0,r=n?await S(e,l.trim()||void 0,void 0,t,n):t.length?await S(e,l.trim()||void 0,void 0,t):await S(e,l.trim()||void 0);if(!r)return;K.success(x(`addProject.toasts.registered`,{name:r.project.name})),A()}catch(e){K.error(x(`addProject.errors.addFailed`),{description:e.message})}finally{g(!1)}}function A(){s(``),u(``),f([]),m(``),a(r?`choose`:`existing`),t()}function j(e){e||A()}let M=!Object.values(_).some(Boolean);return i===`choose`?(0,$.jsx)(vr,{open:e,onOpenChange:j,children:(0,$.jsxs)(gr,{className:`max-w-md`,children:[(0,$.jsxs)(mr,{children:[(0,$.jsxs)(dr,{className:`flex items-center gap-2`,children:[(0,$.jsx)(sl,{className:`w-4 h-4`}),x(`addProject.title`)]}),(0,$.jsx)(cr,{children:x(`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)(al,{className:`h-5 w-5 text-accent-info`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:x(`addProject.chooser.existingTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:x(`addProject.chooser.existingDescription`)})]}),(0,$.jsxs)(`button`,{type:`button`,"data-testid":`chooser-new`,onClick:()=>{A(),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)(Ln,{className:`h-5 w-5 text-accent-highlight`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:x(`addProject.chooser.newTitle`)}),(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:x(`addProject.chooser.newDescription`)})]})]})]})}):(0,$.jsx)(vr,{open:e,onOpenChange:j,children:(0,$.jsxs)(gr,{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)(mr,{children:[(0,$.jsxs)(dr,{className:`flex items-center gap-2`,children:[(0,$.jsx)(sl,{className:`w-4 h-4`}),x(`addProject.title`)]}),(0,$.jsx)(cr,{children:x(`addProject.description`)})]}),M&&(0,$.jsx)(`p`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:x(`addProject.noProviderDetected`)}),(0,$.jsx)(u$,{status:C,isLoading:w,error:T,onMoreInfo:()=>b(!0),onRefresh:E}),(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:[x(`addProject.pathLabel`),` `,(0,$.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(gF,{placeholder:x(`addProject.pathPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&k()},autoFocus:!0,className:`flex-1`}),v$&&(0,$.jsx)(Z,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,title:x(`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([95,0,1])),t=await e({directory:!0,multiple:!1,title:x(`addProject.selectProjectFolder`)});typeof t==`string`&&t&&(s(t),l||u(t.split(`/`).filter(Boolean).pop()??``))}catch{}},children:(0,$.jsx)(sl,{className:`w-4 h-4`})})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:x(`addProject.pathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium`,children:[x(`addProject.nameLabel`),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:x(`addProject.optional`)})]}),(0,$.jsx)(gF,{placeholder:x(`addProject.namePlaceholder`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&k()}}),(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:x(`addProject.nameHint`)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium`,children:[x(`common:repositories.workspacePath`),(0,$.jsx)(`textarea`,{className:`flex min-h-20 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:p,disabled:h,onChange:e=>m(e.target.value),placeholder:o}),(0,$.jsx)(`span`,{className:`block font-normal text-muted-foreground`,children:x(`common:repositories.workspaceHint`)})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2`,disabled:h,children:[(0,$.jsx)(`legend`,{className:`text-xs font-medium`,children:x(`common:repositories.additional`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x(`common:repositories.sharedBacklog`)}),d.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(gF,{"aria-label":x(`common:repositories.folderNumber`,{number:t+2}),value:e,placeholder:x(`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":x(`common:repositories.removeFolder`),onClick:()=>f(e=>e.filter((e,n)=>n!==t)),children:(0,$.jsx)(Vn,{className:`h-4 w-4`})})]},t)),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(v$)try{let{open:e}=await c(async()=>{let{open:e}=await import(`./dist-js-CJ_2XX1Y.js`);return{open:e}},__vite__mapDeps([95,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)(Pn,{className:`mr-1 h-3.5 w-3.5`}),x(`common:repositories.addFolder`)]})]})]}),(0,$.jsxs)(tr,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:A,disabled:h,children:x(`common:actions.cancel`)}),(0,$.jsx)(Z,{size:`sm`,onClick:k,disabled:h||!o.trim()||O||w,title:O?D??void 0:void 0,"data-testid":`add-project-submit`,children:x(h?`addProject.adding`:`addProject.submit`)})]}),(0,$.jsx)(_$,{open:y,onClose:()=>b(!1),status:C,onRecheck:E,isRechecking:w})]})})}var b$=1,x$=.9,S$=.8,C$=.17,w$=.1,T$=.999,E$=.9999,D$=.99,O$=/[\\\/_+.#"@\[\(\{&]/,k$=/[\\\/_+.#"@\[\(\{&]/g,A$=/[\s-]/,j$=/[\s-]/g;function M$(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?b$:D$;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=M$(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=b$:O$.test(e.charAt(l-1))?(d*=S$,p=e.slice(i,l-1).match(k$),p&&i>0&&(d*=T$**+p.length)):A$.test(e.charAt(l-1))?(d*=x$,m=e.slice(i,l-1).match(j$),m&&i>0&&(d*=T$**+m.length)):(d*=C$,i>0&&(d*=T$**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=E$)),(d<w$&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=M$(e,t,n,r,l+1,a+2,o),f*w$>d&&(d=f*w$)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function N$(e){return e.toLowerCase().replace(j$,` `)}function P$(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,M$(e,t,N$(e),N$(t),0,0,{})}var F$=`[cmdk-group=""]`,I$=`[cmdk-group-items=""]`,L$=`[cmdk-group-heading=""]`,R$=`[cmdk-item=""]`,z$=`${R$}:not([aria-disabled="true"])`,B$=`cmdk-item-select`,V$=`data-value`,H$=(e,t,n)=>P$(e,t,n),U$=Q.createContext(void 0),W$=()=>Q.useContext(U$),G$=Q.createContext(void 0),K$=()=>Q.useContext(G$),q$=Q.createContext(void 0),J$=Q.forwardRef((e,t)=>{let n=c1(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=c1(()=>new Set),i=c1(()=>new Map),a=c1(()=>new Map),o=c1(()=>new Set),s=o1(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Xn(),y=Xn(),b=Xn(),x=Q.useRef(null),S=d1();s1(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),s1(()=>{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??H$;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(I$);t?t.appendChild(e.parentElement===t?e:e.closest(`${I$} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${I$} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${F$}[${V$}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(V$);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(F$)?.querySelector(L$))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${R$}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(z$)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(V$))}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(V$))}function P(e){let t=A()?.closest(F$),n;for(;t&&!n;)t=e>0?i1(t,F$):a1(t,F$),n=t?.querySelector(z$);n?C.setState(`value`,n.getAttribute(V$)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},ee=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Q.createElement(Kn.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&&ee(e);break;case`ArrowUp`:ee(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(B$);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:m1},c),p1(e,e=>Q.createElement(G$.Provider,{value:C},Q.createElement(U$.Provider,{value:w},e))))}),Y$=Q.forwardRef((e,t)=>{let n=Xn(),r=Q.useRef(null),i=Q.useContext(q$),a=W$(),o=o1(e),s=o.current?.forceMount??i?.forceMount;s1(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=u1(n,r,[e.value,e.children,r],e.keywords),l=K$(),u=l1(e=>e.value&&e.value===c.current),d=l1(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(B$,f),()=>t.removeEventListener(B$,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(Kn.div,{ref:Jn(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)}),X$=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Xn(),s=Q.useRef(null),c=Q.useRef(null),l=Xn(),u=W$(),d=l1(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));s1(()=>u.group(o),[]),u1(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(Kn.div,{ref:Jn(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),p1(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(q$.Provider,{value:f},e))))}),Z$=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=l1(e=>!e.search);return!n&&!a?null:Q.createElement(Kn.div,{ref:Jn(i,t),...r,"cmdk-separator":``,role:`separator`})}),Q$=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=K$(),o=l1(e=>e.search),s=l1(e=>e.selectedItemId),c=W$();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(Kn.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)}})}),$$=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=l1(e=>e.selectedItemId),c=W$();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(Kn.div,{ref:Jn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},p1(e,e=>Q.createElement(`div`,{ref:Jn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),e1=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(sr,{open:n,onOpenChange:r},Q.createElement(fr,{container:o},Q.createElement(hr,{"cmdk-overlay":``,className:i}),Q.createElement(ir,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement(J$,{ref:t,...s}))))}),t1=Q.forwardRef((e,t)=>l1(e=>e.filtered.count===0)?Q.createElement(Kn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),n1=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(Kn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},p1(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),r1=Object.assign(J$,{List:$$,Item:Y$,Input:Q$,Group:X$,Separator:Z$,Dialog:e1,Empty:t1,Loading:n1});function i1(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function a1(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function o1(e){let t=Q.useRef(e);return s1(()=>{t.current=e}),t}var s1=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function c1(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function l1(e){let t=K$(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function u1(e,t,n,r=[]){let i=Q.useRef(),a=W$();return s1(()=>{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(V$,s),i.current=s}),i}var d1=()=>{let[e,t]=Q.useState(),n=c1(()=>new Map);return s1(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function f1(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function p1({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(f1(t),{ref:t.ref},n(t.props.children)):n(t)}var m1={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function h1(e){return e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase()}function g1(e,t,n=[]){let r=h1(e.trim());return!r||h1(t).includes(r)?!0:n.some(e=>e&&h1(e).includes(r))}function _1(e,t){return WC(t.updated_at)-WC(e.updated_at)}function v1(e,t=8){return[...e].sort(_1).slice(0,Math.max(0,t)).map(e=>({conversation:e,match:`recent`,messageId:null,snippet:null}))}function y1(e,t,n,r=20){let i=h1(t.trim());if(!i)return[];let a=h1(n);return[...e].sort(_1).filter(e=>h1(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 b1(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 x1(e){return e===`agent`?[`missions`,`projects`,`spec`,`jobs`,`navigation`]:[`projects`,`missions`,`spec`,`jobs`,`navigation`]}var S1=[];function C1(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 w1({onOpenSettings:e,onOpenAnalytics:t,onOpenDocs:n}){let{t:r}=U(`commands`),{t:i}=U(`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:S1}),{projects:h,activeProjectId:g,setActiveProjectId:_}=ce(),{leftMode:v,rightMode:b,cycleLeftMode:x,cycleRightMode:S}=BZ(),{uiMode:C}=eL(),{conversations:w,liveByConversation:T,selectConversation:E,open:D}=OL(),O=r(v===`pinned-open`?`palette.sidebar.collapseLeftKeepPinned`:v===`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=y(),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(`${G()}/config`),fetch(`${G()}/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(()=>{xo(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?b1(y1(w,e,N),p.query===e?p.hits:S1):v1(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)},[_]),ee=(0,Q.useCallback)(e=>{o(!1),E(e),C!==`agent`&&D()},[E,D,C]),te=(0,Q.useCallback)(async e=>{o(!1);try{let t=await fetch(`${G()}/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`));K.success(r(`toasts.queued`,{name:e})),A(`/jobs/${n.jobId}`)}catch(e){K.error(e instanceof Error?e.message:r(`errors.spawnFailed`))}},[A,r]),L=(0,Q.useCallback)(e=>{o(!1),A(`/jobs/${e}`)},[A]),R=(0,Q.useCallback)(e=>{o(!1),A(e)},[A]),z=(0,Q.useCallback)(e=>{e&&(o(!1),e())},[]),B=`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`,ne=h.filter(e=>g1(s,e.name,[e.slug])),V=l.filter(e=>g1(s,e.name,[e.slug,e.description??``])),re=d.filter(e=>g1(s,`${e.command} ${e.id}`,[e.status])),ie=[{key:`dashboard`,label:r(`palette.nav.dashboard`),keywords:[`home`],icon:(0,$.jsx)(Fl,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>R(`/`)},...t?[{key:`desktopAnalytics`,label:r(`palette.nav.desktopAnalytics`),keywords:[`cross-project`,`desktop`],icon:(0,$.jsx)($s,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>z(t)}]:[],{key:`projectAnalytics`,label:r(`palette.nav.projectAnalytics`),keywords:[`metrics`],icon:(0,$.jsx)(Ys,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>R(`/analytics`)},{key:`activityFeed`,label:r(`palette.nav.activityFeed`),keywords:[`log`],icon:(0,$.jsx)(Cs,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>R(`/activity`)},{key:`desktopSettings`,label:r(`palette.nav.desktopSettings`),keywords:[`configuration`],icon:(0,$.jsx)(rd,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>e?z(e):R(`/settings`)},{key:`docs`,label:r(`palette.nav.docs`),keywords:[`documentation`],icon:(0,$.jsx)(wn,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>n?z(n):R(`/docs`)},{key:`leftSidebar`,label:O,keywords:[`sidebar`,`panel`,`left`,`pin`,`collapse`,`unpin`,`cycle`],icon:(0,$.jsx)(lu,{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)(du,{className:`w-4 h-4 text-muted-foreground shrink-0`}),onSelect:()=>{S(),o(!1)}}].filter(e=>g1(s,e.label,e.keywords)),ae={missions:P.length>0&&(0,$.jsx)(r1.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)(r1.Item,{value:`mission:${t.id}`,onSelect:()=>ee(t.id),className:X(B,`items-start`),"data-testid":`palette-mission-${t.id}`,children:[(0,$.jsx)(vn,{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:qC(t.updated_at),children:KC(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:C1(e.snippet)})]})]})]})]},t.id)})},`missions`),projects:ne.length>0&&(0,$.jsx)(r1.Group,{heading:r(`palette.groups.projects`),"data-testid":`palette-group-projects`,children:ne.map(e=>(0,$.jsxs)(r1.Item,{value:e.name,keywords:[e.slug],onSelect:()=>I(e.id),className:X(B,e.id===g&&`text-accent-primary`),children:[(0,$.jsx)(sl,{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:V.length>0&&(0,$.jsx)(r1.Group,{heading:r(`palette.groups.spec`),children:V.map(e=>(0,$.jsxs)(r1.Item,{value:e.name,keywords:[e.slug,e.description??``],onSelect:()=>te(e.slug),className:B,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:re.length>0&&(0,$.jsx)(r1.Group,{heading:r(`palette.groups.jobs`),children:re.map(e=>(0,$.jsxs)(r1.Item,{value:`${e.command} ${e.id}`,keywords:[e.status],onSelect:()=>L(e.id),className:B,children:[(0,$.jsx)(qs,{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:ie.length>0&&(0,$.jsx)(r1.Group,{heading:r(`palette.groups.navigation`),children:ie.map(e=>(0,$.jsxs)(r1.Item,{value:e.label,keywords:e.keywords,onSelect:e.onSelect,className:B,children:[e.icon,(0,$.jsx)(`span`,{children:e.label})]},e.key))},`navigation`)};return(0,$.jsxs)(r1.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)(In,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,$.jsx)(r1.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)(r1.List,{className:`max-h-80 overflow-y-auto p-2`,children:[(0,$.jsx)(r1.Empty,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`palette.noResults`)}),x1(C).map(e=>ae[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 T1=`
|
|
78
78
|
|
|
79
79
|
---
|
|
80
80
|
|
|
81
81
|
## Contract Layer
|
|
82
82
|
|
|
83
|
-
`;function E1(e){return`contract-refine:${e}`}async function D1(e,t){try{let n=await fetch(`${F}/api/projects/${e}/tickets/${t}/contract-refine`,{method:`POST`});if(n.ok)K.loading(N.t(`activity:contractRefine.refining`),{id:E1(t)});else{let e=await n.json().catch(()=>({}));K.error(e.error?N.t(`activity:contractRefine.retryRejectedWithError`,{error:e.error}):N.t(`activity:contractRefine.retryRejected`),{id:E1(t)})}}catch(e){K.error(N.t(`activity:contractRefine.retryFailed`,{message:e.message}),{id:E1(t)})}}function O1({children:e}){let{registerHandler:t,unregisterHandler:n}=R(),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=en(a)?{label:N.t(`common:actions.retry`),onClick:()=>void D1(i,n)}:void 0;K.error(N.t(`activity:contractRefine.skipped`),{id:E1(n),description:N.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(T1)&&K.success(N.t(`activity:contractRefine.added`,{title:n.title||`#${n.id}`}),{id:E1(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 k1(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function A1(){let{t:e}=U(`mcp`),t=xY()?.languageId;(0,Q.useEffect)(()=>{k1()&&Y(`set_tray_labels`,{open:e(`tray.open`),exit:e(`tray.exit`)}).catch(()=>{})},[e,t])}var j1=`input, textarea, select, [contenteditable="true"], [contenteditable=""], .monaco-editor, .xterm, [data-native-menu]`;function M1(e){return e instanceof Element&&e.closest(j1)!==null}function N1(e){M1(e.target)||e.preventDefault()}function P1(){(0,Q.useEffect)(()=>(document.addEventListener(`contextmenu`,N1),()=>document.removeEventListener(`contextmenu`,N1)),[])}var F1={jobs:[],activeJobId:null,paused:!1};function I1(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)(F1),[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(F1))}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??F1;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}=R();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(`${G()}/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 L1(){let{t:e}=U(`nav`),t=(0,Q.useRef)(0),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!S())return;let e=!0;async function n(){if(document.visibilityState===`hidden`)return;let n=t.current;try{let{invoke:i}=await c(async()=>{let{invoke:e}=await import(`./core-B3mKBIh5.js`).then(e=>e.i);return{invoke:e}},__vite__mapDeps([0,1])),a=await i(`desktop_system_status`);e&&n===t.current&&r(a)}catch{e&&n===t.current&&s(!0)}}n();let i=setInterval(()=>void n(),3e4);return()=>{e=!1,clearInterval(i)}},[]),!n?.supported)return null;async function l(){if(!(!n||i)){t.current+=1,a(!0),s(!1);try{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_set_awake`,{enabled:!n.awake}),r(await e(`desktop_system_status`))}catch{s(!0)}finally{a(!1)}}}return(0,$.jsxs)(`button`,{type:`button`,"aria-label":e(`keepAwake.label`),"aria-pressed":n.awake,disabled:i,onClick:()=>void l(),title:e(o?`keepAwake.failed`:n.awake?`keepAwake.active`:`keepAwake.inactive`),className:`flex h-6 items-center gap-1.5 rounded px-2 text-xs hover:bg-muted focus-visible:outline focus-visible:outline-ring disabled:opacity-50`,children:[(0,$.jsx)(xc,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(n.awake?`keepAwake.on`:`keepAwake.off`)}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:n.awake?`h-1.5 w-1.5 rounded-full bg-accent-success`:`h-1.5 w-1.5 rounded-full bg-muted-foreground/50`}),o&&(0,$.jsx)(`span`,{role:`status`,className:`sr-only`,children:e(`keepAwake.failed`)})]})}var R1={claude:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`,codex:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`};function z1({provider:e,className:t}){return(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:t,children:(0,$.jsx)(`path`,{d:R1[e]})})}function B1({expanded:e,menu:t=!1}){let{t:n,i18n:r}=U(`subscriptionUsage`),{snapshot:i,busy:a,error:o,refresh:s}=aY(),[c,l]=(0,Q.useState)(t),u=(0,Q.useId)(),d=cY(),f=e=>new Intl.DateTimeFormat(r.language,{dateStyle:`medium`,timeStyle:`long`}).format(new Date(e)),p=e=>{let t=Math.max(1,Math.ceil((Date.parse(e)-d)/6e4)),n=Math.floor(t/1440);t%=1440;let i=Math.floor(t/60);t%=60;let a=[],o=(e,t)=>new Intl.NumberFormat(r.language,{style:`unit`,unit:t,unitDisplay:`narrow`}).format(e);return n&&a.push(o(n,`day`)),i&&a.push(o(i,`hour`)),!n&&t&&a.push(o(t,`minute`)),a.join(` `)},m=e=>{let t=Math.max(0,Math.floor((d-Date.parse(e))/6e4)),n=t>=1440?`day`:t>=60?`hour`:`minute`;return new Intl.RelativeTimeFormat(r.language,{numeric:`auto`}).format(-Math.floor(t/(n===`day`?1440:n===`hour`?60:1)),n)},h=i?.providers.every(e=>e.installed===!1),g=a||i?.providers.some(e=>e.refreshState===`refreshing`),_=i?.providers.every(e=>e.retryAt&&Date.parse(e.retryAt)>d),v=i?.providers.some(e=>!lY(e,d)&&((e.spend?.usedPercent??0)>=90||e.windows.some(e=>e.usedPercent!==null&&e.usedPercent>=90)));return(0,$.jsx)(`div`,{className:X(`shrink-0 px-1.5 py-2`,!t&&`border-t border-border`,e&&`space-y-1.5`),"data-testid":`subscription-usage-section`,children:e?(0,$.jsxs)($.Fragment,{children:[!t&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end px-2`,children:[!t&&(0,$.jsxs)(`button`,{type:`button`,"aria-hidden":t,tabIndex:t?-1:0,disabled:t,"aria-expanded":c,"aria-controls":u,onClick:()=>{l(!c),c||s()},className:`flex min-h-8 flex-1 items-center gap-1.5 rounded-md text-left text-xs font-normal text-muted-foreground hover:text-foreground focus-visible:outline focus-visible:outline-ring`,children:[(0,$.jsx)(Cn,{"aria-hidden":`true`,className:X(`h-3 w-3 motion-safe:transition-transform`,c&&`rotate-90`,t&&`hidden`)}),n(`shortTitle`)]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":n(`refresh`),"aria-hidden":!c,tabIndex:c?0:-1,"aria-busy":!!g,disabled:!c||!!g||!!_,className:X(`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted focus-visible:outline focus-visible:outline-ring motion-safe:transition-opacity motion-safe:duration-200`,c?g||_?`opacity-50`:`opacity-100`:`pointer-events-none opacity-0`),onClick:()=>void s(),children:(0,$.jsx)(Lu,{className:X(`h-3 w-3`,g&&`motion-safe:animate-spin`)})})]}),(0,$.jsx)(`div`,{id:u,hidden:!c,children:i?h?(0,$.jsxs)(`div`,{className:`p-3 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(pd,{className:`mb-2 h-4 w-4`}),(0,$.jsx)(`p`,{children:n(`empty`)})]}):(0,$.jsx)(`div`,{className:X(!t&&`max-h-[36vh]`,`divide-y divide-border/40 overflow-y-auto`),children:i.providers.map(e=>{let t=lY(e,d);return(0,$.jsxs)(`article`,{"aria-label":e.providerId===`claude`?`Claude`:`Codex`,className:`w-full px-3 py-4 text-left`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-white`,children:(0,$.jsx)(z1,{provider:e.providerId,className:`h-4 w-4`})}),e.providerId===`claude`?`Claude`:`Codex`,e.spend&&(0,$.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n(`spend.enterprise`)}),t&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] font-normal text-muted-foreground`,children:n(`stale`)})]}),e.observedAt&&(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,title:f(e.observedAt),children:n(`updated`,{time:m(e.observedAt)})}),(0,$.jsx)(`div`,{className:`mt-2.5 space-y-2.5`,children:e.spend?(0,$.jsx)(sY,{spend:e.spend,stale:t,now:d,compact:!0}):e.windows.length?e.windows.map(r=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2 text-[10px]`,children:[(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,children:uY(r,n)}),(0,$.jsx)(`span`,{className:`shrink-0 font-medium tabular-nums`,children:r.usedPercent===null?`—`:`${r.usedPercent}%`})]}),r.usedPercent!==null&&(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":`${e.providerId} ${uY(r,n)}`,"aria-valuenow":r.usedPercent,"aria-valuemin":0,"aria-valuemax":100,className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:X(`h-full rounded-full`,t?`bg-muted-foreground/50`:r.usedPercent>=90?`bg-destructive`:r.usedPercent>=80?`bg-accent-warning`:`bg-accent-primary`),style:{width:`${r.usedPercent}%`}})}),(0,$.jsx)(`p`,{className:`text-[10px] tabular-nums text-muted-foreground`,title:r.resetsAt?f(r.resetsAt):void 0,children:r.resetsAt?Date.parse(r.resetsAt)<=d?n(`resetPassed`):n(`resetsIn`,{time:p(r.resetsAt)}):n(`resetUnknown`)})]},r.id)):(0,$.jsx)(`p`,{className:`text-[10px] leading-relaxed text-muted-foreground`,children:n(`issues.${dY(e)}`,{defaultValue:n(`issues.unavailable`)})})})]},e.providerId)})}):(0,$.jsx)(`p`,{className:`px-2 text-[11px] text-muted-foreground`,children:n(o?`loadFailed`:`loading`)})})]}):(0,$.jsxs)(`div`,{className:`relative flex h-8 w-full items-center justify-center text-muted-foreground`,"aria-label":n(`title`),title:n(`title`),children:[(0,$.jsx)(Cs,{className:`h-4 w-4`}),v&&(0,$.jsx)(`span`,{className:`absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-destructive`})]})})}function V1(){let{t:e,i18n:t}=U(`subscriptionUsage`),{snapshot:n,busy:r,refresh:i}=aY(),a=r||!!n?.providers.some(e=>e.refreshState===`refreshing`),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)({right:16,bottom:32}),u=(0,Q.useRef)(null),d=(0,Q.useRef)(void 0),f=(0,Q.useRef)(!1),p=()=>{clearTimeout(d.current)};(0,Q.useEffect)(()=>()=>clearTimeout(d.current),[]);let m=e=>{if(p(),e&&!f.current){let e=u.current?.getBoundingClientRect();e&&l({right:Math.max(12,window.innerWidth-e.right),bottom:window.innerHeight-e.top+6}),i()}f.current=e,s(e)},h=()=>{p(),d.current=setTimeout(()=>{document.activeElement===u.current||document.activeElement?.closest(`[data-usage-menu]`)||m(!1)},180)};return(0,$.jsxs)(sr,{open:o,onOpenChange:m,modal:!1,children:[(0,$.jsx)(er,{asChild:!0,children:(0,$.jsxs)(`button`,{ref:u,type:`button`,"aria-label":e(`shortTitle`),className:`flex h-6 items-center gap-1.5 rounded px-2 text-xs hover:bg-muted hover:text-foreground focus-visible:outline focus-visible:outline-ring`,onPointerEnter:e=>{e.pointerType===`mouse`&&m(!0)},onPointerLeave:h,onFocus:()=>m(!0),onBlur:h,onClick:e=>{e.preventDefault(),m(!0)},children:[(!n||n.providers.every(e=>!e.windows.length&&!e.spend))&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),(0,$.jsx)(`span`,{className:`flex items-center gap-3`,children:n?.providers.filter(e=>e.windows.length||e.spend).map(e=>{let n=e.windows.find(e=>e.scope===`account`&&e.label===`weekly`)??e.windows.find(e=>e.scope===`account`)??e.windows[0],r=e.spend?e.spend.usedPercent===null?`—`:oY(e.spend.usedPercent,t.language):n.usedPercent===null?`—`:`${n.usedPercent}%`;return(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,title:e.providerId===`claude`?`Claude`:`Codex`,children:[(0,$.jsx)(z1,{provider:e.providerId,className:`h-3.5 w-3.5 shrink-0 text-white`}),(0,$.jsx)(`span`,{children:e.providerId===`claude`?`Claude`:`Codex`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:r})]},e.providerId)})})]})}),(0,$.jsx)(fr,{children:(0,$.jsxs)(ir,{"aria-busy":a,"data-usage-menu":!0,className:`font-sans fixed z-50 w-[min(320px,calc(100vw-24px))] max-h-[calc(100dvh-48px)] rounded-xl border border-border bg-card p-2 shadow-xl outline-none`,style:c,onPointerEnter:p,onPointerLeave:h,onBlur:e=>{!e.currentTarget.contains(e.relatedTarget)&&e.relatedTarget!==u.current&&h()},onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(or,{className:`sr-only`,children:e(`title`)}),(0,$.jsx)(ar,{className:`sr-only`,children:e(`subtitle`)}),(0,$.jsx)(iM,{active:a,radius:`0.75rem`,inset:0,fadeInMs:450,fadeOutMs:800}),(0,$.jsx)(`div`,{className:`max-h-[calc(100dvh-64px)] overflow-y-auto`,children:(0,$.jsx)(B1,{expanded:!0,menu:!0})})]})})]})}function H1({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=U(`nav`),{t:i}=U(`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`){K.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(`${G()}/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 shrink-0 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)}`})})(),(0,$.jsx)(L1,{}),(0,$.jsx)(V1,{}),t]})]})}var U1={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function W1({missionOnly:e=!1}={}){let{t}=U(`agent`),{t:n}=U(`nav`),{t:r}=U(`builder`),{rightMode:i,cycleRightMode:a}=BZ(),{activeProjectId:o}=ce(),s=Ya(),c=fj(),{builderMode:l}=OL(),[u,d]=(0,Q.useState)(!1),f=l.active||i===`pinned-open`||i===`unpinned`&&u,p=GQ(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:f}),m=i!==`unpinned`,h=n(U1[i]),g=!o,_=[{key:`jobs`,icon:qs,label:t(`workspace.jobs`),onClick:()=>c.toggleJobsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},{key:`analytics`,icon:Ys,label:t(`workspace.analytics`),onClick:()=>c.toggleAnalyticsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},...pt()?[{key:`browser`,icon:ge,label:t(`workspace.browser`),onClick:()=>c.openBrowser(),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...rt?[{key:`terminal`,icon:pd,label:t(`workspace.terminal`),onClick:()=>o&&s.togglePanel(o),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...Ke?[{key:`files`,icon:Yc,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)(KQ,{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}),!S()&&(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`)}),!S()&&(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)(du,{className:`w-4 h-4`})})]}),l.active?(0,$.jsx)(jb,{mode:`wait`,initial:!1,children:(0,$.jsxs)(jS.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)(II,{blueprint:l.session.blueprint,snapshot:l.session.snapshot}),l.session.phase===`chat`&&(0,$.jsx)(zI,{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)(o$,{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))]})]})}function G1(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=Qe(),{tickets:i}=J(),a=p(),o=y(),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 K1(e){let{key:t,detail:n}=Bt(e);return[`chunk_failed`,`chunk_stalled`,`chunk_stopped`,`provider_limit`,`launch_rejected`,`head_missing`,`head_discarded`,`run_lost`,`rail_limit_reached`,`integration_failed`].includes(t)?N.t(`builder:milestoneProgress.chain.reasons.${t}`,{detail:n}):e??``}function q1({setActiveProjectId:e}={}){let t=y(),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}=R();(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=Dt(t.chain);if(!e)return;let n=i.current.get(e.id);i.current.set(e.id,e);let r=kt(e.milestoneN);if(e.status===`running`&&e.nextChunk>1&&(!n||n.nextChunk<e.nextChunk)&&K.success(N.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}`;K.success(N.t(`builder:milestoneProgress.toast.checkpoint`,{milestone:r,k:e.nextChunk,n:e.totalChunks}),{id:t,duration:6e4,action:{label:N.t(`builder:milestoneProgress.toast.launchNext`),onClick:()=>{KF(o,e.id).then(e=>{e.ok?K.success(N.t(`builder:milestoneProgress.chain.nextLaunched`),{id:t}):K.error(N.t(`builder:milestoneProgress.chain.resumeFailed`),{id:t,description:e.detail??e.error})})}},cancel:{label:N.t(`builder:milestoneProgress.toast.autoContinue`),onClick:()=>{JF(o,e.id,!0).then(e=>{e.ok?K.success(N.t(`builder:milestoneProgress.chain.autoOn`),{id:t}):K.error(N.t(`builder:milestoneProgress.chain.autoFailed`),{id:t,description:e.detail??e.error})})}}})}e.status===`paused`&&(!n||n.status!==`paused`||n.pauseReason!==e.pauseReason)&&K.warning(N.t(`builder:milestoneProgress.toast.paused`,{milestone:r,reason:K1(e.pauseReason)}),{id:`chain-paused:${e.id}`,duration:3e4,action:{label:N.t(`builder:milestoneProgress.toast.resume`),onClick:()=>{KF(o,e.id).then(t=>{t.ok?K.success(N.t(`builder:milestoneProgress.chain.resumed`),{id:`chain-paused:${e.id}`}):K.error(N.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 Pt(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=Ft(e);K.success(N.t(`builder:milestoneProgress.toast.delivered`,{milestone:kt(e.n),count:e.counts.onReview}),{id:`milestone-delivered:${t}`,duration:3e4,...i?{action:{label:N.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`&&K.success(N.t(`builder:milestoneProgress.toast.completed`,{milestone:kt(t.n)}),{id:`milestone-completed:${o}:${t.milestoneId??t.n}`,duration:15e3})}),()=>s(e)},[o,s])}function J1(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:Y1(e)?`review`:null}function Y1(e){let t=/^\/review\/([^/]+)\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function X1(e){let t=/^\/loops\/([^/]+)\/edit\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function Z1({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r,reviewOpen:i=null}){if(e===`agent`){let e=J1(t);if(!e)return null;if(e===`review`)return{kind:`modalize`,surface:e,backgroundPath:`/`,reviewDeliveryId:Y1(t)??void 0};let n=e===`loops`?X1(t):null;return n?{kind:`modalize`,surface:`loops`,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 Q1=(0,Q.lazy)(()=>c(()=>import(`./JobDetailPage-Ilu294WS.js`),__vite__mapDeps([97,1,7,45,10,9,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,8,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,93]))),$1=(0,Q.lazy)(()=>c(()=>import(`./ReviewPacketPage-D34bGpSA.js`),__vite__mapDeps([98,1,7,45,10,42,43,8,9,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,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,99]))),e0=(0,Q.lazy)(()=>c(()=>import(`./JobsPage-fPq1hefb.js`),__vite__mapDeps([100,1,7,45,10,9,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,8,57,68,69,54,72,73,74,75,76,77,78,93,101,58,87]))),t0=(0,Q.lazy)(()=>c(()=>import(`./AnalyticsPage-CGn5cgtc.js`),__vite__mapDeps([102,1,7,45,10,9,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,47,43,8,48,50,74,76,77,101,58,103,84]))),n0=(0,Q.lazy)(()=>c(()=>import(`./ActivityFeedPage-Bn2MpG5M.js`),__vite__mapDeps([104,1,7,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,8,55,57,62,71]))),r0=(0,Q.lazy)(()=>c(()=>import(`./AgentsPage-BMfJ4mzU.js`),__vite__mapDeps([105,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,47,43,48,49,51,45,52,53,54,56,59,62,63,65,67,68,69,72,73,74,78,93]))),i0=(0,Q.lazy)(()=>c(()=>import(`./CodePage-C8NIginr.js`),__vite__mapDeps([106,1,7,8,10,45,9,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,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,77,78,79,80]))),a0=(0,Q.lazy)(()=>c(()=>import(`./IntegrationsPage-EAipiDWm.js`),__vite__mapDeps([107,7,1,45,10]))),o0=(0,Q.lazy)(()=>c(()=>import(`./PluginsPage-DfDfEfbW.js`),__vite__mapDeps([108,1,7,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,8,48,58,59,62,67,68,69,70,72,54,73,74,78]))),s0=(0,Q.lazy)(()=>c(()=>import(`./DesktopAnalyticsPage-C87r4y26.js`),__vite__mapDeps([109,1,7,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,74,73,103,8,84]))),c0=(0,Q.lazy)(()=>c(()=>import(`./DocsPage-DIArbEPl.js`),__vite__mapDeps([110,1,7,45,10,42,56,62,73,74,75,86,111,112]))),l0=(0,Q.lazy)(()=>c(()=>import(`./DocsDialog-Z50a_KPv.js`),__vite__mapDeps([113,1,7,42,56,62,72,8,54,73,74,75,86,111,112]))),u0=(0,Q.lazy)(()=>c(()=>import(`./LoopWindowSurface-D1WB9i-9.js`).then(e=>({default:e.LoopWindowSurface})),__vite__mapDeps([114,1,7,43,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,115,45,48,58,59,63,64,65,66,53,68,116,72,54,73,74,78,79,80,89,60,117,49,69,83,84,85]))),d0=(0,Q.lazy)(()=>c(()=>import(`./LoopsPage-CCwc0Biu.js`),__vite__mapDeps([115,1,7,45,10,42,43,8,9,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,48,58,59,63,64,65,66,53,68,116,72,54,73,74,78,79,80,89,60]))),f0=(0,Q.lazy)(()=>c(()=>import(`./LoopBuilderPage-5M7IypEP.js`),__vite__mapDeps([117,1,7,45,10,42,43,8,9,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,48,49,59,60,64,65,66,68,69,116,54,72,73,74,78,80,83,84,85]))),p0=28;function m0({surface:e,onClose:t}){let{t:n}=U(`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`?Fd:e===`review`?qc:ku,{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)(Vn,{className:`h-4 w-4`})})})]})}var h0=new Set([`/settings`,`/loops`,`/plugins`]);function g0(e){return h0.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var _0=`specrails-desktop:routeMemory`;try{localStorage.removeItem(_0)}catch{}function v0(e){let t=p(),n=y(),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{rP((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&&!g0(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!g0(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,Q.useEffect)(()=>{e&&t.pathname!==`/`&&!g0(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function y0(){let{t:e}=U(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setActiveProjectId:a}=ce(),{cycleLeftMode:o,cycleRightMode:s}=BZ(),c=y(),l=p(),u=Ya(),d=OL(),{uiMode:m}=eL();G1();let[g,v]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(`appearance`),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),M=(0,Q.useCallback)(()=>{D(!1),k(null)},[]),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(!1),ee=(0,Q.useCallback)(()=>I(!1),[]),[te,L]=(0,Q.useState)(()=>!EQ());v0(n),A1();let{cheatsheetOpen:R,setCheatsheetOpen:z,openCheatsheet:B}=TZ(),ne=[`/`,`/jobs`,`/analytics`,...lt?[`/agents`]:[],...Ke?[`/code`]:[],`/integrations`,`/settings`];wZ({onOpenCheatsheet:B,onToggleLeftSidebar:o,onToggleRightSidebar:s,onSwitchProject:e=>{let n=t[e-1];n&&a(n.id)},onSwitchProjectPage:e=>{let t=ne[e-1];t&&c(t)},onToggleTerminalPanel:rt?()=>{n&&(u.togglePanel(n),u.getState(n).visibility===`hidden`?queueMicrotask(()=>u.focusActive(n)):u.focusActive(n))}:void 0,onToggleAgentChat:$e&&m!==`agent`?()=>d.toggle():void 0}),hZ({setActiveProjectId:a,projectsById:(0,Q.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])}),q1({setActiveProjectId:a}),(0,Q.useEffect)(()=>{BF()},[]);let V=t.find(e=>e.id===n),re=l.pathname.startsWith(`/loops`),ie=l.pathname.startsWith(`/plugins`),ae=l.pathname.startsWith(`/docs`)||m!==`agent`&&(re||ie);(0,Q.useLayoutEffect)(()=>{let e=Z1({uiMode:m,pathname:l.pathname,loopsOpen:E,pluginsOpen:A,reviewOpen:N});if(e){if(e.kind===`modalize`){if(e.surface===`review`){e.reviewDeliveryId&&P(e.reviewDeliveryId),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}if(e.surface===`loops`){j(!1),D(!0),k(e.loopBuilderId??null),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}else M(),j(!0);l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}M(),j(!1),P(null),l.pathname!==e.path&&c(e.path,{replace:!0})}},[n,l.pathname,c,M,E,A,N,m]);let{connectionStatus:H}=I1(),W=Xa(n),G=p0,se=(0,Q.useRef)(null),[K,le]=(0,Q.useState)(typeof window<`u`?window.innerHeight:820);(0,Q.useLayoutEffect)(()=>{if(!rt)return;let e=se.current;if(!e)return;let t=()=>le(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,Q.useEffect)(()=>{!rt||!n||u.ensureProject(n)},[n,u]);let ue=rt&&m===`kanban`&&W.visibility===`hidden`?(0,$.jsx)(jR,{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)(i$,{onOpenCompanion:()=>{x(`mobile`),C(!0)},onAddProject:()=>v(!0),onOpenLoops:()=>{m===`agent`?D(!0):c(`/loops`)},onOpenPlugins:()=>{m===`agent`?j(!0):c(`/plugins`)},onOpenAnalytics:()=>T(!0),onOpenDocs:()=>I(!0),onOpenSettings:()=>{x(`appearance`),C(!0)}}),(0,$.jsxs)(`div`,{ref:se,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:m===`agent`&&!ae?(0,$.jsx)(fR,{}):(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)(_,{children:[(0,$.jsx)(h,{path:`/docs`,element:(0,$.jsx)(c0,{})}),(0,$.jsx)(h,{path:`/docs/:category/:slug`,element:(0,$.jsx)(c0,{})}),st&&(0,$.jsx)(h,{path:`/loops`,element:(0,$.jsx)(d0,{})}),st&&(0,$.jsx)(h,{path:`/loops/:id/edit`,element:(0,$.jsx)(f0,{})}),(0,$.jsx)(h,{path:`/plugins`,element:(0,$.jsx)(o0,{})}),t.length===0?(0,$.jsx)(h,{path:`*`,element:(0,$.jsx)(CQ,{onAddProject:()=>v(!0)})}):V?(0,$.jsxs)(h,{element:(0,$.jsx)(SQ,{projectName:V.name,children:(0,$.jsx)(bQ,{project:V})},V.id),children:[(0,$.jsx)(h,{path:`/`,element:(0,$.jsx)(Yq,{})}),(0,$.jsx)(h,{path:`/jobs`,element:(0,$.jsx)(e0,{})}),(0,$.jsx)(h,{path:`/jobs/:id`,element:(0,$.jsx)(Q1,{})}),Ve&&(0,$.jsx)(h,{path:`/review/:prDeliveryId`,element:(0,$.jsx)($1,{})}),(0,$.jsx)(h,{path:`/analytics`,element:(0,$.jsx)(t0,{})}),(0,$.jsx)(h,{path:`/activity`,element:(0,$.jsx)(n0,{})}),(0,$.jsx)(h,{path:`/agents`,element:(0,$.jsx)(r0,{})}),(0,$.jsx)(h,{path:`/code`,element:Ke?(0,$.jsx)(i0,{}):(0,$.jsx)(f,{to:`/`,replace:!0})}),(0,$.jsx)(h,{path:`/integrations`,element:(0,$.jsx)(a0,{})}),(0,$.jsx)(h,{path:`/settings`,element:(0,$.jsx)(QJ,{})}),(0,$.jsx)(h,{path:`*`,element:(0,$.jsx)(f,{to:`/`,replace:!0})})]}):(0,$.jsx)(h,{path:`*`,element:(0,$.jsx)(CQ,{onAddProject:()=>v(!0)})})]})})}),rt&&n&&V&&(0,$.jsx)(QR,{projectId:n,provider:V.provider,providers:oe(V),state:W,viewportHeight:K,statusBarHeight:G}),(0,$.jsx)(H1,{connectionStatus:H,minimal:m===`agent`,rightSlot:m===`agent`?void 0:ue})]}),m===`agent`?!ae&&(0,$.jsx)(W1,{}):V&&!ae&&(0,$.jsx)(c$,{}),(0,$.jsx)(y$,{open:g,onClose:()=>v(!1),onOpenBuilder:()=>d.builderMode.enter()}),(0,$.jsx)(yZ,{initialSection:b,open:S,onClose:()=>C(!1),onOpenOnboarding:()=>{C(!1),L(!0)}}),(0,$.jsx)(vr,{open:w,onOpenChange:T,children:(0,$.jsx)(gr,{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)(s0,{})})})})}),(0,$.jsx)(vr,{open:E,onOpenChange:e=>{e||M()},children:(0,$.jsxs)(gr,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,"data-testid":`loops-modal`,children:[(0,$.jsx)(dr,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,$.jsx)(cr,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,$.jsx)(m0,{surface:`loops`,onClose:M}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:O?(0,$.jsx)(f0,{loopId:O,onExit:()=>k(null),onWindowOpened:M}):(0,$.jsx)(d0,{onOpenBuilder:k,onWindowOpened:M})})})]})}),(0,$.jsx)(vr,{open:A,onOpenChange:j,children:(0,$.jsxs)(gr,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,"data-testid":`plugins-modal`,children:[(0,$.jsx)(dr,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,$.jsx)(cr,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,$.jsx)(m0,{surface:`plugins`,onClose:()=>j(!1)}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(o0,{onWindowOpened:()=>j(!1)})})})]})}),Ve&&(0,$.jsx)(vr,{open:N!==null,onOpenChange:e=>{e||P(null)},children:(0,$.jsxs)(gr,{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)(dr,{className:`sr-only`,children:e(`nav:arcSidebar.review`)}),(0,$.jsx)(cr,{className:`sr-only`,children:e(`nav:globalSurfaceModal.reviewDescription`)}),(0,$.jsx)(m0,{surface:`review`,onClose:()=>P(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:N&&(0,$.jsx)($1,{prDeliveryId:N,onClose:()=>P(null)})})})]})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(l0,{open:F,onClose:ee})}),(0,$.jsx)(w1,{onOpenSettings:()=>{x(`appearance`),C(!0)},onOpenAnalytics:()=>T(!0),onOpenDocs:()=>I(!0)}),(0,$.jsx)(AZ,{open:R,onOpenChange:z}),(0,$.jsx)(VQ,{open:te,onClose:()=>L(!1)})]})}function b0({children:e}){let{activeProjectId:t}=ce();return(0,$.jsx)(qa,{activeProjectId:t,children:e})}function x0({children:e}){let{activeProjectId:t}=ce();return(0,$.jsx)(fq,{activeProjectId:t,children:e})}function S0({children:e}){let{activeProjectId:t}=ce();return(0,$.jsx)(yq,{activeProjectId:t,children:e})}function C0(){return(0,$.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function w0(){let{theme:e}=Ma(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,BC.createPortal)((0,$.jsx)(se,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,$.jsx)(C0,{})},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 T0(){return gX(),null}function E0(){let e=wi();return P1(),Kr()||Ur()?(0,$.jsx)(ee,{url:We,children:(0,$.jsx)(ja,{children:(0,$.jsx)(bY,{children:(0,$.jsx)(le,{isolated:!0,children:(0,$.jsx)(QI,{initialMode:`agent`,persist:!1,children:(0,$.jsxs)(`div`,{className:`h-screen flex flex-col overflow-hidden`,children:[(0,$.jsx)(GZ,{}),(0,$.jsx)(Q.Suspense,{fallback:null,children:Ur()?(0,$.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,$.jsx)(o0,{})}):(0,$.jsx)(u0,{})}),(0,$.jsx)(w0,{})]})})})})})}):(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)(ee,{url:We,children:(0,$.jsx)(ja,{children:(0,$.jsxs)(bY,{children:[(0,$.jsx)(yQ,{}),(0,$.jsx)(le,{isolated:e,children:(0,$.jsxs)(QI,{initialMode:e?`agent`:void 0,persist:!e,children:[!e&&(0,$.jsx)(T0,{}),(0,$.jsx)(sW,{children:(0,$.jsx)(O1,{children:(0,$.jsx)(Pe,{children:(0,$.jsxs)(zZ,{children:[(0,$.jsx)(GZ,{}),(0,$.jsx)(b0,{children:(0,$.jsx)(x0,{children:(0,$.jsx)(S0,{children:(0,$.jsx)(yn,{children:(0,$.jsx)(uj,{children:(0,$.jsx)(ji,{secondary:e,children:(0,$.jsx)(EL,{children:(0,$.jsx)(Ej,{children:(0,$.jsx)(ct,{children:(0,$.jsxs)(et,{children:[(0,$.jsx)(AL,{}),(0,$.jsx)(Ld,{}),e?(0,$.jsx)($R,{}):(0,$.jsx)(y0,{}),(0,$.jsx)(YL,{}),(0,$.jsx)(w0,{})]})})})})})})})})})})]})})})})]})})]})})})})})}async function D0(){await te(),z(),await M(),(0,Hr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(v,{children:(0,$.jsx)(E0,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}D0();export{fj as $,Us as $t,LH as A,xu as At,Bz as B,ll as Bt,EK as C,td as Ct,xK as D,Lu as Dt,SK as E,zu as Et,_H as F,zl as Ft,tP as G,kc as Gt,Tz as H,tl as Ht,UV as I,kl as It,ON as J,sc as Jt,QN as K,Dc as Kt,VB as L,Tl as Lt,uH as M,Zl as Mt,NH as N,Yl as Nt,lK as O,ku as Ot,kH as P,ql as Pt,gM as Q,qs as Qt,KB as R,xl as Rt,cq as S,rd as St,CK as T,Uu as Tt,OL as U,$c as Ut,Vz as V,sl as Vt,gF as W,qc as Wt,DN as X,rc as Xt,TN as Y,ac as Yt,_M as Z,Ys as Zt,sJ as _,xd as _t,RJ as a,Pa as an,oT as at,XK as b,ld as bt,yJ as c,qr as cn,IC as ct,wJ as d,NS as dt,zs as en,xA as et,gJ as f,PS as ft,uJ as g,kd as gt,pJ as h,jd as ht,XJ as i,Mo as in,nT as it,xH as j,tu as jt,JW as k,Tu as kt,bJ as l,Ur as ln,MC as lt,SJ as m,Fd as mt,ZJ as n,js as nn,IA as nt,JJ as o,Mi as on,qw as ot,xJ as p,HS as pt,EN as q,pc as qt,zJ as r,Cs as rn,lT as rt,FJ as s,Kr as sn,Kw as st,I1 as t,Ls as tn,SA as tt,CJ as u,Gr as un,US as ut,jq as v,_d as vt,TK as w,Zu as wt,lq as x,ad as xt,mq as y,pd as yt,Xz as z,yl as zt};
|
|
83
|
+
`;function E1(e){return`contract-refine:${e}`}async function D1(e,t){try{let n=await fetch(`${F}/api/projects/${e}/tickets/${t}/contract-refine`,{method:`POST`});if(n.ok)K.loading(N.t(`activity:contractRefine.refining`),{id:E1(t)});else{let e=await n.json().catch(()=>({}));K.error(e.error?N.t(`activity:contractRefine.retryRejectedWithError`,{error:e.error}):N.t(`activity:contractRefine.retryRejected`),{id:E1(t)})}}catch(e){K.error(N.t(`activity:contractRefine.retryFailed`,{message:e.message}),{id:E1(t)})}}function O1({children:e}){let{registerHandler:t,unregisterHandler:n}=R(),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=en(a)?{label:N.t(`common:actions.retry`),onClick:()=>void D1(i,n)}:void 0;K.error(N.t(`activity:contractRefine.skipped`),{id:E1(n),description:N.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(T1)&&K.success(N.t(`activity:contractRefine.added`,{title:n.title||`#${n.id}`}),{id:E1(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 k1(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function A1(){let{t:e}=U(`mcp`),t=xY()?.languageId;(0,Q.useEffect)(()=>{k1()&&Y(`set_tray_labels`,{open:e(`tray.open`),exit:e(`tray.exit`)}).catch(()=>{})},[e,t])}var j1=`input, textarea, select, [contenteditable="true"], [contenteditable=""], .monaco-editor, .xterm, [data-native-menu]`;function M1(e){return e instanceof Element&&e.closest(j1)!==null}function N1(e){M1(e.target)||e.preventDefault()}function P1(){(0,Q.useEffect)(()=>(document.addEventListener(`contextmenu`,N1),()=>document.removeEventListener(`contextmenu`,N1)),[])}var F1={jobs:[],activeJobId:null,paused:!1};function I1(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)(F1),[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(F1))}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??F1;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}=R();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(`${G()}/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 L1(){let{t:e}=U(`nav`),t=(0,Q.useRef)(0),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!S())return;let e=!0;async function n(){if(document.visibilityState===`hidden`)return;let n=t.current;try{let{invoke:i}=await c(async()=>{let{invoke:e}=await import(`./core-B3mKBIh5.js`).then(e=>e.i);return{invoke:e}},__vite__mapDeps([0,1])),a=await i(`desktop_system_status`);e&&n===t.current&&r(a)}catch{e&&n===t.current&&s(!0)}}n();let i=setInterval(()=>void n(),3e4);return()=>{e=!1,clearInterval(i)}},[]),!n?.supported)return null;async function l(){if(!(!n||i)){t.current+=1,a(!0),s(!1);try{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_set_awake`,{enabled:!n.awake}),r(await e(`desktop_system_status`))}catch{s(!0)}finally{a(!1)}}}return(0,$.jsxs)(`button`,{type:`button`,"aria-label":e(`keepAwake.label`),"aria-pressed":n.awake,disabled:i,onClick:()=>void l(),title:e(o?`keepAwake.failed`:n.awake?`keepAwake.active`:`keepAwake.inactive`),className:`flex h-6 items-center gap-1.5 rounded px-2 text-xs hover:bg-muted focus-visible:outline focus-visible:outline-ring disabled:opacity-50`,children:[(0,$.jsx)(xc,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(n.awake?`keepAwake.on`:`keepAwake.off`)}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:n.awake?`h-1.5 w-1.5 rounded-full bg-accent-success`:`h-1.5 w-1.5 rounded-full bg-muted-foreground/50`}),o&&(0,$.jsx)(`span`,{role:`status`,className:`sr-only`,children:e(`keepAwake.failed`)})]})}var R1={claude:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`,codex:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`};function z1({provider:e,className:t}){return(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:t,children:(0,$.jsx)(`path`,{d:R1[e]})})}function B1({expanded:e,menu:t=!1}){let{t:n,i18n:r}=U(`subscriptionUsage`),{snapshot:i,busy:a,error:o,refresh:s}=aY(),[c,l]=(0,Q.useState)(t),u=(0,Q.useId)(),d=cY(),f=e=>new Intl.DateTimeFormat(r.language,{dateStyle:`medium`,timeStyle:`long`}).format(new Date(e)),p=e=>{let t=Math.max(1,Math.ceil((Date.parse(e)-d)/6e4)),n=Math.floor(t/1440);t%=1440;let i=Math.floor(t/60);t%=60;let a=[],o=(e,t)=>new Intl.NumberFormat(r.language,{style:`unit`,unit:t,unitDisplay:`narrow`}).format(e);return n&&a.push(o(n,`day`)),i&&a.push(o(i,`hour`)),!n&&t&&a.push(o(t,`minute`)),a.join(` `)},m=e=>{let t=Math.max(0,Math.floor((d-Date.parse(e))/6e4)),n=t>=1440?`day`:t>=60?`hour`:`minute`;return new Intl.RelativeTimeFormat(r.language,{numeric:`auto`}).format(-Math.floor(t/(n===`day`?1440:n===`hour`?60:1)),n)},h=i?.providers.every(e=>e.installed===!1),g=a||i?.providers.some(e=>e.refreshState===`refreshing`),_=i?.providers.every(e=>e.retryAt&&Date.parse(e.retryAt)>d),v=i?.providers.some(e=>!lY(e,d)&&((e.spend?.usedPercent??0)>=90||e.windows.some(e=>e.usedPercent!==null&&e.usedPercent>=90)));return(0,$.jsx)(`div`,{className:X(`shrink-0 px-1.5 py-2`,!t&&`border-t border-border`,e&&`space-y-1.5`),"data-testid":`subscription-usage-section`,children:e?(0,$.jsxs)($.Fragment,{children:[!t&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end px-2`,children:[!t&&(0,$.jsxs)(`button`,{type:`button`,"aria-hidden":t,tabIndex:t?-1:0,disabled:t,"aria-expanded":c,"aria-controls":u,onClick:()=>{l(!c),c||s()},className:`flex min-h-8 flex-1 items-center gap-1.5 rounded-md text-left text-xs font-normal text-muted-foreground hover:text-foreground focus-visible:outline focus-visible:outline-ring`,children:[(0,$.jsx)(Cn,{"aria-hidden":`true`,className:X(`h-3 w-3 motion-safe:transition-transform`,c&&`rotate-90`,t&&`hidden`)}),n(`shortTitle`)]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":n(`refresh`),"aria-hidden":!c,tabIndex:c?0:-1,"aria-busy":!!g,disabled:!c||!!g||!!_,className:X(`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted focus-visible:outline focus-visible:outline-ring motion-safe:transition-opacity motion-safe:duration-200`,c?g||_?`opacity-50`:`opacity-100`:`pointer-events-none opacity-0`),onClick:()=>void s(),children:(0,$.jsx)(Lu,{className:X(`h-3 w-3`,g&&`motion-safe:animate-spin`)})})]}),(0,$.jsx)(`div`,{id:u,hidden:!c,children:i?h?(0,$.jsxs)(`div`,{className:`p-3 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(pd,{className:`mb-2 h-4 w-4`}),(0,$.jsx)(`p`,{children:n(`empty`)})]}):(0,$.jsx)(`div`,{className:X(!t&&`max-h-[36vh]`,`divide-y divide-border/40 overflow-y-auto`),children:i.providers.map(e=>{let t=lY(e,d);return(0,$.jsxs)(`article`,{"aria-label":e.providerId===`claude`?`Claude`:`Codex`,className:`w-full px-3 py-4 text-left`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-white`,children:(0,$.jsx)(z1,{provider:e.providerId,className:`h-4 w-4`})}),e.providerId===`claude`?`Claude`:`Codex`,e.spend&&(0,$.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n(`spend.enterprise`)}),t&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] font-normal text-muted-foreground`,children:n(`stale`)})]}),e.observedAt&&(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,title:f(e.observedAt),children:n(`updated`,{time:m(e.observedAt)})}),(0,$.jsx)(`div`,{className:`mt-2.5 space-y-2.5`,children:e.spend?(0,$.jsx)(sY,{spend:e.spend,stale:t,now:d,compact:!0}):e.windows.length?e.windows.map(r=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2 text-[10px]`,children:[(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,children:uY(r,n)}),(0,$.jsx)(`span`,{className:`shrink-0 font-medium tabular-nums`,children:r.usedPercent===null?`—`:`${r.usedPercent}%`})]}),r.usedPercent!==null&&(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":`${e.providerId} ${uY(r,n)}`,"aria-valuenow":r.usedPercent,"aria-valuemin":0,"aria-valuemax":100,className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:X(`h-full rounded-full`,t?`bg-muted-foreground/50`:r.usedPercent>=90?`bg-destructive`:r.usedPercent>=80?`bg-accent-warning`:`bg-accent-primary`),style:{width:`${r.usedPercent}%`}})}),(0,$.jsx)(`p`,{className:`text-[10px] tabular-nums text-muted-foreground`,title:r.resetsAt?f(r.resetsAt):void 0,children:r.resetsAt?Date.parse(r.resetsAt)<=d?n(`resetPassed`):n(`resetsIn`,{time:p(r.resetsAt)}):n(`resetUnknown`)})]},r.id)):(0,$.jsx)(`p`,{className:`text-[10px] leading-relaxed text-muted-foreground`,children:n(`issues.${dY(e)}`,{defaultValue:n(`issues.unavailable`)})})})]},e.providerId)})}):(0,$.jsx)(`p`,{className:`px-2 text-[11px] text-muted-foreground`,children:n(o?`loadFailed`:`loading`)})})]}):(0,$.jsxs)(`div`,{className:`relative flex h-8 w-full items-center justify-center text-muted-foreground`,"aria-label":n(`title`),title:n(`title`),children:[(0,$.jsx)(Cs,{className:`h-4 w-4`}),v&&(0,$.jsx)(`span`,{className:`absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-destructive`})]})})}function V1(){let{t:e,i18n:t}=U(`subscriptionUsage`),{snapshot:n,busy:r,refresh:i}=aY(),a=r||!!n?.providers.some(e=>e.refreshState===`refreshing`),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)({right:16,bottom:32}),u=(0,Q.useRef)(null),d=(0,Q.useRef)(void 0),f=(0,Q.useRef)(!1),p=()=>{clearTimeout(d.current)};(0,Q.useEffect)(()=>()=>clearTimeout(d.current),[]);let m=e=>{if(p(),e&&!f.current){let e=u.current?.getBoundingClientRect();e&&l({right:Math.max(12,window.innerWidth-e.right),bottom:window.innerHeight-e.top+6}),i()}f.current=e,s(e)},h=()=>{p(),d.current=setTimeout(()=>{document.activeElement===u.current||document.activeElement?.closest(`[data-usage-menu]`)||m(!1)},180)};return(0,$.jsxs)(sr,{open:o,onOpenChange:m,modal:!1,children:[(0,$.jsx)(er,{asChild:!0,children:(0,$.jsxs)(`button`,{ref:u,type:`button`,"aria-label":e(`shortTitle`),className:`flex h-6 items-center gap-1.5 rounded px-2 text-xs hover:bg-muted hover:text-foreground focus-visible:outline focus-visible:outline-ring`,onPointerEnter:e=>{e.pointerType===`mouse`&&m(!0)},onPointerLeave:h,onFocus:()=>m(!0),onBlur:h,onClick:e=>{e.preventDefault(),m(!0)},children:[(!n||n.providers.every(e=>!e.windows.length&&!e.spend))&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),(0,$.jsx)(`span`,{className:`flex items-center gap-3`,children:n?.providers.filter(e=>e.windows.length||e.spend).map(e=>{let n=e.windows.find(e=>e.scope===`account`&&e.label===`weekly`)??e.windows.find(e=>e.scope===`account`)??e.windows[0],r=e.spend?e.spend.usedPercent===null?`—`:oY(e.spend.usedPercent,t.language):n.usedPercent===null?`—`:`${n.usedPercent}%`;return(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,title:e.providerId===`claude`?`Claude`:`Codex`,children:[(0,$.jsx)(z1,{provider:e.providerId,className:`h-3.5 w-3.5 shrink-0 text-white`}),(0,$.jsx)(`span`,{children:e.providerId===`claude`?`Claude`:`Codex`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:r})]},e.providerId)})})]})}),(0,$.jsx)(fr,{children:(0,$.jsxs)(ir,{"aria-busy":a,"data-usage-menu":!0,className:`font-sans fixed z-50 w-[min(320px,calc(100vw-24px))] max-h-[calc(100dvh-48px)] rounded-xl border border-border bg-card p-2 shadow-xl outline-none`,style:c,onPointerEnter:p,onPointerLeave:h,onBlur:e=>{!e.currentTarget.contains(e.relatedTarget)&&e.relatedTarget!==u.current&&h()},onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(or,{className:`sr-only`,children:e(`title`)}),(0,$.jsx)(ar,{className:`sr-only`,children:e(`subtitle`)}),(0,$.jsx)(iM,{active:a,radius:`0.75rem`,inset:0,fadeInMs:450,fadeOutMs:800}),(0,$.jsx)(`div`,{className:`max-h-[calc(100dvh-64px)] overflow-y-auto`,children:(0,$.jsx)(B1,{expanded:!0,menu:!0})})]})})]})}function H1({connectionStatus:e,rightSlot:t,minimal:n=!1}){let{t:r}=U(`nav`),{t:i}=U(`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`){K.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(`${G()}/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 shrink-0 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)}`})})(),(0,$.jsx)(L1,{}),(0,$.jsx)(V1,{}),t]})]})}var U1={"pinned-open":`sidebarPin.right.pinnedOpen`,"pinned-collapsed":`sidebarPin.right.pinnedCollapsed`,unpinned:`sidebarPin.right.unpinned`};function W1({missionOnly:e=!1}={}){let{t}=U(`agent`),{t:n}=U(`nav`),{t:r}=U(`builder`),{rightMode:i,cycleRightMode:a}=BZ(),{activeProjectId:o}=ce(),s=Ya(),c=fj(),{builderMode:l}=OL(),[u,d]=(0,Q.useState)(!1),f=l.active||i===`pinned-open`||i===`unpinned`&&u,p=GQ(`right-workspace`,{side:`right`,defaultWidth:208,min:180,max:460,collapsedWidth:44,expanded:f}),m=i!==`unpinned`,h=n(U1[i]),g=!o,_=[{key:`jobs`,icon:qs,label:t(`workspace.jobs`),onClick:()=>c.toggleJobsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},{key:`analytics`,icon:Ys,label:t(`workspace.analytics`),onClick:()=>c.toggleAnalyticsPane(),disabled:g,disabledTitle:t(`workspace.requiresProject`)},...pt()?[{key:`browser`,icon:ge,label:t(`workspace.browser`),onClick:()=>c.openBrowser(),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...rt?[{key:`terminal`,icon:pd,label:t(`workspace.terminal`),onClick:()=>o&&s.togglePanel(o),disabled:g,disabledTitle:t(`workspace.requiresProject`)}]:[],...Ke?[{key:`files`,icon:Yc,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)(KQ,{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}),!S()&&(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`)}),!S()&&(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)(du,{className:`w-4 h-4`})})]}),l.active?(0,$.jsx)(jb,{mode:`wait`,initial:!1,children:(0,$.jsxs)(jS.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)(II,{blueprint:l.session.blueprint,snapshot:l.session.snapshot}),l.session.phase===`chat`&&(0,$.jsx)(zI,{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)(o$,{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))]})]})}function G1(){let{state:e,openTicketDetail:t,enterSplit:n,setComparedTicket:r}=Qe(),{tickets:i}=J(),a=p(),o=y(),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 K1(e){let{key:t,detail:n}=Bt(e);return[`chunk_failed`,`chunk_stalled`,`chunk_stopped`,`provider_limit`,`launch_rejected`,`head_missing`,`head_discarded`,`run_lost`,`rail_limit_reached`,`integration_failed`].includes(t)?N.t(`builder:milestoneProgress.chain.reasons.${t}`,{detail:n}):e??``}function q1({setActiveProjectId:e}={}){let t=y(),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}=R();(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=Dt(t.chain);if(!e)return;let n=i.current.get(e.id);i.current.set(e.id,e);let r=kt(e.milestoneN);if(e.status===`running`&&e.nextChunk>1&&(!n||n.nextChunk<e.nextChunk)&&K.success(N.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}`;K.success(N.t(`builder:milestoneProgress.toast.checkpoint`,{milestone:r,k:e.nextChunk,n:e.totalChunks}),{id:t,duration:6e4,action:{label:N.t(`builder:milestoneProgress.toast.launchNext`),onClick:()=>{KF(o,e.id).then(e=>{e.ok?K.success(N.t(`builder:milestoneProgress.chain.nextLaunched`),{id:t}):K.error(N.t(`builder:milestoneProgress.chain.resumeFailed`),{id:t,description:e.detail??e.error})})}},cancel:{label:N.t(`builder:milestoneProgress.toast.autoContinue`),onClick:()=>{JF(o,e.id,!0).then(e=>{e.ok?K.success(N.t(`builder:milestoneProgress.chain.autoOn`),{id:t}):K.error(N.t(`builder:milestoneProgress.chain.autoFailed`),{id:t,description:e.detail??e.error})})}}})}e.status===`paused`&&(!n||n.status!==`paused`||n.pauseReason!==e.pauseReason)&&K.warning(N.t(`builder:milestoneProgress.toast.paused`,{milestone:r,reason:K1(e.pauseReason)}),{id:`chain-paused:${e.id}`,duration:3e4,action:{label:N.t(`builder:milestoneProgress.toast.resume`),onClick:()=>{KF(o,e.id).then(t=>{t.ok?K.success(N.t(`builder:milestoneProgress.chain.resumed`),{id:`chain-paused:${e.id}`}):K.error(N.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 Pt(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=Ft(e);K.success(N.t(`builder:milestoneProgress.toast.delivered`,{milestone:kt(e.n),count:e.counts.onReview}),{id:`milestone-delivered:${t}`,duration:3e4,...i?{action:{label:N.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`&&K.success(N.t(`builder:milestoneProgress.toast.completed`,{milestone:kt(t.n)}),{id:`milestone-completed:${o}:${t.milestoneId??t.n}`,duration:15e3})}),()=>s(e)},[o,s])}function J1(e){return e.startsWith(`/loops`)?`loops`:e.startsWith(`/plugins`)?`plugins`:Y1(e)?`review`:null}function Y1(e){let t=/^\/review\/([^/]+)\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function X1(e){let t=/^\/loops\/([^/]+)\/edit\/?$/.exec(e);return t?decodeURIComponent(t[1]):null}function Z1({uiMode:e,pathname:t,loopsOpen:n,pluginsOpen:r,reviewOpen:i=null}){if(e===`agent`){let e=J1(t);if(!e)return null;if(e===`review`)return{kind:`modalize`,surface:e,backgroundPath:`/`,reviewDeliveryId:Y1(t)??void 0};let n=e===`loops`?X1(t):null;return n?{kind:`modalize`,surface:`loops`,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 Q1=(0,Q.lazy)(()=>c(()=>import(`./JobDetailPage-P-FS_lKz.js`),__vite__mapDeps([97,1,7,45,10,9,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,8,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,93]))),$1=(0,Q.lazy)(()=>c(()=>import(`./ReviewPacketPage-Cktv0-9b.js`),__vite__mapDeps([98,1,7,45,10,42,43,8,9,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,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,99]))),e0=(0,Q.lazy)(()=>c(()=>import(`./JobsPage-CoUXgYse.js`),__vite__mapDeps([100,1,7,45,10,9,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,8,57,68,69,54,72,73,74,75,76,77,78,93,101,58,87]))),t0=(0,Q.lazy)(()=>c(()=>import(`./AnalyticsPage-Bser2Ly3.js`),__vite__mapDeps([102,1,7,45,10,9,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,47,43,8,48,50,74,76,77,101,58,103,84]))),n0=(0,Q.lazy)(()=>c(()=>import(`./ActivityFeedPage-B1bpTy7O.js`),__vite__mapDeps([104,1,7,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,8,55,57,62,71]))),r0=(0,Q.lazy)(()=>c(()=>import(`./AgentsPage-DKE-eMC5.js`),__vite__mapDeps([105,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,47,43,48,49,51,45,52,53,54,56,59,62,63,65,67,68,69,72,73,74,78,93]))),i0=(0,Q.lazy)(()=>c(()=>import(`./CodePage-BK0grm6e.js`),__vite__mapDeps([106,1,7,8,10,45,9,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,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,77,78,79,80]))),a0=(0,Q.lazy)(()=>c(()=>import(`./IntegrationsPage-EAipiDWm.js`),__vite__mapDeps([107,7,1,45,10]))),o0=(0,Q.lazy)(()=>c(()=>import(`./PluginsPage-BgTC2CQx.js`),__vite__mapDeps([108,1,7,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,8,48,58,59,62,67,68,69,70,72,54,73,74,78]))),s0=(0,Q.lazy)(()=>c(()=>import(`./DesktopAnalyticsPage-DEBidZbs.js`),__vite__mapDeps([109,1,7,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,74,73,103,8,84]))),c0=(0,Q.lazy)(()=>c(()=>import(`./DocsPage-BcEkPXd6.js`),__vite__mapDeps([110,1,7,45,10,42,56,62,73,74,75,86,111,112]))),l0=(0,Q.lazy)(()=>c(()=>import(`./DocsDialog-Dhyo57n9.js`),__vite__mapDeps([113,1,7,42,56,62,72,8,54,73,74,75,86,111,112]))),u0=(0,Q.lazy)(()=>c(()=>import(`./LoopWindowSurface-CLr5OPqj.js`).then(e=>({default:e.LoopWindowSurface})),__vite__mapDeps([114,1,7,43,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,115,45,48,58,59,63,64,65,66,53,68,116,72,54,73,74,78,79,80,89,60,117,49,69,83,84,85]))),d0=(0,Q.lazy)(()=>c(()=>import(`./LoopsPage-eKpWFtCp.js`),__vite__mapDeps([115,1,7,45,10,42,43,8,9,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,48,58,59,63,64,65,66,53,68,116,72,54,73,74,78,79,80,89,60]))),f0=(0,Q.lazy)(()=>c(()=>import(`./LoopBuilderPage-iFylNk68.js`),__vite__mapDeps([117,1,7,45,10,42,43,8,9,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,48,49,59,60,64,65,66,68,69,116,54,72,73,74,78,80,83,84,85]))),p0=28;function m0({surface:e,onClose:t}){let{t:n}=U(`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`?Fd:e===`review`?qc:ku,{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)(Vn,{className:`h-4 w-4`})})})]})}var h0=new Set([`/settings`,`/loops`,`/plugins`]);function g0(e){return h0.has(e)||e.startsWith(`/loops`)||e.startsWith(`/plugins`)||e.startsWith(`/docs`)}var _0=`specrails-desktop:routeMemory`;try{localStorage.removeItem(_0)}catch{}function v0(e){let t=p(),n=y(),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{rP((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&&!g0(t.pathname)&&r.current.set(i.current,t.pathname),e&&e!==i.current){let i=r.current.get(e),a=i&&!g0(i)?i:`/`;t.pathname!==a&&n(a,{replace:!0})}i.current=e},[e,t.pathname,n]),(0,Q.useEffect)(()=>{e&&t.pathname!==`/`&&!g0(t.pathname)&&r.current.set(e,t.pathname)},[e,t.pathname])}function y0(){let{t:e}=U(`common`),{projects:t,activeProjectId:n,isLoading:r,isSwitchingProject:i,setActiveProjectId:a}=ce(),{cycleLeftMode:o,cycleRightMode:s}=BZ(),c=y(),l=p(),u=Ya(),d=OL(),{uiMode:m}=eL();G1();let[g,v]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(`appearance`),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),M=(0,Q.useCallback)(()=>{D(!1),k(null)},[]),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(!1),ee=(0,Q.useCallback)(()=>I(!1),[]),[te,L]=(0,Q.useState)(()=>!EQ());v0(n),A1();let{cheatsheetOpen:R,setCheatsheetOpen:z,openCheatsheet:B}=TZ(),ne=[`/`,`/jobs`,`/analytics`,...lt?[`/agents`]:[],...Ke?[`/code`]:[],`/integrations`,`/settings`];wZ({onOpenCheatsheet:B,onToggleLeftSidebar:o,onToggleRightSidebar:s,onSwitchProject:e=>{let n=t[e-1];n&&a(n.id)},onSwitchProjectPage:e=>{let t=ne[e-1];t&&c(t)},onToggleTerminalPanel:rt?()=>{n&&(u.togglePanel(n),u.getState(n).visibility===`hidden`?queueMicrotask(()=>u.focusActive(n)):u.focusActive(n))}:void 0,onToggleAgentChat:$e&&m!==`agent`?()=>d.toggle():void 0}),hZ({setActiveProjectId:a,projectsById:(0,Q.useMemo)(()=>new Map(t.map(e=>[e.id,e.name])),[t])}),q1({setActiveProjectId:a}),(0,Q.useEffect)(()=>{BF()},[]);let V=t.find(e=>e.id===n),re=l.pathname.startsWith(`/loops`),ie=l.pathname.startsWith(`/plugins`),ae=l.pathname.startsWith(`/docs`)||m!==`agent`&&(re||ie);(0,Q.useLayoutEffect)(()=>{let e=Z1({uiMode:m,pathname:l.pathname,loopsOpen:E,pluginsOpen:A,reviewOpen:N});if(e){if(e.kind===`modalize`){if(e.surface===`review`){e.reviewDeliveryId&&P(e.reviewDeliveryId),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}if(e.surface===`loops`){j(!1),D(!0),k(e.loopBuilderId??null),l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}else M(),j(!0);l.pathname!==e.backgroundPath&&c(e.backgroundPath,{replace:!0});return}M(),j(!1),P(null),l.pathname!==e.path&&c(e.path,{replace:!0})}},[n,l.pathname,c,M,E,A,N,m]);let{connectionStatus:H}=I1(),W=Xa(n),G=p0,se=(0,Q.useRef)(null),[K,le]=(0,Q.useState)(typeof window<`u`?window.innerHeight:820);(0,Q.useLayoutEffect)(()=>{if(!rt)return;let e=se.current;if(!e)return;let t=()=>le(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r]),(0,Q.useEffect)(()=>{!rt||!n||u.ensureProject(n)},[n,u]);let ue=rt&&m===`kanban`&&W.visibility===`hidden`?(0,$.jsx)(jR,{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)(i$,{onOpenCompanion:()=>{x(`mobile`),C(!0)},onAddProject:()=>v(!0),onOpenLoops:()=>{m===`agent`?D(!0):c(`/loops`)},onOpenPlugins:()=>{m===`agent`?j(!0):c(`/plugins`)},onOpenAnalytics:()=>T(!0),onOpenDocs:()=>I(!0),onOpenSettings:()=>{x(`appearance`),C(!0)}}),(0,$.jsxs)(`div`,{ref:se,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:m===`agent`&&!ae?(0,$.jsx)(fR,{}):(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)(_,{children:[(0,$.jsx)(h,{path:`/docs`,element:(0,$.jsx)(c0,{})}),(0,$.jsx)(h,{path:`/docs/:category/:slug`,element:(0,$.jsx)(c0,{})}),st&&(0,$.jsx)(h,{path:`/loops`,element:(0,$.jsx)(d0,{})}),st&&(0,$.jsx)(h,{path:`/loops/:id/edit`,element:(0,$.jsx)(f0,{})}),(0,$.jsx)(h,{path:`/plugins`,element:(0,$.jsx)(o0,{})}),t.length===0?(0,$.jsx)(h,{path:`*`,element:(0,$.jsx)(CQ,{onAddProject:()=>v(!0)})}):V?(0,$.jsxs)(h,{element:(0,$.jsx)(SQ,{projectName:V.name,children:(0,$.jsx)(bQ,{project:V})},V.id),children:[(0,$.jsx)(h,{path:`/`,element:(0,$.jsx)(Yq,{})}),(0,$.jsx)(h,{path:`/jobs`,element:(0,$.jsx)(e0,{})}),(0,$.jsx)(h,{path:`/jobs/:id`,element:(0,$.jsx)(Q1,{})}),Ve&&(0,$.jsx)(h,{path:`/review/:prDeliveryId`,element:(0,$.jsx)($1,{})}),(0,$.jsx)(h,{path:`/analytics`,element:(0,$.jsx)(t0,{})}),(0,$.jsx)(h,{path:`/activity`,element:(0,$.jsx)(n0,{})}),(0,$.jsx)(h,{path:`/agents`,element:(0,$.jsx)(r0,{})}),(0,$.jsx)(h,{path:`/code`,element:Ke?(0,$.jsx)(i0,{}):(0,$.jsx)(f,{to:`/`,replace:!0})}),(0,$.jsx)(h,{path:`/integrations`,element:(0,$.jsx)(a0,{})}),(0,$.jsx)(h,{path:`/settings`,element:(0,$.jsx)(QJ,{})}),(0,$.jsx)(h,{path:`*`,element:(0,$.jsx)(f,{to:`/`,replace:!0})})]}):(0,$.jsx)(h,{path:`*`,element:(0,$.jsx)(CQ,{onAddProject:()=>v(!0)})})]})})}),rt&&n&&V&&(0,$.jsx)(QR,{projectId:n,provider:V.provider,providers:oe(V),state:W,viewportHeight:K,statusBarHeight:G}),(0,$.jsx)(H1,{connectionStatus:H,minimal:m===`agent`,rightSlot:m===`agent`?void 0:ue})]}),m===`agent`?!ae&&(0,$.jsx)(W1,{}):V&&!ae&&(0,$.jsx)(c$,{}),(0,$.jsx)(y$,{open:g,onClose:()=>v(!1),onOpenBuilder:()=>d.builderMode.enter()}),(0,$.jsx)(yZ,{initialSection:b,open:S,onClose:()=>C(!1),onOpenOnboarding:()=>{C(!1),L(!0)}}),(0,$.jsx)(vr,{open:w,onOpenChange:T,children:(0,$.jsx)(gr,{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)(s0,{})})})})}),(0,$.jsx)(vr,{open:E,onOpenChange:e=>{e||M()},children:(0,$.jsxs)(gr,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,"data-testid":`loops-modal`,children:[(0,$.jsx)(dr,{className:`sr-only`,children:e(`nav:arcSidebar.loops`)}),(0,$.jsx)(cr,{className:`sr-only`,children:e(`nav:globalSurfaceModal.loopsDescription`)}),(0,$.jsx)(m0,{surface:`loops`,onClose:M}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:O?(0,$.jsx)(f0,{loopId:O,onExit:()=>k(null),onWindowOpened:M}):(0,$.jsx)(d0,{onOpenBuilder:k,onWindowOpened:M})})})]})}),(0,$.jsx)(vr,{open:A,onOpenChange:j,children:(0,$.jsxs)(gr,{showCloseButton:!1,className:`max-w-[96vw] w-[96vw] h-[92vh] max-h-[92vh] overflow-hidden p-0 flex flex-col`,"data-testid":`plugins-modal`,children:[(0,$.jsx)(dr,{className:`sr-only`,children:e(`nav:arcSidebar.plugins`)}),(0,$.jsx)(cr,{className:`sr-only`,children:e(`nav:globalSurfaceModal.pluginsDescription`)}),(0,$.jsx)(m0,{surface:`plugins`,onClose:()=>j(!1)}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(o0,{onWindowOpened:()=>j(!1)})})})]})}),Ve&&(0,$.jsx)(vr,{open:N!==null,onOpenChange:e=>{e||P(null)},children:(0,$.jsxs)(gr,{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)(dr,{className:`sr-only`,children:e(`nav:arcSidebar.review`)}),(0,$.jsx)(cr,{className:`sr-only`,children:e(`nav:globalSurfaceModal.reviewDescription`)}),(0,$.jsx)(m0,{surface:`review`,onClose:()=>P(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:N&&(0,$.jsx)($1,{prDeliveryId:N,onClose:()=>P(null)})})})]})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(l0,{open:F,onClose:ee})}),(0,$.jsx)(w1,{onOpenSettings:()=>{x(`appearance`),C(!0)},onOpenAnalytics:()=>T(!0),onOpenDocs:()=>I(!0)}),(0,$.jsx)(AZ,{open:R,onOpenChange:z}),(0,$.jsx)(VQ,{open:te,onClose:()=>L(!1)})]})}function b0({children:e}){let{activeProjectId:t}=ce();return(0,$.jsx)(qa,{activeProjectId:t,children:e})}function x0({children:e}){let{activeProjectId:t}=ce();return(0,$.jsx)(fq,{activeProjectId:t,children:e})}function S0({children:e}){let{activeProjectId:t}=ce();return(0,$.jsx)(yq,{activeProjectId:t,children:e})}function C0(){return(0,$.jsx)(`span`,{"aria-hidden":!0,style:{display:`none`}})}function w0(){let{theme:e}=Ma(),t=e.previewSwatches.accents[0],n=e.status.completed,r=e.status.failed,i=e.status.canceled,a=e.status.running;return(0,BC.createPortal)((0,$.jsx)(se,{position:`bottom-right`,className:`specrails-toaster`,theme:e.scheme,gap:8,closeButton:!0,visibleToasts:6,icons:{loading:(0,$.jsx)(C0,{})},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 T0(){return gX(),null}function E0(){let e=wi();return P1(),Kr()||Ur()?(0,$.jsx)(ee,{url:We,children:(0,$.jsx)(ja,{children:(0,$.jsx)(bY,{children:(0,$.jsx)(le,{isolated:!0,children:(0,$.jsx)(QI,{initialMode:`agent`,persist:!1,children:(0,$.jsxs)(`div`,{className:`h-screen flex flex-col overflow-hidden`,children:[(0,$.jsx)(GZ,{}),(0,$.jsx)(Q.Suspense,{fallback:null,children:Ur()?(0,$.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,$.jsx)(o0,{})}):(0,$.jsx)(u0,{})}),(0,$.jsx)(w0,{})]})})})})})}):(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)(ee,{url:We,children:(0,$.jsx)(ja,{children:(0,$.jsxs)(bY,{children:[(0,$.jsx)(yQ,{}),(0,$.jsx)(le,{isolated:e,children:(0,$.jsxs)(QI,{initialMode:e?`agent`:void 0,persist:!e,children:[!e&&(0,$.jsx)(T0,{}),(0,$.jsx)(sW,{children:(0,$.jsx)(O1,{children:(0,$.jsx)(Pe,{children:(0,$.jsxs)(zZ,{children:[(0,$.jsx)(GZ,{}),(0,$.jsx)(b0,{children:(0,$.jsx)(x0,{children:(0,$.jsx)(S0,{children:(0,$.jsx)(yn,{children:(0,$.jsx)(uj,{children:(0,$.jsx)(ji,{secondary:e,children:(0,$.jsx)(EL,{children:(0,$.jsx)(Ej,{children:(0,$.jsx)(ct,{children:(0,$.jsxs)(et,{children:[(0,$.jsx)(AL,{}),(0,$.jsx)(Ld,{}),e?(0,$.jsx)($R,{}):(0,$.jsx)(y0,{}),(0,$.jsx)(YL,{}),(0,$.jsx)(w0,{})]})})})})})})})})})})]})})})})]})})]})})})})})}async function D0(){await te(),z(),await M(),(0,Hr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(v,{children:(0,$.jsx)(E0,{})})}));let e=document.getElementById(`specrails-splash`);e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(`is-hidden`),setTimeout(()=>e.remove(),300)})})}D0();export{fj as $,Us as $t,LH as A,xu as At,Bz as B,ll as Bt,EK as C,td as Ct,xK as D,Lu as Dt,SK as E,zu as Et,_H as F,zl as Ft,tP as G,kc as Gt,Tz as H,tl as Ht,UV as I,kl as It,ON as J,sc as Jt,QN as K,Dc as Kt,VB as L,Tl as Lt,uH as M,Zl as Mt,NH as N,Yl as Nt,lK as O,ku as Ot,kH as P,ql as Pt,gM as Q,qs as Qt,KB as R,xl as Rt,cq as S,rd as St,CK as T,Uu as Tt,OL as U,$c as Ut,Vz as V,sl as Vt,gF as W,qc as Wt,DN as X,rc as Xt,TN as Y,ac as Yt,_M as Z,Ys as Zt,sJ as _,xd as _t,RJ as a,Pa as an,oT as at,XK as b,ld as bt,yJ as c,qr as cn,IC as ct,wJ as d,NS as dt,zs as en,xA as et,gJ as f,PS as ft,uJ as g,kd as gt,pJ as h,jd as ht,XJ as i,Mo as in,nT as it,xH as j,tu as jt,JW as k,Tu as kt,bJ as l,Ur as ln,MC as lt,SJ as m,Fd as mt,ZJ as n,js as nn,IA as nt,JJ as o,Mi as on,qw as ot,xJ as p,HS as pt,EN as q,pc as qt,zJ as r,Cs as rn,lT as rt,FJ as s,Kr as sn,Kw as st,I1 as t,Ls as tn,SA as tt,CJ as u,Gr as un,US as ut,jq as v,_d as vt,TK as w,Zu as wt,lq as x,ad as xt,mq as y,pd as yt,Xz as z,yl as zt};
|