@straiffi/archon 1.1.2 → 1.1.3

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TestsDialog-F0VCXRNc.js","assets/rolldown-runtime-BYbx6iT9.js","assets/badge-BentDQnz.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TestsDialog-Buw5J9nT.js","assets/rolldown-runtime-BYbx6iT9.js","assets/badge-BentDQnz.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-BYbx6iT9.js";import{$ as a,A as o,At as s,B as c,C as l,Ct as u,D as d,Dt as f,E as p,Et as m,F as h,Ft as g,G as _,H as v,I as y,It as b,J as x,K as S,L as C,M as w,Mt as T,N as E,Nt as D,O,Ot as k,P as A,Pt as j,Q as M,R as N,S as P,St as F,T as I,Tt as L,U as R,V as ee,W as z,X as B,Y as V,Z as te,_ as ne,_t as re,a as ie,at as ae,b as oe,bt as se,c as H,ct as ce,d as U,dt as le,et as ue,f as W,ft as de,g as G,gt as fe,h as K,ht as q,i as pe,it as me,j as he,jt as ge,k as _e,kt as ve,l as ye,lt as be,m as xe,mt as Se,n as Ce,nt as we,o as Te,ot as Ee,p as De,pt as Oe,q as ke,r as Ae,rt as je,s as Me,st as Ne,t as J,tt as Pe,u as Fe,ut as Ie,v as Le,vt as Re,w as ze,wt as Be,x as Ve,xt as He,y as Ue,yt as We,z as Ge}from"./badge-BentDQnz.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 Ke=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}}}})),Y=i(((e,t)=>{t.exports=Ke()})),qe=i((e=>{var t=Y(),n=b(),r=g();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},R=[],ee=-1;function z(e){return{current:e}}function B(e){0>ee||(e.current=R[ee],R[ee]=null,ee--)}function V(e,t){ee++,R[ee]=e.current,e.current=t}var te=z(null),ne=z(null),re=z(null),ie=z(null);function ae(e,t){switch(V(re,t),V(ne,e),V(te,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(te),V(te,e)}function oe(){B(te),B(ne),B(re)}function se(e){e.memoizedState!==null&&V(ie,e);var t=te.current,n=Ud(t,e.type);t!==n&&(V(ne,e),V(te,n))}function H(e){ne.current===e&&(B(te),B(ne)),ie.current===e&&(B(ie),$f._currentValue=L)}var ce,U;function le(e){if(ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ce=t&&t[1]||``,U=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ce+e+U}var ue=!1;function W(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -7,7 +7,7 @@ import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-BYbx6iT9.js";import{$ as
7
7
  `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ue=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?le(n):``}function de(e,t){switch(e.tag){case 26:case 27:case 5:return le(e.type);case 16:return le(`Lazy`);case 13:return e.child!==t&&t!==null?le(`Suspense Fallback`):le(`Suspense`);case 19:return le(`SuspenseList`);case 0:case 15:return W(e.type,!1);case 11:return W(e.type.render,!1);case 1:return W(e.type,!0);case 31:return le(`Activity`);default:return``}}function G(e){try{var t=``,n=null;do t+=de(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
8
  Error generating stack: `+e.message+`
9
9
  `+e.stack}}var fe=Object.prototype.hasOwnProperty,K=t.unstable_scheduleCallback,q=t.unstable_cancelCallback,pe=t.unstable_shouldYield,me=t.unstable_requestPaint,he=t.unstable_now,ge=t.unstable_getCurrentPriorityLevel,_e=t.unstable_ImmediatePriority,ve=t.unstable_UserBlockingPriority,ye=t.unstable_NormalPriority,be=t.unstable_LowPriority,xe=t.unstable_IdlePriority,Se=t.log,Ce=t.unstable_setDisableYieldValue,we=null,Te=null;function Ee(e){if(typeof Se==`function`&&Ce(e),Te&&typeof Te.setStrictMode==`function`)try{Te.setStrictMode(we,e)}catch{}}var De=Math.clz32?Math.clz32:Ae,Oe=Math.log,ke=Math.LN2;function Ae(e){return e>>>=0,e===0?32:31-(Oe(e)/ke|0)|0}var je=256,Me=262144,Ne=4194304;function J(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Pe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=J(n))):i=J(o):i=J(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=J(n))):i=J(o)):i=J(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Fe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ie(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Le(){var e=Ne;return Ne<<=1,!(Ne&62914560)&&(Ne=4194304),e}function Re(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ze(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Be(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-De(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Ve(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Ve(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-De(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function He(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-De(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ue(e,t){var n=t&-t;return n=n&42?1:We(n),(n&(e.suspendedLanes|t))===0?n:0}function We(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ge(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ke(){var e=I.p;return e===0?(e=window.event,e===void 0?32:hp(e.type)):e}function qe(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}var Je=Math.random().toString(36).slice(2),X=`__reactFiber$`+Je,Ye=`__reactProps$`+Je,Xe=`__reactContainer$`+Je,Ze=`__reactEvents$`+Je,Qe=`__reactListeners$`+Je,$e=`__reactHandles$`+Je,et=`__reactResources$`+Je,tt=`__reactMarker$`+Je;function nt(e){delete e[X],delete e[Ye],delete e[Ze],delete e[Qe],delete e[$e]}function rt(e){var t=e[X];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Xe]||n[X]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=ff(e);e!==null;){if(n=e[X])return n;e=ff(e)}return t}e=n,n=e.parentNode}return null}function it(e){if(e=e[X]||e[Xe]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function at(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function ot(e){var t=e[et];return t||=e[et]={hoistableStyles:new Map,hoistableScripts:new Map},t}function st(e){e[tt]=!0}var ct=new Set,lt={};function ut(e,t){dt(e,t),dt(e+`Capture`,t)}function dt(e,t){for(lt[e]=t,e=0;e<t.length;e++)ct.add(t[e])}var ft=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),pt={},mt={};function ht(e){return fe.call(mt,e)?!0:fe.call(pt,e)?!1:ft.test(e)?mt[e]=!0:(pt[e]=!0,!1)}function gt(e,t,n){if(ht(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function _t(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function vt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function yt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function bt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function xt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function St(e){if(!e._valueTracker){var t=bt(e)?`checked`:`value`;e._valueTracker=xt(e,t,``+e[t])}}function Ct(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=bt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function wt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Tt=/[\n"\\]/g;function Et(e){return e.replace(Tt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Dt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+yt(t)):e.value!==``+yt(t)&&(e.value=``+yt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):kt(e,o,yt(n)):kt(e,o,yt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+yt(s):e.removeAttribute(`name`)}function Ot(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){St(e);return}n=n==null?``:``+yt(n),t=t==null?n:``+yt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),St(e)}function kt(e,t,n){t===`number`&&wt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function At(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+yt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function jt(e,t,n){if(t!=null&&(t=``+yt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+yt(n)}function Mt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(P(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=yt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),St(e)}function Nt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Ft(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Pt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function It(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Ft(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Ft(e,o,t[o])}function Lt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Rt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),zt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Bt(e){return zt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Vt(){}var Ht=null;function Ut(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Wt=null,Gt=null;function Kt(e){var t=it(e);if(t&&(e=t.stateNode)){var n=e[Ye]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Dt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Et(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Ye]||null;if(!a)throw Error(i(90));Dt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Ct(r)}break a;case`textarea`:jt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&At(e,!!n.multiple,t,!1)}}}var qt=!1;function Jt(e,t,n){if(qt)return e(t,n);qt=!0;try{return e(t)}finally{if(qt=!1,(Wt!==null||Gt!==null)&&(yu(),Wt&&(t=Wt,e=Gt,Gt=Wt=null,Kt(t),e)))for(t=0;t<e.length;t++)Kt(e[t])}}function Yt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Ye]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Z=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),Xt=!1;if(Z)try{var Zt={};Object.defineProperty(Zt,`passive`,{get:function(){Xt=!0}}),window.addEventListener(`test`,Zt,Zt),window.removeEventListener(`test`,Zt,Zt)}catch{Xt=!1}var Qt=null,$t=null,en=null;function tn(){if(en)return en;var e,t=$t,n=t.length,r,i=`value`in Qt?Qt.value:Qt.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return en=i.slice(e,1<r?1-r:void 0)}function nn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function rn(){return!0}function an(){return!1}function on(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?rn:an,this.isPropagationStopped=an,this}return f(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=rn)},persist:function(){},isPersistent:rn}),t}var sn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cn=on(sn),ln=f({},sn,{view:0,detail:0}),un=on(ln),dn,fn,pn,mn=f({},ln,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==pn&&(pn&&e.type===`mousemove`?(dn=e.screenX-pn.screenX,fn=e.screenY-pn.screenY):fn=dn=0,pn=e),dn)},movementY:function(e){return`movementY`in e?e.movementY:fn}}),hn=on(mn),gn=on(f({},mn,{dataTransfer:0})),_n=on(f({},ln,{relatedTarget:0})),vn=on(f({},sn,{animationName:0,elapsedTime:0,pseudoElement:0})),yn=on(f({},sn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),bn=on(f({},sn,{data:0})),xn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Sn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Cn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function wn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Cn[e])?!!t[e]:!1}function Tn(){return wn}var En=on(f({},ln,{key:function(e){if(e.key){var t=xn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=nn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Sn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tn,charCode:function(e){return e.type===`keypress`?nn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?nn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Dn=on(f({},mn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),On=on(f({},ln,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tn})),kn=on(f({},sn,{propertyName:0,elapsedTime:0,pseudoElement:0})),An=on(f({},mn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),jn=on(f({},sn,{newState:0,oldState:0})),Mn=[9,13,27,32],Nn=Z&&`CompositionEvent`in window,Pn=null;Z&&`documentMode`in document&&(Pn=document.documentMode);var Fn=Z&&`TextEvent`in window&&!Pn,In=Z&&(!Nn||Pn&&8<Pn&&11>=Pn),Ln=` `,Rn=!1;function zn(e,t){switch(e){case`keyup`:return Mn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Bn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Vn=!1;function Hn(e,t){switch(e){case`compositionend`:return Bn(t);case`keypress`:return t.which===32?(Rn=!0,Ln):null;case`textInput`:return e=t.data,e===Ln&&Rn?null:e;default:return null}}function Un(e,t){if(Vn)return e===`compositionend`||!Nn&&zn(e,t)?(e=tn(),en=$t=Qt=null,Vn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return In&&t.locale!==`ko`?null:t.data;default:return null}}var Wn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Gn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Wn[e.type]:t===`textarea`}function Kn(e,t,n,r){Wt?Gt?Gt.push(r):Gt=[r]:Wt=r,t=Ed(t,`onChange`),0<t.length&&(n=new cn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var qn=null,Jn=null;function Yn(e){vd(e,0)}function Xn(e){if(Ct(at(e)))return e}function Zn(e,t){if(e===`change`)return t}var Qn=!1;if(Z){var $n;if(Z){var er=`oninput`in document;if(!er){var tr=document.createElement(`div`);tr.setAttribute(`oninput`,`return;`),er=typeof tr.oninput==`function`}$n=er}else $n=!1;Qn=$n&&(!document.documentMode||9<document.documentMode)}function nr(){qn&&(qn.detachEvent(`onpropertychange`,rr),Jn=qn=null)}function rr(e){if(e.propertyName===`value`&&Xn(Jn)){var t=[];Kn(t,Jn,e,Ut(e)),Jt(Yn,t)}}function ir(e,t,n){e===`focusin`?(nr(),qn=t,Jn=n,qn.attachEvent(`onpropertychange`,rr)):e===`focusout`&&nr()}function ar(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Xn(Jn)}function or(e,t){if(e===`click`)return Xn(t)}function sr(e,t){if(e===`input`||e===`change`)return Xn(t)}function cr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var lr=typeof Object.is==`function`?Object.is:cr;function ur(e,t){if(lr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!fe.call(t,i)||!lr(e[i],t[i]))return!1}return!0}function dr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fr(e,t){var n=dr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=dr(n)}}function pr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?pr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function mr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=wt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=wt(e.document)}return t}function hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var gr=Z&&`documentMode`in document&&11>=document.documentMode,_r=null,vr=null,yr=null,br=!1;function xr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;br||_r==null||_r!==wt(r)||(r=_r,`selectionStart`in r&&hr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),yr&&ur(yr,r)||(yr=r,r=Ed(vr,`onSelect`),0<r.length&&(t=new cn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=_r)))}function Sr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Cr={animationend:Sr(`Animation`,`AnimationEnd`),animationiteration:Sr(`Animation`,`AnimationIteration`),animationstart:Sr(`Animation`,`AnimationStart`),transitionrun:Sr(`Transition`,`TransitionRun`),transitionstart:Sr(`Transition`,`TransitionStart`),transitioncancel:Sr(`Transition`,`TransitionCancel`),transitionend:Sr(`Transition`,`TransitionEnd`)},wr={},Tr={};Z&&(Tr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Cr.animationend.animation,delete Cr.animationiteration.animation,delete Cr.animationstart.animation),`TransitionEvent`in window||delete Cr.transitionend.transition);function Er(e){if(wr[e])return wr[e];if(!Cr[e])return e;var t=Cr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Tr)return wr[e]=t[n];return e}var Dr=Er(`animationend`),Or=Er(`animationiteration`),kr=Er(`animationstart`),Ar=Er(`transitionrun`),jr=Er(`transitionstart`),Mr=Er(`transitioncancel`),Nr=Er(`transitionend`),Pr=new Map,Fr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Fr.push(`scrollEnd`);function Ir(e,t){Pr.set(e,t),ut(t,[e])}var Lr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Rr=[],zr=0,Br=0;function Vr(){for(var e=zr,t=Br=zr=0;t<e;){var n=Rr[t];Rr[t++]=null;var r=Rr[t];Rr[t++]=null;var i=Rr[t];Rr[t++]=null;var a=Rr[t];if(Rr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Gr(n,i,a)}}function Hr(e,t,n,r){Rr[zr++]=e,Rr[zr++]=t,Rr[zr++]=n,Rr[zr++]=r,Br|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Ur(e,t,n,r){return Hr(e,t,n,r),Kr(e)}function Wr(e,t){return Hr(e,null,null,t),Kr(e)}function Gr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-De(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Kr(e){if(50<uu)throw uu=0,du=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var qr={};function Jr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yr(e,t,n,r){return new Jr(e,t,n,r)}function Xr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zr(e,t){var n=e.alternate;return n===null?(n=Yr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Qr(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function $r(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Xr(e)&&(s=1);else if(typeof e==`string`)s=Wf(e,n,te.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case O:return e=Yr(31,n,t,a),e.elementType=O,e.lanes=o,e;case _:return ei(n.children,a,o,t);case v:s=8,a|=24;break;case y:return e=Yr(12,n,t,a|2),e.elementType=y,e.lanes=o,e;case w:return e=Yr(13,n,t,a),e.elementType=w,e.lanes=o,e;case T:return e=Yr(19,n,t,a),e.elementType=T,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case S:s=10;break a;case x:s=9;break a;case C:s=11;break a;case E:s=14;break a;case D:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Yr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ei(e,t,n,r){return e=Yr(7,e,r,t),e.lanes=n,e}function ti(e,t,n){return e=Yr(6,e,null,t),e.lanes=n,e}function ni(e){var t=Yr(18,null,null,0);return t.stateNode=e,t}function ri(e,t,n){return t=Yr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ii=new WeakMap;function ai(e,t){if(typeof e==`object`&&e){var n=ii.get(e);return n===void 0?(t={value:e,source:t,stack:G(t)},ii.set(e,t),t):n}return{value:e,source:t,stack:G(t)}}var oi=[],si=0,ci=null,li=0,ui=[],di=0,fi=null,pi=1,mi=``;function hi(e,t){oi[si++]=li,oi[si++]=ci,ci=e,li=t}function gi(e,t,n){ui[di++]=pi,ui[di++]=mi,ui[di++]=fi,fi=e;var r=pi;e=mi;var i=32-De(r)-1;r&=~(1<<i),n+=1;var a=32-De(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,pi=1<<32-De(t)+i|n<<i|r,mi=a+e}else pi=1<<a|n<<i|r,mi=e}function _i(e){e.return!==null&&(hi(e,1),gi(e,1,0))}function vi(e){for(;e===ci;)ci=oi[--si],oi[si]=null,li=oi[--si],oi[si]=null;for(;e===fi;)fi=ui[--di],ui[di]=null,mi=ui[--di],ui[di]=null,pi=ui[--di],ui[di]=null}function yi(e,t){ui[di++]=pi,ui[di++]=mi,ui[di++]=fi,pi=t.id,mi=t.overflow,fi=e}var bi=null,xi=null,Si=!1,Ci=null,wi=!1,Ti=Error(i(519));function Ei(e){throw Mi(ai(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ti}function Di(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[X]=e,t[Ye]=r,n){case`dialog`:yd(`cancel`,t),yd(`close`,t);break;case`iframe`:case`object`:case`embed`:yd(`load`,t);break;case`video`:case`audio`:for(n=0;n<gd.length;n++)yd(gd[n],t);break;case`source`:yd(`error`,t);break;case`img`:case`image`:case`link`:yd(`error`,t),yd(`load`,t);break;case`details`:yd(`toggle`,t);break;case`input`:yd(`invalid`,t),Ot(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:yd(`invalid`,t);break;case`textarea`:yd(`invalid`,t),Mt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Md(t.textContent,n)?(r.popover!=null&&(yd(`beforetoggle`,t),yd(`toggle`,t)),r.onScroll!=null&&yd(`scroll`,t),r.onScrollEnd!=null&&yd(`scrollend`,t),r.onClick!=null&&(t.onclick=Vt),t=!0):t=!1,t||Ei(e,!0)}function Oi(e){for(bi=e.return;bi;)switch(bi.tag){case 5:case 31:case 13:wi=!1;return;case 27:case 3:wi=!0;return;default:bi=bi.return}}function ki(e){if(e!==bi)return!1;if(!Si)return Oi(e),Si=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Wd(e.type,e.memoizedProps)),n=!n),n&&xi&&Ei(e),Oi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));xi=df(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));xi=df(e)}else t===27?(t=xi,Qd(e.type)?(e=uf,uf=null,xi=e):xi=t):xi=bi?lf(e.stateNode.nextSibling):null;return!0}function Ai(){xi=bi=null,Si=!1}function ji(){var e=Ci;return e!==null&&(Xl===null?Xl=e:Xl.push.apply(Xl,e),Ci=null),e}function Mi(e){Ci===null?Ci=[e]:Ci.push(e)}var Ni=z(null),Pi=null,Fi=null;function Ii(e,t,n){V(Ni,t._currentValue),t._currentValue=n}function Li(e){e._currentValue=Ni.current,B(Ni)}function Ri(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function zi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Ri(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Ri(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Bi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;lr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ie.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[$f]:e.push($f))}a=a.return}e!==null&&zi(t,e,n,r),t.flags|=262144}function Vi(e){for(e=e.firstContext;e!==null;){if(!lr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Hi(e){Pi=e,Fi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ui(e){return Gi(Pi,e)}function Wi(e,t){return Pi===null&&Hi(e),Gi(e,t)}function Gi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Fi===null){if(e===null)throw Error(i(308));Fi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Fi=Fi.next=t;return n}var Ki=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},qi=t.unstable_scheduleCallback,Ji=t.unstable_NormalPriority,Yi={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Xi(){return{controller:new Ki,data:new Map,refCount:0}}function Zi(e){e.refCount--,e.refCount===0&&qi(Ji,function(){e.controller.abort()})}var Qi=null,$i=0,ea=0,ta=null;function na(e,t){if(Qi===null){var n=Qi=[];$i=0,ea=ud(),ta={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return $i++,t.then(ra,ra),t}function ra(){if(--$i===0&&Qi!==null){ta!==null&&(ta.status=`fulfilled`);var e=Qi;Qi=null,ea=0,ta=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ia(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var aa=F.S;F.S=function(e,t){$l=he(),typeof t==`object`&&t&&typeof t.then==`function`&&na(e,t),aa!==null&&aa(e,t)};var oa=z(null);function sa(){var e=oa.current;return e===null?Pl.pooledCache:e}function ca(e,t){t===null?V(oa,oa.current):V(oa,t.pool)}function la(){var e=sa();return e===null?null:{parent:Yi._currentValue,pool:e}}var ua=Error(i(460)),da=Error(i(474)),fa=Error(i(542)),pa={then:function(){}};function ma(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ha(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Vt,Vt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ya(e),e;default:if(typeof t.status==`string`)t.then(Vt,Vt);else{if(e=Pl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ya(e),e}throw _a=t,ua}}function ga(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(_a=e,ua):e}}var _a=null;function va(){if(_a===null)throw Error(i(459));var e=_a;return _a=null,e}function ya(e){if(e===ua||e===fa)throw Error(i(483))}var ba=null,xa=0;function Sa(e){var t=xa;return xa+=1,ba===null&&(ba=[]),ha(ba,e,t)}function Ca(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function wa(e,t){throw t.$$typeof===p?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ta(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Zr(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ti(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===_?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===D&&ga(i)===t.type)?(t=a(t,n.props),Ca(t,n),t.return=e,t):(t=$r(n.type,n.key,n.props,null,e.mode,r),Ca(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ri(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=ei(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ti(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case m:return n=$r(t.type,t.key,t.props,null,e.mode,n),Ca(n,t),n.return=e,n;case h:return t=ri(t,e.mode,n),t.return=e,t;case D:return t=ga(t),f(e,t,n)}if(P(t)||j(t))return t=ei(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Sa(t),n);if(t.$$typeof===S)return f(e,Wi(e,t),n);wa(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case m:return n.key===i?l(e,t,n,r):null;case h:return n.key===i?u(e,t,n,r):null;case D:return n=ga(n),p(e,t,n,r)}if(P(n)||j(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Sa(n),r);if(n.$$typeof===S)return p(e,t,Wi(e,n),r);wa(e,n)}return null}function g(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case m:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case h:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case D:return r=ga(r),g(e,t,n,r,i)}if(P(r)||j(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return g(e,t,n,Sa(r),i);if(r.$$typeof===S)return g(e,t,n,Wi(t,r),i);wa(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,m=a=0,h=null;d!==null&&m<s.length;m++){d.index>m?(h=d,d=null):h=d.sibling;var _=p(i,d,s[m],c);if(_===null){d===null&&(d=h);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,m),u===null?l=_:u.sibling=_,u=_,d=h}if(m===s.length)return n(i,d),Si&&hi(i,m),l;if(d===null){for(;m<s.length;m++)d=f(i,s[m],c),d!==null&&(a=o(d,a,m),u===null?l=d:u.sibling=d,u=d);return Si&&hi(i,m),l}for(d=r(d);m<s.length;m++)h=g(d,i,m,s[m],c),h!==null&&(e&&h.alternate!==null&&d.delete(h.key===null?m:h.key),a=o(h,a,m),u===null?l=h:u.sibling=h,u=h);return e&&d.forEach(function(e){return t(i,e)}),Si&&hi(i,m),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,m=s,h=s=0,_=null,v=c.next();m!==null&&!v.done;h++,v=c.next()){m.index>h?(_=m,m=null):_=m.sibling;var y=p(a,m,v.value,l);if(y===null){m===null&&(m=_);break}e&&m&&y.alternate===null&&t(a,m),s=o(y,s,h),d===null?u=y:d.sibling=y,d=y,m=_}if(v.done)return n(a,m),Si&&hi(a,h),u;if(m===null){for(;!v.done;h++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return Si&&hi(a,h),u}for(m=r(m);!v.done;h++,v=c.next())v=g(m,a,h,v.value,l),v!==null&&(e&&v.alternate!==null&&m.delete(v.key===null?h:v.key),s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(a,e)}),Si&&hi(a,h),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===_&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case m:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===_){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===D&&ga(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ca(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===_?(c=ei(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=$r(o.type,o.key,o.props,null,e.mode,c),Ca(c,o),c.return=e,e=c)}return s(e);case h:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ri(o,e.mode,c),c.return=e,e=c}return s(e);case D:return o=ga(o),b(e,r,o,c)}if(P(o))return v(e,r,o,c);if(j(o)){if(l=j(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Sa(o),c);if(o.$$typeof===S)return b(e,r,Wi(e,o),c);wa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ti(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{xa=0;var i=b(e,t,n,r);return ba=null,i}catch(t){if(t===ua||t===fa)throw t;var a=Yr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ea=Ta(!0),Da=Ta(!1),Oa=!1;function ka(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Aa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ja(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ma(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Nl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Kr(e),Gr(e,null,n),t}return Hr(e,r,t,n),Kr(e)}function Na(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,He(e,n)}}function Pa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Fa=!1;function Ia(){if(Fa){var e=ta;if(e!==null)throw e}}function La(e,t,n,r){Fa=!1;var i=e.updateQueue;Oa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(Il&p)===p:(r&p)===p){p!==0&&p===ea&&(Fa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Oa=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Wl|=o,e.lanes=o,e.memoizedState=d}}function Ra(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function za(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ra(n[e],t)}var Ba=z(null),Va=z(0);function Ha(e,t){e=Hl,V(Va,e),V(Ba,t),Hl=e|t.baseLanes}function Ua(){V(Va,Hl),V(Ba,Ba.current)}function Wa(){Hl=Va.current,B(Ba),B(Va)}var Ga=z(null),Ka=null;function qa(e){var t=e.alternate;V(Qa,Qa.current&1),V(Ga,e),Ka===null&&(t===null||Ba.current!==null||t.memoizedState!==null)&&(Ka=e)}function Ja(e){V(Qa,Qa.current),V(Ga,e),Ka===null&&(Ka=e)}function Ya(e){e.tag===22?(V(Qa,Qa.current),V(Ga,e),Ka===null&&(Ka=e)):Xa(e)}function Xa(){V(Qa,Qa.current),V(Ga,Ga.current)}function Za(e){B(Ga),Ka===e&&(Ka=null),B(Qa)}var Qa=z(0);function $a(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||of(n)||sf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var eo=0,to=null,no=null,ro=null,io=!1,ao=!1,oo=!1,so=0,co=0,lo=null,uo=0;function fo(){throw Error(i(321))}function po(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!lr(e[n],t[n]))return!1;return!0}function mo(e,t,n,r,i,a){return eo=a,to=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,F.H=e===null||e.memoizedState===null?js:Ms,oo=!1,a=n(r,i),oo=!1,ao&&(a=go(t,n,r,i)),ho(e),a}function ho(e){F.H=As;var t=no!==null&&no.next!==null;if(eo=0,ro=no=to=null,io=!1,co=0,lo=null,t)throw Error(i(300));e===null||Ys||(e=e.dependencies,e!==null&&Vi(e)&&(Ys=!0))}function go(e,t,n,r){to=e;var a=0;do{if(ao&&(lo=null),co=0,ao=!1,25<=a)throw Error(i(301));if(a+=1,ro=no=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}F.H=Ns,o=t(n,r)}while(ao);return o}function _o(){var e=F.H,t=e.useState()[0];return t=typeof t.then==`function`?wo(t):t,e=e.useState()[0],(no===null?null:no.memoizedState)!==e&&(to.flags|=1024),t}function vo(){var e=so!==0;return so=0,e}function yo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function bo(e){if(io){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}io=!1}eo=0,ro=no=to=null,ao=!1,co=so=0,lo=null}function xo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ro===null?to.memoizedState=ro=e:ro=ro.next=e,ro}function So(){if(no===null){var e=to.alternate;e=e===null?null:e.memoizedState}else e=no.next;var t=ro===null?to.memoizedState:ro.next;if(t!==null)ro=t,no=e;else{if(e===null)throw to.alternate===null?Error(i(467)):Error(i(310));no=e,e={memoizedState:no.memoizedState,baseState:no.baseState,baseQueue:no.baseQueue,queue:no.queue,next:null},ro===null?to.memoizedState=ro=e:ro=ro.next=e}return ro}function Co(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(e){var t=co;return co+=1,lo===null&&(lo=[]),e=ha(lo,e,t),t=to,(ro===null?t.memoizedState:ro.next)===null&&(t=t.alternate,F.H=t===null||t.memoizedState===null?js:Ms),e}function To(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return wo(e);if(e.$$typeof===S)return Ui(e)}throw Error(i(438,String(e)))}function Eo(e){var t=null,n=to.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=to.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Co(),to.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=k;return t.index++,n}function Do(e,t){return typeof t==`function`?t(e):t}function Oo(e){return ko(So(),no,e)}function ko(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(eo&f)===f:(Il&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ea&&(d=!0);else if((eo&p)===p){u=u.next,p===ea&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,to.lanes|=p,Wl|=p;f=u.action,oo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,to.lanes|=f,Wl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!lr(o,e.memoizedState)&&(Ys=!0,d&&(n=ta,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Ao(e){var t=So(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);lr(o,t.memoizedState)||(Ys=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function jo(e,t,n){var r=to,a=So(),o=Si;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!lr((no||a).memoizedState,n);if(s&&(a.memoizedState=n,Ys=!0),a=a.queue,ns(Po.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||ro!==null&&ro.memoizedState.tag&1){if(r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,a,n,t),null),Pl===null)throw Error(i(349));o||eo&127||Mo(r,t,n)}return n}function Mo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=to.updateQueue,t===null?(t=Co(),to.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function No(e,t,n,r){t.value=n,t.getSnapshot=r,Fo(t)&&Io(e)}function Po(e,t,n){return n(function(){Fo(t)&&Io(e)})}function Fo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!lr(e,n)}catch{return!0}}function Io(e){var t=Wr(e,2);t!==null&&mu(t,e,2)}function Lo(e){var t=xo();if(typeof e==`function`){var n=e;if(e=n(),oo){Ee(!0);try{n()}finally{Ee(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:e},t}function Ro(e,t,n,r){return e.baseState=n,ko(e,no,typeof r==`function`?r:Do)}function zo(e,t,n,r,a){if(Ds(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};F.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Bo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Bo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=F.T,o={};F.T=o;try{var s=n(i,r),c=F.S;c!==null&&c(o,s),Vo(e,t,s)}catch(n){Uo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),F.T=a}}else try{a=n(i,r),Vo(e,t,a)}catch(n){Uo(e,t,n)}}function Vo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ho(e,t,n)},function(n){return Uo(e,t,n)}):Ho(e,t,n)}function Ho(e,t,n){t.status=`fulfilled`,t.value=n,Wo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Bo(e,n)))}function Uo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Wo(t),t=t.next;while(t!==r)}e.action=null}function Wo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Go(e,t){return t}function Ko(e,t){if(Si){var n=Pl.formState;if(n!==null){a:{var r=to;if(Si){if(xi){b:{for(var i=xi,a=wi;i.nodeType!==8;){if(!a){i=null;break b}if(i=lf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){xi=lf(i.nextSibling),r=i.data===`F!`;break a}}Ei(r)}r=!1}r&&(t=n[0])}}return n=xo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Go,lastRenderedState:t},n.queue=r,n=ws.bind(null,to,r),r.dispatch=n,r=Lo(!1),a=Es.bind(null,to,!1,r.queue),r=xo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=zo.bind(null,to,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function qo(e){return Jo(So(),no,e)}function Jo(e,t,n){if(t=ko(e,t,Go)[0],e=Oo(Do)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=wo(t)}catch(e){throw e===ua?fa:e}else r=t;t=So();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(to.flags|=2048,Zo(9,{destroy:void 0},Yo.bind(null,i,n),null)),[r,a,e]}function Yo(e,t){e.action=t}function Xo(e){var t=So(),n=no;if(n!==null)return Jo(t,n,e);So(),t=t.memoizedState,n=So();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Zo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=to.updateQueue,t===null&&(t=Co(),to.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Qo(){return So().memoizedState}function $o(e,t,n,r){var i=xo();to.flags|=e,i.memoizedState=Zo(1|t,{destroy:void 0},n,r===void 0?null:r)}function es(e,t,n,r){var i=So();r=r===void 0?null:r;var a=i.memoizedState.inst;no!==null&&r!==null&&po(r,no.memoizedState.deps)?i.memoizedState=Zo(t,a,n,r):(to.flags|=e,i.memoizedState=Zo(1|t,a,n,r))}function ts(e,t){$o(8390656,8,e,t)}function ns(e,t){es(2048,8,e,t)}function rs(e){to.flags|=4;var t=to.updateQueue;if(t===null)t=Co(),to.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function is(e){var t=So().memoizedState;return rs({ref:t,nextImpl:e}),function(){if(Nl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function as(e,t){return es(4,2,e,t)}function os(e,t){return es(4,4,e,t)}function ss(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function cs(e,t,n){n=n==null?null:n.concat([e]),es(4,4,ss.bind(null,t,e),n)}function ls(){}function us(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&po(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ds(e,t){var n=So();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&po(t,r[1]))return r[0];if(r=e(),oo){Ee(!0);try{e()}finally{Ee(!1)}}return n.memoizedState=[r,t],r}function fs(e,t,n){return n===void 0||eo&1073741824&&!(Il&261930)?e.memoizedState=t:(e.memoizedState=n,e=pu(),to.lanes|=e,Wl|=e,n)}function ps(e,t,n,r){return lr(n,t)?n:Ba.current===null?!(eo&42)||eo&1073741824&&!(Il&261930)?(Ys=!0,e.memoizedState=n):(e=pu(),to.lanes|=e,Wl|=e,t):(e=fs(e,n,r),lr(e,t)||(Ys=!0),e)}function ms(e,t,n,r,i){var a=I.p;I.p=a!==0&&8>a?a:8;var o=F.T,s={};F.T=s,Es(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ts(e,t,ia(c,r),fu(e)):Ts(e,t,r,fu(e))}catch(n){Ts(e,t,{then:function(){},status:`rejected`,reason:n},fu())}finally{I.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.T=o}}function hs(){}function gs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=_s(e).queue;ms(e,a,t,L,n===null?hs:function(){return vs(e),n(r)})}function _s(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:L,baseState:L,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:L},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Do,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function vs(e){var t=_s(e);t.next===null&&(t=e.alternate.memoizedState),Ts(e,t.next.queue,{},fu())}function ys(){return Ui($f)}function bs(){return So().memoizedState}function xs(){return So().memoizedState}function Ss(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=fu();e=ja(n);var r=Ma(t,e,n);r!==null&&(mu(r,t,n),Na(r,t,n)),t={cache:Xi()},e.payload=t;return}t=t.return}}function Cs(e,t,n){var r=fu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ds(e)?Os(t,n):(n=Ur(e,t,n,r),n!==null&&(mu(n,e,r),ks(n,t,r)))}function ws(e,t,n){Ts(e,t,n,fu())}function Ts(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ds(e))Os(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,lr(s,o))return Hr(e,t,i,0),Pl===null&&Vr(),!1}catch{}if(n=Ur(e,t,i,r),n!==null)return mu(n,e,r),ks(n,t,r),!0}return!1}function Es(e,t,n,r){if(r={lane:2,revertLane:ud(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ds(e)){if(t)throw Error(i(479))}else t=Ur(e,n,r,2),t!==null&&mu(t,e,2)}function Ds(e){var t=e.alternate;return e===to||t!==null&&t===to}function Os(e,t){ao=io=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ks(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,He(e,n)}}var As={readContext:Ui,use:To,useCallback:fo,useContext:fo,useEffect:fo,useImperativeHandle:fo,useLayoutEffect:fo,useInsertionEffect:fo,useMemo:fo,useReducer:fo,useRef:fo,useState:fo,useDebugValue:fo,useDeferredValue:fo,useTransition:fo,useSyncExternalStore:fo,useId:fo,useHostTransitionStatus:fo,useFormState:fo,useActionState:fo,useOptimistic:fo,useMemoCache:fo,useCacheRefresh:fo};As.useEffectEvent=fo;var js={readContext:Ui,use:To,useCallback:function(e,t){return xo().memoizedState=[e,t===void 0?null:t],e},useContext:Ui,useEffect:ts,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),$o(4194308,4,ss.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $o(4194308,4,e,t)},useInsertionEffect:function(e,t){$o(4,2,e,t)},useMemo:function(e,t){var n=xo();t=t===void 0?null:t;var r=e();if(oo){Ee(!0);try{e()}finally{Ee(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=xo();if(n!==void 0){var i=n(t);if(oo){Ee(!0);try{n(t)}finally{Ee(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Cs.bind(null,to,e),[r.memoizedState,e]},useRef:function(e){var t=xo();return e={current:e},t.memoizedState=e},useState:function(e){e=Lo(e);var t=e.queue,n=ws.bind(null,to,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ls,useDeferredValue:function(e,t){return fs(xo(),e,t)},useTransition:function(){var e=Lo(!1);return e=ms.bind(null,to,e.queue,!0,!1),xo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=to,a=xo();if(Si){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Pl===null)throw Error(i(349));Il&127||Mo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ts(Po.bind(null,r,o,e),[e]),r.flags|=2048,Zo(9,{destroy:void 0},No.bind(null,r,o,n,t),null),n},useId:function(){var e=xo(),t=Pl.identifierPrefix;if(Si){var n=mi,r=pi;n=(r&~(1<<32-De(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=so++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=uo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ys,useFormState:Ko,useActionState:Ko,useOptimistic:function(e){var t=xo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Es.bind(null,to,!0,n),n.dispatch=t,[e,t]},useMemoCache:Eo,useCacheRefresh:function(){return xo().memoizedState=Ss.bind(null,to)},useEffectEvent:function(e){var t=xo(),n={impl:e};return t.memoizedState=n,function(){if(Nl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ms={readContext:Ui,use:To,useCallback:us,useContext:Ui,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Oo,useRef:Qo,useState:function(){return Oo(Do)},useDebugValue:ls,useDeferredValue:function(e,t){return ps(So(),no.memoizedState,e,t)},useTransition:function(){var e=Oo(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:qo,useActionState:qo,useOptimistic:function(e,t){return Ro(So(),no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ms.useEffectEvent=is;var Ns={readContext:Ui,use:To,useCallback:us,useContext:Ui,useEffect:ns,useImperativeHandle:cs,useInsertionEffect:as,useLayoutEffect:os,useMemo:ds,useReducer:Ao,useRef:Qo,useState:function(){return Ao(Do)},useDebugValue:ls,useDeferredValue:function(e,t){var n=So();return no===null?fs(n,e,t):ps(n,no.memoizedState,e,t)},useTransition:function(){var e=Ao(Do)[0],t=So().memoizedState;return[typeof e==`boolean`?e:wo(e),t]},useSyncExternalStore:jo,useId:bs,useHostTransitionStatus:ys,useFormState:Xo,useActionState:Xo,useOptimistic:function(e,t){var n=So();return no===null?(n.baseState=e,[e,n.queue.dispatch]):Ro(n,no,e,t)},useMemoCache:Eo,useCacheRefresh:xs};Ns.useEffectEvent=is;function Ps(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:f({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Fs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=fu(),i=ja(r);i.payload=t,n!=null&&(i.callback=n),t=Ma(e,i,r),t!==null&&(mu(t,e,r),Na(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=fu(),i=ja(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ma(e,i,r),t!==null&&(mu(t,e,r),Na(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=fu(),r=ja(n);r.tag=2,t!=null&&(r.callback=t),t=Ma(e,r,n),t!==null&&(mu(t,e,n),Na(t,e,n))}};function Is(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!ur(n,r)||!ur(i,a):!0}function Ls(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Fs.enqueueReplaceState(t,t.state,null)}function Rs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=f({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function zs(e){Lr(e)}function Bs(e){console.error(e)}function Vs(e){Lr(e)}function Hs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Us(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ws(e,t,n){return n=ja(n),n.tag=3,n.payload={element:null},n.callback=function(){Hs(e,t)},n}function Gs(e){return e=ja(e),e.tag=3,e}function Ks(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Us(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Us(t,n,r),typeof i!=`function`&&(nu===null?nu=new Set([this]):nu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function qs(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Bi(t,n,a,!0),n=Ga.current,n!==null){switch(n.tag){case 31:case 13:return Ka===null?Eu():n.alternate===null&&Ul===0&&(Ul=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===pa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Wu(e,r,a)),!1;case 22:return n.flags|=65536,r===pa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Wu(e,r,a)),!1}throw Error(i(435,n.tag))}return Wu(e,r,a),Eu(),!1}if(Si)return t=Ga.current,t===null?(r!==Ti&&(t=Error(i(423),{cause:r}),Mi(ai(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=ai(r,n),a=Ws(e.stateNode,r,a),Pa(e,a),Ul!==4&&(Ul=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ti&&(e=Error(i(422),{cause:r}),Mi(ai(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=ai(o,n),Yl===null?Yl=[o]:Yl.push(o),Ul!==4&&(Ul=2),t===null)return!0;r=ai(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ws(n.stateNode,r,e),Pa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(nu===null||!nu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Gs(a),Ks(a,e,n,r),Pa(n,a),!1}n=n.return}while(n!==null);return!1}var Js=Error(i(461)),Ys=!1;function Xs(e,t,n,r){t.child=e===null?Da(t,null,n,r):Ea(t,e.child,n,r)}function Zs(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Hi(t),r=mo(e,t,n,o,a,i),s=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Si&&s&&_i(t),t.flags|=1,Xs(e,t,r,i),t.child)}function Qs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Xr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,$s(e,t,a,r,i)):(e=$r(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Sc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?ur:n,n(o,r)&&e.ref===t.ref)return xc(e,t,i)}return t.flags|=1,e=Zr(a,r),e.ref=t.ref,e.return=t,t.child=e}function $s(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(ur(a,r)&&e.ref===t.ref)if(Ys=!1,t.pendingProps=r=a,Sc(e,i))e.flags&131072&&(Ys=!0);else return t.lanes=e.lanes,xc(e,t,i)}return sc(e,t,n,r,i)}function ec(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ca(t,a===null?null:a.cachePool),a===null?Ua():Ha(t,a),Ya(t);else return r=t.lanes=536870912,nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ca(t,null),Ua(),Xa(t)):(ca(t,a.cachePool),Ha(t,a),Xa(t),t.memoizedState=null);return Xs(e,t,i,n),t.child}function tc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function nc(e,t,n,r,i){var a=sa();return a=a===null?null:{parent:Yi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ca(t,null),Ua(),Ya(t),e!==null&&Bi(e,t,r,!0),t.childLanes=i,null}function rc(e,t){return t=gc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ic(e,t,n){return Ea(t,e.child,null,n),e=rc(t,t.pendingProps),e.flags|=2,Za(t),t.memoizedState=null,e}function ac(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Si){if(r.mode===`hidden`)return e=rc(t,r),t.lanes=536870912,tc(null,e);if(Ja(t),(e=xi)?(e=af(e,wi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fi===null?null:{id:pi,overflow:mi},retryLane:536870912,hydrationErrors:null},n=ni(e),n.return=t,t.child=n,bi=t,xi=null)):e=null,e===null)throw Ei(t);return t.lanes=536870912,null}return rc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ja(t),a)if(t.flags&256)t.flags&=-257,t=ic(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(Ys||Bi(e,t,n,!1),a=(n&e.childLanes)!==0,Ys||a){if(r=Pl,r!==null&&(s=Ue(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Wr(e,s),mu(r,e,s),Js;Eu(),t=ic(e,t,n)}else e=o.treeContext,xi=lf(s.nextSibling),bi=t,Si=!0,Ci=null,wi=!1,e!==null&&yi(t,e),t=rc(t,r),t.flags|=4096;return t}return e=Zr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function oc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function sc(e,t,n,r,i){return Hi(t),n=mo(e,t,n,r,void 0,i),r=vo(),e!==null&&!Ys?(yo(e,t,i),xc(e,t,i)):(Si&&r&&_i(t),t.flags|=1,Xs(e,t,n,i),t.child)}function cc(e,t,n,r,i,a){return Hi(t),t.updateQueue=null,n=go(t,r,n,i),ho(e),r=vo(),e!==null&&!Ys?(yo(e,t,a),xc(e,t,a)):(Si&&r&&_i(t),t.flags|=1,Xs(e,t,n,a),t.child)}function lc(e,t,n,r,i){if(Hi(t),t.stateNode===null){var a=qr,o=n.contextType;typeof o==`object`&&o&&(a=Ui(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Fs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ka(t),o=n.contextType,a.context=typeof o==`object`&&o?Ui(o):qr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ps(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Fs.enqueueReplaceState(a,a.state,null),La(t,r,a,i),Ia(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Rs(n,s);a.props=c;var l=a.context,u=n.contextType;o=qr,typeof u==`object`&&u&&(o=Ui(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ls(t,a,r,o),Oa=!1;var f=t.memoizedState;a.state=f,La(t,r,a,i),Ia(),l=t.memoizedState,s||f!==l||Oa?(typeof d==`function`&&(Ps(t,n,d,r),l=t.memoizedState),(c=Oa||Is(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Aa(e,t),o=t.memoizedProps,u=Rs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=qr,typeof l==`object`&&l&&(c=Ui(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ls(t,a,r,c),Oa=!1,f=t.memoizedState,a.state=f,La(t,r,a,i),Ia();var p=t.memoizedState;o!==d||f!==p||Oa||e!==null&&e.dependencies!==null&&Vi(e.dependencies)?(typeof s==`function`&&(Ps(t,n,s,r),p=t.memoizedState),(u=Oa||Is(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Vi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,oc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ea(t,e.child,null,i),t.child=Ea(t,null,n,i)):Xs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=xc(e,t,i),e}function uc(e,t,n,r){return Ai(),t.flags|=256,Xs(e,t,n,r),t.child}var dc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function fc(e){return{baseLanes:e,cachePool:la()}}function pc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ql),e}function mc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(Qa.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Si){if(a?qa(t):Xa(t),(e=xi)?(e=af(e,wi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fi===null?null:{id:pi,overflow:mi},retryLane:536870912,hydrationErrors:null},n=ni(e),n.return=t,t.child=n,bi=t,xi=null)):e=null,e===null)throw Ei(t);return sf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Xa(t),a=t.mode,c=gc({mode:`hidden`,children:c},a),r=ei(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(null,r)):(qa(t),hc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(qa(t),t.flags&=-257,t=_c(e,t,n)):t.memoizedState===null?(Xa(t),c=r.fallback,a=t.mode,r=gc({mode:`visible`,children:r.children},a),c=ei(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ea(t,e.child,null,n),r=t.child,r.memoizedState=fc(n),r.childLanes=pc(e,s,n),t.memoizedState=dc,t=tc(null,r)):(Xa(t),t.child=e.child,t.flags|=128,t=null);else if(qa(t),sf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Mi({value:r,source:null,stack:null}),t=_c(e,t,n)}else if(Ys||Bi(e,t,n,!1),s=(n&e.childLanes)!==0,Ys||s){if(s=Pl,s!==null&&(r=Ue(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Wr(e,r),mu(s,e,r),Js;of(c)||Eu(),t=_c(e,t,n)}else of(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,xi=lf(c.nextSibling),bi=t,Si=!0,Ci=null,wi=!1,e!==null&&yi(t,e),t=hc(t,r.children),t.flags|=4096);return t}return a?(Xa(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=Zr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ei(c,a,n,null),c.flags|=2):c=Zr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,tc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=fc(n):(a=c.cachePool,a===null?a=la():(l=Yi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=pc(e,s,n),t.memoizedState=dc,tc(e.child,r)):(qa(t),n=e.child,e=n.sibling,n=Zr(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function hc(e,t){return t=gc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function gc(e,t){return e=Yr(22,e,null,t),e.lanes=0,e}function _c(e,t,n){return Ea(t,e.child,null,n),e=hc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function vc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ri(e.return,t,n)}function yc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function bc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Qa.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,V(Qa,o),Xs(e,t,r,n),r=Si?li:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vc(e,n,t);else if(e.tag===19)vc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&$a(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),yc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&$a(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}yc(t,!0,n,null,a,r);break;case`together`:yc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function xc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Wl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Bi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Zr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Zr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Sc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Vi(e))):!0}function Cc(e,t,n){switch(t.tag){case 3:ae(t,t.stateNode.containerInfo),Ii(t,Yi,e.memoizedState.cache),Ai();break;case 27:case 5:se(t);break;case 4:ae(t,t.stateNode.containerInfo);break;case 10:Ii(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ja(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(qa(t),e=xc(e,t,n),e===null?null:e.sibling):mc(e,t,n):(qa(t),t.flags|=128,null);qa(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Bi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return bc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(Qa,Qa.current),r)break;return null;case 22:return t.lanes=0,ec(e,t,n,t.pendingProps);case 24:Ii(t,Yi,e.memoizedState.cache)}return xc(e,t,n)}function wc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Ys=!0;else{if(!Sc(e,n)&&!(t.flags&128))return Ys=!1,Cc(e,t,n);Ys=!!(e.flags&131072)}else Ys=!1,Si&&t.flags&1048576&&gi(t,li,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ga(t.elementType),t.type=e,typeof e==`function`)Xr(e)?(r=Rs(e,r),t.tag=1,t=lc(null,t,e,r,n)):(t.tag=0,t=sc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===C){t.tag=11,t=Zs(null,t,e,r,n);break a}else if(a===E){t.tag=14,t=Qs(null,t,e,r,n);break a}}throw t=N(e)||e,Error(i(306,t,``))}}return t;case 0:return sc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Rs(r,t.pendingProps),lc(e,t,r,a,n);case 3:a:{if(ae(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Aa(e,t),La(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ii(t,Yi,r),r!==o.cache&&zi(t,[Yi],n,!0),Ia(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=uc(e,t,r,n);break a}else if(r!==a){a=ai(Error(i(424)),t),Mi(a),t=uc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(xi=lf(e.firstChild),bi=t,Si=!0,Ci=null,wi=!0,n=Da(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ai(),r===a){t=xc(e,t,n);break a}Xs(e,t,r,n)}t=t.child}return t;case 26:return oc(e,t),e===null?(n=Af(t.type,null,t.pendingProps,null))?t.memoizedState=n:Si||(n=t.type,e=t.pendingProps,r=Vd(re.current).createElement(n),r[X]=t,r[Ye]=e,Fd(r,n,e),st(r),t.stateNode=r):t.memoizedState=Af(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return se(t),e===null&&Si&&(r=t.stateNode=pf(t.type,t.pendingProps,re.current),bi=t,wi=!0,a=xi,Qd(t.type)?(uf=a,xi=lf(r.firstChild)):xi=a),Xs(e,t,t.pendingProps.children,n),oc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Si&&((a=r=xi)&&(r=nf(r,t.type,t.pendingProps,wi),r===null?a=!1:(t.stateNode=r,bi=t,xi=lf(r.firstChild),wi=!1,a=!0)),a||Ei(t)),se(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Wd(a,o)?r=null:s!==null&&Wd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=mo(e,t,_o,null,null,n),$f._currentValue=a),oc(e,t),Xs(e,t,r,n),t.child;case 6:return e===null&&Si&&((e=n=xi)&&(n=rf(n,t.pendingProps,wi),n===null?e=!1:(t.stateNode=n,bi=t,xi=null,e=!0)),e||Ei(t)),null;case 13:return mc(e,t,n);case 4:return ae(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ea(t,null,r,n):Xs(e,t,r,n),t.child;case 11:return Zs(e,t,t.type,t.pendingProps,n);case 7:return Xs(e,t,t.pendingProps,n),t.child;case 8:return Xs(e,t,t.pendingProps.children,n),t.child;case 12:return Xs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ii(t,t.type,r.value),Xs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Hi(t),a=Ui(a),r=r(a),t.flags|=1,Xs(e,t,r,n),t.child;case 14:return Qs(e,t,t.type,t.pendingProps,n);case 15:return $s(e,t,t.type,t.pendingProps,n);case 19:return bc(e,t,n);case 31:return ac(e,t,n);case 22:return ec(e,t,n,t.pendingProps);case 24:return Hi(t),r=Ui(Yi),e===null?(a=sa(),a===null&&(a=Pl,o=Xi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},ka(t),Ii(t,Yi,a)):((e.lanes&n)!==0&&(Aa(e,t),La(t,null,null,n),Ia()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ii(t,Yi,r),r!==a.cache&&zi(t,[Yi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ii(t,Yi,r))),Xs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Tc(e){e.flags|=4}function Ec(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Cu())e.flags|=8192;else throw _a=pa,da}else e.flags&=-16777217}function Dc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Gf(t))if(Cu())e.flags|=8192;else throw _a=pa,da}function Oc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Le(),e.lanes|=t,Jl|=t)}function kc(e,t){if(!Si)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ac(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function jc(e,t,n){var r=t.pendingProps;switch(vi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ac(t),null;case 1:return Ac(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Li(Yi),oe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ki(t)?Tc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ji())),Ac(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Tc(t),o===null?(Ac(t),Ec(t,a,null,r,n)):(Ac(t),Dc(t,o))):o?o===e.memoizedState?(Ac(t),t.flags&=-16777217):(Tc(t),Ac(t),Dc(t,o)):(e=e.memoizedProps,e!==r&&Tc(t),Ac(t),Ec(t,a,e,r,n)),null;case 27:if(H(t),n=re.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}e=te.current,ki(t)?Di(t,e):(e=pf(a,r,n),t.stateNode=e,Tc(t))}return Ac(t),null;case 5:if(H(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Ac(t),null}if(o=te.current,ki(t))Di(t,o);else{var s=Vd(re.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[X]=t,o[Ye]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Fd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Tc(t)}}return Ac(t),Ec(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Tc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=re.current,ki(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=bi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[X]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Md(e.nodeValue,n)),e||Ei(t,!0)}else e=Vd(e).createTextNode(r),e[X]=t,t.stateNode=e}return Ac(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ki(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[X]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),e=!1}else n=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Za(t),t):(Za(t),null);if(t.flags&128)throw Error(i(558))}return Ac(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ki(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[X]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ac(t),a=!1}else a=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Za(t),t):(Za(t),null)}return Za(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Oc(t,t.updateQueue),Ac(t),null);case 4:return oe(),e===null&&Sd(t.stateNode.containerInfo),Ac(t),null;case 10:return Li(t.type),Ac(t),null;case 19:if(B(Qa),r=t.memoizedState,r===null)return Ac(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)kc(r,!1);else{if(Ul!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=$a(e),o!==null){for(t.flags|=128,kc(r,!1),e=o.updateQueue,t.updateQueue=e,Oc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Qr(n,e),n=n.sibling;return V(Qa,Qa.current&1|2),Si&&hi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&he()>eu&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304)}else{if(!a)if(e=$a(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Oc(t,e),kc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Si)return Ac(t),null}else 2*he()-r.renderingStartTime>eu&&n!==536870912&&(t.flags|=128,a=!0,kc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Ac(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=he(),e.sibling=null,n=Qa.current,V(Qa,a?n&1|2:n&1),Si&&hi(t,r.treeForkCount),e);case 22:case 23:return Za(t),Wa(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ac(t),t.subtreeFlags&6&&(t.flags|=8192)):Ac(t),n=t.updateQueue,n!==null&&Oc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&B(oa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Li(Yi),Ac(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Mc(e,t){switch(vi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Li(Yi),oe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return H(t),null;case 31:if(t.memoizedState!==null){if(Za(t),t.alternate===null)throw Error(i(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Za(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(Qa),null;case 4:return oe(),null;case 10:return Li(t.type),null;case 22:case 23:return Za(t),Wa(),e!==null&&B(oa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Li(Yi),null;case 25:return null;default:return null}}function Nc(e,t){switch(vi(t),t.tag){case 3:Li(Yi),oe();break;case 26:case 27:case 5:H(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&Za(t);break;case 13:Za(t);break;case 19:B(Qa);break;case 10:Li(t.type);break;case 22:case 23:Za(t),Wa(),e!==null&&B(oa);break;case 24:Li(Yi)}}function Pc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Uu(t,t.return,e)}}function Fc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Uu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Uu(t,t.return,e)}}function Ic(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{za(t,n)}catch(t){Uu(e,e.return,t)}}}function Lc(e,t,n){n.props=Rs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Uu(e,t,n)}}function Rc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Uu(e,t,n)}}function zc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Uu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Uu(e,t,n)}else n.current=null}function Bc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Uu(e,e.return,t)}}function Vc(e,t,n){try{var r=e.stateNode;Id(r,e.type,n,t),r[Ye]=t}catch(t){Uu(e,e.return,t)}}function Hc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Qd(e.type)||e.tag===4}function Uc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Hc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Qd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Vt));else if(r!==4&&(r===27&&Qd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Qd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Gc(e,t,n),e=e.sibling;e!==null;)Gc(e,t,n),e=e.sibling}function Kc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Fd(t,r,n),t[X]=e,t[Ye]=n}catch(t){Uu(e,e.return,t)}}var qc=!1,Jc=!1,Yc=!1,Xc=typeof WeakSet==`function`?WeakSet:Set,Zc=null;function Qc(e,t){if(e=e.containerInfo,zd=cp,e=mr(e),hr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Bd={focusedElem:e,selectionRange:n},cp=!1,Zc=t;Zc!==null;)if(t=Zc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Zc=e;else for(;Zc!==null;){switch(t=Zc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Rs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Uu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)tf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:tf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Zc=e;break}Zc=t.return}}function $c(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ml(e,n),r&4&&Pc(5,n);break;case 1:if(ml(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Uu(n,n.return,e)}else{var i=Rs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Uu(n,n.return,e)}}r&64&&Ic(n),r&512&&Rc(n,n.return);break;case 3:if(ml(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{za(e,t)}catch(e){Uu(n,n.return,e)}}break;case 27:t===null&&r&4&&Kc(n);case 26:case 5:ml(e,n),t===null&&r&4&&Bc(n),r&512&&Rc(n,n.return);break;case 12:ml(e,n);break;case 31:ml(e,n),r&4&&al(e,n);break;case 13:ml(e,n),r&4&&ol(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=qu.bind(null,n),cf(e,n))));break;case 22:if(r=n.memoizedState!==null||qc,!r){t=t!==null&&t.memoizedState!==null||Jc,i=qc;var a=Jc;qc=r,(Jc=t)&&!a?gl(e,n,(n.subtreeFlags&8772)!=0):ml(e,n),qc=i,Jc=a}break;case 30:break;default:ml(e,n)}}function el(e){var t=e.alternate;t!==null&&(e.alternate=null,el(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&nt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var tl=null,nl=!1;function rl(e,t,n){for(n=n.child;n!==null;)il(e,t,n),n=n.sibling}function il(e,t,n){if(Te&&typeof Te.onCommitFiberUnmount==`function`)try{Te.onCommitFiberUnmount(we,n)}catch{}switch(n.tag){case 26:Jc||zc(n,t),rl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Jc||zc(n,t);var r=tl,i=nl;Qd(n.type)&&(tl=n.stateNode,nl=!1),rl(e,t,n),mf(n.stateNode),tl=r,nl=i;break;case 5:Jc||zc(n,t);case 6:if(r=tl,i=nl,tl=null,rl(e,t,n),tl=r,nl=i,tl!==null)if(nl)try{(tl.nodeType===9?tl.body:tl.nodeName===`HTML`?tl.ownerDocument.body:tl).removeChild(n.stateNode)}catch(e){Uu(n,t,e)}else try{tl.removeChild(n.stateNode)}catch(e){Uu(n,t,e)}break;case 18:tl!==null&&(nl?(e=tl,$d(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Pp(e)):$d(tl,n.stateNode));break;case 4:r=tl,i=nl,tl=n.stateNode.containerInfo,nl=!0,rl(e,t,n),tl=r,nl=i;break;case 0:case 11:case 14:case 15:Fc(2,n,t),Jc||Fc(4,n,t),rl(e,t,n);break;case 1:Jc||(zc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Lc(n,t,r)),rl(e,t,n);break;case 21:rl(e,t,n);break;case 22:Jc=(r=Jc)||n.memoizedState!==null,rl(e,t,n),Jc=r;break;default:rl(e,t,n)}}function al(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Pp(e)}catch(e){Uu(t,t.return,e)}}}function ol(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Pp(e)}catch(e){Uu(t,t.return,e)}}function sl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Xc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Xc),t;default:throw Error(i(435,e.tag))}}function cl(e,t){var n=sl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Ju.bind(null,e,t);t.then(r,r)}})}function ll(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Qd(c.type)){tl=c.stateNode,nl=!1;break a}break;case 5:tl=c.stateNode,nl=!1;break a;case 3:case 4:tl=c.stateNode.containerInfo,nl=!0;break a}c=c.return}if(tl===null)throw Error(i(160));il(o,s,a),tl=null,nl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)dl(t,e),t=t.sibling}var ul=null;function dl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ll(t,e),fl(e),r&4&&(Fc(3,e,e.return),Pc(3,e),Fc(5,e,e.return));break;case 1:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&64&&qc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=ul;if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[tt]||o[X]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Fd(o,r,n),o[X]=e,st(o),r=o;break a;case`link`:var s=Hf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Fd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Hf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Fd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[X]=e,st(o),r=o}e.stateNode=r}else Uf(a,e.type,e.stateNode);else e.stateNode=Lf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Vc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Uf(a,e.type,e.stateNode):Lf(a,r,e.memoizedProps))}break;case 27:ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),n!==null&&r&4&&Vc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ll(t,e),fl(e),r&512&&(Jc||n===null||zc(n,n.return)),e.flags&32){a=e.stateNode;try{Nt(a,``)}catch(t){Uu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Vc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Yc=!0);break;case 6:if(ll(t,e),fl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Uu(e,e.return,t)}}break;case 3:if(Vf=null,a=ul,ul=_f(t.containerInfo),ll(t,e),ul=a,fl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Pp(t.containerInfo)}catch(t){Uu(e,e.return,t)}Yc&&(Yc=!1,pl(e));break;case 4:r=ul,ul=_f(e.stateNode.containerInfo),ll(t,e),fl(e),ul=r;break;case 12:ll(t,e),fl(e);break;case 31:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 13:ll(t,e),fl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Ql=he()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=qc,d=Jc;if(qc=u||a,Jc=d||l,ll(t,e),Jc=d,qc=u,fl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||qc||Jc||hl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Uu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Uu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?ef(m,!0):ef(l.stateNode,!1)}catch(e){Uu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,cl(e,n))));break;case 19:ll(t,e),fl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,cl(e,r)));break;case 30:break;case 21:break;default:ll(t,e),fl(e)}}function fl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Hc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Gc(e,Uc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Nt(o,``),n.flags&=-33),Gc(e,Uc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Wc(e,Uc(e),s);break;default:throw Error(i(161))}}catch(t){Uu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function pl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;pl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function ml(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)$c(e,t.alternate,t),t=t.sibling}function hl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Fc(4,t,t.return),hl(t);break;case 1:zc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Lc(t,t.return,n),hl(t);break;case 27:mf(t.stateNode);case 26:case 5:zc(t,t.return),hl(t);break;case 22:t.memoizedState===null&&hl(t);break;case 30:hl(t);break;default:hl(t)}e=e.sibling}}function gl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:gl(i,a,n),Pc(4,a);break;case 1:if(gl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Uu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ra(c[i],s)}catch(e){Uu(r,r.return,e)}}n&&o&64&&Ic(a),Rc(a,a.return);break;case 27:Kc(a);case 26:case 5:gl(i,a,n),n&&r===null&&o&4&&Bc(a),Rc(a,a.return);break;case 12:gl(i,a,n);break;case 31:gl(i,a,n),n&&o&4&&al(i,a);break;case 13:gl(i,a,n),n&&o&4&&ol(i,a);break;case 22:a.memoizedState===null&&gl(i,a,n),Rc(a,a.return);break;case 30:break;default:gl(i,a,n)}t=t.sibling}}function _l(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Zi(n))}function vl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Zi(e))}function yl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)bl(e,t,n,r),t=t.sibling}function bl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:yl(e,t,n,r),i&2048&&Pc(9,t);break;case 1:yl(e,t,n,r);break;case 3:yl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Zi(e)));break;case 12:if(i&2048){yl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Uu(t,t.return,e)}}else yl(e,t,n,r);break;case 31:yl(e,t,n,r);break;case 13:yl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?yl(e,t,n,r):(a._visibility|=2,xl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?yl(e,t,n,r):Sl(e,t),i&2048&&_l(o,t);break;case 24:yl(e,t,n,r),i&2048&&vl(t.alternate,t);break;default:yl(e,t,n,r)}}function xl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:xl(a,o,s,c,i),Pc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,xl(a,o,s,c,i)):u._visibility&2?xl(a,o,s,c,i):Sl(a,o),i&&l&2048&&_l(o.alternate,o);break;case 24:xl(a,o,s,c,i),i&&l&2048&&vl(o.alternate,o);break;default:xl(a,o,s,c,i)}t=t.sibling}}function Sl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Sl(n,r),i&2048&&_l(r.alternate,r);break;case 24:Sl(n,r),i&2048&&vl(r.alternate,r);break;default:Sl(n,r)}t=t.sibling}}var Cl=8192;function wl(e,t,n){if(e.subtreeFlags&Cl)for(e=e.child;e!==null;)Tl(e,t,n),e=e.sibling}function Tl(e,t,n){switch(e.tag){case 26:wl(e,t,n),e.flags&Cl&&e.memoizedState!==null&&Kf(n,ul,e.memoizedState,e.memoizedProps);break;case 5:wl(e,t,n);break;case 3:case 4:var r=ul;ul=_f(e.stateNode.containerInfo),wl(e,t,n),ul=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Cl,Cl=16777216,wl(e,t,n),Cl=r):wl(e,t,n));break;default:wl(e,t,n)}}function El(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ol(e),e=e.sibling}function Ol(e){switch(e.tag){case 0:case 11:case 15:Dl(e),e.flags&2048&&Fc(9,e,e.return);break;case 3:Dl(e);break;case 12:Dl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,kl(e)):Dl(e);break;default:Dl(e)}}function kl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Zc=r,Al(r,e)}El(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Fc(8,t,t.return),kl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,kl(t));break;default:kl(t)}e=e.sibling}}function Al(e,t){for(;Zc!==null;){var n=Zc;switch(n.tag){case 0:case 11:case 15:Fc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Zi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Zc=r;else a:for(n=e;Zc!==null;){r=Zc;var i=r.sibling,a=r.return;if(el(r),r===n){Zc=null;break a}if(i!==null){i.return=a,Zc=i;break a}Zc=a}}}var jl={getCacheForType:function(e){var t=Ui(Yi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ui(Yi).controller.signal}},Ml=typeof WeakMap==`function`?WeakMap:Map,Nl=0,Pl=null,Fl=null,Il=0,Ll=0,Rl=null,zl=!1,Bl=!1,Vl=!1,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=0,Yl=null,Xl=null,Zl=!1,Ql=0,$l=0,eu=1/0,tu=null,nu=null,ru=0,iu=null,au=null,ou=0,su=0,cu=null,lu=null,uu=0,du=null;function fu(){return Nl&2&&Il!==0?Il&-Il:F.T===null?Ke():ud()}function pu(){if(ql===0)if(!(Il&536870912)||Si){var e=Me;Me<<=1,!(Me&3932160)&&(Me=262144),ql=e}else ql=536870912;return e=Ga.current,e!==null&&(e.flags|=32),ql}function mu(e,t,n){(e===Pl&&(Ll===2||Ll===9)||e.cancelPendingCommit!==null)&&(xu(e,0),vu(e,Il,ql,!1)),ze(e,n),(!(Nl&2)||e!==Pl)&&(e===Pl&&(!(Nl&2)&&(Gl|=n),Ul===4&&vu(e,Il,ql,!1)),nd(e))}function hu(e,t,n){if(Nl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Fe(e,t),a=r?ku(e,t):Du(e,t,!0),o=r;do{if(a===0){Bl&&!r&&vu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!_u(n)){a=Du(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Yl;var l=c.current.memoizedState.isDehydrated;if(l&&(xu(c,s).flags|=256),s=Du(c,s,!1),s!==2){if(Vl&&!l){c.errorRecoveryDisabledLanes|=o,Gl|=o,a=4;break a}o=Xl,Xl=a,o!==null&&(Xl===null?Xl=o:Xl.push.apply(Xl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){xu(e,0),vu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:vu(r,t,ql,!zl);break a;case 2:Xl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Ql+300-he(),10<a)){if(vu(r,t,ql,!zl),Pe(r,0,!0)!==0)break a;ou=t,r.timeoutHandle=qd(gu.bind(null,r,n,Xl,tu,Zl,t,ql,Gl,Jl,zl,o,`Throttled`,-0,0),a);break a}gu(r,n,Xl,tu,Zl,t,ql,Gl,Jl,zl,o,null,-0,0)}}break}while(1);nd(e)}function gu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Vt},Tl(t,a,d);var m=(a&62914560)===a?Ql-he():(a&4194048)===a?$l-he():0;if(m=Jf(d,m),m!==null){ou=a,e.cancelPendingCommit=m(Iu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),vu(e,a,o,!l);return}}Iu(e,t,a,n,r,i,o,s,c)}function _u(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!lr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function vu(e,t,n,r){t&=~Kl,t&=~Gl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-De(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Ve(e,n,t)}function yu(){return Nl&6?!0:(rd(0,!1),!1)}function bu(){if(Fl!==null){if(Ll===0)var e=Fl.return;else e=Fl,Fi=Pi=null,bo(e),ba=null,xa=0,e=Fl;for(;e!==null;)Nc(e.alternate,e),e=e.return;Fl=null}}function xu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Jd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),ou=0,bu(),Pl=e,Fl=n=Zr(e.current,null),Il=t,Ll=0,Rl=null,zl=!1,Bl=Fe(e,t),Vl=!1,Jl=ql=Kl=Gl=Wl=Ul=0,Xl=Yl=null,Zl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-De(r),a=1<<i;t|=e[i],r&=~a}return Hl=t,Vr(),n}function Su(e,t){to=null,F.H=As,t===ua||t===fa?(t=va(),Ll=3):t===da?(t=va(),Ll=4):Ll=t===Js?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Rl=t,Fl===null&&(Ul=1,Hs(e,ai(t,e.current)))}function Cu(){var e=Ga.current;return e===null?!0:(Il&4194048)===Il?Ka===null:(Il&62914560)===Il||Il&536870912?e===Ka:!1}function wu(){var e=F.H;return F.H=As,e===null?As:e}function Tu(){var e=F.A;return F.A=jl,e}function Eu(){Ul=4,zl||(Il&4194048)!==Il&&Ga.current!==null||(Bl=!0),!(Wl&134217727)&&!(Gl&134217727)||Pl===null||vu(Pl,Il,ql,!1)}function Du(e,t,n){var r=Nl;Nl|=2;var i=wu(),a=Tu();(Pl!==e||Il!==t)&&(tu=null,xu(e,t)),t=!1;var o=Ul;a:do try{if(Ll!==0&&Fl!==null){var s=Fl,c=Rl;switch(Ll){case 8:bu(),o=6;break a;case 3:case 2:case 9:case 6:Ga.current===null&&(t=!0);var l=Ll;if(Ll=0,Rl=null,Nu(e,s,c,l),n&&Bl){o=0;break a}break;default:l=Ll,Ll=0,Rl=null,Nu(e,s,c,l)}}Ou(),o=Ul;break}catch(t){Su(e,t)}while(1);return t&&e.shellSuspendCounter++,Fi=Pi=null,Nl=r,F.H=i,F.A=a,Fl===null&&(Pl=null,Il=0,Vr()),o}function Ou(){for(;Fl!==null;)ju(Fl)}function ku(e,t){var n=Nl;Nl|=2;var r=wu(),a=Tu();Pl!==e||Il!==t?(tu=null,eu=he()+500,xu(e,t)):Bl=Fe(e,t);a:do try{if(Ll!==0&&Fl!==null){t=Fl;var o=Rl;b:switch(Ll){case 1:Ll=0,Rl=null,Nu(e,t,o,1);break;case 2:case 9:if(ma(o)){Ll=0,Rl=null,Mu(t);break}t=function(){Ll!==2&&Ll!==9||Pl!==e||(Ll=7),nd(e)},o.then(t,t);break a;case 3:Ll=7;break a;case 4:Ll=5;break a;case 7:ma(o)?(Ll=0,Rl=null,Mu(t)):(Ll=0,Rl=null,Nu(e,t,o,7));break;case 5:var s=null;switch(Fl.tag){case 26:s=Fl.memoizedState;case 5:case 27:var c=Fl;if(s?Gf(s):c.stateNode.complete){Ll=0,Rl=null;var l=c.sibling;if(l!==null)Fl=l;else{var u=c.return;u===null?Fl=null:(Fl=u,Pu(u))}break b}}Ll=0,Rl=null,Nu(e,t,o,5);break;case 6:Ll=0,Rl=null,Nu(e,t,o,6);break;case 8:bu(),Ul=6;break a;default:throw Error(i(462))}}Au();break}catch(t){Su(e,t)}while(1);return Fi=Pi=null,F.H=r,F.A=a,Nl=n,Fl===null?(Pl=null,Il=0,Vr(),Ul):0}function Au(){for(;Fl!==null&&!pe();)ju(Fl)}function ju(e){var t=wc(e.alternate,e,Hl);e.memoizedProps=e.pendingProps,t===null?Pu(e):Fl=t}function Mu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=cc(n,t,t.pendingProps,t.type,void 0,Il);break;case 11:t=cc(n,t,t.pendingProps,t.type.render,t.ref,Il);break;case 5:bo(t);default:Nc(n,t),t=Fl=Qr(t,Hl),t=wc(n,t,Hl)}e.memoizedProps=e.pendingProps,t===null?Pu(e):Fl=t}function Nu(e,t,n,r){Fi=Pi=null,bo(t),ba=null,xa=0;var i=t.return;try{if(qs(e,i,t,n,Il)){Ul=1,Hs(e,ai(n,e.current)),Fl=null;return}}catch(t){if(i!==null)throw Fl=i,t;Ul=1,Hs(e,ai(n,e.current)),Fl=null;return}t.flags&32768?(Si||r===1?e=!0:Bl||Il&536870912?e=!1:(zl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ga.current,r!==null&&r.tag===13&&(r.flags|=16384))),Fu(t,e)):Pu(t)}function Pu(e){var t=e;do{if(t.flags&32768){Fu(t,zl);return}e=t.return;var n=jc(t.alternate,t,Hl);if(n!==null){Fl=n;return}if(t=t.sibling,t!==null){Fl=t;return}Fl=t=e}while(t!==null);Ul===0&&(Ul=5)}function Fu(e,t){do{var n=Mc(e.alternate,e);if(n!==null){n.flags&=32767,Fl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Fl=e;return}Fl=e=n}while(e!==null);Ul=6,Fl=null}function Iu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Bu();while(ru!==0);if(Nl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Br,Be(e,n,o,s,c,l),e===Pl&&(Fl=Pl=null,Il=0),au=t,iu=e,ou=n,su=o,cu=a,lu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Yu(ye,function(){return Vu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=F.T,F.T=null,a=I.p,I.p=2,s=Nl,Nl|=4;try{Qc(e,t,n)}finally{Nl=s,I.p=a,F.T=r}}ru=1,Lu(),Ru(),Q()}}function Lu(){if(ru===1){ru=0;var e=iu,t=au,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=Nl;Nl|=4;try{dl(t,e);var a=Bd,o=mr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&pr(s.ownerDocument.documentElement,s)){if(c!==null&&hr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=fr(s,h),v=fr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}cp=!!zd,Bd=zd=null}finally{Nl=i,I.p=r,F.T=n}}e.current=t,ru=2}}function Ru(){if(ru===2){ru=0;var e=iu,t=au,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=Nl;Nl|=4;try{$c(e,t.alternate,t)}finally{Nl=i,I.p=r,F.T=n}}ru=3}}function Q(){if(ru===4||ru===3){ru=0,me();var e=iu,t=au,n=ou,r=lu;t.subtreeFlags&10256||t.flags&10256?ru=5:(ru=0,au=iu=null,zu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(nu=null),Ge(n),t=t.stateNode,Te&&typeof Te.onCommitFiberRoot==`function`)try{Te.onCommitFiberRoot(we,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=F.T,i=I.p,I.p=2,F.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{F.T=t,I.p=i}}ou&3&&Bu(),nd(e),i=e.pendingLanes,n&261930&&i&42?e===du?uu++:(uu=0,du=e):uu=0,rd(0,!1)}}function zu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Zi(t)))}function Bu(){return Lu(),Ru(),Q(),Vu()}function Vu(){if(ru!==5)return!1;var e=iu,t=su;su=0;var n=Ge(ou),r=F.T,a=I.p;try{I.p=32>n?32:n,F.T=null,n=cu,cu=null;var o=iu,s=ou;if(ru=0,au=iu=null,ou=0,Nl&6)throw Error(i(331));var c=Nl;if(Nl|=4,Ol(o.current),bl(o,o.current,s,n),Nl=c,rd(0,!1),Te&&typeof Te.onPostCommitFiberRoot==`function`)try{Te.onPostCommitFiberRoot(we,o)}catch{}return!0}finally{I.p=a,F.T=r,zu(e,t)}}function Hu(e,t,n){t=ai(n,t),t=Ws(e.stateNode,t,2),e=Ma(e,t,2),e!==null&&(ze(e,2),nd(e))}function Uu(e,t,n){if(e.tag===3)Hu(e,e,n);else for(;t!==null;){if(t.tag===3){Hu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(nu===null||!nu.has(r))){e=ai(n,e),n=Gs(2),r=Ma(t,n,2),r!==null&&(Ks(n,r,t,e),ze(r,2),nd(r));break}}t=t.return}}function Wu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ml;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Vl=!0,i.add(n),e=Gu.bind(null,e,t,n),t.then(e,e))}function Gu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Pl===e&&(Il&n)===n&&(Ul===4||Ul===3&&(Il&62914560)===Il&&300>he()-Ql?!(Nl&2)&&xu(e,0):Kl|=n,Jl===Il&&(Jl=0)),nd(e)}function Ku(e,t){t===0&&(t=Le()),e=Wr(e,t),e!==null&&(ze(e,t),nd(e))}function qu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ku(e,n)}function Ju(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Ku(e,n)}function Yu(e,t){return K(e,t)}var Xu=null,Zu=null,Qu=!1,$u=!1,ed=!1,td=0;function nd(e){e!==Zu&&e.next===null&&(Zu===null?Xu=Zu=e:Zu=Zu.next=e),$u=!0,Qu||(Qu=!0,ld())}function rd(e,t){if(!ed&&$u){ed=!0;do for(var n=!1,r=Xu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-De(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,cd(r,a))}else a=Il,a=Pe(r,r===Pl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Fe(r,a)||(n=!0,cd(r,a));r=r.next}while(n);ed=!1}}function id(){ad()}function ad(){$u=Qu=!1;var e=0;td!==0&&Kd()&&(e=td);for(var t=he(),n=null,r=Xu;r!==null;){var i=r.next,a=od(r,t);a===0?(r.next=null,n===null?Xu=i:n.next=i,i===null&&(Zu=n)):(n=r,(e!==0||a&3)&&($u=!0)),r=i}ru!==0&&ru!==5||rd(e,!1),td!==0&&(td=0)}function od(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-De(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ie(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Pl,n=Il,n=Pe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ll===2||Ll===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&q(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Fe(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&q(r),Ge(n)){case 2:case 8:n=ve;break;case 32:n=ye;break;case 268435456:n=xe;break;default:n=ye}return r=sd.bind(null,e),n=K(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&q(r),e.callbackPriority=2,e.callbackNode=null,2}function sd(e,t){if(ru!==0&&ru!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Bu()&&e.callbackNode!==n)return null;var r=Il;return r=Pe(e,e===Pl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(hu(e,r,t),od(e,he()),e.callbackNode!=null&&e.callbackNode===n?sd.bind(null,e):null)}function cd(e,t){if(Bu())return null;hu(e,t,!0)}function ld(){Xd(function(){Nl&6?K(_e,id):ad()})}function ud(){if(td===0){var e=ea;e===0&&(e=je,je<<=1,!(je&261888)&&(je=256)),td=e}return td}function dd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Bt(``+e)}function fd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function pd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=dd((i[Ye]||null).action),o=r.submitter;o&&(t=(t=o[Ye]||null)?dd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new cn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(td!==0){var e=o?fd(i,o):new FormData(i);gs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?fd(i,o):new FormData(i),gs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var md=0;md<Fr.length;md++){var hd=Fr[md];Ir(hd.toLowerCase(),`on`+(hd[0].toUpperCase()+hd.slice(1)))}Ir(Dr,`onAnimationEnd`),Ir(Or,`onAnimationIteration`),Ir(kr,`onAnimationStart`),Ir(`dblclick`,`onDoubleClick`),Ir(`focusin`,`onFocus`),Ir(`focusout`,`onBlur`),Ir(Ar,`onTransitionRun`),Ir(jr,`onTransitionStart`),Ir(Mr,`onTransitionCancel`),Ir(Nr,`onTransitionEnd`),dt(`onMouseEnter`,[`mouseout`,`mouseover`]),dt(`onMouseLeave`,[`mouseout`,`mouseover`]),dt(`onPointerEnter`,[`pointerout`,`pointerover`]),dt(`onPointerLeave`,[`pointerout`,`pointerover`]),ut(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),ut(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),ut(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),ut(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),ut(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),ut(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var gd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),_d=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(gd));function vd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Lr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Lr(e)}i.currentTarget=null,a=c}}}}function yd(e,t){var n=t[Ze];n===void 0&&(n=t[Ze]=new Set);var r=e+`__bubble`;n.has(r)||(Cd(t,e,2,!1),n.add(r))}function bd(e,t,n){var r=0;t&&(r|=4),Cd(n,e,r,t)}var xd=`_reactListening`+Math.random().toString(36).slice(2);function Sd(e){if(!e[xd]){e[xd]=!0,ct.forEach(function(t){t!==`selectionchange`&&(_d.has(t)||bd(t,!1,e),bd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[xd]||(t[xd]=!0,bd(`selectionchange`,!1,t))}}function Cd(e,t,n,r){switch(hp(t)){case 2:var i=lp;break;case 8:i=up;break;default:i=dp}n=i.bind(null,t,n,e),i=void 0,!Xt||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function wd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=rt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}Jt(function(){var r=a,i=Ut(n),s=[];a:{var c=Pr.get(e);if(c!==void 0){var l=cn,u=e;switch(e){case`keypress`:if(nn(n)===0)break a;case`keydown`:case`keyup`:l=En;break;case`focusin`:u=`focus`,l=_n;break;case`focusout`:u=`blur`,l=_n;break;case`beforeblur`:case`afterblur`:l=_n;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=hn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=gn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=On;break;case Dr:case Or:case kr:l=vn;break;case Nr:l=kn;break;case`scroll`:case`scrollend`:l=un;break;case`wheel`:l=An;break;case`copy`:case`cut`:case`paste`:l=yn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Dn;break;case`toggle`:case`beforetoggle`:l=jn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Yt(m,p),g!=null&&d.push(Td(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Ht&&(u=n.relatedTarget||n.fromElement)&&(rt(u)||u[Xe]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?rt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=hn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Dn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:at(l),h=u==null?c:at(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,rt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Dd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Od(s,c,l,d,!1),u!==null&&f!==null&&Od(s,f,u,d,!0)}}a:{if(c=r?at(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=Zn;else if(Gn(c))if(Qn)v=sr;else{v=ar;var y=ir}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Lt(r.elementType)&&(v=Zn):v=or;if(v&&=v(e,r)){Kn(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&kt(c,`number`,c.value)}switch(y=r?at(r):window,e){case`focusin`:(Gn(y)||y.contentEditable===`true`)&&(_r=y,vr=r,yr=null);break;case`focusout`:yr=vr=_r=null;break;case`mousedown`:br=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:br=!1,xr(s,n,i);break;case`selectionchange`:if(gr)break;case`keydown`:case`keyup`:xr(s,n,i)}var b;if(Nn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Vn?zn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(In&&n.locale!==`ko`&&(Vn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Vn&&(b=tn()):(Qt=i,$t=`value`in Qt?Qt.value:Qt.textContent,Vn=!0)),y=Ed(r,x),0<y.length&&(x=new bn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Bn(n),b!==null&&(x.data=b)))),(b=Fn?Hn(e,n):Un(e,n))&&(x=Ed(r,`onBeforeInput`),0<x.length&&(y=new bn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),pd(s,e,r,n,i)}vd(s,t)})}function Td(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ed(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Yt(e,n),i!=null&&r.unshift(Td(e,i,a)),i=Yt(e,t),i!=null&&r.push(Td(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Dd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Od(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Yt(n,a),l!=null&&o.unshift(Td(n,l,c))):i||(l=Yt(n,a),l!=null&&o.push(Td(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var kd=/\r\n?/g,Ad=/\u0000|\uFFFD/g;function jd(e){return(typeof e==`string`?e:``+e).replace(kd,`
10
- `).replace(Ad,``)}function Md(e,t){return t=jd(t),jd(e)===t}function Nd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Nt(e,``+r);break;case`className`:_t(e,`class`,r);break;case`tabIndex`:_t(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:_t(e,n,r);break;case`style`:It(e,r,o);break;case`data`:if(t!==`object`){_t(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Nd(e,t,`name`,a.name,a,null),Nd(e,t,`formEncType`,a.formEncType,a,null),Nd(e,t,`formMethod`,a.formMethod,a,null),Nd(e,t,`formTarget`,a.formTarget,a,null)):(Nd(e,t,`encType`,a.encType,a,null),Nd(e,t,`method`,a.method,a,null),Nd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Bt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:yd(`beforetoggle`,e),yd(`toggle`,e),gt(e,`popover`,r);break;case`xlinkActuate`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:gt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Rt.get(n)||n,gt(e,n,r))}}function Pd(e,t,n,r,a,o){switch(n){case`style`:It(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Nt(e,``+r);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!lt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[Ye]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):gt(e,n,r)}}}function Fd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:yd(`error`,e),yd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Nd(e,t,o,s,n,null)}}a&&Nd(e,t,`srcSet`,n.srcSet,n,null),r&&Nd(e,t,`src`,n.src,n,null);return;case`input`:yd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Nd(e,t,r,d,n,null)}}Ot(e,o,c,l,u,s,a,!1);return;case`select`:for(a in yd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Nd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&At(e,!!r,n,!0):At(e,!!r,t,!1);return;case`textarea`:for(s in yd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Nd(e,t,s,c,n,null)}Mt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Nd(e,t,l,r,n,null)}return;case`dialog`:yd(`beforetoggle`,e),yd(`toggle`,e),yd(`cancel`,e),yd(`close`,e);break;case`iframe`:case`object`:yd(`load`,e);break;case`video`:case`audio`:for(r=0;r<gd.length;r++)yd(gd[r],e);break;case`image`:yd(`error`,e),yd(`load`,e);break;case`details`:yd(`toggle`,e);break;case`embed`:case`source`:case`link`:yd(`error`,e),yd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Nd(e,t,u,r,n,null)}return;default:if(Lt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Pd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Nd(e,t,c,r,n,null))}function Id(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Nd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Nd(e,t,p,m,r,f)}}Dt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Nd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Nd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?At(e,!!n,n?[]:``,!1):At(e,!!n,t,!0)):At(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Nd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Nd(e,t,s,a,r,o)}jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Nd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Nd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Nd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Nd(e,t,u,p,r,m)}return;default:if(Lt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Pd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Pd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Nd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Nd(e,t,f,p,r,m)}function Ld(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Rd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Ld(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Ld(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var zd=null,Bd=null;function Vd(e){return e.nodeType===9?e:e.ownerDocument}function Hd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Ud(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Wd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Gd=null;function Kd(){var e=window.event;return e&&e.type===`popstate`?e===Gd?!1:(Gd=e,!0):(Gd=null,!1)}var qd=typeof setTimeout==`function`?setTimeout:void 0,Jd=typeof clearTimeout==`function`?clearTimeout:void 0,Yd=typeof Promise==`function`?Promise:void 0,Xd=typeof queueMicrotask==`function`?queueMicrotask:Yd===void 0?qd:function(e){return Yd.resolve(null).then(e).catch(Zd)};function Zd(e){setTimeout(function(){throw e})}function Qd(e){return e===`head`}function $d(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Pp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)mf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,mf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[tt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&mf(e.ownerDocument.body);n=i}while(n);Pp(t)}function ef(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function tf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:tf(n),nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function nf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[tt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lf(e.nextSibling),e===null)break}return null}function rf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lf(e.nextSibling),e===null))return null;return e}function af(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lf(e.nextSibling),e===null))return null;return e}function of(e){return e.data===`$?`||e.data===`$~`}function sf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var uf=null;function df(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function ff(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pf(e,t,n){switch(t=Vd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function mf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);nt(e)}var hf=new Map,gf=new Set;function _f(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var vf=I.d;I.d={f:yf,r:bf,D:Cf,C:wf,L:Tf,m:Ef,X:Of,S:Df,M:kf};function yf(){var e=vf.f(),t=yu();return e||t}function bf(e){var t=it(e);t!==null&&t.tag===5&&t.type===`form`?vs(t):vf.r(e)}var xf=typeof document>`u`?null:document;function Sf(e,t,n){var r=xf;if(r&&typeof t==`string`&&t){var i=Et(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),gf.has(i)||(gf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Fd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Cf(e){vf.D(e),Sf(`dns-prefetch`,e,null)}function wf(e,t){vf.C(e,t),Sf(`preconnect`,e,t)}function Tf(e,t,n){vf.L(e,t,n);var r=xf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Et(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Et(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Et(n.imageSizes)+`"]`)):i+=`[href="`+Et(e)+`"]`;var a=i;switch(t){case`style`:a=jf(e);break;case`script`:a=Ff(e)}hf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),hf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Mf(a))||t===`script`&&r.querySelector(If(a))||(t=r.createElement(`link`),Fd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Ef(e,t){vf.m(e,t);var n=xf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Et(r)+`"][href="`+Et(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Ff(e)}if(!hf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),hf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(If(a)))return}r=n.createElement(`link`),Fd(r,`link`,e),st(r),n.head.appendChild(r)}}}function Df(e,t,n){vf.S(e,t,n);var r=xf;if(r&&e){var i=ot(r).hoistableStyles,a=jf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Mf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=hf.get(a))&&zf(e,n);var c=o=r.createElement(`link`);st(c),Fd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Rf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Of(e,t){vf.X(e,t);var n=xf;if(n&&e){var r=ot(n).hoistableScripts,i=Ff(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=f({src:e,async:!0},t),(t=hf.get(i))&&Bf(e,t),a=n.createElement(`script`),st(a),Fd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t){vf.M(e,t);var n=xf;if(n&&e){var r=ot(n).hoistableScripts,i=Ff(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=hf.get(i))&&Bf(e,t),a=n.createElement(`script`),st(a),Fd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Af(e,t,n,r){var a=(a=re.current)?_f(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=jf(n.href),n=ot(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=jf(n.href);var o=ot(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Mf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),hf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},hf.set(e,n),o||Pf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Ff(n),n=ot(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function jf(e){return`href="`+Et(e)+`"`}function Mf(e){return`link[rel="stylesheet"][`+e+`]`}function Nf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Pf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Fd(t,`link`,n),st(t),e.head.appendChild(t))}function Ff(e){return`[src="`+Et(e)+`"]`}function If(e){return`script[async]`+e}function Lf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Et(n.href)+`"]`);if(r)return t.instance=r,st(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),st(r),Fd(r,`style`,a),Rf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=jf(n.href);var o=e.querySelector(Mf(a));if(o)return t.state.loading|=4,t.instance=o,st(o),o;r=Nf(n),(a=hf.get(a))&&zf(r,a),o=(e.ownerDocument||e).createElement(`link`),st(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Fd(o,`link`,r),t.state.loading|=4,Rf(o,n.precedence,e),t.instance=o;case`script`:return o=Ff(n.src),(a=e.querySelector(If(o)))?(t.instance=a,st(a),a):(r=n,(a=hf.get(o))&&(r=f({},n),Bf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),st(a),Fd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Rf(r,n.precedence,e));return t.instance}function Rf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Bf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Vf=null;function Hf(e,t,n){if(Vf===null){var r=new Map,i=Vf=new Map;i.set(n,r)}else i=Vf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[tt]||a[X]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Uf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Wf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Gf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Kf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=jf(r.href),a=t.querySelector(Mf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Yf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,st(a);return}a=t.ownerDocument||t,r=Nf(r),(i=hf.get(i))&&zf(r,i),a=a.createElement(`link`),st(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Fd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Yf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var qf=0;function Jf(e,t){return e.stylesheets&&e.count===0&&Zf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Zf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&qf===0&&(qf=62500*Rd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Zf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>qf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Yf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Xf=null;function Zf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Xf=new Map,t.forEach(Qf,e),Xf=null,Yf.call(e))}function Qf(e,t){if(!(t.state.loading&4)){var n=Xf.get(e);if(n)var r=n.get(null);else{n=new Map,Xf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Yf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var $f={$$typeof:S,Provider:null,Consumer:null,_currentValue:L,_currentValue2:L,_threadCount:0};function ep(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Re(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Re(0),this.hiddenUpdates=Re(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function tp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ep(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Yr(3,null,null,t),e.current=a,a.stateNode=e,t=Xi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ka(a),e}function np(e){return e?(e=qr,e):qr}function rp(e,t,n,r,i,a){i=np(i),r.context===null?r.context=i:r.pendingContext=i,r=ja(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ma(e,r,t),n!==null&&(mu(n,e,t),Na(n,e,t))}function ip(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ap(e,t){ip(e,t),(e=e.alternate)&&ip(e,t)}function op(e){if(e.tag===13||e.tag===31){var t=Wr(e,67108864);t!==null&&mu(t,e,67108864),ap(e,67108864)}}function sp(e){if(e.tag===13||e.tag===31){var t=fu();t=We(t);var n=Wr(e,t);n!==null&&mu(n,e,t),ap(e,t)}}var cp=!0;function lp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,dp(e,t,n,r)}finally{I.p=a,F.T=i}}function up(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,dp(e,t,n,r)}finally{I.p=a,F.T=i}}function dp(e,t,n,r){if(cp){var i=fp(r);if(i===null)wd(e,t,r,pp,n),wp(e,r);else if(Ep(i,e,t,n,r))r.stopPropagation();else if(wp(e,r),t&4&&-1<Cp.indexOf(e)){for(;i!==null;){var a=it(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=J(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-De(o);s.entanglements[1]|=c,o&=~c}nd(a),!(Nl&6)&&(eu=he()+500,rd(0,!1))}}break;case 31:case 13:s=Wr(a,2),s!==null&&mu(s,a,2),yu(),ap(a,2)}if(a=fp(r),a===null&&wd(e,t,r,pp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else wd(e,t,r,null,n)}}function fp(e){return e=Ut(e),mp(e)}var pp=null;function mp(e){if(pp=null,e=rt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return pp=e,null}function hp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ge()){case _e:return 2;case ve:return 8;case ye:case be:return 32;case xe:return 268435456;default:return 32}default:return 32}}var gp=!1,_p=null,vp=null,yp=null,bp=new Map,xp=new Map,Sp=[],Cp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function wp(e,t){switch(e){case`focusin`:case`focusout`:_p=null;break;case`dragenter`:case`dragleave`:vp=null;break;case`mouseover`:case`mouseout`:yp=null;break;case`pointerover`:case`pointerout`:bp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:xp.delete(t.pointerId)}}function Tp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=it(t),t!==null&&op(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ep(e,t,n,r,i){switch(t){case`focusin`:return _p=Tp(_p,e,t,n,r,i),!0;case`dragenter`:return vp=Tp(vp,e,t,n,r,i),!0;case`mouseover`:return yp=Tp(yp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return bp.set(a,Tp(bp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,xp.set(a,Tp(xp.get(a)||null,e,t,n,r,i)),!0}return!1}function Dp(e){var t=rt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,qe(e.priority,function(){sp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,qe(e.priority,function(){sp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Op(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=fp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ht=r,n.target.dispatchEvent(r),Ht=null}else return t=it(n),t!==null&&op(t),e.blockedOn=n,!1;t.shift()}return!0}function kp(e,t,n){Op(e)&&n.delete(t)}function Ap(){gp=!1,_p!==null&&Op(_p)&&(_p=null),vp!==null&&Op(vp)&&(vp=null),yp!==null&&Op(yp)&&(yp=null),bp.forEach(kp),xp.forEach(kp)}function jp(e,n){e.blockedOn===n&&(e.blockedOn=null,gp||(gp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Ap)))}var Mp=null;function Np(e){Mp!==e&&(Mp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Mp===e&&(Mp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(mp(r||n)===null)continue;break}var a=it(n);a!==null&&(e.splice(t,3),t-=3,gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Pp(e){function t(t){return jp(t,e)}_p!==null&&jp(_p,e),vp!==null&&jp(vp,e),yp!==null&&jp(yp,e),bp.forEach(t),xp.forEach(t);for(var n=0;n<Sp.length;n++){var r=Sp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Sp.length&&(n=Sp[0],n.blockedOn===null);)Dp(n),n.blockedOn===null&&Sp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Ye]||null;if(typeof a==`function`)o||Np(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Ye]||null)s=o.formAction;else if(mp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Np(n)}}}function Fp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Ip(e){this._internalRoot=e}Lp.prototype.render=Ip.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;rp(n,fu(),e,t,null,null)},Lp.prototype.unmount=Ip.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;rp(e.current,2,null,e,null,null),yu(),t[Xe]=null}};function Lp(e){this._internalRoot=e}Lp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ke();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Sp.length&&t!==0&&t<Sp[n].priority;n++);Sp.splice(n,0,e),n===0&&Dp(e)}};var Rp=n.version;if(Rp!==`19.2.5`)throw Error(i(527,Rp,`19.2.5`));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var zp={bundleType:0,version:`19.2.5`,rendererPackageName:`react-dom`,currentDispatcherRef:F,reconcilerVersion:`19.2.5`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Bp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bp.isDisabled&&Bp.supportsFiber)try{we=Bp.inject(zp),Te=Bp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=zs,s=Bs,c=Vs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=tp(e,1,!1,null,null,n,r,null,o,s,c,Fp),e[Xe]=t.current,Sd(e),new Ip(t)}})),Je=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=qe()}))(),X=e(b(),1),Ye=(e,t)=>j(T(`/bundles`,e),{signal:t}),Xe=(e,t)=>j(T(`/bundles`,e),{method:`POST`,body:typeof t==`string`?{name:t}:t,fallbackErrorMessage:`Unable to create the bundle right now.`}),Ze=(e,t,n)=>j(T(`/bundles/${t}/details`,e),{signal:n,fallbackErrorMessage:`Unable to load the bundle right now.`}),Qe=(e,t,n)=>j(T(`/bundles/${t}/conversation`,e),{signal:n,fallbackErrorMessage:`Unable to load the bundle conversation right now.`}),$e=(e,t,n)=>j(T(`/bundles/${t}/pull-request`,e),{method:`POST`,body:n,fallbackErrorMessage:`Unable to create the pull request right now.`}),et=(e,t,n)=>j(T(`/bundles/${t}/pull-request-description`,e),{method:`POST`,body:n,fallbackErrorMessage:`Unable to generate the pull request description right now.`}),tt=(e,t)=>j(T(`/bundles/${t}/pull-request/sync`,e),{method:`POST`,fallbackErrorMessage:`Unable to sync the pull request right now.`}),nt=(e,t)=>j(T(`/bundles/${t}/build`,e),{method:`POST`,fallbackErrorMessage:`Unable to build the bundle right now.`}),rt=(e,t)=>j(T(`/bundles/${t}/review`,e),{method:`POST`,fallbackErrorMessage:`Unable to review the bundle right now.`}),it=(e,t)=>j(T(`/bundles/${t}/undo-review`,e),{method:`POST`,fallbackErrorMessage:`Unable to undo the bundle review right now.`}),at=(e,t,n)=>j(T(`/bundles/${t}/follow-up`,e),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the bundle follow-up prompt right now.`}),ot=(e,t,n)=>j(T(`/bundles/${t}/review-findings`,e),{signal:n,fallbackErrorMessage:`Unable to load review findings right now.`}),st=(e,t,n)=>j(T(`/bundles/${t}/review-diff`,e),{signal:n,fallbackErrorMessage:`Unable to load the branch diff right now.`}),ct=(e,t,n)=>j(T(`/bundles/${t}/pull-request/comments`,e),{signal:n,fallbackErrorMessage:`Unable to load GitHub review comments right now.`}),lt=(e,t)=>j(T(`/bundles/${t}/run`,e),{method:`POST`,fallbackErrorMessage:`Unable to start the bundle run right now.`}),ut=(e,t)=>j(T(`/bundles/${t}/stop`,e),{method:`POST`,fallbackErrorMessage:`Unable to stop the bundle run right now.`}),dt=(e,t)=>D(T(`/bundles/${t}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the bundle right now.`}),ft=(e,t)=>j(T(`/preview-status`,e),{signal:t,fallbackErrorMessage:`Unable to load preview status right now.`}),pt=(e,t)=>j(T(`/run-status`,e),{signal:t,fallbackErrorMessage:`Unable to load run status right now.`}),mt=e=>j(s(`/projects/${e}/run`),{method:`POST`,fallbackErrorMessage:`Unable to start the project run right now.`}),ht=e=>j(s(`/projects/${e}/stop-run`),{method:`POST`,fallbackErrorMessage:`Unable to stop the project run right now.`}),gt=(e,t,n={})=>{let r=new URL(T(`/tickets`,e));return r.searchParams.set(`detail`,n.detail??`board`),j(r.toString(),{signal:t})},_t=(e,t)=>{let n=new URL(T(`/tickets`,e));return n.searchParams.set(`detail`,`board-enrichment`),j(n.toString(),{signal:t})},vt=(e,t,n)=>j(T(`/tickets/${e}`,t),{signal:n,fallbackErrorMessage:`Unable to load the ticket right now.`}),yt=e=>j(s(`/tickets`),{method:`POST`,body:e,fallbackErrorMessage:`Unable to create the ticket right now.`}),bt=e=>j(s(`/planning-agent`),{method:`POST`,body:e,fallbackErrorMessage:`Unable to generate tickets right now.`}),xt=(e,t,n)=>j(T(`/tickets/${e}`,t),{method:`PATCH`,body:n,fallbackErrorMessage:`Unable to update the ticket right now.`}),St=(e,t,n)=>j(T(`/tickets/${e}/state`,t),{method:`PATCH`,body:{state:n},fallbackErrorMessage:`Unable to move the ticket right now.`}),Ct=(e,t)=>j(T(`/tickets/${e}/diff`,t),{fallbackErrorMessage:`Unable to load the diff right now.`}),wt=(e,t)=>j(T(`/tickets/${e}/git-status`,t),{fallbackErrorMessage:`Unable to load git status right now.`}),Tt=(e,t,n)=>j(T(`/tickets/${e}/git-commit`,t),{method:`POST`,body:n,fallbackErrorMessage:`Unable to create the commit right now.`}),Et=(e,t,n)=>j(T(`/tickets/${e}/git-commit-message`,t),{method:`POST`,body:n,fallbackErrorMessage:`Unable to generate a commit message right now.`}),Dt=(e,t)=>j(T(`/tickets/${e}/git-push`,t),{method:`POST`,fallbackErrorMessage:`Unable to push the branch right now.`}),Ot=(e,t)=>j(T(`/tickets/${e}/git-commits`,t),{fallbackErrorMessage:`Unable to load local commits right now.`}),kt=(e,t)=>j(T(`/tickets/${e}/git-undo-latest`,t),{method:`POST`,fallbackErrorMessage:`Unable to undo the latest local commit right now.`}),At=(e,t)=>j(T(`/tickets/${e}/build-chain`,t),{method:`POST`,fallbackErrorMessage:`Unable to start the build chain right now.`}),jt=(e,t)=>D(T(`/tickets/${e}/stop-build-chain`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the build chain right now.`}),Mt=(e,t)=>D(T(`/tickets/${e}`,t),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the ticket right now.`}),Nt=(e,t)=>j(T(`/tickets/${e}/undo`,t),{method:`POST`,fallbackErrorMessage:`Unable to undo the ticket right now.`}),Pt=(e,t)=>j(T(`/tickets/${e}/park`,t),{method:`PATCH`,fallbackErrorMessage:`Unable to park the ticket right now.`}),Ft=(e,t)=>j(T(`/tickets/${e}/unpark`,t),{method:`PATCH`,fallbackErrorMessage:`Unable to return the ticket right now.`}),It=e=>j(T(`/tickets/delete-parked`,e),{method:`POST`,fallbackErrorMessage:`Unable to empty Done right now.`}),Lt=(e,t)=>D(T(`/tickets/${e}/retry`,t),{method:`POST`,fallbackErrorMessage:`Unable to retry the ticket right now.`}),Rt=(e,t)=>D(T(`/tickets/${e}/run`,t),{method:`POST`,fallbackErrorMessage:`Unable to start the run right now.`}),zt=(e,t)=>D(T(`/tickets/${e}/open-ide`,t),{method:`POST`,fallbackErrorMessage:`Unable to open the IDE right now.`}),Bt=(e,t)=>D(T(`/tickets/${e}/stop`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the run right now.`}),Vt=(e,t)=>D(T(`/tickets/${e}/stop-build`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the build right now.`}),Ht=(e,t)=>D(T(`/tickets/${e}/resume-build`,t),{method:`POST`,fallbackErrorMessage:`Unable to resume the build right now.`}),Ut=(e,t,n)=>j(T(`/tickets/${e}/follow-up`,t),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the follow-up prompt right now.`}),Wt=(e,t)=>j(T(`/tickets/${e}/review`,t),{method:`POST`,fallbackErrorMessage:`Unable to re-run the review right now.`}),Gt=(e,t,n)=>j(T(`/tickets/${e}/plan-follow-up`,t),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the planning follow-up prompt right now.`}),Kt=(e,t,n)=>D(T(`/tickets/${e}/plan`,t),{method:`POST`,...n===void 0?{}:{body:{worktree_bundle_id:n}},fallbackErrorMessage:`Unable to start AI planning.`}),qt=async(e,t)=>{let n=await j(s(`/models?tool=${e}`),{signal:t,cache:`no-store`});return Array.isArray(n)?n.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&typeof t.label==`string`&&typeof t.provider==`string`&&typeof t.supports_reasoning==`boolean`&&Array.isArray(t.variants)&&t.variants.every(e=>typeof e==`string`)&&(t.context_window==null||typeof t.context_window==`number`)&&(t.max_input_tokens==null||typeof t.max_input_tokens==`number`)&&(t.max_output_tokens==null||typeof t.max_output_tokens==`number`)}):[]},Jt=e=>j(s(`/tool`),{signal:e}),Yt=e=>j(s(`/tool`),{method:`POST`,body:{tool:e}}),Z=v(),Xt=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`}),Zt=`VisuallyHidden`,Qt=X.forwardRef((e,t)=>(0,Z.jsx)(N.span,{...e,ref:t,style:{...Xt,...e.style}}));Qt.displayName=Zt;var $t=Qt,en=`Collapsible`,[tn,nn]=C(en),[rn,an]=tn(en),on=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:s,...c}=e,[l,u]=w({prop:r,defaultProp:i??!1,onChange:s,caller:en});return(0,Z.jsx)(rn,{scope:n,disabled:a,contentId:o(),open:l,onOpenToggle:X.useCallback(()=>u(e=>!e),[u]),children:(0,Z.jsx)(N.div,{"data-state":fn(l),"data-disabled":a?``:void 0,...c,ref:t})})});on.displayName=en;var sn=`CollapsibleTrigger`,cn=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=an(sn,n);return(0,Z.jsx)(N.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":fn(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:A(e.onClick,i.onOpenToggle)})});cn.displayName=sn;var ln=`CollapsibleContent`,un=X.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=an(ln,e.__scopeCollapsible);return(0,Z.jsx)(he,{present:n||i.open,children:({present:e})=>(0,Z.jsx)(dn,{...r,ref:t,present:e})})});un.displayName=ln;var dn=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=an(ln,n),[s,c]=X.useState(r),l=X.useRef(null),u=z(t,l),d=X.useRef(0),f=d.current,p=X.useRef(0),m=p.current,h=o.open||s,g=X.useRef(h),_=X.useRef(void 0);return X.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),E(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,Z.jsx)(N.div,{"data-state":fn(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function fn(e){return e?`open`:`closed`}var pn=on,mn=cn,hn=un,gn=`Dialog`,[_n,vn]=C(gn),[yn,bn]=_n(gn),xn=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,c=X.useRef(null),l=X.useRef(null),[u,d]=w({prop:r,defaultProp:i??!1,onChange:a,caller:gn});return(0,Z.jsx)(yn,{scope:t,triggerRef:c,contentRef:l,contentId:o(),titleId:o(),descriptionId:o(),open:u,onOpenChange:d,onOpenToggle:X.useCallback(()=>d(e=>!e),[d]),modal:s,children:n})};xn.displayName=gn;var Sn=`DialogTrigger`,Cn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(Sn,n),a=z(t,i.triggerRef);return(0,Z.jsx)(N.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Un(i.open),...r,ref:a,onClick:A(e.onClick,i.onOpenToggle)})});Cn.displayName=Sn;var wn=`DialogPortal`,[Tn,En]=_n(wn,{forceMount:void 0}),Dn=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=bn(wn,t);return(0,Z.jsx)(Tn,{scope:t,forceMount:n,children:X.Children.map(r,e=>(0,Z.jsx)(he,{present:n||a.open,children:(0,Z.jsx)(I,{asChild:!0,container:i,children:e})}))})};Dn.displayName=wn;var On=`DialogOverlay`,kn=X.forwardRef((e,t)=>{let n=En(On,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=bn(On,e.__scopeDialog);return a.modal?(0,Z.jsx)(he,{present:r||a.open,children:(0,Z.jsx)(jn,{...i,ref:t})}):null});kn.displayName=On;var An=c(`DialogOverlay.RemoveScroll`),jn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(On,n);return(0,Z.jsx)(l,{as:An,allowPinchZoom:!0,shards:[i.contentRef],children:(0,Z.jsx)(N.div,{"data-state":Un(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),Mn=`DialogContent`,Nn=X.forwardRef((e,t)=>{let n=En(Mn,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=bn(Mn,e.__scopeDialog);return(0,Z.jsx)(he,{present:r||a.open,children:a.modal?(0,Z.jsx)(Pn,{...i,ref:t}):(0,Z.jsx)(Fn,{...i,ref:t})})});Nn.displayName=Mn;var Pn=X.forwardRef((e,t)=>{let n=bn(Mn,e.__scopeDialog),r=X.useRef(null),i=z(t,n.contentRef,r);return X.useEffect(()=>{let e=r.current;if(e)return P(e)},[]),(0,Z.jsx)(In,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:A(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:A(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:A(e.onFocusOutside,e=>e.preventDefault())})}),Fn=X.forwardRef((e,t)=>{let n=bn(Mn,e.__scopeDialog),r=X.useRef(!1),i=X.useRef(!1);return(0,Z.jsx)(In,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),In=X.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=bn(Mn,n),c=X.useRef(null),l=z(t,c);return ze(),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(d,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Un(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(qn,{titleId:s.titleId}),(0,Z.jsx)(Yn,{contentRef:c,descriptionId:s.descriptionId})]})]})}),Ln=`DialogTitle`,Rn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(Ln,n);return(0,Z.jsx)(N.h2,{id:i.titleId,...r,ref:t})});Rn.displayName=Ln;var zn=`DialogDescription`,Bn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(zn,n);return(0,Z.jsx)(N.p,{id:i.descriptionId,...r,ref:t})});Bn.displayName=zn;var Vn=`DialogClose`,Hn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(Vn,n);return(0,Z.jsx)(N.button,{type:`button`,...r,ref:t,onClick:A(e.onClick,()=>i.onOpenChange(!1))})});Hn.displayName=Vn;function Un(e){return e?`open`:`closed`}var Wn=`DialogTitleWarning`,[Gn,Kn]=y(Wn,{contentName:Mn,titleName:Ln,docsSlug:`dialog`}),qn=({titleId:e})=>{let t=Kn(Wn),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
10
+ `).replace(Ad,``)}function Md(e,t){return t=jd(t),jd(e)===t}function Nd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Nt(e,``+r);break;case`className`:_t(e,`class`,r);break;case`tabIndex`:_t(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:_t(e,n,r);break;case`style`:It(e,r,o);break;case`data`:if(t!==`object`){_t(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Nd(e,t,`name`,a.name,a,null),Nd(e,t,`formEncType`,a.formEncType,a,null),Nd(e,t,`formMethod`,a.formMethod,a,null),Nd(e,t,`formTarget`,a.formTarget,a,null)):(Nd(e,t,`encType`,a.encType,a,null),Nd(e,t,`method`,a.method,a,null),Nd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Bt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:yd(`beforetoggle`,e),yd(`toggle`,e),gt(e,`popover`,r);break;case`xlinkActuate`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:vt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:vt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:gt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Rt.get(n)||n,gt(e,n,r))}}function Pd(e,t,n,r,a,o){switch(n){case`style`:It(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Nt(e,``+r);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!lt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[Ye]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):gt(e,n,r)}}}function Fd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:yd(`error`,e),yd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Nd(e,t,o,s,n,null)}}a&&Nd(e,t,`srcSet`,n.srcSet,n,null),r&&Nd(e,t,`src`,n.src,n,null);return;case`input`:yd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Nd(e,t,r,d,n,null)}}Ot(e,o,c,l,u,s,a,!1);return;case`select`:for(a in yd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Nd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&At(e,!!r,n,!0):At(e,!!r,t,!1);return;case`textarea`:for(s in yd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Nd(e,t,s,c,n,null)}Mt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Nd(e,t,l,r,n,null)}return;case`dialog`:yd(`beforetoggle`,e),yd(`toggle`,e),yd(`cancel`,e),yd(`close`,e);break;case`iframe`:case`object`:yd(`load`,e);break;case`video`:case`audio`:for(r=0;r<gd.length;r++)yd(gd[r],e);break;case`image`:yd(`error`,e),yd(`load`,e);break;case`details`:yd(`toggle`,e);break;case`embed`:case`source`:case`link`:yd(`error`,e),yd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Nd(e,t,u,r,n,null)}return;default:if(Lt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Pd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Nd(e,t,c,r,n,null))}function Id(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Nd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Nd(e,t,p,m,r,f)}}Dt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Nd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Nd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?At(e,!!n,n?[]:``,!1):At(e,!!n,t,!0)):At(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Nd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Nd(e,t,s,a,r,o)}jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Nd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Nd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Nd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Nd(e,t,u,p,r,m)}return;default:if(Lt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Pd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Pd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Nd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Nd(e,t,f,p,r,m)}function Ld(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Rd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Ld(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Ld(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var zd=null,Bd=null;function Vd(e){return e.nodeType===9?e:e.ownerDocument}function Hd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Ud(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Wd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Gd=null;function Kd(){var e=window.event;return e&&e.type===`popstate`?e===Gd?!1:(Gd=e,!0):(Gd=null,!1)}var qd=typeof setTimeout==`function`?setTimeout:void 0,Jd=typeof clearTimeout==`function`?clearTimeout:void 0,Yd=typeof Promise==`function`?Promise:void 0,Xd=typeof queueMicrotask==`function`?queueMicrotask:Yd===void 0?qd:function(e){return Yd.resolve(null).then(e).catch(Zd)};function Zd(e){setTimeout(function(){throw e})}function Qd(e){return e===`head`}function $d(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Pp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)mf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,mf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[tt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&mf(e.ownerDocument.body);n=i}while(n);Pp(t)}function ef(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function tf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:tf(n),nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function nf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[tt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lf(e.nextSibling),e===null)break}return null}function rf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lf(e.nextSibling),e===null))return null;return e}function af(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lf(e.nextSibling),e===null))return null;return e}function of(e){return e.data===`$?`||e.data===`$~`}function sf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var uf=null;function df(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function ff(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pf(e,t,n){switch(t=Vd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function mf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);nt(e)}var hf=new Map,gf=new Set;function _f(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var vf=I.d;I.d={f:yf,r:bf,D:Cf,C:wf,L:Tf,m:Ef,X:Of,S:Df,M:kf};function yf(){var e=vf.f(),t=yu();return e||t}function bf(e){var t=it(e);t!==null&&t.tag===5&&t.type===`form`?vs(t):vf.r(e)}var xf=typeof document>`u`?null:document;function Sf(e,t,n){var r=xf;if(r&&typeof t==`string`&&t){var i=Et(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),gf.has(i)||(gf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Fd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Cf(e){vf.D(e),Sf(`dns-prefetch`,e,null)}function wf(e,t){vf.C(e,t),Sf(`preconnect`,e,t)}function Tf(e,t,n){vf.L(e,t,n);var r=xf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Et(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Et(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Et(n.imageSizes)+`"]`)):i+=`[href="`+Et(e)+`"]`;var a=i;switch(t){case`style`:a=jf(e);break;case`script`:a=Ff(e)}hf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),hf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Mf(a))||t===`script`&&r.querySelector(If(a))||(t=r.createElement(`link`),Fd(t,`link`,e),st(t),r.head.appendChild(t)))}}function Ef(e,t){vf.m(e,t);var n=xf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Et(r)+`"][href="`+Et(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Ff(e)}if(!hf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),hf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(If(a)))return}r=n.createElement(`link`),Fd(r,`link`,e),st(r),n.head.appendChild(r)}}}function Df(e,t,n){vf.S(e,t,n);var r=xf;if(r&&e){var i=ot(r).hoistableStyles,a=jf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Mf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=hf.get(a))&&zf(e,n);var c=o=r.createElement(`link`);st(c),Fd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Rf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Of(e,t){vf.X(e,t);var n=xf;if(n&&e){var r=ot(n).hoistableScripts,i=Ff(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=f({src:e,async:!0},t),(t=hf.get(i))&&Bf(e,t),a=n.createElement(`script`),st(a),Fd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t){vf.M(e,t);var n=xf;if(n&&e){var r=ot(n).hoistableScripts,i=Ff(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=hf.get(i))&&Bf(e,t),a=n.createElement(`script`),st(a),Fd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Af(e,t,n,r){var a=(a=re.current)?_f(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=jf(n.href),n=ot(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=jf(n.href);var o=ot(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Mf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),hf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},hf.set(e,n),o||Pf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Ff(n),n=ot(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function jf(e){return`href="`+Et(e)+`"`}function Mf(e){return`link[rel="stylesheet"][`+e+`]`}function Nf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Pf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Fd(t,`link`,n),st(t),e.head.appendChild(t))}function Ff(e){return`[src="`+Et(e)+`"]`}function If(e){return`script[async]`+e}function Lf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Et(n.href)+`"]`);if(r)return t.instance=r,st(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),st(r),Fd(r,`style`,a),Rf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=jf(n.href);var o=e.querySelector(Mf(a));if(o)return t.state.loading|=4,t.instance=o,st(o),o;r=Nf(n),(a=hf.get(a))&&zf(r,a),o=(e.ownerDocument||e).createElement(`link`),st(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Fd(o,`link`,r),t.state.loading|=4,Rf(o,n.precedence,e),t.instance=o;case`script`:return o=Ff(n.src),(a=e.querySelector(If(o)))?(t.instance=a,st(a),a):(r=n,(a=hf.get(o))&&(r=f({},n),Bf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),st(a),Fd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Rf(r,n.precedence,e));return t.instance}function Rf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Bf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Vf=null;function Hf(e,t,n){if(Vf===null){var r=new Map,i=Vf=new Map;i.set(n,r)}else i=Vf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[tt]||a[X]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Uf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Wf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Gf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Kf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=jf(r.href),a=t.querySelector(Mf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Yf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,st(a);return}a=t.ownerDocument||t,r=Nf(r),(i=hf.get(i))&&zf(r,i),a=a.createElement(`link`),st(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Fd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Yf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var qf=0;function Jf(e,t){return e.stylesheets&&e.count===0&&Zf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Zf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&qf===0&&(qf=62500*Rd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Zf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>qf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Yf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Xf=null;function Zf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Xf=new Map,t.forEach(Qf,e),Xf=null,Yf.call(e))}function Qf(e,t){if(!(t.state.loading&4)){var n=Xf.get(e);if(n)var r=n.get(null);else{n=new Map,Xf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Yf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var $f={$$typeof:S,Provider:null,Consumer:null,_currentValue:L,_currentValue2:L,_threadCount:0};function ep(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Re(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Re(0),this.hiddenUpdates=Re(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function tp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ep(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Yr(3,null,null,t),e.current=a,a.stateNode=e,t=Xi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ka(a),e}function np(e){return e?(e=qr,e):qr}function rp(e,t,n,r,i,a){i=np(i),r.context===null?r.context=i:r.pendingContext=i,r=ja(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ma(e,r,t),n!==null&&(mu(n,e,t),Na(n,e,t))}function ip(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ap(e,t){ip(e,t),(e=e.alternate)&&ip(e,t)}function op(e){if(e.tag===13||e.tag===31){var t=Wr(e,67108864);t!==null&&mu(t,e,67108864),ap(e,67108864)}}function sp(e){if(e.tag===13||e.tag===31){var t=fu();t=We(t);var n=Wr(e,t);n!==null&&mu(n,e,t),ap(e,t)}}var cp=!0;function lp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,dp(e,t,n,r)}finally{I.p=a,F.T=i}}function up(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,dp(e,t,n,r)}finally{I.p=a,F.T=i}}function dp(e,t,n,r){if(cp){var i=fp(r);if(i===null)wd(e,t,r,pp,n),wp(e,r);else if(Ep(i,e,t,n,r))r.stopPropagation();else if(wp(e,r),t&4&&-1<Cp.indexOf(e)){for(;i!==null;){var a=it(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=J(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-De(o);s.entanglements[1]|=c,o&=~c}nd(a),!(Nl&6)&&(eu=he()+500,rd(0,!1))}}break;case 31:case 13:s=Wr(a,2),s!==null&&mu(s,a,2),yu(),ap(a,2)}if(a=fp(r),a===null&&wd(e,t,r,pp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else wd(e,t,r,null,n)}}function fp(e){return e=Ut(e),mp(e)}var pp=null;function mp(e){if(pp=null,e=rt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return pp=e,null}function hp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ge()){case _e:return 2;case ve:return 8;case ye:case be:return 32;case xe:return 268435456;default:return 32}default:return 32}}var gp=!1,_p=null,vp=null,yp=null,bp=new Map,xp=new Map,Sp=[],Cp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function wp(e,t){switch(e){case`focusin`:case`focusout`:_p=null;break;case`dragenter`:case`dragleave`:vp=null;break;case`mouseover`:case`mouseout`:yp=null;break;case`pointerover`:case`pointerout`:bp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:xp.delete(t.pointerId)}}function Tp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=it(t),t!==null&&op(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ep(e,t,n,r,i){switch(t){case`focusin`:return _p=Tp(_p,e,t,n,r,i),!0;case`dragenter`:return vp=Tp(vp,e,t,n,r,i),!0;case`mouseover`:return yp=Tp(yp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return bp.set(a,Tp(bp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,xp.set(a,Tp(xp.get(a)||null,e,t,n,r,i)),!0}return!1}function Dp(e){var t=rt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,qe(e.priority,function(){sp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,qe(e.priority,function(){sp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Op(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=fp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ht=r,n.target.dispatchEvent(r),Ht=null}else return t=it(n),t!==null&&op(t),e.blockedOn=n,!1;t.shift()}return!0}function kp(e,t,n){Op(e)&&n.delete(t)}function Ap(){gp=!1,_p!==null&&Op(_p)&&(_p=null),vp!==null&&Op(vp)&&(vp=null),yp!==null&&Op(yp)&&(yp=null),bp.forEach(kp),xp.forEach(kp)}function jp(e,n){e.blockedOn===n&&(e.blockedOn=null,gp||(gp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Ap)))}var Mp=null;function Np(e){Mp!==e&&(Mp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Mp===e&&(Mp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(mp(r||n)===null)continue;break}var a=it(n);a!==null&&(e.splice(t,3),t-=3,gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Pp(e){function t(t){return jp(t,e)}_p!==null&&jp(_p,e),vp!==null&&jp(vp,e),yp!==null&&jp(yp,e),bp.forEach(t),xp.forEach(t);for(var n=0;n<Sp.length;n++){var r=Sp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Sp.length&&(n=Sp[0],n.blockedOn===null);)Dp(n),n.blockedOn===null&&Sp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Ye]||null;if(typeof a==`function`)o||Np(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Ye]||null)s=o.formAction;else if(mp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Np(n)}}}function Fp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Ip(e){this._internalRoot=e}Lp.prototype.render=Ip.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;rp(n,fu(),e,t,null,null)},Lp.prototype.unmount=Ip.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;rp(e.current,2,null,e,null,null),yu(),t[Xe]=null}};function Lp(e){this._internalRoot=e}Lp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ke();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Sp.length&&t!==0&&t<Sp[n].priority;n++);Sp.splice(n,0,e),n===0&&Dp(e)}};var Rp=n.version;if(Rp!==`19.2.5`)throw Error(i(527,Rp,`19.2.5`));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var zp={bundleType:0,version:`19.2.5`,rendererPackageName:`react-dom`,currentDispatcherRef:F,reconcilerVersion:`19.2.5`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Bp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bp.isDisabled&&Bp.supportsFiber)try{we=Bp.inject(zp),Te=Bp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=zs,s=Bs,c=Vs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=tp(e,1,!1,null,null,n,r,null,o,s,c,Fp),e[Xe]=t.current,Sd(e),new Ip(t)}})),Je=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=qe()}))(),X=e(b(),1),Ye=(e,t)=>j(T(`/bundles`,e),{signal:t}),Xe=(e,t)=>j(T(`/bundles`,e),{method:`POST`,body:typeof t==`string`?{name:t}:t,fallbackErrorMessage:`Unable to create the bundle right now.`}),Ze=(e,t,n)=>j(T(`/bundles/${t}/details`,e),{signal:n,fallbackErrorMessage:`Unable to load the bundle right now.`}),Qe=(e,t,n)=>j(T(`/bundles/${t}/conversation`,e),{signal:n,fallbackErrorMessage:`Unable to load the bundle conversation right now.`}),$e=(e,t,n)=>j(T(`/bundles/${t}/pull-request`,e),{method:`POST`,body:n,fallbackErrorMessage:`Unable to create the pull request right now.`}),et=(e,t,n)=>j(T(`/bundles/${t}/pull-request-description`,e),{method:`POST`,body:n,fallbackErrorMessage:`Unable to generate the pull request description right now.`}),tt=(e,t)=>j(T(`/bundles/${t}/pull-request/sync`,e),{method:`POST`,fallbackErrorMessage:`Unable to sync the pull request right now.`}),nt=(e,t)=>j(T(`/bundles/${t}/build`,e),{method:`POST`,fallbackErrorMessage:`Unable to build the bundle right now.`}),rt=(e,t)=>j(T(`/bundles/${t}/review`,e),{method:`POST`,fallbackErrorMessage:`Unable to review the bundle right now.`}),it=(e,t)=>j(T(`/bundles/${t}/undo-review`,e),{method:`POST`,fallbackErrorMessage:`Unable to undo the bundle review right now.`}),at=(e,t,n)=>j(T(`/bundles/${t}/follow-up`,e),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the bundle follow-up prompt right now.`}),ot=(e,t,n)=>j(T(`/bundles/${t}/review-findings`,e),{signal:n,fallbackErrorMessage:`Unable to load review findings right now.`}),st=(e,t,n)=>j(T(`/bundles/${t}/review-diff`,e),{signal:n,fallbackErrorMessage:`Unable to load the branch diff right now.`}),ct=(e,t,n)=>j(T(`/bundles/${t}/pull-request/comments`,e),{signal:n,fallbackErrorMessage:`Unable to load GitHub review comments right now.`}),lt=(e,t)=>j(T(`/bundles/${t}/run`,e),{method:`POST`,fallbackErrorMessage:`Unable to start the bundle run right now.`}),ut=(e,t)=>j(T(`/bundles/${t}/stop`,e),{method:`POST`,fallbackErrorMessage:`Unable to stop the bundle run right now.`}),dt=(e,t)=>D(T(`/bundles/${t}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the bundle right now.`}),ft=(e,t)=>j(T(`/preview-status`,e),{signal:t,fallbackErrorMessage:`Unable to load preview status right now.`}),pt=(e,t)=>j(T(`/run-status`,e),{signal:t,fallbackErrorMessage:`Unable to load run status right now.`}),mt=e=>j(s(`/projects/${e}/run`),{method:`POST`,fallbackErrorMessage:`Unable to start the project run right now.`}),ht=e=>j(s(`/projects/${e}/stop-run`),{method:`POST`,fallbackErrorMessage:`Unable to stop the project run right now.`}),gt=(e,t,n={})=>{let r=new URL(T(`/tickets`,e));return r.searchParams.set(`detail`,n.detail??`board`),j(r.toString(),{signal:t})},_t=(e,t)=>{let n=new URL(T(`/tickets`,e));return n.searchParams.set(`detail`,`board-enrichment`),j(n.toString(),{signal:t})},vt=(e,t,n)=>j(T(`/tickets/${e}`,t),{signal:n,fallbackErrorMessage:`Unable to load the ticket right now.`}),yt=e=>j(s(`/tickets`),{method:`POST`,body:e,fallbackErrorMessage:`Unable to create the ticket right now.`}),bt=e=>j(s(`/planning-agent`),{method:`POST`,body:e,fallbackErrorMessage:`Unable to generate tickets right now.`}),xt=(e,t,n)=>j(T(`/tickets/${e}`,t),{method:`PATCH`,body:n,fallbackErrorMessage:`Unable to update the ticket right now.`}),St=(e,t,n)=>j(T(`/tickets/${e}/state`,t),{method:`PATCH`,body:{state:n},fallbackErrorMessage:`Unable to move the ticket right now.`}),Ct=(e,t)=>j(T(`/tickets/${e}/diff`,t),{fallbackErrorMessage:`Unable to load the diff right now.`}),wt=(e,t,n={})=>{let r=new URL(T(`/tickets/${e}/git-status`,t));return n.refreshRemote&&r.searchParams.set(`refresh_remote`,`true`),j(r.toString(),{fallbackErrorMessage:`Unable to load git status right now.`})},Tt=(e,t,n)=>j(T(`/tickets/${e}/git-commit`,t),{method:`POST`,body:n,fallbackErrorMessage:`Unable to create the commit right now.`}),Et=(e,t,n)=>j(T(`/tickets/${e}/git-commit-message`,t),{method:`POST`,body:n,fallbackErrorMessage:`Unable to generate a commit message right now.`}),Dt=(e,t)=>j(T(`/tickets/${e}/git-push`,t),{method:`POST`,fallbackErrorMessage:`Unable to push the branch right now.`}),Ot=(e,t)=>j(T(`/tickets/${e}/git-commits`,t),{fallbackErrorMessage:`Unable to load local commits right now.`}),kt=(e,t)=>j(T(`/tickets/${e}/git-undo-latest`,t),{method:`POST`,fallbackErrorMessage:`Unable to undo the latest local commit right now.`}),At=(e,t)=>j(T(`/tickets/${e}/build-chain`,t),{method:`POST`,fallbackErrorMessage:`Unable to start the build chain right now.`}),jt=(e,t)=>D(T(`/tickets/${e}/stop-build-chain`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the build chain right now.`}),Mt=(e,t)=>D(T(`/tickets/${e}`,t),{method:`DELETE`,fallbackErrorMessage:`Unable to delete the ticket right now.`}),Nt=(e,t)=>j(T(`/tickets/${e}/undo`,t),{method:`POST`,fallbackErrorMessage:`Unable to undo the ticket right now.`}),Pt=(e,t)=>j(T(`/tickets/${e}/park`,t),{method:`PATCH`,fallbackErrorMessage:`Unable to park the ticket right now.`}),Ft=(e,t)=>j(T(`/tickets/${e}/unpark`,t),{method:`PATCH`,fallbackErrorMessage:`Unable to return the ticket right now.`}),It=e=>j(T(`/tickets/delete-parked`,e),{method:`POST`,fallbackErrorMessage:`Unable to empty Done right now.`}),Lt=(e,t)=>D(T(`/tickets/${e}/retry`,t),{method:`POST`,fallbackErrorMessage:`Unable to retry the ticket right now.`}),Rt=(e,t)=>D(T(`/tickets/${e}/run`,t),{method:`POST`,fallbackErrorMessage:`Unable to start the run right now.`}),zt=(e,t)=>D(T(`/tickets/${e}/open-ide`,t),{method:`POST`,fallbackErrorMessage:`Unable to open the IDE right now.`}),Bt=(e,t)=>D(T(`/tickets/${e}/stop`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the run right now.`}),Vt=(e,t)=>D(T(`/tickets/${e}/stop-build`,t),{method:`POST`,fallbackErrorMessage:`Unable to stop the build right now.`}),Ht=(e,t)=>D(T(`/tickets/${e}/resume-build`,t),{method:`POST`,fallbackErrorMessage:`Unable to resume the build right now.`}),Ut=(e,t,n)=>j(T(`/tickets/${e}/follow-up`,t),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the follow-up prompt right now.`}),Wt=(e,t)=>j(T(`/tickets/${e}/review`,t),{method:`POST`,fallbackErrorMessage:`Unable to re-run the review right now.`}),Gt=(e,t,n)=>j(T(`/tickets/${e}/plan-follow-up`,t),{method:`POST`,body:{instruction:n},fallbackErrorMessage:`Unable to send the planning follow-up prompt right now.`}),Kt=(e,t,n)=>D(T(`/tickets/${e}/plan`,t),{method:`POST`,...n===void 0?{}:{body:{worktree_bundle_id:n}},fallbackErrorMessage:`Unable to start AI planning.`}),qt=async(e,t)=>{let n=await j(s(`/models?tool=${e}`),{signal:t,cache:`no-store`});return Array.isArray(n)?n.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&typeof t.label==`string`&&typeof t.provider==`string`&&typeof t.supports_reasoning==`boolean`&&Array.isArray(t.variants)&&t.variants.every(e=>typeof e==`string`)&&(t.context_window==null||typeof t.context_window==`number`)&&(t.max_input_tokens==null||typeof t.max_input_tokens==`number`)&&(t.max_output_tokens==null||typeof t.max_output_tokens==`number`)}):[]},Jt=e=>j(s(`/tool`),{signal:e}),Yt=e=>j(s(`/tool`),{method:`POST`,body:{tool:e}}),Z=v(),Xt=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`}),Zt=`VisuallyHidden`,Qt=X.forwardRef((e,t)=>(0,Z.jsx)(N.span,{...e,ref:t,style:{...Xt,...e.style}}));Qt.displayName=Zt;var $t=Qt,en=`Collapsible`,[tn,nn]=C(en),[rn,an]=tn(en),on=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:s,...c}=e,[l,u]=w({prop:r,defaultProp:i??!1,onChange:s,caller:en});return(0,Z.jsx)(rn,{scope:n,disabled:a,contentId:o(),open:l,onOpenToggle:X.useCallback(()=>u(e=>!e),[u]),children:(0,Z.jsx)(N.div,{"data-state":fn(l),"data-disabled":a?``:void 0,...c,ref:t})})});on.displayName=en;var sn=`CollapsibleTrigger`,cn=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=an(sn,n);return(0,Z.jsx)(N.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":fn(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:A(e.onClick,i.onOpenToggle)})});cn.displayName=sn;var ln=`CollapsibleContent`,un=X.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=an(ln,e.__scopeCollapsible);return(0,Z.jsx)(he,{present:n||i.open,children:({present:e})=>(0,Z.jsx)(dn,{...r,ref:t,present:e})})});un.displayName=ln;var dn=X.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=an(ln,n),[s,c]=X.useState(r),l=X.useRef(null),u=z(t,l),d=X.useRef(0),f=d.current,p=X.useRef(0),m=p.current,h=o.open||s,g=X.useRef(h),_=X.useRef(void 0);return X.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),E(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,Z.jsx)(N.div,{"data-state":fn(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function fn(e){return e?`open`:`closed`}var pn=on,mn=cn,hn=un,gn=`Dialog`,[_n,vn]=C(gn),[yn,bn]=_n(gn),xn=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,c=X.useRef(null),l=X.useRef(null),[u,d]=w({prop:r,defaultProp:i??!1,onChange:a,caller:gn});return(0,Z.jsx)(yn,{scope:t,triggerRef:c,contentRef:l,contentId:o(),titleId:o(),descriptionId:o(),open:u,onOpenChange:d,onOpenToggle:X.useCallback(()=>d(e=>!e),[d]),modal:s,children:n})};xn.displayName=gn;var Sn=`DialogTrigger`,Cn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(Sn,n),a=z(t,i.triggerRef);return(0,Z.jsx)(N.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Un(i.open),...r,ref:a,onClick:A(e.onClick,i.onOpenToggle)})});Cn.displayName=Sn;var wn=`DialogPortal`,[Tn,En]=_n(wn,{forceMount:void 0}),Dn=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=bn(wn,t);return(0,Z.jsx)(Tn,{scope:t,forceMount:n,children:X.Children.map(r,e=>(0,Z.jsx)(he,{present:n||a.open,children:(0,Z.jsx)(I,{asChild:!0,container:i,children:e})}))})};Dn.displayName=wn;var On=`DialogOverlay`,kn=X.forwardRef((e,t)=>{let n=En(On,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=bn(On,e.__scopeDialog);return a.modal?(0,Z.jsx)(he,{present:r||a.open,children:(0,Z.jsx)(jn,{...i,ref:t})}):null});kn.displayName=On;var An=c(`DialogOverlay.RemoveScroll`),jn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(On,n);return(0,Z.jsx)(l,{as:An,allowPinchZoom:!0,shards:[i.contentRef],children:(0,Z.jsx)(N.div,{"data-state":Un(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),Mn=`DialogContent`,Nn=X.forwardRef((e,t)=>{let n=En(Mn,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=bn(Mn,e.__scopeDialog);return(0,Z.jsx)(he,{present:r||a.open,children:a.modal?(0,Z.jsx)(Pn,{...i,ref:t}):(0,Z.jsx)(Fn,{...i,ref:t})})});Nn.displayName=Mn;var Pn=X.forwardRef((e,t)=>{let n=bn(Mn,e.__scopeDialog),r=X.useRef(null),i=z(t,n.contentRef,r);return X.useEffect(()=>{let e=r.current;if(e)return P(e)},[]),(0,Z.jsx)(In,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:A(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:A(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:A(e.onFocusOutside,e=>e.preventDefault())})}),Fn=X.forwardRef((e,t)=>{let n=bn(Mn,e.__scopeDialog),r=X.useRef(!1),i=X.useRef(!1);return(0,Z.jsx)(In,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),In=X.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=bn(Mn,n),c=X.useRef(null),l=z(t,c);return ze(),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(d,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Un(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(qn,{titleId:s.titleId}),(0,Z.jsx)(Yn,{contentRef:c,descriptionId:s.descriptionId})]})]})}),Ln=`DialogTitle`,Rn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(Ln,n);return(0,Z.jsx)(N.h2,{id:i.titleId,...r,ref:t})});Rn.displayName=Ln;var zn=`DialogDescription`,Bn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(zn,n);return(0,Z.jsx)(N.p,{id:i.descriptionId,...r,ref:t})});Bn.displayName=zn;var Vn=`DialogClose`,Hn=X.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=bn(Vn,n);return(0,Z.jsx)(N.button,{type:`button`,...r,ref:t,onClick:A(e.onClick,()=>i.onOpenChange(!1))})});Hn.displayName=Vn;function Un(e){return e?`open`:`closed`}var Wn=`DialogTitleWarning`,[Gn,Kn]=y(Wn,{contentName:Mn,titleName:Ln,docsSlug:`dialog`}),qn=({titleId:e})=>{let t=Kn(Wn),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
11
11
 
12
12
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
13
13
 
@@ -130,13 +130,13 @@ ${s.join(`
130
130
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),nB&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=TB(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Bz(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-EB),EB),t/=EB,t/Math.abs(t)+Math.round(t*(DB-1)))}shouldForceSelection(e){return Qz?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),OB)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Qz&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<kB&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=dB(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=TB(n,this._bufferService.cols)}};jB=xP([SP(3,YP),SP(4,ZP),SP(5,lF),SP(6,tF),SP(7,uF),SP(8,cF)],jB);var MB=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},NB=class{constructor(){this._color=new MB,this._css=new MB}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},PB=Object.freeze((()=>{let e=[cz.toColor(`#2e3436`),cz.toColor(`#cc0000`),cz.toColor(`#4e9a06`),cz.toColor(`#c4a000`),cz.toColor(`#3465a4`),cz.toColor(`#75507b`),cz.toColor(`#06989a`),cz.toColor(`#d3d7cf`),cz.toColor(`#555753`),cz.toColor(`#ef2929`),cz.toColor(`#8ae234`),cz.toColor(`#fce94f`),cz.toColor(`#729fcf`),cz.toColor(`#ad7fa8`),cz.toColor(`#34e2e2`),cz.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:oz.toCss(r,i,a),rgba:oz.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:oz.toCss(n,n,n),rgba:oz.toRgba(n,n,n)})}return e})()),FB=cz.toColor(`#ffffff`),IB=cz.toColor(`#000000`),LB=cz.toColor(`#ffffff`),RB=IB,zB={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},BB=FB,VB=class extends JF{constructor(e){super(),this._optionsService=e,this._contrastCache=new NB,this._halfContrastCache=new NB,this._onChangeColors=this._register(new yI),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:FB,background:IB,cursor:LB,cursorAccent:RB,selectionForeground:void 0,selectionBackgroundTransparent:zB,selectionBackgroundOpaque:sz.blend(IB,zB),selectionInactiveBackgroundTransparent:zB,selectionInactiveBackgroundOpaque:sz.blend(IB,zB),scrollbarSliderBackground:sz.opacity(FB,.2),scrollbarSliderHoverBackground:sz.opacity(FB,.4),scrollbarSliderActiveBackground:sz.opacity(FB,.5),overviewRulerBorder:FB,ansi:PB.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=HB(e.foreground,FB),t.background=HB(e.background,IB),t.cursor=sz.blend(t.background,HB(e.cursor,LB)),t.cursorAccent=sz.blend(t.background,HB(e.cursorAccent,RB)),t.selectionBackgroundTransparent=HB(e.selectionBackground,zB),t.selectionBackgroundOpaque=sz.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=HB(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=sz.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?HB(e.selectionForeground,az):void 0,t.selectionForeground===az&&(t.selectionForeground=void 0),sz.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=sz.opacity(t.selectionBackgroundTransparent,.3)),sz.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=sz.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=HB(e.scrollbarSliderBackground,sz.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=HB(e.scrollbarSliderHoverBackground,sz.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=HB(e.scrollbarSliderActiveBackground,sz.opacity(t.foreground,.5)),t.overviewRulerBorder=HB(e.overviewRulerBorder,BB),t.ansi=PB.slice(),t.ansi[0]=HB(e.black,PB[0]),t.ansi[1]=HB(e.red,PB[1]),t.ansi[2]=HB(e.green,PB[2]),t.ansi[3]=HB(e.yellow,PB[3]),t.ansi[4]=HB(e.blue,PB[4]),t.ansi[5]=HB(e.magenta,PB[5]),t.ansi[6]=HB(e.cyan,PB[6]),t.ansi[7]=HB(e.white,PB[7]),t.ansi[8]=HB(e.brightBlack,PB[8]),t.ansi[9]=HB(e.brightRed,PB[9]),t.ansi[10]=HB(e.brightGreen,PB[10]),t.ansi[11]=HB(e.brightYellow,PB[11]),t.ansi[12]=HB(e.brightBlue,PB[12]),t.ansi[13]=HB(e.brightMagenta,PB[13]),t.ansi[14]=HB(e.brightCyan,PB[14]),t.ansi[15]=HB(e.brightWhite,PB[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=HB(e.extendedAnsi[r],PB[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};VB=xP([SP(0,tF)],VB);function HB(e,t){if(e!==void 0)try{return cz.toColor(e)}catch{}return t}var UB=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},WB=class{constructor(){this._services=new UB,this._services.set($P,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=KP(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},GB={trace:0,debug:1,info:2,warn:3,error:4,off:5},KB=`xterm.js: `,qB=class extends JF{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),JB=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=GB[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:KB)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};qB=xP([SP(0,tF)],qB);var JB,YB=class extends JF{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new yI),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new yI),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new yI),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},XB=3,ZB=Object.freeze(new BP),QB=0,$B=2,eV=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*XB);let r=t||HP.fromCharData([0,RP,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*XB+0],n=t&2097151;return[this._data[e*XB+1],t&2097152?this._combined[e]:n?PP(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*XB+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*XB+0]=e|2097152|t[2]<<22):this._data[e*XB+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*XB+0]>>22}hasWidth(e){return this._data[e*XB+0]&12582912}getFg(e){return this._data[e*XB+1]}getBg(e){return this._data[e*XB+2]}hasContent(e){return this._data[e*XB+0]&4194303}getCodePoint(e){let t=this._data[e*XB+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*XB+0]&2097152}getString(e){let t=this._data[e*XB+0];return t&2097152?this._combined[e]:t&2097151?PP(t&2097151):``}isProtected(e){return this._data[e*XB+2]&536870912}loadCell(e,t){return QB=e*XB,t.content=this._data[QB+0],t.fg=this._data[QB+1],t.bg=this._data[QB+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*XB+0]=t.content,this._data[e*XB+1]=t.fg,this._data[e*XB+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*XB+0]=t|n<<22,this._data[e*XB+1]=r.fg,this._data[e*XB+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*XB+0];r&2097152?this._combined[e]+=PP(t):r&2097151?(this._combined[e]=PP(r&2097151)+PP(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*XB+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new HP;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new HP;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*$B<this._data.buffer.byteLength;let n=e*XB;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*$B<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*$B<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*XB+0]&4194303)return e+(this._data[e*XB+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*XB+0]&4194303||this._data[e*XB+2]&50331648)return e+(this._data[e*XB+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<XB;e++)this._data[(n+i)*XB+e]=a[(t+i)*XB+e];a[(t+i)*XB+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<XB;e++)this._data[(n+i)*XB+e]=a[(t+i)*XB+e];a[(t+i)*XB+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*XB+0],n=e&2097151,a=e&2097152?this._combined[t]:n?PP(n):zP;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function tV(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=aV(u,d,t),p=1,m=0;for(;p<u.length;){let e=aV(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function nV(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function rV(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function iV(e,t,n){let r=[],i=e.map((n,r)=>aV(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=aV(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function aV(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var oV=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new yI),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),UF(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};oV._nextId=1;var sV=oV,cV={},lV=cV.B;cV[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},cV.A={"#":`£`},cV.B=void 0,cV[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},cV.C=cV[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},cV.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},cV.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},cV.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},cV.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},cV.E=cV[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},cV.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},cV.H=cV[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},cV[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var uV=4294967295,dV=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=ZB.clone(),this.savedCharset=lV,this.markers=[],this._nullCell=HP.fromCharData([0,RP,1,0]),this._whitespaceCell=HP.fromCharData([0,zP,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new sB,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new YB(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new VP),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new VP),this._whitespaceCell}getBlankLine(e,t){return new eV(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>uV?uV:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ZB);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new YB(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(ZB),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new eV(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new eV(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=tV(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ZB),n);if(r.length>0){let n=nV(this.lines,r);rV(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(ZB),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new eV(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(ZB),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=iV(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(ZB,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=aV(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new sV(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},fV=class extends JF{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new yI),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new dV(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new dV(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},pV=2,mV=1,hV=class extends JF{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new yI),this.onResize=this._onResize.event,this._onScroll=this._register(new yI),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,pV),this.rows=Math.max(e.rawOptions.rows||0,mV),this.buffers=this._register(new fV(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};hV=xP([SP(0,tF)],hV);var gV={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Qz,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},_V=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],vV=class extends JF{constructor(e){super(),this._onOptionChange=this._register(new yI),this.onOptionChange=this._onOptionChange.event;let t={...gV};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(GF(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in gV))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in gV))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=gV[e],!yV(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=gV[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=_V.includes(t)?t:gV[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={};break}return t}};function yV(e){return e===`block`||e===`underline`||e===`bar`}function bV(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&bV(e[r],t-1);return n}var xV=Object.freeze({insertMode:!1}),SV=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),CV=class extends JF{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new yI),this.onData=this._onData.event,this._onUserInput=this._register(new yI),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new yI),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new yI),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=bV(xV),this.decPrivateModes=bV(SV)}reset(){this.modes=bV(xV),this.decPrivateModes=bV(SV)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};CV=xP([SP(0,YP),SP(1,eF),SP(2,tF)],CV);var wV={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function TV(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var EV=String.fromCharCode,DV={DEFAULT:e=>{let t=[TV(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${EV(t[0])}${EV(t[1])}${EV(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${TV(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${TV(e,!0)};${e.x};${e.y}${t}`}},OV=class extends JF{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new yI),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(wV))this.addProtocol(e,wV[e]);for(let e of Object.keys(DV))this.addEncoding(e,DV[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};OV=xP([SP(0,YP),SP(1,ZP),SP(2,tF)],OV);var kV=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],AV=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],jV;function MV(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var NV=class{constructor(){if(this.version=`6`,!jV){jV=new Uint8Array(65536),jV.fill(1),jV[0]=0,jV.fill(0,1,32),jV.fill(0,127,160),jV.fill(2,4352,4448),jV[9001]=2,jV[9002]=2,jV.fill(2,11904,42192),jV[12351]=1,jV.fill(2,44032,55204),jV.fill(2,63744,64256),jV.fill(2,65040,65050),jV.fill(2,65072,65136),jV.fill(2,65280,65377),jV.fill(2,65504,65511);for(let e=0;e<kV.length;++e)jV.fill(0,kV[e][0],kV[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?jV[e]:MV(e,AV)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=PV.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return PV.createPropertyValue(0,n,r)}},PV=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new yI,this.onChange=this._onChange.event;let e=new NV;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},FV=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function IV(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var LV=2147483647,RV=256,zV=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>RV)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>LV?LV:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>LV?LV:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,LV):e}},BV=[],VV=class{constructor(){this._state=0,this._active=BV,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=BV}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=BV,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||BV,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,FP(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=BV,this._id=-1,this._state=0}}},HV=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=FP(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},UV=[],WV=class{constructor(){this._handlers=Object.create(null),this._active=UV,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=UV}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=UV,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||UV,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,FP(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=UV,this._ident=0}},GV=new zV;GV.addParam(0);var KV=class{constructor(e){this._handler=e,this._data=``,this._params=GV,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():GV,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=FP(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=GV,this._data=``,this._hitLimit=!1,e));return this._params=GV,this._data=``,this._hitLimit=!1,t}},qV=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},JV=160,YV=function(){let e=new qV(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(JV,0,2,0),e.add(JV,8,5,8),e.add(JV,6,0,6),e.add(JV,11,0,11),e.add(JV,13,13,13),e}(),XV=class extends JF{constructor(e=YV){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new zV,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(GF(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new VV),this._dcsParser=this._register(new WV),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:JV)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<JV){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<JV){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<JV){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<JV){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<JV){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<JV){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},ZV=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,QV=/^[\da-f]+$/;function $V(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=ZV.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),QV.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function eH(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function tH(e,t=16){let[n,r,i]=e;return`rgb:${eH(n,t)}/${eH(r,t)}/${eH(i,t)}`}var nH={"(":0,")":1,"*":2,"+":3,"-":1,".":2},rH=131072,iH=10;function aH(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var oH=5e3,sH=0,cH=class extends JF{constructor(e,t,n,r,i,a,o,s,c=new XV){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new IP,this._utf8Decoder=new LP,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ZB.clone(),this._eraseAttrDataInternal=ZB.clone(),this._onRequestBell=this._register(new yI),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new yI),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new yI),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new yI),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new yI),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new yI),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new yI),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new yI),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new yI),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new yI),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new yI),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new yI),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new yI),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new lH(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(QR.IND,()=>this.index()),this._parser.setExecuteHandler(QR.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(QR.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new HV(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new HV(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new HV(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new HV(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new HV(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new HV(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new HV(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new HV(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new HV(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new HV(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new HV(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new HV(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in cV)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new KV((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),oH))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${oH} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>rH&&(a=this._parseStack.position+rH)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<rH&&(this._parseBuffer=new Uint32Array(Math.min(e.length,rH))),o||this._dirtyRowTracker.clearRange(),e.length>rH)for(let t=a;t<e.length;t+=rH){let a=t+rH<e.length?t+rH:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=PV.extractWidth(t);let n=PV.extractShouldJoin(t),m=n?PV.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(PP(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof eV&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>aH(e.params[0],this._optionsService.rawOptions.windowOptions)?t(e):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new KV(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new HV(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(ZB));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=PV.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,lV),this._charsetService.setgCharset(1,lV),this._charsetService.setgCharset(2,lV),this._charsetService.setgCharset(3,lV);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=BP.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=ZB.fg,e.bg=ZB.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=ZB.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=ZB.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=ZB.fg&16777215,r.bg&=-67108864,r.bg|=ZB.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ZB.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`;break}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!aH(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>iH&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>iH&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(uH(n))if(r===`?`)t.push({type:0,index:n});else{let e=$V(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=$V(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);uH(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,lV),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(nH[e[0]],cV[e[1]]||lV),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=ZB.clone(),this._eraseAttrDataInternal=ZB.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new HP;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},lH=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(sH=e,e=t,t=sH),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};lH=xP([SP(0,YP)],lH);function uH(e){return 0<=e&&e<256}var dH=5e7,fH=12,pH=50,mH=class extends JF{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new yI),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>dH)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=fH?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=fH)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>pH&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},hH=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};hH=xP([SP(0,YP)],hH);var gH=!1,_H=class extends JF{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new YF),this._onBinary=this._register(new yI),this.onBinary=this._onBinary.event,this._onData=this._register(new yI),this.onData=this._onData.event,this._onLineFeed=this._register(new yI),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new yI),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new yI),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new yI),this._instantiationService=new WB,this.optionsService=this._register(new vV(e)),this._instantiationService.setService(tF,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(hV)),this._instantiationService.setService(YP,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(qB)),this._instantiationService.setService(eF,this._logService),this.coreService=this._register(this._instantiationService.createInstance(CV)),this._instantiationService.setService(ZP,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(OV)),this._instantiationService.setService(XP,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(PV)),this._instantiationService.setService(rF,this.unicodeService),this._charsetService=this._instantiationService.createInstance(FV),this._instantiationService.setService(QP,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(hH),this._instantiationService.setService(nF,this._oscLinkService),this._inputHandler=this._register(new cH(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(aI.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(aI.forward(this._bufferService.onResize,this._onResize)),this._register(aI.forward(this.coreService.onData,this._onData)),this._register(aI.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new mH((e,t)=>this._inputHandler.parse(e,t))),this._register(aI.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new yI),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!gH&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),gH=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,pV),t=Math.max(t,mV),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(IV.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(IV(this._bufferService),!1))),this._windowsWrappingHeuristics.value=GF(()=>{for(let t of e)t.dispose()})}}},vH={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function yH(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`D`:t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`C`:t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`A`:t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`B`:t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:a?i.key=$.ESC+`[3;`+(a+1)+`~`:i.key=$.ESC+`[3~`;break;case 36:a?i.key=$.ESC+`[1;`+(a+1)+`H`:t?i.key=$.ESC+`OH`:i.key=$.ESC+`[H`;break;case 35:a?i.key=$.ESC+`[1;`+(a+1)+`F`:t?i.key=$.ESC+`OF`:i.key=$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=$.ESC+`[5;`+(a+1)+`~`:i.key=$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=$.ESC+`[6;`+(a+1)+`~`:i.key=$.ESC+`[6~`;break;case 112:a?i.key=$.ESC+`[1;`+(a+1)+`P`:i.key=$.ESC+`OP`;break;case 113:a?i.key=$.ESC+`[1;`+(a+1)+`Q`:i.key=$.ESC+`OQ`;break;case 114:a?i.key=$.ESC+`[1;`+(a+1)+`R`:i.key=$.ESC+`OR`;break;case 115:a?i.key=$.ESC+`[1;`+(a+1)+`S`:i.key=$.ESC+`OS`;break;case 116:a?i.key=$.ESC+`[15;`+(a+1)+`~`:i.key=$.ESC+`[15~`;break;case 117:a?i.key=$.ESC+`[17;`+(a+1)+`~`:i.key=$.ESC+`[17~`;break;case 118:a?i.key=$.ESC+`[18;`+(a+1)+`~`:i.key=$.ESC+`[18~`;break;case 119:a?i.key=$.ESC+`[19;`+(a+1)+`~`:i.key=$.ESC+`[19~`;break;case 120:a?i.key=$.ESC+`[20;`+(a+1)+`~`:i.key=$.ESC+`[20~`;break;case 121:a?i.key=$.ESC+`[21;`+(a+1)+`~`:i.key=$.ESC+`[21~`;break;case 122:a?i.key=$.ESC+`[23;`+(a+1)+`~`:i.key=$.ESC+`[23~`;break;case 123:a?i.key=$.ESC+`[24;`+(a+1)+`~`:i.key=$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=vH[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL));break}return i}var bH=0,xH=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new sB,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new sB,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(bH=this._search(t),bH===-1)||this._getKey(this._array[bH])!==t)return!1;do if(this._array[bH]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(bH),!0;while(++bH<this._array.length&&this._getKey(this._array[bH])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bH=this._search(e),!(bH<0||bH>=this._array.length)&&this._getKey(this._array[bH])===e))do yield this._array[bH];while(++bH<this._array.length&&this._getKey(this._array[bH])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bH=this._search(e),!(bH<0||bH>=this._array.length)&&this._getKey(this._array[bH])===e))do t(this._array[bH]);while(++bH<this._array.length&&this._getKey(this._array[bH])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},SH=0,CH=0,wH=class extends JF{constructor(){super(),this._decorations=new xH(e=>e?.marker.line),this._onDecorationRegistered=this._register(new yI),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new yI),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(GF(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new TH(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{SH=t.options.x??0,CH=SH+(t.options.width??1),e>=SH&&e<CH&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},TH=class extends qF{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new yI),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new yI),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=cz.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=cz.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},EH=1e3,DH=class{constructor(e,t=EH){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},OH=20,kH=!1,AH=class extends JF{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new DH(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);kH?(this._accessibilityContainer.classList.add(`debug`),this._rowContainer.classList.add(`debug`),this._debugRootContainer=i.createElement(`div`),this._debugRootContainer.classList.add(`xterm`),this._debugRootContainer.appendChild(i.createTextNode(`------start a11y------`)),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode(`------end a11y------`)),this._terminal.element.insertAdjacentElement(`afterend`,this._debugRootContainer)):this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
131
131
  `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(QL(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(GF(()=>{kH?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<OH+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
132
132
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===OH+1&&(this._liveRegion.textContent+=EP.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};AH=xP([SP(1,$P),SP(2,cF),SP(3,uF)],AH);var jH=class extends JF{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new yI),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new yI),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(GF(()=>{UF(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(QL(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(QL(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(QL(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(QL(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&MH(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,UF(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};jH=xP([SP(1,lF),SP(2,uF),SP(3,YP),SP(4,mF)],jH);function MH(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var NH=class extends _H{constructor(e={}){super(e),this._linkifier=this._register(new YF),this.browser=Wz,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new YF),this._onCursorMove=this._register(new yI),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new yI),this.onKey=this._onKey.event,this._onRender=this._register(new yI),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new yI),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new yI),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new yI),this.onBell=this._onBell.event,this._onFocus=this._register(new yI),this._onBlur=this._register(new yI),this._onA11yCharEmitter=this._register(new yI),this._onA11yTabEmitter=this._register(new yI),this._onWillOpen=this._register(new yI),this._setup(),this._decorationService=this._instantiationService.createInstance(wH),this._instantiationService.setService(iF,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(zz),this._instantiationService.setService(mF,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(aF)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(aI.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(aI.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(aI.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(aI.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(GF(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=sz.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${tH(r)}${$R.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=oz.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=oz.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(AH,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(QL(this.element,`copy`,e=>{this.hasSelection()&&kP(e,this._selectionService)}));let e=e=>AP(e,this.textarea,this.coreService,this.optionsService);this._register(QL(this.textarea,`paste`,e)),this._register(QL(this.element,`paste`,e)),Jz?this._register(QL(this.element,`mousedown`,e=>{e.button===2&&NP(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(QL(this.element,`contextmenu`,e=>{NP(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),nB&&this._register(QL(this.element,`auxclick`,e=>{e.button===1&&MP(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(QL(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(QL(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(QL(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(QL(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(QL(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(QL(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(QL(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(QL(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,wP.get()),rB||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Lz,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(cF,this._coreBrowserService),this._register(QL(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(QL(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Nz,this._document,this._helperContainer),this._instantiationService.setService(sF,this._charSizeService),this._themeService=this._instantiationService.createInstance(VB),this._instantiationService.setService(pF,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(mz),this._instantiationService.setService(fF,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(lB,this.rows,this.screenElement)),this._instantiationService.setService(uF,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(ez,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hz),this._instantiationService.setService(lF,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(jH,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(GR,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(jB,this.element,this.screenElement,r)),this._instantiationService.setService(dF,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(aI.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(KR,this.screenElement)),this._register(QL(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(AH,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ZR,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ZR,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Mz,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(QL(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(QL(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){jP(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=yH(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(PH(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(ZB));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function PH(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var FH=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},IH=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new HP)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},LH=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new IH(t)}getNullCell(){return new HP}},RH=class extends JF{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new yI),this.onBufferChange=this._onBufferChange.event,this._normal=new LH(this._core.buffers.normal,`normal`),this._alternate=new LH(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},zH=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},BH=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},VH=[`cols`,`rows`],HH=0,UH=class extends JF{constructor(e){super(),this._core=this._register(new NH(e)),this._addonManager=this._register(new FH),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(VH.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new zH(this._core),this._parser}get unicode(){return this._checkProposedApi(),new BH(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new RH(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
133
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return wP.get()},set promptLabel(e){wP.set(e)},get tooMuchOutput(){return EP.get()},set tooMuchOutput(e){EP.set(e)}}}_verifyIntegers(...e){for(HH of e)if(HH===1/0||isNaN(HH)||HH%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(HH of e)if(HH&&(HH===1/0||isNaN(HH)||HH%1!=0||HH<0))throw Error(`This API only accepts positive integers`)}},WH=Object.create(null);WH.open=`0`,WH.close=`1`,WH.ping=`2`,WH.pong=`3`,WH.message=`4`,WH.upgrade=`5`,WH.noop=`6`;var GH=Object.create(null);Object.keys(WH).forEach(e=>{GH[WH[e]]=e});var KH={type:`error`,data:`parser error`},qH=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,JH=typeof ArrayBuffer==`function`,YH=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,XH=({type:e,data:t},n,r)=>qH&&t instanceof Blob?n?r(t):ZH(t,r):JH&&(t instanceof ArrayBuffer||YH(t))?n?r(t):ZH(new Blob([t]),r):r(WH[e]+(t||``)),ZH=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function QH(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var $H;function eU(e,t){if(qH&&e.data instanceof Blob)return e.data.arrayBuffer().then(QH).then(t);if(JH&&(e.data instanceof ArrayBuffer||YH(e.data)))return t(QH(e.data));XH(e,!1,e=>{$H||=new TextEncoder,t($H.encode(e))})}var tU=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,nU=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)nU[tU.charCodeAt(e)]=e;var rU=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=nU[e.charCodeAt(r)],o=nU[e.charCodeAt(r+1)],s=nU[e.charCodeAt(r+2)],c=nU[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},iU=typeof ArrayBuffer==`function`,aU=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:sU(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:oU(e.substring(1),t)}:GH[n]?e.length>1?{type:GH[n],data:e.substring(1)}:{type:GH[n]}:KH},oU=(e,t)=>iU?sU(rU(e),t):{base64:!0,data:e},sU=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},cU=``,lU=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{XH(e,!1,e=>{r[a]=e,++i===n&&t(r.join(cU))})})},uU=(e,t)=>{let n=e.split(cU),r=[];for(let e=0;e<n.length;e++){let i=aU(n[e],t);if(r.push(i),i.type===`error`)break}return r};function dU(){return new TransformStream({transform(e,t){eU(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var fU;function pU(e){return e.reduce((e,t)=>e+t.length,0)}function mU(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function hU(e,t){fU||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(pU(n)<1)break;let e=mU(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(pU(n)<2)break;let e=mU(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(pU(n)<8)break;let e=mU(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(KH);break}i=a*2**32+t.getUint32(4),r=3}else{if(pU(n)<i)break;let e=mU(n,i);s.enqueue(aU(a?e:fU.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(KH);break}}}})}function gU(e){if(e)return _U(e)}function _U(e){for(var t in gU.prototype)e[t]=gU.prototype[t];return e}gU.prototype.on=gU.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},gU.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},gU.prototype.off=gU.prototype.removeListener=gU.prototype.removeAllListeners=gU.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},gU.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},gU.prototype.emitReserved=gU.prototype.emit,gU.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},gU.prototype.hasListeners=function(e){return!!this.listeners(e).length};var vU=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),yU=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),bU=`arraybuffer`;function xU(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var SU=yU.setTimeout,CU=yU.clearTimeout;function wU(e,t){t.useNativeTimers?(e.setTimeoutFn=SU.bind(yU),e.clearTimeoutFn=CU.bind(yU)):(e.setTimeoutFn=yU.setTimeout.bind(yU),e.clearTimeoutFn=yU.clearTimeout.bind(yU))}var TU=1.33;function EU(e){return typeof e==`string`?DU(e):Math.ceil((e.byteLength||e.size)*TU)}function DU(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function OU(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function kU(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function AU(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var jU=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},MU=class extends gU{constructor(e){super(),this.writable=!1,wU(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new jU(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=aU(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=kU(e);return t.length?`?`+t:``}},NU=class extends MU{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){uU(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,lU(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=OU()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},PU=!1;try{PU=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var FU=PU;function IU(){}var LU=class extends NU{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},RU=class e extends gU{constructor(e,t,n){super(),this.createRequest=e,wU(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=xU(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=IU,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(RU.requestsCount=0,RU.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,zU);else if(typeof addEventListener==`function`){let e=`onpagehide`in yU?`pagehide`:`unload`;addEventListener(e,zU,!1)}}function zU(){for(let e in RU.requests)RU.requests.hasOwnProperty(e)&&RU.requests[e].abort()}var BU=(function(){let e=HU({xdomain:!1});return e&&e.responseType!==null})(),VU=class extends LU{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=BU&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new RU(HU,this.uri(),e)}};function HU(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||FU))return new XMLHttpRequest}catch{}if(!t)try{return new yU[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var UU=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,WU=class extends MU{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=UU?{}:xU(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;XH(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&vU(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=OU()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},GU=yU.WebSocket||yU.MozWebSocket,KU={websocket:class extends WU{createSocket(e,t,n){return UU?new GU(e,t,n):t?new GU(e,t):new GU(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends MU{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=hU(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=dU();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&vU(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:VU},qU=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,JU=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function YU(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=qU.exec(e||``),a={},o=14;for(;o--;)a[JU[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=XU(a,a.path),a.queryKey=ZU(a,a.query),a}function XU(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function ZU(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var QU=typeof addEventListener==`function`&&typeof removeEventListener==`function`,$U=[];QU&&addEventListener(`offline`,()=>{$U.forEach(e=>e())},!1);var eW=class e extends gU{constructor(e,t){if(super(),this.binaryType=bU,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=YU(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=YU(t.host).host);wU(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=AU(this.opts.query)),QU&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},$U.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=EU(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,vU(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),QU&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=$U.indexOf(this._offlineEventListener);e!==-1&&$U.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};eW.protocol=4;var tW=class extends eW{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;eW.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;eW.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},nW=class extends tW{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>KU[e]).filter(e=>!!e)),super(e,n)}};nW.protocol;function rW(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=YU(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var iW=typeof ArrayBuffer==`function`,aW=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,oW=Object.prototype.toString,sW=typeof Blob==`function`||typeof Blob<`u`&&oW.call(Blob)===`[object BlobConstructor]`,cW=typeof File==`function`||typeof File<`u`&&oW.call(File)===`[object FileConstructor]`;function lW(e){return iW&&(e instanceof ArrayBuffer||aW(e))||sW&&e instanceof Blob||cW&&e instanceof File}function uW(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(uW(e[t]))return!0;return!1}if(lW(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return uW(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&uW(e[t]))return!0;return!1}function dW(e){let t=[],n=e.data,r=e;return r.data=fW(n,t),r.attachments=t.length,{packet:r,buffers:t}}function fW(e,t){if(!e)return e;if(lW(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=fW(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=fW(e[r],t));return n}return e}function pW(e,t){return e.data=mW(e.data,t),delete e.attachments,e}function mW(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=mW(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=mW(e[n],t));return e}var hW=r({Decoder:()=>yW,Encoder:()=>vW,PacketType:()=>_W,isPacketValid:()=>EW,protocol:()=>5}),gW=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],_W;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(_W||={});var vW=class{constructor(e){this.replacer=e}encode(e){return(e.type===_W.EVENT||e.type===_W.ACK)&&uW(e)?this.encodeAsBinary({type:e.type===_W.EVENT?_W.BINARY_EVENT:_W.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===_W.BINARY_EVENT||e.type===_W.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=dW(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},yW=class e extends gU{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===_W.BINARY_EVENT;n||t.type===_W.BINARY_ACK?(t.type=n?_W.EVENT:_W.ACK,this.reconstructor=new bW(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(lW(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(_W[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===_W.BINARY_EVENT||r.type===_W.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!SW(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case _W.CONNECT:return wW(t);case _W.DISCONNECT:return t===void 0;case _W.CONNECT_ERROR:return typeof t==`string`||wW(t);case _W.EVENT:case _W.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&gW.indexOf(t[0])===-1);case _W.ACK:case _W.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},bW=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=pW(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function xW(e){return typeof e==`string`}var SW=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function CW(e){return e===void 0||SW(e)}function wW(e){return Object.prototype.toString.call(e)===`[object Object]`}function TW(e,t){switch(e){case _W.CONNECT:return t===void 0||wW(t);case _W.DISCONNECT:return t===void 0;case _W.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&gW.indexOf(t[0])===-1);case _W.ACK:return Array.isArray(t);case _W.CONNECT_ERROR:return typeof t==`string`||wW(t);default:return!1}}function EW(e){return xW(e.nsp)&&CW(e.id)&&TW(e.type,e.data)}function DW(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var OW=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),kW=class extends gU{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[DW(e,`open`,this.onopen.bind(this)),DW(e,`packet`,this.onpacket.bind(this)),DW(e,`error`,this.onerror.bind(this)),DW(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(OW.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:_W.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:_W.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case _W.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case _W.EVENT:case _W.BINARY_EVENT:this.onevent(e);break;case _W.ACK:case _W.BINARY_ACK:this.onack(e);break;case _W.DISCONNECT:this.ondisconnect();break;case _W.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:_W.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:_W.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function AW(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}AW.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},AW.prototype.reset=function(){this.attempts=0},AW.prototype.setMin=function(e){this.ms=e},AW.prototype.setMax=function(e){this.max=e},AW.prototype.setJitter=function(e){this.jitter=e};var jW=class extends gU{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,wU(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new AW({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||hW;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new nW(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=DW(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=DW(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(DW(e,`ping`,this.onping.bind(this)),DW(e,`data`,this.ondata.bind(this)),DW(e,`error`,this.onerror.bind(this)),DW(e,`close`,this.onclose.bind(this)),DW(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){vU(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new kW(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},MW={};function NW(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=rW(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=MW[i]&&a in MW[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new jW(r,t):(MW[i]||(MW[i]=new jW(r,t)),c=MW[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(NW,{Manager:jW,Socket:kW,io:NW,connect:NW});var PW=NW(k),FW=({label:e,onClick:t,children:n})=>(0,Z.jsx)(U,{type:`button`,"aria-label":e,onClick:t,variant:`outline`,size:`icon-sm`,className:`bg-secondary/60`,children:n}),IW=({exitCode:e,signal:t})=>t>0?`[archon] Shell exited with signal ${t}`:`[archon] Shell exited with code ${e}`,LW=({createSession:e,isExpanded:t,isVisible:n,onClose:r,onToggleExpanded:i,className:a=``,ariaLabel:o=`Terminal`,title:s=`Terminal`,closeLabel:c=`Close terminal`,headerMeta:l})=>{let u=(0,X.useRef)(null),d=(0,X.useRef)(null),f=(0,X.useRef)(null),p=(0,X.useRef)(null),m=(0,X.useRef)(e),h=(0,X.useRef)(!1),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!0);return(0,X.useEffect)(()=>{m.current=e},[e]),(0,X.useEffect)(()=>{if(!u.current)return;let e=new UH({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,fontSize:13,theme:{background:`#0b0d14`,foreground:`#d8deef`,cursor:`#c4b5fd`}}),t=new _P,n=null,r=!1;e.loadAddon(t),e.open(u.current),d.current=e,f.current=t;let i=()=>{let e=p.current;!e||h.current||(h.current=!0,AT(e))};window.addEventListener(`pagehide`,i),window.addEventListener(`beforeunload`,i);let a=()=>{p.current&&PW.emit(`terminal:resize`,{sessionId:p.current,cols:e.cols,rows:e.rows})},o=()=>{!u.current||r||(t.fit(),a())},s=t=>{t.sessionId===p.current&&(y(!1),window.setTimeout(()=>{o(),e.focus()},0))},c=t=>{t.sessionId===p.current&&(y(!1),e.write(t.data))},l=t=>{t.sessionId===p.current&&(e.writeln(``),e.writeln(IW(t)))},g=t=>{t.sessionId&&t.sessionId!==p.current||(y(!1),_(t.message),e.writeln(``),e.writeln(`[archon] ${t.message}`))};PW.on(`terminal:ready`,s),PW.on(`terminal:data`,c),PW.on(`terminal:exit`,l),PW.on(`terminal:error`,g);let v=e.onData(e=>{p.current&&PW.emit(`terminal:input`,{sessionId:p.current,input:e})});return typeof ResizeObserver==`function`&&(n=new ResizeObserver(()=>{o()}),n.observe(u.current)),window.setTimeout(()=>{o()},0),m.current().then(e=>{r||(p.current=e.session_id,PW.emit(`terminal:join`,{sessionId:e.session_id}))}).catch(t=>{if(r)return;y(!1);let n=t instanceof Error?t.message:`Unable to open the terminal right now.`;_(n),e.writeln(``),e.writeln(`[archon] ${n}`)}),()=>{r=!0,window.removeEventListener(`pagehide`,i),window.removeEventListener(`beforeunload`,i),p.current&&(h.current||PW.emit(`terminal:destroy`,{sessionId:p.current})),n?.disconnect(),v.dispose(),PW.off(`terminal:ready`,s),PW.off(`terminal:data`,c),PW.off(`terminal:exit`,l),PW.off(`terminal:error`,g),e.dispose(),d.current=null,f.current=null,p.current=null}},[]),(0,X.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{f.current?.fit(),d.current&&p.current&&(PW.emit(`terminal:resize`,{sessionId:p.current,cols:d.current.cols,rows:d.current.rows}),d.current.focus())},0);return()=>{window.clearTimeout(e)}},[t,n]),(0,Z.jsxs)(kd,{"aria-label":o,"data-terminal-pane":`true`,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden rounded-xl border-border bg-[#0c1119] ${a}`.trim(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border bg-card/80 px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,Z.jsx)(Cu,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),l&&(0,Z.jsx)(`div`,{className:`mt-1 min-w-0 text-xs text-muted-foreground`,children:l})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v&&!g&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Opening terminal...`}),g&&(0,Z.jsx)(`span`,{className:`max-w-56 truncate text-xs text-red-300`,children:g}),(0,Z.jsx)(FW,{label:t?`Collapse terminal`:`Expand terminal`,onClick:i,children:t?(0,Z.jsx)(Df,{className:`h-4 w-4`}):(0,Z.jsx)(Of,{className:`h-4 w-4`})}),(0,Z.jsx)(FW,{label:c,onClick:r,children:(0,Z.jsx)(pe,{className:`h-4 w-4`})})]})]}),(0,Z.jsx)(`div`,{ref:u,"data-testid":`terminal-viewport`,onClick:()=>d.current?.focus(),className:`min-h-0 flex-1 overflow-hidden bg-[#0b0d14] pb-4`})]})},RW=`modulepreload`,zW=function(e){return`/`+e},BW={},VW=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=zW(t,n),t in BW)return;BW[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:RW,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},HW=(0,X.lazy)(()=>VW(()=>Promise.resolve().then(()=>Xq).then(e=>({default:e.TicketChangesModal})),void 0)),UW=(0,X.lazy)(()=>VW(()=>import(`./TestsDialog-F0VCXRNc.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),WW=`(min-width: 1280px)`,GW=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches,KW=e=>{let[t,n]=(0,X.useState)(()=>GW(e));return(0,X.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>{n(t.matches)};return r(),t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}},[e]),t},qW=({onClose:e})=>(0,Z.jsx)(Ce,{onClose:e,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-full w-full max-w-none items-center justify-center rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Loading diff...`})}),JW=({ariaLabel:e,title:t,closeAriaLabel:n,className:r,showTopSpacer:i=!0,description:a,onClose:o,...s})=>(0,Z.jsxs)(`aside`,{className:`min-h-0 flex flex-col gap-3 overflow-hidden${r?` ${r}`:``}`,"aria-label":e,children:[i?(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`h-9 shrink-0`}):null,(0,Z.jsx)(RN,{...s,header:({showThinkingControl:e})=>(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:t}),e]}),a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:a}):null]}),(0,Z.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n,onClick:o,children:(0,Z.jsx)(pe,{className:`h-4 w-4`})})]})})]}),YW=(e,t)=>e?t.find(t=>t.id===e)?.label??e:null,XW=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectTestCommands:i=[],showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],projectBranchState:c=null,projectMemoryEnabled:l=!1,runDisabled:u=!1,runDisabledReason:d,onClose:f,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onUpdate:g,onDeleteDependency:_,onAdvance:v,onBuildChain:y,onRun:b,onOpenIde:x,onStop:S,onStopBuild:C,onStopBuildChain:w,onResumeBuild:T,onFollowUp:E,onRequestTicketRefresh:D,onProjectMemorySuggestionsChanged:O})=>{let[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(!1),[L,R]=(0,X.useState)(!1),[ee,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)(!1),[te,ne]=(0,X.useState)(``),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),[se,H]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(0),[ue,W]=(0,X.useState)(!1),[de,G]=(0,X.useState)(!1),[fe,K]=(0,X.useState)(null),q=k??e,[pe,me]=(0,X.useState)(q.model??``),[he,ge]=(0,X.useState)(q.variant??``),[_e,ve]=(0,X.useState)(q.skills??[]),[ye,be]=(0,X.useState)(()=>YW(q.model,o)??`Agent`),xe=(0,X.useRef)(q.id),Se=(0,X.useRef)(null),we=(0,X.useRef)(null),Te=(0,X.useRef)(!1),Ee=(0,X.useRef)(q.id),De=(0,X.useRef)(q.build_completed_at),Oe=KW(WW),[ke,Ae]=(0,X.useState)(!1),[je,Me]=(0,X.useState)({model:q.model,variant:q.variant,skills:q.skills??[]}),Ne=q.state===`plan`,Pe=Mw(q.state),Fe=q.worktree_bundle_id!==null,Ie=Ne&&q.agent_status===`running`,Le=Ne&&q.agent_status===`error`,Re=Ne&&!Ie||j,ze=jw(q.state),Be=ze?Hw(q,ze):!1,Ve=ze?ze===`review`?`Review Bundle`:ze.charAt(0).toUpperCase()+ze.slice(1):null,He=async e=>{let t=await xt(q.id,q.project_id,e);return A(t),g?.(t),h&&await h(),t},Ue=async e=>{try{await He(e),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},We=async e=>{try{if(await He(e),!v){f();return}await v(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Ge=async()=>{!v||!Be||(await v(),f())},Ke=async e=>{try{if(await He(e),!y){f();return}await y(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Y=Ne?q.planning_session_id:q.session_id,qe=Y?Y.startsWith(`ses_`)?`opencode --session ${Y}`:`claude --resume ${Y}`:null,Je=q.bundle?.branch??q.branch,Ye=q.has_worktree??!!Je,Xe=!Re&&Pw(q)&&q.agent_status===`running`&&!!q.session_id&&!!C,Ze=!Re&&Pw(q)&&q.agent_status===`stopped`&&!!q.session_id&&!!T,Qe=`Pause Build`,$e=`Stop Build Chain`,et=`Stop Run`,tt=new Map(t.map(e=>[e.id,e])),nt=n.filter(e=>e.blocker_ticket_id===q.id),rt=n.filter(e=>e.dependent_ticket_id===q.id),it=oT(q,tt,n),at=it.pendingBuildChainOrder.length>0?`Will build in order: ${it.pendingBuildChainOrder.map(e=>e.title).join(` -> `)}`:`All tickets in this chain have already finished build.`,ot=it.skippedBuildChainCount>0?`Skips ${it.skippedBuildChainCount} ticket${it.skippedBuildChainCount===1?``:`s`} that already finished build.`:null,st=it.hasOpenBlockers,ct=Lw(q),lt=q.build_chain?.active_ticket_id?`Currently building ${tt.get(q.build_chain.active_ticket_id)?.title??`Unknown ticket`}.`:`Build chain is active.`,ut=q.build_chain&&q.build_chain.queued_ticket_ids.length>0?`Queued next: ${q.build_chain.queued_ticket_ids.map(e=>tt.get(e)?.title??`Unknown ticket`).join(` -> `)}`:`No additional tickets are queued after the current build.`,dt=Ne&&!!v&&!it.hasOpenBlockers,ft=Ne&&!!y&&it.canStartBuildChain,pt=!!q.project_id&&!Ne&&!Fe,mt=Ne,ht=Fe&&!Ne,gt=!!q.project_id&&!!Je&&Ye&&!Re&&!Ie&&!Fe,_t=!!q.project_id&&Ye&&!Re&&!Ie&&!!x&&!Fe,vt=!!q.project_id&&i.length>0&&Ye,yt=pt&&!L,bt=pt&&B,St=te.trim(),Ct=!Re&&!Ie&&q.state!==`plan`&&Ye&&!!E,wt=mt&&ae,Tt=ht&&se,Et=(q.planning_context?.open_questions.length??0)>0,Dt=Ct&&a&&q.tool===`opencode`,Ot=o.find(e=>e.id===pe)??null,kt=q.agent_status===`running`,At=gT(q,{allTickets:t,preferBundleReviewStatus:!0}),jt=q.skills??[],Mt=kt?`Wait for the current build to finish before sending a follow-up prompt.`:void 0,Nt=Ie?`Wait for planning to finish before sending another message.`:void 0,Pt=[...Ie?[]:[{label:`Worktree`,value:Je??``}],{label:`Session`,value:qe??``},...Ie?[{label:q.bundle?.kind===`project_root`?`Project root branch`:`Bundle`,value:(q.bundle?.kind,q.bundle?md(q.bundle):``)}]:Ne?[{label:`Bundle`,value:q.bundle?md(q.bundle):``},{label:`Model`,value:q.model??``},{label:`Variant`,value:q.variant??``},{label:`Skills`,value:jt.length>0?`${jt.length} skill${jt.length===1?``:`s`}`:``},{label:`Initiative`,value:q.planning_context?.initiative_prompt??``}]:[]],Ft=Ie?{model:q.model??``,variant:q.variant??``,skills:jt}:null,It=mt&&ae,Lt=ht&&se,Rt=(It||Lt)&&!Oe,zt=It&&!Rt,Bt=zt||Lt&&!Rt,Vt=Ne&&(It||!Oe),Ht=L?`flex h-[92vh] w-[96vw] max-w-7xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Bt?`flex h-[92vh] w-[98vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Rt?`flex h-[92vh] w-[98vw] max-w-6xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-6xl flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,Ut=L&&!ee?`grid min-h-0 flex-1 grid-cols-1 gap-3 lg:grid-cols-2`:Bt?`grid min-h-0 flex-1 grid-cols-1 gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(30rem,1fr)]`:`flex min-h-0 flex-1 flex-col`,Wt=()=>{V(!0),R(e=>(e&&z(!1),!e))},qt=()=>{R(!1),z(!1),V(!1),D?.(q.id)},Jt=()=>{G(!1),K(null)},Yt=()=>{G(!1),fe===`cancel_edit`&&!Ne?M(!1):f(),K(null)},Xt=()=>{if(!Re){f();return}if(!ue){f();return}K(`close_modal`),G(!0)},Zt=()=>{if(Ne){Xt();return}if(!ue){M(!1);return}K(`cancel_edit`),G(!0)};(0,X.useEffect)(()=>{A(t=>!t||t.id!==e.id||e.updated_at>=t.updated_at?null:t)},[e]),(0,X.useEffect)(()=>{if(Ee.current!==q.id){Ee.current=q.id,De.current=q.build_completed_at;return}if(De.current===q.build_completed_at)return;let e=De.current;De.current=q.build_completed_at,q.build_completed_at&&q.build_completed_at!==e&&le(e=>e+1)},[q.build_completed_at,q.id]),(0,X.useEffect)(()=>{me(q.model??``),ge(q.variant??``),ve(q.skills??[])},[q.model,q.skills,q.variant]),(0,X.useEffect)(()=>{xe.current!==q.id&&(xe.current=q.id,be(YW(q.model,o)??`Agent`))},[o,q.id,q.model]),(0,X.useEffect)(()=>{let e=YW(q.model,o);e&&be(e)},[o,q.model]),(0,X.useEffect)(()=>{Me({model:q.model,variant:q.variant,skills:q.skills??[]})},[q.id,q.model,q.skills,q.variant]),(0,X.useEffect)(()=>{Re||(W(!1),G(!1),K(null))},[Re]),(0,X.useEffect)(()=>{ue||(G(!1),K(null))},[ue]),(0,X.useEffect)(()=>{if(!Ne){Se.current=null,Te.current=!1;return}let e=Se.current!==q.id,t=!Te.current&&Et;(e&&Et||t)&&oe(!0),Se.current=q.id,Te.current=Et},[Et,Ne,q.id]),(0,X.useEffect)(()=>{if(!ht){we.current=null;return}we.current!==q.id&&H(!1),we.current=q.id},[ht,q.id]);let Qt=async(e,t,n)=>{Ae(!0);try{let r=await xt(q.id,q.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});A(r),g?.(r)}catch(e){me(q.model??``),ge(q.variant??``),ve(q.skills??[]),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{Ae(!1)}},$t=e=>{let t=(o.find(t=>t.id===e)??null)?.variants.includes(he)?he:``;me(e),ge(t),Qt(e,t,_e)},en=e=>{ge(e),Qt(pe,e,_e)},tn=e=>{ve(e),Qt(pe,he,e)},nn=async()=>{if(!(!E||re||kt||!St)){ie(!0);try{await E(St),ne(``)}finally{ie(!1)}}},rn=async()=>{if(!(re||Ie||!St||!wt)){ie(!0);try{let e=q.skills??[];if(je.model!==q.model||je.variant!==q.variant||je.skills.length!==e.length||je.skills.some((t,n)=>t!==e[n])){let e=await xt(q.id,q.project_id,{model:je.model,variant:je.variant,skills:je.skills});A(e),g?.(e)}let t=await Gt(q.id,q.project_id,St);A(t),g?.(t),ne(``)}finally{ie(!1)}}},an=(q.messages??[]).filter(BT).map(e=>e.role===`assistant`?{...e,displayTitle:ye}:e.kind===`follow_up`?{...e,displayTitle:`You`}:e),on=(q.messages??[]).filter(e=>(e.kind===`planning_follow_up`||e.kind===`planning_response`)&&BT(e)).map(e=>e.role===`assistant`?{...e,displayTitle:ye}:e.kind===`planning_follow_up`?{...e,displayTitle:`You`}:e),sn=It?(0,Z.jsx)(JW,{ariaLabel:`Planning chat`,title:`Planning Chat`,closeAriaLabel:`Close planning chat`,className:Rt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Rt,description:Et?(0,Z.jsxs)(`p`,{children:[q.planning_context?.open_questions.length,` open question`,q.planning_context?.open_questions.length===1?``:`s`]}):void 0,projectId:q.project_id,followUpTicketId:null,messages:on,internalLog:q.agent_log??null,streamingResponse:q.streaming_response??null,isRunning:q.agent_status===`running`,canShowComposer:wt,pendingAgentTitle:ye,composerTheme:Pe,followUpPlaceholder:`Ask the agent to refine this plan`,emptyStateText:null,autoFocusComposer:ae,followUpPrompt:te,isSendingFollowUp:re,followUpDisabledReason:Nt,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ie||re||(e.preventDefault(),rn())},onFollowUpSubmit:()=>{rn()},onClose:()=>{oe(!1)}}):Lt?(0,Z.jsx)(JW,{ariaLabel:`Ticket chat`,title:`Ticket Chat`,closeAriaLabel:`Close ticket chat`,className:Rt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Rt,projectId:q.project_id,followUpTicketId:q.id,messages:an,internalLog:q.agent_log??null,streamingResponse:q.streaming_response??null,isRunning:q.agent_status===`running`,canShowComposer:Tt,pendingAgentTitle:ye,composerTheme:Pe,autoFocusComposer:se,followUpPrompt:te,isSendingFollowUp:re,followUpDisabledReason:Mt,followUpComposerControls:Dt?(0,Z.jsx)(mP,{model:pe,variant:he,skills:_e,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Ot,onModelChange:$t,onVariantChange:en,onSkillsChange:tn,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:ke}):void 0,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||kt||re||(e.preventDefault(),nn())},onFollowUpSubmit:()=>{nn()},onClose:()=>{H(!1)}}):null;return(0,Z.jsx)(Ce,{onClose:Xt,overlayClassName:`bg-black/60`,panelClassName:Ht,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:[gt&&q.diff_stats&&(0,Z.jsx)(gu,{stats:q.diff_stats,showFiles:!0,className:`text-xs`}),gt&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Changes`,onClick:()=>{D?.(q.id),P(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(vu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Changes`})]}),vt&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Tests`,onClick:()=>{I(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(_u,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Tests`})]}),_t&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Open IDE`,onClick:()=>{x?.()},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Open IDE`})]}),yt&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Open terminal`,"aria-pressed":L,onClick:Wt,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Cu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Terminal`})]}),(mt||ht)&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Chat`,"aria-pressed":Ne?ae:se,onClick:()=>{if(Ne){oe(e=>!e);return}H(e=>!e)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(um,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Chat`})]}),e]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-modal-layout`,"data-terminal-mode":L?ee?`expanded`:`split`:`closed`,"data-side-chat-mode":Bt?`inline`:Rt?`overlay`:`closed`,className:Ut,children:[(0,Z.jsxs)(`div`,{className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[Re?(0,Z.jsxs)(Z.Fragment,{children:[Le&&q.agent_log&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-red-500/40 bg-destructive/15 px-3 py-2 text-xs text-red-300`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:`Planning failed: `}),q.agent_log]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(NT,{tool:q.tool,className:`text-[11px]`})}),(0,Z.jsx)(PT,{externalSource:q.external_source}),(0,Z.jsx)($N,{heading:`Edit Ticket`,bundles:r,initialTitle:q.title,initialDescription:q.description??``,initialModel:q.model??``,initialVariant:q.variant??``,initialSkills:q.skills??[],initialWorktreeBundleId:q.worktree_bundle_id,projectBranchState:c,projectId:q.project_id,stackConfigurationSections:zt&&!Vt,preferWideBundleSelector:zt&&Vt,agentSettingsPresentation:Vt?`popover`:`panel`,showModelSelector:a,availableModels:o,availableSkills:s,onAgentSettingsChange:Me,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onCancel:Zt,onDirtyChange:W,titleInputId:`edit-title`,descriptionInputId:`edit-description`,bundleSelectId:`edit-ticket-bundle`,modelSelectId:`edit-model`,variantSelectId:`edit-variant`,skillsSelectId:`edit-skills`,showEmptyBundleOption:!1,planAction:{label:`Plan`,onClick:async({title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a})=>{let o=await xt(q.id,q.project_id,{title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a});g?.(o),f(),await Kt(q.id,q.project_id)}},primaryAction:{label:`Save`,variant:dt?`subtle`:`brand`,onClick:Ue},secondaryAction:dt?{label:`Save & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:We}:void 0,tertiaryAction:ft?{label:`Save & Build Chain`,variant:`brand`,showAdvanceIcon:!0,onClick:Ke}:void 0,beforeActionsContent:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(sP,{projectId:q.project_id,ticketId:q.id,memoryEnabled:l,refreshKey:ce,onSuggestionsChanged:O}),it.hasDependents&&(0,Z.jsx)(VT,{summary:at,detail:ot}),(0,Z.jsx)(VN,{blocks:nt,blockedBy:rt,resolveTicket:e=>tt.get(e),onDeleteDependency:_})]}),footerLeadingContent:ue?(0,Z.jsx)(J,{variant:`outline`,className:`border-amber-500/35 bg-amber-500/10 text-amber-200`,children:`Unsaved changes`}):null},`${q.id}:${q.updated_at}:${q.title}:${q.description}`)]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`sticky top-0 -my-1 bg-card py-1 pr-12 sm:pr-24`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:q.title}),(0,Z.jsx)(NT,{tool:q.tool,className:`text-[11px]`}),(At===`building`||At===`done`)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[q.is_running&&(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(fT,{status:At,showBuildGlyph:!0})]}),At!==null&&At!==`building`&&At!==`done`&&(0,Z.jsx)(fT,{status:At,showBuildGlyph:!0}),Et&&(0,Z.jsx)(J,{variant:`warning`,children:`Open questions`}),ct&&(0,Z.jsx)(J,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]})}),Fe?(0,Z.jsx)(`div`,{className:`mt-3 min-h-0 flex flex-1 flex-col`,children:(0,Z.jsx)(cP,{content:q.description,externalSource:q.external_source})}):(0,Z.jsx)(Z.Fragment,{children:Ne?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 flex flex-col${Ie?` mt-3`:``}`,children:(0,Z.jsx)(cP,{content:q.description,externalSource:q.external_source})}):(0,Z.jsx)(RN,{projectId:q.project_id,followUpTicketId:q.id,messages:an,internalLog:q.agent_log??null,streamingResponse:q.streaming_response??null,isRunning:q.agent_status===`running`,canShowComposer:Ct,pendingAgentTitle:ye,composerTheme:Pe,followUpComposerControls:Dt?(0,Z.jsx)(mP,{model:pe,variant:he,skills:_e,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Ot,onModelChange:$t,onVariantChange:en,onSkillsChange:tn,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:ke}):void 0,followUpPrompt:te,isSendingFollowUp:re,followUpDisabledReason:Mt,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||kt||re||(e.preventDefault(),nn())},onFollowUpSubmit:()=>{nn()}})}),Ie&&(0,Z.jsxs)(`section`,{"aria-label":`Ticket metadata`,className:`flex flex-wrap items-center gap-2`,children:[Pt.filter(e=>e.value.trim().length>0).map(e=>(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,Z.jsx)(IT,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`)),(0,Z.jsx)(`div`,{className:`min-w-0 sm:flex-none`,children:(0,Z.jsx)(jT,{model:Ft.model,variant:Ft.variant,skills:Ft.skills})})]}),!Ie&&!Bt&&(0,Z.jsx)(LT,{ariaLabel:`Ticket metadata`,items:Pt}),(0,Z.jsx)(sP,{projectId:q.project_id,ticketId:q.id,memoryEnabled:l,refreshKey:ce,onSuggestionsChanged:O}),(0,Z.jsx)(VN,{blocks:nt,blockedBy:rt,resolveTicket:e=>tt.get(e),onDeleteDependency:_}),q.build_chain&&(0,Z.jsx)(VT,{summary:lt,detail:ut})]}),!Re&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),Xe&&(0,Z.jsxs)(U,{type:`button`,onClick:C,title:`Pause the build session. You can resume it later.`,"aria-label":Qe,variant:`warning`,children:[(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),Qe]}),q.build_chain&&w&&(0,Z.jsxs)(U,{type:`button`,onClick:()=>{w()},title:`Stop scheduling the remaining tickets in this build chain.`,"aria-label":$e,variant:`destructive`,children:[(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),$e]}),Ze&&(0,Z.jsxs)(U,{type:`button`,onClick:T,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),`Resume`]}),Je&&!Re&&!Fe&&q.is_running&&S&&(0,Z.jsxs)(U,{type:`button`,onClick:S,title:`Stop the currently running ticket.`,"aria-label":et,variant:`destructive`,children:[(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),et]}),Je&&Ye&&!Ie&&!Re&&!Fe&&!q.is_running&&b&&(0,Z.jsxs)(U,{type:`button`,disabled:u,title:u?d??`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{u||b()},variant:`secondary`,className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),`Run`]}),!Re&&q.state===`build`&&!st&&Ve&&v&&(0,Z.jsxs)(U,{type:`button`,disabled:!Be,onClick:()=>{Ge()},children:[Ve,(0,Z.jsx)(Ow,{className:`w-3.5 h-3.5`})]})]})]})]}),Bt&&sn,bt&&(0,Z.jsx)(`div`,{className:L?ee?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`mt-12 min-h-0 flex flex-1 flex-col overflow-hidden`:`hidden`,children:(0,Z.jsx)(LW,{createSession:()=>OT(q.id,q.project_id),isExpanded:ee,isVisible:L,ariaLabel:`Ticket terminal`,className:ee?`h-full w-full max-w-none rounded-2xl shadow-2xl`:void 0,onClose:qt,onToggleExpanded:()=>{z(e=>!e)}})})]}),Rt&&sn,N&&(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(qW,{onClose:()=>{P(!1),D?.(q.id)}}),children:(0,Z.jsx)(HW,{ticketId:q.id,projectId:q.project_id,title:q.title,onTicketUpdate:g,onRequestTicketRefresh:D,onSubmitReviewPrompt:E,canSubmitReviewPrompt:!kt,reviewSubmitDisabledReason:Mt,onClose:()=>{P(!1),D?.(q.id)}})}),F&&vt&&q.project_id&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(UW,{scope:`ticket`,ticketId:q.id,projectId:q.project_id,testCommands:i,onClose:()=>{I(!1)}})}),de&&(0,Z.jsx)(Od,{title:`Discard unsaved edits?`,description:`Any changes made will be lost.`,confirmLabel:`Discard`,cancelLabel:`Keep editing`,confirmVariant:`destructive`,onConfirm:Yt,onCancel:Jt})]})})},ZW=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectMemoryEnabled:i=!1,overlay:a=!1,showModelSelector:o,availableModels:s,runDisabled:c=!1,runDisabledReason:l,dependencyTargetState:u=`idle`,onDependencyStart:d,onDeleteDependency:f,onRegisterNode:p,onRegisterOverlayNode:m,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onDelete:y,onUndo:b,onRetry:x,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:E,onOpenTests:D,onOpenChanges:O,onOpenIde:k,onStop:A,onStopBuild:j,onStopBuildChain:M,onResumeBuild:N,onFollowUp:P,onOpenBundleDetails:F,onOpenTicketDetails:I,preferBundleDetailsOnClick:L=!1,hideBundleScopedControls:R=!1,hideStatusBadge:ee=!1,onRequestTicketRefresh:z,undoInProgress:B=!1})=>{let[V,te]=(0,X.useState)(!1),[ne,re]=(0,X.useState)(!1),[ie,ae]=(0,X.useState)(!1),[oe,se]=(0,X.useState)(!1),[H,ce]=(0,X.useState)(null),[le,ue]=(0,X.useState)(!1),[W,de]=(0,X.useState)(!1),G=e.agent_status===`running`||B,fe=R,K=e.bundle?.branch??e.branch,q=e.has_worktree??(e.state===`plan`?!1:!!K),pe=!R&&q,me=oT(e,new Map(t.map(e=>[e.id,e])),n),he=jw(e.state),ge=e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`,_e=Fw(e),ve=Iw(e),ye=Lw(e),be=!R&&ve!==`plan`&&e.diff_stats===void 0,xe=(ye||_e)&&!a,Se=he?he===`review`?`Review Bundle`:he.charAt(0).toUpperCase()+he.slice(1):ge?`Re-run review`:null,Ce=Hw(e,`trash`),we=e.undo,Te=!!b&&we?.stage!==null,Ee=ge||(he?Hw(e,he):!1),De=!_e&&!!S&&!!Se&&!me.hasOpenBlockers,Oe=!!C&&Bw(e),ke=_e&&typeof e.state==`string`?`Return to ${e.state.charAt(0).toUpperCase()}${e.state.slice(1)}`:null,Ae=!!w&&ke!==null&&e.state!==`plan`,je=!_e&&!!T&&me.canStartBuildChain,Me=Pw(e)&&e.agent_status===`running`&&!!e.session_id&&!!j,Ne=Pw(e)&&e.agent_status===`stopped`&&!!e.session_id&&!!N,Pe=pe&&!!O,Fe=pe&&!!e.project_id&&!!D,Ie=pe&&!!k,Le=!fe&&q&&!!K&&!e.is_running&&!!E,Re=!fe&&q&&!!K&&!!e.is_running&&!!A,ze=!!e.build_chain&&!!M,Be=!!y||Te||De||Oe||Ae||je||Me||Ne||Le||Re||Fe||Pe||Ie||ze,Ve=_e&&!e.is_running?`opacity-0 pointer-events-none transition-opacity group-hover/card:opacity-100 group-hover/card:pointer-events-auto group-focus-within/card:opacity-100 group-focus-within/card:pointer-events-auto`:``,He=async()=>{if(!(!E||c||le)){ue(!0);try{await E()}finally{ue(!1)}}},Ue=async()=>{if(!(!A||W)){de(!0);try{await A()}finally{de(!1)}}},We=!fe&&q&&K&&e.is_running&&A&&!B?(0,Z.jsx)(mT,{isRunning:!0,isStopPending:W,onStop:Ue}):!fe&&q&&K&&!e.is_running&&E?(0,Z.jsx)(mT,{isRunning:!1,isRunPending:le,runDisabled:c,runDisabledReason:l,onRun:He,className:Ve}):null;(0,X.useEffect)(()=>{if(!oe)return;let e=()=>{se(!1)};return window.addEventListener(`click`,e,{once:!0}),()=>{window.removeEventListener(`click`,e)}},[oe]);let Ge=()=>{if(a||oe||B){se(!1);return}if(L&&F){F();return}if(I){I();return}z?.(e.id),ae(!0)},{attributes:Ke,listeners:Y,setNodeRef:qe,isDragging:Je}=tw({id:e.id,disabled:a||G}),Ye=(0,X.useRef)(qe);(0,X.useEffect)(()=>{Ye.current=qe},[qe]);let Xe=(0,X.useCallback)(t=>{if(a){m?.(t);return}Ye.current(t),p?.(e.id,t)},[p,m,a,e.id]),Ze=u===`valid`?`border-emerald-400 shadow-[0_0_0_1px_rgba(52,211,153,0.35)]`:u===`invalid`?`border-red-400 shadow-[0_0_0_1px_rgba(248,113,113,0.35)]`:a?`border-violet-400`:me.isVisibleStartPoint?`border-violet-500/35 shadow-[0_0_0_1px_rgba(168,85,247,0.18)] hover:border-violet-400/55`:`border-border hover:border-primary/40`,Qe=a||B?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,$e=Je?`opacity-30`:xe?`opacity-90`:`opacity-100`,et=xe?`bg-card/60`:`bg-secondary/30`,tt=xe?`p-3 text-foreground/70`:`p-3`,nt=xe?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,rt=xe?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,it=xe?`whitespace-pre-line text-xs leading-relaxed text-foreground/55 wrap-anywhere`:`whitespace-pre-line text-xs leading-relaxed text-muted-foreground wrap-anywhere`,at=e.model??``,ot=!!e.bundle&&!R,st=!!e.bundle?.pull_request&&!R,ct=ot||st,lt=ct||at.length>0,ut=H===e.id,dt=(0,X.useMemo)(()=>{let t=e.description??``;return t?rN(t):{text:``,truncated:!1}},[e.description]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(kd,{"data-testid":`ticket-card-${e.id}`,className:`group/card shrink-0 select-none transition-colors ${Ze} ${Qe} ${$e} ${et} gap-0 rounded-xl border shadow-none`,ref:Xe,onClick:Ge,...Y,...Ke,children:[B&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(J,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Bf,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),(0,Z.jsxs)(Pd,{className:tt,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`div`,{className:nt,children:e.title})}),(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,Z.jsx)(`div`,{className:`mr-1`,children:We}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:d&&(0,Z.jsx)(cu,{content:`Draw dependency`,children:(0,Z.jsx)(U,{type:`button`,"aria-label":`Create dependency from ${e.title}`,variant:`ghost`,size:`icon-xs`,className:`cursor-crosshair opacity-0 transition-all group-hover/card:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.stopPropagation(),se(!0),d(e.id,t)},children:(0,Z.jsx)(ef,{className:`h-4 w-4`})})})}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:Be&&(0,Z.jsx)(wT,{title:e.title,canDelete:Ce,undo:we,undoInProgress:B,runDisabled:c,isRunPending:le,isStopPending:W,showTestsAction:Fe,showOpenChangesAction:Pe,showOpenIdeAction:Ie,showRunAction:Le,showStopRunAction:Re,showAdvanceAction:De,advanceLabel:Se,canAdvance:Ee,showParkAction:Oe,showReturnAction:Ae,returnLabel:ke,showBuildChainAction:je,showPauseBuildAction:Me,showResumeBuildAction:Ne,showStopBuildChainAction:ze,onDelete:y,onConfirmDelete:()=>te(!0),onConfirmUndo:()=>re(!0),onOpenTests:D,onOpenChanges:O,onOpenIde:k,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:He,onStop:Ue,onStopBuild:j,onResumeBuild:N,onStopBuildChain:M})})]})]}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(DT,{ticket:e,hideStatusBadge:ee,hideBundleScopedControls:R,isStale:ye,runControl:null,onRetry:x,undoInProgress:B,isChainStart:me.isVisibleStartPoint})}),lt&&(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[ct&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${rt}`,children:[ot&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:md(e.bundle)}),st&&e.bundle?.pull_request&&(0,Z.jsx)(Ew,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})]}),at.length>0&&(0,Z.jsx)(`div`,{className:rt,children:(0,Z.jsx)(`span`,{className:`truncate`,children:at})})]}),e.description&&(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(ET,{description:e.description,descriptionClass:it,isExpanded:ut,collapsedState:dt,useStaleLikeStyling:xe,onExpand:()=>ce(e.id),onCollapse:()=>ce(null)})}),!R&&(zw(ve,e.diff_stats)||be)&&(0,Z.jsx)(gu,{stats:e.diff_stats,isLoading:be,showFiles:!0,className:`mt-2`})]})]}),ie&&(0,Z.jsx)(XW,{ticket:e,allTickets:t,dependencies:n,bundles:r,projectMemoryEnabled:i,onClose:()=>{ae(!1),z?.(e.id)},showModelSelector:o,availableModels:s,runDisabled:c,runDisabledReason:l,onDeleteDependency:f,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onAdvance:S,onBuildChain:T,onRun:E,onOpenIde:k,onStop:A,onStopBuild:j,onStopBuildChain:M,onResumeBuild:N,onFollowUp:P}),V&&(0,Z.jsx)(TT,{title:e.title,bundleName:e.bundle?md(e.bundle):void 0,onConfirm:()=>{te(!1),y?.()},onCancel:()=>te(!1)}),ne&&we?.stage&&(0,Z.jsx)(pT,{title:e.title,stage:we.stage,onConfirm:()=>{re(!1),b?.()},onCancel:()=>re(!1)})]})},QW=({index:e})=>(0,Z.jsx)(kd,{"aria-hidden":`true`,"data-testid":`ticket-card-skeleton`,className:`group shrink-0 select-none gap-0 rounded-xl border border-border/70 bg-secondary/20 shadow-none`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(hu,{className:`h-3.5 w-3/5 rounded-full`}),(0,Z.jsx)(hu,{className:`h-5 w-11 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(hu,{className:`h-3 w-full rounded-full`}),(0,Z.jsx)(hu,{className:`h-3 w-11/12 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(hu,{className:`h-4 w-14 rounded-full`}),(0,Z.jsx)(hu,{className:`h-4 w-10 rounded-full`})]}),(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`Loading card `,e+1]})]})}),$W=({id:e,title:t,items:n,ticketCount:r,pinnedContent:i=null,allTickets:a,dependencies:o,showModelSelector:s,availableModels:c,activeRunContextKey:l,isProjectRootRunActive:u=!1,isBundleRunDisabled:d,bundles:f,getDependencyTargetState:p,onDependencyStart:m,onDeleteDependency:h,onRegisterTicketNode:g,onAddTicket:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdateTicket:x,onDeleteTicket:S,onUndoTicket:C,undoingColumn:w=null,onRetryTicket:T,onAdvanceTicket:E,onParkTicket:D,onUnparkTicket:O,onBuildChainTicket:k,onRunTicket:A,onOpenTestsTicket:j,canOpenChangesForTicket:M,onOpenChangesTicket:N,canOpenIdeForTicket:P,onOpenIdeTicket:F,onStopTicket:I,onStopBuildTicket:L,onStopBuildChainTicket:R,onResumeBuildTicket:ee,onFollowUpTicket:z,onBuildBundle:B,onReviewBundle:V,onUndoBundleReview:te,onRunBundle:ne,onStopBundle:re,onParkBundleWrapper:ie,onUnparkBundleWrapper:ae,bundleActionState:oe,onOpenTicketDetails:se,onOpenBundleDetails:H,onOpenBundleChanges:ce,onOpenBundleTests:le,onOpenBundleIde:ue,onDeleteBundleWrapper:W,onRequestBundleRefresh:de,onRequestTicketRefresh:G,className:fe=``,headerAccessory:K=null,loadingSkeletonCount:q=0})=>{let{setNodeRef:pe,isOver:me}=aw({id:e}),he=(0,X.useRef)(null),[ge,_e]=(0,X.useState)(!1),[ve,ye]=(0,X.useState)(!1),be=e=>e.has_worktree??!!(e.bundle?.branch??e.branch),xe=me?`border-primary`:`border-border`,Se=w===e&&(e===`build`||e===`review`),Ce=(0,X.useCallback)(()=>{let e=he.current;if(!e){_e(!1),ye(!1);return}if(!(e.scrollHeight>e.clientHeight+1)){_e(!1),ye(!1);return}let t=e.scrollHeight-e.clientHeight;_e(e.scrollTop>1),ye(e.scrollTop<t-1)},[]);(0,X.useEffect)(()=>{let e=window.requestAnimationFrame(Ce),t=he.current;if(!t){window.cancelAnimationFrame(e);return}return t.addEventListener(`scroll`,Ce),window.addEventListener(`resize`,Ce),()=>{window.cancelAnimationFrame(e),t.removeEventListener(`scroll`,Ce),window.removeEventListener(`resize`,Ce)}},[n.length,q,Ce]);let we=(0,X.useCallback)((t,n)=>{let r=t.worktree_bundle_id!==null,i=n?.nestedInBundle??!1,d=n?.hideStatusBadge??!1,_=r&&e!==`plan`,w=tT(t),B=u||l!==null&&l!==Nw(t)?`Stop the currently running ticket before starting another run.`:w;return(0,Z.jsx)(ZW,{ticket:t,allTickets:a,dependencies:o,bundles:f,showModelSelector:s,availableModels:c,runDisabled:B!==void 0,runDisabledReason:B,dependencyTargetState:p?.(t.id)??`idle`,onDependencyStart:m,onDeleteDependency:h,onRegisterNode:g,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdate:x,onDelete:()=>S(t.id),onUndo:C?()=>C(t.id):void 0,undoInProgress:!1,onRetry:()=>T(t.id),onAdvance:E?()=>E(t.id):void 0,onPark:D?()=>D(t.id):void 0,onUnpark:O?()=>O(t.id):void 0,onBuildChain:k?()=>k(t.id):void 0,onRun:be(t)&&t.has_run_config&&A?()=>A(t.id):void 0,onOpenTests:j&&t.project_id&&be(t)?()=>j(t.id):void 0,onOpenChanges:M?.(t)&&N?()=>N(t.id):void 0,onOpenIde:P?.(t)&&F?()=>F(t.id):void 0,onStop:I?()=>I(t.id):void 0,onStopBuild:L?()=>L(t.id):void 0,onStopBuildChain:R?()=>R(t.id):void 0,onResumeBuild:ee?()=>ee(t.id):void 0,onFollowUp:z?e=>z(t.id,e):void 0,onOpenBundleDetails:_&&H?()=>H(t.worktree_bundle_id,e):void 0,onOpenTicketDetails:()=>se(t),preferBundleDetailsOnClick:_,hideBundleScopedControls:i,hideStatusBadge:d,onRequestTicketRefresh:G})},[l,a,c,f,M,P,o,p,e,u,E,k,v,y,h,S,m,z,H,N,F,j,se,D,b,g,G,ee,T,A,R,L,I,C,O,x,s]);return(0,Z.jsxs)(kd,{className:`flex min-h-0 min-w-[280px] flex-1 flex-col rounded-2xl bg-card/80 p-4 transition-colors ${fe} ${xe}`,ref:pe,children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex min-h-7 items-center justify-between`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:t}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K,(0,Z.jsx)(J,{variant:`outline`,children:r}),_&&(0,Z.jsxs)(U,{type:`button`,onClick:_,size:`xs`,variant:`success`,className:`gap-2 shadow-[0_8px_20px_rgba(16,185,129,0.22)]`,children:[(0,Z.jsx)(`span`,{children:`+ New ticket`}),(0,Z.jsx)(J,{"aria-hidden":`true`,variant:`hotkeyDark`,className:`rounded-md px-1.5 py-0.5 text-[10px] leading-none`,children:`N`})]})]})]}),(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{ref:he,className:`flex min-h-0 h-full flex-col gap-2.5 overflow-y-auto pr-1`,children:[i,n.map(e=>{if(e.kind===`bundle`)return(0,Z.jsx)(ST,{group:e.group,renderTicket:t=>we(t,{nestedInBundle:!0,hideStatusBadge:e.group.column===`review`}),runDisabled:d?.(e.group.bundle.id)??!1,onBuildBundle:B,onReviewBundle:V,onUndoBundleReview:te,onRunBundle:ne,onStopBundle:re,onParkBundleWrapper:ie,onUnparkBundleWrapper:ae,bundleActionState:oe,onStopBuildTicket:L,onResumeBuildTicket:ee,onOpenBundleDetails:H,onOpenBundleChanges:ce,onOpenBundleTests:le,onOpenBundleIde:ue,onDeleteBundleWrapper:W,onRequestBundleRefresh:de},e.group.id);let t=e.ticket;return(0,Z.jsx)(X.Fragment,{children:we(t)},t.id)}),Array.from({length:q},(t,n)=>(0,Z.jsx)(QW,{index:n},`loading-card-${e}-${n}`))]}),Se&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-undo-overlay-${e}`,className:`absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(J,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Bf,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),ge&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-top-fade`,className:`pointer-events-none absolute inset-x-0 top-0 h-6 rounded-t-xl bg-gradient-to-b from-card to-transparent`}),ve&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-bottom-fade`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 rounded-b-xl bg-gradient-to-t from-card to-transparent`})]})]})},eG=({ticketCount:e,isDeleting:t,onCancel:n,onConfirm:r})=>{let i=e===1?`1 done ticket`:`${e} done tickets`;return(0,Z.jsxs)(Ce,{onClose:t?()=>{}:n,overlayClassName:`bg-black/60`,panelClassName:`max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Empty Done`}),(0,Z.jsxs)(`p`,{className:`mb-2 text-sm text-foreground`,children:[`Delete `,i,` from the Done column?`]}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`Standalone ticket worktrees will be removed when applicable. Deleting the last parked ticket in a bundle also removes that shared bundle worktree.`}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,variant:`ghost`,disabled:t,onClick:n,children:`Cancel`}),(0,Z.jsx)(U,{type:`button`,variant:`destructive`,disabled:t,onClick:r,children:t?`Deleting...`:`Delete all`})]})]})},tG=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,thinkingTicketId:i=null,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c=!1,canShowComposer:l,composerControls:u,composerTheme:d=`default`,layoutKey:f,scrollLayoutKey:p,followUpPrompt:m,followUpPlaceholder:h=`Follow up on this bundle`,isSendingFollowUp:g,followUpDisabledReason:_,onFollowUpPromptChange:v,onFollowUpKeyDown:y,onFollowUpSubmit:b})=>(0,Z.jsx)(LN,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,thinkingTicketId:i,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c,autoScrollBehavior:`sticky`,canShowComposer:l,composerInlineControls:u,composerTheme:d,composerSize:`compact-on-laptop`,layoutKey:f,scrollLayoutKey:p,followUpPrompt:m,followUpPlaceholder:h,emptyStateText:`No bundle messages yet.`,autoFocusComposer:!0,isSendingFollowUp:g,followUpDisabledReason:_,onFollowUpPromptChange:v,onFollowUpKeyDown:y,onFollowUpSubmit:b}),nG=({bundleId:e,actionState:t,runDisabled:n,canBuild:r,canStopBuild:i,runningBuildTicketId:a,canResumeBuild:o,resumableBuildTicketId:s,isRunning:c,canRun:l,canReview:u,reviewActionLabel:d=`Review Bundle`,onClose:f,onBuildBundle:p,onStopBuildTicket:m,onResumeBuildTicket:h,onRunBundle:g,onStopBundle:_,onReviewBundle:v})=>{let y=t.review||t.followUp;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),c?(0,Z.jsxs)(U,{type:`button`,variant:`destructive`,disabled:t.stop,onClick:()=>void _(e),children:[(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),t.stop?`Stopping...`:`Stop Run`]}):l?(0,Z.jsxs)(U,{type:`button`,variant:`secondary`,disabled:t.run||n,title:n?`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{n||g(e)},className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),t.run?`Starting Run...`:`Run`]}):null,r&&(0,Z.jsxs)(U,{type:`button`,disabled:t.build,onClick:()=>void p(e),children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),t.build?`Building Bundle...`:`Build Bundle`]}),i&&a&&(0,Z.jsxs)(U,{type:`button`,variant:`warning`,disabled:t.stopBuild,title:`Pause the build session. You can resume it later.`,"aria-label":`Pause Build`,onClick:()=>void m(a),children:[(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),t.stopBuild?`Pausing...`:`Pause Build`]}),o&&s&&(0,Z.jsxs)(U,{type:`button`,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,disabled:t.resumeBuild,onClick:()=>void h(s),children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),t.resumeBuild?`Resuming...`:`Resume`]}),u&&(0,Z.jsxs)(U,{type:`button`,disabled:y,onClick:()=>void v(e),children:[(0,Z.jsx)(Ow,{className:`w-3.5 h-3.5`}),y?`Reviewing Bundle...`:d]})]})]})},rG=e=>e.agent_status===`running`?`bg-amber-400`:e.agent_status===`error`?`bg-rose-400`:e.agent_status===`stopped`?`bg-amber-300`:e.agent_status===`done`?`bg-emerald-400`:`bg-border`,iG=({tickets:e,onOpenTicketDetails:t,highlightedTicketId:n=null,pendingMemorySuggestionCounts:r={}})=>{let i=e.filter(e=>e.agent_status===`running`).length,a=e.filter(e=>e.agent_status===`error`).length;return(0,Z.jsxs)(`section`,{"aria-label":`Bundle tickets`,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Tickets`}),(0,Z.jsx)(J,{variant:`outline`,children:e.length}),i>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[i,` active`]}),a>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-rose-300`,children:[a,` error`,a===1?``:`s`]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-col gap-1 overflow-y-auto pr-1`,children:e.map(e=>{let i=r[e.id]??0,a=e.id===n;return(0,Z.jsxs)(`button`,{type:`button`,"data-follow-up-target":a?`true`:`false`,"aria-current":a?`true`:void 0,className:W(`flex cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2.5 text-left text-foreground transition-colors`,a?`border border-sky-500/35 bg-sky-500/10 shadow-[inset_0_0_0_1px_rgba(56,189,248,0.12)] hover:bg-sky-500/15`:`bg-background/20 hover:bg-accent/45`),onClick:()=>t(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:W(`h-2 w-2 shrink-0 rounded-full`,rG(e))}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.title}),(0,Z.jsx)(NT,{tool:e.tool,className:`shrink-0 text-[10px]`})]}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e.state})]}),a&&(0,Z.jsx)(J,{variant:`info`,className:`shrink-0 px-1.5 text-[10px]`,"aria-label":`Follow-up target`,children:`Follow-up`}),i>0&&(0,Z.jsx)(J,{variant:`warning`,className:`h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[10px]`,"aria-label":`${i} pending memory suggestion${i===1?``:`s`}`,title:`${i} pending memory suggestion${i===1?``:`s`}`,children:i})]},e.id)})})]})},aG=(0,X.lazy)(()=>VW(()=>Promise.resolve().then(()=>Xq).then(e=>({default:e.TicketChangesModal})),void 0)),oG=e=>e.kind===`description`?e.bundle_visible_at??e.created_at:e.created_at,sG=e=>e.replace(/\r\n/g,`
133
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return wP.get()},set promptLabel(e){wP.set(e)},get tooMuchOutput(){return EP.get()},set tooMuchOutput(e){EP.set(e)}}}_verifyIntegers(...e){for(HH of e)if(HH===1/0||isNaN(HH)||HH%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(HH of e)if(HH&&(HH===1/0||isNaN(HH)||HH%1!=0||HH<0))throw Error(`This API only accepts positive integers`)}},WH=Object.create(null);WH.open=`0`,WH.close=`1`,WH.ping=`2`,WH.pong=`3`,WH.message=`4`,WH.upgrade=`5`,WH.noop=`6`;var GH=Object.create(null);Object.keys(WH).forEach(e=>{GH[WH[e]]=e});var KH={type:`error`,data:`parser error`},qH=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,JH=typeof ArrayBuffer==`function`,YH=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,XH=({type:e,data:t},n,r)=>qH&&t instanceof Blob?n?r(t):ZH(t,r):JH&&(t instanceof ArrayBuffer||YH(t))?n?r(t):ZH(new Blob([t]),r):r(WH[e]+(t||``)),ZH=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function QH(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var $H;function eU(e,t){if(qH&&e.data instanceof Blob)return e.data.arrayBuffer().then(QH).then(t);if(JH&&(e.data instanceof ArrayBuffer||YH(e.data)))return t(QH(e.data));XH(e,!1,e=>{$H||=new TextEncoder,t($H.encode(e))})}var tU=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,nU=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)nU[tU.charCodeAt(e)]=e;var rU=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=nU[e.charCodeAt(r)],o=nU[e.charCodeAt(r+1)],s=nU[e.charCodeAt(r+2)],c=nU[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},iU=typeof ArrayBuffer==`function`,aU=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:sU(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:oU(e.substring(1),t)}:GH[n]?e.length>1?{type:GH[n],data:e.substring(1)}:{type:GH[n]}:KH},oU=(e,t)=>iU?sU(rU(e),t):{base64:!0,data:e},sU=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},cU=``,lU=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{XH(e,!1,e=>{r[a]=e,++i===n&&t(r.join(cU))})})},uU=(e,t)=>{let n=e.split(cU),r=[];for(let e=0;e<n.length;e++){let i=aU(n[e],t);if(r.push(i),i.type===`error`)break}return r};function dU(){return new TransformStream({transform(e,t){eU(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var fU;function pU(e){return e.reduce((e,t)=>e+t.length,0)}function mU(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function hU(e,t){fU||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(pU(n)<1)break;let e=mU(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(pU(n)<2)break;let e=mU(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(pU(n)<8)break;let e=mU(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(KH);break}i=a*2**32+t.getUint32(4),r=3}else{if(pU(n)<i)break;let e=mU(n,i);s.enqueue(aU(a?e:fU.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(KH);break}}}})}function gU(e){if(e)return _U(e)}function _U(e){for(var t in gU.prototype)e[t]=gU.prototype[t];return e}gU.prototype.on=gU.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},gU.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},gU.prototype.off=gU.prototype.removeListener=gU.prototype.removeAllListeners=gU.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},gU.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},gU.prototype.emitReserved=gU.prototype.emit,gU.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},gU.prototype.hasListeners=function(e){return!!this.listeners(e).length};var vU=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),yU=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),bU=`arraybuffer`;function xU(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var SU=yU.setTimeout,CU=yU.clearTimeout;function wU(e,t){t.useNativeTimers?(e.setTimeoutFn=SU.bind(yU),e.clearTimeoutFn=CU.bind(yU)):(e.setTimeoutFn=yU.setTimeout.bind(yU),e.clearTimeoutFn=yU.clearTimeout.bind(yU))}var TU=1.33;function EU(e){return typeof e==`string`?DU(e):Math.ceil((e.byteLength||e.size)*TU)}function DU(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function OU(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function kU(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function AU(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var jU=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},MU=class extends gU{constructor(e){super(),this.writable=!1,wU(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new jU(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=aU(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=kU(e);return t.length?`?`+t:``}},NU=class extends MU{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){uU(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,lU(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=OU()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},PU=!1;try{PU=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var FU=PU;function IU(){}var LU=class extends NU{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},RU=class e extends gU{constructor(e,t,n){super(),this.createRequest=e,wU(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=xU(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=IU,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(RU.requestsCount=0,RU.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,zU);else if(typeof addEventListener==`function`){let e=`onpagehide`in yU?`pagehide`:`unload`;addEventListener(e,zU,!1)}}function zU(){for(let e in RU.requests)RU.requests.hasOwnProperty(e)&&RU.requests[e].abort()}var BU=(function(){let e=HU({xdomain:!1});return e&&e.responseType!==null})(),VU=class extends LU{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=BU&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new RU(HU,this.uri(),e)}};function HU(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||FU))return new XMLHttpRequest}catch{}if(!t)try{return new yU[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var UU=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,WU=class extends MU{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=UU?{}:xU(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;XH(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&vU(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=OU()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},GU=yU.WebSocket||yU.MozWebSocket,KU={websocket:class extends WU{createSocket(e,t,n){return UU?new GU(e,t,n):t?new GU(e,t):new GU(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends MU{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=hU(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=dU();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&vU(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:VU},qU=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,JU=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function YU(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=qU.exec(e||``),a={},o=14;for(;o--;)a[JU[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=XU(a,a.path),a.queryKey=ZU(a,a.query),a}function XU(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function ZU(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var QU=typeof addEventListener==`function`&&typeof removeEventListener==`function`,$U=[];QU&&addEventListener(`offline`,()=>{$U.forEach(e=>e())},!1);var eW=class e extends gU{constructor(e,t){if(super(),this.binaryType=bU,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=YU(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=YU(t.host).host);wU(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=AU(this.opts.query)),QU&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},$U.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=EU(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,vU(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),QU&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=$U.indexOf(this._offlineEventListener);e!==-1&&$U.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};eW.protocol=4;var tW=class extends eW{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;eW.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;eW.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},nW=class extends tW{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>KU[e]).filter(e=>!!e)),super(e,n)}};nW.protocol;function rW(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=YU(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var iW=typeof ArrayBuffer==`function`,aW=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,oW=Object.prototype.toString,sW=typeof Blob==`function`||typeof Blob<`u`&&oW.call(Blob)===`[object BlobConstructor]`,cW=typeof File==`function`||typeof File<`u`&&oW.call(File)===`[object FileConstructor]`;function lW(e){return iW&&(e instanceof ArrayBuffer||aW(e))||sW&&e instanceof Blob||cW&&e instanceof File}function uW(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(uW(e[t]))return!0;return!1}if(lW(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return uW(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&uW(e[t]))return!0;return!1}function dW(e){let t=[],n=e.data,r=e;return r.data=fW(n,t),r.attachments=t.length,{packet:r,buffers:t}}function fW(e,t){if(!e)return e;if(lW(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=fW(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=fW(e[r],t));return n}return e}function pW(e,t){return e.data=mW(e.data,t),delete e.attachments,e}function mW(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=mW(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=mW(e[n],t));return e}var hW=r({Decoder:()=>yW,Encoder:()=>vW,PacketType:()=>_W,isPacketValid:()=>EW,protocol:()=>5}),gW=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],_W;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(_W||={});var vW=class{constructor(e){this.replacer=e}encode(e){return(e.type===_W.EVENT||e.type===_W.ACK)&&uW(e)?this.encodeAsBinary({type:e.type===_W.EVENT?_W.BINARY_EVENT:_W.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===_W.BINARY_EVENT||e.type===_W.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=dW(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},yW=class e extends gU{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===_W.BINARY_EVENT;n||t.type===_W.BINARY_ACK?(t.type=n?_W.EVENT:_W.ACK,this.reconstructor=new bW(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(lW(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(_W[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===_W.BINARY_EVENT||r.type===_W.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!SW(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case _W.CONNECT:return wW(t);case _W.DISCONNECT:return t===void 0;case _W.CONNECT_ERROR:return typeof t==`string`||wW(t);case _W.EVENT:case _W.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&gW.indexOf(t[0])===-1);case _W.ACK:case _W.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},bW=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=pW(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function xW(e){return typeof e==`string`}var SW=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function CW(e){return e===void 0||SW(e)}function wW(e){return Object.prototype.toString.call(e)===`[object Object]`}function TW(e,t){switch(e){case _W.CONNECT:return t===void 0||wW(t);case _W.DISCONNECT:return t===void 0;case _W.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&gW.indexOf(t[0])===-1);case _W.ACK:return Array.isArray(t);case _W.CONNECT_ERROR:return typeof t==`string`||wW(t);default:return!1}}function EW(e){return xW(e.nsp)&&CW(e.id)&&TW(e.type,e.data)}function DW(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var OW=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),kW=class extends gU{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[DW(e,`open`,this.onopen.bind(this)),DW(e,`packet`,this.onpacket.bind(this)),DW(e,`error`,this.onerror.bind(this)),DW(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(OW.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:_W.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:_W.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case _W.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case _W.EVENT:case _W.BINARY_EVENT:this.onevent(e);break;case _W.ACK:case _W.BINARY_ACK:this.onack(e);break;case _W.DISCONNECT:this.ondisconnect();break;case _W.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:_W.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:_W.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function AW(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}AW.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},AW.prototype.reset=function(){this.attempts=0},AW.prototype.setMin=function(e){this.ms=e},AW.prototype.setMax=function(e){this.max=e},AW.prototype.setJitter=function(e){this.jitter=e};var jW=class extends gU{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,wU(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new AW({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||hW;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new nW(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=DW(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=DW(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(DW(e,`ping`,this.onping.bind(this)),DW(e,`data`,this.ondata.bind(this)),DW(e,`error`,this.onerror.bind(this)),DW(e,`close`,this.onclose.bind(this)),DW(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){vU(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new kW(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},MW={};function NW(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=rW(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=MW[i]&&a in MW[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new jW(r,t):(MW[i]||(MW[i]=new jW(r,t)),c=MW[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(NW,{Manager:jW,Socket:kW,io:NW,connect:NW});var PW=NW(k),FW=({label:e,onClick:t,children:n})=>(0,Z.jsx)(U,{type:`button`,"aria-label":e,onClick:t,variant:`outline`,size:`icon-sm`,className:`bg-secondary/60`,children:n}),IW=({exitCode:e,signal:t})=>t>0?`[archon] Shell exited with signal ${t}`:`[archon] Shell exited with code ${e}`,LW=({createSession:e,isExpanded:t,isVisible:n,onClose:r,onToggleExpanded:i,className:a=``,ariaLabel:o=`Terminal`,title:s=`Terminal`,closeLabel:c=`Close terminal`,headerMeta:l})=>{let u=(0,X.useRef)(null),d=(0,X.useRef)(null),f=(0,X.useRef)(null),p=(0,X.useRef)(null),m=(0,X.useRef)(e),h=(0,X.useRef)(!1),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!0);return(0,X.useEffect)(()=>{m.current=e},[e]),(0,X.useEffect)(()=>{if(!u.current)return;let e=new UH({cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,fontSize:13,theme:{background:`#0b0d14`,foreground:`#d8deef`,cursor:`#c4b5fd`}}),t=new _P,n=null,r=!1;e.loadAddon(t),e.open(u.current),d.current=e,f.current=t;let i=()=>{let e=p.current;!e||h.current||(h.current=!0,AT(e))};window.addEventListener(`pagehide`,i),window.addEventListener(`beforeunload`,i);let a=()=>{p.current&&PW.emit(`terminal:resize`,{sessionId:p.current,cols:e.cols,rows:e.rows})},o=()=>{!u.current||r||(t.fit(),a())},s=t=>{t.sessionId===p.current&&(y(!1),window.setTimeout(()=>{o(),e.focus()},0))},c=t=>{t.sessionId===p.current&&(y(!1),e.write(t.data))},l=t=>{t.sessionId===p.current&&(e.writeln(``),e.writeln(IW(t)))},g=t=>{t.sessionId&&t.sessionId!==p.current||(y(!1),_(t.message),e.writeln(``),e.writeln(`[archon] ${t.message}`))};PW.on(`terminal:ready`,s),PW.on(`terminal:data`,c),PW.on(`terminal:exit`,l),PW.on(`terminal:error`,g);let v=e.onData(e=>{p.current&&PW.emit(`terminal:input`,{sessionId:p.current,input:e})});return typeof ResizeObserver==`function`&&(n=new ResizeObserver(()=>{o()}),n.observe(u.current)),window.setTimeout(()=>{o()},0),m.current().then(e=>{r||(p.current=e.session_id,PW.emit(`terminal:join`,{sessionId:e.session_id}))}).catch(t=>{if(r)return;y(!1);let n=t instanceof Error?t.message:`Unable to open the terminal right now.`;_(n),e.writeln(``),e.writeln(`[archon] ${n}`)}),()=>{r=!0,window.removeEventListener(`pagehide`,i),window.removeEventListener(`beforeunload`,i),p.current&&(h.current||PW.emit(`terminal:destroy`,{sessionId:p.current})),n?.disconnect(),v.dispose(),PW.off(`terminal:ready`,s),PW.off(`terminal:data`,c),PW.off(`terminal:exit`,l),PW.off(`terminal:error`,g),e.dispose(),d.current=null,f.current=null,p.current=null}},[]),(0,X.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{f.current?.fit(),d.current&&p.current&&(PW.emit(`terminal:resize`,{sessionId:p.current,cols:d.current.cols,rows:d.current.rows}),d.current.focus())},0);return()=>{window.clearTimeout(e)}},[t,n]),(0,Z.jsxs)(kd,{"aria-label":o,"data-terminal-pane":`true`,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden rounded-xl border-border bg-[#0c1119] ${a}`.trim(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border bg-card/80 px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary/12 text-primary`,children:(0,Z.jsx)(Cu,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),l&&(0,Z.jsx)(`div`,{className:`mt-1 min-w-0 text-xs text-muted-foreground`,children:l})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v&&!g&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Opening terminal...`}),g&&(0,Z.jsx)(`span`,{className:`max-w-56 truncate text-xs text-red-300`,children:g}),(0,Z.jsx)(FW,{label:t?`Collapse terminal`:`Expand terminal`,onClick:i,children:t?(0,Z.jsx)(Df,{className:`h-4 w-4`}):(0,Z.jsx)(Of,{className:`h-4 w-4`})}),(0,Z.jsx)(FW,{label:c,onClick:r,children:(0,Z.jsx)(pe,{className:`h-4 w-4`})})]})]}),(0,Z.jsx)(`div`,{ref:u,"data-testid":`terminal-viewport`,onClick:()=>d.current?.focus(),className:`min-h-0 flex-1 overflow-hidden bg-[#0b0d14] pb-4`})]})},RW=`modulepreload`,zW=function(e){return`/`+e},BW={},VW=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=zW(t,n),t in BW)return;BW[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:RW,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},HW=(0,X.lazy)(()=>VW(()=>Promise.resolve().then(()=>Xq).then(e=>({default:e.TicketChangesModal})),void 0)),UW=(0,X.lazy)(()=>VW(()=>import(`./TestsDialog-Buw5J9nT.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),WW=`(min-width: 1280px)`,GW=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!0:window.matchMedia(e).matches,KW=e=>{let[t,n]=(0,X.useState)(()=>GW(e));return(0,X.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>{n(t.matches)};return r(),t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}},[e]),t},qW=({onClose:e})=>(0,Z.jsx)(Ce,{onClose:e,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-full w-full max-w-none items-center justify-center rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Loading diff...`})}),JW=({ariaLabel:e,title:t,closeAriaLabel:n,className:r,showTopSpacer:i=!0,description:a,onClose:o,...s})=>(0,Z.jsxs)(`aside`,{className:`min-h-0 flex flex-col gap-3 overflow-hidden${r?` ${r}`:``}`,"aria-label":e,children:[i?(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`h-9 shrink-0`}):null,(0,Z.jsx)(RN,{...s,header:({showThinkingControl:e})=>(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:t}),e]}),a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:a}):null]}),(0,Z.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n,onClick:o,children:(0,Z.jsx)(pe,{className:`h-4 w-4`})})]})})]}),YW=(e,t)=>e?t.find(t=>t.id===e)?.label??e:null,XW=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectTestCommands:i=[],showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],projectBranchState:c=null,projectMemoryEnabled:l=!1,runDisabled:u=!1,runDisabledReason:d,onClose:f,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onUpdate:g,onDeleteDependency:_,onAdvance:v,onBuildChain:y,onRun:b,onOpenIde:x,onStop:S,onStopBuild:C,onStopBuildChain:w,onResumeBuild:T,onFollowUp:E,onRequestTicketRefresh:D,onProjectMemorySuggestionsChanged:O})=>{let[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(!1),[L,R]=(0,X.useState)(!1),[ee,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)(!1),[te,ne]=(0,X.useState)(``),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),[se,H]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(0),[ue,W]=(0,X.useState)(!1),[de,G]=(0,X.useState)(!1),[fe,K]=(0,X.useState)(null),q=k??e,[pe,me]=(0,X.useState)(q.model??``),[he,ge]=(0,X.useState)(q.variant??``),[_e,ve]=(0,X.useState)(q.skills??[]),[ye,be]=(0,X.useState)(()=>YW(q.model,o)??`Agent`),xe=(0,X.useRef)(q.id),Se=(0,X.useRef)(null),we=(0,X.useRef)(null),Te=(0,X.useRef)(!1),Ee=(0,X.useRef)(q.id),De=(0,X.useRef)(q.build_completed_at),Oe=KW(WW),[ke,Ae]=(0,X.useState)(!1),[je,Me]=(0,X.useState)({model:q.model,variant:q.variant,skills:q.skills??[]}),Ne=q.state===`plan`,Pe=Mw(q.state),Fe=q.worktree_bundle_id!==null,Ie=Ne&&q.agent_status===`running`,Le=Ne&&q.agent_status===`error`,Re=Ne&&!Ie||j,ze=jw(q.state),Be=ze?Hw(q,ze):!1,Ve=ze?ze===`review`?`Review Bundle`:ze.charAt(0).toUpperCase()+ze.slice(1):null,He=async e=>{let t=await xt(q.id,q.project_id,e);return A(t),g?.(t),h&&await h(),t},Ue=async e=>{try{await He(e),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},We=async e=>{try{if(await He(e),!v){f();return}await v(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Ge=async()=>{!v||!Be||(await v(),f())},Ke=async e=>{try{if(await He(e),!y){f();return}await y(),f()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}},Y=Ne?q.planning_session_id:q.session_id,qe=Y?Y.startsWith(`ses_`)?`opencode --session ${Y}`:`claude --resume ${Y}`:null,Je=q.bundle?.branch??q.branch,Ye=q.has_worktree??!!Je,Xe=!Re&&Pw(q)&&q.agent_status===`running`&&!!q.session_id&&!!C,Ze=!Re&&Pw(q)&&q.agent_status===`stopped`&&!!q.session_id&&!!T,Qe=`Pause Build`,$e=`Stop Build Chain`,et=`Stop Run`,tt=new Map(t.map(e=>[e.id,e])),nt=n.filter(e=>e.blocker_ticket_id===q.id),rt=n.filter(e=>e.dependent_ticket_id===q.id),it=oT(q,tt,n),at=it.pendingBuildChainOrder.length>0?`Will build in order: ${it.pendingBuildChainOrder.map(e=>e.title).join(` -> `)}`:`All tickets in this chain have already finished build.`,ot=it.skippedBuildChainCount>0?`Skips ${it.skippedBuildChainCount} ticket${it.skippedBuildChainCount===1?``:`s`} that already finished build.`:null,st=it.hasOpenBlockers,ct=Lw(q),lt=q.build_chain?.active_ticket_id?`Currently building ${tt.get(q.build_chain.active_ticket_id)?.title??`Unknown ticket`}.`:`Build chain is active.`,ut=q.build_chain&&q.build_chain.queued_ticket_ids.length>0?`Queued next: ${q.build_chain.queued_ticket_ids.map(e=>tt.get(e)?.title??`Unknown ticket`).join(` -> `)}`:`No additional tickets are queued after the current build.`,dt=Ne&&!!v&&!it.hasOpenBlockers,ft=Ne&&!!y&&it.canStartBuildChain,pt=!!q.project_id&&!Ne&&!Fe,mt=Ne,ht=Fe&&!Ne,gt=!!q.project_id&&!!Je&&Ye&&!Re&&!Ie&&!Fe,_t=!!q.project_id&&Ye&&!Re&&!Ie&&!!x&&!Fe,vt=!!q.project_id&&i.length>0&&Ye,yt=pt&&!L,bt=pt&&B,St=te.trim(),Ct=!Re&&!Ie&&q.state!==`plan`&&Ye&&!!E,wt=mt&&ae,Tt=ht&&se,Et=(q.planning_context?.open_questions.length??0)>0,Dt=Ct&&a&&q.tool===`opencode`,Ot=o.find(e=>e.id===pe)??null,kt=q.agent_status===`running`,At=gT(q,{allTickets:t,preferBundleReviewStatus:!0}),jt=q.skills??[],Mt=kt?`Wait for the current build to finish before sending a follow-up prompt.`:void 0,Nt=Ie?`Wait for planning to finish before sending another message.`:void 0,Pt=[...Ie?[]:[{label:`Worktree`,value:Je??``}],{label:`Session`,value:qe??``},...Ie?[{label:q.bundle?.kind===`project_root`?`Project root branch`:`Bundle`,value:(q.bundle?.kind,q.bundle?md(q.bundle):``)}]:Ne?[{label:`Bundle`,value:q.bundle?md(q.bundle):``},{label:`Model`,value:q.model??``},{label:`Variant`,value:q.variant??``},{label:`Skills`,value:jt.length>0?`${jt.length} skill${jt.length===1?``:`s`}`:``},{label:`Initiative`,value:q.planning_context?.initiative_prompt??``}]:[]],Ft=Ie?{model:q.model??``,variant:q.variant??``,skills:jt}:null,It=mt&&ae,Lt=ht&&se,Rt=(It||Lt)&&!Oe,zt=It&&!Rt,Bt=zt||Lt&&!Rt,Vt=Ne&&(It||!Oe),Ht=L?`flex h-[92vh] w-[96vw] max-w-7xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Bt?`flex h-[92vh] w-[98vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:Rt?`flex h-[92vh] w-[98vw] max-w-6xl flex-col gap-3 overflow-hidden rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-6xl flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,Ut=L&&!ee?`grid min-h-0 flex-1 grid-cols-1 gap-3 lg:grid-cols-2`:Bt?`grid min-h-0 flex-1 grid-cols-1 gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(30rem,1fr)]`:`flex min-h-0 flex-1 flex-col`,Wt=()=>{V(!0),R(e=>(e&&z(!1),!e))},qt=()=>{R(!1),z(!1),V(!1),D?.(q.id)},Jt=()=>{G(!1),K(null)},Yt=()=>{G(!1),fe===`cancel_edit`&&!Ne?M(!1):f(),K(null)},Xt=()=>{if(!Re){f();return}if(!ue){f();return}K(`close_modal`),G(!0)},Zt=()=>{if(Ne){Xt();return}if(!ue){M(!1);return}K(`cancel_edit`),G(!0)};(0,X.useEffect)(()=>{A(t=>!t||t.id!==e.id||e.updated_at>=t.updated_at?null:t)},[e]),(0,X.useEffect)(()=>{if(Ee.current!==q.id){Ee.current=q.id,De.current=q.build_completed_at;return}if(De.current===q.build_completed_at)return;let e=De.current;De.current=q.build_completed_at,q.build_completed_at&&q.build_completed_at!==e&&le(e=>e+1)},[q.build_completed_at,q.id]),(0,X.useEffect)(()=>{me(q.model??``),ge(q.variant??``),ve(q.skills??[])},[q.model,q.skills,q.variant]),(0,X.useEffect)(()=>{xe.current!==q.id&&(xe.current=q.id,be(YW(q.model,o)??`Agent`))},[o,q.id,q.model]),(0,X.useEffect)(()=>{let e=YW(q.model,o);e&&be(e)},[o,q.model]),(0,X.useEffect)(()=>{Me({model:q.model,variant:q.variant,skills:q.skills??[]})},[q.id,q.model,q.skills,q.variant]),(0,X.useEffect)(()=>{Re||(W(!1),G(!1),K(null))},[Re]),(0,X.useEffect)(()=>{ue||(G(!1),K(null))},[ue]),(0,X.useEffect)(()=>{if(!Ne){Se.current=null,Te.current=!1;return}let e=Se.current!==q.id,t=!Te.current&&Et;(e&&Et||t)&&oe(!0),Se.current=q.id,Te.current=Et},[Et,Ne,q.id]),(0,X.useEffect)(()=>{if(!ht){we.current=null;return}we.current!==q.id&&H(!1),we.current=q.id},[ht,q.id]);let Qt=async(e,t,n)=>{Ae(!0);try{let r=await xt(q.id,q.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});A(r),g?.(r)}catch(e){me(q.model??``),ge(q.variant??``),ve(q.skills??[]),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{Ae(!1)}},$t=e=>{let t=(o.find(t=>t.id===e)??null)?.variants.includes(he)?he:``;me(e),ge(t),Qt(e,t,_e)},en=e=>{ge(e),Qt(pe,e,_e)},tn=e=>{ve(e),Qt(pe,he,e)},nn=async()=>{if(!(!E||re||kt||!St)){ie(!0);try{await E(St),ne(``)}finally{ie(!1)}}},rn=async()=>{if(!(re||Ie||!St||!wt)){ie(!0);try{let e=q.skills??[];if(je.model!==q.model||je.variant!==q.variant||je.skills.length!==e.length||je.skills.some((t,n)=>t!==e[n])){let e=await xt(q.id,q.project_id,{model:je.model,variant:je.variant,skills:je.skills});A(e),g?.(e)}let t=await Gt(q.id,q.project_id,St);A(t),g?.(t),ne(``)}finally{ie(!1)}}},an=(q.messages??[]).filter(BT).map(e=>e.role===`assistant`?{...e,displayTitle:ye}:e.kind===`follow_up`?{...e,displayTitle:`You`}:e),on=(q.messages??[]).filter(e=>(e.kind===`planning_follow_up`||e.kind===`planning_response`)&&BT(e)).map(e=>e.role===`assistant`?{...e,displayTitle:ye}:e.kind===`planning_follow_up`?{...e,displayTitle:`You`}:e),sn=It?(0,Z.jsx)(JW,{ariaLabel:`Planning chat`,title:`Planning Chat`,closeAriaLabel:`Close planning chat`,className:Rt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Rt,description:Et?(0,Z.jsxs)(`p`,{children:[q.planning_context?.open_questions.length,` open question`,q.planning_context?.open_questions.length===1?``:`s`]}):void 0,projectId:q.project_id,followUpTicketId:null,messages:on,internalLog:q.agent_log??null,streamingResponse:q.streaming_response??null,isRunning:q.agent_status===`running`,canShowComposer:wt,pendingAgentTitle:ye,composerTheme:Pe,followUpPlaceholder:`Ask the agent to refine this plan`,emptyStateText:null,autoFocusComposer:ae,followUpPrompt:te,isSendingFollowUp:re,followUpDisabledReason:Nt,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Ie||re||(e.preventDefault(),rn())},onFollowUpSubmit:()=>{rn()},onClose:()=>{oe(!1)}}):Lt?(0,Z.jsx)(JW,{ariaLabel:`Ticket chat`,title:`Ticket Chat`,closeAriaLabel:`Close ticket chat`,className:Rt?`absolute inset-x-4 bottom-4 top-[4.25rem] z-30 rounded-2xl border border-border bg-card shadow-2xl sm:inset-x-auto sm:right-5 sm:w-[min(34rem,calc(100%-2.5rem))] lg:right-6`:void 0,showTopSpacer:!Rt,projectId:q.project_id,followUpTicketId:q.id,messages:an,internalLog:q.agent_log??null,streamingResponse:q.streaming_response??null,isRunning:q.agent_status===`running`,canShowComposer:Tt,pendingAgentTitle:ye,composerTheme:Pe,autoFocusComposer:se,followUpPrompt:te,isSendingFollowUp:re,followUpDisabledReason:Mt,followUpComposerControls:Dt?(0,Z.jsx)(mP,{model:pe,variant:he,skills:_e,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Ot,onModelChange:$t,onVariantChange:en,onSkillsChange:tn,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:ke}):void 0,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||kt||re||(e.preventDefault(),nn())},onFollowUpSubmit:()=>{nn()},onClose:()=>{H(!1)}}):null;return(0,Z.jsx)(Ce,{onClose:Xt,overlayClassName:`bg-black/60`,panelClassName:Ht,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:[gt&&q.diff_stats&&(0,Z.jsx)(gu,{stats:q.diff_stats,showFiles:!0,className:`text-xs`}),gt&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Changes`,onClick:()=>{D?.(q.id),P(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(vu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Changes`})]}),vt&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Tests`,onClick:()=>{I(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(_u,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Tests`})]}),_t&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Open IDE`,onClick:()=>{x?.()},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Open IDE`})]}),yt&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Open terminal`,"aria-pressed":L,onClick:Wt,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Cu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Terminal`})]}),(mt||ht)&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Chat`,"aria-pressed":Ne?ae:se,onClick:()=>{if(Ne){oe(e=>!e);return}H(e=>!e)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(um,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Chat`})]}),e]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-modal-layout`,"data-terminal-mode":L?ee?`expanded`:`split`:`closed`,"data-side-chat-mode":Bt?`inline`:Rt?`overlay`:`closed`,className:Ut,children:[(0,Z.jsxs)(`div`,{className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[Re?(0,Z.jsxs)(Z.Fragment,{children:[Le&&q.agent_log&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-red-500/40 bg-destructive/15 px-3 py-2 text-xs text-red-300`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:`Planning failed: `}),q.agent_log]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(NT,{tool:q.tool,className:`text-[11px]`})}),(0,Z.jsx)(PT,{externalSource:q.external_source}),(0,Z.jsx)($N,{heading:`Edit Ticket`,bundles:r,initialTitle:q.title,initialDescription:q.description??``,initialModel:q.model??``,initialVariant:q.variant??``,initialSkills:q.skills??[],initialWorktreeBundleId:q.worktree_bundle_id,projectBranchState:c,projectId:q.project_id,stackConfigurationSections:zt&&!Vt,preferWideBundleSelector:zt&&Vt,agentSettingsPresentation:Vt?`popover`:`panel`,showModelSelector:a,availableModels:o,availableSkills:s,onAgentSettingsChange:Me,onCreateBundle:p,onDeleteBundle:m,onRefreshBundles:h,onCancel:Zt,onDirtyChange:W,titleInputId:`edit-title`,descriptionInputId:`edit-description`,bundleSelectId:`edit-ticket-bundle`,modelSelectId:`edit-model`,variantSelectId:`edit-variant`,skillsSelectId:`edit-skills`,showEmptyBundleOption:!1,planAction:{label:`Plan`,onClick:async({title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a})=>{let o=await xt(q.id,q.project_id,{title:e,description:t,model:n,variant:r,skills:i,worktree_bundle_id:a});g?.(o),f(),await Kt(q.id,q.project_id)}},primaryAction:{label:`Save`,variant:dt?`subtle`:`brand`,onClick:Ue},secondaryAction:dt?{label:`Save & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:We}:void 0,tertiaryAction:ft?{label:`Save & Build Chain`,variant:`brand`,showAdvanceIcon:!0,onClick:Ke}:void 0,beforeActionsContent:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(sP,{projectId:q.project_id,ticketId:q.id,memoryEnabled:l,refreshKey:ce,onSuggestionsChanged:O}),it.hasDependents&&(0,Z.jsx)(VT,{summary:at,detail:ot}),(0,Z.jsx)(VN,{blocks:nt,blockedBy:rt,resolveTicket:e=>tt.get(e),onDeleteDependency:_})]}),footerLeadingContent:ue?(0,Z.jsx)(J,{variant:`outline`,className:`border-amber-500/35 bg-amber-500/10 text-amber-200`,children:`Unsaved changes`}):null},`${q.id}:${q.updated_at}:${q.title}:${q.description}`)]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`sticky top-0 -my-1 bg-card py-1 pr-12 sm:pr-24`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:q.title}),(0,Z.jsx)(NT,{tool:q.tool,className:`text-[11px]`}),(At===`building`||At===`done`)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[q.is_running&&(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(fT,{status:At,showBuildGlyph:!0})]}),At!==null&&At!==`building`&&At!==`done`&&(0,Z.jsx)(fT,{status:At,showBuildGlyph:!0}),Et&&(0,Z.jsx)(J,{variant:`warning`,children:`Open questions`}),ct&&(0,Z.jsx)(J,{variant:`outline`,className:`border-border/80 bg-card/60 text-muted-foreground`,children:`Stale`})]})}),Fe?(0,Z.jsx)(`div`,{className:`mt-3 min-h-0 flex flex-1 flex-col`,children:(0,Z.jsx)(cP,{content:q.description,externalSource:q.external_source})}):(0,Z.jsx)(Z.Fragment,{children:Ne?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 flex flex-col${Ie?` mt-3`:``}`,children:(0,Z.jsx)(cP,{content:q.description,externalSource:q.external_source})}):(0,Z.jsx)(RN,{projectId:q.project_id,followUpTicketId:q.id,messages:an,internalLog:q.agent_log??null,streamingResponse:q.streaming_response??null,isRunning:q.agent_status===`running`,canShowComposer:Ct,pendingAgentTitle:ye,composerTheme:Pe,followUpComposerControls:Dt?(0,Z.jsx)(mP,{model:pe,variant:he,skills:_e,showModelSelector:!0,showSkillsSelector:!0,availableModels:o,availableSkills:s,selectedModel:Ot,onModelChange:$t,onVariantChange:en,onSkillsChange:tn,modelSelectId:`ticket-follow-up-model`,variantSelectId:`ticket-follow-up-variant`,skillsSelectId:`ticket-follow-up-skills`,disabled:ke}):void 0,followUpPrompt:te,isSendingFollowUp:re,followUpDisabledReason:Mt,onFollowUpPromptChange:ne,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||kt||re||(e.preventDefault(),nn())},onFollowUpSubmit:()=>{nn()}})}),Ie&&(0,Z.jsxs)(`section`,{"aria-label":`Ticket metadata`,className:`flex flex-wrap items-center gap-2`,children:[Pt.filter(e=>e.value.trim().length>0).map(e=>(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 sm:flex-none sm:max-w-full`,children:(0,Z.jsx)(IT,{label:e.label,value:e.value,variant:`compact`,className:`min-w-0`})},`${e.label}:${e.value}`)),(0,Z.jsx)(`div`,{className:`min-w-0 sm:flex-none`,children:(0,Z.jsx)(jT,{model:Ft.model,variant:Ft.variant,skills:Ft.skills})})]}),!Ie&&!Bt&&(0,Z.jsx)(LT,{ariaLabel:`Ticket metadata`,items:Pt}),(0,Z.jsx)(sP,{projectId:q.project_id,ticketId:q.id,memoryEnabled:l,refreshKey:ce,onSuggestionsChanged:O}),(0,Z.jsx)(VN,{blocks:nt,blockedBy:rt,resolveTicket:e=>tt.get(e),onDeleteDependency:_}),q.build_chain&&(0,Z.jsx)(VT,{summary:lt,detail:ut})]}),!Re&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),Xe&&(0,Z.jsxs)(U,{type:`button`,onClick:C,title:`Pause the build session. You can resume it later.`,"aria-label":Qe,variant:`warning`,children:[(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),Qe]}),q.build_chain&&w&&(0,Z.jsxs)(U,{type:`button`,onClick:()=>{w()},title:`Stop scheduling the remaining tickets in this build chain.`,"aria-label":$e,variant:`destructive`,children:[(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),$e]}),Ze&&(0,Z.jsxs)(U,{type:`button`,onClick:T,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),`Resume`]}),Je&&!Re&&!Fe&&q.is_running&&S&&(0,Z.jsxs)(U,{type:`button`,onClick:S,title:`Stop the currently running ticket.`,"aria-label":et,variant:`destructive`,children:[(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),et]}),Je&&Ye&&!Ie&&!Re&&!Fe&&!q.is_running&&b&&(0,Z.jsxs)(U,{type:`button`,disabled:u,title:u?d??`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{u||b()},variant:`secondary`,className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),`Run`]}),!Re&&q.state===`build`&&!st&&Ve&&v&&(0,Z.jsxs)(U,{type:`button`,disabled:!Be,onClick:()=>{Ge()},children:[Ve,(0,Z.jsx)(Ow,{className:`w-3.5 h-3.5`})]})]})]})]}),Bt&&sn,bt&&(0,Z.jsx)(`div`,{className:L?ee?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`mt-12 min-h-0 flex flex-1 flex-col overflow-hidden`:`hidden`,children:(0,Z.jsx)(LW,{createSession:()=>OT(q.id,q.project_id),isExpanded:ee,isVisible:L,ariaLabel:`Ticket terminal`,className:ee?`h-full w-full max-w-none rounded-2xl shadow-2xl`:void 0,onClose:qt,onToggleExpanded:()=>{z(e=>!e)}})})]}),Rt&&sn,N&&(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(qW,{onClose:()=>{P(!1),D?.(q.id)}}),children:(0,Z.jsx)(HW,{ticketId:q.id,projectId:q.project_id,title:q.title,onTicketUpdate:g,onRequestTicketRefresh:D,onSubmitReviewPrompt:E,canSubmitReviewPrompt:!kt,reviewSubmitDisabledReason:Mt,onClose:()=>{P(!1),D?.(q.id)}})}),F&&vt&&q.project_id&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(UW,{scope:`ticket`,ticketId:q.id,projectId:q.project_id,testCommands:i,onClose:()=>{I(!1)}})}),de&&(0,Z.jsx)(Od,{title:`Discard unsaved edits?`,description:`Any changes made will be lost.`,confirmLabel:`Discard`,cancelLabel:`Keep editing`,confirmVariant:`destructive`,onConfirm:Yt,onCancel:Jt})]})})},ZW=({ticket:e,allTickets:t=[],dependencies:n=[],bundles:r=[],projectMemoryEnabled:i=!1,overlay:a=!1,showModelSelector:o,availableModels:s,runDisabled:c=!1,runDisabledReason:l,dependencyTargetState:u=`idle`,onDependencyStart:d,onDeleteDependency:f,onRegisterNode:p,onRegisterOverlayNode:m,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onDelete:y,onUndo:b,onRetry:x,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:E,onOpenTests:D,onOpenChanges:O,onOpenIde:k,onStop:A,onStopBuild:j,onStopBuildChain:M,onResumeBuild:N,onFollowUp:P,onOpenBundleDetails:F,onOpenTicketDetails:I,preferBundleDetailsOnClick:L=!1,hideBundleScopedControls:R=!1,hideStatusBadge:ee=!1,onRequestTicketRefresh:z,undoInProgress:B=!1})=>{let[V,te]=(0,X.useState)(!1),[ne,re]=(0,X.useState)(!1),[ie,ae]=(0,X.useState)(!1),[oe,se]=(0,X.useState)(!1),[H,ce]=(0,X.useState)(null),[le,ue]=(0,X.useState)(!1),[W,de]=(0,X.useState)(!1),G=e.agent_status===`running`||B,fe=R,K=e.bundle?.branch??e.branch,q=e.has_worktree??(e.state===`plan`?!1:!!K),pe=!R&&q,me=oT(e,new Map(t.map(e=>[e.id,e])),n),he=jw(e.state),ge=e.state===`review`&&e.can_re_review===!0&&e.agent_status!==`running`,_e=Fw(e),ve=Iw(e),ye=Lw(e),be=!R&&ve!==`plan`&&e.diff_stats===void 0,xe=(ye||_e)&&!a,Se=he?he===`review`?`Review Bundle`:he.charAt(0).toUpperCase()+he.slice(1):ge?`Re-run review`:null,Ce=Hw(e,`trash`),we=e.undo,Te=!!b&&we?.stage!==null,Ee=ge||(he?Hw(e,he):!1),De=!_e&&!!S&&!!Se&&!me.hasOpenBlockers,Oe=!!C&&Bw(e),ke=_e&&typeof e.state==`string`?`Return to ${e.state.charAt(0).toUpperCase()}${e.state.slice(1)}`:null,Ae=!!w&&ke!==null&&e.state!==`plan`,je=!_e&&!!T&&me.canStartBuildChain,Me=Pw(e)&&e.agent_status===`running`&&!!e.session_id&&!!j,Ne=Pw(e)&&e.agent_status===`stopped`&&!!e.session_id&&!!N,Pe=pe&&!!O,Fe=pe&&!!e.project_id&&!!D,Ie=pe&&!!k,Le=!fe&&q&&!!K&&!e.is_running&&!!E,Re=!fe&&q&&!!K&&!!e.is_running&&!!A,ze=!!e.build_chain&&!!M,Be=!!y||Te||De||Oe||Ae||je||Me||Ne||Le||Re||Fe||Pe||Ie||ze,Ve=_e&&!e.is_running?`opacity-0 pointer-events-none transition-opacity group-hover/card:opacity-100 group-hover/card:pointer-events-auto group-focus-within/card:opacity-100 group-focus-within/card:pointer-events-auto`:``,He=async()=>{if(!(!E||c||le)){ue(!0);try{await E()}finally{ue(!1)}}},Ue=async()=>{if(!(!A||W)){de(!0);try{await A()}finally{de(!1)}}},We=!fe&&q&&K&&e.is_running&&A&&!B?(0,Z.jsx)(mT,{isRunning:!0,isStopPending:W,onStop:Ue}):!fe&&q&&K&&!e.is_running&&E?(0,Z.jsx)(mT,{isRunning:!1,isRunPending:le,runDisabled:c,runDisabledReason:l,onRun:He,className:Ve}):null;(0,X.useEffect)(()=>{if(!oe)return;let e=()=>{se(!1)};return window.addEventListener(`click`,e,{once:!0}),()=>{window.removeEventListener(`click`,e)}},[oe]);let Ge=()=>{if(a||oe||B){se(!1);return}if(L&&F){F();return}if(I){I();return}z?.(e.id),ae(!0)},{attributes:Ke,listeners:Y,setNodeRef:qe,isDragging:Je}=tw({id:e.id,disabled:a||G}),Ye=(0,X.useRef)(qe);(0,X.useEffect)(()=>{Ye.current=qe},[qe]);let Xe=(0,X.useCallback)(t=>{if(a){m?.(t);return}Ye.current(t),p?.(e.id,t)},[p,m,a,e.id]),Ze=u===`valid`?`border-emerald-400 shadow-[0_0_0_1px_rgba(52,211,153,0.35)]`:u===`invalid`?`border-red-400 shadow-[0_0_0_1px_rgba(248,113,113,0.35)]`:a?`border-violet-400`:me.isVisibleStartPoint?`border-violet-500/35 shadow-[0_0_0_1px_rgba(168,85,247,0.18)] hover:border-violet-400/55`:`border-border hover:border-primary/40`,Qe=a||B?`pointer-events-none cursor-grabbing shadow-2xl`:`cursor-pointer`,$e=Je?`opacity-30`:xe?`opacity-90`:`opacity-100`,et=xe?`bg-card/60`:`bg-secondary/30`,tt=xe?`p-3 text-foreground/70`:`p-3`,nt=xe?`truncate text-sm font-medium text-foreground/70`:`truncate text-sm font-medium text-foreground`,rt=xe?`text-[11px] text-foreground/55`:`text-[11px] text-muted-foreground`,it=xe?`whitespace-pre-line text-xs leading-relaxed text-foreground/55 wrap-anywhere`:`whitespace-pre-line text-xs leading-relaxed text-muted-foreground wrap-anywhere`,at=e.model??``,ot=!!e.bundle&&!R,st=!!e.bundle?.pull_request&&!R,ct=ot||st,lt=ct||at.length>0,ut=H===e.id,dt=(0,X.useMemo)(()=>{let t=e.description??``;return t?rN(t):{text:``,truncated:!1}},[e.description]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(kd,{"data-testid":`ticket-card-${e.id}`,className:`group/card shrink-0 select-none transition-colors ${Ze} ${Qe} ${$e} ${et} gap-0 rounded-xl border shadow-none`,ref:Xe,onClick:Ge,...Y,...Ke,children:[B&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(J,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Bf,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),(0,Z.jsxs)(Pd,{className:tt,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`div`,{className:nt,children:e.title})}),(0,Z.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-1`,children:[(0,Z.jsx)(`div`,{className:`mr-1`,children:We}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:d&&(0,Z.jsx)(cu,{content:`Draw dependency`,children:(0,Z.jsx)(U,{type:`button`,"aria-label":`Create dependency from ${e.title}`,variant:`ghost`,size:`icon-xs`,className:`cursor-crosshair opacity-0 transition-all group-hover/card:opacity-100`,onClick:e=>e.stopPropagation(),onPointerDown:t=>{t.stopPropagation(),se(!0),d(e.id,t)},children:(0,Z.jsx)(ef,{className:`h-4 w-4`})})})}),(0,Z.jsx)(`div`,{className:`flex size-7 items-start justify-center`,children:Be&&(0,Z.jsx)(wT,{title:e.title,canDelete:Ce,undo:we,undoInProgress:B,runDisabled:c,isRunPending:le,isStopPending:W,showTestsAction:Fe,showOpenChangesAction:Pe,showOpenIdeAction:Ie,showRunAction:Le,showStopRunAction:Re,showAdvanceAction:De,advanceLabel:Se,canAdvance:Ee,showParkAction:Oe,showReturnAction:Ae,returnLabel:ke,showBuildChainAction:je,showPauseBuildAction:Me,showResumeBuildAction:Ne,showStopBuildChainAction:ze,onDelete:y,onConfirmDelete:()=>te(!0),onConfirmUndo:()=>re(!0),onOpenTests:D,onOpenChanges:O,onOpenIde:k,onAdvance:S,onPark:C,onUnpark:w,onBuildChain:T,onRun:He,onStop:Ue,onStopBuild:j,onResumeBuild:N,onStopBuildChain:M})})]})]}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(DT,{ticket:e,hideStatusBadge:ee,hideBundleScopedControls:R,isStale:ye,runControl:null,onRetry:x,undoInProgress:B,isChainStart:me.isVisibleStartPoint})}),lt&&(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,children:[ct&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${rt}`,children:[ot&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:md(e.bundle)}),st&&e.bundle?.pull_request&&(0,Z.jsx)(Ew,{pullRequest:e.bundle.pull_request,asLink:!0,showNumber:!0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})]}),at.length>0&&(0,Z.jsx)(`div`,{className:rt,children:(0,Z.jsx)(`span`,{className:`truncate`,children:at})})]}),e.description&&(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(ET,{description:e.description,descriptionClass:it,isExpanded:ut,collapsedState:dt,useStaleLikeStyling:xe,onExpand:()=>ce(e.id),onCollapse:()=>ce(null)})}),!R&&(zw(ve,e.diff_stats)||be)&&(0,Z.jsx)(gu,{stats:e.diff_stats,isLoading:be,showFiles:!0,className:`mt-2`})]})]}),ie&&(0,Z.jsx)(XW,{ticket:e,allTickets:t,dependencies:n,bundles:r,projectMemoryEnabled:i,onClose:()=>{ae(!1),z?.(e.id)},showModelSelector:o,availableModels:s,runDisabled:c,runDisabledReason:l,onDeleteDependency:f,onCreateBundle:h,onDeleteBundle:g,onRefreshBundles:_,onUpdate:v,onAdvance:S,onBuildChain:T,onRun:E,onOpenIde:k,onStop:A,onStopBuild:j,onStopBuildChain:M,onResumeBuild:N,onFollowUp:P}),V&&(0,Z.jsx)(TT,{title:e.title,bundleName:e.bundle?md(e.bundle):void 0,onConfirm:()=>{te(!1),y?.()},onCancel:()=>te(!1)}),ne&&we?.stage&&(0,Z.jsx)(pT,{title:e.title,stage:we.stage,onConfirm:()=>{re(!1),b?.()},onCancel:()=>re(!1)})]})},QW=({index:e})=>(0,Z.jsx)(kd,{"aria-hidden":`true`,"data-testid":`ticket-card-skeleton`,className:`group shrink-0 select-none gap-0 rounded-xl border border-border/70 bg-secondary/20 shadow-none`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(hu,{className:`h-3.5 w-3/5 rounded-full`}),(0,Z.jsx)(hu,{className:`h-5 w-11 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(hu,{className:`h-3 w-full rounded-full`}),(0,Z.jsx)(hu,{className:`h-3 w-11/12 rounded-full`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(hu,{className:`h-4 w-14 rounded-full`}),(0,Z.jsx)(hu,{className:`h-4 w-10 rounded-full`})]}),(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`Loading card `,e+1]})]})}),$W=({id:e,title:t,items:n,ticketCount:r,pinnedContent:i=null,allTickets:a,dependencies:o,showModelSelector:s,availableModels:c,activeRunContextKey:l,isProjectRootRunActive:u=!1,isBundleRunDisabled:d,bundles:f,getDependencyTargetState:p,onDependencyStart:m,onDeleteDependency:h,onRegisterTicketNode:g,onAddTicket:_,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdateTicket:x,onDeleteTicket:S,onUndoTicket:C,undoingColumn:w=null,onRetryTicket:T,onAdvanceTicket:E,onParkTicket:D,onUnparkTicket:O,onBuildChainTicket:k,onRunTicket:A,onOpenTestsTicket:j,canOpenChangesForTicket:M,onOpenChangesTicket:N,canOpenIdeForTicket:P,onOpenIdeTicket:F,onStopTicket:I,onStopBuildTicket:L,onStopBuildChainTicket:R,onResumeBuildTicket:ee,onFollowUpTicket:z,onBuildBundle:B,onReviewBundle:V,onUndoBundleReview:te,onRunBundle:ne,onStopBundle:re,onParkBundleWrapper:ie,onUnparkBundleWrapper:ae,bundleActionState:oe,onOpenTicketDetails:se,onOpenBundleDetails:H,onOpenBundleChanges:ce,onOpenBundleTests:le,onOpenBundleIde:ue,onDeleteBundleWrapper:W,onRequestBundleRefresh:de,onRequestTicketRefresh:G,className:fe=``,headerAccessory:K=null,loadingSkeletonCount:q=0})=>{let{setNodeRef:pe,isOver:me}=aw({id:e}),he=(0,X.useRef)(null),[ge,_e]=(0,X.useState)(!1),[ve,ye]=(0,X.useState)(!1),be=e=>e.has_worktree??!!(e.bundle?.branch??e.branch),xe=me?`border-primary`:`border-border`,Se=w===e&&(e===`build`||e===`review`),Ce=(0,X.useCallback)(()=>{let e=he.current;if(!e){_e(!1),ye(!1);return}if(!(e.scrollHeight>e.clientHeight+1)){_e(!1),ye(!1);return}let t=e.scrollHeight-e.clientHeight;_e(e.scrollTop>1),ye(e.scrollTop<t-1)},[]);(0,X.useEffect)(()=>{let e=window.requestAnimationFrame(Ce),t=he.current;if(!t){window.cancelAnimationFrame(e);return}return t.addEventListener(`scroll`,Ce),window.addEventListener(`resize`,Ce),()=>{window.cancelAnimationFrame(e),t.removeEventListener(`scroll`,Ce),window.removeEventListener(`resize`,Ce)}},[n.length,q,Ce]);let we=(0,X.useCallback)((t,n)=>{let r=t.worktree_bundle_id!==null,i=n?.nestedInBundle??!1,d=n?.hideStatusBadge??!1,_=r&&e!==`plan`,w=tT(t),B=u||l!==null&&l!==Nw(t)?`Stop the currently running ticket before starting another run.`:w;return(0,Z.jsx)(ZW,{ticket:t,allTickets:a,dependencies:o,bundles:f,showModelSelector:s,availableModels:c,runDisabled:B!==void 0,runDisabledReason:B,dependencyTargetState:p?.(t.id)??`idle`,onDependencyStart:m,onDeleteDependency:h,onRegisterNode:g,onCreateBundle:v,onDeleteBundle:y,onRefreshBundles:b,onUpdate:x,onDelete:()=>S(t.id),onUndo:C?()=>C(t.id):void 0,undoInProgress:!1,onRetry:()=>T(t.id),onAdvance:E?()=>E(t.id):void 0,onPark:D?()=>D(t.id):void 0,onUnpark:O?()=>O(t.id):void 0,onBuildChain:k?()=>k(t.id):void 0,onRun:be(t)&&t.has_run_config&&A?()=>A(t.id):void 0,onOpenTests:j&&t.project_id&&be(t)?()=>j(t.id):void 0,onOpenChanges:M?.(t)&&N?()=>N(t.id):void 0,onOpenIde:P?.(t)&&F?()=>F(t.id):void 0,onStop:I?()=>I(t.id):void 0,onStopBuild:L?()=>L(t.id):void 0,onStopBuildChain:R?()=>R(t.id):void 0,onResumeBuild:ee?()=>ee(t.id):void 0,onFollowUp:z?e=>z(t.id,e):void 0,onOpenBundleDetails:_&&H?()=>H(t.worktree_bundle_id,e):void 0,onOpenTicketDetails:()=>se(t),preferBundleDetailsOnClick:_,hideBundleScopedControls:i,hideStatusBadge:d,onRequestTicketRefresh:G})},[l,a,c,f,M,P,o,p,e,u,E,k,v,y,h,S,m,z,H,N,F,j,se,D,b,g,G,ee,T,A,R,L,I,C,O,x,s]);return(0,Z.jsxs)(kd,{className:`flex min-h-0 min-w-[280px] flex-1 flex-col rounded-2xl bg-card/80 p-4 transition-colors ${fe} ${xe}`,ref:pe,children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex min-h-7 items-center justify-between`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:t}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K,(0,Z.jsx)(J,{variant:`outline`,children:r}),_&&(0,Z.jsxs)(U,{type:`button`,onClick:_,size:`xs`,variant:`success`,className:`gap-2 shadow-[0_8px_20px_rgba(16,185,129,0.22)]`,children:[(0,Z.jsx)(`span`,{children:`+ New ticket`}),(0,Z.jsx)(J,{"aria-hidden":`true`,variant:`hotkeyDark`,className:`rounded-md px-1.5 py-0.5 text-[10px] leading-none`,children:`N`})]})]})]}),(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{ref:he,className:`flex min-h-0 h-full flex-col gap-2.5 overflow-y-auto pr-1`,children:[i,n.map(e=>{if(e.kind===`bundle`)return(0,Z.jsx)(ST,{group:e.group,renderTicket:t=>we(t,{nestedInBundle:!0,hideStatusBadge:e.group.column===`review`}),runDisabled:d?.(e.group.bundle.id)??!1,onBuildBundle:B,onReviewBundle:V,onUndoBundleReview:te,onRunBundle:ne,onStopBundle:re,onParkBundleWrapper:ie,onUnparkBundleWrapper:ae,bundleActionState:oe,onStopBuildTicket:L,onResumeBuildTicket:ee,onOpenBundleDetails:H,onOpenBundleChanges:ce,onOpenBundleTests:le,onOpenBundleIde:ue,onDeleteBundleWrapper:W,onRequestBundleRefresh:de},e.group.id);let t=e.ticket;return(0,Z.jsx)(X.Fragment,{children:we(t)},t.id)}),Array.from({length:q},(t,n)=>(0,Z.jsx)(QW,{index:n},`loading-card-${e}-${n}`))]}),Se&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-undo-overlay-${e}`,className:`absolute inset-0 z-20 flex items-center justify-center rounded-xl bg-background/85 backdrop-blur-[1px]`,children:(0,Z.jsxs)(J,{variant:`warning`,className:`gap-1.5`,children:[(0,Z.jsx)(Bf,{className:`h-3.5 w-3.5 animate-spin`}),`Undo in progress...`]})}),ge&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-top-fade`,className:`pointer-events-none absolute inset-x-0 top-0 h-6 rounded-t-xl bg-gradient-to-b from-card to-transparent`}),ve&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`column-bottom-fade`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 rounded-b-xl bg-gradient-to-t from-card to-transparent`})]})]})},eG=({ticketCount:e,isDeleting:t,onCancel:n,onConfirm:r})=>{let i=e===1?`1 done ticket`:`${e} done tickets`;return(0,Z.jsxs)(Ce,{onClose:t?()=>{}:n,overlayClassName:`bg-black/60`,panelClassName:`max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Empty Done`}),(0,Z.jsxs)(`p`,{className:`mb-2 text-sm text-foreground`,children:[`Delete `,i,` from the Done column?`]}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`Standalone ticket worktrees will be removed when applicable. Deleting the last parked ticket in a bundle also removes that shared bundle worktree.`}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,variant:`ghost`,disabled:t,onClick:n,children:`Cancel`}),(0,Z.jsx)(U,{type:`button`,variant:`destructive`,disabled:t,onClick:r,children:t?`Deleting...`:`Delete all`})]})]})},tG=({projectId:e,followUpTicketId:t=null,messages:n,internalLog:r,thinkingTicketId:i=null,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c=!1,canShowComposer:l,composerControls:u,composerTheme:d=`default`,layoutKey:f,scrollLayoutKey:p,followUpPrompt:m,followUpPlaceholder:h=`Follow up on this bundle`,isSendingFollowUp:g,followUpDisabledReason:_,onFollowUpPromptChange:v,onFollowUpKeyDown:y,onFollowUpSubmit:b})=>(0,Z.jsx)(LN,{projectId:e,followUpTicketId:t,messages:n,internalLog:r,thinkingTicketId:i,pendingAgentTitle:a,streamingResponse:o,isRunning:s,isLoading:c,autoScrollBehavior:`sticky`,canShowComposer:l,composerInlineControls:u,composerTheme:d,composerSize:`compact-on-laptop`,layoutKey:f,scrollLayoutKey:p,followUpPrompt:m,followUpPlaceholder:h,emptyStateText:`No bundle messages yet.`,autoFocusComposer:!0,isSendingFollowUp:g,followUpDisabledReason:_,onFollowUpPromptChange:v,onFollowUpKeyDown:y,onFollowUpSubmit:b}),nG=({bundleId:e,actionState:t,runDisabled:n,canBuild:r,canStopBuild:i,runningBuildTicketId:a,canResumeBuild:o,resumableBuildTicketId:s,isRunning:c,canRun:l,canReview:u,reviewActionLabel:d=`Review Bundle`,onClose:f,onBuildBundle:p,onStopBuildTicket:m,onResumeBuildTicket:h,onRunBundle:g,onStopBundle:_,onReviewBundle:v})=>{let y=t.review||t.followUp;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,onClick:f,variant:`ghost`,children:`Close`}),c?(0,Z.jsxs)(U,{type:`button`,variant:`destructive`,disabled:t.stop,onClick:()=>void _(e),children:[(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-400 animate-pulse flex-shrink-0`}),(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),t.stop?`Stopping...`:`Stop Run`]}):l?(0,Z.jsxs)(U,{type:`button`,variant:`secondary`,disabled:t.run||n,title:n?`Stop the currently running ticket before starting another run.`:void 0,onClick:()=>{n||g(e)},className:`bg-sky-700 text-sky-100 hover:bg-sky-600 hover:text-white disabled:bg-slate-700 disabled:text-slate-400`,children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),t.run?`Starting Run...`:`Run`]}):null,r&&(0,Z.jsxs)(U,{type:`button`,disabled:t.build,onClick:()=>void p(e),children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),t.build?`Building Bundle...`:`Build Bundle`]}),i&&a&&(0,Z.jsxs)(U,{type:`button`,variant:`warning`,disabled:t.stopBuild,title:`Pause the build session. You can resume it later.`,"aria-label":`Pause Build`,onClick:()=>void m(a),children:[(0,Z.jsx)(Su,{className:`w-3.5 h-3.5`}),t.stopBuild?`Pausing...`:`Pause Build`]}),o&&s&&(0,Z.jsxs)(U,{type:`button`,variant:`warning`,className:`bg-amber-700 text-amber-50 hover:bg-amber-600 hover:text-white`,disabled:t.resumeBuild,onClick:()=>void h(s),children:[(0,Z.jsx)(bu,{className:`w-3.5 h-3.5`}),t.resumeBuild?`Resuming...`:`Resume`]}),u&&(0,Z.jsxs)(U,{type:`button`,disabled:y,onClick:()=>void v(e),children:[(0,Z.jsx)(Ow,{className:`w-3.5 h-3.5`}),y?`Reviewing Bundle...`:d]})]})]})},rG=e=>e.agent_status===`running`?`bg-amber-400`:e.agent_status===`error`?`bg-rose-400`:e.agent_status===`stopped`?`bg-amber-300`:e.agent_status===`done`?`bg-emerald-400`:`bg-border`,iG=({tickets:e,onOpenTicketDetails:t,highlightedTicketId:n=null,pendingMemorySuggestionCounts:r={}})=>{let i=e.filter(e=>e.agent_status===`running`).length,a=e.filter(e=>e.agent_status===`error`).length;return(0,Z.jsxs)(`section`,{"aria-label":`Bundle tickets`,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Tickets`}),(0,Z.jsx)(J,{variant:`outline`,children:e.length}),i>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[i,` active`]}),a>0&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-rose-300`,children:[a,` error`,a===1?``:`s`]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-col gap-1 overflow-y-auto pr-1`,children:e.map(e=>{let i=r[e.id]??0,a=e.id===n;return(0,Z.jsxs)(`button`,{type:`button`,"data-follow-up-target":a?`true`:`false`,"aria-current":a?`true`:void 0,className:W(`flex cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2.5 text-left text-foreground transition-colors`,a?`border border-sky-500/35 bg-sky-500/10 shadow-[inset_0_0_0_1px_rgba(56,189,248,0.12)] hover:bg-sky-500/15`:`bg-background/20 hover:bg-accent/45`),onClick:()=>t(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:W(`h-2 w-2 shrink-0 rounded-full`,rG(e))}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.title}),(0,Z.jsx)(NT,{tool:e.tool,className:`shrink-0 text-[10px]`})]}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e.state})]}),a&&(0,Z.jsx)(J,{variant:`info`,className:`shrink-0 px-1.5 text-[10px]`,"aria-label":`Follow-up target`,children:`Follow-up`}),i>0&&(0,Z.jsx)(J,{variant:`warning`,className:`h-5 min-w-5 shrink-0 justify-center rounded-full px-1.5 text-[10px]`,"aria-label":`${i} pending memory suggestion${i===1?``:`s`}`,title:`${i} pending memory suggestion${i===1?``:`s`}`,children:i})]},e.id)})})]})},aG=(0,X.lazy)(()=>VW(()=>Promise.resolve().then(()=>Xq).then(e=>({default:e.TicketChangesModal})),void 0)),oG=e=>e.kind===`description`?e.bundle_visible_at??e.created_at:e.created_at,sG=e=>e.replace(/\r\n/g,`
134
134
  `).trim(),cG=(e,t)=>e.ticket_id===t.ticket_id&&e.role===`user`&&t.role===`user`&&e.kind===`follow_up`&&t.kind===`follow_up`&&sG(e.content)===sG(t.content),lG=(e,t)=>{if(t.length===0)return e;let n=new Set,r=new Set,i=new Map,a=[];for(let a of t){let t=[...e].reverse().find(e=>!r.has(e.id)&&!n.has(a.id)&&cG(a,e));t&&(r.add(t.id),n.add(a.id),i.set(t.id,a))}for(let t of e){let e=i.get(t.id);if(e){a.push(e);continue}a.push(t)}for(let e of t)n.has(e.id)||a.push(e);return a},uG=(e,t)=>e?t.get(e)??e:null,dG=(e,t=[])=>{let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>{let r=n.get(e.id)??e.bundle_execution_position??2**53-1,i=n.get(t.id)??t.bundle_execution_position??2**53-1;if(r!==i)return r-i;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let a=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return a===0?e.id.localeCompare(t.id):a})},fG=(e,t)=>uG(e,t)??`Agent`,pG=(e,t)=>{let n={};for(let r of e){let e=uG(r.model,t);e&&(n[r.id]=e)}return n},mG=e=>e.kind===`planning_follow_up`||e.kind===`planning_response`?0:e.kind===`description`?1:2,hG=(e,t,n,r=[])=>{let i=dG(e,r),a=new Map(i.map((e,t)=>[e.id,t]));return i.flatMap(e=>{let r=e.messages??[],i=e.agent_status!==null||e.session_id!==null||r.some(e=>e.kind!==`description`&&BT(e)),o=r.filter(e=>BT(e)&&(i||e.kind!==`description`)),s=n[e.id]??fG(e.model,t);return o.map(t=>t.role===`assistant`?{...t,displayTitle:s,ticketOrder:a.get(e.id)??2**53-1}:t.kind===`follow_up`?{...t,displayTitle:`You`,ticketOrder:a.get(e.id)??2**53-1}:{...t,displayTitle:e.title,ticketOrder:a.get(e.id)??2**53-1})}).sort((e,t)=>{if(e.ticket_id===t.ticket_id){let n=mG(e)-mG(t);if(n!==0)return n}let n=oG(e),r=oG(t);if(n!==r)return n.localeCompare(r);if(e.ticket_id!==t.ticket_id&&e.ticketOrder!==t.ticketOrder)return e.ticketOrder-t.ticketOrder;let i=mG(e)-mG(t);return i===0?e.id.localeCompare(t.id):i}).map(e=>{let{ticketOrder:t,...n}=e;return n})},gG=e=>cd(e.tickets,{targetTicketId:e.target_ticket_id,reviewOwnerTicketId:e.review_owner_ticket_id,latestSessionTicketId:e.latest_session_ticket_id}),_G=e=>e?e.startsWith(`ses_`)?`opencode --session ${e}`:`claude --resume ${e}`:null,vG=(e,t)=>e.latest_session_id?_G(e.latest_session_id):_G(t?.session_id??null),yG=(e,t)=>t?.diff_stats?t.diff_stats:e.find(e=>e.diff_stats)?.diff_stats??null,bG=({details:e,activeColumn:t=null,isLoading:n=!1,actionState:r,canOpenIde:i,projectMemoryEnabled:a=!1,memorySuggestionsRefreshKey:o=0,runDisabled:s=!1,showModelSelector:c=!1,availableModels:l=[],availableSkills:u=[],onClose:d,onOpenTicketDetails:f,onOpenIde:p,onOpenTests:m,onRefresh:h,onUpdateTicket:g,onBuildBundle:_,onStopBuildTicket:v,onResumeBuildTicket:y,onReviewBundle:b,onRunBundle:x,onStopBundle:S,onFollowUpBundle:C})=>{let[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(``),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(``),[I,L]=(0,X.useState)(``),[R,ee]=(0,X.useState)([]),[z,B]=(0,X.useState)(null),[V,te]=(0,X.useState)(!1),[ne,re]=(0,X.useState)(!1),[ie,ae]=(0,X.useState)({}),[oe,se]=(0,X.useState)([]),H=(0,X.useMemo)(()=>gG(e),[e]),ce=(0,X.useMemo)(()=>new Map(l.map(e=>[e.id,e.label])),[l]),[le,ue]=(0,X.useState)(()=>pG(e.tickets,ce)),W=(0,X.useMemo)(()=>dG(e.tickets,e.execution_order_ticket_ids),[e.execution_order_ticket_ids,e.tickets]),de=t??H?.state??null,G=de===`plan`,fe=(0,X.useMemo)(()=>lG(hG(e.tickets,ce,le,e.execution_order_ticket_ids),oe),[ce,e.execution_order_ticket_ids,e.tickets,oe,le]),K=(0,X.useMemo)(()=>_T(e.tickets,de),[de,e.tickets]),pe=(0,X.useMemo)(()=>(0,Z.jsx)(fT,{status:K}),[K]),me=(0,X.useMemo)(()=>vG(e,H),[e,H]),he=(0,X.useMemo)(()=>yG(e.tickets,H),[e.tickets,H]),ge=!G&&!!(H?.project_id&&H&&sd(H)),_e=!!(m&&H?.project_id&&H&&sd(H)),ye=!G&&!!(H?.project_id&&H),be=ye&&!O,xe=ye&&M&&H!==null,Se=de===`plan`&&e.tickets.some(e=>e.state===`plan`),we=W.find(e=>Pw(e)&&e.agent_status===`running`&&!!e.session_id)??null,Te=W.find(e=>Pw(e)&&e.agent_status===`stopped`&&!!e.session_id)??null,Ee=we!==null,De=!Ee&&Te!==null,Oe=de===`build`&&e.tickets.some(e=>e.state===`build`)&&e.tickets.filter(e=>e.state===`build`).every(e=>e.agent_status===`done`),ke=r.review||r.followUp,Ae=de===`review`&&e.can_re_review===!0&&!e.tickets.some(e=>e.agent_status===`running`)&&!ke,je=Oe||Ae,Me=Ae?`Re-run review`:`Review Bundle`,Ne=e.tickets.some(e=>e.has_run_config&&eT(e)),Pe=e.tickets.some(e=>e.is_running),Fe=e.tickets.find(e=>e.agent_status===`running`)??H,Ie=Fe?.streaming_response??null,Le=Fe?.agent_log??null,Re=Fe?.id??H?.id??null,ze=l.find(e=>e.id===P)??null,Be=H?.project_id??e.tickets.find(e=>e.project_id)?.project_id??null,Ve=(0,X.useMemo)(()=>e.tickets.map(e=>e.id).sort().join(`|`),[e.tickets]),He=(0,X.useMemo)(()=>new Set(Ve.length>0?Ve.split(`|`):[]),[Ve]),Ue=(0,X.useMemo)(()=>e.tickets.map(e=>`${e.id}:${e.build_completed_at??``}`).sort().join(`|`),[e.tickets]),We=Fe??H??e.tickets[0]??null,Ge=We??H,Ke=Ge?.id??null,Y=Fe?le[Fe.id]??fG(Fe.model,ce):`Agent`,qe=Fe?.agent_status===`running`?Y:null,Je=!G&&!!(H&&sd(H)),Ye=Mw(t??H?.state??null),Xe=Je&&c&&Ge?.tool===`opencode`,Ze=r.followUp||ne,Qe=e.tickets.some(e=>e.agent_status===`running`),$e=Qe?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,et=We?`Follow up on: ${We.title}`:`Follow up on this bundle`,tt=[{label:e.bundle.kind===`project_root`?`Project root branch`:`Worktree`,value:e.bundle.branch},{label:`Session`,value:me??``}],nt=!G,rt=O&&!A,it=e.bundle.id,at=O?A?`expanded`:`split`:`closed`,ot=rt?`flex h-[92vh] w-[98vw] max-w-[110rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`:`flex h-[92vh] w-[96vw] max-w-[100rem] flex-col gap-3 overflow-visible rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,st=rt?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)_minmax(30rem,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)_minmax(30rem,1fr)]`:nt?`grid min-h-0 flex-1 grid-cols-[16rem_minmax(0,1fr)] gap-3 2xl:grid-cols-[18rem_minmax(0,1fr)]`:`flex min-h-0 flex-1 flex-col`,ct=A?`fixed inset-0 z-[70] flex items-center justify-center bg-black/30 p-[5vh]`:`fixed inset-4 z-[70] flex items-stretch justify-end bg-black/30 backdrop-blur-sm 2xl:hidden sm:inset-6 lg:inset-8`;(0,X.useEffect)(()=>{if(!a||G||!Be||Ve.length===0){ae({});return}let e=new AbortController;return q(Be,null,e.signal).then(t=>{e.signal.aborted||ae(t.suggestions.reduce((e,t)=>(!t.ticket_id||!He.has(t.ticket_id)||(e[t.ticket_id]=(e[t.ticket_id]??0)+1),e),{}))}).catch(t=>{if(!e.signal.aborted){if(t instanceof ve&&(t.status===404||t.status===409)){ae({});return}ae({})}}),()=>{e.abort()}},[Ue,Be,He,Ve,G,o,a]),(0,X.useEffect)(()=>{ue(t=>{let n={...t},r=!1,i=new Set(e.tickets.map(e=>e.id));for(let t of e.tickets){let e=uG(t.model,ce);!e||n[t.id]===e||(n[t.id]=e,r=!0)}for(let e of Object.keys(n))i.has(e)||(delete n[e],r=!0);return r?n:t})},[ce,e.tickets]),(0,X.useEffect)(()=>{if(Ke!==null&&z?.ticketId===Ke)if((Ge?.model??``)===z.model&&(Ge?.variant??``)===z.variant&&(Ge?.skills.length??0)===z.skills.length&&(Ge?.skills??[]).every((e,t)=>e===z.skills[t]))B(null);else return;F(Ge?.model??``),L(Ge?.variant??``),ee(Ge?.skills??[])},[Ge?.model,Ge?.skills,Ge?.variant,Ke,z]);let lt=async(e,t,n)=>{if(Ge){B({ticketId:Ge.id,model:e,variant:t,skills:n}),te(!0);try{let r=await xt(Ge.id,Ge.project_id,{model:e.trim()||null,variant:t.trim()||null,skills:n});g?.(r)}catch(e){B(null),F(Ge.model??``),L(Ge.variant??``),ee(Ge.skills),Q.error(e instanceof Error?e.message:`Unable to update the ticket right now.`,{id:`ticket-save-error`})}finally{te(!1)}}},ut=async()=>{let t=E.trim();if(!t||Ze||Qe)return;let n=We?{id:`optimistic-follow-up-${Date.now()}`,ticket_id:We.id,role:`user`,kind:`follow_up`,content:t,created_at:new Date().toISOString(),displayTitle:`You`}:null;re(!0),D(``),n&&se(e=>[...e,n]);try{await C(e.bundle.id,t)}catch{n&&se(e=>e.filter(e=>e.id!==n.id)),D(t)}finally{re(!1)}},dt=Xe?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:Xe&&(0,Z.jsx)(mP,{model:P,variant:I,skills:R,showModelSelector:!0,showSkillsSelector:!0,availableModels:l,availableSkills:u,selectedModel:ze,onModelChange:e=>{let t=(l.find(t=>t.id===e)??null)?.variants.includes(I)?I:``;F(e),L(t),lt(e,t,R)},onVariantChange:e=>{L(e),lt(P,e,R)},onSkillsChange:e=>{ee(e),lt(P,I,e)},modelSelectId:`bundle-follow-up-model`,variantSelectId:`bundle-follow-up-variant`,skillsSelectId:`bundle-follow-up-skills`,disabled:V})}):void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ce,{onClose:d,overlayClassName:`bg-black/60 !z-40`,panelClassName:ot,renderContent:({closeButton:t})=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`div`,{"data-testid":`bundle-modal-layout`,"data-terminal-mode":at,className:`min-h-0 flex flex-1 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:md(e.bundle)}),pe,e.bundle.pull_request&&(0,Z.jsx)(Ew,{pullRequest:e.bundle.pull_request,asLink:!0}),(0,Z.jsxs)(J,{variant:`outline`,children:[e.tickets.length,` tickets`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!G&&he&&(0,Z.jsx)(gu,{stats:he,showFiles:!0,className:`text-xs`}),ge&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Changes`,onClick:()=>T(!0),variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(vu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Changes`})]}),_e&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Tests`,onClick:m,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(_u,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Tests`})]}),!G&&i&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Open IDE`,onClick:p,variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(yu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Open IDE`})]}),be&&(0,Z.jsxs)(U,{type:`button`,"aria-label":`Open terminal`,onClick:()=>{N(!0),k(!0)},variant:`outline`,className:`gap-2`,children:[(0,Z.jsx)(Cu,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`Terminal`})]}),t]})]}),(0,Z.jsxs)(`div`,{className:st,children:[nt&&(0,Z.jsxs)(`aside`,{"data-testid":`bundle-modal-sidebar`,className:`flex min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(LT,{ariaLabel:`Ticket metadata`,items:tt,className:`flex-col items-stretch gap-3`}),(0,Z.jsx)(iG,{tickets:e.tickets,onOpenTicketDetails:f,highlightedTicketId:We?.id??null,pendingMemorySuggestionCounts:ie})]}),(0,Z.jsxs)(`div`,{"data-testid":`bundle-modal-main`,className:`min-h-0 flex flex-1 flex-col gap-3 overflow-hidden`,children:[!G&&(0,Z.jsx)(tG,{projectId:H?.project_id??null,followUpTicketId:e.target_ticket_id,messages:fe,internalLog:Le,thinkingTicketId:Re,pendingAgentTitle:qe,streamingResponse:Ie,isRunning:Fe?.agent_status===`running`,isLoading:n,canShowComposer:Je,layoutKey:it,scrollLayoutKey:at,composerControls:dt,composerTheme:Ye,followUpPrompt:E,followUpPlaceholder:et,isSendingFollowUp:Ze,followUpDisabledReason:$e,onFollowUpPromptChange:D,onFollowUpKeyDown:e=>{e.key!==`Enter`||e.shiftKey||Qe||Ze||(e.preventDefault(),ut())},onFollowUpSubmit:()=>{ut()}}),G&&(0,Z.jsx)(iG,{tickets:e.tickets,onOpenTicketDetails:f,pendingMemorySuggestionCounts:ie}),(0,Z.jsx)(nG,{bundleId:e.bundle.id,actionState:r,runDisabled:s,canBuild:Se,canStopBuild:Ee,runningBuildTicketId:we?.id??null,canResumeBuild:De,resumableBuildTicketId:Te?.id??null,isRunning:Pe,canRun:Ne,canReview:je,reviewActionLabel:Me,onClose:d,onBuildBundle:_,onStopBuildTicket:v,onResumeBuildTicket:y,onRunBundle:x,onStopBundle:S,onReviewBundle:b})]}),xe&&H&&(0,Z.jsx)(`div`,{className:O?rt?`min-h-0 flex flex-col overflow-hidden`:ct:`hidden`,children:(0,Z.jsx)(LW,{createSession:()=>OT(H.id,H.project_id),isExpanded:A,isVisible:O,ariaLabel:`Bundle terminal`,title:`Terminal`,className:rt||A?`h-full w-full max-w-none rounded-2xl shadow-2xl`:`h-full w-full max-w-5xl rounded-2xl shadow-2xl`,onClose:()=>{k(!1),j(!1),N(!1),h(e.bundle.id)},onToggleExpanded:()=>{j(e=>!e)}})})]})]})})}),w&&H&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(aG,{ticketId:H.id,projectId:H.project_id,reviewCommentsBundleId:e.bundle.id,title:md(e.bundle),onSubmitReviewPrompt:t=>C(e.bundle.id,t),canSubmitReviewPrompt:!Qe,reviewSubmitDisabledReason:$e,canAddReviewComments:!Qe,canModifyChanges:!Qe,changesDisabledReason:$e,onClose:()=>{T(!1),h(e.bundle.id)}})})]})},xG=_(`group/toggle inline-flex cursor-pointer items-center justify-center gap-1 rounded-3xl text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-9 min-w-9 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5`,sm:`h-8 min-w-8 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,lg:`h-10 min-w-10 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3`}},defaultVariants:{variant:`default`,size:`default`}}),SG=X.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function CG({className:e,variant:t,size:n,spacing:r=0,orientation:i=`horizontal`,children:a,...o}){return(0,Z.jsx)(es,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:W(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-3xl data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,Z.jsx)(SG.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function wG({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=X.useContext(SG);return(0,Z.jsx)(ts,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:W(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-3 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-2.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-2.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-3xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-3xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-3xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-3xl data-[state=on]:bg-muted group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,xG({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}var TG=`border-sky-400/30 bg-sky-400/10 text-sky-100`,EG=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,DG=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,OG=e=>e.subject_type===`file`,kG=({reviewComments:e,reviewFindings:t=[],githubComments:n=[],pendingFixCount:r,triggerMode:i=`full`,canSendReview:a,isSubmittingReview:o,reviewSubmitDisabledReason:s,onClearPendingFixes:c,onSubmitReview:l})=>(0,Z.jsxs)(Bl,{children:[(0,Z.jsx)(Vl,{asChild:!0,children:(0,Z.jsxs)(U,{type:`button`,variant:`default`,size:`sm`,className:i===`compact`?`gap-1.5 px-2.5`:`gap-2`,"aria-label":`Pending fixes`,disabled:r===0,children:[i===`compact`?(0,Z.jsx)(um,{className:`h-4 w-4`}):(0,Z.jsx)(`span`,{children:`Pending fixes`}),(0,Z.jsx)(J,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:r}),(0,Z.jsx)(Te,{className:`h-4 w-4`})]})}),(0,Z.jsxs)(Hl,{align:`end`,className:`z-[90] w-[30rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsxs)(Ul,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(Wl,{children:`Pending fixes`}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Review selected comments and findings before sending them back to the agent.`})]}),(0,Z.jsx)(J,{variant:`outline`,children:r})]}),r===0?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:`No pending fixes selected yet.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`max-h-80 space-y-2 overflow-auto pr-1`,children:[e.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 px-3 py-3 shadow-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(um,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-sky-200`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Manual comment`}),(0,Z.jsx)(J,{variant:`outline`,className:TG,children:`Manual`})]}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-sky-100/70`,children:[fb(e.scope),` · `,e.filePath,` · `,db(e)]}),(0,Z.jsx)(`div`,{className:`mt-2 rounded-lg border border-sky-500/15 bg-background/60 px-3 py-2`,children:(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-xs text-foreground`,children:e.comment})})]})]})},`${e.filePath}:${e.changeKey}`)),t.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Qd,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[`Finding `,e.ordinal]}),(0,Z.jsx)(J,{variant:`outline`,className:`capitalize`,children:e.severity})]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,EG(e)].filter(Boolean).join(` · `)}),(0,Z.jsx)(`div`,{className:`mt-2 text-xs font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]})]})},e.id)),n.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(xu,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.kind===`review`?`GitHub review summary`:`GitHub review comment`}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.file_path,e.kind===`inline`&&!OG(e)?DG(e):e.author].filter(Boolean).join(` · `)}),(0,Z.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.body})]})]})},e.id))]}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-2 pt-2`,children:[(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`ghost`,disabled:r===0||o,onClick:c,children:`Clear`}),(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`default`,disabled:!a,title:s,onClick:l,className:`gap-2`,children:[(0,Z.jsx)(Ow,{className:`h-4 w-4`}),o?`Sending...`:`Send fixes (${r})`]})]})]})]})]}),AG=({commitMessage:e,onCommitMessageChange:t,commitMessageRef:n,selectedFileCount:r,changesDisabledReason:i,canEditCommitMessage:a=!0,canGenerateCommitMessage:o,canCommit:s,isGeneratingCommitMessage:c,isCommitting:l,onGenerateCommitMessage:u,onCommit:d})=>{let f=e.trim()===``;return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border bg-background/40 px-4 py-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 xl:flex-row xl:items-center xl:gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 xl:w-56`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Commit selected files`}),(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 text-xs text-muted-foreground`,children:(0,Z.jsxs)(J,{variant:`outline`,children:[r,` file`,r===1?``:`s`,` selected`]})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(Dl,{"data-disabled":!a,className:`flex-1`,children:[(0,Z.jsx)(Ml,{"aria-label":`Commit message`,id:`ticket-changes-commit-message`,ref:n,value:e,onChange:e=>{t(e.target.value)},placeholder:`Commit message`,disabled:!a||c,title:i}),f&&(0,Z.jsx)(kl,{align:`inline-end`,children:(0,Z.jsx)(jl,{"aria-label":`Generate commit message`,disabled:!o,onClick:u,title:i,children:c?`Generating...`:`Generate`})})]}),(0,Z.jsxs)(U,{type:`button`,onClick:d,disabled:!s,title:i,className:`w-full gap-2 sm:w-auto sm:min-w-32`,children:[(0,Z.jsx)(vu,{className:`h-4 w-4`}),l?`Committing...`:`Commit`]})]})]})})},jG=({isCommitsLoading:e,commitsError:t,unpushedCommits:n,canUndoLatestCommit:r,isUndoing:i,aheadCount:a,onUndoLatestCommit:o})=>{if(!e&&n.length===0&&!t)return null;let s=n.length||a;return(0,Z.jsxs)(Bl,{children:[(0,Z.jsx)(Vl,{asChild:!0,children:(0,Z.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Local commits`}),(0,Z.jsx)(J,{variant:`outline`,className:`h-5 min-w-5 px-1.5 text-[10px]`,children:s}),(0,Z.jsx)(Te,{className:`h-4 w-4`})]})}),(0,Z.jsxs)(Hl,{align:`end`,className:`z-[90] w-[28rem] p-4`,children:[(0,Z.jsxs)(Ul,{className:`flex-row items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(Wl,{children:`Local commits`}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Review what will be pushed from this branch.`})]}),!e&&!t&&(0,Z.jsx)(J,{variant:`outline`,children:n.length})]}),e?(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-background/40 px-4 py-3 text-sm text-muted-foreground`,children:`Loading branch commits...`}):t?(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:o,disabled:!r,children:[(0,Z.jsx)(Bf,{className:`h-3.5 w-3.5`}),i?`Undoing...`:`Undo latest commit`]})}),(0,Z.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto`,children:n.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border bg-background/40 px-3 py-3`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.subject}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(J,{variant:`outline`,className:`font-mono`,children:e.short_hash}),(0,Z.jsx)(`span`,{children:new Date(e.committed_at).toLocaleString()})]})]},e.hash))})]})]})]})};function MG(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
135
135
  font-size: .6rem;
136
136
  font-weight: bold;
137
137
  color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function NG(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var PG=(e,t)=>Math.abs(e-t)<1.01,FG=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},IG=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},LG=e=>e,RG=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},zG=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(IG(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(IG(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},BG={passive:!0},VG=typeof window>`u`?!0:`onscrollend`in window,HG=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&VG?()=>void 0:FG(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,BG);let l=e.options.useScrollendEvent&&VG;return l&&n.addEventListener(`scrollend`,c,BG),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},UG=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},WG=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},GG=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:LG,rangeExtractor:RG,onChange:()=>{},measureElement:UG,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=MG(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=MG(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=MG(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=MG(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?qG({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=MG(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=MG(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return NG(t[KG(0,t.length-1,e=>NG(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&PG(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},KG=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function qG({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=KG(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var JG=typeof document<`u`?X.useLayoutEffect:X.useEffect;function YG({useFlushSync:e=!0,...t}){let n=X.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,wu.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=X.useState(()=>new GG(r));return i.setOptions(r),JG(()=>i._didMount(),[]),JG(()=>i._willUpdate()),i}function XG(e){return YG({observeElementRect:zG,observeElementOffset:HG,scrollToFn:WG,...e})}var ZG=8,QG=520,$G=2,eK=()=>(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-resize-placeholder`,className:`space-y-4 px-3 py-3`,children:[{gutter:`w-8`,code:`w-[68%]`},{gutter:`w-10`,code:`w-[54%]`},{gutter:`w-8`,code:`w-[74%]`},{gutter:`w-6`,code:`w-[38%]`},{gutter:`w-10`,code:`w-[82%]`},{gutter:`w-7`,code:`w-[61%]`},{gutter:`w-9`,code:`w-[48%]`},{gutter:`w-8`,code:`w-[71%]`},{gutter:`w-11`,code:`w-[57%]`},{gutter:`w-7`,code:`w-[66%]`},{gutter:`w-9`,code:`w-[43%]`},{gutter:`w-8`,code:`w-[76%]`}].map((e,t)=>(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-resize-placeholder-row`,className:`flex items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:W(`h-4 rounded bg-muted/80`,e.gutter)}),(0,Z.jsx)(`div`,{className:W(`h-4 rounded bg-muted/60`,e.code)})]},`${e.gutter}-${e.code}-${t}`))}),tK=({additions:e,deletions:t,fileCount:n})=>n===null?[{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}]:[{key:`files`,content:`${n} file${n===1?``:`s`}`,className:`text-muted-foreground`},{key:`additions`,content:`+${e}`,className:`font-mono text-emerald-400`},{key:`deletions`,content:`-${t}`,className:`font-mono text-rose-400`}],nK=({control:e,mode:t})=>typeof e==`function`?e(t):e??null,rK=e=>e.reduce((e,t)=>e+t.hunks.reduce((e,t)=>e+t.changes.length,0),0),iK=e=>ab(e),aK=(e,t)=>{let n=`oldPath`in e&&typeof e.oldPath==`string`?t(e.oldPath):``,r=`newPath`in e&&typeof e.newPath==`string`?t(e.newPath):``;return[...new Set([r,n].filter(e=>e&&e!==`/dev/null`))]},oK=e=>e.subject_type===`file`,sK=e=>e.subject_type===`line`,cK=`border-sky-400/30 bg-sky-400/10 text-sky-100`,lK=({context:e,comment:t,reviewDraftInput:n,canEdit:r,autoFocus:i,isReadOnly:a,hasSavedComment:o,onReviewDraftInputChange:s,onCancelReviewDraft:c,onEditReviewDraft:l,onRemoveReviewDraft:u,onSaveReviewDraft:d})=>{let f=(0,X.useRef)(null),[p,m]=(0,X.useState)(()=>n),h=iK(e.change);return(0,X.useEffect)(()=>{!i||a||f.current?.focus({preventScroll:!0})},[i,a]),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/8 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(J,{variant:`outline`,className:cK,children:`Manual`}),(0,Z.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-sky-100/80`,children:o?`Comment on line ${h}`:`Add a comment to line ${h}`})]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[a?(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap rounded-xl border border-sky-500/15 bg-background/70 px-3 py-2.5 text-xs text-foreground`,children:t}):(0,Z.jsx)(El,{ref:f,"aria-label":`Review comment for ${e.filePath}`,value:p,onChange:e=>{m(e.target.value),s(e.target.value)},disabled:!r,className:`min-h-20 text-xs`,placeholder:`Add a review comment for this change`}),(0,Z.jsx)(`div`,{className:`flex gap-2`,children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(U,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{l(e.commentKey)},disabled:!r,children:[(0,Z.jsx)(Lf,{className:`h-3.5 w-3.5`}),`Edit`]}),(0,Z.jsx)(U,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{u(e.commentKey)},disabled:!r,children:`Remove`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{type:`button`,size:`xs`,onClick:()=>{d(e,p)},disabled:!r||!p.trim(),children:`Add comment`}),(0,Z.jsx)(U,{type:`button`,size:`xs`,variant:`ghost`,onClick:c,children:`Cancel`})]})})]})]})},uK=e=>e===`high`?`destructive`:e===`medium`?`warning`:`outline`,dK=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,fK=({finding:e,isSelected:t,onToggle:n})=>{let[r,i]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`rounded-xl border border-slate-400/30 bg-slate-400/10 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(Qd,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,Z.jsx)(`div`,{children:`Finding ${e.ordinal}`}),(0,Z.jsx)(J,{variant:uK(e.severity),className:`normal-case`,children:e.severity})]}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-foreground`,children:e.what_text})]}),(0,Z.jsxs)(U,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,Z.jsx)(Td,{className:`h-3.5 w-3.5`}),t?`Selected`:`Fix`]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:dK(e)}),e.file_path&&(0,Z.jsx)(`span`,{children:e.file_path})]}),(e.why_text||e.fix_text)&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(U,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{i(e=>!e)},children:r?`Hide details`:`Details`}),r&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-xl border border-border bg-background/60 p-3 text-xs text-foreground`,children:[e.why_text&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Why it matters`}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.why_text})]}),e.fix_text&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Requested fix`}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.fix_text})]})]})]})]})},pK=e=>e.old_line_number!==null&&e.new_line_number!==null?`old ${e.old_line_number}, new ${e.new_line_number}`:e.new_line_number===null?e.old_line_number===null?`line unavailable`:`old ${e.old_line_number}`:`new ${e.new_line_number}`,mK=e=>e.old_line_number!==null||e.new_line_number!==null,hK=e=>e.kind===`review`?`Review summary`:oK(e)?`File comment`:mK(e)||sK(e)?`Inline comment`:`File comment`,gK=({comment:e,isSelected:t,onToggle:n})=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-violet-400/30 bg-violet-400/10 p-3 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(J,{variant:`outline`,className:`border-violet-400/40 bg-violet-400/10 text-violet-100`,children:`GitHub`}),(0,Z.jsx)(`span`,{children:hK(e)}),e.is_outdated&&(0,Z.jsx)(J,{variant:`warning`,className:`normal-case`,children:`Outdated`})]}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e.author}),(0,Z.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-foreground`,children:e.body})]}),(0,Z.jsxs)(U,{type:`button`,size:`xs`,variant:t?`default`:`outline`,onClick:n,className:`gap-1.5`,children:[!t&&(0,Z.jsx)(Td,{className:`h-3.5 w-3.5`}),t?`Selected`:`Fix`]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[e.file_path&&(0,Z.jsx)(`span`,{children:e.file_path}),e.kind===`inline`&&!oK(e)&&mK(e)&&(0,Z.jsx)(`span`,{children:pK(e)}),(0,Z.jsx)(`span`,{children:new Date(e.updated_at).toLocaleString()}),(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-violet-200 underline underline-offset-2 transition-colors hover:text-violet-100`,children:`Open on GitHub`})]})]}),_K=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,reviewFindings:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of aK(t,n))s.has(e)||s.set(e,t);for(let e of r){let n=e.file_path,r=n?s.get(n):null;if(!r||!n){o.push(e);continue}let c=t(r),l=null;for(let t of r.hunks){for(let n of t.changes)if(sb(e,n)){l=_v(n);break}if(l)break}if(l){let t=i.get(c)??new Map,n=t.get(l)??[];t.set(l,[...n,e]),i.set(c,t);continue}a.set(c,[...a.get(c)??[],e])}return{inlineByFilePath:i,fileLevelByFilePath:a,globalFindings:o}},vK=({allDiffFiles:e,resolveFilePath:t,normalizeDiffPath:n,githubComments:r})=>{let i=new Map,a=new Map,o=[],s=new Map;for(let t of e)for(let e of aK(t,n))s.has(e)||s.set(e,t);for(let e of r){if(e.kind===`review`||!e.file_path){o.push(e);continue}let n=s.get(e.file_path);if(!n){o.push(e);continue}let r=t(n);if(oK(e)||!e.subject_type&&!mK(e)){a.set(r,[...a.get(r)??[],e]);continue}let c=null;for(let t of n.hunks){for(let n of t.changes)if(ob(e,n)){c=_v(n);break}if(c)break}if(!c){o.push(e);continue}let l=i.get(r)??new Map,u=l.get(c)??[];l.set(c,[...u,e]),i.set(r,l)}return{inlineByFilePath:i,fileLevelByFilePath:a,fallbackComments:o}},yK=({filePath:e,hunks:t,activeReviewTarget:n,editingReviewCommentKey:r,reviewDraftInstanceKey:i,reviewDraftInput:a,reviewComments:o,reviewFindingsByChangeKey:s,githubCommentsByChangeKey:c,selectedReviewFindingIds:l,selectedGitHubCommentIds:u,canEditActiveReviewDraft:d,onToggleReviewFindingSelection:f,onToggleGitHubCommentSelection:p,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v})=>{let y=new Map(o.map(e=>[pb(e.filePath,e.changeKey),e]));return t.reduce((t,o)=>{for(let b of o.changes){let x=_v(b),S=pb(e,x),C=n?.commentKey===S,w=y.get(S),T=r===S,E=s.get(x)??[],D=c.get(x)??[];if(!C&&!w&&E.length===0&&D.length===0)continue;let O={filePath:e,changeKey:x,commentKey:S,hunk:o,change:b},k=!!w&&!T&&!C,A=k?w?.comment??``:a;t[x]=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[E.map(e=>(0,Z.jsx)(fK,{finding:e,isSelected:l.includes(e.id),onToggle:()=>{f(e.id)}},e.id)),D.map(e=>(0,Z.jsx)(gK,{comment:e,isSelected:u.includes(e.id),onToggle:()=>{p(e.id)}},e.id)),(C||w)&&(0,Z.jsx)(lK,{context:O,comment:w?.comment??``,reviewDraftInput:A,canEdit:d,autoFocus:C||T,isReadOnly:k,hasSavedComment:!!w,onReviewDraftInputChange:m,onCancelReviewDraft:h,onEditReviewDraft:g,onRemoveReviewDraft:_,onSaveReviewDraft:v},`${i??O.commentKey}:${k?`readonly`:`editable`}`)]})}return t},{})},bK=e=>e.reduce((e,t)=>{for(let n of t.changes)e.set(_v(n),{hunk:t,change:n});return e},new Map),xK=(0,X.memo)(({selectedDiffPath:e,sidebarFiles:t,diffResponse:n,isDiffLoading:r,diffError:i,allDiffFiles:a,renderedFiles:o,viewType:s,onViewTypeChange:c,onRetry:l,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindings:h,githubComments:g,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canSelectReviewTarget:y,canEditActiveReviewDraft:b,reviewFindingsError:x,gitHubCommentsError:S,hasStaleReviewFindings:C,onSelectReviewTarget:w,onToggleReviewFindingSelection:T,onToggleGitHubCommentSelection:E,onReviewDraftInputChange:D,onCancelReviewDraft:O,onEditReviewDraft:k,onRemoveReviewDraft:A,onSaveReviewDraft:j,diffThemeClassName:M,resolveFilePath:N,normalizeDiffPath:P,emptyStateTitle:F=`No changes to show.`,emptyStateDescription:I=null,filePickerControl:L,reviewSummaryControl:R,extraHeaderControl:ee,headerLayout:z=`stacked`,surfaceVariant:B=`default`,showViewTypeToggle:V=!0,gutterVariant:te=`default`,isResizing:ne=!1,resizePlaceholderLineThreshold:re=1/0,onVisibleFilePathsChange:ie})=>{let ae=(0,X.useRef)(null),{mode:oe,ref:se}=Xp({compactAt:B===`flat`?460:620,tightAt:B===`flat`?360:500}),H=!!n?.diff?.trim()||o.length>0||(n?.files.length??0)>0,ce=(0,X.useMemo)(()=>rK(o),[o]),le=e===`all`&&o.length>=ZG,ue=ne&&ce>re,de=(0,X.useMemo)(()=>o.map(e=>N(e)).join(`
138
138
  `),[o,N]),G=XG({count:le?o.length:0,getScrollElement:()=>ae.current,estimateSize:()=>QG,overscan:$G,getItemKey:e=>{let t=o[e];return t?`${N(t)}:${t.type??`modify`}`:e},initialRect:{width:0,height:900}}),fe=(0,X.useMemo)(()=>new Map(n?.files.map(e=>[e.path,e])??[]),[n?.files]),K=(0,X.useMemo)(()=>_K({allDiffFiles:a,resolveFilePath:N,normalizeDiffPath:P,reviewFindings:C?[]:h}),[a,C,P,N,h]),q=(0,X.useMemo)(()=>vK({allDiffFiles:a,resolveFilePath:N,normalizeDiffPath:P,githubComments:g}),[a,g,P,N]);(0,X.useEffect)(()=>{let e=ae.current;e&&(e.scrollTop=0)},[e]),(0,X.useEffect)(()=>{let e=ae.current;return()=>{window.getSelection()?.removeAllRanges(),e&&(e.scrollTop=0)}},[de]);let pe=G.getVirtualItems(),me=(0,X.useMemo)(()=>le?pe.map(e=>N(o[e.index])):o.map(e=>N(e)),[o,N,le,pe]);(0,X.useEffect)(()=>{ie?.(me)},[ie,me]);let he=le&&pe.length>0?pe[0]?.start??0:0,ge=le&&pe.length>0?Math.max(0,G.getTotalSize()-(pe[pe.length-1]?.end??0)):0,_e=le?pe.map(e=>({file:o[e.index],virtualItem:e})):o.map(e=>({file:e,virtualItem:null})),ve=e===`all`?null:t.find(t=>t.path===e)??null,ye=e===`all`?tK({additions:n?.stats?.additions??0,deletions:n?.stats?.deletions??0,fileCount:n?.stats?.files_changed??null}):ve?tK({additions:ve.additions,deletions:ve.deletions,fileCount:null}):[],be=(0,X.useMemo)(()=>V?(0,Z.jsxs)(CG,{type:`single`,size:`sm`,variant:`outline`,value:s,onValueChange:e=>{(e===`split`||e===`unified`)&&c(e)},children:[(0,Z.jsx)(wG,{value:`unified`,children:`Unified`}),(0,Z.jsx)(wG,{value:`split`,children:`Split`})]}):null,[c,V,s]),xe=(0,X.useMemo)(()=>[nK({control:L,mode:oe}),nK({control:R,mode:oe})].filter(Boolean),[L,oe,R]),Se=be||xe.length>0||ee;return(0,Z.jsxs)(`section`,{className:W(`flex min-h-0 flex-1 flex-col overflow-hidden`,B===`default`?`rounded-2xl border border-border bg-background/30`:`bg-transparent`),children:[(0,Z.jsx)(`div`,{ref:se,"data-responsive-mode":oe,"data-testid":`ticket-diff-header`,className:W(`grid min-w-0 items-start gap-x-3 gap-y-2 border-b px-4 py-3`,B===`default`?`border-border`:`border-border/70 px-3`,z===`stacked`?ee?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`:Se?`grid-cols-[minmax(0,1fr)_auto]`:`grid-cols-[minmax(0,1fr)]`),children:z===`stacked`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-left`,className:`grid min-w-0 gap-2`,children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?`All changes`:e}),ye.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:ye.map(e=>(0,Z.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),be||xe.length>0?(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-controls`,className:`flex min-w-0 flex-wrap items-center gap-2 justify-start`,children:[be?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:be}):null,xe.length>0?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 items-center gap-2 justify-start`,children:xe.map((e,t)=>(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null]}):null]}),ee?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:ee}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-info`,className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:e===`all`?`All changes`:e}),ye.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-3 whitespace-nowrap text-xs`,children:ye.map(e=>(0,Z.jsx)(`span`,{className:e.className,children:e.content},e.key))})]}),Se?(0,Z.jsxs)(`div`,{"data-testid":`ticket-diff-header-inline-controls`,className:`flex min-w-0 flex-wrap items-start justify-end gap-2`,children:[be?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-primary-controls`,className:`shrink-0`,children:be}):null,xe.length>0?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-secondary-controls`,className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:xe.map((e,t)=>(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:e},`header-secondary-control-${t+1}`))}):null,ee?(0,Z.jsx)(`div`,{"data-testid":`ticket-diff-header-close`,className:`flex shrink-0 items-start justify-end`,children:ee}):null]}):null]})}),(0,Z.jsx)(`div`,{ref:ae,"data-testid":`ticket-diff-scroll-region`,className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsxs)(`div`,{className:W(`min-h-full pb-4 pt-4`,B===`default`?`px-4`:`px-0`),children:[r&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading diff...`}),!r&&i&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-4 text-center`,children:[(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-rose-300`,children:i}),(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:l,children:`Retry`})]}),!r&&!i&&n&&!H&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-foreground`,children:F}),I&&(0,Z.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:I})]}),!r&&!i&&n&&H&&e!==`all`&&o.length===0&&(0,Z.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-3 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-foreground`,children:`No renderable diff for this file in the UI.`}),(0,Z.jsx)(`div`,{className:`max-w-md text-xs text-muted-foreground`,children:e})]}),!r&&!i&&n&&H&&o.length>0&&ue&&(0,Z.jsx)(eK,{}),!r&&!i&&n&&H&&o.length>0&&!ue&&(0,Z.jsxs)(`div`,{className:W(`archon-diff-viewer`,te===`compact`&&`archon-diff-viewer--compact-gutter`,e===`all`&&B===`default`&&`space-y-6`,e===`all`&&B===`flat`&&`space-y-0`,M),children:[x&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:x}),S&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border bg-background/40 px-4 py-3 text-xs text-muted-foreground`,children:S}),K.globalFindings.length>0&&(0,Z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:`Review findings`}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:K.globalFindings.map(e=>(0,Z.jsx)(fK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))})]}),e===`all`&&q.fallbackComments.length>0&&(0,Z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card/70 p-3`,children:[(0,Z.jsx)(`div`,{className:`mb-3 text-sm font-semibold text-foreground`,children:`GitHub review comments`}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:q.fallbackComments.map(e=>(0,Z.jsx)(gK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))})]}),he>0&&(0,Z.jsx)(`div`,{style:{height:he}}),_e.map(({file:t,virtualItem:n})=>{let r=N(t),i=fe.get(r),a=bK(t.hunks),o=K.inlineByFilePath.get(r)??new Map,c=q.inlineByFilePath.get(r)??new Map,l=K.fileLevelByFilePath.get(r)??[],h=q.fileLevelByFilePath.get(r)??[],g=d?m.find(e=>pb(e.filePath,e.changeKey)===d)??null:null,x=[...m.filter(e=>e.filePath===r).map(e=>e.changeKey),...u?.filePath===r?[u.changeKey]:[],...g?.filePath===r?[g.changeKey]:[]],S=yK({filePath:r,hunks:t.hunks,activeReviewTarget:u,editingReviewCommentKey:d,reviewDraftInstanceKey:f,reviewDraftInput:p,reviewComments:m,reviewFindingsByChangeKey:o,githubCommentsByChangeKey:c,selectedReviewFindingIds:_,selectedGitHubCommentIds:v,canEditActiveReviewDraft:b,onToggleReviewFindingSelection:T,onToggleGitHubCommentSelection:E,onReviewDraftInputChange:D,onCancelReviewDraft:O,onEditReviewDraft:k,onRemoveReviewDraft:A,onSaveReviewDraft:j}),C=(0,Z.jsx)(ry,{diffType:t.type,hunks:t.hunks,tokens:t.tokens,viewType:s,selectedChanges:[...new Set(x)],widgets:S,renderGutter:({change:e,side:t,renderDefault:n,wrapInAnchor:r,inHoverState:i})=>{if(!e)return r(n());let a=_v(e),o=t===`new`,c=y&&t===`new`,l=s===`unified`&&e.type===`normal`&&t===`new`?null:r(n());return(0,Z.jsxs)(`div`,{className:W(`flex items-center justify-end pr-1`,te===`compact`?`gap-1 pr-0.5`:`gap-2`),children:[l,o&&(0,Z.jsx)(`span`,{"data-diff-gutter-action-slot":`true`,className:[te===`compact`?`flex size-5 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`:`flex size-6 shrink-0 items-center justify-center rounded-md border border-emerald-300/80 bg-emerald-400 text-[#07130d] shadow-[0_8px_20px_rgba(16,185,129,0.22)] transition-all`,c&&i?`border-emerald-200 bg-emerald-300 opacity-100`:`opacity-0`,!c&&`pointer-events-none`].join(` `),"aria-hidden":`true`,children:(0,Z.jsx)(Td,{className:te===`compact`?`h-3 w-3`:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`sr-only`,children:a})]})},gutterEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(_v(e));t&&w({filePath:r,changeKey:_v(e),commentKey:pb(r,_v(e)),hunk:t.hunk,change:t.change})}},codeEvents:{onClick:({change:e})=>{if(!y||!e)return;let t=a.get(_v(e));t&&w({filePath:r,changeKey:_v(e),commentKey:pb(r,_v(e)),hunk:t.hunk,change:t.change})}},children:e=>e.map(e=>(0,Z.jsx)(Qv,{hunk:e},`${r}-${e.content}`))});return e===`all`?(0,Z.jsx)(`div`,{"data-index":n?.index,ref:n?G.measureElement:void 0,children:(0,Z.jsxs)(`section`,{className:W(B===`default`?`rounded-xl border border-border bg-card/70`:`border-t border-border/70 bg-transparent first:border-t-0`),children:[(0,Z.jsxs)(`div`,{className:W(`sticky top-0 z-20 border-b text-xs font-medium text-foreground`,B===`default`?`rounded-t-xl border-border bg-card px-4 py-3`:`border-border/70 bg-background/95 px-3 py-2.5 backdrop-blur-sm`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[`oldPath`in t&&typeof t.oldPath==`string`&&P(t.oldPath)===`/dev/null`&&(0,Z.jsx)(J,{variant:`success`,className:`shrink-0`,children:`New file`}),(0,Z.jsx)(`span`,{children:r})]}),i&&(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-emerald-400`,children:[`+`,i.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono text-rose-400`,children:[`-`,i.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:W(`overflow-x-auto`,B===`default`?`p-3`:`px-0 py-3`),children:[l.length>0&&(0,Z.jsx)(`div`,{className:W(`mb-3 space-y-3`,B===`flat`&&`px-3`),children:l.map(e=>(0,Z.jsx)(fK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))}),h.length>0&&(0,Z.jsx)(`div`,{className:W(`mb-3 space-y-3`,B===`flat`&&`px-3`),children:h.map(e=>(0,Z.jsx)(gK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),C]})]})},`${r}-${t.type??`modify`}`):(0,Z.jsxs)(`div`,{"data-index":n?.index,ref:n?G.measureElement:void 0,children:[l.length>0&&(0,Z.jsx)(`div`,{className:`mb-3 space-y-3`,children:l.map(e=>(0,Z.jsx)(fK,{finding:e,isSelected:_.includes(e.id),onToggle:()=>{T(e.id)}},e.id))}),h.length>0&&(0,Z.jsx)(`div`,{className:`mb-3 space-y-3`,children:h.map(e=>(0,Z.jsx)(gK,{comment:e,isSelected:v.includes(e.id),onToggle:()=>{E(e.id)}},e.id))}),C]},`${r}-${t.type??`modify`}`)}),ge>0&&(0,Z.jsx)(`div`,{style:{height:ge}})]})]})})]})});xK.displayName=`TicketChangesDiffPanel`;var SK=e=>W(`group`,e?`border-sky-700 bg-card/95 shadow-sm`:`border-border/50 bg-transparent text-muted-foreground hover:border-border/80 hover:bg-accent/60 hover:text-accent-foreground hover:shadow-sm`),CK={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},wK={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},TK=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},EK=({selectionWarning:e,gitError:t,sidebarFiles:n,commentCountByPath:r,commentCountTone:i,isGitStatusLoading:a,selectedPaths:o,selectedDiffPath:s,allFilesSelected:c,diffStats:l,title:u=`Changed files`,allChangesDescription:d=`Review the full workspace diff.`,enableSelection:f=!0,onToggleSelectAll:p,onSelectDiffPath:m,onTogglePath:h})=>{let g=i===`bundle_diff`?`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`;return(0,Z.jsxs)(`aside`,{className:`flex min-h-0 h-full flex-col between overflow-hidden rounded-2xl border border-border bg-background/40`,children:[(e||t)&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-border p-4`,children:[e&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:e}),t&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-100`,children:t})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:u}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.length,` file`,n.length===1?``:`s`,` changed`]})]}),f&&(0,Z.jsx)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:n.length===0,children:c?`Unselect all`:`Select all`})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[a&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`Loading file list...`}),!a&&n.length===0&&(0,Z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center text-sm text-muted-foreground`,children:`No changes to review.`}),!a&&n.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{m(`all`)},className:W(`flex w-full cursor-pointer items-start justify-between gap-3 rounded-xl border px-2.5 py-2 text-left transition-colors`,SK(s===`all`)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`All changes`}),l&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[l.files_changed,` file`,l.files_changed===1?``:`s`]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,l.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,l.deletions]})]})]}),(0,Z.jsx)(`div`,{className:`mt-1 flex w-full flex-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:d})]})}),n.map(e=>{let t=f&&o.has(e.path),n=s===e.path,i=r.get(e.path)??0;return(0,Z.jsxs)(`div`,{className:W(`relative flex cursor-pointer items-start gap-2.5 rounded-xl border px-2.5 py-2 transition-colors`,SK(n)),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Open diff for ${e.path}`,onClick:()=>{m(e.path)},className:`absolute inset-0 cursor-pointer rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`}),f&&(0,Z.jsx)(`input`,{type:`checkbox`,"aria-label":e.path,checked:t,onChange:()=>{h(e.path)},className:`relative z-10 mt-0.5 h-4 w-4 rounded border-border bg-background text-primary`}),(0,Z.jsxs)(`div`,{className:`relative z-10 min-w-0 flex-1 cursor-pointer text-left pointer-events-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex flex-1 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:TK(e.path)}),i>0&&(0,Z.jsx)(`span`,{"aria-label":`${i} comment${i===1?``:`s`} in ${e.path}`,className:g,children:i})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,e.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,e.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[e.status&&(0,Z.jsx)(J,{variant:`outline`,className:CK[e.status],children:wK[e.status]}),e.staged&&(0,Z.jsx)(J,{variant:`outline`,children:`Staged`}),e.unstaged&&(0,Z.jsx)(J,{variant:`outline`,children:`Unstaged`}),e.conflicted&&(0,Z.jsx)(J,{variant:`destructive`,children:`Conflicted`}),e.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:e.status===`renamed`?`from ${e.originalPath}`:e.originalPath})]})]})]},`${e.path}:${e.originalPath??``}`)})]})]})]})},DK=[`[--diff-background-color:transparent]`,`[--diff-text-color:rgb(226_232_240)]`,`[--diff-selection-background-color:rgba(148,163,184,0.2)]`,`[--diff-gutter-insert-background-color:rgba(34,197,94,0.16)]`,`[--diff-gutter-delete-background-color:rgba(244,63,94,0.16)]`,`[--diff-gutter-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-code-insert-background-color:rgba(34,197,94,0.08)]`,`[--diff-code-delete-background-color:rgba(244,63,94,0.08)]`,`[--diff-code-insert-edit-background-color:rgba(34,197,94,0.22)]`,`[--diff-code-delete-edit-background-color:rgba(244,63,94,0.22)]`,`[--diff-code-selected-background-color:rgba(148,163,184,0.12)]`,`[--diff-font-family:var(--font-mono)]`,`[&_.diff]:w-full`,`[&_.diff]:border-collapse`,`[&_.diff]:font-mono`,`[&_.diff-code]:whitespace-pre-wrap`,`[&_.diff-code]:break-words`,`[&_.diff-gutter]:select-none`].join(` `),OK=25e4,kK=2e3,AK=new Map,jK=e=>e?e.split(`
139
- `).length:0,MK=e=>{let t=e.diff??``;return t?t.length<=OK&&jK(t)<=kK:!0},NK=({scope:e,projectId:t,ticketId:n})=>e===`project_root`?t?`project_root:${t}`:null:n?`ticket:${t??`none`}:${n}`:null,PK=e=>e?AK.get(e)??null:null,FK=({cacheKey:e,diffResponse:t,gitStatus:n})=>{let r=n.workspace_signature?.trim();if(!(!e||!r)){if(!MK(t)){AK.delete(e);return}AK.set(e,{diffResponse:t,gitStatus:n,workspaceSignature:r})}},IK=e=>{e&&AK.delete(e)},LK={css:`css`,html:`markup`,htm:`markup`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,markdown:`markdown`,sh:`bash`,ts:`typescript`,tsx:`tsx`,yaml:`yaml`,yml:`yaml`},RK=e=>{if(!e)return null;let t=e.split(` -> `),n=t[t.length-1]??e,r=n.split(`/`),i=r[r.length-1]??n,a=``;if(i.includes(`.`)){let e=i.split(`.`);a=e[e.length-1]?.toLowerCase()??``}return LK[a]??null},zK=new Set,BK=e=>{e&&zK.forEach(t=>t(e))},VK=e=>(zK.add(e),()=>{zK.delete(e)}),HK=300,UK=(e,t={})=>{let n=t.dedupeMs??HK,r=0,i=()=>{if(document.visibilityState!==`visible`)return;let t=Date.now();t-r<n||(r=t,e())};return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,i)}},WK=i(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),GK=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.normal={},n.property={};function r(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}})),KK=i(((e,t)=>{var n=WK(),r=GK();t.exports=i;function i(e){for(var t=e.length,i=[],a=[],o=-1,s,c;++o<t;)s=e[o],i.push(s.property),a.push(s.normal),c=s.space;return new r(n.apply(null,i),n.apply(null,a),c)}})),qK=i(((e,t)=>{t.exports=n;function n(e){return e.toLowerCase()}})),JK=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.attribute=null,n.property=null,n.boolean=!1,n.booleanish=!1,n.overloadedBoolean=!1,n.number=!1,n.commaSeparated=!1,n.spaceSeparated=!1,n.commaOrSpaceSeparated=!1,n.mustUseProperty=!1,n.defined=!1;function r(e,t){this.property=e,this.attribute=t}})),YK=i((e=>{var t=0;e.boolean=n(),e.booleanish=n(),e.overloadedBoolean=n(),e.number=n(),e.spaceSeparated=n(),e.commaSeparated=n(),e.commaOrSpaceSeparated=n();function n(){return 2**++t}})),XK=i(((e,t)=>{var n=JK(),r=YK();t.exports=o,o.prototype=new n,o.prototype.defined=!0;var i=[`boolean`,`booleanish`,`overloadedBoolean`,`number`,`commaSeparated`,`spaceSeparated`,`commaOrSpaceSeparated`],a=i.length;function o(e,t,o,c){var l=-1,u;for(s(this,`space`,c),n.call(this,e,t);++l<a;)u=i[l],s(this,u,(o&r[u])===r[u])}function s(e,t,n){n&&(e[t]=n)}})),ZK=i(((e,t)=>{var n=qK(),r=GK(),i=XK();t.exports=a;function a(e){var t=e.space,a=e.mustUseProperty||[],o=e.attributes||{},s=e.properties,c=e.transform,l={},u={},d,f;for(d in s)f=new i(d,c(o,d),s[d],t),a.indexOf(d)!==-1&&(f.mustUseProperty=!0),l[d]=f,u[n(d)]=d,u[n(f.attribute)]=d;return new r(l,u,t)}})),QK=i(((e,t)=>{t.exports=ZK()({space:`xlink`,transform:n,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function n(e,t){return`xlink:`+t.slice(5).toLowerCase()}})),$K=i(((e,t)=>{t.exports=ZK()({space:`xml`,transform:n,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function n(e,t){return`xml:`+t.slice(3).toLowerCase()}})),eq=i(((e,t)=>{t.exports=n;function n(e,t){return t in e?e[t]:t}})),tq=i(((e,t)=>{var n=eq();t.exports=r;function r(e,t){return n(e,t.toLowerCase())}})),nq=i(((e,t)=>{t.exports=ZK()({space:`xmlns`,attributes:{xmlnsxlink:`xmlns:xlink`},transform:tq(),properties:{xmlns:null,xmlnsXLink:null}})})),rq=i(((e,t)=>{var n=YK(),r=ZK(),i=n.booleanish,a=n.number,o=n.spaceSeparated;t.exports=r({transform:s,properties:{ariaActiveDescendant:null,ariaAtomic:i,ariaAutoComplete:null,ariaBusy:i,ariaChecked:i,ariaColCount:a,ariaColIndex:a,ariaColSpan:a,ariaControls:o,ariaCurrent:null,ariaDescribedBy:o,ariaDetails:null,ariaDisabled:i,ariaDropEffect:o,ariaErrorMessage:null,ariaExpanded:i,ariaFlowTo:o,ariaGrabbed:i,ariaHasPopup:null,ariaHidden:i,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:o,ariaLevel:a,ariaLive:null,ariaModal:i,ariaMultiLine:i,ariaMultiSelectable:i,ariaOrientation:null,ariaOwns:o,ariaPlaceholder:null,ariaPosInSet:a,ariaPressed:i,ariaReadOnly:i,ariaRelevant:null,ariaRequired:i,ariaRoleDescription:o,ariaRowCount:a,ariaRowIndex:a,ariaRowSpan:a,ariaSelected:i,ariaSetSize:a,ariaSort:null,ariaValueMax:a,ariaValueMin:a,ariaValueNow:a,ariaValueText:null,role:null}});function s(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}})),iq=i(((e,t)=>{var n=YK(),r=ZK(),i=tq(),a=n.boolean,o=n.overloadedBoolean,s=n.booleanish,c=n.number,l=n.spaceSeparated,u=n.commaSeparated;t.exports=r({space:`html`,attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},transform:i,mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:u,acceptCharset:l,accessKey:l,action:null,allow:null,allowFullScreen:a,allowPaymentRequest:a,allowUserMedia:a,alt:null,as:null,async:a,autoCapitalize:null,autoComplete:l,autoFocus:a,autoPlay:a,capture:a,charSet:null,checked:a,cite:null,className:l,cols:c,colSpan:null,content:null,contentEditable:s,controls:a,controlsList:l,coords:c|u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:a,defer:a,dir:null,dirName:null,disabled:a,download:o,draggable:s,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:a,formTarget:null,headers:l,height:c,hidden:a,high:c,href:null,hrefLang:null,htmlFor:l,httpEquiv:l,id:null,imageSizes:null,imageSrcSet:u,inputMode:null,integrity:null,is:null,isMap:a,itemId:null,itemProp:l,itemRef:l,itemScope:a,itemType:l,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:a,low:c,manifest:null,max:null,maxLength:c,media:null,method:null,min:null,minLength:c,multiple:a,muted:a,name:null,nonce:null,noModule:a,noValidate:a,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:a,optimum:c,pattern:null,ping:l,placeholder:null,playsInline:a,poster:null,preload:null,readOnly:a,referrerPolicy:null,rel:l,required:a,reversed:a,rows:c,rowSpan:c,sandbox:l,scope:null,scoped:a,seamless:a,selected:a,shape:null,size:c,sizes:null,slot:null,span:c,spellCheck:s,src:null,srcDoc:null,srcLang:null,srcSet:u,start:c,step:null,style:null,tabIndex:c,target:null,title:null,translate:null,type:null,typeMustMatch:a,useMap:null,value:s,width:c,wrap:null,align:null,aLink:null,archive:l,axis:null,background:null,bgColor:null,border:c,borderColor:null,bottomMargin:c,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:a,declare:a,event:null,face:null,frame:null,frameBorder:null,hSpace:c,leftMargin:c,link:null,longDesc:null,lowSrc:null,marginHeight:c,marginWidth:c,noResize:a,noHref:a,noShade:a,noWrap:a,object:null,profile:null,prompt:null,rev:null,rightMargin:c,rules:null,scheme:null,scrolling:s,standby:null,summary:null,text:null,topMargin:c,valueType:null,version:null,vAlign:null,vLink:null,vSpace:c,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:a,disableRemotePlayback:a,prefix:null,property:null,results:c,security:null,unselectable:null}})})),aq=i(((e,t)=>{var n=KK(),r=QK();t.exports=n([$K(),r,nq(),rq(),iq()])})),oq=i(((e,t)=>{var n=qK(),r=XK(),i=JK(),a=`data`;t.exports=l;var o=/^data[-\w.:]+$/i,s=/-[a-z]/g,c=/[A-Z]/g;function l(e,t){var s=n(t),c=t,l=i;return s in e.normal?e.property[e.normal[s]]:(s.length>4&&s.slice(0,4)===a&&o.test(t)&&(t.charAt(4)===`-`?c=u(t):t=d(t),l=r),new l(c,t))}function u(e){var t=e.slice(5).replace(s,p);return a+t.charAt(0).toUpperCase()+t.slice(1)}function d(e){var t=e.slice(4);return s.test(t)?e:(t=t.replace(c,f),t.charAt(0)!==`-`&&(t=`-`+t),a+t)}function f(e){return`-`+e.toLowerCase()}function p(e){return e.charAt(1).toUpperCase()}})),sq=i(((e,t)=>{t.exports=r;var n=/[#.]/g;function r(e,t){for(var r=e||``,i=t||`div`,a={},o=0,s,c,l;o<r.length;)n.lastIndex=o,l=n.exec(r),s=r.slice(o,l?l.index:r.length),s&&(c?c===`#`?a.id=s:a.className?a.className.push(s):a.className=[s]:i=s,o+=s.length),l&&(c=l[0],o++);return{type:`element`,tagName:i,properties:a,children:[]}}})),cq=i((e=>{e.parse=i,e.stringify=a;var t=``,n=` `,r=/[ \t\n\r\f]+/g;function i(e){var n=String(e||t).trim();return n===t?[]:n.split(r)}function a(e){return e.join(n).trim()}})),lq=i((e=>{e.parse=i,e.stringify=a;var t=`,`,n=` `,r=``;function i(e){for(var n=[],i=String(e||r),a=i.indexOf(t),o=0,s=!1,c;!s;)a===-1&&(a=i.length,s=!0),c=i.slice(o,a).trim(),(c||!s)&&n.push(c),o=a+1,a=i.indexOf(t,o);return n}function a(e,i){var a=i||{},o=a.padLeft===!1?r:n,s=a.padRight?n:r;return e[e.length-1]===r&&(e=e.concat(r)),e.join(s+t+o).trim()}})),uq=i(((e,t)=>{var n=oq(),r=qK(),i=sq(),a=cq().parse,o=lq().parse;t.exports=c;var s={}.hasOwnProperty;function c(e,t,r){var c=r?h(r):null;return u;function u(e,n){var r=i(e,t),a=Array.prototype.slice.call(arguments,2),o=r.tagName.toLowerCase(),u;if(r.tagName=c&&s.call(c,o)?c[o]:o,n&&l(n,r)&&(a.unshift(n),n=null),n)for(u in n)p(r.properties,u,n[u]);return d(r.children,a),r.tagName===`template`&&(r.content={type:`root`,children:r.children},r.children=[]),r}function p(t,r,i){var s,c,l;i==null||i!==i||(s=n(e,r),c=s.property,l=i,typeof l==`string`&&(s.spaceSeparated?l=a(l):s.commaSeparated?l=o(l):s.commaOrSpaceSeparated&&(l=a(o(l).join(` `)))),c===`style`&&typeof i!=`string`&&(l=m(l)),c===`className`&&t.className&&(l=t.className.concat(l)),t[c]=f(s,c,l))}}function l(e,t){return typeof e==`string`||`length`in e||u(t.tagName,e)}function u(e,t){var n=t.type;return e===`input`||!n||typeof n!=`string`?!1:typeof t.children==`object`&&`length`in t.children?!0:(n=n.toLowerCase(),e===`button`?n!==`menu`&&n!==`submit`&&n!==`reset`&&n!==`button`:`value`in t)}function d(e,t){var n,r;if(typeof t==`string`||typeof t==`number`){e.push({type:`text`,value:String(t)});return}if(typeof t==`object`&&`length`in t){for(n=-1,r=t.length;++n<r;)d(e,t[n]);return}if(typeof t!=`object`||!(`type`in t))throw Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function f(e,t,n){var r,i,a;if(typeof n!=`object`||!(`length`in n))return p(e,t,n);for(i=n.length,r=-1,a=[];++r<i;)a[r]=p(e,t,n[r]);return a}function p(e,t,n){var i=n;return e.number||e.positiveNumber?!isNaN(i)&&i!==``&&(i=Number(i)):(e.boolean||e.overloadedBoolean)&&typeof i==`string`&&(i===``||r(n)===r(t))&&(i=!0),i}function m(e){var t=[],n;for(n in e)t.push([n,e[n]].join(`: `));return t.join(`; `)}function h(e){for(var t=e.length,n=-1,r={},i;++n<t;)i=e[n],r[i.toLowerCase()]=i;return r}})),dq=i(((e,t)=>{var n=aq(),r=uq()(n,`div`);r.displayName=`html`,t.exports=r})),fq=i(((e,t)=>{t.exports=dq()})),pq=r({AElig:()=>`Æ`,AMP:()=>`&`,Aacute:()=>`Á`,Acirc:()=>`Â`,Agrave:()=>`À`,Aring:()=>`Å`,Atilde:()=>`Ã`,Auml:()=>`Ä`,COPY:()=>`©`,Ccedil:()=>`Ç`,ETH:()=>`Ð`,Eacute:()=>`É`,Ecirc:()=>`Ê`,Egrave:()=>`È`,Euml:()=>`Ë`,GT:()=>`>`,Iacute:()=>`Í`,Icirc:()=>`Î`,Igrave:()=>`Ì`,Iuml:()=>`Ï`,LT:()=>`<`,Ntilde:()=>`Ñ`,Oacute:()=>`Ó`,Ocirc:()=>`Ô`,Ograve:()=>`Ò`,Oslash:()=>`Ø`,Otilde:()=>`Õ`,Ouml:()=>`Ö`,QUOT:()=>`"`,REG:()=>`®`,THORN:()=>`Þ`,Uacute:()=>`Ú`,Ucirc:()=>`Û`,Ugrave:()=>`Ù`,Uuml:()=>`Ü`,Yacute:()=>`Ý`,aacute:()=>`á`,acirc:()=>`â`,acute:()=>`´`,aelig:()=>`æ`,agrave:()=>`à`,amp:()=>`&`,aring:()=>`å`,atilde:()=>`ã`,auml:()=>`ä`,brvbar:()=>`¦`,ccedil:()=>`ç`,cedil:()=>`¸`,cent:()=>`¢`,copy:()=>`©`,curren:()=>`¤`,default:()=>mq,deg:()=>`°`,divide:()=>`÷`,eacute:()=>`é`,ecirc:()=>`ê`,egrave:()=>`è`,eth:()=>`ð`,euml:()=>`ë`,frac12:()=>`½`,frac14:()=>`¼`,frac34:()=>`¾`,gt:()=>`>`,iacute:()=>`í`,icirc:()=>`î`,iexcl:()=>`¡`,igrave:()=>`ì`,iquest:()=>`¿`,iuml:()=>`ï`,laquo:()=>`«`,lt:()=>`<`,macr:()=>`¯`,micro:()=>`µ`,middot:()=>`·`,nbsp:()=>`\xA0`,not:()=>`¬`,ntilde:()=>`ñ`,oacute:()=>`ó`,ocirc:()=>`ô`,ograve:()=>`ò`,ordf:()=>`ª`,ordm:()=>`º`,oslash:()=>`ø`,otilde:()=>`õ`,ouml:()=>`ö`,para:()=>`¶`,plusmn:()=>`±`,pound:()=>`£`,quot:()=>`"`,raquo:()=>`»`,reg:()=>`®`,sect:()=>`§`,shy:()=>`­`,sup1:()=>`¹`,sup2:()=>`²`,sup3:()=>`³`,szlig:()=>`ß`,thorn:()=>`þ`,times:()=>`×`,uacute:()=>`ú`,ucirc:()=>`û`,ugrave:()=>`ù`,uml:()=>`¨`,uuml:()=>`ü`,yacute:()=>`ý`,yen:()=>`¥`,yuml:()=>`ÿ`}),mq,hq=n((()=>{mq={AElig:`Æ`,AMP:`&`,Aacute:`Á`,Acirc:`Â`,Agrave:`À`,Aring:`Å`,Atilde:`Ã`,Auml:`Ä`,COPY:`©`,Ccedil:`Ç`,ETH:`Ð`,Eacute:`É`,Ecirc:`Ê`,Egrave:`È`,Euml:`Ë`,GT:`>`,Iacute:`Í`,Icirc:`Î`,Igrave:`Ì`,Iuml:`Ï`,LT:`<`,Ntilde:`Ñ`,Oacute:`Ó`,Ocirc:`Ô`,Ograve:`Ò`,Oslash:`Ø`,Otilde:`Õ`,Ouml:`Ö`,QUOT:`"`,REG:`®`,THORN:`Þ`,Uacute:`Ú`,Ucirc:`Û`,Ugrave:`Ù`,Uuml:`Ü`,Yacute:`Ý`,aacute:`á`,acirc:`â`,acute:`´`,aelig:`æ`,agrave:`à`,amp:`&`,aring:`å`,atilde:`ã`,auml:`ä`,brvbar:`¦`,ccedil:`ç`,cedil:`¸`,cent:`¢`,copy:`©`,curren:`¤`,deg:`°`,divide:`÷`,eacute:`é`,ecirc:`ê`,egrave:`è`,eth:`ð`,euml:`ë`,frac12:`½`,frac14:`¼`,frac34:`¾`,gt:`>`,iacute:`í`,icirc:`î`,iexcl:`¡`,igrave:`ì`,iquest:`¿`,iuml:`ï`,laquo:`«`,lt:`<`,macr:`¯`,micro:`µ`,middot:`·`,nbsp:`\xA0`,not:`¬`,ntilde:`ñ`,oacute:`ó`,ocirc:`ô`,ograve:`ò`,ordf:`ª`,ordm:`º`,oslash:`ø`,otilde:`õ`,ouml:`ö`,para:`¶`,plusmn:`±`,pound:`£`,quot:`"`,raquo:`»`,reg:`®`,sect:`§`,shy:`­`,sup1:`¹`,sup2:`²`,sup3:`³`,szlig:`ß`,thorn:`þ`,times:`×`,uacute:`ú`,ucirc:`û`,ugrave:`ù`,uml:`¨`,uuml:`ü`,yacute:`ý`,yen:`¥`,yuml:`ÿ`}})),gq=r({default:()=>_q}),_q,vq=n((()=>{_q={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`}})),yq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}})),bq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}})),xq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}})),Sq=i(((e,t)=>{var n=xq(),r=yq();t.exports=i;function i(e){return n(e)||r(e)}})),Cq=i(((e,t)=>{var n,r=59;t.exports=i;function i(e){var t=`&`+e+`;`,i;return n||=document.createElement(`i`),n.innerHTML=t,i=n.textContent,i.charCodeAt(i.length-1)===r&&e!==`semi`||i===t?!1:i}})),wq=i(((e,n)=>{var r=(hq(),t(pq).default),i=(vq(),t(gq).default),a=yq(),o=bq(),s=Sq(),c=Cq();n.exports=R;var l={}.hasOwnProperty,u=String.fromCharCode,d=Function.prototype,f={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},p=9,m=10,h=12,g=32,_=38,v=59,y=60,b=61,x=35,S=88,C=120,w=65533,T=`named`,E=`hexadecimal`,D=`decimal`,O={};O[E]=16,O[D]=10;var k={};k[T]=s,k[D]=a,k[E]=o;var A=1,j=2,M=3,N=4,P=5,F=6,I=7,L={};L[A]=`Named character references must be terminated by a semicolon`,L[j]=`Numeric character references must be terminated by a semicolon`,L[M]=`Named character references cannot be empty`,L[N]=`Numeric character references cannot be empty`,L[P]=`Named character references must be known`,L[F]=`Numeric character references cannot be disallowed`,L[I]=`Numeric character references cannot be outside the permissible Unicode range`;function R(e,t){var n={},r,i;for(i in t||={},f)r=t[i],n[i]=r??f[i];return(n.position.indent||n.position.start)&&(n.indent=n.position.indent||[],n.position=n.position.start),ee(e,n)}function ee(e,t){var n=t.additional,a=t.nonTerminated,o=t.text,f=t.reference,R=t.warning,ee=t.textContext,V=t.referenceContext,te=t.warningContext,ne=t.position,re=t.indent||[],ie=e.length,ae=0,oe=-1,se=ne.column||1,H=ne.line||1,ce=``,U=[],le,ue,W,de,G,fe,K,q,pe,me,he,ge,_e,ve,ye,be,xe,Se,Ce;for(typeof n==`string`&&(n=n.charCodeAt(0)),be=we(),q=R?Te:d,ae--,ie++;++ae<ie;)if(G===m&&(se=re[oe]||1),G=e.charCodeAt(ae),G===_){if(K=e.charCodeAt(ae+1),K===p||K===m||K===h||K===g||K===_||K===y||K!==K||n&&K===n){ce+=u(G),se++;continue}for(_e=ae+1,ge=_e,Ce=_e,K===x?(Ce=++ge,K=e.charCodeAt(Ce),K===S||K===C?(ve=E,Ce=++ge):ve=D):ve=T,le=``,he=``,de=``,ye=k[ve],Ce--;++Ce<ie&&(K=e.charCodeAt(Ce),ye(K));)de+=u(K),ve===T&&l.call(r,de)&&(le=de,he=r[de]);W=e.charCodeAt(Ce)===v,W&&(Ce++,ue=ve===T?c(de):!1,ue&&(le=de,he=ue)),Se=1+Ce-_e,!W&&!a||(de?ve===T?(W&&!he?q(P,1):(le!==de&&(Ce=ge+le.length,Se=1+Ce-ge,W=!1),W||(pe=le?A:M,t.attribute?(K=e.charCodeAt(Ce),K===b?(q(pe,Se),he=null):s(K)?he=null:q(pe,Se)):q(pe,Se))),fe=he):(W||q(j,Se),fe=parseInt(de,O[ve]),z(fe)?(q(I,Se),fe=u(w)):fe in i?(q(F,Se),fe=i[fe]):(me=``,B(fe)&&q(F,Se),fe>65535&&(fe-=65536,me+=u(fe>>>10|55296),fe=56320|fe&1023),fe=me+u(fe))):ve!==T&&q(N,Se)),fe?(Ee(),be=we(),ae=Ce-1,se+=Ce-_e+1,U.push(fe),xe=we(),xe.offset++,f&&f.call(V,fe,{start:be,end:xe},e.slice(_e-1,Ce)),be=xe):(de=e.slice(_e-1,Ce),ce+=de,se+=de.length,ae=Ce-1)}else G===10&&(H++,oe++,se=0),G===G?(ce+=u(G),se++):Ee();return U.join(``);function we(){return{line:H,column:se,offset:ae+(ne.offset||0)}}function Te(e,t){var n=we();n.column+=t,n.offset+=t,R.call(te,L[e],n,e)}function Ee(){ce&&=(U.push(ce),o&&o.call(ee,ce,{start:be,end:we()}),``)}}function z(e){return e>=55296&&e<=57343||e>1114111}function B(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}})),Tq=i(((e,t)=>{var n=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,r={},i={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof a?new a(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/\u00a0/g,` `)},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,`__id`,{value:++n}),e.__id},clone:function e(t,n){n||={};var r,a;switch(i.util.type(t)){case`Object`:if(a=i.util.objId(t),n[a])return n[a];for(var o in r={},n[a]=r,t)t.hasOwnProperty(o)&&(r[o]=e(t[o],n));return r;case`Array`:return a=i.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return`none`},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,`gi`),``),e.classList.add(`language-`+n)},currentScript:function(){if(typeof document>`u`)return null;if(`currentScript`in document)return document.currentScript;try{throw Error()}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var t=document.getElementsByTagName(`script`);for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var r=`no-`+t;e;){var i=e.classList;if(i.contains(t))return!0;if(i.contains(r))return!1;e=e.parentElement}return!!n}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,t){var n=i.util.clone(i.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=i.languages;var a=r[e],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==t)for(var c in n)n.hasOwnProperty(c)&&(o[c]=n[c]);n.hasOwnProperty(s)||(o[s]=a[s])}var l=r[e];return r[e]=o,i.languages.DFS(i.languages,function(t,n){n===l&&t!=e&&(this[t]=o)}),o},DFS:function e(t,n,r,a){a||={};var o=i.util.objId;for(var s in t)if(t.hasOwnProperty(s)){n.call(t,s,t[s],r||s);var c=t[s],l=i.util.type(c);l===`Object`&&!a[o(c)]?(a[o(c)]=!0,e(c,n,null,a)):l===`Array`&&!a[o(c)]&&(a[o(c)]=!0,e(c,n,s,a))}}},plugins:{},highlightAll:function(e,t){i.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var r={callback:n,container:e,selector:`code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code`};i.hooks.run(`before-highlightall`,r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),i.hooks.run(`before-all-elements-highlight`,r);for(var a=0,o;o=r.elements[a++];)i.highlightElement(o,t===!0,r.callback)},highlightElement:function(t,n,r){var a=i.util.getLanguage(t),o=i.languages[a];i.util.setLanguage(t,a);var s=t.parentElement;s&&s.nodeName.toLowerCase()===`pre`&&i.util.setLanguage(s,a);var c={element:t,language:a,grammar:o,code:t.textContent};function l(e){c.highlightedCode=e,i.hooks.run(`before-insert`,c),c.element.innerHTML=c.highlightedCode,i.hooks.run(`after-highlight`,c),i.hooks.run(`complete`,c),r&&r.call(c.element)}if(i.hooks.run(`before-sanity-check`,c),s=c.element.parentElement,s&&s.nodeName.toLowerCase()===`pre`&&!s.hasAttribute(`tabindex`)&&s.setAttribute(`tabindex`,`0`),!c.code){i.hooks.run(`complete`,c),r&&r.call(c.element);return}if(i.hooks.run(`before-highlight`,c),!c.grammar){l(i.util.encode(c.code));return}if(n&&e.Worker){var u=new Worker(i.filename);u.onmessage=function(e){l(e.data)},u.postMessage(JSON.stringify({language:c.language,code:c.code,immediateClose:!0}))}else l(i.highlight(c.code,c.grammar,c.language))},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(i.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=i.tokenize(r.code,r.grammar),i.hooks.run(`after-tokenize`,r),a.stringify(i.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new c;return l(i,i.head,e),s(e,i,t,i.head,0),d(i)},hooks:{all:{},add:function(e,t){var n=i.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=i.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:a};e.Prism=i;function a(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}a.stringify=function e(t,n){if(typeof t==`string`)return t;if(Array.isArray(t)){var r=``;return t.forEach(function(t){r+=e(t,n)}),r}var a={type:t.type,content:e(t.content,n),tag:`span`,classes:[`token`,t.type],attributes:{},language:n},o=t.alias;o&&(Array.isArray(o)?Array.prototype.push.apply(a.classes,o):a.classes.push(o)),i.hooks.run(`wrap`,a);var s=``;for(var c in a.attributes)s+=` `+c+`="`+(a.attributes[c]||``).replace(/"/g,`&quot;`)+`"`;return`<`+a.tag+` class="`+a.classes.join(` `)+`"`+s+`>`+a.content+`</`+a.tag+`>`};function o(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function s(e,t,n,r,c,d){for(var f in n)if(!(!n.hasOwnProperty(f)||!n[f])){var p=n[f];p=Array.isArray(p)?p:[p];for(var m=0;m<p.length;++m){if(d&&d.cause==f+`,`+m)return;var h=p[m],g=h.inside,_=!!h.lookbehind,v=!!h.greedy,y=h.alias;if(v&&!h.pattern.global){var b=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,b+`g`)}for(var x=h.pattern||h,S=r.next,C=c;S!==t.tail&&!(d&&C>=d.reach);C+=S.value.length,S=S.next){var w=S.value;if(t.length>e.length)return;if(!(w instanceof a)){var T=1,E;if(v){if(E=o(x,C,e,_),!E||E.index>=e.length)break;var D=E.index,O=E.index+E[0].length,k=C;for(k+=S.value.length;D>=k;)S=S.next,k+=S.value.length;if(k-=S.value.length,C=k,S.value instanceof a)continue;for(var A=S;A!==t.tail&&(k<O||typeof A.value==`string`);A=A.next)T++,k+=A.value.length;T--,w=e.slice(C,k),E.index-=C}else if(E=o(x,0,w,_),!E)continue;var D=E.index,j=E[0],M=w.slice(0,D),N=w.slice(D+j.length),P=C+w.length;d&&P>d.reach&&(d.reach=P);var F=S.prev;M&&(F=l(t,F,M),C+=M.length),u(t,F,T);var I=new a(f,g?i.tokenize(j,g):j,y,j);if(S=l(t,F,I),N&&l(t,S,N),T>1){var L={cause:f+`,`+m,reach:P};s(e,t,n,S.prev,C,L),d&&L.reach>d.reach&&(d.reach=L.reach)}}}}}}function c(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function l(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function u(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function d(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}if(!e.document)return e.addEventListener&&(i.disableWorkerMessageHandler||e.addEventListener(`message`,function(t){var n=JSON.parse(t.data),r=n.language,a=n.code,o=n.immediateClose;e.postMessage(i.highlight(a,i.languages[r],r)),o&&e.close()},!1)),i;var f=i.util.currentScript();f&&(i.filename=f.src,f.hasAttribute(`data-manual`)&&(i.manual=!0));function p(){i.manual||i.highlightAll()}if(!i.manual){var m=document.readyState;m===`loading`||m===`interactive`&&f&&f.defer?document.addEventListener(`DOMContentLoaded`,p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return i}(typeof window<`u`?window:typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope?self:{});t!==void 0&&t.exports&&(t.exports=n),typeof global<`u`&&(global.Prism=n)})),Eq=i(((e,t)=>{t.exports=n,n.displayName=`markup`,n.aliases=[`html`,`mathml`,`svg`,`xml`,`ssml`,`atom`,`rss`];function n(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&amp;/,`&`))}),Object.defineProperty(e.languages.markup.tag,`addInlined`,{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,`addAttribute`,{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}})),Dq=i(((e,t)=>{t.exports=n,n.displayName=`css`,n.aliases=[];function n(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}})),Oq=i(((e,t)=>{t.exports=n,n.displayName=`clike`,n.aliases=[];function n(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}})),kq=i(((e,t)=>{t.exports=n,n.displayName=`javascript`,n.aliases=[`js`];function n(e){e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}})),Aq=i(((e,t)=>{var n=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},r=C();n.Prism={manual:!0,disableWorkerMessageHandler:!0};var i=fq(),a=wq(),o=Tq(),s=Eq(),c=Dq(),l=Oq(),u=kq();r();var d={}.hasOwnProperty;function f(){}f.prototype=o;var p=new f;t.exports=p,p.highlight=g,p.register=m,p.alias=h,p.registered=_,p.listLanguages=v,m(s),m(c),m(l),m(u),p.util.encode=x,p.Token.stringify=y;function m(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `grammar`, got `"+e+"`");p.languages[e.displayName]===void 0&&e(p)}function h(e,t){var n=p.languages,r=e,i,a,o,s;for(i in t&&(r={},r[e]=t),r)for(a=r[i],a=typeof a==`string`?[a]:a,o=a.length,s=-1;++s<o;)n[a[s]]=n[i]}function g(e,t){var n=o.highlight,r;if(typeof e!=`string`)throw Error("Expected `string` for `value`, got `"+e+"`");if(p.util.type(t)===`Object`)r=t,t=null;else{if(typeof t!=`string`)throw Error("Expected `string` for `name`, got `"+t+"`");if(d.call(p.languages,t))r=p.languages[t];else throw Error("Unknown language: `"+t+"` is not registered")}return n.call(this,e,r,t)}function _(e){if(typeof e!=`string`)throw Error("Expected `string` for `language`, got `"+e+"`");return d.call(p.languages,e)}function v(){var e=p.languages,t=[],n;for(n in e)d.call(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function y(e,t,n){var r;return typeof e==`string`?{type:`text`,value:e}:p.util.type(e)===`Array`?b(e,t):(r={type:e.type,content:p.Token.stringify(e.content,t,n),tag:`span`,classes:[`token`,e.type],attributes:{},language:t,parent:n},e.alias&&(r.classes=r.classes.concat(e.alias)),p.hooks.run(`wrap`,r),i(r.tag+`.`+r.classes.join(`.`),S(r.attributes),r.content))}function b(e,t){for(var n=[],r=e.length,i=-1,a;++i<r;)a=e[i],a!==``&&a!=null&&n.push(a);for(i=-1,r=n.length;++i<r;)a=n[i],n[i]=p.Token.stringify(a,t,n);return n}function x(e){return e}function S(e){for(var t in e)e[t]=a(e[t]);return e}function C(){var e=`Prism`in n,t=e?n.Prism:void 0;return r;function r(){e?n.Prism=t:delete n.Prism,e=void 0,t=void 0}}})),jq=i(((e,t)=>{t.exports=n,n.displayName=`bash`,n.aliases=[`shell`];function n(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.shell=e.languages.bash})(e)}})),Mq=i(((e,t)=>{t.exports=n,n.displayName=`json`,n.aliases=[`webmanifest`];function n(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}})),Nq=i(((e,t)=>{t.exports=n,n.displayName=`jsx`,n.aliases=[];function n(e){(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){e.language!==`jsx`&&e.language!==`tsx`||s(e.tokens)})})(e)}})),Pq=i(((e,t)=>{t.exports=n,n.displayName=`markdown`,n.aliases=[`md`];function n(e){(function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(l(t.content.value),s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}});var o=RegExp(e.languages.markup.tag.pattern.source,`gi`),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;function l(e){var t=e.replace(o,``);return t=t.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){return t=t.toLowerCase(),t[0]===`#`?c(t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1))):s[t]||e}),t}e.languages.md=e.languages.markdown})(e)}})),Fq=i(((e,t)=>{t.exports=n,n.displayName=`typescript`,n.aliases=[`ts`];function n(e){(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}})),Iq=i(((e,t)=>{var n=Nq(),r=Fq();t.exports=i,i.displayName=`tsx`,i.aliases=[];function i(e){e.register(n),e.register(r),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}})),Lq=i(((e,t)=>{t.exports=n,n.displayName=`yaml`,n.aliases=[`yml`];function n(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}})),Rq=e(Aq(),1),zq=e(jq(),1),Bq=e(Dq(),1),Vq=e(kq(),1),Hq=e(Mq(),1),Uq=e(Nq(),1),Wq=e(Pq(),1),Gq=e(Eq(),1),Kq=e(Iq(),1),qq=e(Fq(),1),Jq=e(Lq(),1),Yq=e=>{let t=e.displayName;!t||Rq.default.registered(t)||Rq.default.register(e)};Yq(Gq.default),Yq(Bq.default),Yq(Vq.default),Yq(qq.default),Yq(Kq.default),Yq(Hq.default),Yq(Uq.default),Yq(Wq.default),Yq(Jq.default),Yq(zq.default);var Xq=r({TicketChangesModal:()=>TJ}),Zq=4,Qq=1500,$q=`archon.ticket-changes.review-comments`,eJ=[],tJ=[],nJ=[],rJ=e=>new Set(e.map(e=>e.path)),iJ=(e,t)=>{if(!e)return null;if(e.blocked_reason)return e.blocked_reason;let n=e.files.find(e=>!t.has(e.path)&&e.staged);return n?`"${n.path}" already has staged changes. Finish that commit in the terminal first.`:null},aJ=e=>e.replace(/^[ab]\//,``),oJ=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?aJ(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?aJ(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},sJ=e=>{let[t,n]=oJ(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},cJ=e=>{let[t,n]=oJ(e);return t??n??null},lJ=e=>e.hunks.reduce((e,t)=>e+t.changes.length,0),uJ=e=>{if(lJ(e)>Qq)return null;let t=RK(cJ(e));if(!t)return null;try{return rb(e.hunks,{highlight:!0,refractor:Rq.default,language:t,enhancers:[tb(e.hunks)]})}catch{return null}},dJ=(e,t)=>e instanceof Error?e.message:t,fJ=(e,t)=>`${$q}:${e}:${t}`,pJ=()=>({activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map,signature:null}),mJ=()=>({uncommitted:pJ(),bundle_diff:pJ()}),hJ=e=>({uncommitted:e(),bundle_diff:e()}),gJ=()=>hJ(()=>new Map),_J=e=>{let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^e.charCodeAt(n);return`${e.length}:${t>>>0}`},vJ=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return(t.scope===void 0||t.scope===`uncommitted`||t.scope===`bundle_diff`)&&typeof t.filePath==`string`&&typeof t.changeKey==`string`&&typeof t.changeType==`string`&&(typeof t.oldLineNumber==`number`||t.oldLineNumber===null)&&(typeof t.newLineNumber==`number`||t.newLineNumber===null)&&typeof t.hunkHeader==`string`&&typeof t.lineContent==`string`&&typeof t.diffSnippet==`string`&&typeof t.comment==`string`},yJ=e=>{try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.diffSignature!=`string`||!Array.isArray(n.comments))return null;let r=n.comments.filter(vJ).map(e=>({scope:e.scope??`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.changeType,oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber,hunkHeader:e.hunkHeader,lineContent:e.lineContent,diffSnippet:e.diffSnippet,comment:e.comment}));return r.length===n.comments.length?{diffSignature:n.diffSignature,comments:r}:null}catch{return null}},bJ=e=>new Map(e.map(e=>[pb(e.filePath,e.changeKey),e])),xJ=(e,t)=>{e.set(t,(e.get(t)??0)+1)},SJ=e=>e.find(e=>e.trim())||``,CJ=({pullRequest:e,isLoading:t,isOpen:n,canCreate:r,disabledReason:i,isCreating:a,isSyncing:o,isGeneratingDescription:s,title:c,body:l,baseBranch:u,onOpenChange:d,onTitleChange:f,onBodyChange:p,onBaseBranchChange:m,showGenerateDescription:h,onGenerateDescription:g,onCreate:_})=>t?(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:`Loading PR...`}):o?(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:[(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}),`Checking PR...`]}):e?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border/80 bg-background/50 px-3 py-2`,children:[(0,Z.jsx)(Ew,{pullRequest:e}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-xs font-medium text-sky-300 underline underline-offset-2 hover:text-sky-200`,children:[`PR #`,e.number]})]}):(0,Z.jsxs)(Bl,{open:n,onOpenChange:d,children:[(0,Z.jsx)(Vl,{asChild:!0,children:(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`default`,disabled:!r,title:i,className:`gap-2`,children:[a?(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(xu,{className:`h-4 w-4`}),a?`Creating PR...`:`Create PR`]})}),(0,Z.jsxs)(Hl,{align:`end`,className:`z-[90] w-[36rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsx)(Ul,{children:(0,Z.jsx)(Wl,{children:`Create pull request`})}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(Id,{label:`Title`,htmlFor:`bundle-pr-title`,children:(0,Z.jsx)(Me,{id:`bundle-pr-title`,value:c,onChange:e=>f(e.target.value),placeholder:`Bundle title`,disabled:a})}),(0,Z.jsx)(Id,{label:`Base branch`,htmlFor:`bundle-pr-base-branch`,description:`Optional. Leave blank to use the repository default branch.`,children:(0,Z.jsx)(Me,{id:`bundle-pr-base-branch`,value:u,onChange:e=>m(e.target.value),placeholder:`main`,disabled:a})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,htmlFor:`bundle-pr-body`,children:`Description`}),h&&(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a||s,onClick:g,children:[s?(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}):null,s?`Generating...`:`Generate`]})]}),(0,Z.jsx)(El,{id:`bundle-pr-body`,value:l,onChange:e=>p(e.target.value),placeholder:`Summarize the bundle changes for reviewers.`,className:`min-h-40`,disabled:a})]}),(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(U,{type:`button`,size:`sm`,disabled:!c.trim()||a,onClick:_,children:a?`Creating...`:`Create PR`})})]})]})]}),wJ=(e,t,n)=>{if(n)return rJ(t);let r=new Set(t.map(e=>e.path));return new Set([...e].filter(e=>r.has(e)))},TJ=e=>{let{projectId:t,reviewCommentsBundleId:n=null,title:r,onClose:i,onSubmitReviewPrompt:a,canSubmitReviewPrompt:o=!1,reviewSubmitDisabledReason:s,canAddReviewComments:c=!0,canModifyChanges:l=!0,changesDisabledReason:d}=e,f=e.scope??`ticket`,{isGitHubConnected:p}=Cf(t),m=e.scope===`project_root`?null:e.ticketId,h=e.scope===`project_root`?void 0:e.onTicketUpdate,g=e.scope===`project_root`?void 0:e.onRequestTicketRefresh,[_,v]=(0,X.useState)(`uncommitted`),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),[T,E]=(0,X.useState)([]),[D,O]=(0,X.useState)(new Set),[k,A]=(0,X.useState)(`all`),[j,M]=(0,X.useState)(``),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(null),[L,R]=(0,X.useState)(null),[ee,z]=(0,X.useState)(null),[B,V]=(0,X.useState)(!0),[ne,re]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!0),[se,H]=(0,X.useState)(!1),[le,ue]=(0,X.useState)(!1),[W,de]=(0,X.useState)(!1),[G,fe]=(0,X.useState)(!1),[K,q]=(0,X.useState)(!1),[pe,me]=(0,X.useState)(`unified`),[he,ge]=(0,X.useState)(new Map),[_e,ve]=(0,X.useState)(nJ),[ye,be]=(0,X.useState)(mJ),[xe,Se]=(0,X.useState)(null),[we,Te]=(0,X.useState)([]),[De,Oe]=(0,X.useState)(null),[ke,Ae]=(0,X.useState)(null),[Me,Pe]=(0,X.useState)(new Set),[Fe,Ie]=(0,X.useState)(new Set),[Le,Re]=(0,X.useState)(!1),[ze,Be]=(0,X.useState)(null),[Ve,He]=(0,X.useState)(!1),[Ue,Ge]=(0,X.useState)(!1),[Ke,Y]=(0,X.useState)(``),[qe,Je]=(0,X.useState)(``),[Ye,Xe]=(0,X.useState)(``),[Qe,nt]=(0,X.useState)([]),[rt,it]=(0,X.useState)(!1),[at,lt]=(0,X.useState)(!1),[ut,dt]=(0,X.useState)(!1),ft=(0,X.useRef)(null),pt=(0,X.useRef)(!1),mt=(0,X.useRef)(null),ht=(0,X.useRef)(null),gt=(0,X.useRef)(0),_t=(0,X.useRef)(0),vt=(0,X.useRef)(hJ(()=>null)),yt=(0,X.useRef)(gJ()),bt=(0,X.useMemo)(()=>NK({scope:f,projectId:t,ticketId:m}),[t,f,m]),xt=(0,X.useCallback)(()=>{if(!m)throw Error(`Ticket changes require a ticket id.`);return m},[m]),St=(0,X.useCallback)(e=>{mt.current=e,b(e),P(null)},[]),At=(0,X.useCallback)((e,t)=>{FK({cacheKey:bt,diffResponse:e,gitStatus:t})},[bt]),jt=(0,X.useCallback)(e=>{mt.current&&FK({cacheKey:bt,diffResponse:mt.current,gitStatus:e})},[bt]),Mt=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ee(t)}return await Ct(xt(),t)},[t,xt,f]),Nt=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await ce(t)}return await wt(xt(),t)},[t,xt,f]),Pt=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ne(t)}return await Ot(xt(),t)},[t,xt,f]),Ft=(0,X.useCallback)(async e=>f===`project_root`||!n||!t?null:await ot(t,n,e),[t,n,f]),It=(0,X.useCallback)(async e=>f===`project_root`||!n||!t?null:await Ze(t,n,e),[t,n,f]),Lt=(0,X.useCallback)(async e=>f===`project_root`||!n||!t?null:await st(t,n,e),[t,n,f]),Rt=(0,X.useCallback)(async e=>f===`project_root`||!n||!t?null:await ct(t,n,e),[t,n,f]),zt=(0,X.useCallback)((e,t)=>{be(n=>({...n,[e]:t(n[e])}))},[]),Bt=(0,X.useCallback)(async e=>{if(f===`project_root`||!n||!t)throw Error(`Pull request description generation requires a bundle context.`);return await et(t,n,e)},[t,n,f]),Vt=(0,X.useCallback)(async e=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await te(t,e)}return await Tt(xt(),t,e)},[t,xt,f]),Ht=(0,X.useCallback)(async e=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await je(t,e)}return await Et(xt(),t,e)},[t,xt,f]),Ut=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await We(t)}return await Dt(xt(),t)},[t,xt,f]),Wt=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await u(t)}return await kt(xt(),t)},[t,xt,f]),Gt=(0,X.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=gt.current+1;gt.current=r,H(!0),n||z(null);try{let t=await Pt();if(!e()||gt.current!==r)return;E(t.commits),z(null)}catch(t){if(!e()||gt.current!==r)return;z(dJ(t,`Unable to load local commits right now.`)),n||E([])}finally{e()&&gt.current===r&&H(!1)}},[Pt]),Kt=(0,X.useCallback)(()=>{gt.current+=1,E([]),z(null),H(!1)},[]),qt=(0,X.useCallback)((e,t={})=>{let n=t.resetSelection??!1;ht.current=e,w(e),R(null),O(t=>{let r=wJ(t,e.files,n||!pt.current);return pt.current=!0,r})},[]),Jt=(0,X.useCallback)(async(e={})=>{let t=e.preserveContent??!1,n=e.gitStatusForCache??null;t||P(null),V(!0);try{let e=await Mt();St(e),n&&At(e,n)}catch(e){n&&IK(bt),(!t||!mt.current)&&P(dJ(e,`Unable to load the diff right now.`))}finally{V(!1)}},[St,bt,Mt,At]),Yt=(0,X.useCallback)(async(e={})=>{let r=e.preserveContent??!1;if(f===`project_root`||!n||!t){S(null),I(null),re(!1);return}r||I(null),re(!0);try{S(await Lt()),I(null)}catch(e){(!r||!x)&&I(dJ(e,`Unable to load the branch diff right now.`))}finally{re(!1)}},[x,t,Lt,n,f]),Xt=(0,X.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=t.resetSelection??!1,i=t.allowCache??!0?PK(bt):null;if(n||(P(null),R(null)),oe(!0),i){St(i.diffResponse),qt(i.gitStatus,{resetSelection:r}),V(!1);try{let t=await Nt();if(!e())return;qt(t,{resetSelection:r}),oe(!1),(t.ahead??0)>0?Gt(e,{preserveContent:!0}):Kt();let n=t.workspace_signature??null;if(n&&n===i.workspaceSignature){At(i.diffResponse,t);return}IK(bt),await Jt({preserveContent:!0,gitStatusForCache:t});return}catch(t){if(!e())return;R(dJ(t,`Unable to load git status right now.`)),w(null),oe(!1),Kt();return}}V(!0);let[a,o]=await Promise.allSettled([Mt(),Nt()]);e()&&(a.status===`fulfilled`?St(a.value):(!n||!mt.current)&&P(dJ(a.reason,`Unable to load the diff right now.`)),V(!1),o.status===`fulfilled`?qt(o.value,{resetSelection:r}):(R(dJ(o.reason,`Unable to load git status right now.`)),n||w(null)),oe(!1),a.status===`fulfilled`&&o.status===`fulfilled`&&At(a.value,o.value),o.status===`fulfilled`&&(o.value.ahead??0)>0?Gt(e,{preserveContent:n}):Kt())},[St,qt,bt,Kt,Gt,Jt,Mt,Nt,At]),Zt=(0,X.useCallback)(async()=>{if(!t)return;let e=_t.current+1;_t.current=e,oe(!0);try{let t=await Nt();if(_t.current!==e)return;let n=ht.current?.workspace_signature??null,r=t.workspace_signature??null,i=!mt.current||n!==r;if(qt(t),(t.ahead??0)>0?Gt(()=>_t.current===e,{preserveContent:!0}):Kt(),!i){jt(t);return}await Jt({preserveContent:!0,gitStatusForCache:t})}catch{return}finally{_t.current===e&&oe(!1)}},[qt,Kt,Gt,Jt,t,Nt,jt]);(0,X.useEffect)(()=>{mt.current=y},[y]),(0,X.useEffect)(()=>{ht.current=C},[C]),(0,X.useEffect)(()=>{let e=!0;return Xt(()=>e,{resetSelection:!0}),()=>{e=!1}},[Xt]),(0,X.useEffect)(()=>{if(t)return VK(e=>{e===t&&Zt()})},[t,Zt]),(0,X.useEffect)(()=>{if(!t)return;let e=UK(()=>{document.visibilityState===`visible`&&Zt()});return()=>{e()}},[t,Zt]),(0,X.useEffect)(()=>{if(f===`project_root`){Se(null),Oe(null),Pe(new Set);return}let e=new AbortController,t=!0;return Oe(null),Ft(e.signal).then(e=>{t&&(Se(e),Pe(t=>{let n=new Set((e?.findings??[]).map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(n=>{!t||e.signal.aborted||(Oe(dJ(n,`Unable to load review findings right now.`)),Se(null),Pe(new Set))}),()=>{t=!1,e.abort()}},[y?.diff,Ft,f]),(0,X.useEffect)(()=>{v(`uncommitted`),vt.current=hJ(()=>null),yt.current=gJ(),be(mJ()),S(null),I(null),re(!1),Te([]),Ae(null),Ie(new Set),Be(null),He(!1),Ge(!1),Y(``),Je(``),Xe(``),nt([]),it(!1),lt(!1),dt(!1)},[n]),(0,X.useEffect)(()=>{if(f===`project_root`||!n||!t){Be(null),He(!1);return}let e=new AbortController,i=!0;return He(!0),It(e.signal).then(e=>{i&&(Be(e),Y(t=>t.trim()?t:e?.bundle?md(e.bundle):r),Je(t=>t.trim()?t:SJ(e?.recent_commit_subjects??Qe)),Xe(t=>t.trim()?t:e?.bundle.pull_request?.base_branch??``))}).catch(()=>{!i||e.signal.aborted||Be(null)}).finally(()=>{i&&He(!1)}),()=>{i=!1,e.abort()}},[Qe,t,It,n,f,r]),(0,X.useEffect)(()=>{if(f===`project_root`||!n||!t){S(null),I(null),re(!1);return}let e=new AbortController,r=!0;return re(!0),I(null),Lt(e.signal).then(e=>{r&&(S(e),I(null))}).catch(t=>{!r||e.signal.aborted||(I(dJ(t,`Unable to load the branch diff right now.`)),S(null))}).finally(()=>{r&&re(!1)}),()=>{r=!1,e.abort()}},[t,Lt,n,f]),(0,X.useEffect)(()=>{let e=ze?.bundle.pull_request??null;if(f===`project_root`||!n||!t||!p||!e){Te([]),Ae(null),Ie(new Set);return}let r=new AbortController,i=!0;return Ae(null),Rt(r.signal).then(e=>{!i||!e||(Te(e.comments),Ae(e.error),Ie(t=>{let n=new Set(e.comments.map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(e=>{!i||r.signal.aborted||(Te([]),Ae(dJ(e,`Unable to load GitHub review comments right now.`)),Ie(new Set))}),()=>{i=!1,r.abort()}},[ze?.bundle.pull_request,p,t,Rt,n,f]),(0,X.useEffect)(()=>{ae&&C===null||ft.current?.focus()},[C,ae]);let Qt=(0,X.useMemo)(()=>{let e=typeof y?.diff==`string`?y.diff:``;return e.trim()?Jm(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:oJ(e)})):[]},[y]),$t=(0,X.useMemo)(()=>{let e=typeof x?.diff==`string`?x.diff:``;return e.trim()?Jm(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:oJ(e)})):[]},[x]),en=(0,X.useMemo)(()=>{let e=y?.diff??``;return e?_J(e):null},[y?.diff]),tn=(0,X.useMemo)(()=>{let e=x?.diff??``;return e?_J(e):null},[x?.diff]),nn=_===`bundle_diff`?x:y,rn=_===`bundle_diff`?$t:Qt,an=(0,X.useMemo)(()=>n?{uncommitted:fJ(n,`uncommitted`),bundle_diff:fJ(n,`bundle_diff`)}:{uncommitted:null,bundle_diff:null},[n]),on=(0,X.useMemo)(()=>({uncommitted:en,bundle_diff:tn}),[tn,en]),sn=(0,X.useMemo)(()=>{let e=new Map;for(let t of nn?.files??[])e.set(t.path,t);return e},[nn]),cn=(0,X.useMemo)(()=>{let e=new Map;for(let t of rn)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[rn]),ln=(0,X.useCallback)(e=>{ve(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),un=(0,X.useMemo)(()=>_===`bundle_diff`?(x?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})):C?(C.files??[]).map(e=>{let t=sn.get(e.path)??(e.original_path?sn.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(y?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})),[_,x?.files,sn,y?.files,C]);(0,X.useEffect)(()=>{k!==`all`&&(un.some(e=>e.path===k)||A(`all`))},[k,un]);let dn=_===`bundle_diff`?0:D.size,fn=_===`bundle_diff`?un.length:C?.files?.length??un.length,pn=fn>0&&dn===fn,mn=(0,X.useMemo)(()=>_===`bundle_diff`?null:iJ(C,D),[_,C,D]),hn=_===`uncommitted`&&!ae&&!le&&l&&!!C&&dn>0&&j.trim().length>0&&mn===null,gn=_===`uncommitted`&&!ae&&!B&&!W&&!le&&!G&&l&&!Le&&!!C&&dn>0,_n=!ae&&(G||!!C?.can_push&&(C?.ahead??0)>0),vn=_n&&l&&!G&&!le,yn=l&&!se&&!K&&!le&&!G&&(T?.length??0)>0,bn=(C?.ahead??0)>0?`${C?.ahead??0} to push`:`Up to date`,xn=(C?.behind??0)>0?`${C?.behind??0} behind`:`In sync`,Sn=C?.branch??null,Cn=k===`all`?null:cn.get(k)??null,wn=(0,X.useMemo)(()=>k===`all`?rn:Cn?[Cn]:[],[rn,k,Cn]);(0,X.useEffect)(()=>{ge(new Map),ve(nJ)},[_,rn]),(0,X.useEffect)(()=>{let e={uncommitted:an.uncommitted&&on.uncommitted?`${an.uncommitted}:${on.uncommitted}`:null,bundle_diff:an.bundle_diff&&on.bundle_diff?`${an.bundle_diff}:${on.bundle_diff}`:null};vt.current.uncommitted===e.uncommitted&&vt.current.bundle_diff===e.bundle_diff||(vt.current=e,yt.current=gJ(),be(e=>{let t={...e};return[`uncommitted`,`bundle_diff`].forEach(e=>{let n=on[e],r=an[e];if(!n){t[e]=pJ();return}let i=new Map;if(r){let t=window.localStorage.getItem(r),a=t?yJ(t):null;a?.diffSignature===n?i=bJ(a.comments.map(t=>({...t,scope:e}))):t!==null&&window.localStorage.removeItem(r)}t[e]={activeTarget:null,editingCommentKey:null,draftInput:``,comments:i,signature:n}}),t}))},[on,an]),(0,X.useEffect)(()=>{[`uncommitted`,`bundle_diff`].forEach(e=>{let t=an[e],n=on[e],r=ye[e];if(!t||!n||r.signature!==n)return;if(r.comments.size===0){window.localStorage.removeItem(t);return}let i={diffSignature:n,comments:[...r.comments.values()]};window.localStorage.setItem(t,JSON.stringify(i))})},[on,an,ye]),(0,X.useEffect)(()=>{if(rn.length===0)return;let e=!1,t=null,n=(()=>{if(!Cn){let e=[],t=new Set;for(let n of _e){let r=cn.get(n);if(!r)continue;let i=sJ(r);t.has(i)||(t.add(i),e.push(r))}return e.length>0?e:rn.slice(0,Zq)}return[Cn]})(),r=0,i=()=>{if(e)return;let a=n.slice(r,r+Zq);a.length!==0&&(ge(e=>{let t=new Map(e);for(let e of a){let n=sJ(e);t.has(n)||t.set(n,uJ(e))}return t}),r+=Zq,r<n.length&&(t=window.setTimeout(i,0)))};return n.length<=Zq?i():t=window.setTimeout(i,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[rn,cn,Cn,_e]);let Tn=(0,X.useMemo)(()=>wn.map(e=>({...e,tokens:he.get(sJ(e))??null})),[he,wn]),En=(0,X.useMemo)(()=>rn.map(e=>({...e,tokens:null})),[rn]),Dn=(0,X.useMemo)(()=>{let e=new Map;for(let t of rn){let n=sJ(t);e.set(n,n);for(let r of oJ(t))e.set(r,n)}return e},[rn]),On=(0,X.useMemo)(()=>[...ye.uncommitted.comments.values()],[ye.uncommitted.comments]),kn=(0,X.useMemo)(()=>[...ye.bundle_diff.comments.values()],[ye.bundle_diff.comments]),An=ye[_],jn=An.activeTarget,Mn=An.editingCommentKey,Nn=jn?.commentKey??Mn,Pn=Nn?`${_}:${Nn}`:_,Fn=Nn?yt.current[_].get(Nn)??An.draftInput:An.draftInput,In=_===`bundle_diff`?kn:On,Ln=(0,X.useMemo)(()=>[...On,...kn],[kn,On]),Rn=(0,X.useMemo)(()=>xe?.findings??[],[xe]),zn=(0,X.useMemo)(()=>xe?.is_current_diff?Rn.filter(e=>Me.has(e.id)):[],[Rn,xe?.is_current_diff,Me]),Bn=(0,X.useMemo)(()=>[...Me],[Me]),Vn=(0,X.useMemo)(()=>we.filter(e=>Fe.has(e.id)),[we,Fe]),Hn=(0,X.useMemo)(()=>[...Fe],[Fe]),Un=Ln.length+zn.length+Vn.length,Wn=!!(xe?.review_run&&Rn.length>0&&!xe.is_current_diff),Gn=ze?.bundle.pull_request??null,Kn=(0,X.useMemo)(()=>Qe.length>0?Qe:ze?.recent_commit_subjects??[],[ze?.recent_commit_subjects,Qe]),qn=ze?.has_helper_model===!0,Jn=f!==`project_root`&&!!n&&!!t,Yn=_===`bundle_diff`?F:N,Xn=B&&y===null,Zn=ne&&x===null,Qn=ae&&C===null,$n=Ve&&ze===null,er=_===`bundle_diff`?Zn:Xn,tr=_===`uncommitted`?Rn:eJ,nr=_===`uncommitted`?Bn:nJ,rr=_===`bundle_diff`?we:tJ,ir=_===`bundle_diff`?Hn:nJ,ar=_===`bundle_diff`?`bundle_diff`:`uncommitted`,or=(0,X.useMemo)(()=>{let e=new Map,t=e=>e?Dn.get(e)??e:null;for(let n of In){let r=t(n.filePath);r&&xJ(e,r)}if(_===`uncommitted`){if(Wn)return e;for(let n of Rn){let r=t(n.file_path);r&&xJ(e,r)}return e}for(let n of we){let r=t(n.file_path);r&&xJ(e,r)}return e},[_,Dn,In,we,Wn,Rn]),sr=(Wn?0:Rn.length)+On.length,cr=we.length+kn.length,lr=_===`bundle_diff`?`No branch diff to show.`:`No uncommitted changes to show.`,ur=_===`uncommitted`&&(x?.files.length??0)>0?`Switch to Branch diff to review the full branch diff.`:null,dr=Jn&&!$n&&!!ze&&ze?.bundle.kind!==`project_root`&&C?.has_upstream===!0&&p,fr=dr&&!Gn&&!rt&&!at&&!ut&&!Le&&!G&&!le&&!K&&(C?.ahead??0)===0&&!!C?.branch,pr=(0,X.useCallback)(e=>{if(!e){Ge(!1);return}if(!t||!n||!dr||Gn||at){Ge(e);return}lt(!0),tt(t,n).then(e=>{Be(e),Xe(t=>t.trim()?t:e.bundle.pull_request?.base_branch??``),Ge(!e.bundle.pull_request)}).catch(e=>{Q.error(dJ(e,`Unable to check for an existing pull request right now.`),{id:`ticket-changes-sync-pr-error`}),Ge(!0)}).finally(()=>{lt(!1)})},[Gn,at,t,n,dr]),mr=(0,X.useMemo)(()=>{if(dr)return(C?.ahead??0)>0?`Push the branch before creating a pull request.`:C?.branch?d:`Bundle branch information is not available right now.`},[d,C?.ahead,C?.branch,dr]),hr=c&&!er&&(_===`bundle_diff`||!Qn)&&!le&&!G&&!K,gr=jn?hr||An.comments.has(jn.commentKey):hr,_r=!!a&&o&&Un>0&&!Le,vr=(0,X.useCallback)(e=>{Pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),yr=(0,X.useCallback)(e=>{Ie(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),br=(0,X.useCallback)(()=>{yt.current=gJ(),be(e=>({uncommitted:{...e.uncommitted,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map},bundle_diff:{...e.bundle_diff,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map}}))},[]),xr=(0,X.useCallback)(()=>{br(),Pe(new Set),Ie(new Set)},[br]),Sr=(0,X.useCallback)(async()=>{if(!(!t||!n||!fr)){it(!0);try{let e=await $e(t,n,{title:Ke.trim(),body:qe.trim(),base_branch:Ye.trim()||null});Be(e),Xe(e.bundle.pull_request?.base_branch??Ye.trim()),Ge(!1),Q.success(`Pull request created.`,{id:`ticket-changes-create-pr-success`})}catch(e){Q.error(dJ(e,`Unable to create the pull request right now.`),{id:`ticket-changes-create-pr-error`})}finally{it(!1)}}},[fr,t,Ye,qe,Ke,n]),Cr=(0,X.useCallback)(async()=>{if(!(!t||!n||!dr||ut)){dt(!0);try{Je((await Bt({title:Ke.trim(),commit_subjects:Kn})).description)}catch(e){Q.error(dJ(e,`Unable to generate the pull request description right now.`),{id:`ticket-changes-generate-pr-description-error`})}finally{dt(!1)}}},[ut,t,Kn,Ke,Bt,n,dr]),wr=(0,X.useCallback)(({filePath:e,changeKey:t,commentKey:n})=>{let r=An.comments.get(n),i=yt.current[_].get(n)??r?.comment??``;if(r){A(r.filePath),zt(_,e=>({...e,activeTarget:null,editingCommentKey:n,draftInput:i}));return}hr&&zt(_,r=>({...r,activeTarget:{filePath:e,changeKey:t,commentKey:n},editingCommentKey:null,draftInput:i}))},[_,An.comments,hr,zt]),Tr=(0,X.useCallback)(()=>{Nn&&yt.current[_].delete(Nn),zt(_,e=>({...e,activeTarget:null,editingCommentKey:null,draftInput:``}))},[_,Nn,zt]),Er=(0,X.useCallback)(e=>{Nn&&yt.current[_].set(Nn,e)},[_,Nn]),Dr=(0,X.useCallback)((e,t)=>{let n=An.comments.has(e.commentKey);if(!hr&&!n)return;let r=t.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;zt(_,t=>{let n=new Map(t.comments);return n.set(e.commentKey,{scope:_,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:mb(e.hunk,e.change),comment:r}),{...t,activeTarget:null,editingCommentKey:null,draftInput:``,comments:n}}),yt.current[_].delete(e.commentKey)},[_,An.comments,hr,zt]),Or=(0,X.useCallback)(e=>{let t=An.comments.get(e);if(!t)return;A(t.filePath);let n=yt.current[_].get(e)??t.comment;zt(_,t=>({...t,activeTarget:null,editingCommentKey:e,draftInput:n}))},[_,An.comments,zt]),kr=(0,X.useCallback)(e=>{yt.current[_].delete(e),zt(_,t=>{let n=new Map(t.comments);return n.delete(e),{...t,activeTarget:t.activeTarget?.commentKey===e?null:t.activeTarget,editingCommentKey:t.editingCommentKey===e?null:t.editingCommentKey,draftInput:t.activeTarget?.commentKey===e||t.editingCommentKey===e?``:t.draftInput,comments:n}})},[_,zt]),Ar=(0,X.useCallback)(async()=>{if(!a||!_r)return;Re(!0);let e=Cb({drafts:Ln,findings:zn,githubComments:Vn,uncommittedFiles:Qt,bundleFiles:$t});try{await a(e),br(),Pe(new Set),Ie(new Set),Se(e=>e&&{...e,findings:[],is_current_diff:!1}),Q.success(`Fixes submitted.`,{id:`ticket-diff-review-submit-success`}),i()}catch(e){Q.error(dJ(e,`Unable to submit the review right now.`),{id:`ticket-diff-review-submit-error`})}finally{Re(!1)}},[Ln,$t,_r,br,i,a,Vn,zn,Qt]),jr=(0,X.useCallback)(()=>{if(_===`bundle_diff`){Yt();return}Xt(()=>!0,{allowCache:!1,resetSelection:!pt.current})},[_,Yt,Xt]),Mr=(0,X.useMemo)(()=>a?(0,Z.jsx)(kG,{reviewComments:Ln,reviewFindings:zn,githubComments:Vn,pendingFixCount:Un,canSendReview:_r,isSubmittingReview:Le,reviewSubmitDisabledReason:s,onClearPendingFixes:xr,onSubmitReview:()=>{Ar()}}):null,[Ln,_r,xr,Ar,Le,a,Un,s,Vn,zn]),Nr=e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Pr=()=>{C&&O(pn?new Set:rJ(C.files))},Fr=async()=>{if(hn){ue(!0);try{let e=await Vt({message:j.trim(),selected_paths:[...D]});e.ticket&&h?.(e.ticket),qt(e.git_status,{resetSelection:!0}),M(``),f===`project_root`&&BK(t),m&&g?.(m),await Jt({preserveContent:!0,gitStatusForCache:e.git_status}),await Yt({preserveContent:!0}),(e.git_status.ahead??0)>0?await Gt(()=>!0):Kt(),Q.success(`Commit created.`,{id:`ticket-git-commit-success`})}catch(e){Q.error(dJ(e,`Unable to create the commit right now.`),{id:`ticket-git-commit-error`})}finally{ue(!1)}}},Ir=async()=>{if(gn){de(!0);try{M((await Ht({selected_paths:[...D]})).message),ft.current?.focus()}catch(e){Q.error(dJ(e,`Unable to generate a commit message right now.`),{id:`ticket-git-commit-message-error`})}finally{de(!1)}}},Lr=async()=>{if(vn){fe(!0);try{let e=T.map(e=>e.subject.trim()).filter(Boolean),r=await Ut();if(r.ticket&&h?.(r.ticket),qt(r.git_status,{resetSelection:!0}),jt(r.git_status),nt(e),Kt(),f===`project_root`&&BK(t),m&&g?.(m),Q.success(r.git_status.ahead===0?`Branch pushed.`:`Push completed.`,{id:`ticket-git-push-success`}),r.git_status.ahead===0)if(f!==`project_root`&&t&&n)try{let r=await Ze(t,n);Be(r),Y(e=>e.trim()?e:md(r.bundle)),Je(t=>t.trim()?t:SJ(e)),Xe(e=>e.trim()?e:r.bundle.pull_request?.base_branch??``)}catch{}else i()}catch(e){Q.error(dJ(e,`Unable to push the branch right now.`),{id:`ticket-git-push-error`})}finally{fe(!1)}}},Rr=async()=>{if(yn){q(!0);try{let e=await Wt();e.ticket&&h?.(e.ticket),qt(e.git_status,{resetSelection:!0}),E(e.commits),z(null),H(!1),f===`project_root`&&BK(t),m&&g?.(m),await Jt({preserveContent:!0,gitStatusForCache:e.git_status}),await Yt({preserveContent:!0}),Q.success(`Latest local commit undone.`,{id:`ticket-git-undo-success`})}catch(e){Q.error(dJ(e,`Unable to undo the latest local commit right now.`),{id:`ticket-git-undo-error`})}finally{q(!1)}}};return(0,Z.jsx)(Ce,{onClose:i,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-[92vh] w-full max-w-none flex-col overflow-hidden rounded-2xl border border-border bg-card p-6 shadow-2xl`,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[G&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-2xl bg-black/45 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-border bg-card/95 px-4 py-3 text-sm text-foreground shadow-xl`,children:[(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{children:`Pushing branch...`})]})}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Changes`}),Sn?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`h2`,{className:`max-w-full truncate font-mono text-lg font-semibold text-foreground`,children:Sn}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(J,{variant:(C?.ahead??0)>0?`info`:`outline`,children:bn}),(0,Z.jsx)(J,{variant:(C?.behind??0)>0?`warning`:`outline`,children:xn}),(0,Z.jsx)(J,{variant:C?.is_dirty?`warning`:`success`,children:C?.is_dirty?`Dirty`:`Clean`})]})]}):(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-7 w-56 animate-pulse rounded-md bg-muted/70`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-6 w-32 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 text-xs text-muted-foreground`,children:[(Gn||dr)&&(0,Z.jsx)(CJ,{pullRequest:Gn,isLoading:$n,isOpen:Ue,canCreate:fr,disabledReason:mr,isCreating:rt,isSyncing:at,isGeneratingDescription:ut,title:Ke,body:qe,baseBranch:Ye,onOpenChange:pr,onTitleChange:Y,onBodyChange:Je,onBaseBranchChange:Xe,showGenerateDescription:qn,onGenerateDescription:()=>{Cr()},onCreate:()=>{Sr()}}),(0,Z.jsx)(jG,{isCommitsLoading:se,commitsError:ee,unpushedCommits:T,canUndoLatestCommit:yn,isUndoing:K,aheadCount:C?.ahead??0,onUndoLatestCommit:()=>{Rr()}}),_n&&(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Lr()},disabled:!vn,title:d,className:`gap-2`,children:[G?(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(xu,{className:`h-4 w-4`}),G?`Pushing...`:`Push branch`]}),e]})]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-changes-layout`,className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)] xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`flex min-h-0 flex-col`,children:[Jn&&(0,Z.jsxs)(CG,{type:`single`,size:`sm`,variant:`outline`,value:_,onValueChange:e=>{(e===`uncommitted`||e===`bundle_diff`)&&v(e)},className:`mb-3 self-start`,children:[(0,Z.jsxs)(wG,{value:`uncommitted`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Uncommitted`}),sr>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`,children:sr})]}),(0,Z.jsxs)(wG,{value:`bundle_diff`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Branch diff`}),cr>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`,children:cr})]})]}),(0,Z.jsx)(EK,{selectionWarning:_===`uncommitted`?mn:null,gitError:_===`uncommitted`?L:F,sidebarFiles:un,commentCountByPath:or,commentCountTone:ar,isGitStatusLoading:_===`bundle_diff`?Zn:Qn,selectedPaths:D,selectedDiffPath:k,allFilesSelected:pn,diffStats:nn?.stats??null,title:_===`bundle_diff`?`Branch diff files`:`Changed files`,allChangesDescription:_===`bundle_diff`?`Review the full branch diff against the review base.`:`Review the full workspace diff.`,enableSelection:_===`uncommitted`,onToggleSelectAll:Pr,onSelectDiffPath:A,onTogglePath:Nr})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,Z.jsx)(xK,{selectedDiffPath:k,sidebarFiles:un,diffResponse:nn,isDiffLoading:er,diffError:Yn,allDiffFiles:En,renderedFiles:Tn,viewType:pe,onViewTypeChange:me,onRetry:jr,activeReviewTarget:jn,editingReviewCommentKey:Mn,reviewDraftInstanceKey:Pn,reviewDraftInput:Fn,reviewComments:In,reviewFindings:tr,githubComments:rr,selectedReviewFindingIds:nr,selectedGitHubCommentIds:ir,canSelectReviewTarget:hr,canEditActiveReviewDraft:gr,reviewFindingsError:_===`uncommitted`?De:null,gitHubCommentsError:_===`bundle_diff`?ke:null,hasStaleReviewFindings:_===`uncommitted`?Wn:!1,onSelectReviewTarget:wr,onToggleReviewFindingSelection:vr,onToggleGitHubCommentSelection:yr,onReviewDraftInputChange:Er,onCancelReviewDraft:Tr,onEditReviewDraft:Or,onRemoveReviewDraft:kr,onSaveReviewDraft:Dr,diffThemeClassName:DK,resolveFilePath:sJ,normalizeDiffPath:aJ,onVisibleFilePathsChange:ln,emptyStateTitle:lr,emptyStateDescription:ur,reviewSummaryControl:Mr,headerLayout:`inline-controls`}),_===`uncommitted`&&(0,Z.jsx)(`div`,{className:`mt-auto shrink-0`,children:(0,Z.jsx)(AG,{commitMessage:j,onCommitMessageChange:M,commitMessageRef:ft,selectedFileCount:dn,changesDisabledReason:d,canEditCommitMessage:l&&!Le,canGenerateCommitMessage:gn,canCommit:hn,isGeneratingCommitMessage:W,isCommitting:le,onGenerateCommitMessage:()=>{Ir()},onCommit:()=>{Fr()}})})]})]})]})]})})},EJ={blocked:{className:`stroke-red-400/80`,markerId:`dependency-arrowhead-blocked`},ready:{className:`stroke-emerald-400/80`,markerId:`dependency-arrowhead-ready`},preview:{className:`stroke-amber-300/80`,markerId:`dependency-arrowhead-preview`}},DJ=e=>$w(e)?`ready`:`blocked`,OJ=180,kJ=560,AJ=88,jJ=12,MJ=18,NJ=(e,t,n)=>Math.min(Math.max(e,t),n),PJ=(e,t,n)=>n&&n.width>0&&n.height>0?n:Object.values(e).reduce((e,t)=>({width:Math.max(e.width,t.left+t.width),height:Math.max(e.height,t.top+t.height)}),{width:t.x,height:t.y}),FJ=(e,t)=>{let n=NJ(Math.round(e.length*7.2)+24,OJ,kJ),r=Math.max(OJ,t-jJ*2);return Math.min(n,r)},IJ=(e,t,n,r,i)=>{let a=n.get(e.blockerTicketId);if(!a)return null;let o=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?r[e.hoveredTicketId]:null,s=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?n.get(e.hoveredTicketId):null,c=s?`${a.title} is blocking ${s.title}`:`${a.title} is blocking...`,{start:l,end:u}=sT(t,o??{left:e.pointer.x,top:e.pointer.y,width:0,height:0}),d=PJ(r,e.pointer,i),f=o&&s?{x:l.x+(u.x-l.x)*.6,y:l.y+(u.y-l.y)*.6-28}:{x:u.x,y:u.y-28},p=FJ(c,d.width);return{text:c,x:o&&s?NJ(f.x-p/2,jJ,Math.max(jJ,d.width-p-jJ)):(()=>{let e=f.x+MJ,t=f.x-MJ-p;return e+p<=d.width-jJ?e:t>=jJ?t:NJ(e,jJ,Math.max(jJ,d.width-p-jJ))})(),y:NJ(f.y,jJ,Math.max(jJ,d.height-AJ-jJ)),width:p}},LJ=({blockerRect:e,dependentRect:t,className:n,testId:r,markerEnd:i})=>{let{start:a,end:o}=sT(e,t),{path:s}=cT(a,o);return(0,Z.jsx)(`g`,{"data-testid":r,children:(0,Z.jsx)(`path`,{d:s,className:n,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,markerEnd:i})})},RJ=({preview:e,cardRects:t,ticketsById:n,overlaySize:r})=>{if(!e)return null;let i=t[e.blockerTicketId];if(!i)return null;let a=(e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId&&t[e.hoveredTicketId]?t[e.hoveredTicketId]:null)??{left:e.pointer.x,top:e.pointer.y,width:0,height:0},o=IJ(e,i,n,t,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(LJ,{blockerRect:i,dependentRect:a,className:EJ.preview.className,testId:`dependency-preview`,markerEnd:`url(#${EJ.preview.markerId})`}),(e=>o?(0,Z.jsx)(`foreignObject`,{x:o.x,y:o.y,width:o.width,height:AJ,"data-testid":`dependency-preview-label`,children:e}):null)((0,Z.jsx)(`div`,{className:`pointer-events-none flex h-full w-full items-start`,children:(0,Z.jsx)(`div`,{className:`max-w-full rounded-md border border-amber-300/60 bg-stone-950/85 px-3 py-1.5 text-xs font-medium leading-5 text-amber-100 shadow-lg shadow-stone-950/20 whitespace-normal break-words`,children:o?.text})}))]})},zJ=({dependencies:e,cardRects:t,preview:n,ticketsById:r,overlaySize:i})=>(0,Z.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 z-10 h-full w-full overflow-visible`,children:[(0,Z.jsx)(`defs`,{children:Object.values(EJ).map(e=>(0,Z.jsx)(`marker`,{id:e.markerId,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,markerUnits:`userSpaceOnUse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8`,className:e.className,fill:`none`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})},e.markerId))}),e.map(e=>{let n=r.get(e.blocker_ticket_id),i=r.get(e.dependent_ticket_id),a=t[e.blocker_ticket_id],o=t[e.dependent_ticket_id];if(n?.parked_at||i?.parked_at)return null;let s=EJ[DJ(n)];return!a||!o?null:(0,Z.jsx)(LJ,{blockerRect:a,dependentRect:o,className:s.className,testId:`dependency-edge-${e.blocker_ticket_id}-${e.dependent_ticket_id}`,markerEnd:`url(#${s.markerId})`},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`)}),(0,Z.jsx)(RJ,{preview:n,cardRects:t,ticketsById:r,overlaySize:i})]}),BJ=({onSubmit:e,bundles:t,projectId:n=null,projectBranchState:r=null,tool:i,showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialModel:c=``,initialVariant:l=``,initialSkills:u=[],onCreateBundle:d,onDeleteBundle:f,onRefreshBundles:p,onClose:m})=>{let{jiraImportState:h,importFromJira:g}=Ef(n);return(0,Z.jsx)(Ce,{onClose:m,overlayClassName:`bg-black/60`,panelClassName:`h-[92vh] w-[96vw] max-w-6xl overflow-y-auto rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,renderContent:({closeButton:_})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:_}),(0,Z.jsx)($N,{heading:`New Ticket`,bundles:t,showModelSelector:a,availableModels:o,availableSkills:s,projectId:n,initialModel:c,initialVariant:l,initialSkills:u,projectBranchState:r,jiraImportState:h,onImportFromJira:g,onCancel:m,onCreateBundle:d,onDeleteBundle:f,onRefreshBundles:p,titleInputId:`title`,descriptionInputId:`description`,bundleSelectId:`new-ticket-bundle`,modelSelectId:`new-model`,variantSelectId:`new-variant`,skillsSelectId:`new-skills`,showEmptyBundleOption:!0,planAction:i?{label:`Plan`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`plan`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}}:void 0,primaryAction:{label:`Create Ticket`,variant:`subtle`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`create`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}},secondaryAction:{label:`Create & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`build`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}}})]})})},VJ=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},HJ=e=>e.status===`error`?`border-red-500/35 bg-red-500/10`:e.status===`done`?e.boardState===`fading`?`border-emerald-500/25 bg-emerald-500/10 opacity-0 transition-opacity duration-700`:`border-emerald-500/35 bg-emerald-500/10`:`border-violet-500/30 bg-card/60`,UJ=({run:e})=>(0,Z.jsxs)(kd,{"data-testid":`planning-run-card-${e.id}`,className:`relative overflow-hidden rounded-xl border shadow-none ${HJ(e)}`,children:[e.status===`running`&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-0 h-1 animate-pulse bg-gradient-to-r from-violet-500/0 via-violet-300/80 to-violet-500/0`}),(0,Z.jsxs)(Pd,{className:`space-y-3 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[e.status===`running`?(0,Z.jsx)(dT,{label:`Planning...`}):e.status===`done`?(0,Z.jsx)(dT,{label:`Done`,className:`bg-emerald-500/85 text-emerald-50`}):(0,Z.jsx)(dT,{label:`Planning failed`,className:`bg-red-500/85 text-red-50`}),(0,Z.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.16em] text-muted-foreground`,children:VJ(e.submittedAt)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),e.status===`done`&&e.summary&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Created `,e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]}),e.status===`error`&&e.error&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-200`,children:e.error})]})]})]}),WJ={idle:`bg-secondary`,running:`bg-sky-400`,done:`bg-emerald-400`,error:`bg-red-400`},GJ=e=>e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`done`)?`done`:`idle`,KJ=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},qJ=({status:e})=>e===`running`?(0,Z.jsx)(dT,{label:`Planning...`,className:`px-2.5 py-0.5 text-[11px]`}):e===`done`?(0,Z.jsx)(J,{className:`bg-emerald-500/85 px-2.5 py-0.5 text-[11px] text-emerald-50`,children:`Done`}):(0,Z.jsx)(J,{className:`bg-red-500/85 px-2.5 py-0.5 text-[11px] text-red-50`,children:`Failed`}),JJ=({heading:e,runs:t})=>t.length===0?null:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:t.map(e=>(0,Z.jsx)(kd,{className:`rounded-2xl border-border bg-card/70 shadow-none`,children:(0,Z.jsxs)(Pd,{className:`space-y-2 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),(0,Z.jsx)(qJ,{status:e.status})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:KJ(e.submittedAt)}),e.summary&&(0,Z.jsxs)(`span`,{children:[e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]})]}),e.error&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-destructive/15 px-3 py-2 text-xs text-red-200`,children:e.error})]})},e.id))})]}),YJ=({projectId:e=null,state:t,bundles:n,showModelSelector:r,availableModels:i,availableSkills:a,onManageBundles:o,onToggle:s,onDescriptionChange:c,onModelChange:l,onVariantChange:u,onSkillsChange:d,onBundleChange:f,onGenerate:p})=>{let m=i.find(e=>e.id===t.composer.model)??null,{jiraImportState:h,importFromJira:g}=Ef(t.isOpen?e:null),_=(0,X.useRef)(null),v=(0,X.useRef)(t.isOpen),y=(0,X.useRef)(t.isOpen),b=GJ(t.runs),x=t.runs.filter(e=>e.status===`running`),S=t.runs.filter(e=>e.status!==`running`),C=t.composer.description.trim().length>0;(0,X.useEffect)(()=>{if(t.isOpen&&!v.current&&(y.current=!0),t.isOpen||(y.current=!1),v.current=t.isOpen,!t.isOpen||!y.current)return;let e=window.requestAnimationFrame(()=>{let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`[data-testid="planning-agent-rail"]`)!==null;if(e instanceof HTMLElement&&e!==document.body&&e!==_.current&&!t){y.current=!1;return}_.current?.focus({preventScroll:!0}),y.current=!1});return()=>{window.cancelAnimationFrame(e)}},[t.isOpen]),(0,X.useEffect)(()=>{if(!t.isOpen)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),s())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[s,t.isOpen]);let w=(0,Z.jsxs)(U,{type:`button`,"aria-label":t.isOpen?`Close planning agent`:`Open planning agent`,"aria-pressed":t.isOpen,onClick:s,variant:`outline`,className:`relative flex h-14 w-11 flex-col items-center justify-center gap-1 p-0`,children:[(0,Z.jsx)(Qd,{className:`size-5`}),(0,Z.jsx)(vw,{"aria-hidden":`true`,children:`A`}),(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-2.5 w-2.5 rounded-full ring-2 ring-card ${WJ[b]}`})]});return(0,Z.jsxs)(`aside`,{"aria-label":`Planning agent sidebar`,className:`relative z-20 h-full w-16 shrink-0 overflow-visible border-r border-border bg-background`,children:[(0,Z.jsx)(`div`,{"data-testid":`planning-agent-rail`,className:`relative z-40 flex h-full w-16 shrink-0 flex-col items-center border-r border-border bg-background py-4`,children:t.isOpen?w:(0,Z.jsx)(cu,{content:`Planning agent`,children:w})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-drawer`,"aria-hidden":!t.isOpen,inert:!t.isOpen||void 0,className:W(`absolute inset-y-0 left-16 z-30 w-[min(36rem,calc(100vw-5rem))] overflow-hidden transition-transform duration-200 ease-out motion-reduce:transition-none`,t.isOpen?`pointer-events-auto translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,Z.jsxs)(`div`,{className:`flex h-full w-[min(36rem,calc(100vw-5rem))] flex-col border-r border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-border px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Planning agent`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Turn a larger initiative into plan-stage tickets with dependencies and bundle context.`})]}),(0,Z.jsx)(U,{type:`button`,"aria-label":`Close planning agent panel`,onClick:s,variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(pe,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-scroll-body`,className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`space-y-5 px-6 py-5`,children:[(0,Z.jsx)(YN,{jiraImportState:h,onImportFromJira:g,onImported:e=>{c(e.description)},inputId:`planning-agent-jira-import`}),(0,Z.jsx)(Id,{label:`Description`,htmlFor:`planning-agent-description`,className:`gap-2`,children:(0,Z.jsx)(`div`,{className:`relative`,children:(0,Z.jsx)(sm,{ref:_,projectId:e,suggestionAnchor:`caret`,id:`planning-agent-description`,"aria-label":`Planning description`,value:t.composer.description,onValueChange:c,rows:14,className:`min-h-[18rem] resize-y text-sm leading-6`,placeholder:`Describe the task, acceptance criteria, context...`})})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(XN,{bundles:n,value:t.composer.worktreeBundleId,onChange:f,selectId:`planning-agent-bundle`,emptyLabel:`Auto-create bundle`,hideProjectRootBundles:!0,label:``})}),o&&(0,Z.jsx)(U,{type:`button`,onClick:o,variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`,children:`Manage bundles`})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:(0,Z.jsx)(KN,{model:t.composer.model,variant:t.composer.variant,skills:t.composer.skills,showModelSelector:r,showSkillsSelector:r,availableModels:i,availableSkills:a,selectedModel:m,onModelChange:l,onVariantChange:u,onSkillsChange:d,modelSelectId:`planning-agent-model`,variantSelectId:`planning-agent-variant`,skillsSelectId:`planning-agent-skills`,layout:`stacked`})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-runs`,className:`border-t border-border/80 px-0 pt-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(JJ,{heading:`Active planning runs`,runs:x}),(0,Z.jsx)(JJ,{heading:`Recent runs`,runs:S})]})})]})}),(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border px-6 py-4`,children:(0,Z.jsx)(U,{type:`button`,onClick:p,disabled:!C,className:`w-full`,children:`Plan tickets`})})]})})]})},XJ=({className:e=``})=>{let{setNodeRef:t,isOver:n}=aw({id:`trash`});return(0,Z.jsxs)(`div`,{ref:t,"data-testid":`delete-drop-zone`,className:`${e} flex min-w-[13rem] select-none items-center justify-between gap-4 rounded-2xl border px-4 py-3 backdrop-blur-sm transition-all duration-150 ${n?`scale-[1.02] border-red-400/70 bg-destructive/35 text-red-100 shadow-lg shadow-red-950/30`:`border-red-500/30 bg-background/82 text-red-200/85`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(J,{variant:`destructive`,className:`text-[11px] uppercase tracking-[0.28em]`,children:`Delete`}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:n?`Release to delete`:`Drop here to delete`})]}),(0,Z.jsx)(`div`,{className:`rounded-xl border p-2 transition-colors ${n?`border-red-400/60 bg-red-500/20`:`border-red-500/20 bg-background/60`}`,children:(0,Z.jsx)(Ld,{className:`h-5 w-5 transition-colors ${n?`text-red-100`:`text-red-300/70`}`})})]})},ZJ=(e,t)=>j(T(`/ticket-dependencies`,e),{signal:t}),QJ=(e,t)=>j(T(`/ticket-dependencies`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create the dependency right now.`}),$J=(e,t,n)=>D(T(`/ticket-dependencies/${t}/${n}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to remove the dependency right now.`}),eY=(e,t)=>{let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.left!==i.left||n.top!==i.top||n.width!==i.width||n.height!==i.height)return!1}return!0},tY=(e,t)=>e===t?!0:!e||!t?!1:e.projectId===t.projectId&&e.blockerTicketId===t.blockerTicketId&&e.hoveredTicketId===t.hoveredTicketId&&e.pointer.x===t.pointer.x&&e.pointer.y===t.pointer.y,nY=({activeProjectId:e,tickets:t,dependencies:n,setDependencies:r,activeTicket:i,activeOverlayNode:a,dragOffset:o})=>{let[s,c]=(0,X.useState)({}),[l,u]=(0,X.useState)({width:0,height:0}),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),h=(0,X.useRef)(null),g=(0,X.useRef)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(new Map),y=(0,X.useRef)({}),b=(0,X.useRef)(null),x=(0,X.useRef)(null),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useRef)(null),E=(0,X.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);(0,X.useEffect)(()=>{C.current=p},[p]),(0,X.useLayoutEffect)(()=>{if(!i||!a||!g.current)return;let e=window.requestAnimationFrame(()=>{let e=g.current?.getBoundingClientRect(),t=a.getBoundingClientRect();e&&f({ticketId:i.id,rect:{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}})});return()=>{window.cancelAnimationFrame(e)}},[a,i,o.x,o.y]);let D=(0,X.useCallback)(()=>{b.current===null&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=g.current;if(!e){_.current=null,y.current={},c({}),u({width:0,height:0});return}let t=e.getBoundingClientRect(),n={};_.current={left:t.left,top:t.top},u(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height});for(let[e,r]of v.current){let i=r.getBoundingClientRect();n[e]={left:i.left-t.left,top:i.top-t.top,width:i.width,height:i.height}}y.current=n,c(e=>eY(e,n)?e:n)}))},[]);(0,X.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{D()};return e.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[D]),(0,X.useEffect)(()=>{if(typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(()=>{D()});x.current=e;for(let t of v.current.values())e.observe(t);return()=>{e.disconnect(),x.current===e&&(x.current=null)}},[D]),(0,X.useEffect)(()=>{let e=h.current,t=g.current;if(!e&&!t)return;let n=new ResizeObserver(()=>{D()});return e&&n.observe(e),t&&t!==e&&n.observe(t),()=>{n.disconnect()}},[D]),(0,X.useEffect)(()=>(D(),()=>{b.current!==null&&(window.cancelAnimationFrame(b.current),b.current=null)}),[n,D,t]);let O=(0,X.useCallback)((e,t)=>{let n=v.current.get(e);if(t){if(n===t)return;v.current.set(e,t),x.current?.observe(t)}else{if(!n)return;v.current.delete(e),x.current?.unobserve(n)}D()},[D]),k=(0,X.useCallback)(e=>{tY(C.current,e)||(C.current=e,m(e))},[]),A=(0,X.useCallback)(()=>{w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),T.current=null},[]),j=(0,X.useCallback)(e=>{T.current=e,w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null;let e=T.current;T.current=null,k(e)}))},[k]),M=(0,X.useCallback)((e,t)=>{let n=_.current;if(!n&&g.current){let e=g.current.getBoundingClientRect();n={left:e.left,top:e.top},_.current=n}return n?{x:e-n.left,y:t-n.top}:{x:e,y:t}},[]),N=(0,X.useCallback)((e,t,n)=>{for(let[r,i]of Object.entries(y.current))if(r!==n&&e>=i.left&&e<=i.left+i.width&&t>=i.top&&t<=i.top+i.height)return r;return null},[]),P=(0,X.useCallback)(async t=>{if(e)try{await $J(e,t.blocker_ticket_id,t.dependent_ticket_id),r(e=>Yw(e,t.blocker_ticket_id,t.dependent_ticket_id))}catch(e){Q.error(e instanceof ve?e.message:`Unable to remove the dependency right now.`,{id:`board-dependency-error`})}},[e,r]),F=(0,X.useCallback)((t,i)=>{if(!e)return;i.preventDefault(),S.current?.();let a=(n,r,i=!1)=>{let a=M(n,r),o={projectId:e,blockerTicketId:t,hoveredTicketId:N(a.x,a.y,t),pointer:a};if(i){A(),k(o);return}j(o)};a(i.clientX,i.clientY,!0);let o=e=>{a(e.clientX,e.clientY)},s=async i=>{let a=M(i.clientX,i.clientY),o=N(a.x,a.y,t),s=o?Zw(n,t,o):null;if(S.current?.(),S.current=null,k(null),!(!o||!s)){if(!s.valid){Q.error(Qw(s.reason),{id:`board-dependency-error`});return}try{let n=await QJ(e,{blocker_ticket_id:t,dependent_ticket_id:o});r(e=>Jw(e,n))}catch(e){Q.error(e instanceof ve?e.message:`Unable to create the dependency right now.`,{id:`board-dependency-error`})}}};S.current=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),A()},window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0})},[e,A,n,N,M,j,r,k]);(0,X.useEffect)(()=>{S.current?.(),S.current=null,A(),C.current=null},[e,A]),(0,X.useEffect)(()=>()=>{S.current?.(),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]);let I=(0,X.useMemo)(()=>{let r=p?.blockerTicketId;if(!r||p.projectId!==e||!E.has(r))return null;let i=new Map;for(let e of t){if(e.id===r){i.set(e.id,`source`);continue}let t=Zw(n,r,e.id);i.set(e.id,t.valid?`valid`:`idle`)}return i},[e,n,p,E,t]),L=(0,X.useCallback)(e=>{if(!I||!p)return`idle`;let t=I.get(e)??`idle`;return e===p.hoveredTicketId&&t===`idle`?`invalid`:t},[I,p]),R=(0,X.useMemo)(()=>!p||p.projectId!==e||!E.has(p.blockerTicketId)?null:{blockerTicketId:p.blockerTicketId,hoveredTicketId:p.hoveredTicketId,pointer:p.pointer},[e,p,E]);return{boardViewportRef:h,boardContentRef:g,registerTicketNode:O,measuredCardRects:(0,X.useMemo)(()=>{if(!i)return s;let e=s[i.id];return e?d?.ticketId===i.id?{...s,[i.id]:d.rect}:{...s,[i.id]:{...e,left:e.left+o.x,top:e.top+o.y}}:s},[d,i,s,o.x,o.y]),overlayPreview:R,overlaySize:l,getDependencyTargetState:L,handleDependencyStart:F,handleDeleteDependency:P}},rY=e=>{if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.id==`string`?t.id:``,r=typeof t.name==`string`?t.name:``,i=typeof t.command==`string`?t.command:``,a=typeof t.cwd==`string`?t.cwd:``,o=t.runner===`vitest`||t.runner===`jest`||t.runner===`unknown`?t.runner:`auto`;return n.trim()===``||r.trim()===``&&i.trim()===``&&a.trim()===``?[]:[{id:n,name:r,command:i,cwd:a,runner:o}]}):[]}catch{return[]}},iY=`[data-terminal-pane="true"]`,aY=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||e.isContentEditable},oY=e=>e instanceof HTMLElement?e.closest(iY)!==null:!1,sY=e=>aY(e)||oY(e),cY=(e,t={})=>{let{isBlocked:n}=t;(0,X.useEffect)(()=>{let t=t=>{if(t.defaultPrevented||t.repeat)return;let r=e.find(e=>!e.disabled&&e.key.toLowerCase()===t.key.toLowerCase()&&(e.ctrlKey??!1)===t.ctrlKey&&(e.altKey??!1)===t.altKey&&(e.metaKey??!1)===t.metaKey&&(e.shiftKey===void 0||e.shiftKey===t.shiftKey));r&&(n?.(document.activeElement)||(t.preventDefault(),r.onKeyDown()))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,n])},lY=e=>({...e,messages:void 0,agent_log:void 0,streaming_response:void 0}),uY=(e,t)=>e?e.state!==t.state||e.parked_at!==t.parked_at||e.worktree_bundle_id!==t.worktree_bundle_id:!0,dY=(e,t)=>{if(!e)return t;let n=t.worktree_bundle_id!==null&&e.worktree_bundle_id===t.worktree_bundle_id,r=t.bundle??(n&&e.bundle?.id===t.worktree_bundle_id?e.bundle:null),i=t.bundle_execution_position??(n?e.bundle_execution_position??null:null);return{...e,...t,bundle:r,bundle_execution_position:i}},fY=(e,t)=>{let n=e=>Fw(t)?Fw(e):e.state===t.state&&!Fw(e),r=e.findIndex(e=>n(e));if(r===-1)return[...e,t];let i=[...e];return i.splice(r,0,t),i},pY=(e,t)=>{let n=e.find(e=>e.id===t.id);return[n&&n.pull_request!==void 0&&t.pull_request===void 0?{...n,...t,pull_request:n.pull_request}:t,...e.filter(e=>e.id!==t.id)]},mY=(e,t)=>{let n=e.find(e=>e.id===t.id);if(!n)return[...e,t];let r=dY(n,t);return e.map(e=>e.id===t.id?r:e)},hY=(e,t)=>{let n=dY(e.find(e=>e.id===t.id),t);return fY(_Y(e,t.id),n)},gY=(e,t)=>{if(e.length===0)return[...t];let n=[...e];for(let e of t)n=uY(n.find(t=>t.id===e.id),e)?hY(n,e):mY(n,e);let r=new Set(t.map(e=>e.id));return n.filter(e=>r.has(e.id))},_Y=(e,t)=>e.filter(e=>e.id!==t),vY=(e,t,n,r={},i={})=>{let a=e.findIndex(e=>e.id===t);if(a===-1)return e;let o={...e[a],state:n,...r},s=_Y(e,t);if(i.preferredIndex!==void 0){let e=Math.max(0,Math.min(i.preferredIndex,s.length));return s.splice(e,0,o),s}return fY(s,o)},yY=async(e,t)=>{`Notification`in window&&Notification.permission!==`denied`&&(Notification.permission===`default`&&await Notification.requestPermission(),Notification.permission===`granted`&&new Notification(e,{body:t}))},bY=(0,X.createContext)(null),xY=15*1e3,SY=1e3,CY=async e=>yY(`Ticket done`,e),wY=e=>lY(e),TY=(e,t)=>t===`running`&&e.agent_status===`done`?`Finished ${e.state} for "${e.title}"`:t===`running`&&e.agent_status===`error`?`Failed ${e.state} for "${e.title}"`:t!==`running`&&e.agent_status===`running`?`Running ${e.state} for "${e.title}"`:null,EY=({activeProjectId:e,refreshKey:t=0,onLoadedProjectIdChange:n,onProjectUsageChange:r,onBundlesChange:i,onBundlesLoadingChange:a,children:o})=>{let[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)([]),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),C=(0,X.useRef)(0),w=(0,X.useRef)(0),T=(0,X.useRef)(new Map),E=(0,X.useRef)(new Map),D=(0,X.useRef)(e),O=(0,X.useRef)(new Map),k=(0,X.useRef)(new Map),A=(0,X.useRef)(new Map),j=(0,X.useCallback)((e,t)=>{let n=k.current.get(t.id);return!n||!e||t.state===n?t:e},[]),M=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(k.current);for(let r of e)n.set(r,t);k.current=n},[]),N=(0,X.useCallback)(e=>{if(e.length===0||k.current.size===0)return;let t=new Map(k.current);for(let n of e)t.delete(n);k.current=t},[]),P=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(A.current);for(let r of e)n.set(r,t);A.current=n},[]),F=(0,X.useCallback)(e=>{if(e.length===0||A.current.size===0)return;let t=new Map(A.current);for(let n of e)t.delete(n);A.current=t},[]),I=(0,X.useCallback)((e,t)=>{if(O.current.has(t.id))return null;let n=j(e,t);return A.current.has(t.id)?{...n,parked_at:A.current.get(t.id)??null}:n},[j]),L=(0,X.useCallback)((e,t)=>{if(O.current.size===0&&k.current.size===0&&A.current.size===0)return t;let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=I(n.get(e.id),e);return t?[t]:[]})},[I]),R=(0,X.useCallback)(async(e,t)=>{let n=await gt(e,t,{detail:`board`});return Array.isArray(n)?(!t?.aborted&&D.current===e&&c(e=>gY(e,L(e,n).map(wY))),n):null},[L]),ee=(0,X.useCallback)(async(e,t)=>{await R(e,t)},[R]),z=(0,X.useCallback)(async(e,t)=>{let n=++w.current,r=await _t(e,t);if(!Array.isArray(r)||t?.aborted||D.current!==e||w.current!==n)return;let i=new Map(r.map(e=>[e.id,e]));c(e=>e.map(e=>{let t=i.get(e.id);return t?{...e,diff_stats:t.diff_stats??null,is_stale:t.is_stale}:e}))},[]),B=(0,X.useCallback)(e=>e.some(e=>e.is_stale===void 0),[]),V=(0,X.useCallback)(async e=>{let t=D.current;if(!t)return null;try{let n=await vt(e,t);if(D.current!==t)return null;let r=E.current.get(n.id),i=I(r,n);if(!i)return null;let a=wY(i),o=uY(r,a);return c(e=>o?hY(e,a):mY(e,a)),n}catch{return null}},[I]),te=(0,X.useCallback)(async t=>{if(!e){f([]);return}f(await Ye(e,t))},[e]),ne=(0,X.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),re=(0,X.useMemo)(()=>{let e=s.filter(e=>e.agent_status===`running`),t=new Set(e.map(e=>e.worktree_bundle_id).filter(e=>typeof e==`string`&&e.trim().length>0));return{total_running:e.length,running_plan_count:e.filter(e=>e.state===`plan`).length,running_build_count:e.filter(e=>e.state===`build`).length,running_review_count:e.filter(e=>e.state===`review`).length,active_bundle_count:t.size,latest_message:x}},[x,s]);(0,X.useEffect)(()=>{E.current=ne},[ne]),(0,X.useEffect)(()=>{D.current=e,O.current.clear(),k.current.clear(),A.current.clear(),S(null),m(null),T.current.clear()},[e]),(0,X.useEffect)(()=>{n?.(_?null:h)},[h,_,n]),(0,X.useEffect)(()=>{if(i){if(!e){i(null,[]);return}if(h!==e){i(e,[]);return}i(e,d)}},[e,d,h,i]),(0,X.useEffect)(()=>{if(a){if(!e){a(null,!1);return}a(e,y===e)}},[e,y,a]),(0,X.useEffect)(()=>{let t=new AbortController,n=++C.current,r=null,i=async()=>{try{if(!e){c([]),u([]),f([]),g(null),v(null);return}c([]),u([]),f([]),g(null),v(e),b(e);let[n,i,a]=await Promise.allSettled([R(e,t.signal),ZJ(e,t.signal),Ye(e,t.signal)]);if(t.signal.aborted)return;n.status!==`fulfilled`&&!ge(n.reason)&&c([]),i.status===`fulfilled`?u(i.value):ge(i.reason)||u([]),a.status===`fulfilled`?f(a.value):ge(a.reason)||f([]),g(n.status===`fulfilled`&&i.status===`fulfilled`&&a.status===`fulfilled`?e:null),n.status===`fulfilled`&&n.value!==null&&B(n.value)&&(r=window.setTimeout(()=>{t.signal.aborted||z(e,t.signal)},SY))}finally{!t.signal.aborted&&C.current===n&&(v(null),b(null))}},a=t=>{t.project_id===e&&(m(t),!O.current.has(t.id)&&(t.bundle&&f(e=>pY(e,t.bundle)),c(e=>hY(e,wY(t)))))},o=t=>{if(t.project_id===e&&m(t),c(n=>{if(t.project_id!==e)return _Y(n,t.id);let r=n.find(e=>e.id===t.id),i=I(r,t);if(!i)return n;let a=wY(i);return uY(r,a)?hY(n,a):mY(n,a)}),t.project_id!==e){u(e=>qw(e,t.id));return}t.bundle&&f(e=>pY(e,t.bundle))},s=({id:e})=>{O.current.delete(e),A.current.delete(e),k.current.delete(e),c(t=>_Y(t,e)),u(t=>qw(t,e))},l=e=>{if(!e)return;let t=E.current.get(e.blocker_ticket_id),n=E.current.get(e.dependent_ticket_id);!t||!n||t.project_id!==D.current||n.project_id!==D.current||u(t=>Jw(t,e))},d=e=>{u(t=>Yw(t,e.blocker_ticket_id,e.dependent_ticket_id))};return i(),PW.on(`ticket:created`,a),PW.on(`ticket:updated`,o),PW.on(`ticket:deleted`,s),PW.on(`ticket-dependency:created`,l),PW.on(`ticket-dependency:deleted`,d),()=>{t.abort(),r!==null&&window.clearTimeout(r),PW.off(`ticket:created`,a),PW.off(`ticket:updated`,o),PW.off(`ticket:deleted`,s),PW.off(`ticket-dependency:created`,l),PW.off(`ticket-dependency:deleted`,d)}},[e,z,t,B,R,I]),(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController,n=()=>{document.visibilityState===`visible`&&Promise.allSettled([R(e,t.signal),te(t.signal)]).then(n=>{n[0]?.status===`fulfilled`&&n[0].value!==null&&B(n[0].value)&&z(e,t.signal)}).catch(()=>{})},r=window.setInterval(n,xY),i=UK(n);return()=>{t.abort(),window.clearInterval(r),i()}},[e,te,z,B,R]),(0,X.useEffect)(()=>{if(!e||!r||h!==e)return;let t=s.filter(e=>{let t=e.bundle?.branch??e.branch;return typeof t==`string`&&t.trim()!==``}).length;r({projectId:e,ticketCount:s.length,worktreeCount:t,repoPathLocked:s.length>0||t>0||d.length>0})},[e,d.length,h,r,s]),(0,X.useEffect)(()=>{for(let e of s){let t=T.current.get(e.id),n=TY(e,t);n&&S(n),t!==void 0&&t===`running`&&e.agent_status===`done`&&(e.state===`plan`||e.state===`build`||e.state===`review`)&&CY(e.title),T.current.set(e.id,e.agent_status)}},[s]);let ie=(0,X.useCallback)(()=>{m(null)},[]),ae=(0,X.useMemo)(()=>({tickets:s,setTickets:c,dependencies:l,setDependencies:u,bundles:d,setBundles:f,latestDetailedTicketUpdate:p,clearLatestDetailedTicketUpdate:ie,loadedProjectId:h,loadingProjectId:_,activeProjectIdRef:D,pendingDeletedTicketsRef:O,pendingOptimisticMovesRef:k,pendingParkedTicketsRef:A,refreshTickets:ee,requestSingleTicketRefresh:V,refreshBundles:te,resolvePendingTicket:I,resolvePendingTickets:L,markPendingOptimisticMoves:M,clearPendingOptimisticMoves:N,markPendingParkedTickets:P,clearPendingParkedTickets:F,liveActivity:re}),[d,ie,N,F,l,re,h,p,_,M,P,te,ee,V,I,L,s]);return(0,Z.jsx)(bY.Provider,{value:ae,children:o})},DY=()=>{let e=(0,X.useContext)(bY);if(!e)throw Error(`useProjectWorkspace must be used inside ProjectWorkspaceProvider`);return e},OY=(0,X.lazy)(()=>VW(()=>import(`./TestsDialog-F0VCXRNc.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),kY=e=>e===1?`1 ticket created`:`${e} tickets created`,AY=async e=>yY(`Planning done`,kY(e)),jY=`archon.last-model-selection`,MY=`archon.last-variant-selection`,NY=`archon.last-skills-selection`,PY=()=>{try{let e=window.localStorage.getItem(NY),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},FY=e=>[e.title,e.description,e.bundle?.name??``,e.bundle?.branch??``,e.branch??``].map(e=>e.toLowerCase()),IY=(e,t)=>{let n=e.bundle_execution_position??2**53-1,r=t.bundle_execution_position??2**53-1;if(n!==r)return n-r;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let i=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return i===0?e.id.localeCompare(t.id):i},LY=(e,t)=>t?{...e,...t,messages:t.messages===void 0?e.messages:t.messages,agent_log:t.agent_log===void 0?e.agent_log:t.agent_log,streaming_response:t.streaming_response===void 0?e.streaming_response:t.streaming_response}:e,RY=(e,t)=>{let n=e.toLowerCase().trim().split(/\s+/).filter(Boolean);if(n.length===0)return!0;let r=FY(t);return n.every(e=>r.some(t=>t.includes(e)))},zY=[`plan`,`build`,`review`],BY=`done`,VY=()=>({build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1,bundleRefresh:!1}),HY=({bundleId:e,activeRunContextKey:t,isProjectRootRunActive:n})=>n?!0:t!==null&&t!==e,UY=(e,t)=>{if(!e)return null;let n=t.find(t=>t.id===e.ticket_id);return n?Nw(n):e.ticket_id},WY=()=>({description:``,model:window.localStorage.getItem(jY)??``,variant:window.localStorage.getItem(MY)??``,skills:PY(),worktreeBundleId:``}),GY=()=>({isOpen:!1,composer:WY(),runs:[]}),KY=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`planning-run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,qY=e=>({ticketCount:e.tickets.length,dependencyCount:e.dependencies.length,ticketsWithOpenQuestions:e.tickets.filter(e=>(e.planning_context?.open_questions.length??0)>0).length,ticketTitles:e.tickets.map(e=>e.title),ticketIds:e.tickets.map(e=>e.id)}),JY=(e,t,n)=>e.map(e=>e.id===t?n(e):e),YY=(e,t,n)=>{e?window.localStorage.setItem(jY,e):window.localStorage.removeItem(jY),t?window.localStorage.setItem(MY,t):window.localStorage.removeItem(MY),n.length>0?window.localStorage.setItem(NY,JSON.stringify(n)):window.localStorage.removeItem(NY)},XY=(e,t={})=>cd(e,t),ZY=()=>({model:window.localStorage.getItem(jY)??``,variant:window.localStorage.getItem(MY)??``,skills:PY()}),QY=(e,t)=>{let n=_Y(e,t.ticket.id),r=Math.max(0,Math.min(t.index,n.length));return n.splice(r,0,t.ticket),n},$Y=e=>e.tickets.length>0&&e.tickets.every(e=>Hw(e,`trash`)),eX=e=>e.tickets.length>0&&e.tickets.every(e=>Hw(e,BY)),tX=e=>e.column===BY&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),nX=(e,t,n)=>n||t!==null&&t!==Nw(e)?`Stop the currently running ticket before starting another run.`:tT(e),rX=(e,t)=>t===`build`?{agent_status:null,agent_log:null,streaming_response:null,build_completed_at:null,planning_context:e.planning_context?{...e.planning_context,open_questions:[]}:null}:t===`review`?{agent_status:null,agent_log:null,streaming_response:null}:{},iX=(e,t)=>e===`plan`&&t===`build`?`build`:e===`build`&&t===`review`?`review`:e===`review`&&t===`build`?`undoReview`:null,aX=(e,t,n)=>t===`review`&&n===`build`?{}:rX(e,n),oX=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:a,onRunStopped:o,onRunStatusChange:s,refreshKey:c=0})=>{let l=Qx(Zx(eC,{activationConstraint:{distance:5}})),{tickets:u,setTickets:d,dependencies:f,setDependencies:p,bundles:m,setBundles:h,latestDetailedTicketUpdate:g,clearLatestDetailedTicketUpdate:_,loadedProjectId:v,loadingProjectId:y,activeProjectIdRef:b,pendingDeletedTicketsRef:x,requestSingleTicketRefresh:S,refreshBundles:C,resolvePendingTicket:w,markPendingOptimisticMoves:T,clearPendingOptimisticMoves:E,markPendingParkedTickets:D,clearPendingParkedTickets:O}=DY(),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)({x:0,y:0}),[L,R]=(0,X.useState)(!1),[ee,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)([]),[te,ne]=(0,X.useState)([]),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)({}),[se,H]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(!1),[ue,de]=(0,X.useState)(null),[G,fe]=(0,X.useState)(null),[K,q]=(0,X.useState)(null),[me,he]=(0,X.useState)(null),[_e,ye]=(0,X.useState)(null),[be,xe]=(0,X.useState)(null),[Se,Ce]=(0,X.useState)(null),[we,Te]=(0,X.useState)(null),[Ee,De]=(0,X.useState)(null),[Oe,ke]=(0,X.useState)(null),[Ae,je]=(0,X.useState)(!1),[Ne,J]=(0,X.useState)(VY()),[Pe,Fe]=(0,X.useState)(0),[Ie,Le]=(0,X.useState)(``),[Re,ze]=(0,X.useState)(!1),Be=i===`opencode`||K?.tool===`opencode`||!!be?.tickets.some(e=>e.tool===`opencode`),Ve=i===`opencode`&&B.length>0,He=K?.tool===`opencode`&&B.length>0,Ue=!!be?.tickets.some(e=>e.tool===`opencode`)&&B.length>0,We=(0,X.useRef)(e),Ge=(0,X.useRef)(null),Ke=(0,X.useRef)(null),Y=u.find(e=>e.is_running)??null,qe=Y?Nw(Y):null,Je=r?.context_key??null,Ye=r?.kind===`ticket`?UY(r,u)??qe:qe,$e=r?.kind===`project`,et=(0,X.useCallback)(e=>HY({bundleId:e,activeRunContextKey:Ye,isProjectRootRunActive:$e}),[Ye,$e]),tt=k!==null&&Hw(k,`trash`)||j!==null&&$Y(j),ot=y===e,st=(0,X.useMemo)(()=>rY(t?.test_commands??null),[t?.test_commands]),ct=st.length>0,ft=(0,X.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]);(0,X.useEffect)(()=>{if(!G){q(null);return}let e=ft.get(G)??null;e&&q(t=>!t||t.id!==G?e:LY(t,e))},[G,ft]),(0,X.useEffect)(()=>{g&&(q(e=>!e||e.id!==g.id?e:LY(e,g)),xe(e=>{if(!e)return e;let t=g.worktree_bundle_id;if(!t||e.bundle.id!==t)return e;let n=e.tickets.some(e=>e.id===g.id)?e.tickets.map(e=>e.id===g.id?LY(e,g):e):[...e.tickets,g];return{...e,tickets:n}}))},[g]),(0,X.useEffect)(()=>{g===null||G!==null||me!==null||_()},[_,g,me,G]);let pt=(0,X.useCallback)(async e=>{let t=await S(e);if(!t)return null;let n=ft.get(e),r=n?LY(t,n):t;return q(t=>t&&t.id!==e||G&&G!==e?t:r),r},[S,G,ft]),mt=(0,X.useCallback)(e=>{q(e),fe(e.id),pt(e.id)},[pt]),ht=(0,X.useMemo)(()=>new Map(m.map(e=>[e.id,e])),[m]),gt=(0,X.useMemo)(()=>{if(!be)return null;let e=be.bundle.id,t=g?.worktree_bundle_id===e?g:null,n=u.filter(t=>t.worktree_bundle_id===e),r=new Map(n.map(e=>[e.id,e])),i=be.tickets.filter(e=>!x.current.has(e.id)).map(e=>t&&e.id===t.id?LY(e,t):e);t&&!i.some(e=>e.id===t.id)&&!x.current.has(t.id)&&i.push(t);let a=i.map(e=>LY(e,r.get(e.id)));for(let e of n)a.some(t=>t.id===e.id)||a.push(e);a.sort(IY);let o=be.execution_order_ticket_ids??[],s=a.map(e=>e.id),c=[...o,...s].filter((e,t,n)=>s.includes(e)&&n.indexOf(e)===t),l=n.some(e=>e.can_re_review!==void 0||e.has_completed_review!==void 0||e.has_follow_up_since_last_review!==void 0),d=n.some(e=>e.agent_status===`running`),f={has_completed_review:n.some(e=>e.has_completed_review===!0),has_follow_up_since_last_review:n.some(e=>e.has_follow_up_since_last_review===!0),can_re_review:!d&&n.some(e=>e.can_re_review===!0)},p=ad(a),m=a.find(e=>e.id===be.review_owner_ticket_id&&e.state===`review`)??a.find(e=>e.state===`review`)??null,h=cd(a,{targetTicketId:be.target_ticket_id,reviewOwnerTicketId:m?.id??be.review_owner_ticket_id,latestSessionTicketId:p?.id??be.latest_session_ticket_id});return{...be,bundle:ht.get(e)??be.bundle,tickets:a,execution_order_ticket_ids:c,latest_session_ticket_id:p?.id??null,latest_session_id:p?.session_id??null,review_owner_ticket_id:m?.id??null,target_ticket_id:h?.id??null,has_completed_review:l?f.has_completed_review:be.has_completed_review,has_follow_up_since_last_review:l?f.has_follow_up_since_last_review:be.has_follow_up_since_last_review,can_re_review:l?f.can_re_review:be.can_re_review}},[ht,g,x,be,u]),_t=(0,X.useMemo)(()=>u.filter(e=>Re&&Lw(e)?!1:RY(Ie,e)),[Re,Ie,u]),vt=(0,X.useMemo)(()=>_t.filter(e=>Fw(e)),[_t]),xt=(0,X.useMemo)(()=>ld(vt,m,BY),[m,vt]),{boardViewportRef:Ct,boardContentRef:wt,registerTicketNode:Tt,measuredCardRects:Et,overlayPreview:Dt,overlaySize:Ot,getDependencyTargetState:kt,handleDependencyStart:Jt,handleDeleteDependency:Yt}=nY({activeProjectId:e,tickets:u,dependencies:f,setDependencies:p,activeTicket:k,activeOverlayNode:N,dragOffset:F}),Xt=e?ae[e]??GY():GY(),Zt=Xt.composer.worktreeBundleId&&m.some(e=>e.id===Xt.composer.worktreeBundleId)?Xt.composer.worktreeBundleId:``,Qt=Zt===Xt.composer.worktreeBundleId?Xt:{...Xt,composer:{...Xt.composer,worktreeBundleId:Zt}},$t=ZY(),en=!!t?.run_ide?.trim(),tn=Qt.runs.filter(e=>e.boardVisible),nn=(0,X.useCallback)((e,t,n=u)=>{let r=ld(n,m,t).find(t=>t.kind===`bundle`&&t.group.bundle.id===e);return r?.kind===`bundle`?r.group:null},[m,u]),rn=(0,X.useCallback)(e=>(0,Z.jsx)(ZW,{ticket:e,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:e.tool===`opencode`&&B.length>0,availableModels:B,runDisabled:!0,hideBundleScopedControls:!0}),[t?.memory_enabled,B,m,f,u]),an=tn.length>0?(0,Z.jsx)(`div`,{className:`mb-0.5 flex flex-col gap-2.5`,children:tn.map(e=>(0,Z.jsx)(UJ,{run:e},e.id))}):null,on=(0,X.useCallback)(t=>sd(t)?t.project_id===e?en:!!t.has_run_ide:!1,[en,e]),sn=(0,X.useCallback)(e=>!!e.project_id&&!!(e.bundle?.branch??e.branch)&&sd(e),[]),cn=(0,X.useCallback)(e=>{let t=e?.tickets.find(t=>t.id===e.target_ticket_id)??e?.tickets.find(e=>e.has_worktree)??null;return t?on(t):!1},[on]),ln=(0,X.useCallback)(e=>{let t=u.filter(t=>t.worktree_bundle_id===e).sort(IY);return be?.bundle.id===e?XY(be.tickets.map(e=>t.find(t=>t.id===e.id)??e).sort(IY),{targetTicketId:be.target_ticket_id,reviewOwnerTicketId:be.review_owner_ticket_id,latestSessionTicketId:be.latest_session_ticket_id}):XY(t)},[be,u]),un=(0,X.useCallback)((e,t)=>{oe(n=>({...n,[e]:t(n[e]??GY())}))},[]);(0,X.useEffect)(()=>{H(!1),le(!1),Ce(null),ke(null),We.current!==e&&(Ge.current=e),e||(Ge.current=null,Le(``)),We.current=e},[e,c]),(0,X.useLayoutEffect)(()=>{!e||v!==e||Ge.current===e&&(Ge.current=null,Le(``))},[e,v]),(0,X.useEffect)(()=>{if(!Be){ne([]);return}let t=new AbortController;return(async()=>{try{V(await qt(`opencode`,t.signal))}catch(e){ge(e)||V(e=>e)}})(),(async()=>{try{ne(await yw(`opencode`,t.signal,e))}catch(e){ge(e)||ne([])}})(),()=>{t.abort()}},[e,Be]);let dn=({active:e})=>{ie(!1),P(null),I({x:0,y:0});let t=dd(String(e.id));if(t){M(nn(t.bundleId,t.column)),A(null);return}M(null),A(u.find(t=>t.id===e.id)??null)},fn=()=>{ie(!1),P(null),I({x:0,y:0}),A(null),M(null)},pn=(0,X.useCallback)(e=>{d(t=>e.reduce((e,t)=>hY(e,t),t))},[d]),mn=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=e[0]?.state;n&&d(r=>e.reduce((e,r)=>vY(e,r.id,t,aX(r,n,t)),r))},[d]),hn=(0,X.useCallback)((e,t=u)=>!e.worktree_bundle_id||!e.project_id||e.state!==`build`?[]:t.filter(t=>t.project_id===e.project_id&&t.worktree_bundle_id===e.worktree_bundle_id&&t.state===`build`&&t.parked_at===null).sort(IY),[u]),gn=async({active:e,over:t})=>{let n=dd(String(e.id)),r=u.find(t=>t.id===e.id),i=n?nn(n.bundleId,n.column):null,a=t?.id===`trash`&&(r!==void 0&&Hw(r,`trash`)||i!==null&&$Y(i)),o=t?.id&&zY.includes(t.id)?t.id:null;if(ie(a),P(null),I({x:0,y:0}),A(null),M(null),t){if(n){if(t.id===`trash`){if(!i||!$Y(i))return;await On(i);return}if(t.id===BY){if(!i||!eX(i))return;await Tn(i);return}if(o){if(n.column===BY){if(!i||!tX(i))return;await En(i);return}await rr(n.bundleId,n.column,o)}return}if(t.id===`trash`){if(!r||!Hw(r,`trash`))return;jn(e.id);return}if(t.id===BY){if(!r||!Hw(r,BY))return;await Cn(e.id);return}if(o){if(r&&Vw(r,o)){await wn(e.id);return}if(!(!r||!Hw(r,o)))try{await xn(r,o,{optimistic:!0})}catch(e){Q.error(e instanceof ve?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`})}}}},_n=async(t,n,r,a,o,s,c)=>{let l=await yt({title:t,description:n,tool:i,model:a,variant:o,skills:s,project_id:e,...c});if(YY(a,o,s),d(e=>hY(e,lY(l))),l.bundle&&h(e=>pY(e,l.bundle)),r===`build`)try{await xn(l,`build`)}catch(e){Q.error(e instanceof ve?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`})}r===`plan`&&Kt(l.id,l.project_id)},vn=async t=>{if(!e)throw Error(`Cannot create a bundle without an active project.`);let n=await Xe(e,{name:t,prepare:!0});return h(e=>pY(e,n)),n},yn=e=>{d(t=>[...e.tickets].reverse().reduce((e,t)=>hY(e,lY(t)),t)),p(t=>e.dependencies.reduce((e,t)=>Jw(e,t),t));for(let t of e.tickets)t.bundle&&h(e=>pY(e,t.bundle))},bn=(0,X.useCallback)((e,t={})=>{let n=lY(e);d(e=>t.reorderInState?hY(e,n):mY(e,n)),q(t=>!t||t.id!==e.id?t:LY(e,n)),e.bundle&&h(t=>pY(t,e.bundle))},[h,d]),xn=async(e,t,n={})=>{let r=u.findIndex(t=>t.id===e.id),i=t===`review`?hn(e):[],a=t===`review`&&i.length>1,o=n.optimistic?a?i.map(e=>e.id):[e.id]:[];n.optimistic&&(T(o,t),a?mn(i,t):d(n=>vY(n,e.id,t,rX(e,t))));try{if(a&&e.project_id&&e.worktree_bundle_id){let t=await rt(e.project_id,e.worktree_bundle_id);Kn(t);let n=t.tickets.find(t=>t.id===e.id);if(!n)throw Error(`Requested ticket was not returned from the bundle review response.`);return E(o),n}let n=await St(e.id,e.project_id,t);return d(r=>{let i=r.find(t=>t.id===e.id);return i?.state===t&&n.state===t&&i.agent_status!==n.agent_status&&n.agent_status===e.agent_status?r:uY(i,n)?hY(r,n):mY(r,n)}),n.bundle&&h(e=>pY(e,n.bundle)),E(o),n}catch(t){throw n.optimistic&&(a?pn(i):d(t=>vY(t,e.id,e.state,{agent_status:e.agent_status,agent_log:e.agent_log,build_completed_at:e.build_completed_at},{preferredIndex:r})),E(o)),t}},Sn=(e,t)=>{d(n=>n.map(n=>n.id===e?{...n,...t}:n))},Cn=async t=>{let n=u.find(e=>e.id===t);if(n)try{let r=new Date().toISOString();D([t],r),Sn(t,{parked_at:r}),bn(await Pt(t,n.project_id??e),{reorderInState:!0}),O([t])}catch(e){O([t]),Sn(t,{parked_at:n.parked_at}),Q.error(e instanceof ve?e.message:`Unable to park the ticket right now.`,{id:`board-park-error`})}},wn=async t=>{let n=u.find(e=>e.id===t);if(n)try{D([t],null),Sn(t,{parked_at:null}),bn(await Ft(t,n.project_id??e),{reorderInState:!0}),O([t])}catch(e){O([t]),Sn(t,{parked_at:n.parked_at}),Q.error(e instanceof ve?e.message:`Unable to return the ticket right now.`,{id:`board-unpark-error`})}},Tn=(0,X.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at})),r=new Date().toISOString();D(e.tickets.map(e=>e.id),r),d(e=>e.map(e=>t.has(e.id)?{...e,parked_at:r}:e));let i=await Promise.allSettled(e.tickets.map(e=>Pt(e.id,e.project_id??b.current))),a=new Set;if(i.forEach((t,n)=>{if(t.status===`fulfilled`){O([t.value.id]),bn(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&a.add(r.id)}),a.size===0)return;O([...a]),d(e=>e.map(e=>{if(!a.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let o=i.find(e=>e.status===`rejected`),s=a.size===e.tickets.length?o?.reason instanceof ve?o.reason.message:`Unable to move the bundle to Done right now.`:`Moved ${e.tickets.length-a.size} of ${e.tickets.length} bundle tickets to Done.`;Q.error(s,{id:`board-bundle-park-error`})},[b,bn,O,D,d]),En=(0,X.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at}));D(e.tickets.map(e=>e.id),null),d(e=>e.map(e=>t.has(e.id)?{...e,parked_at:null}:e));let r=await Promise.allSettled(e.tickets.map(e=>Ft(e.id,e.project_id??b.current))),i=new Set;if(r.forEach((t,n)=>{if(t.status===`fulfilled`){O([t.value.id]),bn(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&i.add(r.id)}),i.size===0)return;O([...i]),d(e=>e.map(e=>{if(!i.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let a=r.find(e=>e.status===`rejected`),o=i.size===e.tickets.length?a?.reason instanceof ve?a.reason.message:`Unable to restore the bundle right now.`:`Restored ${e.tickets.length-i.size} of ${e.tickets.length} bundle tickets.`;Q.error(o,{id:`board-bundle-unpark-error`})},[b,bn,O,D,d]),Dn=async t=>{e&&(await dt(e,t),h(e=>e.filter(e=>e.id!==t)))},On=(0,X.useCallback)(async t=>{let n=t.tickets.map(e=>({ticket:e,index:u.findIndex(t=>t.id===e.id)})).filter(e=>e.index!==-1);if(n.length===0)return;for(let e of n)x.current.set(e.ticket.id,e);let r=new Set(n.map(e=>e.ticket.id));d(e=>e.filter(e=>!r.has(e.id))),p(e=>e.filter(e=>!r.has(e.blocker_ticket_id)&&!r.has(e.dependent_ticket_id)));let i=await Promise.allSettled(n.map(async t=>(await Mt(t.ticket.id,t.ticket.project_id??e),x.current.delete(t.ticket.id),t.ticket.id)));t.tickets.some(e=>e.project_id===b.current)&&C().catch(()=>{});let a=n.filter((e,t)=>i[t]?.status===`rejected`);if(a.length===0)return;for(let e of a)x.current.delete(e.ticket.id);a.some(e=>e.ticket.project_id===b.current)&&d(e=>[...a].sort((e,t)=>e.index-t.index).reduce((e,t)=>QY(e,t),e));let o=i.find(e=>e.status===`rejected`),s=a.length===n.length?o?.reason instanceof ve?o.reason.message:`Unable to delete the bundle tickets right now.`:`Deleted ${n.length-a.length} of ${n.length} bundle tickets.`;Q.error(s,{id:`board-delete-bundle-wrapper-error`})},[e,b,x,C,p,d,u]),kn=e=>{let t=ft.get(e.id);bn(e,{reorderInState:t?t.state!==e.state||t.parked_at!==e.parked_at||t.worktree_bundle_id!==e.worktree_bundle_id:!1}),t?.worktree_bundle_id&&t.worktree_bundle_id!==e.worktree_bundle_id&&t.bundle?.ticket_count===1&&h(e=>e.filter(e=>e.id!==t.worktree_bundle_id)),(t?.worktree_bundle_id!==e.worktree_bundle_id||t?.bundle?.ticket_count!==e.bundle?.ticket_count)&&e.project_id===b.current&&C().catch(()=>{})},An=async()=>{if(!e)return;let t=e,n=Xt.composer.description.trim();if(!n)return;let r=KY(),a=Ve?Xt.composer.model.trim():``,o=Ve&&a?Xt.composer.variant.trim():``,s=Ve?Xt.composer.skills:[],c=Date.now();un(t,e=>({...e,isOpen:!1,composer:{...e.composer,description:``,worktreeBundleId:``},runs:[{id:r,description:n,model:a,variant:o,skills:s,worktreeBundleId:Zt,status:`running`,error:null,submittedAt:c,completedAt:null,boardVisible:!0,boardState:`visible`,summary:null},...e.runs]}));try{let e=await bt({description:n,tool:i,model:a||null,variant:a&&o||null,skills:s,project_id:t,worktree_bundle_id:Zt||null});YY(a||null,a&&o||null,s);let c=qY(e);un(t,e=>({...e,runs:JY(e.runs,r,e=>({...e,status:`done`,error:null,completedAt:Date.now(),summary:c,boardVisible:!1}))})),Q.success(`${c.ticketCount} ${c.ticketCount===1?`card`:`cards`} created`,{id:`planning-agent-success-${r}`}),AY(e.tickets.length),b.current===t&&yn(e)}catch(e){let n=e instanceof ve?e.message:`Unable to generate tickets right now.`;un(t,e=>({...e,runs:JY(e.runs,r,e=>({...e,status:`error`,error:n,completedAt:Date.now()}))})),Q.error(n,{id:`planning-agent-error`})}},jn=async t=>{let n=u.find(e=>e.id===t),r=u.findIndex(e=>e.id===t);if(!(!n||r===-1)){x.current.set(t,{ticket:n,index:r}),d(e=>_Y(e,t)),p(e=>qw(e,t));try{await Mt(t,n.project_id??e),n.project_id===b.current&&C().catch(()=>{}),x.current.delete(t)}catch(e){let n=x.current.get(t);x.current.delete(t),n&&n.ticket.project_id===b.current&&(d(e=>QY(e,n)),Q.error(e instanceof ve?e.message:`Unable to delete the ticket right now.`,{id:`board-delete-error`}))}}},Mn=async t=>{let n=u.find(e=>e.id===t);if(!n)return;let r=n.state===`review`?`review`:`build`;try{if(de(r),n.project_id&&n.worktree_bundle_id&&n.state===`review`){Kn(await it(n.project_id,n.worktree_bundle_id));return}bn(await Nt(t,n.project_id??e),{reorderInState:!0})}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to undo the ticket right now.`,{id:`board-undo-error`}),e}finally{de(e=>e===r?null:e)}},Nn=t=>{Lt(t,u.find(e=>e.id===t)?.project_id??e)},Pn=async t=>{let n=u.find(e=>e.id===t);try{await Rt(t,n?.project_id??e),s?.()}catch(e){Q.error(e instanceof ve?e.message:`Unable to start the run right now.`,{id:`board-run-error`})}},Fn=(0,X.useCallback)(async t=>{let n=u.find(e=>e.id===t);try{await zt(t,n?.project_id??e)}catch(e){Q.error(e instanceof ve?e.message:`Unable to open the IDE right now.`,{id:`board-open-ide-error`})}},[e,u]),In=async t=>{let n=u.find(e=>e.id===t),i=r?.kind===`ticket`&&n&&Ye===Nw(n)?Je:null;try{await Bt(t,n?.project_id??e),o?.(i),s?.()}catch{}},Ln=t=>{Vt(t,u.find(e=>e.id===t)?.project_id??e).then(()=>{d(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e))})},Rn=t=>{Ht(t,u.find(e=>e.id===t)?.project_id??e).then(()=>{d(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e))})},zn=(0,X.useCallback)(e=>{let t=ln(e);!t||!on(t)||Fn(t.id)},[on,ln,Fn]),Bn=(0,X.useCallback)(e=>{let t=ln(e);t&&De({bundleId:e,ticketId:t.id,projectId:t.project_id,title:t.bundle?md(t.bundle):t.title})},[ln]),Vn=(0,X.useCallback)(e=>{if(!ct)return;let t=ln(e);!t?.project_id||!sd(t)||ke(e)},[ln,ct]),Hn=(0,X.useCallback)(e=>{let t=u.find(t=>t.id===e);!t||!sn(t)||Te({ticketId:t.id,projectId:t.project_id,title:t.title})},[sn,u]),Un=(0,X.useCallback)(e=>{if(!ct)return;let t=u.find(t=>t.id===e);!t?.project_id||!sd(t)||Ce({ticketId:t.id,projectId:t.project_id})},[ct,u]),Wn=(0,X.useCallback)(async(t,n)=>{let r=u.find(e=>e.id===t);if(r)try{bn(r.state===`plan`?await Gt(t,r.project_id??e,n):await Ut(t,r.project_id??e,n))}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to send the follow-up prompt right now.`,{id:`board-follow-up-error`}),e}},[e,bn,u]),Gn=(0,X.useCallback)(e=>{d(t=>e.reduce((e,t)=>{let n=e.find(e=>e.id===t.id),r=w(n,t);if(!r)return e;let i=lY(n&&n.state===r.state&&n.agent_status===`running`&&r.agent_status===null?{...r,agent_status:n.agent_status,session_id:n.session_id,is_running:n.is_running}:r);return uY(n,i)?hY(e,i):mY(e,i)},t))},[w,d]),Kn=(0,X.useCallback)(e=>{xe(e),h(t=>pY(t,e.bundle)),Gn(e.tickets)},[Gn,h]),qn=(0,X.useCallback)((e,t)=>{Array.isArray(t.tickets)&&xe(n=>!n||n.bundle.id!==e?n:{...n,tickets:t.tickets,execution_order_ticket_ids:t.execution_order_ticket_ids,latest_session_ticket_id:t.latest_session_ticket_id,latest_session_id:t.latest_session_id,review_owner_ticket_id:t.review_owner_ticket_id,target_ticket_id:t.target_ticket_id})},[]),Jn=(0,X.useCallback)(async e=>{let t=b.current;if(!t)return null;let n=await Ze(t,e);return b.current===t?(Kn(n),n):null},[b,Kn]),Yn=(0,X.useCallback)(async e=>{let t=b.current;if(!t)return null;let n=await Qe(t,e);return b.current===t?(qn(e,n),n):null},[b,qn]),Xn=(0,X.useCallback)(async(e,t=null)=>{let n=b.current;if(!n)return;fe(null),q(null),he(e),ye(t),J(VY());let r=ht.get(e)??null,i=u.filter(t=>t.worktree_bundle_id===e);if(r&&i.length>0){let e=ad(i),t=cd(i,{reviewOwnerTicketId:i.find(e=>e.state===`review`)?.id??null,latestSessionTicketId:e?.id??null});xe({bundle:r,tickets:i,latest_session_ticket_id:e?.id??null,latest_session_id:e?.session_id??null,review_owner_ticket_id:i.find(e=>e.state===`review`)?.id??null,target_ticket_id:t?.id??null})}else xe(null);je(!0);try{await Yn(e)}catch{}finally{b.current===n&&je(!1)}},[b,ht,Yn,u]),Zn=(0,X.useCallback)(async(e,t)=>{J(t=>({...t,[e]:!0}));try{return await t()}finally{J(t=>({...t,[e]:!1}))}},[]),Qn=(0,X.useCallback)(async t=>{await Zn(`stopBuild`,async()=>{let n=u.find(e=>e.id===t);await Vt(t,n?.project_id??e),d(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e)),n?.worktree_bundle_id&&await Jn(n.worktree_bundle_id)})},[e,Jn,Zn,d,u]),$n=(0,X.useCallback)(async t=>{await Zn(`resumeBuild`,async()=>{let n=u.find(e=>e.id===t);await Ht(t,n?.project_id??e),d(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e)),n?.worktree_bundle_id&&await Jn(n.worktree_bundle_id)})},[e,Jn,Zn,d,u]),er=(0,X.useCallback)(async t=>{if(e)try{Kn(await Zn(`build`,()=>nt(e,t))),me===t&&ye(`build`),s?.()}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to build the bundle right now.`,{id:`board-bundle-build-error`}),e}},[e,Kn,s,Zn,me]),tr=(0,X.useCallback)(async t=>{if(e)try{Kn(await Zn(`review`,()=>rt(e,t))),me===t&&ye(`review`)}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to review the bundle right now.`,{id:`board-bundle-review-error`}),e}},[e,Kn,Zn,me]),nr=(0,X.useCallback)(async t=>{if(e)try{de(`review`),Kn(await Zn(`undoReview`,()=>it(e,t))),me===t&&ye(`build`)}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to undo the bundle review right now.`,{id:`board-bundle-undo-review-error`}),e}finally{de(e=>e===`review`?null:e)}},[e,Kn,Zn,me]),rr=(0,X.useCallback)(async(e,t,n)=>{if(t===BY||n===BY)return;let r=iX(t,n);if(!r)return;let i=u.filter(n=>n.worktree_bundle_id===e&&n.state===t&&n.parked_at===null);if(i.length===0)return;let a=i.map(e=>e.id);T(a,n),mn(i,n);try{if(r===`build`){await er(e),E(a);return}if(r===`review`){await tr(e),E(a);return}await nr(e),E(a)}catch(e){pn(i),E(a),Q.error(e instanceof ve?e.message:`Unable to move the bundle right now.`,{id:`board-bundle-move-error`})}},[E,er,tr,nr,T,mn,pn,u]),ir=async t=>{e&&(Kn(await Zn(`run`,()=>lt(e,t))),s?.())},ar=async t=>{if(!e)return;let n=r?.kind===`ticket`&&Ye===t?Je:null,i=await Zn(`stop`,()=>ut(e,t));o?.(n),Kn(i),s?.()},or=(0,X.useCallback)(async(t,n)=>{e&&Kn(await Zn(`followUp`,()=>at(e,t,n)))},[e,Kn,Zn]);(0,X.useEffect)(()=>()=>{a?.(null)},[a]),(0,X.useEffect)(()=>{if(!a)return;if(!r){a(null);return}if(r.kind===`project`){a({target:null,canSelect:!1,disabledReason:`Preview selection is unavailable for project root runs.`,submitPrompt:null});return}let e=u.find(e=>e.id===r.ticket_id);if(!e){a({target:null,canSelect:!1,disabledReason:`Preview selection is only available for build-capable ticket runs.`,submitPrompt:null});return}if(e.state===`plan`){a({target:{kind:`ticket`,id:e.id},canSelect:!1,disabledReason:`Preview selection is unavailable while this ticket is in Plan mode.`,submitPrompt:null});return}if(e.worktree_bundle_id){a({target:{kind:`bundle`,id:e.worktree_bundle_id,ticket_id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:`Follow up on this bundle`,submitPrompt:t=>or(e.worktree_bundle_id,t)});return}a({target:{kind:`ticket`,id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:`Follow up on this ticket`,submitPrompt:t=>Wn(e.id,t)})},[r,Wn,or,a,u]);let sr=async t=>{let n=u.find(e=>e.id===t),r=n?jw(n.state):null;if(n)try{if(n.state===`review`&&n.can_re_review&&n.agent_status!==`running`){let t=await Wt(n.id,n.project_id??e);bn(t),t.worktree_bundle_id&&await Jn(t.worktree_bundle_id);return}if(!r)return;if(n.worktree_bundle_id&&r===`review`){await tr(n.worktree_bundle_id);return}await xn(n,r)}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`}),e}},cr=async t=>{let n=u.find(e=>e.id===t);try{bn(await At(t,n?.project_id??e))}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to start the build chain right now.`,{id:`board-build-chain-error`}),e}},lr=async t=>{let n=u.find(e=>e.id===t);try{await jt(t,n?.project_id??e)}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to stop the build chain right now.`,{id:`board-stop-build-chain-error`}),e}},ur=async()=>{if(!(!e||ce)){le(!0);try{let t=await It(e);d(e=>e.filter(e=>!t.deleted_ticket_ids.includes(e.id))),p(e=>t.deleted_ticket_ids.reduce(qw,e)),await C(),H(!1),t.failed_count>0?Q.error(`Deleted ${t.deleted_count} done ticket${t.deleted_count===1?``:`s`}, but ${t.failed_count} failed.`,{id:`board-delete-parked-error`}):Q.success(`Deleted ${t.deleted_count} done ticket${t.deleted_count===1?``:`s`}.`,{id:`board-delete-parked-success`})}catch(e){Q.error(e instanceof ve?e.message:`Unable to empty Done right now.`,{id:`board-delete-parked-error`})}finally{le(!1)}}},dr=({delta:e})=>{I(e)},fr=(0,X.useCallback)(()=>{e&&R(!0)},[e]),pr=(0,X.useCallback)(()=>{e&&un(e,e=>e.isOpen?e:{...e,isOpen:!0})},[e,un]),mr=(0,X.useCallback)(()=>{Ke.current?.focus({preventScroll:!0})},[]);return cY([{key:`n`,onKeyDown:fr,disabled:!e},{key:`a`,onKeyDown:pr,disabled:!e},{key:`k`,ctrlKey:!0,onKeyDown:mr}],{isBlocked:sY}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ZC,{sensors:l,collisionDetection:lS,onDragStart:dn,onDragMove:dr,onDragCancel:fn,onDragEnd:gn,children:[(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(YJ,{projectId:e,state:Qt,bundles:m,projectBranchState:n,showModelSelector:Ve,availableModels:B,availableSkills:te,onManageBundles:e?()=>{(async()=>{try{await C()}catch{}z(!0)})()}:void 0,onToggle:()=>{e&&un(e,e=>({...e,isOpen:!e.isOpen}))},onDescriptionChange:t=>{e&&un(e,e=>({...e,composer:{...e.composer,description:t}}))},onModelChange:t=>{if(!e)return;let n=B.find(e=>e.id===t)??null;un(e,e=>({...e,composer:{...e.composer,model:t,variant:n?.variants.includes(e.composer.variant)?e.composer.variant:``}}))},onSkillsChange:t=>{e&&un(e,e=>({...e,composer:{...e.composer,skills:t}}))},onVariantChange:t=>{e&&un(e,e=>({...e,composer:{...e.composer,variant:t}}))},onBundleChange:t=>{e&&un(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t}}))},onGenerate:()=>{An()}}),(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:W(`absolute inset-y-0 left-16 right-0 z-10 bg-black/60 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Qt.isOpen?`opacity-100`:`pointer-events-none opacity-0`)}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 overflow-hidden p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,Z.jsx)(Me,{id:`board-ticket-search`,ref:Ke,type:`search`,value:Ie,onChange:e=>Le(e.target.value),placeholder:`Search tickets`,"aria-label":`Search tickets`,className:`pr-32`}),Ie.length>0?(0,Z.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Clear search`,className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{Le(``),Ke.current?.focus()},children:(0,Z.jsx)(pe,{className:`size-4`})}):(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(vw,{children:`CTRL`}),(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(vw,{children:`K`})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Zd,{id:`board-hide-stale-tickets`,checked:Re,onCheckedChange:ze,"aria-label":`Hide stale tickets`}),(0,Z.jsx)(zl,{htmlFor:`board-hide-stale-tickets`,className:`text-sm text-muted-foreground`,children:`Hide stale tickets`})]})]}),(0,Z.jsx)(`div`,{ref:Ct,className:`flex min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,Z.jsxs)(`div`,{ref:wt,className:`relative flex min-h-0 w-max min-w-full gap-4`,children:[(0,Z.jsx)(zJ,{dependencies:f,cardRects:Et,preview:Dt,ticketsById:ft,overlaySize:Ot}),zY.map(t=>{let n=u.filter(e=>e.state===t&&!Fw(e)),r=_t.filter(e=>e.state===t&&!Fw(e)),i=ld(r,m,t),a=ot&&n.length===0?t===`plan`?1:t===`build`?2:0:0;return(0,Z.jsx)($W,{id:t,title:t.charAt(0).toUpperCase()+t.slice(1),pinnedContent:t===`plan`?an:null,items:i,ticketCount:r.length,allTickets:u,dependencies:f,showModelSelector:Ve,availableModels:B,bundles:m,activeRunContextKey:Ye,isProjectRootRunActive:$e,isBundleRunDisabled:et,getDependencyTargetState:kt,onDependencyStart:Jt,onDeleteDependency:Yt,onRegisterTicketNode:Tt,onAddTicket:t===`plan`&&e?fr:void 0,onCreateBundle:t===`plan`&&e?vn:void 0,onDeleteBundle:t===`plan`&&e?Dn:void 0,onDeleteBundleWrapper:On,onRefreshBundles:t===`plan`&&e?C:void 0,onUpdateTicket:kn,onDeleteTicket:jn,onUndoTicket:Mn,undoingColumn:ue,onRetryTicket:Nn,onAdvanceTicket:sr,onParkTicket:Cn,onUnparkTicket:wn,onBuildChainTicket:cr,onRunTicket:Pn,onOpenTestsTicket:ct?Un:void 0,canOpenChangesForTicket:sn,onOpenChangesTicket:Hn,canOpenIdeForTicket:on,onOpenIdeTicket:Fn,onStopTicket:In,onStopBuildTicket:Ln,onStopBuildChainTicket:lr,onResumeBuildTicket:Rn,onOpenBundleChanges:Bn,onOpenBundleTests:ct?Vn:void 0,onOpenBundleIde:zn,onFollowUpTicket:Wn,bundleActionState:Ne,onBuildBundle:er,onReviewBundle:tr,onUndoBundleReview:nr,onRunBundle:ir,onStopBundle:ar,onParkBundleWrapper:Tn,onUnparkBundleWrapper:En,onOpenTicketDetails:mt,onOpenBundleDetails:(e,t)=>{Xn(e,t)},onRequestBundleRefresh:e=>{Zn(`bundleRefresh`,()=>Jn(e))},onRequestTicketRefresh:S,loadingSkeletonCount:a},t)}),(0,Z.jsx)($W,{id:BY,title:`Done`,items:xt,ticketCount:vt.length,allTickets:u,dependencies:f,showModelSelector:Ve,availableModels:B,bundles:m,activeRunContextKey:Ye,isProjectRootRunActive:$e,isBundleRunDisabled:et,getDependencyTargetState:kt,onDependencyStart:Jt,onDeleteDependency:Yt,onRegisterTicketNode:Tt,onUpdateTicket:kn,onDeleteTicket:jn,onUndoTicket:Mn,undoingColumn:ue,onRetryTicket:Nn,onAdvanceTicket:sr,onParkTicket:Cn,onUnparkTicket:wn,onBuildChainTicket:cr,onRunTicket:Pn,onOpenTestsTicket:ct?Un:void 0,canOpenChangesForTicket:sn,onOpenChangesTicket:Hn,canOpenIdeForTicket:on,onOpenIdeTicket:Fn,onStopTicket:In,onStopBuildTicket:Ln,onStopBuildChainTicket:lr,onResumeBuildTicket:Rn,onOpenBundleChanges:Bn,onOpenBundleTests:ct?Vn:void 0,onOpenBundleIde:zn,onFollowUpTicket:Wn,bundleActionState:Ne,onBuildBundle:er,onReviewBundle:tr,onUndoBundleReview:nr,onRunBundle:ir,onStopBundle:ar,onParkBundleWrapper:Tn,onUnparkBundleWrapper:En,onOpenTicketDetails:mt,onOpenBundleDetails:(e,t)=>{Xn(e,t)},onRequestBundleRefresh:e=>{Zn(`bundleRefresh`,()=>Jn(e))},onRequestTicketRefresh:S,className:`min-w-[272px] max-w-[272px] flex-[0.98] bg-card/65`,headerAccessory:(0,Z.jsxs)(U,{type:`button`,variant:`destructive`,size:`xs`,className:`gap-1.5`,disabled:vt.length===0||ce,onClick:()=>H(!0),children:[(0,Z.jsx)(Ld,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:`Empty`})]})})]})})]})]}),(0,Z.jsxs)(_w,{zIndex:5,dropAnimation:re?null:void 0,children:[k&&(0,Z.jsx)(ZW,{ticket:k,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:k.tool===`opencode`&&B.length>0,availableModels:B,runDisabled:nX(k,Ye,$e)!==void 0,runDisabledReason:nX(k,Ye,$e),onDependencyStart:Jt,onDeleteDependency:Yt,onRegisterOverlayNode:P,onCreateBundle:vn,onDeleteBundle:Dn,onRefreshBundles:C,onUpdate:kn,onDelete:()=>jn(k.id),onUndo:()=>Mn(k.id),undoInProgress:ue===k.state&&(k.state===`build`||k.state===`review`),onRetry:()=>Nn(k.id),onAdvance:()=>sr(k.id),onPark:()=>Cn(k.id),onUnpark:()=>wn(k.id),onBuildChain:()=>cr(k.id),onRun:k.worktree_bundle_id===null&&sd(k)&&k.has_run_config?()=>Pn(k.id):void 0,onOpenIde:k.worktree_bundle_id===null&&on(k)?()=>Fn(k.id):void 0,onStop:k.worktree_bundle_id===null?()=>In(k.id):void 0,onStopBuild:()=>Ln(k.id),onStopBuildChain:()=>lr(k.id),onResumeBuild:()=>Rn(k.id),onFollowUp:e=>Wn(k.id,e),onRequestTicketRefresh:S}),!k&&j&&(0,Z.jsx)(ST,{group:j,overlay:!0,renderTicket:rn})]}),tt&&(0,Z.jsx)(XJ,{className:`pointer-events-auto fixed left-1/2 top-4 z-20 w-[min(14rem,calc(100vw-2rem))] -translate-x-1/2`})]}),L&&(0,Z.jsx)(BJ,{onSubmit:_n,bundles:m,projectId:e,projectBranchState:n,tool:i,showModelSelector:Ve,availableModels:B,availableSkills:te,initialModel:Ve?$t.model:``,initialVariant:Ve&&$t.model?$t.variant:``,initialSkills:Ve?$t.skills:[],onCreateBundle:vn,onDeleteBundle:Dn,onRefreshBundles:C,onClose:()=>R(!1)}),ee&&e&&(0,Z.jsx)(Bd,{bundles:m,selectedBundleId:Qt.composer.worktreeBundleId||null,onSelectBundle:t=>{un(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t??``}}))},onCreateBundle:vn,onDeleteBundle:Dn,onClose:()=>z(!1)}),se&&(0,Z.jsx)(eG,{ticketCount:vt.length,isDeleting:ce,onCancel:()=>H(!1),onConfirm:()=>{ur()}}),K&&(0,Z.jsx)(XW,{ticket:K,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,projectBranchState:n,onClose:()=>{let e=K.id;fe(null),q(null),d(t=>t.map(t=>t.id===e?lY(t):t))},showModelSelector:He,availableModels:B,availableSkills:te,runDisabled:nX(K,Ye,$e)!==void 0,runDisabledReason:nX(K,Ye,$e),onDeleteDependency:Yt,onCreateBundle:vn,onDeleteBundle:Dn,onRefreshBundles:C,onUpdate:kn,onAdvance:()=>sr(K.id),onBuildChain:()=>cr(K.id),onRun:sd(K)&&K.has_run_config?()=>Pn(K.id):void 0,onOpenIde:on(K)?()=>Fn(K.id):void 0,onStop:()=>In(K.id),onStopBuild:()=>Ln(K.id),onStopBuildChain:()=>lr(K.id),onResumeBuild:()=>Rn(K.id),onFollowUp:e=>Wn(K.id,e),onProjectMemorySuggestionsChanged:()=>{Fe(e=>e+1)},onRequestTicketRefresh:e=>{pt(e)}}),Se&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(OY,{scope:`ticket`,ticketId:Se.ticketId,projectId:Se.projectId,testCommands:st,onClose:()=>Ce(null)})}),Ee&&(0,Z.jsx)(TJ,{ticketId:Ee.ticketId,projectId:Ee.projectId,reviewCommentsBundleId:Ee.bundleId,title:Ee.title,onSubmitReviewPrompt:e=>or(Ee.bundleId,e),canSubmitReviewPrompt:!u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),reviewSubmitDisabledReason:u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`)?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,canAddReviewComments:!u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),canModifyChanges:!u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),changesDisabledReason:u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`)?`Wait for all bundle tickets to finish building before modifying changes.`:void 0,onClose:()=>{let{bundleId:e}=Ee;De(null),Jn(e)},onTicketUpdate:kn,onRequestTicketRefresh:S}),we&&(0,Z.jsx)(TJ,{ticketId:we.ticketId,projectId:we.projectId,title:we.title,onClose:()=>{let{ticketId:e}=we;Te(null),pt(e)},onTicketUpdate:kn,onRequestTicketRefresh:e=>{pt(e)}}),Oe&&e&&t&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(OY,{scope:`project`,projectId:e,targetKind:`bundle`,targetBundleId:Oe,testCommands:st,onClose:()=>ke(null)})}),me&&gt&&(0,Z.jsx)(bG,{details:gt,activeColumn:_e,isLoading:Ae||Ne.bundleRefresh,actionState:Ne,canOpenIde:cn(gt),projectMemoryEnabled:!!t?.memory_enabled,memorySuggestionsRefreshKey:Pe,runDisabled:et(gt.bundle.id),showModelSelector:Ue,availableModels:B,availableSkills:te,onClose:()=>{let e=gt.bundle.id;he(null),ye(null),xe(null),je(!1),J(VY()),d(t=>t.map(t=>t.worktree_bundle_id===e&&t.id!==G?lY(t):t))},onOpenTicketDetails:mt,onUpdateTicket:kn,onOpenIde:()=>{let e=gt.tickets.find(e=>e.id===gt.target_ticket_id)??gt.tickets.find(e=>e.has_worktree);e&&Fn(e.id)},onOpenTests:ct?()=>{Vn(gt.bundle.id)}:void 0,onRefresh:e=>{Zn(`bundleRefresh`,()=>Jn(e))},onBuildBundle:er,onStopBuildTicket:Qn,onResumeBuildTicket:$n,onReviewBundle:tr,onUndoBundleReview:nr,onRunBundle:ir,onStopBundle:ar,onFollowUpBundle:or})]})},sX=({className:e})=>(0,Z.jsx)(dc,{"aria-hidden":`true`,className:e}),cX=({className:e})=>(0,Z.jsx)(fc,{"aria-hidden":`true`,className:e}),lX=({state:e,className:t})=>e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-activity-indicator":`true`,"data-state":e,"data-testid":`workspace-activity-indicator`,className:W(`h-2 w-2 flex-shrink-0 rounded-full`,e===`running`?`animate-pulse bg-amber-300`:e===`interrupted`?`bg-amber-400/80 ring-1 ring-amber-400/30`:e===`error`?`bg-rose-400/90 ring-1 ring-rose-400/30`:`bg-emerald-400/80 ring-1 ring-emerald-400/30`,t)}):null,uX=4,dX=5e3,fX=e=>e.replace(/^[ab]\//,``),pX=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?fX(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?fX(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},mX=e=>{let[t,n]=pX(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},hX=e=>{let t=RK((()=>{let[t,n]=pX(e);return t??n??null})());if(!t)return null;try{return rb(e.hunks,{highlight:!0,refractor:Rq.default,language:t,enhancers:[tb(e.hunks)]})}catch{return null}},gX=(e,t)=>e instanceof Error?e.message:t,_X=(e,t)=>{if(!t)return e;let n=mX(t);return[t,...e.filter(e=>mX(e)!==n)]},vX=e=>[...e].sort((e,t)=>{if(e.filePath!==t.filePath)return e.filePath.localeCompare(t.filePath);let n=e.newLineNumber??e.oldLineNumber??2**53-1,r=t.newLineNumber??t.oldLineNumber??2**53-1;return n===r?e.changeKey.localeCompare(t.changeKey):n-r}),yX=({diffResponse:e,gitStatus:t})=>{let n=new Map;for(let t of e?.files??[])n.set(t.path,t);return t?t.files.map(e=>{let t=n.get(e.path)??(e.original_path?n.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(e?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions}))},bX=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},xX={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},SX={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},CX=({selectedDiffPath:e,sidebarFiles:t,diffStats:n,triggerMode:r=`full`,onSelectDiffPath:i})=>{let[a,o]=(0,X.useState)(!1),s=t.find(t=>t.path===e)??null,c=r===`compact`?e===`all`?`Diff`:s?bX(s.path):`File`:e===`all`?`All changes`:s?bX(s.path):e;return(0,Z.jsxs)(Bl,{open:a,onOpenChange:o,children:[(0,Z.jsx)(Vl,{asChild:!0,children:(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`outline`,className:W(`max-w-full gap-2`,r===`full`?`min-w-0 max-w-[18rem]`:`min-w-0 px-2.5`),"aria-label":`Open changed files`,title:e===`all`?void 0:s?.path??e,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:c}),r===`full`&&(0,Z.jsxs)(J,{variant:`outline`,className:`shrink-0 text-[10px] uppercase tracking-wide`,children:[t.length,` file`,t.length===1?``:`s`]}),(0,Z.jsx)(Te,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Z.jsxs)(Hl,{align:`start`,className:`z-[90] w-[28rem] max-w-[calc(100vw-2rem)] p-0`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Changed files`})}),(0,Z.jsx)(`div`,{className:`max-h-[min(28rem,calc(100vh-10rem))] overflow-y-auto p-3`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{i(`all`),o(!1)},className:W(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,SK(e===`all`),`justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`All changes`}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:`Review the full workspace diff.`})]}),n&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[n.files_changed,` file`,n.files_changed===1?``:`s`]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,n.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,n.deletions]})]})]}),t.map(t=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{i(t.path),o(!1)},className:W(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,SK(e===t.path)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:bX(t.path)}),(0,Z.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.path})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,t.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,t.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[t.status&&(0,Z.jsx)(J,{variant:`outline`,className:xX[t.status],children:SX[t.status]}),t.staged&&(0,Z.jsx)(J,{variant:`outline`,children:`Staged`}),t.unstaged&&(0,Z.jsx)(J,{variant:`outline`,children:`Unstaged`}),t.conflicted&&(0,Z.jsx)(J,{variant:`destructive`,children:`Conflicted`}),t.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.status===`renamed`?`from ${t.originalPath}`:t.originalPath})]})]})},`${t.path}:${t.originalPath??``}`))]})})]})]})},wX=(0,X.memo)(({projectId:e,chatSessionId:t=null,canSubmitReviewPrompt:n,reviewSubmitDisabledReason:r,onSubmitReviewPrompt:i,state:a,onStateChange:o,isResizing:s=!1,onClose:c,desktopWidth:l,panelElementRef:u})=>{let[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(new Map),[S,C]=(0,X.useState)(!1),w=(0,X.useRef)(0),T=(0,X.useRef)(0),E=(0,X.useRef)(null),D=(0,X.useRef)(null),O=a.selectedDiffPath,k=a.activeReviewTarget,A=a.editingReviewCommentKey,j=k?.commentKey??A??`chat`,M=a.reviewDraftInput,N=(0,X.useMemo)(()=>new Map(a.reviewComments.map(e=>[pb(e.filePath,e.changeKey),e])),[a.reviewComments]),P=(0,X.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await lx(e,t):await Ee(e)},[t,e]),F=(0,X.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await ux(e,t):await ce(e)},[t,e]);(0,X.useEffect)(()=>{E.current=d},[d]),(0,X.useEffect)(()=>{D.current=p},[p]);let I=(0,X.useCallback)(async()=>{if(!e){T.current+=1,f(null),m(null),g(null),v(!1),y(!1);return}let t=w.current+1,n=T.current+1;w.current=t,T.current=n,v(!0),y(!0);let[r,i]=await Promise.allSettled([P(),F()]);w.current===t&&(r.status===`fulfilled`?(E.current=r.value,f(r.value),g(null)):g(gX(r.reason,`Unable to load the diff right now.`)),i.status===`fulfilled`&&(D.current=i.value,m(i.value)),T.current===n&&v(!1),y(!1))},[P,F,e]),L=(0,X.useCallback)(async(t={})=>{if(!e)return;let{broadcastOnSignatureChange:n=!1}=t,r=w.current+1;w.current=r,y(!0);try{let t=await F();if(w.current!==r)return;let i=D.current?.workspace_signature??null,a=t.workspace_signature??null,o=!E.current||i!==a;if(D.current=t,m(t),!o){T.current+=1,v(!1);return}let s=!E.current,c=T.current+1;T.current=c,s&&v(!0);try{let t=await P();if(w.current!==r)return;E.current=t,f(t),g(null),n&&i!==a&&BK(e)}catch(e){if(w.current!==r)return;E.current||g(gX(e,`Unable to load the diff right now.`))}finally{s&&T.current===c&&v(!1)}}catch{E.current||(T.current+=1,v(!1));return}finally{w.current===r&&y(!1)}},[P,F,e]);(0,X.useEffect)(()=>{I()},[I]),(0,X.useEffect)(()=>{if(e)return VK(t=>{t===e&&L()})},[e,L]),(0,X.useEffect)(()=>{if(!e)return;let t=UK(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})});return()=>{t()}},[e,L]),(0,X.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})},dX);return()=>{window.clearInterval(t)}},[e,L]);let R=(0,X.useMemo)(()=>{let e=typeof d?.diff==`string`?d.diff:``;return e.trim()?Jm(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:pX(e)})):[]},[d]),ee=(0,X.useMemo)(()=>{let e=new Map;for(let t of R)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[R]),z=(0,X.useMemo)(()=>yX({diffResponse:d,gitStatus:p}),[d,p]);(0,X.useEffect)(()=>{if(O!==`all`&&!(!d&&!p)){if(z.length===0){o(e=>({...e,selectedDiffPath:`all`}));return}z.some(e=>e.path===O)||o(e=>({...e,selectedDiffPath:`all`}))}},[d,p,o,O,z]);let B=O===`all`?null:ee.get(O)??null,V=(0,X.useMemo)(()=>_X(R,B),[R,B]),te=(0,X.useMemo)(()=>O===`all`?R:B?[B]:[],[R,O,B]);(0,X.useEffect)(()=>{x(new Map)},[R]),(0,X.useEffect)(()=>{if(V.length===0)return;let e=!1,t=null,n=0,r=()=>{if(e)return;let i=V.slice(n,n+uX);i.length!==0&&(x(e=>{let t=new Map(e);for(let e of i){let n=mX(e);t.has(n)||t.set(n,hX(e))}return t}),n+=uX,n<V.length&&(t=window.setTimeout(r,0)))};return t=window.setTimeout(r,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[V]);let ne=(0,X.useMemo)(()=>{let e=new Map;for(let t of V.slice(0,uX))e.set(mX(t),hX(t));return e},[V]),re=(0,X.useMemo)(()=>te.map(e=>({...e,tokens:b.get(mX(e))??ne.get(mX(e))??null})),[ne,b,te]),ie=(0,X.useMemo)(()=>R.map(e=>({...e,tokens:null})),[R]),ae=(0,X.useMemo)(()=>vX(a.reviewComments),[a.reviewComments]),oe=ae.length,se=n&&!S&&oe>0,H=(0,X.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}))},[o]),le=(0,X.useCallback)(({filePath:e,changeKey:t,commentKey:r})=>{let i=N.get(r);if(i){o(e=>({...e,selectedDiffPath:i.filePath,activeReviewTarget:null,editingReviewCommentKey:r,reviewDraftInput:i.comment}));return}n&&o(n=>({...n,activeReviewTarget:{filePath:e,changeKey:t,commentKey:r},editingReviewCommentKey:null,reviewDraftInput:``}))},[n,o,N]),ue=(0,X.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``}))},[o]),de=(0,X.useCallback)(e=>{let t=N.has(e.commentKey);if(!n&&!t)return;let r=M.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;o(t=>{let n=new Map(t.reviewComments.map(e=>[pb(e.filePath,e.changeKey),e]));return n.set(e.commentKey,{scope:`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:mb(e.hunk,e.change),comment:r}),{...t,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[...n.values()]}})},[n,o,N,M]),G=(0,X.useCallback)(e=>{let t=N.get(e);t&&o(n=>({...n,selectedDiffPath:t.filePath,activeReviewTarget:null,editingReviewCommentKey:e,reviewDraftInput:t.comment}))},[o,N]),fe=(0,X.useCallback)(e=>{o(t=>({...t,activeReviewTarget:t.activeReviewTarget?.commentKey===e?null:t.activeReviewTarget,editingReviewCommentKey:t.editingReviewCommentKey===e?null:t.editingReviewCommentKey,reviewDraftInput:t.activeReviewTarget?.commentKey===e||t.editingReviewCommentKey===e?``:t.reviewDraftInput,reviewComments:t.reviewComments.filter(t=>pb(t.filePath,t.changeKey)!==e)}))},[o]),K=(0,X.useCallback)(async()=>{if(!se)return;C(!0);let e=Cb({drafts:ae,findings:[],githubComments:[],uncommittedFiles:R});try{await i(e),H(),Q.success(`Changes sent to chat.`,{id:`chat-diff-review-submit-success`})}catch(e){Q.error(gX(e,`Unable to send the changes right now.`),{id:`chat-diff-review-submit-error`})}finally{C(!1)}},[se,H,i,R,ae]),q=(0,X.useCallback)(e=>(0,Z.jsx)(kG,{reviewComments:ae,pendingFixCount:oe,triggerMode:e===`wide`?`full`:`compact`,canSendReview:se,isSubmittingReview:S,reviewSubmitDisabledReason:r??void 0,onClearPendingFixes:H,onSubmitReview:()=>{K()}}),[se,H,K,S,oe,ae,r]),me=c?(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close diff panel`,className:`text-muted-foreground hover:text-foreground`,onClick:c,children:(0,Z.jsx)(pe,{className:`h-4 w-4`})}):null,he=l?{"--chat-changes-panel-width":`${l}px`}:void 0;return(0,Z.jsx)(`aside`,{"data-testid":`chat-changes-panel`,"data-desktop-width":l?String(l):void 0,ref:u,style:he,className:W(`flex h-[26rem] min-h-0 w-full shrink-0 flex-col overflow-hidden border-t border-border/70 bg-background/20 xl:h-full xl:border-l xl:border-t-0`,l?`xl:w-[var(--chat-changes-panel-width)]`:`xl:w-[32rem]`),children:(0,Z.jsx)(xK,{selectedDiffPath:O,sidebarFiles:z,diffResponse:d,isDiffLoading:_,diffError:h,allDiffFiles:ie,renderedFiles:re,viewType:`unified`,onViewTypeChange:()=>{},onRetry:()=>{I()},activeReviewTarget:k,editingReviewCommentKey:A,reviewDraftInstanceKey:j,reviewDraftInput:M,reviewComments:ae,reviewFindings:[],githubComments:[],selectedReviewFindingIds:[],selectedGitHubCommentIds:[],canSelectReviewTarget:n,canEditActiveReviewDraft:n,reviewFindingsError:null,gitHubCommentsError:null,hasStaleReviewFindings:!1,onSelectReviewTarget:le,onToggleReviewFindingSelection:()=>{},onToggleGitHubCommentSelection:()=>{},onReviewDraftInputChange:e=>{o(t=>({...t,reviewDraftInput:e}))},onCancelReviewDraft:ue,onEditReviewDraft:G,onRemoveReviewDraft:fe,onSaveReviewDraft:de,diffThemeClassName:DK,resolveFilePath:mX,normalizeDiffPath:fX,emptyStateTitle:`No uncommitted changes.`,emptyStateDescription:`The current project branch is clean.`,filePickerControl:e=>(0,Z.jsx)(CX,{selectedDiffPath:O,sidebarFiles:z,diffStats:d?.stats??null,triggerMode:e===`wide`?`full`:`compact`,onSelectDiffPath:e=>{o(t=>({...t,selectedDiffPath:e}))}}),reviewSummaryControl:q,extraHeaderControl:me,surfaceVariant:`flat`,showViewTypeToggle:!1,gutterVariant:`compact`,isResizing:s,resizePlaceholderLineThreshold:200})})});wX.displayName=`ChatChangesPanel`;var TX=({projectId:e,messages:t,internalLog:n,pendingAgentTitle:r,streamingResponse:i,isRunning:a,isLoading:o=!1,canShowComposer:s,isExternallyResizing:c=!1,pendingAgentRevealKey:l=null,pendingAgentRevealDelayMs:u=0,composerFocusNonce:d=0,header:f,composerControls:p,composerInlineControls:m,composerTheme:h=`default`,layoutKey:g,scrollLayoutKey:_,followUpPrompt:v,followUpPlaceholder:y,emptyStateText:b=null,renderMessageFooter:x,isSendingFollowUp:S,followUpDisabledReason:C,onFollowUpPromptChange:w,onFollowUpKeyDown:T,onFollowUpSubmit:E})=>(0,Z.jsx)(LN,{projectId:e,messages:t,internalLog:n,pendingAgentTitle:r,streamingResponse:i,isRunning:a,isLoading:o,autoScrollBehavior:`sticky`,surfaceVariant:`chat`,canShowComposer:s,header:f,composerControls:p,composerInlineControls:m,composerTheme:h,composerSize:`compact-on-laptop`,showThinkingPlacement:`header`,pinComposerToBottom:!0,isExternallyResizing:c,pendingAgentRevealKey:l,pendingAgentRevealDelayMs:u,composerFocusNonce:d,layoutKey:g,scrollLayoutKey:_,followUpPrompt:v,followUpPlaceholder:y,emptyStateText:b,autoFocusComposer:!0,renderMessageFooter:x,isSendingFollowUp:S,followUpDisabledReason:C,onFollowUpPromptChange:w,onFollowUpKeyDown:T,onFollowUpSubmit:E}),EX={default:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,muted:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`},DX=({tone:e=`default`,className:t,children:n,...r})=>(0,Z.jsx)(J,{variant:`outline`,className:W(EX[e],t),...r,children:n}),OX=()=>({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),kX=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
139
+ `).length:0,MK=e=>{let t=e.diff??``;return t?t.length<=OK&&jK(t)<=kK:!0},NK=({scope:e,projectId:t,ticketId:n})=>e===`project_root`?t?`project_root:${t}`:null:n?`ticket:${t??`none`}:${n}`:null,PK=e=>e?AK.get(e)??null:null,FK=({cacheKey:e,diffResponse:t,gitStatus:n})=>{let r=n.workspace_signature?.trim();if(!(!e||!r)){if(!MK(t)){AK.delete(e);return}AK.set(e,{diffResponse:t,gitStatus:n,workspaceSignature:r})}},IK=e=>{e&&AK.delete(e)},LK={css:`css`,html:`markup`,htm:`markup`,js:`javascript`,jsx:`jsx`,json:`json`,md:`markdown`,markdown:`markdown`,sh:`bash`,ts:`typescript`,tsx:`tsx`,yaml:`yaml`,yml:`yaml`},RK=e=>{if(!e)return null;let t=e.split(` -> `),n=t[t.length-1]??e,r=n.split(`/`),i=r[r.length-1]??n,a=``;if(i.includes(`.`)){let e=i.split(`.`);a=e[e.length-1]?.toLowerCase()??``}return LK[a]??null},zK=new Set,BK=e=>{e&&zK.forEach(t=>t(e))},VK=e=>(zK.add(e),()=>{zK.delete(e)}),HK=300,UK=(e,t={})=>{let n=t.dedupeMs??HK,r=0,i=()=>{if(document.visibilityState!==`visible`)return;let t=Date.now();t-r<n||(r=t,e())};return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,i)}},WK=i(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),GK=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.normal={},n.property={};function r(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}})),KK=i(((e,t)=>{var n=WK(),r=GK();t.exports=i;function i(e){for(var t=e.length,i=[],a=[],o=-1,s,c;++o<t;)s=e[o],i.push(s.property),a.push(s.normal),c=s.space;return new r(n.apply(null,i),n.apply(null,a),c)}})),qK=i(((e,t)=>{t.exports=n;function n(e){return e.toLowerCase()}})),JK=i(((e,t)=>{t.exports=r;var n=r.prototype;n.space=null,n.attribute=null,n.property=null,n.boolean=!1,n.booleanish=!1,n.overloadedBoolean=!1,n.number=!1,n.commaSeparated=!1,n.spaceSeparated=!1,n.commaOrSpaceSeparated=!1,n.mustUseProperty=!1,n.defined=!1;function r(e,t){this.property=e,this.attribute=t}})),YK=i((e=>{var t=0;e.boolean=n(),e.booleanish=n(),e.overloadedBoolean=n(),e.number=n(),e.spaceSeparated=n(),e.commaSeparated=n(),e.commaOrSpaceSeparated=n();function n(){return 2**++t}})),XK=i(((e,t)=>{var n=JK(),r=YK();t.exports=o,o.prototype=new n,o.prototype.defined=!0;var i=[`boolean`,`booleanish`,`overloadedBoolean`,`number`,`commaSeparated`,`spaceSeparated`,`commaOrSpaceSeparated`],a=i.length;function o(e,t,o,c){var l=-1,u;for(s(this,`space`,c),n.call(this,e,t);++l<a;)u=i[l],s(this,u,(o&r[u])===r[u])}function s(e,t,n){n&&(e[t]=n)}})),ZK=i(((e,t)=>{var n=qK(),r=GK(),i=XK();t.exports=a;function a(e){var t=e.space,a=e.mustUseProperty||[],o=e.attributes||{},s=e.properties,c=e.transform,l={},u={},d,f;for(d in s)f=new i(d,c(o,d),s[d],t),a.indexOf(d)!==-1&&(f.mustUseProperty=!0),l[d]=f,u[n(d)]=d,u[n(f.attribute)]=d;return new r(l,u,t)}})),QK=i(((e,t)=>{t.exports=ZK()({space:`xlink`,transform:n,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function n(e,t){return`xlink:`+t.slice(5).toLowerCase()}})),$K=i(((e,t)=>{t.exports=ZK()({space:`xml`,transform:n,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function n(e,t){return`xml:`+t.slice(3).toLowerCase()}})),eq=i(((e,t)=>{t.exports=n;function n(e,t){return t in e?e[t]:t}})),tq=i(((e,t)=>{var n=eq();t.exports=r;function r(e,t){return n(e,t.toLowerCase())}})),nq=i(((e,t)=>{t.exports=ZK()({space:`xmlns`,attributes:{xmlnsxlink:`xmlns:xlink`},transform:tq(),properties:{xmlns:null,xmlnsXLink:null}})})),rq=i(((e,t)=>{var n=YK(),r=ZK(),i=n.booleanish,a=n.number,o=n.spaceSeparated;t.exports=r({transform:s,properties:{ariaActiveDescendant:null,ariaAtomic:i,ariaAutoComplete:null,ariaBusy:i,ariaChecked:i,ariaColCount:a,ariaColIndex:a,ariaColSpan:a,ariaControls:o,ariaCurrent:null,ariaDescribedBy:o,ariaDetails:null,ariaDisabled:i,ariaDropEffect:o,ariaErrorMessage:null,ariaExpanded:i,ariaFlowTo:o,ariaGrabbed:i,ariaHasPopup:null,ariaHidden:i,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:o,ariaLevel:a,ariaLive:null,ariaModal:i,ariaMultiLine:i,ariaMultiSelectable:i,ariaOrientation:null,ariaOwns:o,ariaPlaceholder:null,ariaPosInSet:a,ariaPressed:i,ariaReadOnly:i,ariaRelevant:null,ariaRequired:i,ariaRoleDescription:o,ariaRowCount:a,ariaRowIndex:a,ariaRowSpan:a,ariaSelected:i,ariaSetSize:a,ariaSort:null,ariaValueMax:a,ariaValueMin:a,ariaValueNow:a,ariaValueText:null,role:null}});function s(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}})),iq=i(((e,t)=>{var n=YK(),r=ZK(),i=tq(),a=n.boolean,o=n.overloadedBoolean,s=n.booleanish,c=n.number,l=n.spaceSeparated,u=n.commaSeparated;t.exports=r({space:`html`,attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},transform:i,mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:u,acceptCharset:l,accessKey:l,action:null,allow:null,allowFullScreen:a,allowPaymentRequest:a,allowUserMedia:a,alt:null,as:null,async:a,autoCapitalize:null,autoComplete:l,autoFocus:a,autoPlay:a,capture:a,charSet:null,checked:a,cite:null,className:l,cols:c,colSpan:null,content:null,contentEditable:s,controls:a,controlsList:l,coords:c|u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:a,defer:a,dir:null,dirName:null,disabled:a,download:o,draggable:s,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:a,formTarget:null,headers:l,height:c,hidden:a,high:c,href:null,hrefLang:null,htmlFor:l,httpEquiv:l,id:null,imageSizes:null,imageSrcSet:u,inputMode:null,integrity:null,is:null,isMap:a,itemId:null,itemProp:l,itemRef:l,itemScope:a,itemType:l,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:a,low:c,manifest:null,max:null,maxLength:c,media:null,method:null,min:null,minLength:c,multiple:a,muted:a,name:null,nonce:null,noModule:a,noValidate:a,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:a,optimum:c,pattern:null,ping:l,placeholder:null,playsInline:a,poster:null,preload:null,readOnly:a,referrerPolicy:null,rel:l,required:a,reversed:a,rows:c,rowSpan:c,sandbox:l,scope:null,scoped:a,seamless:a,selected:a,shape:null,size:c,sizes:null,slot:null,span:c,spellCheck:s,src:null,srcDoc:null,srcLang:null,srcSet:u,start:c,step:null,style:null,tabIndex:c,target:null,title:null,translate:null,type:null,typeMustMatch:a,useMap:null,value:s,width:c,wrap:null,align:null,aLink:null,archive:l,axis:null,background:null,bgColor:null,border:c,borderColor:null,bottomMargin:c,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:a,declare:a,event:null,face:null,frame:null,frameBorder:null,hSpace:c,leftMargin:c,link:null,longDesc:null,lowSrc:null,marginHeight:c,marginWidth:c,noResize:a,noHref:a,noShade:a,noWrap:a,object:null,profile:null,prompt:null,rev:null,rightMargin:c,rules:null,scheme:null,scrolling:s,standby:null,summary:null,text:null,topMargin:c,valueType:null,version:null,vAlign:null,vLink:null,vSpace:c,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:a,disableRemotePlayback:a,prefix:null,property:null,results:c,security:null,unselectable:null}})})),aq=i(((e,t)=>{var n=KK(),r=QK();t.exports=n([$K(),r,nq(),rq(),iq()])})),oq=i(((e,t)=>{var n=qK(),r=XK(),i=JK(),a=`data`;t.exports=l;var o=/^data[-\w.:]+$/i,s=/-[a-z]/g,c=/[A-Z]/g;function l(e,t){var s=n(t),c=t,l=i;return s in e.normal?e.property[e.normal[s]]:(s.length>4&&s.slice(0,4)===a&&o.test(t)&&(t.charAt(4)===`-`?c=u(t):t=d(t),l=r),new l(c,t))}function u(e){var t=e.slice(5).replace(s,p);return a+t.charAt(0).toUpperCase()+t.slice(1)}function d(e){var t=e.slice(4);return s.test(t)?e:(t=t.replace(c,f),t.charAt(0)!==`-`&&(t=`-`+t),a+t)}function f(e){return`-`+e.toLowerCase()}function p(e){return e.charAt(1).toUpperCase()}})),sq=i(((e,t)=>{t.exports=r;var n=/[#.]/g;function r(e,t){for(var r=e||``,i=t||`div`,a={},o=0,s,c,l;o<r.length;)n.lastIndex=o,l=n.exec(r),s=r.slice(o,l?l.index:r.length),s&&(c?c===`#`?a.id=s:a.className?a.className.push(s):a.className=[s]:i=s,o+=s.length),l&&(c=l[0],o++);return{type:`element`,tagName:i,properties:a,children:[]}}})),cq=i((e=>{e.parse=i,e.stringify=a;var t=``,n=` `,r=/[ \t\n\r\f]+/g;function i(e){var n=String(e||t).trim();return n===t?[]:n.split(r)}function a(e){return e.join(n).trim()}})),lq=i((e=>{e.parse=i,e.stringify=a;var t=`,`,n=` `,r=``;function i(e){for(var n=[],i=String(e||r),a=i.indexOf(t),o=0,s=!1,c;!s;)a===-1&&(a=i.length,s=!0),c=i.slice(o,a).trim(),(c||!s)&&n.push(c),o=a+1,a=i.indexOf(t,o);return n}function a(e,i){var a=i||{},o=a.padLeft===!1?r:n,s=a.padRight?n:r;return e[e.length-1]===r&&(e=e.concat(r)),e.join(s+t+o).trim()}})),uq=i(((e,t)=>{var n=oq(),r=qK(),i=sq(),a=cq().parse,o=lq().parse;t.exports=c;var s={}.hasOwnProperty;function c(e,t,r){var c=r?h(r):null;return u;function u(e,n){var r=i(e,t),a=Array.prototype.slice.call(arguments,2),o=r.tagName.toLowerCase(),u;if(r.tagName=c&&s.call(c,o)?c[o]:o,n&&l(n,r)&&(a.unshift(n),n=null),n)for(u in n)p(r.properties,u,n[u]);return d(r.children,a),r.tagName===`template`&&(r.content={type:`root`,children:r.children},r.children=[]),r}function p(t,r,i){var s,c,l;i==null||i!==i||(s=n(e,r),c=s.property,l=i,typeof l==`string`&&(s.spaceSeparated?l=a(l):s.commaSeparated?l=o(l):s.commaOrSpaceSeparated&&(l=a(o(l).join(` `)))),c===`style`&&typeof i!=`string`&&(l=m(l)),c===`className`&&t.className&&(l=t.className.concat(l)),t[c]=f(s,c,l))}}function l(e,t){return typeof e==`string`||`length`in e||u(t.tagName,e)}function u(e,t){var n=t.type;return e===`input`||!n||typeof n!=`string`?!1:typeof t.children==`object`&&`length`in t.children?!0:(n=n.toLowerCase(),e===`button`?n!==`menu`&&n!==`submit`&&n!==`reset`&&n!==`button`:`value`in t)}function d(e,t){var n,r;if(typeof t==`string`||typeof t==`number`){e.push({type:`text`,value:String(t)});return}if(typeof t==`object`&&`length`in t){for(n=-1,r=t.length;++n<r;)d(e,t[n]);return}if(typeof t!=`object`||!(`type`in t))throw Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function f(e,t,n){var r,i,a;if(typeof n!=`object`||!(`length`in n))return p(e,t,n);for(i=n.length,r=-1,a=[];++r<i;)a[r]=p(e,t,n[r]);return a}function p(e,t,n){var i=n;return e.number||e.positiveNumber?!isNaN(i)&&i!==``&&(i=Number(i)):(e.boolean||e.overloadedBoolean)&&typeof i==`string`&&(i===``||r(n)===r(t))&&(i=!0),i}function m(e){var t=[],n;for(n in e)t.push([n,e[n]].join(`: `));return t.join(`; `)}function h(e){for(var t=e.length,n=-1,r={},i;++n<t;)i=e[n],r[i.toLowerCase()]=i;return r}})),dq=i(((e,t)=>{var n=aq(),r=uq()(n,`div`);r.displayName=`html`,t.exports=r})),fq=i(((e,t)=>{t.exports=dq()})),pq=r({AElig:()=>`Æ`,AMP:()=>`&`,Aacute:()=>`Á`,Acirc:()=>`Â`,Agrave:()=>`À`,Aring:()=>`Å`,Atilde:()=>`Ã`,Auml:()=>`Ä`,COPY:()=>`©`,Ccedil:()=>`Ç`,ETH:()=>`Ð`,Eacute:()=>`É`,Ecirc:()=>`Ê`,Egrave:()=>`È`,Euml:()=>`Ë`,GT:()=>`>`,Iacute:()=>`Í`,Icirc:()=>`Î`,Igrave:()=>`Ì`,Iuml:()=>`Ï`,LT:()=>`<`,Ntilde:()=>`Ñ`,Oacute:()=>`Ó`,Ocirc:()=>`Ô`,Ograve:()=>`Ò`,Oslash:()=>`Ø`,Otilde:()=>`Õ`,Ouml:()=>`Ö`,QUOT:()=>`"`,REG:()=>`®`,THORN:()=>`Þ`,Uacute:()=>`Ú`,Ucirc:()=>`Û`,Ugrave:()=>`Ù`,Uuml:()=>`Ü`,Yacute:()=>`Ý`,aacute:()=>`á`,acirc:()=>`â`,acute:()=>`´`,aelig:()=>`æ`,agrave:()=>`à`,amp:()=>`&`,aring:()=>`å`,atilde:()=>`ã`,auml:()=>`ä`,brvbar:()=>`¦`,ccedil:()=>`ç`,cedil:()=>`¸`,cent:()=>`¢`,copy:()=>`©`,curren:()=>`¤`,default:()=>mq,deg:()=>`°`,divide:()=>`÷`,eacute:()=>`é`,ecirc:()=>`ê`,egrave:()=>`è`,eth:()=>`ð`,euml:()=>`ë`,frac12:()=>`½`,frac14:()=>`¼`,frac34:()=>`¾`,gt:()=>`>`,iacute:()=>`í`,icirc:()=>`î`,iexcl:()=>`¡`,igrave:()=>`ì`,iquest:()=>`¿`,iuml:()=>`ï`,laquo:()=>`«`,lt:()=>`<`,macr:()=>`¯`,micro:()=>`µ`,middot:()=>`·`,nbsp:()=>`\xA0`,not:()=>`¬`,ntilde:()=>`ñ`,oacute:()=>`ó`,ocirc:()=>`ô`,ograve:()=>`ò`,ordf:()=>`ª`,ordm:()=>`º`,oslash:()=>`ø`,otilde:()=>`õ`,ouml:()=>`ö`,para:()=>`¶`,plusmn:()=>`±`,pound:()=>`£`,quot:()=>`"`,raquo:()=>`»`,reg:()=>`®`,sect:()=>`§`,shy:()=>`­`,sup1:()=>`¹`,sup2:()=>`²`,sup3:()=>`³`,szlig:()=>`ß`,thorn:()=>`þ`,times:()=>`×`,uacute:()=>`ú`,ucirc:()=>`û`,ugrave:()=>`ù`,uml:()=>`¨`,uuml:()=>`ü`,yacute:()=>`ý`,yen:()=>`¥`,yuml:()=>`ÿ`}),mq,hq=n((()=>{mq={AElig:`Æ`,AMP:`&`,Aacute:`Á`,Acirc:`Â`,Agrave:`À`,Aring:`Å`,Atilde:`Ã`,Auml:`Ä`,COPY:`©`,Ccedil:`Ç`,ETH:`Ð`,Eacute:`É`,Ecirc:`Ê`,Egrave:`È`,Euml:`Ë`,GT:`>`,Iacute:`Í`,Icirc:`Î`,Igrave:`Ì`,Iuml:`Ï`,LT:`<`,Ntilde:`Ñ`,Oacute:`Ó`,Ocirc:`Ô`,Ograve:`Ò`,Oslash:`Ø`,Otilde:`Õ`,Ouml:`Ö`,QUOT:`"`,REG:`®`,THORN:`Þ`,Uacute:`Ú`,Ucirc:`Û`,Ugrave:`Ù`,Uuml:`Ü`,Yacute:`Ý`,aacute:`á`,acirc:`â`,acute:`´`,aelig:`æ`,agrave:`à`,amp:`&`,aring:`å`,atilde:`ã`,auml:`ä`,brvbar:`¦`,ccedil:`ç`,cedil:`¸`,cent:`¢`,copy:`©`,curren:`¤`,deg:`°`,divide:`÷`,eacute:`é`,ecirc:`ê`,egrave:`è`,eth:`ð`,euml:`ë`,frac12:`½`,frac14:`¼`,frac34:`¾`,gt:`>`,iacute:`í`,icirc:`î`,iexcl:`¡`,igrave:`ì`,iquest:`¿`,iuml:`ï`,laquo:`«`,lt:`<`,macr:`¯`,micro:`µ`,middot:`·`,nbsp:`\xA0`,not:`¬`,ntilde:`ñ`,oacute:`ó`,ocirc:`ô`,ograve:`ò`,ordf:`ª`,ordm:`º`,oslash:`ø`,otilde:`õ`,ouml:`ö`,para:`¶`,plusmn:`±`,pound:`£`,quot:`"`,raquo:`»`,reg:`®`,sect:`§`,shy:`­`,sup1:`¹`,sup2:`²`,sup3:`³`,szlig:`ß`,thorn:`þ`,times:`×`,uacute:`ú`,ucirc:`û`,ugrave:`ù`,uml:`¨`,uuml:`ü`,yacute:`ý`,yen:`¥`,yuml:`ÿ`}})),gq=r({default:()=>_q}),_q,vq=n((()=>{_q={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`}})),yq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}})),bq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}})),xq=i(((e,t)=>{t.exports=n;function n(e){var t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}})),Sq=i(((e,t)=>{var n=xq(),r=yq();t.exports=i;function i(e){return n(e)||r(e)}})),Cq=i(((e,t)=>{var n,r=59;t.exports=i;function i(e){var t=`&`+e+`;`,i;return n||=document.createElement(`i`),n.innerHTML=t,i=n.textContent,i.charCodeAt(i.length-1)===r&&e!==`semi`||i===t?!1:i}})),wq=i(((e,n)=>{var r=(hq(),t(pq).default),i=(vq(),t(gq).default),a=yq(),o=bq(),s=Sq(),c=Cq();n.exports=R;var l={}.hasOwnProperty,u=String.fromCharCode,d=Function.prototype,f={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},p=9,m=10,h=12,g=32,_=38,v=59,y=60,b=61,x=35,S=88,C=120,w=65533,T=`named`,E=`hexadecimal`,D=`decimal`,O={};O[E]=16,O[D]=10;var k={};k[T]=s,k[D]=a,k[E]=o;var A=1,j=2,M=3,N=4,P=5,F=6,I=7,L={};L[A]=`Named character references must be terminated by a semicolon`,L[j]=`Numeric character references must be terminated by a semicolon`,L[M]=`Named character references cannot be empty`,L[N]=`Numeric character references cannot be empty`,L[P]=`Named character references must be known`,L[F]=`Numeric character references cannot be disallowed`,L[I]=`Numeric character references cannot be outside the permissible Unicode range`;function R(e,t){var n={},r,i;for(i in t||={},f)r=t[i],n[i]=r??f[i];return(n.position.indent||n.position.start)&&(n.indent=n.position.indent||[],n.position=n.position.start),ee(e,n)}function ee(e,t){var n=t.additional,a=t.nonTerminated,o=t.text,f=t.reference,R=t.warning,ee=t.textContext,V=t.referenceContext,te=t.warningContext,ne=t.position,re=t.indent||[],ie=e.length,ae=0,oe=-1,se=ne.column||1,H=ne.line||1,ce=``,U=[],le,ue,W,de,G,fe,K,q,pe,me,he,ge,_e,ve,ye,be,xe,Se,Ce;for(typeof n==`string`&&(n=n.charCodeAt(0)),be=we(),q=R?Te:d,ae--,ie++;++ae<ie;)if(G===m&&(se=re[oe]||1),G=e.charCodeAt(ae),G===_){if(K=e.charCodeAt(ae+1),K===p||K===m||K===h||K===g||K===_||K===y||K!==K||n&&K===n){ce+=u(G),se++;continue}for(_e=ae+1,ge=_e,Ce=_e,K===x?(Ce=++ge,K=e.charCodeAt(Ce),K===S||K===C?(ve=E,Ce=++ge):ve=D):ve=T,le=``,he=``,de=``,ye=k[ve],Ce--;++Ce<ie&&(K=e.charCodeAt(Ce),ye(K));)de+=u(K),ve===T&&l.call(r,de)&&(le=de,he=r[de]);W=e.charCodeAt(Ce)===v,W&&(Ce++,ue=ve===T?c(de):!1,ue&&(le=de,he=ue)),Se=1+Ce-_e,!W&&!a||(de?ve===T?(W&&!he?q(P,1):(le!==de&&(Ce=ge+le.length,Se=1+Ce-ge,W=!1),W||(pe=le?A:M,t.attribute?(K=e.charCodeAt(Ce),K===b?(q(pe,Se),he=null):s(K)?he=null:q(pe,Se)):q(pe,Se))),fe=he):(W||q(j,Se),fe=parseInt(de,O[ve]),z(fe)?(q(I,Se),fe=u(w)):fe in i?(q(F,Se),fe=i[fe]):(me=``,B(fe)&&q(F,Se),fe>65535&&(fe-=65536,me+=u(fe>>>10|55296),fe=56320|fe&1023),fe=me+u(fe))):ve!==T&&q(N,Se)),fe?(Ee(),be=we(),ae=Ce-1,se+=Ce-_e+1,U.push(fe),xe=we(),xe.offset++,f&&f.call(V,fe,{start:be,end:xe},e.slice(_e-1,Ce)),be=xe):(de=e.slice(_e-1,Ce),ce+=de,se+=de.length,ae=Ce-1)}else G===10&&(H++,oe++,se=0),G===G?(ce+=u(G),se++):Ee();return U.join(``);function we(){return{line:H,column:se,offset:ae+(ne.offset||0)}}function Te(e,t){var n=we();n.column+=t,n.offset+=t,R.call(te,L[e],n,e)}function Ee(){ce&&=(U.push(ce),o&&o.call(ee,ce,{start:be,end:we()}),``)}}function z(e){return e>=55296&&e<=57343||e>1114111}function B(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}})),Tq=i(((e,t)=>{var n=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,r={},i={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof a?new a(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/\u00a0/g,` `)},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,`__id`,{value:++n}),e.__id},clone:function e(t,n){n||={};var r,a;switch(i.util.type(t)){case`Object`:if(a=i.util.objId(t),n[a])return n[a];for(var o in r={},n[a]=r,t)t.hasOwnProperty(o)&&(r[o]=e(t[o],n));return r;case`Array`:return a=i.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return`none`},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,`gi`),``),e.classList.add(`language-`+n)},currentScript:function(){if(typeof document>`u`)return null;if(`currentScript`in document)return document.currentScript;try{throw Error()}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var t=document.getElementsByTagName(`script`);for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var r=`no-`+t;e;){var i=e.classList;if(i.contains(t))return!0;if(i.contains(r))return!1;e=e.parentElement}return!!n}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,t){var n=i.util.clone(i.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=i.languages;var a=r[e],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==t)for(var c in n)n.hasOwnProperty(c)&&(o[c]=n[c]);n.hasOwnProperty(s)||(o[s]=a[s])}var l=r[e];return r[e]=o,i.languages.DFS(i.languages,function(t,n){n===l&&t!=e&&(this[t]=o)}),o},DFS:function e(t,n,r,a){a||={};var o=i.util.objId;for(var s in t)if(t.hasOwnProperty(s)){n.call(t,s,t[s],r||s);var c=t[s],l=i.util.type(c);l===`Object`&&!a[o(c)]?(a[o(c)]=!0,e(c,n,null,a)):l===`Array`&&!a[o(c)]&&(a[o(c)]=!0,e(c,n,s,a))}}},plugins:{},highlightAll:function(e,t){i.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var r={callback:n,container:e,selector:`code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code`};i.hooks.run(`before-highlightall`,r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),i.hooks.run(`before-all-elements-highlight`,r);for(var a=0,o;o=r.elements[a++];)i.highlightElement(o,t===!0,r.callback)},highlightElement:function(t,n,r){var a=i.util.getLanguage(t),o=i.languages[a];i.util.setLanguage(t,a);var s=t.parentElement;s&&s.nodeName.toLowerCase()===`pre`&&i.util.setLanguage(s,a);var c={element:t,language:a,grammar:o,code:t.textContent};function l(e){c.highlightedCode=e,i.hooks.run(`before-insert`,c),c.element.innerHTML=c.highlightedCode,i.hooks.run(`after-highlight`,c),i.hooks.run(`complete`,c),r&&r.call(c.element)}if(i.hooks.run(`before-sanity-check`,c),s=c.element.parentElement,s&&s.nodeName.toLowerCase()===`pre`&&!s.hasAttribute(`tabindex`)&&s.setAttribute(`tabindex`,`0`),!c.code){i.hooks.run(`complete`,c),r&&r.call(c.element);return}if(i.hooks.run(`before-highlight`,c),!c.grammar){l(i.util.encode(c.code));return}if(n&&e.Worker){var u=new Worker(i.filename);u.onmessage=function(e){l(e.data)},u.postMessage(JSON.stringify({language:c.language,code:c.code,immediateClose:!0}))}else l(i.highlight(c.code,c.grammar,c.language))},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(i.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=i.tokenize(r.code,r.grammar),i.hooks.run(`after-tokenize`,r),a.stringify(i.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new c;return l(i,i.head,e),s(e,i,t,i.head,0),d(i)},hooks:{all:{},add:function(e,t){var n=i.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=i.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:a};e.Prism=i;function a(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}a.stringify=function e(t,n){if(typeof t==`string`)return t;if(Array.isArray(t)){var r=``;return t.forEach(function(t){r+=e(t,n)}),r}var a={type:t.type,content:e(t.content,n),tag:`span`,classes:[`token`,t.type],attributes:{},language:n},o=t.alias;o&&(Array.isArray(o)?Array.prototype.push.apply(a.classes,o):a.classes.push(o)),i.hooks.run(`wrap`,a);var s=``;for(var c in a.attributes)s+=` `+c+`="`+(a.attributes[c]||``).replace(/"/g,`&quot;`)+`"`;return`<`+a.tag+` class="`+a.classes.join(` `)+`"`+s+`>`+a.content+`</`+a.tag+`>`};function o(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function s(e,t,n,r,c,d){for(var f in n)if(!(!n.hasOwnProperty(f)||!n[f])){var p=n[f];p=Array.isArray(p)?p:[p];for(var m=0;m<p.length;++m){if(d&&d.cause==f+`,`+m)return;var h=p[m],g=h.inside,_=!!h.lookbehind,v=!!h.greedy,y=h.alias;if(v&&!h.pattern.global){var b=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,b+`g`)}for(var x=h.pattern||h,S=r.next,C=c;S!==t.tail&&!(d&&C>=d.reach);C+=S.value.length,S=S.next){var w=S.value;if(t.length>e.length)return;if(!(w instanceof a)){var T=1,E;if(v){if(E=o(x,C,e,_),!E||E.index>=e.length)break;var D=E.index,O=E.index+E[0].length,k=C;for(k+=S.value.length;D>=k;)S=S.next,k+=S.value.length;if(k-=S.value.length,C=k,S.value instanceof a)continue;for(var A=S;A!==t.tail&&(k<O||typeof A.value==`string`);A=A.next)T++,k+=A.value.length;T--,w=e.slice(C,k),E.index-=C}else if(E=o(x,0,w,_),!E)continue;var D=E.index,j=E[0],M=w.slice(0,D),N=w.slice(D+j.length),P=C+w.length;d&&P>d.reach&&(d.reach=P);var F=S.prev;M&&(F=l(t,F,M),C+=M.length),u(t,F,T);var I=new a(f,g?i.tokenize(j,g):j,y,j);if(S=l(t,F,I),N&&l(t,S,N),T>1){var L={cause:f+`,`+m,reach:P};s(e,t,n,S.prev,C,L),d&&L.reach>d.reach&&(d.reach=L.reach)}}}}}}function c(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function l(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function u(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function d(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}if(!e.document)return e.addEventListener&&(i.disableWorkerMessageHandler||e.addEventListener(`message`,function(t){var n=JSON.parse(t.data),r=n.language,a=n.code,o=n.immediateClose;e.postMessage(i.highlight(a,i.languages[r],r)),o&&e.close()},!1)),i;var f=i.util.currentScript();f&&(i.filename=f.src,f.hasAttribute(`data-manual`)&&(i.manual=!0));function p(){i.manual||i.highlightAll()}if(!i.manual){var m=document.readyState;m===`loading`||m===`interactive`&&f&&f.defer?document.addEventListener(`DOMContentLoaded`,p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return i}(typeof window<`u`?window:typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope?self:{});t!==void 0&&t.exports&&(t.exports=n),typeof global<`u`&&(global.Prism=n)})),Eq=i(((e,t)=>{t.exports=n,n.displayName=`markup`,n.aliases=[`html`,`mathml`,`svg`,`xml`,`ssml`,`atom`,`rss`];function n(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&amp;/,`&`))}),Object.defineProperty(e.languages.markup.tag,`addInlined`,{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,`addAttribute`,{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}})),Dq=i(((e,t)=>{t.exports=n,n.displayName=`css`,n.aliases=[];function n(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}})),Oq=i(((e,t)=>{t.exports=n,n.displayName=`clike`,n.aliases=[];function n(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}})),kq=i(((e,t)=>{t.exports=n,n.displayName=`javascript`,n.aliases=[`js`];function n(e){e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}})),Aq=i(((e,t)=>{var n=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},r=C();n.Prism={manual:!0,disableWorkerMessageHandler:!0};var i=fq(),a=wq(),o=Tq(),s=Eq(),c=Dq(),l=Oq(),u=kq();r();var d={}.hasOwnProperty;function f(){}f.prototype=o;var p=new f;t.exports=p,p.highlight=g,p.register=m,p.alias=h,p.registered=_,p.listLanguages=v,m(s),m(c),m(l),m(u),p.util.encode=x,p.Token.stringify=y;function m(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `grammar`, got `"+e+"`");p.languages[e.displayName]===void 0&&e(p)}function h(e,t){var n=p.languages,r=e,i,a,o,s;for(i in t&&(r={},r[e]=t),r)for(a=r[i],a=typeof a==`string`?[a]:a,o=a.length,s=-1;++s<o;)n[a[s]]=n[i]}function g(e,t){var n=o.highlight,r;if(typeof e!=`string`)throw Error("Expected `string` for `value`, got `"+e+"`");if(p.util.type(t)===`Object`)r=t,t=null;else{if(typeof t!=`string`)throw Error("Expected `string` for `name`, got `"+t+"`");if(d.call(p.languages,t))r=p.languages[t];else throw Error("Unknown language: `"+t+"` is not registered")}return n.call(this,e,r,t)}function _(e){if(typeof e!=`string`)throw Error("Expected `string` for `language`, got `"+e+"`");return d.call(p.languages,e)}function v(){var e=p.languages,t=[],n;for(n in e)d.call(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function y(e,t,n){var r;return typeof e==`string`?{type:`text`,value:e}:p.util.type(e)===`Array`?b(e,t):(r={type:e.type,content:p.Token.stringify(e.content,t,n),tag:`span`,classes:[`token`,e.type],attributes:{},language:t,parent:n},e.alias&&(r.classes=r.classes.concat(e.alias)),p.hooks.run(`wrap`,r),i(r.tag+`.`+r.classes.join(`.`),S(r.attributes),r.content))}function b(e,t){for(var n=[],r=e.length,i=-1,a;++i<r;)a=e[i],a!==``&&a!=null&&n.push(a);for(i=-1,r=n.length;++i<r;)a=n[i],n[i]=p.Token.stringify(a,t,n);return n}function x(e){return e}function S(e){for(var t in e)e[t]=a(e[t]);return e}function C(){var e=`Prism`in n,t=e?n.Prism:void 0;return r;function r(){e?n.Prism=t:delete n.Prism,e=void 0,t=void 0}}})),jq=i(((e,t)=>{t.exports=n,n.displayName=`bash`,n.aliases=[`shell`];function n(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.shell=e.languages.bash})(e)}})),Mq=i(((e,t)=>{t.exports=n,n.displayName=`json`,n.aliases=[`webmanifest`];function n(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}})),Nq=i(((e,t)=>{t.exports=n,n.displayName=`jsx`,n.aliases=[];function n(e){(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){e.language!==`jsx`&&e.language!==`tsx`||s(e.tokens)})})(e)}})),Pq=i(((e,t)=>{t.exports=n,n.displayName=`markdown`,n.aliases=[`md`];function n(e){(function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(l(t.content.value),s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}});var o=RegExp(e.languages.markup.tag.pattern.source,`gi`),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;function l(e){var t=e.replace(o,``);return t=t.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){return t=t.toLowerCase(),t[0]===`#`?c(t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1))):s[t]||e}),t}e.languages.md=e.languages.markdown})(e)}})),Fq=i(((e,t)=>{t.exports=n,n.displayName=`typescript`,n.aliases=[`ts`];function n(e){(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}})),Iq=i(((e,t)=>{var n=Nq(),r=Fq();t.exports=i,i.displayName=`tsx`,i.aliases=[];function i(e){e.register(n),e.register(r),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}})),Lq=i(((e,t)=>{t.exports=n,n.displayName=`yaml`,n.aliases=[`yml`];function n(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}})),Rq=e(Aq(),1),zq=e(jq(),1),Bq=e(Dq(),1),Vq=e(kq(),1),Hq=e(Mq(),1),Uq=e(Nq(),1),Wq=e(Pq(),1),Gq=e(Eq(),1),Kq=e(Iq(),1),qq=e(Fq(),1),Jq=e(Lq(),1),Yq=e=>{let t=e.displayName;!t||Rq.default.registered(t)||Rq.default.register(e)};Yq(Gq.default),Yq(Bq.default),Yq(Vq.default),Yq(qq.default),Yq(Kq.default),Yq(Hq.default),Yq(Uq.default),Yq(Wq.default),Yq(Jq.default),Yq(zq.default);var Xq=r({TicketChangesModal:()=>TJ}),Zq=4,Qq=1500,$q=`archon.ticket-changes.review-comments`,eJ=[],tJ=[],nJ=[],rJ=e=>new Set(e.map(e=>e.path)),iJ=(e,t)=>{if(!e)return null;if(e.blocked_reason)return e.blocked_reason;let n=e.files.find(e=>!t.has(e.path)&&e.staged);return n?`"${n.path}" already has staged changes. Finish that commit in the terminal first.`:null},aJ=e=>e.replace(/^[ab]\//,``),oJ=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?aJ(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?aJ(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},sJ=e=>{let[t,n]=oJ(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},cJ=e=>{let[t,n]=oJ(e);return t??n??null},lJ=e=>e.hunks.reduce((e,t)=>e+t.changes.length,0),uJ=e=>{if(lJ(e)>Qq)return null;let t=RK(cJ(e));if(!t)return null;try{return rb(e.hunks,{highlight:!0,refractor:Rq.default,language:t,enhancers:[tb(e.hunks)]})}catch{return null}},dJ=(e,t)=>e instanceof Error?e.message:t,fJ=(e,t)=>`${$q}:${e}:${t}`,pJ=()=>({activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map,signature:null}),mJ=()=>({uncommitted:pJ(),bundle_diff:pJ()}),hJ=e=>({uncommitted:e(),bundle_diff:e()}),gJ=()=>hJ(()=>new Map),_J=e=>{let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^e.charCodeAt(n);return`${e.length}:${t>>>0}`},vJ=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return(t.scope===void 0||t.scope===`uncommitted`||t.scope===`bundle_diff`)&&typeof t.filePath==`string`&&typeof t.changeKey==`string`&&typeof t.changeType==`string`&&(typeof t.oldLineNumber==`number`||t.oldLineNumber===null)&&(typeof t.newLineNumber==`number`||t.newLineNumber===null)&&typeof t.hunkHeader==`string`&&typeof t.lineContent==`string`&&typeof t.diffSnippet==`string`&&typeof t.comment==`string`},yJ=e=>{try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.diffSignature!=`string`||!Array.isArray(n.comments))return null;let r=n.comments.filter(vJ).map(e=>({scope:e.scope??`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.changeType,oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber,hunkHeader:e.hunkHeader,lineContent:e.lineContent,diffSnippet:e.diffSnippet,comment:e.comment}));return r.length===n.comments.length?{diffSignature:n.diffSignature,comments:r}:null}catch{return null}},bJ=e=>new Map(e.map(e=>[pb(e.filePath,e.changeKey),e])),xJ=(e,t)=>{e.set(t,(e.get(t)??0)+1)},SJ=e=>e.find(e=>e.trim())||``,CJ=({pullRequest:e,isLoading:t,isOpen:n,canCreate:r,disabledReason:i,isCreating:a,isSyncing:o,isGeneratingDescription:s,title:c,body:l,baseBranch:u,onOpenChange:d,onTitleChange:f,onBodyChange:p,onBaseBranchChange:m,showGenerateDescription:h,onGenerateDescription:g,onCreate:_})=>t?(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:`Loading PR...`}):o?(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`outline`,disabled:!0,className:`gap-2`,children:[(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}),`Checking PR...`]}):e?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border/80 bg-background/50 px-3 py-2`,children:[(0,Z.jsx)(Ew,{pullRequest:e}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-xs font-medium text-sky-300 underline underline-offset-2 hover:text-sky-200`,children:[`PR #`,e.number]})]}):(0,Z.jsxs)(Bl,{open:n,onOpenChange:d,children:[(0,Z.jsx)(Vl,{asChild:!0,children:(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`default`,disabled:!r,title:i,className:`gap-2`,children:[a?(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(xu,{className:`h-4 w-4`}),a?`Creating PR...`:`Create PR`]})}),(0,Z.jsxs)(Hl,{align:`end`,className:`z-[90] w-[36rem] max-w-[calc(100vw-2rem)] p-4`,children:[(0,Z.jsx)(Ul,{children:(0,Z.jsx)(Wl,{children:`Create pull request`})}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(Id,{label:`Title`,htmlFor:`bundle-pr-title`,children:(0,Z.jsx)(Me,{id:`bundle-pr-title`,value:c,onChange:e=>f(e.target.value),placeholder:`Bundle title`,disabled:a})}),(0,Z.jsx)(Id,{label:`Base branch`,htmlFor:`bundle-pr-base-branch`,description:`Optional. Leave blank to use the repository default branch.`,children:(0,Z.jsx)(Me,{id:`bundle-pr-base-branch`,value:u,onChange:e=>m(e.target.value),placeholder:`main`,disabled:a})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-[0.22em] text-muted-foreground`,htmlFor:`bundle-pr-body`,children:`Description`}),h&&(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:a||s,onClick:g,children:[s?(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}):null,s?`Generating...`:`Generate`]})]}),(0,Z.jsx)(El,{id:`bundle-pr-body`,value:l,onChange:e=>p(e.target.value),placeholder:`Summarize the bundle changes for reviewers.`,className:`min-h-40`,disabled:a})]}),(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(U,{type:`button`,size:`sm`,disabled:!c.trim()||a,onClick:_,children:a?`Creating...`:`Create PR`})})]})]})]}),wJ=(e,t,n)=>{if(n)return rJ(t);let r=new Set(t.map(e=>e.path));return new Set([...e].filter(e=>r.has(e)))},TJ=e=>{let{projectId:t,reviewCommentsBundleId:n=null,title:r,onClose:i,onSubmitReviewPrompt:a,canSubmitReviewPrompt:o=!1,reviewSubmitDisabledReason:s,canAddReviewComments:c=!0,canModifyChanges:l=!0,changesDisabledReason:d}=e,f=e.scope??`ticket`,{isGitHubConnected:p}=Cf(t),m=e.scope===`project_root`?null:e.ticketId,h=e.scope===`project_root`?void 0:e.onTicketUpdate,g=e.scope===`project_root`?void 0:e.onRequestTicketRefresh,[_,v]=(0,X.useState)(`uncommitted`),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),[T,E]=(0,X.useState)([]),[D,O]=(0,X.useState)(new Set),[k,A]=(0,X.useState)(`all`),[j,M]=(0,X.useState)(``),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(null),[L,R]=(0,X.useState)(null),[ee,z]=(0,X.useState)(null),[B,V]=(0,X.useState)(!0),[ne,re]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!0),[se,H]=(0,X.useState)(!1),[le,ue]=(0,X.useState)(!1),[W,de]=(0,X.useState)(!1),[G,fe]=(0,X.useState)(!1),[K,q]=(0,X.useState)(!1),[pe,me]=(0,X.useState)(`unified`),[he,ge]=(0,X.useState)(new Map),[_e,ve]=(0,X.useState)(nJ),[ye,be]=(0,X.useState)(mJ),[xe,Se]=(0,X.useState)(null),[we,Te]=(0,X.useState)([]),[De,Oe]=(0,X.useState)(null),[ke,Ae]=(0,X.useState)(null),[Me,Pe]=(0,X.useState)(new Set),[Fe,Ie]=(0,X.useState)(new Set),[Le,Re]=(0,X.useState)(!1),[ze,Be]=(0,X.useState)(null),[Ve,He]=(0,X.useState)(!1),[Ue,Ge]=(0,X.useState)(!1),[Ke,Y]=(0,X.useState)(``),[qe,Je]=(0,X.useState)(``),[Ye,Xe]=(0,X.useState)(``),[Qe,nt]=(0,X.useState)([]),[rt,it]=(0,X.useState)(!1),[at,lt]=(0,X.useState)(!1),[ut,dt]=(0,X.useState)(!1),ft=(0,X.useRef)(null),pt=(0,X.useRef)(!1),mt=(0,X.useRef)(null),ht=(0,X.useRef)(null),gt=(0,X.useRef)(0),_t=(0,X.useRef)(0),vt=(0,X.useRef)(hJ(()=>null)),yt=(0,X.useRef)(gJ()),bt=(0,X.useMemo)(()=>NK({scope:f,projectId:t,ticketId:m}),[t,f,m]),xt=(0,X.useCallback)(()=>{if(!m)throw Error(`Ticket changes require a ticket id.`);return m},[m]),St=(0,X.useCallback)(e=>{mt.current=e,b(e),P(null)},[]),At=(0,X.useCallback)((e,t)=>{FK({cacheKey:bt,diffResponse:e,gitStatus:t})},[bt]),jt=(0,X.useCallback)(e=>{mt.current&&FK({cacheKey:bt,diffResponse:mt.current,gitStatus:e})},[bt]),Mt=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ee(t)}return await Ct(xt(),t)},[t,xt,f]),Nt=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await ce(t)}return await wt(xt(),t,{refreshRemote:!1})},[t,xt,f]),Pt=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await Ne(t)}return await Ot(xt(),t)},[t,xt,f]),Ft=(0,X.useCallback)(async e=>f===`project_root`||!n||!t?null:await ot(t,n,e),[t,n,f]),It=(0,X.useCallback)(async e=>f===`project_root`||!n||!t?null:await Ze(t,n,e),[t,n,f]),Lt=(0,X.useCallback)(async e=>f===`project_root`||!n||!t?null:await st(t,n,e),[t,n,f]),Rt=(0,X.useCallback)(async e=>f===`project_root`||!n||!t?null:await ct(t,n,e),[t,n,f]),zt=(0,X.useCallback)((e,t)=>{be(n=>({...n,[e]:t(n[e])}))},[]),Bt=(0,X.useCallback)(async e=>{if(f===`project_root`||!n||!t)throw Error(`Pull request description generation requires a bundle context.`);return await et(t,n,e)},[t,n,f]),Vt=(0,X.useCallback)(async e=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await te(t,e)}return await Tt(xt(),t,e)},[t,xt,f]),Ht=(0,X.useCallback)(async e=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await je(t,e)}return await Et(xt(),t,e)},[t,xt,f]),Ut=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await We(t)}return await Dt(xt(),t)},[t,xt,f]),Wt=(0,X.useCallback)(async()=>{if(f===`project_root`){if(!t)throw Error(`Project changes require a project id.`);return await u(t)}return await kt(xt(),t)},[t,xt,f]),Gt=(0,X.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=gt.current+1;gt.current=r,H(!0),n||z(null);try{let t=await Pt();if(!e()||gt.current!==r)return;E(t.commits),z(null)}catch(t){if(!e()||gt.current!==r)return;z(dJ(t,`Unable to load local commits right now.`)),n||E([])}finally{e()&&gt.current===r&&H(!1)}},[Pt]),Kt=(0,X.useCallback)(()=>{gt.current+=1,E([]),z(null),H(!1)},[]),qt=(0,X.useCallback)((e,t={})=>{let n=t.resetSelection??!1;ht.current=e,w(e),R(null),O(t=>{let r=wJ(t,e.files,n||!pt.current);return pt.current=!0,r})},[]),Jt=(0,X.useCallback)(async(e={})=>{let t=e.preserveContent??!1,n=e.gitStatusForCache??null;t||P(null),V(!0);try{let e=await Mt();St(e),n&&At(e,n)}catch(e){n&&IK(bt),(!t||!mt.current)&&P(dJ(e,`Unable to load the diff right now.`))}finally{V(!1)}},[St,bt,Mt,At]),Yt=(0,X.useCallback)(async(e={})=>{let r=e.preserveContent??!1;if(f===`project_root`||!n||!t){S(null),I(null),re(!1);return}r||I(null),re(!0);try{S(await Lt()),I(null)}catch(e){(!r||!x)&&I(dJ(e,`Unable to load the branch diff right now.`))}finally{re(!1)}},[x,t,Lt,n,f]),Xt=(0,X.useCallback)(async(e,t={})=>{let n=t.preserveContent??!1,r=t.resetSelection??!1,i=t.allowCache??!0?PK(bt):null;if(n||(P(null),R(null)),oe(!0),i){St(i.diffResponse),qt(i.gitStatus,{resetSelection:r}),V(!1);try{let t=await Nt();if(!e())return;qt(t,{resetSelection:r}),oe(!1),(t.ahead??0)>0?Gt(e,{preserveContent:!0}):Kt();let n=t.workspace_signature??null;if(n&&n===i.workspaceSignature){At(i.diffResponse,t);return}IK(bt),await Jt({preserveContent:!0,gitStatusForCache:t});return}catch(t){if(!e())return;R(dJ(t,`Unable to load git status right now.`)),w(null),oe(!1),Kt();return}}V(!0),Mt().then(t=>{e()&&(St(t),ht.current&&At(t,ht.current))}).catch(t=>{e()&&(!n||!mt.current)&&P(dJ(t,`Unable to load the diff right now.`))}).finally(()=>{e()&&V(!1)});try{let t=await Nt();if(!e())return;qt(t,{resetSelection:r}),oe(!1),mt.current&&At(mt.current,t),(t.ahead??0)>0?Gt(e,{preserveContent:n}):Kt()}catch(t){if(!e())return;R(dJ(t,`Unable to load git status right now.`)),n||w(null),oe(!1),Kt()}},[St,qt,bt,Kt,Gt,Jt,Mt,Nt,At]),Zt=(0,X.useCallback)(async()=>{if(!t)return;let e=_t.current+1;_t.current=e,oe(!0);try{let t=await Nt();if(_t.current!==e)return;let n=ht.current?.workspace_signature??null,r=t.workspace_signature??null,i=!mt.current||n!==r;if(qt(t),(t.ahead??0)>0?Gt(()=>_t.current===e,{preserveContent:!0}):Kt(),!i){jt(t);return}await Jt({preserveContent:!0,gitStatusForCache:t})}catch{return}finally{_t.current===e&&oe(!1)}},[qt,Kt,Gt,Jt,t,Nt,jt]);(0,X.useEffect)(()=>{mt.current=y},[y]),(0,X.useEffect)(()=>{ht.current=C},[C]),(0,X.useEffect)(()=>{let e=!0;return Xt(()=>e,{resetSelection:!0}),()=>{e=!1}},[Xt]),(0,X.useEffect)(()=>{if(t)return VK(e=>{e===t&&Zt()})},[t,Zt]),(0,X.useEffect)(()=>{if(!t)return;let e=UK(()=>{document.visibilityState===`visible`&&Zt()});return()=>{e()}},[t,Zt]),(0,X.useEffect)(()=>{if(f===`project_root`){Se(null),Oe(null),Pe(new Set);return}if(!y?.diff?.trim()){Se(null),Oe(null),Pe(new Set);return}let e=new AbortController,t=!0;return Oe(null),Ft(e.signal).then(e=>{t&&(Se(e),Pe(t=>{let n=new Set((e?.findings??[]).map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(n=>{!t||e.signal.aborted||(Oe(dJ(n,`Unable to load review findings right now.`)),Se(null),Pe(new Set))}),()=>{t=!1,e.abort()}},[y?.diff,Ft,f]),(0,X.useEffect)(()=>{v(`uncommitted`),vt.current=hJ(()=>null),yt.current=gJ(),be(mJ()),S(null),I(null),re(!1),Te([]),Ae(null),Ie(new Set),Be(null),He(!1),Ge(!1),Y(``),Je(``),Xe(``),nt([]),it(!1),lt(!1),dt(!1)},[n]),(0,X.useEffect)(()=>{if(f===`project_root`||!n||!t){Be(null),He(!1);return}if(y===null&&!N){He(!1);return}let e=new AbortController,i=!0;return He(!0),It(e.signal).then(e=>{i&&(Be(e),Y(t=>t.trim()?t:e?.bundle?md(e.bundle):r),Je(t=>t.trim()?t:SJ(e?.recent_commit_subjects??Qe)),Xe(t=>t.trim()?t:e?.bundle.pull_request?.base_branch??``))}).catch(()=>{!i||e.signal.aborted||Be(null)}).finally(()=>{i&&He(!1)}),()=>{i=!1,e.abort()}},[N,y,Qe,t,It,n,f,r]),(0,X.useEffect)(()=>{if(f===`project_root`||!n||!t){S(null),I(null),re(!1);return}if(_!==`bundle_diff`){re(!1);return}let e=new AbortController,r=!0;return re(!0),I(null),Lt(e.signal).then(e=>{r&&(S(e),I(null))}).catch(t=>{!r||e.signal.aborted||(I(dJ(t,`Unable to load the branch diff right now.`)),S(null))}).finally(()=>{r&&re(!1)}),()=>{r=!1,e.abort()}},[_,t,Lt,n,f]),(0,X.useEffect)(()=>{let e=ze?.bundle.pull_request??null;if(f===`project_root`||!n||!t||!e){Te([]),Ae(null),Ie(new Set);return}if(!p){Te([]),Ae(null),Ie(new Set);return}if(_!==`bundle_diff`)return;let r=new AbortController,i=!0;return Ae(null),Rt(r.signal).then(e=>{!i||!e||(Te(e.comments),Ae(e.error),Ie(t=>{let n=new Set(e.comments.map(e=>e.id));return new Set([...t].filter(e=>n.has(e)))}))}).catch(e=>{!i||r.signal.aborted||(Te([]),Ae(dJ(e,`Unable to load GitHub review comments right now.`)),Ie(new Set))}),()=>{i=!1,r.abort()}},[_,ze?.bundle.pull_request,p,t,Rt,n,f]),(0,X.useEffect)(()=>{ae&&C===null||ft.current?.focus()},[C,ae]);let Qt=(0,X.useMemo)(()=>{let e=typeof y?.diff==`string`?y.diff:``;return e.trim()?Jm(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:oJ(e)})):[]},[y]),$t=(0,X.useMemo)(()=>{let e=typeof x?.diff==`string`?x.diff:``;return e.trim()?Jm(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:oJ(e)})):[]},[x]),en=(0,X.useMemo)(()=>{let e=y?.diff??``;return e?_J(e):null},[y?.diff]),tn=(0,X.useMemo)(()=>{let e=x?.diff??``;return e?_J(e):null},[x?.diff]),nn=_===`bundle_diff`?x:y,rn=_===`bundle_diff`?$t:Qt,an=(0,X.useMemo)(()=>n?{uncommitted:fJ(n,`uncommitted`),bundle_diff:fJ(n,`bundle_diff`)}:{uncommitted:null,bundle_diff:null},[n]),on=(0,X.useMemo)(()=>({uncommitted:en,bundle_diff:tn}),[tn,en]),sn=(0,X.useMemo)(()=>{let e=new Map;for(let t of nn?.files??[])e.set(t.path,t);return e},[nn]),cn=(0,X.useMemo)(()=>{let e=new Map;for(let t of rn)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[rn]),ln=(0,X.useCallback)(e=>{ve(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),un=(0,X.useMemo)(()=>_===`bundle_diff`?(x?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})):C?(C.files??[]).map(e=>{let t=sn.get(e.path)??(e.original_path?sn.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(y?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions})),[_,x?.files,sn,y?.files,C]);(0,X.useEffect)(()=>{k!==`all`&&(un.some(e=>e.path===k)||A(`all`))},[k,un]);let dn=_===`bundle_diff`?0:D.size,fn=_===`bundle_diff`?un.length:C?.files?.length??un.length,pn=fn>0&&dn===fn,mn=(0,X.useMemo)(()=>_===`bundle_diff`?null:iJ(C,D),[_,C,D]),hn=_===`uncommitted`&&!ae&&!le&&l&&!!C&&dn>0&&j.trim().length>0&&mn===null,gn=_===`uncommitted`&&!ae&&!B&&!W&&!le&&!G&&l&&!Le&&!!C&&dn>0,_n=!ae&&(G||!!C?.can_push&&(C?.ahead??0)>0),vn=_n&&l&&!G&&!le,yn=l&&!se&&!K&&!le&&!G&&(T?.length??0)>0,bn=(C?.ahead??0)>0?`${C?.ahead??0} to push`:`Up to date`,xn=(C?.behind??0)>0?`${C?.behind??0} behind`:`In sync`,Sn=C?.branch??null,Cn=k===`all`?null:cn.get(k)??null,wn=(0,X.useMemo)(()=>k===`all`?rn:Cn?[Cn]:[],[rn,k,Cn]);(0,X.useEffect)(()=>{ge(new Map),ve(nJ)},[_,rn]),(0,X.useEffect)(()=>{let e={uncommitted:an.uncommitted&&on.uncommitted?`${an.uncommitted}:${on.uncommitted}`:null,bundle_diff:an.bundle_diff&&on.bundle_diff?`${an.bundle_diff}:${on.bundle_diff}`:null},t=vt.current;t.uncommitted===e.uncommitted&&t.bundle_diff===e.bundle_diff||(vt.current=e,be(n=>{let r={...n};return[`uncommitted`,`bundle_diff`].forEach(i=>{if(t[i]===e[i])return;let a=on[i],o=an[i],s=n[i];if(t[i]===null&&a&&(s.activeTarget||s.editingCommentKey||s.draftInput.trim()||s.comments.size>0)){r[i]={...s,signature:a};return}if(!a){yt.current[i]=new Map,r[i]=pJ();return}let c=new Map;if(o){let e=window.localStorage.getItem(o),t=e?yJ(e):null;t?.diffSignature===a?c=bJ(t.comments.map(e=>({...e,scope:i}))):e!==null&&window.localStorage.removeItem(o)}yt.current[i]=new Map,r[i]={activeTarget:null,editingCommentKey:null,draftInput:``,comments:c,signature:a}}),r}))},[on,an]),(0,X.useEffect)(()=>{[`uncommitted`,`bundle_diff`].forEach(e=>{let t=an[e],n=on[e],r=ye[e];if(!t||!n||r.signature!==n)return;if(r.comments.size===0){window.localStorage.removeItem(t);return}let i={diffSignature:n,comments:[...r.comments.values()]};window.localStorage.setItem(t,JSON.stringify(i))})},[on,an,ye]),(0,X.useEffect)(()=>{if(rn.length===0)return;let e=!1,t=null,n=(()=>{if(!Cn){let e=[],t=new Set;for(let n of _e){let r=cn.get(n);if(!r)continue;let i=sJ(r);t.has(i)||(t.add(i),e.push(r))}return e.length>0?e:rn.slice(0,Zq)}return[Cn]})(),r=0,i=()=>{if(e)return;let a=n.slice(r,r+Zq);a.length!==0&&(ge(e=>{let t=new Map(e);for(let e of a){let n=sJ(e);t.has(n)||t.set(n,uJ(e))}return t}),r+=Zq,r<n.length&&(t=window.setTimeout(i,0)))};return n.length<=Zq?i():t=window.setTimeout(i,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[rn,cn,Cn,_e]);let Tn=(0,X.useMemo)(()=>wn.map(e=>({...e,tokens:he.get(sJ(e))??null})),[he,wn]),En=(0,X.useMemo)(()=>rn.map(e=>({...e,tokens:null})),[rn]),Dn=(0,X.useMemo)(()=>{let e=new Map;for(let t of rn){let n=sJ(t);e.set(n,n);for(let r of oJ(t))e.set(r,n)}return e},[rn]),On=(0,X.useMemo)(()=>[...ye.uncommitted.comments.values()],[ye.uncommitted.comments]),kn=(0,X.useMemo)(()=>[...ye.bundle_diff.comments.values()],[ye.bundle_diff.comments]),An=ye[_],jn=An.activeTarget,Mn=An.editingCommentKey,Nn=jn?.commentKey??Mn,Pn=Nn?`${_}:${Nn}`:_,Fn=Nn?yt.current[_].get(Nn)??An.draftInput:An.draftInput,In=_===`bundle_diff`?kn:On,Ln=(0,X.useMemo)(()=>[...On,...kn],[kn,On]),Rn=(0,X.useMemo)(()=>xe?.findings??[],[xe]),zn=(0,X.useMemo)(()=>xe?.is_current_diff?Rn.filter(e=>Me.has(e.id)):[],[Rn,xe?.is_current_diff,Me]),Bn=(0,X.useMemo)(()=>[...Me],[Me]),Vn=(0,X.useMemo)(()=>we.filter(e=>Fe.has(e.id)),[we,Fe]),Hn=(0,X.useMemo)(()=>[...Fe],[Fe]),Un=Ln.length+zn.length+Vn.length,Wn=!!(xe?.review_run&&Rn.length>0&&!xe.is_current_diff),Gn=ze?.bundle.pull_request??null,Kn=(0,X.useMemo)(()=>Qe.length>0?Qe:ze?.recent_commit_subjects??[],[ze?.recent_commit_subjects,Qe]),qn=ze?.has_helper_model===!0,Jn=f!==`project_root`&&!!n&&!!t,Yn=_===`bundle_diff`?F:N,Xn=B&&y===null,Zn=ne&&x===null,Qn=ae&&C===null,$n=Ve&&ze===null,er=_===`bundle_diff`?Zn:Xn,tr=_===`uncommitted`?Rn:eJ,nr=_===`uncommitted`?Bn:nJ,rr=_===`bundle_diff`?we:tJ,ir=_===`bundle_diff`?Hn:nJ,ar=_===`bundle_diff`?`bundle_diff`:`uncommitted`,or=(0,X.useMemo)(()=>{let e=new Map,t=e=>e?Dn.get(e)??e:null;for(let n of In){let r=t(n.filePath);r&&xJ(e,r)}if(_===`uncommitted`){if(Wn)return e;for(let n of Rn){let r=t(n.file_path);r&&xJ(e,r)}return e}for(let n of we){let r=t(n.file_path);r&&xJ(e,r)}return e},[_,Dn,In,we,Wn,Rn]),sr=(Wn?0:Rn.length)+On.length,cr=we.length+kn.length,lr=_===`bundle_diff`?`No branch diff to show.`:`No uncommitted changes to show.`,ur=_===`uncommitted`&&Jn?`Switch to Branch diff to review the full branch diff.`:null,dr=Jn&&!$n&&!!ze&&ze?.bundle.kind!==`project_root`&&C?.has_upstream===!0&&p,fr=dr&&!Gn&&!rt&&!at&&!ut&&!Le&&!G&&!le&&!K&&(C?.ahead??0)===0&&!!C?.branch,pr=(0,X.useCallback)(e=>{if(!e){Ge(!1);return}if(!t||!n||!dr||Gn||at){Ge(e);return}lt(!0),tt(t,n).then(e=>{Be(e),Xe(t=>t.trim()?t:e.bundle.pull_request?.base_branch??``),Ge(!e.bundle.pull_request)}).catch(e=>{Q.error(dJ(e,`Unable to check for an existing pull request right now.`),{id:`ticket-changes-sync-pr-error`}),Ge(!0)}).finally(()=>{lt(!1)})},[Gn,at,t,n,dr]),mr=(0,X.useMemo)(()=>{if(dr)return(C?.ahead??0)>0?`Push the branch before creating a pull request.`:C?.branch?d:`Bundle branch information is not available right now.`},[d,C?.ahead,C?.branch,dr]),hr=c&&!er&&(_===`bundle_diff`||!Qn)&&!le&&!G&&!K,gr=jn?hr||An.comments.has(jn.commentKey):hr,_r=!!a&&o&&Un>0&&!Le,vr=(0,X.useCallback)(e=>{Pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),yr=(0,X.useCallback)(e=>{Ie(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),br=(0,X.useCallback)(()=>{yt.current=gJ(),be(e=>({uncommitted:{...e.uncommitted,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map},bundle_diff:{...e.bundle_diff,activeTarget:null,editingCommentKey:null,draftInput:``,comments:new Map}}))},[]),xr=(0,X.useCallback)(()=>{br(),Pe(new Set),Ie(new Set)},[br]),Sr=(0,X.useCallback)(async()=>{if(!(!t||!n||!fr)){it(!0);try{let e=await $e(t,n,{title:Ke.trim(),body:qe.trim(),base_branch:Ye.trim()||null});Be(e),Xe(e.bundle.pull_request?.base_branch??Ye.trim()),Ge(!1),Q.success(`Pull request created.`,{id:`ticket-changes-create-pr-success`})}catch(e){Q.error(dJ(e,`Unable to create the pull request right now.`),{id:`ticket-changes-create-pr-error`})}finally{it(!1)}}},[fr,t,Ye,qe,Ke,n]),Cr=(0,X.useCallback)(async()=>{if(!(!t||!n||!dr||ut)){dt(!0);try{Je((await Bt({title:Ke.trim(),commit_subjects:Kn})).description)}catch(e){Q.error(dJ(e,`Unable to generate the pull request description right now.`),{id:`ticket-changes-generate-pr-description-error`})}finally{dt(!1)}}},[ut,t,Kn,Ke,Bt,n,dr]),wr=(0,X.useCallback)(({filePath:e,changeKey:t,commentKey:n})=>{let r=An.comments.get(n),i=yt.current[_].get(n)??r?.comment??``;if(r){A(r.filePath),zt(_,e=>({...e,activeTarget:null,editingCommentKey:n,draftInput:i}));return}hr&&zt(_,r=>({...r,activeTarget:{filePath:e,changeKey:t,commentKey:n},editingCommentKey:null,draftInput:i}))},[_,An.comments,hr,zt]),Tr=(0,X.useCallback)(()=>{Nn&&yt.current[_].delete(Nn),zt(_,e=>({...e,activeTarget:null,editingCommentKey:null,draftInput:``}))},[_,Nn,zt]),Er=(0,X.useCallback)(e=>{Nn&&yt.current[_].set(Nn,e)},[_,Nn]),Dr=(0,X.useCallback)((e,t)=>{let n=An.comments.has(e.commentKey);if(!hr&&!n)return;let r=t.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;zt(_,t=>{let n=new Map(t.comments);return n.set(e.commentKey,{scope:_,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:mb(e.hunk,e.change),comment:r}),{...t,activeTarget:null,editingCommentKey:null,draftInput:``,comments:n}}),yt.current[_].delete(e.commentKey)},[_,An.comments,hr,zt]),Or=(0,X.useCallback)(e=>{let t=An.comments.get(e);if(!t)return;A(t.filePath);let n=yt.current[_].get(e)??t.comment;zt(_,t=>({...t,activeTarget:null,editingCommentKey:e,draftInput:n}))},[_,An.comments,zt]),kr=(0,X.useCallback)(e=>{yt.current[_].delete(e),zt(_,t=>{let n=new Map(t.comments);return n.delete(e),{...t,activeTarget:t.activeTarget?.commentKey===e?null:t.activeTarget,editingCommentKey:t.editingCommentKey===e?null:t.editingCommentKey,draftInput:t.activeTarget?.commentKey===e||t.editingCommentKey===e?``:t.draftInput,comments:n}})},[_,zt]),Ar=(0,X.useCallback)(async()=>{if(!a||!_r)return;Re(!0);let e=Cb({drafts:Ln,findings:zn,githubComments:Vn,uncommittedFiles:Qt,bundleFiles:$t});try{await a(e),br(),Pe(new Set),Ie(new Set),Se(e=>e&&{...e,findings:[],is_current_diff:!1}),Q.success(`Fixes submitted.`,{id:`ticket-diff-review-submit-success`}),i()}catch(e){Q.error(dJ(e,`Unable to submit the review right now.`),{id:`ticket-diff-review-submit-error`})}finally{Re(!1)}},[Ln,$t,_r,br,i,a,Vn,zn,Qt]),jr=(0,X.useCallback)(()=>{if(_===`bundle_diff`){Yt();return}Xt(()=>!0,{allowCache:!1,resetSelection:!pt.current})},[_,Yt,Xt]),Mr=(0,X.useMemo)(()=>a?(0,Z.jsx)(kG,{reviewComments:Ln,reviewFindings:zn,githubComments:Vn,pendingFixCount:Un,canSendReview:_r,isSubmittingReview:Le,reviewSubmitDisabledReason:s,onClearPendingFixes:xr,onSubmitReview:()=>{Ar()}}):null,[Ln,_r,xr,Ar,Le,a,Un,s,Vn,zn]),Nr=e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Pr=()=>{C&&O(pn?new Set:rJ(C.files))},Fr=async()=>{if(hn){ue(!0);try{let e=await Vt({message:j.trim(),selected_paths:[...D]});e.ticket&&h?.(e.ticket),qt(e.git_status,{resetSelection:!0}),M(``),f===`project_root`&&BK(t),m&&g?.(m),await Jt({preserveContent:!0,gitStatusForCache:e.git_status}),await Yt({preserveContent:!0}),(e.git_status.ahead??0)>0?await Gt(()=>!0):Kt(),Q.success(`Commit created.`,{id:`ticket-git-commit-success`})}catch(e){Q.error(dJ(e,`Unable to create the commit right now.`),{id:`ticket-git-commit-error`})}finally{ue(!1)}}},Ir=async()=>{if(gn){de(!0);try{M((await Ht({selected_paths:[...D]})).message),ft.current?.focus()}catch(e){Q.error(dJ(e,`Unable to generate a commit message right now.`),{id:`ticket-git-commit-message-error`})}finally{de(!1)}}},Lr=async()=>{if(vn){fe(!0);try{let e=T.map(e=>e.subject.trim()).filter(Boolean),r=await Ut();if(r.ticket&&h?.(r.ticket),qt(r.git_status,{resetSelection:!0}),jt(r.git_status),nt(e),Kt(),f===`project_root`&&BK(t),m&&g?.(m),Q.success(r.git_status.ahead===0?`Branch pushed.`:`Push completed.`,{id:`ticket-git-push-success`}),r.git_status.ahead===0)if(f!==`project_root`&&t&&n)try{let r=await Ze(t,n);Be(r),Y(e=>e.trim()?e:md(r.bundle)),Je(t=>t.trim()?t:SJ(e)),Xe(e=>e.trim()?e:r.bundle.pull_request?.base_branch??``)}catch{}else i()}catch(e){Q.error(dJ(e,`Unable to push the branch right now.`),{id:`ticket-git-push-error`})}finally{fe(!1)}}},Rr=async()=>{if(yn){q(!0);try{let e=await Wt();e.ticket&&h?.(e.ticket),qt(e.git_status,{resetSelection:!0}),E(e.commits),z(null),H(!1),f===`project_root`&&BK(t),m&&g?.(m),await Jt({preserveContent:!0,gitStatusForCache:e.git_status}),await Yt({preserveContent:!0}),Q.success(`Latest local commit undone.`,{id:`ticket-git-undo-success`})}catch(e){Q.error(dJ(e,`Unable to undo the latest local commit right now.`),{id:`ticket-git-undo-error`})}finally{q(!1)}}};return(0,Z.jsx)(Ce,{onClose:i,overlayClassName:`z-[70] bg-black/30 p-[5vh]`,panelClassName:`flex h-[92vh] w-full max-w-none flex-col overflow-hidden rounded-2xl border border-border bg-card p-6 shadow-2xl`,renderContent:({closeButton:e})=>(0,Z.jsxs)(Z.Fragment,{children:[G&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-2xl bg-black/45 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-border bg-card/95 px-4 py-3 text-sm text-foreground shadow-xl`,children:[(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{children:`Pushing branch...`})]})}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Changes`}),Sn?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`h2`,{className:`max-w-full truncate font-mono text-lg font-semibold text-foreground`,children:Sn}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(J,{variant:(C?.ahead??0)>0?`info`:`outline`,children:bn}),(0,Z.jsx)(J,{variant:(C?.behind??0)>0?`warning`:`outline`,children:xn}),(0,Z.jsx)(J,{variant:C?.is_dirty?`warning`:`success`,children:C?.is_dirty?`Dirty`:`Clean`})]})]}):(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-7 w-56 animate-pulse rounded-md bg-muted/70`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-6 w-32 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`h-6 w-20 animate-pulse rounded-full bg-muted/60`,"aria-hidden":`true`})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 text-xs text-muted-foreground`,children:[(Gn||dr)&&(0,Z.jsx)(CJ,{pullRequest:Gn,isLoading:$n,isOpen:Ue,canCreate:fr,disabledReason:mr,isCreating:rt,isSyncing:at,isGeneratingDescription:ut,title:Ke,body:qe,baseBranch:Ye,onOpenChange:pr,onTitleChange:Y,onBodyChange:Je,onBaseBranchChange:Xe,showGenerateDescription:qn,onGenerateDescription:()=>{Cr()},onCreate:()=>{Sr()}}),(0,Z.jsx)(jG,{isCommitsLoading:se,commitsError:ee,unpushedCommits:T,canUndoLatestCommit:yn,isUndoing:K,aheadCount:C?.ahead??0,onUndoLatestCommit:()=>{Rr()}}),_n&&(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`default`,onClick:()=>{Lr()},disabled:!vn,title:d,className:`gap-2`,children:[G?(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(xu,{className:`h-4 w-4`}),G?`Pushing...`:`Push branch`]}),e]})]}),(0,Z.jsxs)(`div`,{"data-testid":`ticket-changes-layout`,className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)] xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`flex min-h-0 flex-col`,children:[Jn&&(0,Z.jsxs)(CG,{type:`single`,size:`sm`,variant:`outline`,value:_,onValueChange:e=>{(e===`uncommitted`||e===`bundle_diff`)&&v(e)},className:`mb-3 self-start`,children:[(0,Z.jsxs)(wG,{value:`uncommitted`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Uncommitted`}),sr>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-sky-400/40 bg-sky-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-sky-100`,children:sr})]}),(0,Z.jsxs)(wG,{value:`bundle_diff`,className:`gap-2`,children:[(0,Z.jsx)(`span`,{children:`Branch diff`}),cr>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-violet-400/40 bg-violet-400/12 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-violet-100`,children:cr})]})]}),(0,Z.jsx)(EK,{selectionWarning:_===`uncommitted`?mn:null,gitError:_===`uncommitted`?L:F,sidebarFiles:un,commentCountByPath:or,commentCountTone:ar,isGitStatusLoading:_===`bundle_diff`?Zn:Qn&&un.length===0,selectedPaths:D,selectedDiffPath:k,allFilesSelected:pn,diffStats:nn?.stats??null,title:_===`bundle_diff`?`Branch diff files`:`Changed files`,allChangesDescription:_===`bundle_diff`?`Review the full branch diff against the review base.`:`Review the full workspace diff.`,enableSelection:_===`uncommitted`&&!Qn,onToggleSelectAll:Pr,onSelectDiffPath:A,onTogglePath:Nr})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,Z.jsx)(xK,{selectedDiffPath:k,sidebarFiles:un,diffResponse:nn,isDiffLoading:er,diffError:Yn,allDiffFiles:En,renderedFiles:Tn,viewType:pe,onViewTypeChange:me,onRetry:jr,activeReviewTarget:jn,editingReviewCommentKey:Mn,reviewDraftInstanceKey:Pn,reviewDraftInput:Fn,reviewComments:In,reviewFindings:tr,githubComments:rr,selectedReviewFindingIds:nr,selectedGitHubCommentIds:ir,canSelectReviewTarget:hr,canEditActiveReviewDraft:gr,reviewFindingsError:_===`uncommitted`?De:null,gitHubCommentsError:_===`bundle_diff`?ke:null,hasStaleReviewFindings:_===`uncommitted`?Wn:!1,onSelectReviewTarget:wr,onToggleReviewFindingSelection:vr,onToggleGitHubCommentSelection:yr,onReviewDraftInputChange:Er,onCancelReviewDraft:Tr,onEditReviewDraft:Or,onRemoveReviewDraft:kr,onSaveReviewDraft:Dr,diffThemeClassName:DK,resolveFilePath:sJ,normalizeDiffPath:aJ,onVisibleFilePathsChange:ln,emptyStateTitle:lr,emptyStateDescription:ur,reviewSummaryControl:Mr,headerLayout:`inline-controls`}),_===`uncommitted`&&(0,Z.jsx)(`div`,{className:`mt-auto shrink-0`,children:(0,Z.jsx)(AG,{commitMessage:j,onCommitMessageChange:M,commitMessageRef:ft,selectedFileCount:dn,changesDisabledReason:d,canEditCommitMessage:l&&!Le,canGenerateCommitMessage:gn,canCommit:hn,isGeneratingCommitMessage:W,isCommitting:le,onGenerateCommitMessage:()=>{Ir()},onCommit:()=>{Fr()}})})]})]})]})]})})},EJ={blocked:{className:`stroke-red-400/80`,markerId:`dependency-arrowhead-blocked`},ready:{className:`stroke-emerald-400/80`,markerId:`dependency-arrowhead-ready`},preview:{className:`stroke-amber-300/80`,markerId:`dependency-arrowhead-preview`}},DJ=e=>$w(e)?`ready`:`blocked`,OJ=180,kJ=560,AJ=88,jJ=12,MJ=18,NJ=(e,t,n)=>Math.min(Math.max(e,t),n),PJ=(e,t,n)=>n&&n.width>0&&n.height>0?n:Object.values(e).reduce((e,t)=>({width:Math.max(e.width,t.left+t.width),height:Math.max(e.height,t.top+t.height)}),{width:t.x,height:t.y}),FJ=(e,t)=>{let n=NJ(Math.round(e.length*7.2)+24,OJ,kJ),r=Math.max(OJ,t-jJ*2);return Math.min(n,r)},IJ=(e,t,n,r,i)=>{let a=n.get(e.blockerTicketId);if(!a)return null;let o=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?r[e.hoveredTicketId]:null,s=e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId?n.get(e.hoveredTicketId):null,c=s?`${a.title} is blocking ${s.title}`:`${a.title} is blocking...`,{start:l,end:u}=sT(t,o??{left:e.pointer.x,top:e.pointer.y,width:0,height:0}),d=PJ(r,e.pointer,i),f=o&&s?{x:l.x+(u.x-l.x)*.6,y:l.y+(u.y-l.y)*.6-28}:{x:u.x,y:u.y-28},p=FJ(c,d.width);return{text:c,x:o&&s?NJ(f.x-p/2,jJ,Math.max(jJ,d.width-p-jJ)):(()=>{let e=f.x+MJ,t=f.x-MJ-p;return e+p<=d.width-jJ?e:t>=jJ?t:NJ(e,jJ,Math.max(jJ,d.width-p-jJ))})(),y:NJ(f.y,jJ,Math.max(jJ,d.height-AJ-jJ)),width:p}},LJ=({blockerRect:e,dependentRect:t,className:n,testId:r,markerEnd:i})=>{let{start:a,end:o}=sT(e,t),{path:s}=cT(a,o);return(0,Z.jsx)(`g`,{"data-testid":r,children:(0,Z.jsx)(`path`,{d:s,className:n,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,markerEnd:i})})},RJ=({preview:e,cardRects:t,ticketsById:n,overlaySize:r})=>{if(!e)return null;let i=t[e.blockerTicketId];if(!i)return null;let a=(e.hoveredTicketId&&e.hoveredTicketId!==e.blockerTicketId&&t[e.hoveredTicketId]?t[e.hoveredTicketId]:null)??{left:e.pointer.x,top:e.pointer.y,width:0,height:0},o=IJ(e,i,n,t,r);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(LJ,{blockerRect:i,dependentRect:a,className:EJ.preview.className,testId:`dependency-preview`,markerEnd:`url(#${EJ.preview.markerId})`}),(e=>o?(0,Z.jsx)(`foreignObject`,{x:o.x,y:o.y,width:o.width,height:AJ,"data-testid":`dependency-preview-label`,children:e}):null)((0,Z.jsx)(`div`,{className:`pointer-events-none flex h-full w-full items-start`,children:(0,Z.jsx)(`div`,{className:`max-w-full rounded-md border border-amber-300/60 bg-stone-950/85 px-3 py-1.5 text-xs font-medium leading-5 text-amber-100 shadow-lg shadow-stone-950/20 whitespace-normal break-words`,children:o?.text})}))]})},zJ=({dependencies:e,cardRects:t,preview:n,ticketsById:r,overlaySize:i})=>(0,Z.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 z-10 h-full w-full overflow-visible`,children:[(0,Z.jsx)(`defs`,{children:Object.values(EJ).map(e=>(0,Z.jsx)(`marker`,{id:e.markerId,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`4`,orient:`auto`,markerUnits:`userSpaceOnUse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 8 4 L 0 8`,className:e.className,fill:`none`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})},e.markerId))}),e.map(e=>{let n=r.get(e.blocker_ticket_id),i=r.get(e.dependent_ticket_id),a=t[e.blocker_ticket_id],o=t[e.dependent_ticket_id];if(n?.parked_at||i?.parked_at)return null;let s=EJ[DJ(n)];return!a||!o?null:(0,Z.jsx)(LJ,{blockerRect:a,dependentRect:o,className:s.className,testId:`dependency-edge-${e.blocker_ticket_id}-${e.dependent_ticket_id}`,markerEnd:`url(#${s.markerId})`},`${e.blocker_ticket_id}:${e.dependent_ticket_id}`)}),(0,Z.jsx)(RJ,{preview:n,cardRects:t,ticketsById:r,overlaySize:i})]}),BJ=({onSubmit:e,bundles:t,projectId:n=null,projectBranchState:r=null,tool:i,showModelSelector:a=!1,availableModels:o=[],availableSkills:s=[],initialModel:c=``,initialVariant:l=``,initialSkills:u=[],onCreateBundle:d,onDeleteBundle:f,onRefreshBundles:p,onClose:m})=>{let{jiraImportState:h,importFromJira:g}=Ef(n);return(0,Z.jsx)(Ce,{onClose:m,overlayClassName:`bg-black/60`,panelClassName:`h-[92vh] w-[96vw] max-w-6xl overflow-y-auto rounded-2xl border border-border bg-card p-4 shadow-2xl sm:p-5 lg:p-6`,renderContent:({closeButton:_})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-5 sm:top-5 lg:right-6 lg:top-6`,children:_}),(0,Z.jsx)($N,{heading:`New Ticket`,bundles:t,showModelSelector:a,availableModels:o,availableSkills:s,projectId:n,initialModel:c,initialVariant:l,initialSkills:u,projectBranchState:r,jiraImportState:h,onImportFromJira:g,onCancel:m,onCreateBundle:d,onDeleteBundle:f,onRefreshBundles:p,titleInputId:`title`,descriptionInputId:`description`,bundleSelectId:`new-ticket-bundle`,modelSelectId:`new-model`,variantSelectId:`new-variant`,skillsSelectId:`new-skills`,showEmptyBundleOption:!0,planAction:i?{label:`Plan`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`plan`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}}:void 0,primaryAction:{label:`Create Ticket`,variant:`subtle`,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`create`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}},secondaryAction:{label:`Create & Build`,variant:`brand`,showAdvanceIcon:!0,onClick:async({title:t,description:n,model:r,variant:i,skills:a,worktree_bundle_id:o,external_source:s})=>{await e(t,n,`build`,r,i,a,{worktree_bundle_id:o??void 0,...s?{external_source:s}:{}}),m()}}})]})})},VJ=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},HJ=e=>e.status===`error`?`border-red-500/35 bg-red-500/10`:e.status===`done`?e.boardState===`fading`?`border-emerald-500/25 bg-emerald-500/10 opacity-0 transition-opacity duration-700`:`border-emerald-500/35 bg-emerald-500/10`:`border-violet-500/30 bg-card/60`,UJ=({run:e})=>(0,Z.jsxs)(kd,{"data-testid":`planning-run-card-${e.id}`,className:`relative overflow-hidden rounded-xl border shadow-none ${HJ(e)}`,children:[e.status===`running`&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-0 h-1 animate-pulse bg-gradient-to-r from-violet-500/0 via-violet-300/80 to-violet-500/0`}),(0,Z.jsxs)(Pd,{className:`space-y-3 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[e.status===`running`?(0,Z.jsx)(dT,{label:`Planning...`}):e.status===`done`?(0,Z.jsx)(dT,{label:`Done`,className:`bg-emerald-500/85 text-emerald-50`}):(0,Z.jsx)(dT,{label:`Planning failed`,className:`bg-red-500/85 text-red-50`}),(0,Z.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.16em] text-muted-foreground`,children:VJ(e.submittedAt)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),e.status===`done`&&e.summary&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Created `,e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]}),e.status===`error`&&e.error&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-200`,children:e.error})]})]})]}),WJ={idle:`bg-secondary`,running:`bg-sky-400`,done:`bg-emerald-400`,error:`bg-red-400`},GJ=e=>e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`done`)?`done`:`idle`,KJ=e=>{let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`},qJ=({status:e})=>e===`running`?(0,Z.jsx)(dT,{label:`Planning...`,className:`px-2.5 py-0.5 text-[11px]`}):e===`done`?(0,Z.jsx)(J,{className:`bg-emerald-500/85 px-2.5 py-0.5 text-[11px] text-emerald-50`,children:`Done`}):(0,Z.jsx)(J,{className:`bg-red-500/85 px-2.5 py-0.5 text-[11px] text-red-50`,children:`Failed`}),JJ=({heading:e,runs:t})=>t.length===0?null:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:t.map(e=>(0,Z.jsx)(kd,{className:`rounded-2xl border-border bg-card/70 shadow-none`,children:(0,Z.jsxs)(Pd,{className:`space-y-2 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm font-medium text-foreground`,children:e.description}),(0,Z.jsx)(qJ,{status:e.status})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:KJ(e.submittedAt)}),e.summary&&(0,Z.jsxs)(`span`,{children:[e.summary.ticketCount,` tickets, `,e.summary.dependencyCount,` dependencies`,e.summary.ticketsWithOpenQuestions>0?`, ${e.summary.ticketsWithOpenQuestions} open question${e.summary.ticketsWithOpenQuestions===1?``:`s`}`:``]})]}),e.error&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-red-500/30 bg-destructive/15 px-3 py-2 text-xs text-red-200`,children:e.error})]})},e.id))})]}),YJ=({projectId:e=null,state:t,bundles:n,showModelSelector:r,availableModels:i,availableSkills:a,onManageBundles:o,onToggle:s,onDescriptionChange:c,onModelChange:l,onVariantChange:u,onSkillsChange:d,onBundleChange:f,onGenerate:p})=>{let m=i.find(e=>e.id===t.composer.model)??null,{jiraImportState:h,importFromJira:g}=Ef(t.isOpen?e:null),_=(0,X.useRef)(null),v=(0,X.useRef)(t.isOpen),y=(0,X.useRef)(t.isOpen),b=GJ(t.runs),x=t.runs.filter(e=>e.status===`running`),S=t.runs.filter(e=>e.status!==`running`),C=t.composer.description.trim().length>0;(0,X.useEffect)(()=>{if(t.isOpen&&!v.current&&(y.current=!0),t.isOpen||(y.current=!1),v.current=t.isOpen,!t.isOpen||!y.current)return;let e=window.requestAnimationFrame(()=>{let e=document.activeElement,t=e instanceof HTMLElement&&e.closest(`[data-testid="planning-agent-rail"]`)!==null;if(e instanceof HTMLElement&&e!==document.body&&e!==_.current&&!t){y.current=!1;return}_.current?.focus({preventScroll:!0}),y.current=!1});return()=>{window.cancelAnimationFrame(e)}},[t.isOpen]),(0,X.useEffect)(()=>{if(!t.isOpen)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),s())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[s,t.isOpen]);let w=(0,Z.jsxs)(U,{type:`button`,"aria-label":t.isOpen?`Close planning agent`:`Open planning agent`,"aria-pressed":t.isOpen,onClick:s,variant:`outline`,className:`relative flex h-14 w-11 flex-col items-center justify-center gap-1 p-0`,children:[(0,Z.jsx)(Qd,{className:`size-5`}),(0,Z.jsx)(vw,{"aria-hidden":`true`,children:`A`}),(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-2.5 w-2.5 rounded-full ring-2 ring-card ${WJ[b]}`})]});return(0,Z.jsxs)(`aside`,{"aria-label":`Planning agent sidebar`,className:`relative z-20 h-full w-16 shrink-0 overflow-visible border-r border-border bg-background`,children:[(0,Z.jsx)(`div`,{"data-testid":`planning-agent-rail`,className:`relative z-40 flex h-full w-16 shrink-0 flex-col items-center border-r border-border bg-background py-4`,children:t.isOpen?w:(0,Z.jsx)(cu,{content:`Planning agent`,children:w})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-drawer`,"aria-hidden":!t.isOpen,inert:!t.isOpen||void 0,className:W(`absolute inset-y-0 left-16 z-30 w-[min(36rem,calc(100vw-5rem))] overflow-hidden transition-transform duration-200 ease-out motion-reduce:transition-none`,t.isOpen?`pointer-events-auto translate-x-0`:`pointer-events-none -translate-x-full`),children:(0,Z.jsxs)(`div`,{className:`flex h-full w-[min(36rem,calc(100vw-5rem))] flex-col border-r border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-border px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Planning agent`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Turn a larger initiative into plan-stage tickets with dependencies and bundle context.`})]}),(0,Z.jsx)(U,{type:`button`,"aria-label":`Close planning agent panel`,onClick:s,variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(pe,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-scroll-body`,className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`space-y-5 px-6 py-5`,children:[(0,Z.jsx)(YN,{jiraImportState:h,onImportFromJira:g,onImported:e=>{c(e.description)},inputId:`planning-agent-jira-import`}),(0,Z.jsx)(Id,{label:`Description`,htmlFor:`planning-agent-description`,className:`gap-2`,children:(0,Z.jsx)(`div`,{className:`relative`,children:(0,Z.jsx)(sm,{ref:_,projectId:e,suggestionAnchor:`caret`,id:`planning-agent-description`,"aria-label":`Planning description`,value:t.composer.description,onValueChange:c,rows:14,className:`min-h-[18rem] resize-y text-sm leading-6`,placeholder:`Describe the task, acceptance criteria, context...`})})}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(XN,{bundles:n,value:t.composer.worktreeBundleId,onChange:f,selectId:`planning-agent-bundle`,emptyLabel:`Auto-create bundle`,hideProjectRootBundles:!0,label:``})}),o&&(0,Z.jsx)(U,{type:`button`,onClick:o,variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap border-sky-500/30 bg-sky-500/10 text-sky-200 hover:border-sky-400 hover:bg-sky-500/20 hover:text-sky-100`,children:`Manage bundles`})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:(0,Z.jsx)(KN,{model:t.composer.model,variant:t.composer.variant,skills:t.composer.skills,showModelSelector:r,showSkillsSelector:r,availableModels:i,availableSkills:a,selectedModel:m,onModelChange:l,onVariantChange:u,onSkillsChange:d,modelSelectId:`planning-agent-model`,variantSelectId:`planning-agent-variant`,skillsSelectId:`planning-agent-skills`,layout:`stacked`})}),(0,Z.jsx)(`div`,{"data-testid":`planning-agent-runs`,className:`border-t border-border/80 px-0 pt-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(JJ,{heading:`Active planning runs`,runs:x}),(0,Z.jsx)(JJ,{heading:`Recent runs`,runs:S})]})})]})}),(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border px-6 py-4`,children:(0,Z.jsx)(U,{type:`button`,onClick:p,disabled:!C,className:`w-full`,children:`Plan tickets`})})]})})]})},XJ=({className:e=``})=>{let{setNodeRef:t,isOver:n}=aw({id:`trash`});return(0,Z.jsxs)(`div`,{ref:t,"data-testid":`delete-drop-zone`,className:`${e} flex min-w-[13rem] select-none items-center justify-between gap-4 rounded-2xl border px-4 py-3 backdrop-blur-sm transition-all duration-150 ${n?`scale-[1.02] border-red-400/70 bg-destructive/35 text-red-100 shadow-lg shadow-red-950/30`:`border-red-500/30 bg-background/82 text-red-200/85`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(J,{variant:`destructive`,className:`text-[11px] uppercase tracking-[0.28em]`,children:`Delete`}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:n?`Release to delete`:`Drop here to delete`})]}),(0,Z.jsx)(`div`,{className:`rounded-xl border p-2 transition-colors ${n?`border-red-400/60 bg-red-500/20`:`border-red-500/20 bg-background/60`}`,children:(0,Z.jsx)(Ld,{className:`h-5 w-5 transition-colors ${n?`text-red-100`:`text-red-300/70`}`})})]})},ZJ=(e,t)=>j(T(`/ticket-dependencies`,e),{signal:t}),QJ=(e,t)=>j(T(`/ticket-dependencies`,e),{method:`POST`,body:t,fallbackErrorMessage:`Unable to create the dependency right now.`}),$J=(e,t,n)=>D(T(`/ticket-dependencies/${t}/${n}`,e),{method:`DELETE`,fallbackErrorMessage:`Unable to remove the dependency right now.`}),eY=(e,t)=>{let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.left!==i.left||n.top!==i.top||n.width!==i.width||n.height!==i.height)return!1}return!0},tY=(e,t)=>e===t?!0:!e||!t?!1:e.projectId===t.projectId&&e.blockerTicketId===t.blockerTicketId&&e.hoveredTicketId===t.hoveredTicketId&&e.pointer.x===t.pointer.x&&e.pointer.y===t.pointer.y,nY=({activeProjectId:e,tickets:t,dependencies:n,setDependencies:r,activeTicket:i,activeOverlayNode:a,dragOffset:o})=>{let[s,c]=(0,X.useState)({}),[l,u]=(0,X.useState)({width:0,height:0}),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),h=(0,X.useRef)(null),g=(0,X.useRef)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(new Map),y=(0,X.useRef)({}),b=(0,X.useRef)(null),x=(0,X.useRef)(null),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useRef)(null),E=(0,X.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);(0,X.useEffect)(()=>{C.current=p},[p]),(0,X.useLayoutEffect)(()=>{if(!i||!a||!g.current)return;let e=window.requestAnimationFrame(()=>{let e=g.current?.getBoundingClientRect(),t=a.getBoundingClientRect();e&&f({ticketId:i.id,rect:{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}})});return()=>{window.cancelAnimationFrame(e)}},[a,i,o.x,o.y]);let D=(0,X.useCallback)(()=>{b.current===null&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=g.current;if(!e){_.current=null,y.current={},c({}),u({width:0,height:0});return}let t=e.getBoundingClientRect(),n={};_.current={left:t.left,top:t.top},u(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height});for(let[e,r]of v.current){let i=r.getBoundingClientRect();n[e]={left:i.left-t.left,top:i.top-t.top,width:i.width,height:i.height}}y.current=n,c(e=>eY(e,n)?e:n)}))},[]);(0,X.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{D()};return e.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[D]),(0,X.useEffect)(()=>{if(typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(()=>{D()});x.current=e;for(let t of v.current.values())e.observe(t);return()=>{e.disconnect(),x.current===e&&(x.current=null)}},[D]),(0,X.useEffect)(()=>{let e=h.current,t=g.current;if(!e&&!t)return;let n=new ResizeObserver(()=>{D()});return e&&n.observe(e),t&&t!==e&&n.observe(t),()=>{n.disconnect()}},[D]),(0,X.useEffect)(()=>(D(),()=>{b.current!==null&&(window.cancelAnimationFrame(b.current),b.current=null)}),[n,D,t]);let O=(0,X.useCallback)((e,t)=>{let n=v.current.get(e);if(t){if(n===t)return;v.current.set(e,t),x.current?.observe(t)}else{if(!n)return;v.current.delete(e),x.current?.unobserve(n)}D()},[D]),k=(0,X.useCallback)(e=>{tY(C.current,e)||(C.current=e,m(e))},[]),A=(0,X.useCallback)(()=>{w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),T.current=null},[]),j=(0,X.useCallback)(e=>{T.current=e,w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null;let e=T.current;T.current=null,k(e)}))},[k]),M=(0,X.useCallback)((e,t)=>{let n=_.current;if(!n&&g.current){let e=g.current.getBoundingClientRect();n={left:e.left,top:e.top},_.current=n}return n?{x:e-n.left,y:t-n.top}:{x:e,y:t}},[]),N=(0,X.useCallback)((e,t,n)=>{for(let[r,i]of Object.entries(y.current))if(r!==n&&e>=i.left&&e<=i.left+i.width&&t>=i.top&&t<=i.top+i.height)return r;return null},[]),P=(0,X.useCallback)(async t=>{if(e)try{await $J(e,t.blocker_ticket_id,t.dependent_ticket_id),r(e=>Yw(e,t.blocker_ticket_id,t.dependent_ticket_id))}catch(e){Q.error(e instanceof ve?e.message:`Unable to remove the dependency right now.`,{id:`board-dependency-error`})}},[e,r]),F=(0,X.useCallback)((t,i)=>{if(!e)return;i.preventDefault(),S.current?.();let a=(n,r,i=!1)=>{let a=M(n,r),o={projectId:e,blockerTicketId:t,hoveredTicketId:N(a.x,a.y,t),pointer:a};if(i){A(),k(o);return}j(o)};a(i.clientX,i.clientY,!0);let o=e=>{a(e.clientX,e.clientY)},s=async i=>{let a=M(i.clientX,i.clientY),o=N(a.x,a.y,t),s=o?Zw(n,t,o):null;if(S.current?.(),S.current=null,k(null),!(!o||!s)){if(!s.valid){Q.error(Qw(s.reason),{id:`board-dependency-error`});return}try{let n=await QJ(e,{blocker_ticket_id:t,dependent_ticket_id:o});r(e=>Jw(e,n))}catch(e){Q.error(e instanceof ve?e.message:`Unable to create the dependency right now.`,{id:`board-dependency-error`})}}};S.current=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),A()},window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0})},[e,A,n,N,M,j,r,k]);(0,X.useEffect)(()=>{S.current?.(),S.current=null,A(),C.current=null},[e,A]),(0,X.useEffect)(()=>()=>{S.current?.(),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]);let I=(0,X.useMemo)(()=>{let r=p?.blockerTicketId;if(!r||p.projectId!==e||!E.has(r))return null;let i=new Map;for(let e of t){if(e.id===r){i.set(e.id,`source`);continue}let t=Zw(n,r,e.id);i.set(e.id,t.valid?`valid`:`idle`)}return i},[e,n,p,E,t]),L=(0,X.useCallback)(e=>{if(!I||!p)return`idle`;let t=I.get(e)??`idle`;return e===p.hoveredTicketId&&t===`idle`?`invalid`:t},[I,p]),R=(0,X.useMemo)(()=>!p||p.projectId!==e||!E.has(p.blockerTicketId)?null:{blockerTicketId:p.blockerTicketId,hoveredTicketId:p.hoveredTicketId,pointer:p.pointer},[e,p,E]);return{boardViewportRef:h,boardContentRef:g,registerTicketNode:O,measuredCardRects:(0,X.useMemo)(()=>{if(!i)return s;let e=s[i.id];return e?d?.ticketId===i.id?{...s,[i.id]:d.rect}:{...s,[i.id]:{...e,left:e.left+o.x,top:e.top+o.y}}:s},[d,i,s,o.x,o.y]),overlayPreview:R,overlaySize:l,getDependencyTargetState:L,handleDependencyStart:F,handleDeleteDependency:P}},rY=e=>{if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.id==`string`?t.id:``,r=typeof t.name==`string`?t.name:``,i=typeof t.command==`string`?t.command:``,a=typeof t.cwd==`string`?t.cwd:``,o=t.runner===`vitest`||t.runner===`jest`||t.runner===`unknown`?t.runner:`auto`;return n.trim()===``||r.trim()===``&&i.trim()===``&&a.trim()===``?[]:[{id:n,name:r,command:i,cwd:a,runner:o}]}):[]}catch{return[]}},iY=`[data-terminal-pane="true"]`,aY=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||e.isContentEditable},oY=e=>e instanceof HTMLElement?e.closest(iY)!==null:!1,sY=e=>aY(e)||oY(e),cY=(e,t={})=>{let{isBlocked:n}=t;(0,X.useEffect)(()=>{let t=t=>{if(t.defaultPrevented||t.repeat)return;let r=e.find(e=>!e.disabled&&e.key.toLowerCase()===t.key.toLowerCase()&&(e.ctrlKey??!1)===t.ctrlKey&&(e.altKey??!1)===t.altKey&&(e.metaKey??!1)===t.metaKey&&(e.shiftKey===void 0||e.shiftKey===t.shiftKey));r&&(n?.(document.activeElement)||(t.preventDefault(),r.onKeyDown()))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,n])},lY=e=>({...e,messages:void 0,agent_log:void 0,streaming_response:void 0}),uY=(e,t)=>e?e.state!==t.state||e.parked_at!==t.parked_at||e.worktree_bundle_id!==t.worktree_bundle_id:!0,dY=(e,t)=>{if(!e)return t;let n=t.worktree_bundle_id!==null&&e.worktree_bundle_id===t.worktree_bundle_id,r=t.bundle??(n&&e.bundle?.id===t.worktree_bundle_id?e.bundle:null),i=t.bundle_execution_position??(n?e.bundle_execution_position??null:null);return{...e,...t,bundle:r,bundle_execution_position:i}},fY=(e,t)=>{let n=e=>Fw(t)?Fw(e):e.state===t.state&&!Fw(e),r=e.findIndex(e=>n(e));if(r===-1)return[...e,t];let i=[...e];return i.splice(r,0,t),i},pY=(e,t)=>{let n=e.find(e=>e.id===t.id);return[n&&n.pull_request!==void 0&&t.pull_request===void 0?{...n,...t,pull_request:n.pull_request}:t,...e.filter(e=>e.id!==t.id)]},mY=(e,t)=>{let n=e.find(e=>e.id===t.id);if(!n)return[...e,t];let r=dY(n,t);return e.map(e=>e.id===t.id?r:e)},hY=(e,t)=>{let n=dY(e.find(e=>e.id===t.id),t);return fY(_Y(e,t.id),n)},gY=(e,t)=>{if(e.length===0)return[...t];let n=[...e];for(let e of t)n=uY(n.find(t=>t.id===e.id),e)?hY(n,e):mY(n,e);let r=new Set(t.map(e=>e.id));return n.filter(e=>r.has(e.id))},_Y=(e,t)=>e.filter(e=>e.id!==t),vY=(e,t,n,r={},i={})=>{let a=e.findIndex(e=>e.id===t);if(a===-1)return e;let o={...e[a],state:n,...r},s=_Y(e,t);if(i.preferredIndex!==void 0){let e=Math.max(0,Math.min(i.preferredIndex,s.length));return s.splice(e,0,o),s}return fY(s,o)},yY=async(e,t)=>{`Notification`in window&&Notification.permission!==`denied`&&(Notification.permission===`default`&&await Notification.requestPermission(),Notification.permission===`granted`&&new Notification(e,{body:t}))},bY=(0,X.createContext)(null),xY=15*1e3,SY=1e3,CY=async e=>yY(`Ticket done`,e),wY=e=>lY(e),TY=(e,t)=>t===`running`&&e.agent_status===`done`?`Finished ${e.state} for "${e.title}"`:t===`running`&&e.agent_status===`error`?`Failed ${e.state} for "${e.title}"`:t!==`running`&&e.agent_status===`running`?`Running ${e.state} for "${e.title}"`:null,EY=({activeProjectId:e,refreshKey:t=0,onLoadedProjectIdChange:n,onProjectUsageChange:r,onBundlesChange:i,onBundlesLoadingChange:a,children:o})=>{let[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)([]),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),C=(0,X.useRef)(0),w=(0,X.useRef)(0),T=(0,X.useRef)(new Map),E=(0,X.useRef)(new Map),D=(0,X.useRef)(e),O=(0,X.useRef)(new Map),k=(0,X.useRef)(new Map),A=(0,X.useRef)(new Map),j=(0,X.useCallback)((e,t)=>{let n=k.current.get(t.id);return!n||!e||t.state===n?t:e},[]),M=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(k.current);for(let r of e)n.set(r,t);k.current=n},[]),N=(0,X.useCallback)(e=>{if(e.length===0||k.current.size===0)return;let t=new Map(k.current);for(let n of e)t.delete(n);k.current=t},[]),P=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=new Map(A.current);for(let r of e)n.set(r,t);A.current=n},[]),F=(0,X.useCallback)(e=>{if(e.length===0||A.current.size===0)return;let t=new Map(A.current);for(let n of e)t.delete(n);A.current=t},[]),I=(0,X.useCallback)((e,t)=>{if(O.current.has(t.id))return null;let n=j(e,t);return A.current.has(t.id)?{...n,parked_at:A.current.get(t.id)??null}:n},[j]),L=(0,X.useCallback)((e,t)=>{if(O.current.size===0&&k.current.size===0&&A.current.size===0)return t;let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=I(n.get(e.id),e);return t?[t]:[]})},[I]),R=(0,X.useCallback)(async(e,t)=>{let n=await gt(e,t,{detail:`board`});return Array.isArray(n)?(!t?.aborted&&D.current===e&&c(e=>gY(e,L(e,n).map(wY))),n):null},[L]),ee=(0,X.useCallback)(async(e,t)=>{await R(e,t)},[R]),z=(0,X.useCallback)(async(e,t)=>{let n=++w.current,r=await _t(e,t);if(!Array.isArray(r)||t?.aborted||D.current!==e||w.current!==n)return;let i=new Map(r.map(e=>[e.id,e]));c(e=>e.map(e=>{let t=i.get(e.id);return t?{...e,diff_stats:t.diff_stats??null,is_stale:t.is_stale}:e}))},[]),B=(0,X.useCallback)(e=>e.some(e=>e.is_stale===void 0),[]),V=(0,X.useCallback)(async e=>{let t=D.current;if(!t)return null;try{let n=await vt(e,t);if(D.current!==t)return null;let r=E.current.get(n.id),i=I(r,n);if(!i)return null;let a=wY(i),o=uY(r,a);return c(e=>o?hY(e,a):mY(e,a)),n}catch{return null}},[I]),te=(0,X.useCallback)(async t=>{if(!e){f([]);return}f(await Ye(e,t))},[e]),ne=(0,X.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),re=(0,X.useMemo)(()=>{let e=s.filter(e=>e.agent_status===`running`),t=new Set(e.map(e=>e.worktree_bundle_id).filter(e=>typeof e==`string`&&e.trim().length>0));return{total_running:e.length,running_plan_count:e.filter(e=>e.state===`plan`).length,running_build_count:e.filter(e=>e.state===`build`).length,running_review_count:e.filter(e=>e.state===`review`).length,active_bundle_count:t.size,latest_message:x}},[x,s]);(0,X.useEffect)(()=>{E.current=ne},[ne]),(0,X.useEffect)(()=>{D.current=e,O.current.clear(),k.current.clear(),A.current.clear(),S(null),m(null),T.current.clear()},[e]),(0,X.useEffect)(()=>{n?.(_?null:h)},[h,_,n]),(0,X.useEffect)(()=>{if(i){if(!e){i(null,[]);return}if(h!==e){i(e,[]);return}i(e,d)}},[e,d,h,i]),(0,X.useEffect)(()=>{if(a){if(!e){a(null,!1);return}a(e,y===e)}},[e,y,a]),(0,X.useEffect)(()=>{let t=new AbortController,n=++C.current,r=null,i=async()=>{try{if(!e){c([]),u([]),f([]),g(null),v(null);return}c([]),u([]),f([]),g(null),v(e),b(e);let[n,i,a]=await Promise.allSettled([R(e,t.signal),ZJ(e,t.signal),Ye(e,t.signal)]);if(t.signal.aborted)return;n.status!==`fulfilled`&&!ge(n.reason)&&c([]),i.status===`fulfilled`?u(i.value):ge(i.reason)||u([]),a.status===`fulfilled`?f(a.value):ge(a.reason)||f([]),g(n.status===`fulfilled`&&i.status===`fulfilled`&&a.status===`fulfilled`?e:null),n.status===`fulfilled`&&n.value!==null&&B(n.value)&&(r=window.setTimeout(()=>{t.signal.aborted||z(e,t.signal)},SY))}finally{!t.signal.aborted&&C.current===n&&(v(null),b(null))}},a=t=>{t.project_id===e&&(m(t),!O.current.has(t.id)&&(t.bundle&&f(e=>pY(e,t.bundle)),c(e=>hY(e,wY(t)))))},o=t=>{if(t.project_id===e&&m(t),c(n=>{if(t.project_id!==e)return _Y(n,t.id);let r=n.find(e=>e.id===t.id),i=I(r,t);if(!i)return n;let a=wY(i);return uY(r,a)?hY(n,a):mY(n,a)}),t.project_id!==e){u(e=>qw(e,t.id));return}t.bundle&&f(e=>pY(e,t.bundle))},s=({id:e})=>{O.current.delete(e),A.current.delete(e),k.current.delete(e),c(t=>_Y(t,e)),u(t=>qw(t,e))},l=e=>{if(!e)return;let t=E.current.get(e.blocker_ticket_id),n=E.current.get(e.dependent_ticket_id);!t||!n||t.project_id!==D.current||n.project_id!==D.current||u(t=>Jw(t,e))},d=e=>{u(t=>Yw(t,e.blocker_ticket_id,e.dependent_ticket_id))};return i(),PW.on(`ticket:created`,a),PW.on(`ticket:updated`,o),PW.on(`ticket:deleted`,s),PW.on(`ticket-dependency:created`,l),PW.on(`ticket-dependency:deleted`,d),()=>{t.abort(),r!==null&&window.clearTimeout(r),PW.off(`ticket:created`,a),PW.off(`ticket:updated`,o),PW.off(`ticket:deleted`,s),PW.off(`ticket-dependency:created`,l),PW.off(`ticket-dependency:deleted`,d)}},[e,z,t,B,R,I]),(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController,n=()=>{document.visibilityState===`visible`&&Promise.allSettled([R(e,t.signal),te(t.signal)]).then(n=>{n[0]?.status===`fulfilled`&&n[0].value!==null&&B(n[0].value)&&z(e,t.signal)}).catch(()=>{})},r=window.setInterval(n,xY),i=UK(n);return()=>{t.abort(),window.clearInterval(r),i()}},[e,te,z,B,R]),(0,X.useEffect)(()=>{if(!e||!r||h!==e)return;let t=s.filter(e=>{let t=e.bundle?.branch??e.branch;return typeof t==`string`&&t.trim()!==``}).length;r({projectId:e,ticketCount:s.length,worktreeCount:t,repoPathLocked:s.length>0||t>0||d.length>0})},[e,d.length,h,r,s]),(0,X.useEffect)(()=>{for(let e of s){let t=T.current.get(e.id),n=TY(e,t);n&&S(n),t!==void 0&&t===`running`&&e.agent_status===`done`&&(e.state===`plan`||e.state===`build`||e.state===`review`)&&CY(e.title),T.current.set(e.id,e.agent_status)}},[s]);let ie=(0,X.useCallback)(()=>{m(null)},[]),ae=(0,X.useMemo)(()=>({tickets:s,setTickets:c,dependencies:l,setDependencies:u,bundles:d,setBundles:f,latestDetailedTicketUpdate:p,clearLatestDetailedTicketUpdate:ie,loadedProjectId:h,loadingProjectId:_,activeProjectIdRef:D,pendingDeletedTicketsRef:O,pendingOptimisticMovesRef:k,pendingParkedTicketsRef:A,refreshTickets:ee,requestSingleTicketRefresh:V,refreshBundles:te,resolvePendingTicket:I,resolvePendingTickets:L,markPendingOptimisticMoves:M,clearPendingOptimisticMoves:N,markPendingParkedTickets:P,clearPendingParkedTickets:F,liveActivity:re}),[d,ie,N,F,l,re,h,p,_,M,P,te,ee,V,I,L,s]);return(0,Z.jsx)(bY.Provider,{value:ae,children:o})},DY=()=>{let e=(0,X.useContext)(bY);if(!e)throw Error(`useProjectWorkspace must be used inside ProjectWorkspaceProvider`);return e},OY=(0,X.lazy)(()=>VW(()=>import(`./TestsDialog-Buw5J9nT.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),kY=e=>e===1?`1 ticket created`:`${e} tickets created`,AY=async e=>yY(`Planning done`,kY(e)),jY=`archon.last-model-selection`,MY=`archon.last-variant-selection`,NY=`archon.last-skills-selection`,PY=()=>{try{let e=window.localStorage.getItem(NY),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},FY=e=>[e.title,e.description,e.bundle?.name??``,e.bundle?.branch??``,e.branch??``].map(e=>e.toLowerCase()),IY=(e,t)=>{let n=e.bundle_execution_position??2**53-1,r=t.bundle_execution_position??2**53-1;if(n!==r)return n-r;if(e.created_at!==t.created_at)return e.created_at.localeCompare(t.created_at);let i=e.title.localeCompare(t.title,void 0,{sensitivity:`base`});return i===0?e.id.localeCompare(t.id):i},LY=(e,t)=>t?{...e,...t,messages:t.messages===void 0?e.messages:t.messages,agent_log:t.agent_log===void 0?e.agent_log:t.agent_log,streaming_response:t.streaming_response===void 0?e.streaming_response:t.streaming_response}:e,RY=(e,t)=>{let n=e.toLowerCase().trim().split(/\s+/).filter(Boolean);if(n.length===0)return!0;let r=FY(t);return n.every(e=>r.some(t=>t.includes(e)))},zY=[`plan`,`build`,`review`],BY=`done`,VY=()=>({build:!1,stopBuild:!1,resumeBuild:!1,review:!1,undoReview:!1,run:!1,stop:!1,followUp:!1,bundleRefresh:!1}),HY=({bundleId:e,activeRunContextKey:t,isProjectRootRunActive:n})=>n?!0:t!==null&&t!==e,UY=(e,t)=>{if(!e)return null;let n=t.find(t=>t.id===e.ticket_id);return n?Nw(n):e.ticket_id},WY=()=>({description:``,model:window.localStorage.getItem(jY)??``,variant:window.localStorage.getItem(MY)??``,skills:PY(),worktreeBundleId:``}),GY=()=>({isOpen:!1,composer:WY(),runs:[]}),KY=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`planning-run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,qY=e=>({ticketCount:e.tickets.length,dependencyCount:e.dependencies.length,ticketsWithOpenQuestions:e.tickets.filter(e=>(e.planning_context?.open_questions.length??0)>0).length,ticketTitles:e.tickets.map(e=>e.title),ticketIds:e.tickets.map(e=>e.id)}),JY=(e,t,n)=>e.map(e=>e.id===t?n(e):e),YY=(e,t,n)=>{e?window.localStorage.setItem(jY,e):window.localStorage.removeItem(jY),t?window.localStorage.setItem(MY,t):window.localStorage.removeItem(MY),n.length>0?window.localStorage.setItem(NY,JSON.stringify(n)):window.localStorage.removeItem(NY)},XY=(e,t={})=>cd(e,t),ZY=()=>({model:window.localStorage.getItem(jY)??``,variant:window.localStorage.getItem(MY)??``,skills:PY()}),QY=(e,t)=>{let n=_Y(e,t.ticket.id),r=Math.max(0,Math.min(t.index,n.length));return n.splice(r,0,t.ticket),n},$Y=e=>e.tickets.length>0&&e.tickets.every(e=>Hw(e,`trash`)),eX=e=>e.tickets.length>0&&e.tickets.every(e=>Hw(e,BY)),tX=e=>e.column===BY&&e.tickets.length>0&&e.tickets.every(e=>e.state!==`plan`),nX=(e,t,n)=>n||t!==null&&t!==Nw(e)?`Stop the currently running ticket before starting another run.`:tT(e),rX=(e,t)=>t===`build`?{agent_status:null,agent_log:null,streaming_response:null,build_completed_at:null,planning_context:e.planning_context?{...e.planning_context,open_questions:[]}:null}:t===`review`?{agent_status:null,agent_log:null,streaming_response:null}:{},iX=(e,t)=>e===`plan`&&t===`build`?`build`:e===`build`&&t===`review`?`review`:e===`review`&&t===`build`?`undoReview`:null,aX=(e,t,n)=>t===`review`&&n===`build`?{}:rX(e,n),oX=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:a,onRunStopped:o,onRunStatusChange:s,refreshKey:c=0})=>{let l=Qx(Zx(eC,{activationConstraint:{distance:5}})),{tickets:u,setTickets:d,dependencies:f,setDependencies:p,bundles:m,setBundles:h,latestDetailedTicketUpdate:g,clearLatestDetailedTicketUpdate:_,loadedProjectId:v,loadingProjectId:y,activeProjectIdRef:b,pendingDeletedTicketsRef:x,requestSingleTicketRefresh:S,refreshBundles:C,resolvePendingTicket:w,markPendingOptimisticMoves:T,clearPendingOptimisticMoves:E,markPendingParkedTickets:D,clearPendingParkedTickets:O}=DY(),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)({x:0,y:0}),[L,R]=(0,X.useState)(!1),[ee,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)([]),[te,ne]=(0,X.useState)([]),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)({}),[se,H]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(!1),[ue,de]=(0,X.useState)(null),[G,fe]=(0,X.useState)(null),[K,q]=(0,X.useState)(null),[me,he]=(0,X.useState)(null),[_e,ye]=(0,X.useState)(null),[be,xe]=(0,X.useState)(null),[Se,Ce]=(0,X.useState)(null),[we,Te]=(0,X.useState)(null),[Ee,De]=(0,X.useState)(null),[Oe,ke]=(0,X.useState)(null),[Ae,je]=(0,X.useState)(!1),[Ne,J]=(0,X.useState)(VY()),[Pe,Fe]=(0,X.useState)(0),[Ie,Le]=(0,X.useState)(``),[Re,ze]=(0,X.useState)(!1),Be=i===`opencode`||K?.tool===`opencode`||!!be?.tickets.some(e=>e.tool===`opencode`),Ve=i===`opencode`&&B.length>0,He=K?.tool===`opencode`&&B.length>0,Ue=!!be?.tickets.some(e=>e.tool===`opencode`)&&B.length>0,We=(0,X.useRef)(e),Ge=(0,X.useRef)(null),Ke=(0,X.useRef)(null),[Y,qe]=(0,X.useState)(null),Je=u.find(e=>e.is_running)??null,Ye=Je?Nw(Je):null,$e=r?.context_key??null,et=r?.kind===`ticket`?UY(r,u)??Ye:Ye,tt=r?.kind===`project`,ot=et??Y,st=(0,X.useCallback)(e=>HY({bundleId:e,activeRunContextKey:ot,isProjectRootRunActive:tt}),[ot,tt]),ct=k!==null&&Hw(k,`trash`)||j!==null&&$Y(j),ft=y===e,pt=(0,X.useMemo)(()=>rY(t?.test_commands??null),[t?.test_commands]),mt=pt.length>0,ht=(0,X.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]);(0,X.useEffect)(()=>{qe(null)},[e]),(0,X.useEffect)(()=>{Y!==null&&(tt||et!==null)&&qe(null)},[et,tt,Y]),(0,X.useEffect)(()=>{if(!G){q(null);return}let e=ht.get(G)??null;e&&q(t=>!t||t.id!==G?e:LY(t,e))},[G,ht]),(0,X.useEffect)(()=>{g&&(q(e=>!e||e.id!==g.id?e:LY(e,g)),xe(e=>{if(!e)return e;let t=g.worktree_bundle_id;if(!t||e.bundle.id!==t)return e;let n=e.tickets.some(e=>e.id===g.id)?e.tickets.map(e=>e.id===g.id?LY(e,g):e):[...e.tickets,g];return{...e,tickets:n}}))},[g]),(0,X.useEffect)(()=>{g===null||G!==null||me!==null||_()},[_,g,me,G]);let gt=(0,X.useCallback)(async e=>{let t=await S(e);if(!t)return null;let n=ht.get(e),r=n?LY(t,n):t;return q(t=>t&&t.id!==e||G&&G!==e?t:r),r},[S,G,ht]),_t=(0,X.useCallback)(e=>{q(e),fe(e.id),gt(e.id)},[gt]),vt=(0,X.useMemo)(()=>new Map(m.map(e=>[e.id,e])),[m]),xt=(0,X.useMemo)(()=>{if(!be)return null;let e=be.bundle.id,t=g?.worktree_bundle_id===e?g:null,n=u.filter(t=>t.worktree_bundle_id===e),r=new Map(n.map(e=>[e.id,e])),i=be.tickets.filter(e=>!x.current.has(e.id)).map(e=>t&&e.id===t.id?LY(e,t):e);t&&!i.some(e=>e.id===t.id)&&!x.current.has(t.id)&&i.push(t);let a=i.map(e=>LY(e,r.get(e.id)));for(let e of n)a.some(t=>t.id===e.id)||a.push(e);a.sort(IY);let o=be.execution_order_ticket_ids??[],s=a.map(e=>e.id),c=[...o,...s].filter((e,t,n)=>s.includes(e)&&n.indexOf(e)===t),l=n.some(e=>e.can_re_review!==void 0||e.has_completed_review!==void 0||e.has_follow_up_since_last_review!==void 0),d=n.some(e=>e.agent_status===`running`),f={has_completed_review:n.some(e=>e.has_completed_review===!0),has_follow_up_since_last_review:n.some(e=>e.has_follow_up_since_last_review===!0),can_re_review:!d&&n.some(e=>e.can_re_review===!0)},p=ad(a),m=a.find(e=>e.id===be.review_owner_ticket_id&&e.state===`review`)??a.find(e=>e.state===`review`)??null,h=cd(a,{targetTicketId:be.target_ticket_id,reviewOwnerTicketId:m?.id??be.review_owner_ticket_id,latestSessionTicketId:p?.id??be.latest_session_ticket_id});return{...be,bundle:vt.get(e)??be.bundle,tickets:a,execution_order_ticket_ids:c,latest_session_ticket_id:p?.id??null,latest_session_id:p?.session_id??null,review_owner_ticket_id:m?.id??null,target_ticket_id:h?.id??null,has_completed_review:l?f.has_completed_review:be.has_completed_review,has_follow_up_since_last_review:l?f.has_follow_up_since_last_review:be.has_follow_up_since_last_review,can_re_review:l?f.can_re_review:be.can_re_review}},[vt,g,x,be,u]),Ct=(0,X.useMemo)(()=>u.filter(e=>Re&&Lw(e)?!1:RY(Ie,e)),[Re,Ie,u]),wt=(0,X.useMemo)(()=>Ct.filter(e=>Fw(e)),[Ct]),Tt=(0,X.useMemo)(()=>ld(wt,m,BY),[m,wt]),{boardViewportRef:Et,boardContentRef:Dt,registerTicketNode:Ot,measuredCardRects:kt,overlayPreview:Jt,overlaySize:Yt,getDependencyTargetState:Xt,handleDependencyStart:Zt,handleDeleteDependency:Qt}=nY({activeProjectId:e,tickets:u,dependencies:f,setDependencies:p,activeTicket:k,activeOverlayNode:N,dragOffset:F}),$t=e?ae[e]??GY():GY(),en=$t.composer.worktreeBundleId&&m.some(e=>e.id===$t.composer.worktreeBundleId)?$t.composer.worktreeBundleId:``,tn=en===$t.composer.worktreeBundleId?$t:{...$t,composer:{...$t.composer,worktreeBundleId:en}},nn=ZY(),rn=!!t?.run_ide?.trim(),an=tn.runs.filter(e=>e.boardVisible),on=(0,X.useCallback)((e,t,n=u)=>{let r=ld(n,m,t).find(t=>t.kind===`bundle`&&t.group.bundle.id===e);return r?.kind===`bundle`?r.group:null},[m,u]),sn=(0,X.useCallback)(e=>(0,Z.jsx)(ZW,{ticket:e,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:e.tool===`opencode`&&B.length>0,availableModels:B,runDisabled:!0,hideBundleScopedControls:!0}),[t?.memory_enabled,B,m,f,u]),cn=an.length>0?(0,Z.jsx)(`div`,{className:`mb-0.5 flex flex-col gap-2.5`,children:an.map(e=>(0,Z.jsx)(UJ,{run:e},e.id))}):null,ln=(0,X.useCallback)(t=>sd(t)?t.project_id===e?rn:!!t.has_run_ide:!1,[rn,e]),un=(0,X.useCallback)(e=>!!e.project_id&&!!(e.bundle?.branch??e.branch)&&sd(e),[]),dn=(0,X.useCallback)(e=>{let t=e?.tickets.find(t=>t.id===e.target_ticket_id)??e?.tickets.find(e=>e.has_worktree)??null;return t?ln(t):!1},[ln]),fn=(0,X.useCallback)(e=>{let t=u.filter(t=>t.worktree_bundle_id===e).sort(IY);return be?.bundle.id===e?XY(be.tickets.map(e=>t.find(t=>t.id===e.id)??e).sort(IY),{targetTicketId:be.target_ticket_id,reviewOwnerTicketId:be.review_owner_ticket_id,latestSessionTicketId:be.latest_session_ticket_id}):XY(t)},[be,u]),pn=(0,X.useCallback)((e,t)=>{oe(n=>({...n,[e]:t(n[e]??GY())}))},[]);(0,X.useEffect)(()=>{H(!1),le(!1),Ce(null),ke(null),We.current!==e&&(Ge.current=e),e||(Ge.current=null,Le(``)),We.current=e},[e,c]),(0,X.useLayoutEffect)(()=>{!e||v!==e||Ge.current===e&&(Ge.current=null,Le(``))},[e,v]),(0,X.useEffect)(()=>{if(!Be){ne([]);return}let t=new AbortController;return(async()=>{try{V(await qt(`opencode`,t.signal))}catch(e){ge(e)||V(e=>e)}})(),(async()=>{try{ne(await yw(`opencode`,t.signal,e))}catch(e){ge(e)||ne([])}})(),()=>{t.abort()}},[e,Be]);let mn=({active:e})=>{ie(!1),P(null),I({x:0,y:0});let t=dd(String(e.id));if(t){M(on(t.bundleId,t.column)),A(null);return}M(null),A(u.find(t=>t.id===e.id)??null)},hn=()=>{ie(!1),P(null),I({x:0,y:0}),A(null),M(null)},gn=(0,X.useCallback)(e=>{d(t=>e.reduce((e,t)=>hY(e,t),t))},[d]),_n=(0,X.useCallback)((e,t)=>{if(e.length===0)return;let n=e[0]?.state;n&&d(r=>e.reduce((e,r)=>vY(e,r.id,t,aX(r,n,t)),r))},[d]),vn=(0,X.useCallback)((e,t=u)=>!e.worktree_bundle_id||!e.project_id||e.state!==`build`?[]:t.filter(t=>t.project_id===e.project_id&&t.worktree_bundle_id===e.worktree_bundle_id&&t.state===`build`&&t.parked_at===null).sort(IY),[u]),yn=async({active:e,over:t})=>{let n=dd(String(e.id)),r=u.find(t=>t.id===e.id),i=n?on(n.bundleId,n.column):null,a=t?.id===`trash`&&(r!==void 0&&Hw(r,`trash`)||i!==null&&$Y(i)),o=t?.id&&zY.includes(t.id)?t.id:null;if(ie(a),P(null),I({x:0,y:0}),A(null),M(null),t){if(n){if(t.id===`trash`){if(!i||!$Y(i))return;await jn(i);return}if(t.id===BY){if(!i||!eX(i))return;await On(i);return}if(o){if(n.column===BY){if(!i||!tX(i))return;await kn(i);return}await or(n.bundleId,n.column,o)}return}if(t.id===`trash`){if(!r||!Hw(r,`trash`))return;Pn(e.id);return}if(t.id===BY){if(!r||!Hw(r,BY))return;await En(e.id);return}if(o){if(r&&Vw(r,o)){await Dn(e.id);return}if(!(!r||!Hw(r,o)))try{await wn(r,o,{optimistic:!0})}catch(e){Q.error(e instanceof ve?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`})}}}},bn=async(t,n,r,a,o,s,c)=>{let l=await yt({title:t,description:n,tool:i,model:a,variant:o,skills:s,project_id:e,...c});if(YY(a,o,s),d(e=>hY(e,lY(l))),l.bundle&&h(e=>pY(e,l.bundle)),r===`build`)try{await wn(l,`build`)}catch(e){Q.error(e instanceof ve?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`})}r===`plan`&&Kt(l.id,l.project_id)},xn=async t=>{if(!e)throw Error(`Cannot create a bundle without an active project.`);let n=await Xe(e,{name:t,prepare:!0});return h(e=>pY(e,n)),n},Sn=e=>{d(t=>[...e.tickets].reverse().reduce((e,t)=>hY(e,lY(t)),t)),p(t=>e.dependencies.reduce((e,t)=>Jw(e,t),t));for(let t of e.tickets)t.bundle&&h(e=>pY(e,t.bundle))},Cn=(0,X.useCallback)((e,t={})=>{let n=lY(e);d(e=>t.reorderInState?hY(e,n):mY(e,n)),q(t=>!t||t.id!==e.id?t:LY(e,n)),e.bundle&&h(t=>pY(t,e.bundle))},[h,d]),wn=async(e,t,n={})=>{let r=u.findIndex(t=>t.id===e.id),i=t===`review`?vn(e):[],a=t===`review`&&i.length>1,o=n.optimistic?a?i.map(e=>e.id):[e.id]:[];n.optimistic&&(T(o,t),a?_n(i,t):d(n=>vY(n,e.id,t,rX(e,t))));try{if(a&&e.project_id&&e.worktree_bundle_id){let t=await rt(e.project_id,e.worktree_bundle_id);Yn(t);let n=t.tickets.find(t=>t.id===e.id);if(!n)throw Error(`Requested ticket was not returned from the bundle review response.`);return E(o),n}let n=await St(e.id,e.project_id,t);return d(r=>{let i=r.find(t=>t.id===e.id);return i?.state===t&&n.state===t&&i.agent_status!==n.agent_status&&n.agent_status===e.agent_status?r:uY(i,n)?hY(r,n):mY(r,n)}),n.bundle&&h(e=>pY(e,n.bundle)),E(o),n}catch(t){throw n.optimistic&&(a?gn(i):d(t=>vY(t,e.id,e.state,{agent_status:e.agent_status,agent_log:e.agent_log,build_completed_at:e.build_completed_at},{preferredIndex:r})),E(o)),t}},Tn=(e,t)=>{d(n=>n.map(n=>n.id===e?{...n,...t}:n))},En=async t=>{let n=u.find(e=>e.id===t);if(n)try{let r=new Date().toISOString();D([t],r),Tn(t,{parked_at:r}),Cn(await Pt(t,n.project_id??e),{reorderInState:!0}),O([t])}catch(e){O([t]),Tn(t,{parked_at:n.parked_at}),Q.error(e instanceof ve?e.message:`Unable to park the ticket right now.`,{id:`board-park-error`})}},Dn=async t=>{let n=u.find(e=>e.id===t);if(n)try{D([t],null),Tn(t,{parked_at:null}),Cn(await Ft(t,n.project_id??e),{reorderInState:!0}),O([t])}catch(e){O([t]),Tn(t,{parked_at:n.parked_at}),Q.error(e instanceof ve?e.message:`Unable to return the ticket right now.`,{id:`board-unpark-error`})}},On=(0,X.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at})),r=new Date().toISOString();D(e.tickets.map(e=>e.id),r),d(e=>e.map(e=>t.has(e.id)?{...e,parked_at:r}:e));let i=await Promise.allSettled(e.tickets.map(e=>Pt(e.id,e.project_id??b.current))),a=new Set;if(i.forEach((t,n)=>{if(t.status===`fulfilled`){O([t.value.id]),Cn(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&a.add(r.id)}),a.size===0)return;O([...a]),d(e=>e.map(e=>{if(!a.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let o=i.find(e=>e.status===`rejected`),s=a.size===e.tickets.length?o?.reason instanceof ve?o.reason.message:`Unable to move the bundle to Done right now.`:`Moved ${e.tickets.length-a.size} of ${e.tickets.length} bundle tickets to Done.`;Q.error(s,{id:`board-bundle-park-error`})},[b,Cn,O,D,d]),kn=(0,X.useCallback)(async e=>{let t=new Set(e.tickets.map(e=>e.id)),n=e.tickets.map(e=>({id:e.id,parked_at:e.parked_at}));D(e.tickets.map(e=>e.id),null),d(e=>e.map(e=>t.has(e.id)?{...e,parked_at:null}:e));let r=await Promise.allSettled(e.tickets.map(e=>Ft(e.id,e.project_id??b.current))),i=new Set;if(r.forEach((t,n)=>{if(t.status===`fulfilled`){O([t.value.id]),Cn(t.value,{reorderInState:!0});return}let r=e.tickets[n];r&&i.add(r.id)}),i.size===0)return;O([...i]),d(e=>e.map(e=>{if(!i.has(e.id))return e;let t=n.find(t=>t.id===e.id);return t?{...e,parked_at:t.parked_at}:e}));let a=r.find(e=>e.status===`rejected`),o=i.size===e.tickets.length?a?.reason instanceof ve?a.reason.message:`Unable to restore the bundle right now.`:`Restored ${e.tickets.length-i.size} of ${e.tickets.length} bundle tickets.`;Q.error(o,{id:`board-bundle-unpark-error`})},[b,Cn,O,D,d]),An=async t=>{e&&(await dt(e,t),h(e=>e.filter(e=>e.id!==t)))},jn=(0,X.useCallback)(async t=>{let n=t.tickets.map(e=>({ticket:e,index:u.findIndex(t=>t.id===e.id)})).filter(e=>e.index!==-1);if(n.length===0)return;for(let e of n)x.current.set(e.ticket.id,e);let r=new Set(n.map(e=>e.ticket.id));d(e=>e.filter(e=>!r.has(e.id))),p(e=>e.filter(e=>!r.has(e.blocker_ticket_id)&&!r.has(e.dependent_ticket_id)));let i=await Promise.allSettled(n.map(async t=>(await Mt(t.ticket.id,t.ticket.project_id??e),x.current.delete(t.ticket.id),t.ticket.id)));t.tickets.some(e=>e.project_id===b.current)&&C().catch(()=>{});let a=n.filter((e,t)=>i[t]?.status===`rejected`);if(a.length===0)return;for(let e of a)x.current.delete(e.ticket.id);a.some(e=>e.ticket.project_id===b.current)&&d(e=>[...a].sort((e,t)=>e.index-t.index).reduce((e,t)=>QY(e,t),e));let o=i.find(e=>e.status===`rejected`),s=a.length===n.length?o?.reason instanceof ve?o.reason.message:`Unable to delete the bundle tickets right now.`:`Deleted ${n.length-a.length} of ${n.length} bundle tickets.`;Q.error(s,{id:`board-delete-bundle-wrapper-error`})},[e,b,x,C,p,d,u]),Mn=e=>{let t=ht.get(e.id);Cn(e,{reorderInState:t?t.state!==e.state||t.parked_at!==e.parked_at||t.worktree_bundle_id!==e.worktree_bundle_id:!1}),t?.worktree_bundle_id&&t.worktree_bundle_id!==e.worktree_bundle_id&&t.bundle?.ticket_count===1&&h(e=>e.filter(e=>e.id!==t.worktree_bundle_id)),(t?.worktree_bundle_id!==e.worktree_bundle_id||t?.bundle?.ticket_count!==e.bundle?.ticket_count)&&e.project_id===b.current&&C().catch(()=>{})},Nn=async()=>{if(!e)return;let t=e,n=$t.composer.description.trim();if(!n)return;let r=KY(),a=Ve?$t.composer.model.trim():``,o=Ve&&a?$t.composer.variant.trim():``,s=Ve?$t.composer.skills:[],c=Date.now();pn(t,e=>({...e,isOpen:!1,composer:{...e.composer,description:``,worktreeBundleId:``},runs:[{id:r,description:n,model:a,variant:o,skills:s,worktreeBundleId:en,status:`running`,error:null,submittedAt:c,completedAt:null,boardVisible:!0,boardState:`visible`,summary:null},...e.runs]}));try{let e=await bt({description:n,tool:i,model:a||null,variant:a&&o||null,skills:s,project_id:t,worktree_bundle_id:en||null});YY(a||null,a&&o||null,s);let c=qY(e);pn(t,e=>({...e,runs:JY(e.runs,r,e=>({...e,status:`done`,error:null,completedAt:Date.now(),summary:c,boardVisible:!1}))})),Q.success(`${c.ticketCount} ${c.ticketCount===1?`card`:`cards`} created`,{id:`planning-agent-success-${r}`}),AY(e.tickets.length),b.current===t&&Sn(e)}catch(e){let n=e instanceof ve?e.message:`Unable to generate tickets right now.`;pn(t,e=>({...e,runs:JY(e.runs,r,e=>({...e,status:`error`,error:n,completedAt:Date.now()}))})),Q.error(n,{id:`planning-agent-error`})}},Pn=async t=>{let n=u.find(e=>e.id===t),r=u.findIndex(e=>e.id===t);if(!(!n||r===-1)){x.current.set(t,{ticket:n,index:r}),d(e=>_Y(e,t)),p(e=>qw(e,t));try{await Mt(t,n.project_id??e),n.project_id===b.current&&C().catch(()=>{}),x.current.delete(t)}catch(e){let n=x.current.get(t);x.current.delete(t),n&&n.ticket.project_id===b.current&&(d(e=>QY(e,n)),Q.error(e instanceof ve?e.message:`Unable to delete the ticket right now.`,{id:`board-delete-error`}))}}},Fn=async t=>{let n=u.find(e=>e.id===t);if(!n)return;let r=n.state===`review`?`review`:`build`;try{if(de(r),n.project_id&&n.worktree_bundle_id&&n.state===`review`){Yn(await it(n.project_id,n.worktree_bundle_id));return}Cn(await Nt(t,n.project_id??e),{reorderInState:!0})}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to undo the ticket right now.`,{id:`board-undo-error`}),e}finally{de(e=>e===r?null:e)}},In=t=>{Lt(t,u.find(e=>e.id===t)?.project_id??e)},Ln=async t=>{let n=u.find(e=>e.id===t),r=n?Nw(n):t;try{qe(r),await Rt(t,n?.project_id??e),s?.()}catch(e){qe(e=>e===r?null:e),Q.error(e instanceof ve?e.message:`Unable to start the run right now.`,{id:`board-run-error`})}},Rn=(0,X.useCallback)(async t=>{let n=u.find(e=>e.id===t);try{await zt(t,n?.project_id??e)}catch(e){Q.error(e instanceof ve?e.message:`Unable to open the IDE right now.`,{id:`board-open-ide-error`})}},[e,u]),zn=async t=>{let n=u.find(e=>e.id===t),i=r?.kind===`ticket`&&n&&et===Nw(n)?$e:null;try{await Bt(t,n?.project_id??e),o?.(i),s?.()}catch{}},Bn=t=>{Vt(t,u.find(e=>e.id===t)?.project_id??e).then(()=>{d(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e))})},Vn=t=>{Ht(t,u.find(e=>e.id===t)?.project_id??e).then(()=>{d(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e))})},Hn=(0,X.useCallback)(e=>{let t=fn(e);!t||!ln(t)||Rn(t.id)},[ln,fn,Rn]),Un=(0,X.useCallback)(e=>{let t=fn(e);t&&De({bundleId:e,ticketId:t.id,projectId:t.project_id,title:t.bundle?md(t.bundle):t.title})},[fn]),Wn=(0,X.useCallback)(e=>{if(!mt)return;let t=fn(e);!t?.project_id||!sd(t)||ke(e)},[fn,mt]),Gn=(0,X.useCallback)(e=>{let t=u.find(t=>t.id===e);!t||!un(t)||Te({ticketId:t.id,projectId:t.project_id,title:t.title})},[un,u]),Kn=(0,X.useCallback)(e=>{if(!mt)return;let t=u.find(t=>t.id===e);!t?.project_id||!sd(t)||Ce({ticketId:t.id,projectId:t.project_id})},[mt,u]),qn=(0,X.useCallback)(async(t,n)=>{let r=u.find(e=>e.id===t);if(r)try{Cn(r.state===`plan`?await Gt(t,r.project_id??e,n):await Ut(t,r.project_id??e,n))}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to send the follow-up prompt right now.`,{id:`board-follow-up-error`}),e}},[e,Cn,u]),Jn=(0,X.useCallback)(e=>{d(t=>e.reduce((e,t)=>{let n=e.find(e=>e.id===t.id),r=w(n,t);if(!r)return e;let i=lY(n&&n.state===r.state&&n.agent_status===`running`&&r.agent_status===null?{...r,agent_status:n.agent_status,session_id:n.session_id,is_running:n.is_running}:r);return uY(n,i)?hY(e,i):mY(e,i)},t))},[w,d]),Yn=(0,X.useCallback)(e=>{xe(e),h(t=>pY(t,e.bundle)),Jn(e.tickets)},[Jn,h]),Xn=(0,X.useCallback)((e,t)=>{Array.isArray(t.tickets)&&xe(n=>!n||n.bundle.id!==e?n:{...n,tickets:t.tickets,execution_order_ticket_ids:t.execution_order_ticket_ids,latest_session_ticket_id:t.latest_session_ticket_id,latest_session_id:t.latest_session_id,review_owner_ticket_id:t.review_owner_ticket_id,target_ticket_id:t.target_ticket_id})},[]),Zn=(0,X.useCallback)(async e=>{let t=b.current;if(!t)return null;let n=await Ze(t,e);return b.current===t?(Yn(n),n):null},[b,Yn]),Qn=(0,X.useCallback)(async e=>{let t=b.current;if(!t)return null;let n=await Qe(t,e);return b.current===t?(Xn(e,n),n):null},[b,Xn]),$n=(0,X.useCallback)(async(e,t=null)=>{let n=b.current;if(!n)return;fe(null),q(null),he(e),ye(t),J(VY());let r=vt.get(e)??null,i=u.filter(t=>t.worktree_bundle_id===e);if(r&&i.length>0){let e=ad(i),t=cd(i,{reviewOwnerTicketId:i.find(e=>e.state===`review`)?.id??null,latestSessionTicketId:e?.id??null});xe({bundle:r,tickets:i,latest_session_ticket_id:e?.id??null,latest_session_id:e?.session_id??null,review_owner_ticket_id:i.find(e=>e.state===`review`)?.id??null,target_ticket_id:t?.id??null})}else xe(null);je(!0);try{await Qn(e)}catch{}finally{b.current===n&&je(!1)}},[b,vt,Qn,u]),er=(0,X.useCallback)(async(e,t)=>{J(t=>({...t,[e]:!0}));try{return await t()}finally{J(t=>({...t,[e]:!1}))}},[]),tr=(0,X.useCallback)(async t=>{await er(`stopBuild`,async()=>{let n=u.find(e=>e.id===t);await Vt(t,n?.project_id??e),d(e=>e.map(e=>e.id===t?{...e,agent_status:`stopped`,is_running:!1}:e)),n?.worktree_bundle_id&&await Zn(n.worktree_bundle_id)})},[e,Zn,er,d,u]),nr=(0,X.useCallback)(async t=>{await er(`resumeBuild`,async()=>{let n=u.find(e=>e.id===t);await Ht(t,n?.project_id??e),d(e=>e.map(e=>e.id===t?{...e,agent_status:`running`}:e)),n?.worktree_bundle_id&&await Zn(n.worktree_bundle_id)})},[e,Zn,er,d,u]),rr=(0,X.useCallback)(async t=>{if(e)try{Yn(await er(`build`,()=>nt(e,t))),me===t&&ye(`build`),s?.()}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to build the bundle right now.`,{id:`board-bundle-build-error`}),e}},[e,Yn,s,er,me]),ir=(0,X.useCallback)(async t=>{if(e)try{Yn(await er(`review`,()=>rt(e,t))),me===t&&ye(`review`)}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to review the bundle right now.`,{id:`board-bundle-review-error`}),e}},[e,Yn,er,me]),ar=(0,X.useCallback)(async t=>{if(e)try{de(`review`),Yn(await er(`undoReview`,()=>it(e,t))),me===t&&ye(`build`)}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to undo the bundle review right now.`,{id:`board-bundle-undo-review-error`}),e}finally{de(e=>e===`review`?null:e)}},[e,Yn,er,me]),or=(0,X.useCallback)(async(e,t,n)=>{if(t===BY||n===BY)return;let r=iX(t,n);if(!r)return;let i=u.filter(n=>n.worktree_bundle_id===e&&n.state===t&&n.parked_at===null);if(i.length===0)return;let a=i.map(e=>e.id);T(a,n),_n(i,n);try{if(r===`build`){await rr(e),E(a);return}if(r===`review`){await ir(e),E(a);return}await ar(e),E(a)}catch(e){gn(i),E(a),Q.error(e instanceof ve?e.message:`Unable to move the bundle right now.`,{id:`board-bundle-move-error`})}},[E,rr,ir,ar,T,_n,gn,u]),sr=async t=>{e&&(Yn(await er(`run`,()=>lt(e,t))),s?.())},cr=async t=>{if(!e)return;let n=r?.kind===`ticket`&&et===t?$e:null,i=await er(`stop`,()=>ut(e,t));o?.(n),Yn(i),s?.()},lr=(0,X.useCallback)(async(t,n)=>{e&&Yn(await er(`followUp`,()=>at(e,t,n)))},[e,Yn,er]);(0,X.useEffect)(()=>()=>{a?.(null)},[a]),(0,X.useEffect)(()=>{if(!a)return;if(!r){a(null);return}if(r.kind===`project`){a({target:null,canSelect:!1,disabledReason:`Preview selection is unavailable for project root runs.`,submitPrompt:null});return}let e=u.find(e=>e.id===r.ticket_id);if(!e){a({target:null,canSelect:!1,disabledReason:`Preview selection is only available for build-capable ticket runs.`,submitPrompt:null});return}if(e.state===`plan`){a({target:{kind:`ticket`,id:e.id},canSelect:!1,disabledReason:`Preview selection is unavailable while this ticket is in Plan mode.`,submitPrompt:null});return}if(e.worktree_bundle_id){a({target:{kind:`bundle`,id:e.worktree_bundle_id,ticket_id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:`Follow up on this bundle`,submitPrompt:t=>lr(e.worktree_bundle_id,t)});return}a({target:{kind:`ticket`,id:e.id},canSelect:!0,disabledReason:null,promptPlaceholder:`Follow up on this ticket`,submitPrompt:t=>qn(e.id,t)})},[r,qn,lr,a,u]);let ur=async t=>{let n=u.find(e=>e.id===t),r=n?jw(n.state):null;if(n)try{if(n.state===`review`&&n.can_re_review&&n.agent_status!==`running`){let t=await Wt(n.id,n.project_id??e);Cn(t),t.worktree_bundle_id&&await Zn(t.worktree_bundle_id);return}if(!r)return;if(n.worktree_bundle_id&&r===`review`){await ir(n.worktree_bundle_id);return}await wn(n,r)}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to move the ticket right now.`,{id:`board-move-error`}),e}},dr=async t=>{let n=u.find(e=>e.id===t);try{Cn(await At(t,n?.project_id??e))}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to start the build chain right now.`,{id:`board-build-chain-error`}),e}},fr=async t=>{let n=u.find(e=>e.id===t);try{await jt(t,n?.project_id??e)}catch(e){throw Q.error(e instanceof ve?e.message:`Unable to stop the build chain right now.`,{id:`board-stop-build-chain-error`}),e}},pr=async()=>{if(!(!e||ce)){le(!0);try{let t=await It(e);d(e=>e.filter(e=>!t.deleted_ticket_ids.includes(e.id))),p(e=>t.deleted_ticket_ids.reduce(qw,e)),await C(),H(!1),t.failed_count>0?Q.error(`Deleted ${t.deleted_count} done ticket${t.deleted_count===1?``:`s`}, but ${t.failed_count} failed.`,{id:`board-delete-parked-error`}):Q.success(`Deleted ${t.deleted_count} done ticket${t.deleted_count===1?``:`s`}.`,{id:`board-delete-parked-success`})}catch(e){Q.error(e instanceof ve?e.message:`Unable to empty Done right now.`,{id:`board-delete-parked-error`})}finally{le(!1)}}},mr=({delta:e})=>{I(e)},hr=(0,X.useCallback)(()=>{e&&R(!0)},[e]),gr=(0,X.useCallback)(()=>{e&&pn(e,e=>e.isOpen?e:{...e,isOpen:!0})},[e,pn]),_r=(0,X.useCallback)(()=>{Ke.current?.focus({preventScroll:!0})},[]);return cY([{key:`n`,onKeyDown:hr,disabled:!e},{key:`a`,onKeyDown:gr,disabled:!e},{key:`k`,ctrlKey:!0,onKeyDown:_r}],{isBlocked:sY}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ZC,{sensors:l,collisionDetection:lS,onDragStart:mn,onDragMove:mr,onDragCancel:hn,onDragEnd:yn,children:[(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(YJ,{projectId:e,state:tn,bundles:m,projectBranchState:n,showModelSelector:Ve,availableModels:B,availableSkills:te,onManageBundles:e?()=>{(async()=>{try{await C()}catch{}z(!0)})()}:void 0,onToggle:()=>{e&&pn(e,e=>({...e,isOpen:!e.isOpen}))},onDescriptionChange:t=>{e&&pn(e,e=>({...e,composer:{...e.composer,description:t}}))},onModelChange:t=>{if(!e)return;let n=B.find(e=>e.id===t)??null;pn(e,e=>({...e,composer:{...e.composer,model:t,variant:n?.variants.includes(e.composer.variant)?e.composer.variant:``}}))},onSkillsChange:t=>{e&&pn(e,e=>({...e,composer:{...e.composer,skills:t}}))},onVariantChange:t=>{e&&pn(e,e=>({...e,composer:{...e.composer,variant:t}}))},onBundleChange:t=>{e&&pn(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t}}))},onGenerate:()=>{Nn()}}),(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:W(`absolute inset-y-0 left-16 right-0 z-10 bg-black/60 transition-opacity duration-200 ease-out motion-reduce:transition-none`,tn.isOpen?`opacity-100`:`pointer-events-none opacity-0`)}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 overflow-hidden p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,Z.jsx)(Me,{id:`board-ticket-search`,ref:Ke,type:`search`,value:Ie,onChange:e=>Le(e.target.value),placeholder:`Search tickets`,"aria-label":`Search tickets`,className:`pr-32`}),Ie.length>0?(0,Z.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Clear search`,className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{Le(``),Ke.current?.focus()},children:(0,Z.jsx)(pe,{className:`size-4`})}):(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(vw,{children:`CTRL`}),(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(vw,{children:`K`})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Zd,{id:`board-hide-stale-tickets`,checked:Re,onCheckedChange:ze,"aria-label":`Hide stale tickets`}),(0,Z.jsx)(zl,{htmlFor:`board-hide-stale-tickets`,className:`text-sm text-muted-foreground`,children:`Hide stale tickets`})]})]}),(0,Z.jsx)(`div`,{ref:Et,className:`flex min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,Z.jsxs)(`div`,{ref:Dt,className:`relative flex min-h-0 w-max min-w-full gap-4`,children:[(0,Z.jsx)(zJ,{dependencies:f,cardRects:kt,preview:Jt,ticketsById:ht,overlaySize:Yt}),zY.map(t=>{let n=u.filter(e=>e.state===t&&!Fw(e)),r=Ct.filter(e=>e.state===t&&!Fw(e)),i=ld(r,m,t),a=ft&&n.length===0?t===`plan`?1:t===`build`?2:0:0;return(0,Z.jsx)($W,{id:t,title:t.charAt(0).toUpperCase()+t.slice(1),pinnedContent:t===`plan`?cn:null,items:i,ticketCount:r.length,allTickets:u,dependencies:f,showModelSelector:Ve,availableModels:B,bundles:m,activeRunContextKey:ot,isProjectRootRunActive:tt,isBundleRunDisabled:st,getDependencyTargetState:Xt,onDependencyStart:Zt,onDeleteDependency:Qt,onRegisterTicketNode:Ot,onAddTicket:t===`plan`&&e?hr:void 0,onCreateBundle:t===`plan`&&e?xn:void 0,onDeleteBundle:t===`plan`&&e?An:void 0,onDeleteBundleWrapper:jn,onRefreshBundles:t===`plan`&&e?C:void 0,onUpdateTicket:Mn,onDeleteTicket:Pn,onUndoTicket:Fn,undoingColumn:ue,onRetryTicket:In,onAdvanceTicket:ur,onParkTicket:En,onUnparkTicket:Dn,onBuildChainTicket:dr,onRunTicket:Ln,onOpenTestsTicket:mt?Kn:void 0,canOpenChangesForTicket:un,onOpenChangesTicket:Gn,canOpenIdeForTicket:ln,onOpenIdeTicket:Rn,onStopTicket:zn,onStopBuildTicket:Bn,onStopBuildChainTicket:fr,onResumeBuildTicket:Vn,onOpenBundleChanges:Un,onOpenBundleTests:mt?Wn:void 0,onOpenBundleIde:Hn,onFollowUpTicket:qn,bundleActionState:Ne,onBuildBundle:rr,onReviewBundle:ir,onUndoBundleReview:ar,onRunBundle:sr,onStopBundle:cr,onParkBundleWrapper:On,onUnparkBundleWrapper:kn,onOpenTicketDetails:_t,onOpenBundleDetails:(e,t)=>{$n(e,t)},onRequestBundleRefresh:e=>{er(`bundleRefresh`,()=>Zn(e))},onRequestTicketRefresh:S,loadingSkeletonCount:a},t)}),(0,Z.jsx)($W,{id:BY,title:`Done`,items:Tt,ticketCount:wt.length,allTickets:u,dependencies:f,showModelSelector:Ve,availableModels:B,bundles:m,activeRunContextKey:ot,isProjectRootRunActive:tt,isBundleRunDisabled:st,getDependencyTargetState:Xt,onDependencyStart:Zt,onDeleteDependency:Qt,onRegisterTicketNode:Ot,onUpdateTicket:Mn,onDeleteTicket:Pn,onUndoTicket:Fn,undoingColumn:ue,onRetryTicket:In,onAdvanceTicket:ur,onParkTicket:En,onUnparkTicket:Dn,onBuildChainTicket:dr,onRunTicket:Ln,onOpenTestsTicket:mt?Kn:void 0,canOpenChangesForTicket:un,onOpenChangesTicket:Gn,canOpenIdeForTicket:ln,onOpenIdeTicket:Rn,onStopTicket:zn,onStopBuildTicket:Bn,onStopBuildChainTicket:fr,onResumeBuildTicket:Vn,onOpenBundleChanges:Un,onOpenBundleTests:mt?Wn:void 0,onOpenBundleIde:Hn,onFollowUpTicket:qn,bundleActionState:Ne,onBuildBundle:rr,onReviewBundle:ir,onUndoBundleReview:ar,onRunBundle:sr,onStopBundle:cr,onParkBundleWrapper:On,onUnparkBundleWrapper:kn,onOpenTicketDetails:_t,onOpenBundleDetails:(e,t)=>{$n(e,t)},onRequestBundleRefresh:e=>{er(`bundleRefresh`,()=>Zn(e))},onRequestTicketRefresh:S,className:`min-w-[272px] max-w-[272px] flex-[0.98] bg-card/65`,headerAccessory:(0,Z.jsxs)(U,{type:`button`,variant:`destructive`,size:`xs`,className:`gap-1.5`,disabled:wt.length===0||ce,onClick:()=>H(!0),children:[(0,Z.jsx)(Ld,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:`Empty`})]})})]})})]})]}),(0,Z.jsxs)(_w,{zIndex:5,dropAnimation:re?null:void 0,children:[k&&(0,Z.jsx)(ZW,{ticket:k,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,overlay:!0,showModelSelector:k.tool===`opencode`&&B.length>0,availableModels:B,runDisabled:nX(k,ot,tt)!==void 0,runDisabledReason:nX(k,ot,tt),onDependencyStart:Zt,onDeleteDependency:Qt,onRegisterOverlayNode:P,onCreateBundle:xn,onDeleteBundle:An,onRefreshBundles:C,onUpdate:Mn,onDelete:()=>Pn(k.id),onUndo:()=>Fn(k.id),undoInProgress:ue===k.state&&(k.state===`build`||k.state===`review`),onRetry:()=>In(k.id),onAdvance:()=>ur(k.id),onPark:()=>En(k.id),onUnpark:()=>Dn(k.id),onBuildChain:()=>dr(k.id),onRun:k.worktree_bundle_id===null&&sd(k)&&k.has_run_config?()=>Ln(k.id):void 0,onOpenIde:k.worktree_bundle_id===null&&ln(k)?()=>Rn(k.id):void 0,onStop:k.worktree_bundle_id===null?()=>zn(k.id):void 0,onStopBuild:()=>Bn(k.id),onStopBuildChain:()=>fr(k.id),onResumeBuild:()=>Vn(k.id),onFollowUp:e=>qn(k.id,e),onRequestTicketRefresh:S}),!k&&j&&(0,Z.jsx)(ST,{group:j,overlay:!0,renderTicket:sn})]}),ct&&(0,Z.jsx)(XJ,{className:`pointer-events-auto fixed left-1/2 top-4 z-20 w-[min(14rem,calc(100vw-2rem))] -translate-x-1/2`})]}),L&&(0,Z.jsx)(BJ,{onSubmit:bn,bundles:m,projectId:e,projectBranchState:n,tool:i,showModelSelector:Ve,availableModels:B,availableSkills:te,initialModel:Ve?nn.model:``,initialVariant:Ve&&nn.model?nn.variant:``,initialSkills:Ve?nn.skills:[],onCreateBundle:xn,onDeleteBundle:An,onRefreshBundles:C,onClose:()=>R(!1)}),ee&&e&&(0,Z.jsx)(Bd,{bundles:m,selectedBundleId:tn.composer.worktreeBundleId||null,onSelectBundle:t=>{pn(e,e=>({...e,composer:{...e.composer,worktreeBundleId:t??``}}))},onCreateBundle:xn,onDeleteBundle:An,onClose:()=>z(!1)}),se&&(0,Z.jsx)(eG,{ticketCount:wt.length,isDeleting:ce,onCancel:()=>H(!1),onConfirm:()=>{pr()}}),K&&(0,Z.jsx)(XW,{ticket:K,allTickets:u,dependencies:f,bundles:m,projectMemoryEnabled:!!t?.memory_enabled,projectBranchState:n,onClose:()=>{let e=K.id;fe(null),q(null),d(t=>t.map(t=>t.id===e?lY(t):t))},showModelSelector:He,availableModels:B,availableSkills:te,runDisabled:nX(K,ot,tt)!==void 0,runDisabledReason:nX(K,ot,tt),onDeleteDependency:Qt,onCreateBundle:xn,onDeleteBundle:An,onRefreshBundles:C,onUpdate:Mn,onAdvance:()=>ur(K.id),onBuildChain:()=>dr(K.id),onRun:sd(K)&&K.has_run_config?()=>Ln(K.id):void 0,onOpenIde:ln(K)?()=>Rn(K.id):void 0,onStop:()=>zn(K.id),onStopBuild:()=>Bn(K.id),onStopBuildChain:()=>fr(K.id),onResumeBuild:()=>Vn(K.id),onFollowUp:e=>qn(K.id,e),onProjectMemorySuggestionsChanged:()=>{Fe(e=>e+1)},onRequestTicketRefresh:e=>{gt(e)}}),Se&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(OY,{scope:`ticket`,ticketId:Se.ticketId,projectId:Se.projectId,testCommands:pt,onClose:()=>Ce(null)})}),Ee&&(0,Z.jsx)(TJ,{ticketId:Ee.ticketId,projectId:Ee.projectId,reviewCommentsBundleId:Ee.bundleId,title:Ee.title,onSubmitReviewPrompt:e=>lr(Ee.bundleId,e),canSubmitReviewPrompt:!u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),reviewSubmitDisabledReason:u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`)?`Wait for all bundle tickets to finish building before sending a follow-up prompt.`:void 0,canAddReviewComments:!u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),canModifyChanges:!u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`),changesDisabledReason:u.some(e=>e.worktree_bundle_id===Ee.bundleId&&e.agent_status===`running`)?`Wait for all bundle tickets to finish building before modifying changes.`:void 0,onClose:()=>{let{bundleId:e}=Ee;De(null),Zn(e)},onTicketUpdate:Mn,onRequestTicketRefresh:S}),we&&(0,Z.jsx)(TJ,{ticketId:we.ticketId,projectId:we.projectId,title:we.title,onClose:()=>{let{ticketId:e}=we;Te(null),gt(e)},onTicketUpdate:Mn,onRequestTicketRefresh:e=>{gt(e)}}),Oe&&e&&t&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(OY,{scope:`project`,projectId:e,targetKind:`bundle`,targetBundleId:Oe,testCommands:pt,onClose:()=>ke(null)})}),me&&xt&&(0,Z.jsx)(bG,{details:xt,activeColumn:_e,isLoading:Ae||Ne.bundleRefresh,actionState:Ne,canOpenIde:dn(xt),projectMemoryEnabled:!!t?.memory_enabled,memorySuggestionsRefreshKey:Pe,runDisabled:st(xt.bundle.id),showModelSelector:Ue,availableModels:B,availableSkills:te,onClose:()=>{let e=xt.bundle.id;he(null),ye(null),xe(null),je(!1),J(VY()),d(t=>t.map(t=>t.worktree_bundle_id===e&&t.id!==G?lY(t):t))},onOpenTicketDetails:_t,onUpdateTicket:Mn,onOpenIde:()=>{let e=xt.tickets.find(e=>e.id===xt.target_ticket_id)??xt.tickets.find(e=>e.has_worktree);e&&Rn(e.id)},onOpenTests:mt?()=>{Wn(xt.bundle.id)}:void 0,onRefresh:e=>{er(`bundleRefresh`,()=>Zn(e))},onBuildBundle:rr,onStopBuildTicket:tr,onResumeBuildTicket:nr,onReviewBundle:ir,onUndoBundleReview:ar,onRunBundle:sr,onStopBundle:cr,onFollowUpBundle:lr})]})},sX=({className:e})=>(0,Z.jsx)(dc,{"aria-hidden":`true`,className:e}),cX=({className:e})=>(0,Z.jsx)(fc,{"aria-hidden":`true`,className:e}),lX=({state:e,className:t})=>e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-activity-indicator":`true`,"data-state":e,"data-testid":`workspace-activity-indicator`,className:W(`h-2 w-2 flex-shrink-0 rounded-full`,e===`running`?`animate-pulse bg-amber-300`:e===`interrupted`?`bg-amber-400/80 ring-1 ring-amber-400/30`:e===`error`?`bg-rose-400/90 ring-1 ring-rose-400/30`:`bg-emerald-400/80 ring-1 ring-emerald-400/30`,t)}):null,uX=4,dX=5e3,fX=e=>e.replace(/^[ab]\//,``),pX=e=>{let t=`oldPath`in e&&typeof e.oldPath==`string`?fX(e.oldPath):``,n=`newPath`in e&&typeof e.newPath==`string`?fX(e.newPath):``;return[...new Set([n,t].filter(e=>e&&e!==`/dev/null`))]},mX=e=>{let[t,n]=pX(e);return!t&&!n?`Unknown file`:t&&n&&t!==n?`${n} -> ${t}`:t??n??`Unknown file`},hX=e=>{let t=RK((()=>{let[t,n]=pX(e);return t??n??null})());if(!t)return null;try{return rb(e.hunks,{highlight:!0,refractor:Rq.default,language:t,enhancers:[tb(e.hunks)]})}catch{return null}},gX=(e,t)=>e instanceof Error?e.message:t,_X=(e,t)=>{if(!t)return e;let n=mX(t);return[t,...e.filter(e=>mX(e)!==n)]},vX=e=>[...e].sort((e,t)=>{if(e.filePath!==t.filePath)return e.filePath.localeCompare(t.filePath);let n=e.newLineNumber??e.oldLineNumber??2**53-1,r=t.newLineNumber??t.oldLineNumber??2**53-1;return n===r?e.changeKey.localeCompare(t.changeKey):n-r}),yX=({diffResponse:e,gitStatus:t})=>{let n=new Map;for(let t of e?.files??[])n.set(t.path,t);return t?t.files.map(e=>{let t=n.get(e.path)??(e.original_path?n.get(e.original_path):void 0);return{path:e.path,originalPath:e.original_path,status:e.status,staged:e.staged,unstaged:e.unstaged,conflicted:e.conflicted,additions:t?.additions??0,deletions:t?.deletions??0}}):(e?.files??[]).map(e=>({path:e.path,originalPath:null,status:null,staged:!1,unstaged:!1,conflicted:!1,additions:e.additions,deletions:e.deletions}))},bX=e=>{let t=e.split(/[\\/]/);return t[t.length-1]||e},xX={modified:`border-amber-500/40 bg-amber-500/10 text-amber-200`,added:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`,deleted:`border-rose-500/40 bg-rose-500/10 text-rose-200`,renamed:`border-sky-500/40 bg-sky-500/10 text-sky-200`,untracked:`border-violet-500/40 bg-violet-500/10 text-violet-200`,typechanged:`border-slate-500/40 bg-slate-500/10 text-slate-200`},SX={modified:`Modified`,added:`Added`,deleted:`Deleted`,renamed:`Renamed`,untracked:`Untracked`,typechanged:`Type changed`},CX=({selectedDiffPath:e,sidebarFiles:t,diffStats:n,triggerMode:r=`full`,onSelectDiffPath:i})=>{let[a,o]=(0,X.useState)(!1),s=t.find(t=>t.path===e)??null,c=r===`compact`?e===`all`?`Diff`:s?bX(s.path):`File`:e===`all`?`All changes`:s?bX(s.path):e;return(0,Z.jsxs)(Bl,{open:a,onOpenChange:o,children:[(0,Z.jsx)(Vl,{asChild:!0,children:(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`outline`,className:W(`max-w-full gap-2`,r===`full`?`min-w-0 max-w-[18rem]`:`min-w-0 px-2.5`),"aria-label":`Open changed files`,title:e===`all`?void 0:s?.path??e,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:c}),r===`full`&&(0,Z.jsxs)(J,{variant:`outline`,className:`shrink-0 text-[10px] uppercase tracking-wide`,children:[t.length,` file`,t.length===1?``:`s`]}),(0,Z.jsx)(Te,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Z.jsxs)(Hl,{align:`start`,className:`z-[90] w-[28rem] max-w-[calc(100vw-2rem)] p-0`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Changed files`})}),(0,Z.jsx)(`div`,{className:`max-h-[min(28rem,calc(100vh-10rem))] overflow-y-auto p-3`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{i(`all`),o(!1)},className:W(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,SK(e===`all`),`justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`All changes`}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground transition-colors group-hover:text-foreground/70`,children:`Review the full workspace diff.`})]}),n&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground transition-colors group-hover:text-foreground/70`,children:[n.files_changed,` file`,n.files_changed===1?``:`s`]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,n.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,n.deletions]})]})]}),t.map(t=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{i(t.path),o(!1)},className:W(`flex w-full cursor-pointer items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-colors`,SK(e===t.path)),children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:bX(t.path)}),(0,Z.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.path})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 text-[11px]`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-emerald-400`,children:[`+`,t.additions]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums text-rose-400`,children:[`-`,t.deletions]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[t.status&&(0,Z.jsx)(J,{variant:`outline`,className:xX[t.status],children:SX[t.status]}),t.staged&&(0,Z.jsx)(J,{variant:`outline`,children:`Staged`}),t.unstaged&&(0,Z.jsx)(J,{variant:`outline`,children:`Unstaged`}),t.conflicted&&(0,Z.jsx)(J,{variant:`destructive`,children:`Conflicted`}),t.originalPath&&(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-muted-foreground transition-colors group-hover:text-foreground/70`,children:t.status===`renamed`?`from ${t.originalPath}`:t.originalPath})]})]})},`${t.path}:${t.originalPath??``}`))]})})]})]})},wX=(0,X.memo)(({projectId:e,chatSessionId:t=null,canSubmitReviewPrompt:n,reviewSubmitDisabledReason:r,onSubmitReviewPrompt:i,state:a,onStateChange:o,isResizing:s=!1,onClose:c,desktopWidth:l,panelElementRef:u})=>{let[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(new Map),[S,C]=(0,X.useState)(!1),w=(0,X.useRef)(0),T=(0,X.useRef)(0),E=(0,X.useRef)(null),D=(0,X.useRef)(null),O=a.selectedDiffPath,k=a.activeReviewTarget,A=a.editingReviewCommentKey,j=k?.commentKey??A??`chat`,M=a.reviewDraftInput,N=(0,X.useMemo)(()=>new Map(a.reviewComments.map(e=>[pb(e.filePath,e.changeKey),e])),[a.reviewComments]),P=(0,X.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await lx(e,t):await Ee(e)},[t,e]),F=(0,X.useCallback)(async()=>{if(!e)throw Error(`Project id is required`);return t?await ux(e,t):await ce(e)},[t,e]);(0,X.useEffect)(()=>{E.current=d},[d]),(0,X.useEffect)(()=>{D.current=p},[p]);let I=(0,X.useCallback)(async()=>{if(!e){T.current+=1,f(null),m(null),g(null),v(!1),y(!1);return}let t=w.current+1,n=T.current+1;w.current=t,T.current=n,v(!0),y(!0);let[r,i]=await Promise.allSettled([P(),F()]);w.current===t&&(r.status===`fulfilled`?(E.current=r.value,f(r.value),g(null)):g(gX(r.reason,`Unable to load the diff right now.`)),i.status===`fulfilled`&&(D.current=i.value,m(i.value)),T.current===n&&v(!1),y(!1))},[P,F,e]),L=(0,X.useCallback)(async(t={})=>{if(!e)return;let{broadcastOnSignatureChange:n=!1}=t,r=w.current+1;w.current=r,y(!0);try{let t=await F();if(w.current!==r)return;let i=D.current?.workspace_signature??null,a=t.workspace_signature??null,o=!E.current||i!==a;if(D.current=t,m(t),!o){T.current+=1,v(!1);return}let s=!E.current,c=T.current+1;T.current=c,s&&v(!0);try{let t=await P();if(w.current!==r)return;E.current=t,f(t),g(null),n&&i!==a&&BK(e)}catch(e){if(w.current!==r)return;E.current||g(gX(e,`Unable to load the diff right now.`))}finally{s&&T.current===c&&v(!1)}}catch{E.current||(T.current+=1,v(!1));return}finally{w.current===r&&y(!1)}},[P,F,e]);(0,X.useEffect)(()=>{I()},[I]),(0,X.useEffect)(()=>{if(e)return VK(t=>{t===e&&L()})},[e,L]),(0,X.useEffect)(()=>{if(!e)return;let t=UK(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})});return()=>{t()}},[e,L]),(0,X.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>{document.visibilityState===`visible`&&L({broadcastOnSignatureChange:!0})},dX);return()=>{window.clearInterval(t)}},[e,L]);let R=(0,X.useMemo)(()=>{let e=typeof d?.diff==`string`?d.diff:``;return e.trim()?Jm(e,{nearbySequences:`zip`}).map(e=>({...e,pathCandidates:pX(e)})):[]},[d]),ee=(0,X.useMemo)(()=>{let e=new Map;for(let t of R)for(let n of t.pathCandidates)e.has(n)||e.set(n,t);return e},[R]),z=(0,X.useMemo)(()=>yX({diffResponse:d,gitStatus:p}),[d,p]);(0,X.useEffect)(()=>{if(O!==`all`&&!(!d&&!p)){if(z.length===0){o(e=>({...e,selectedDiffPath:`all`}));return}z.some(e=>e.path===O)||o(e=>({...e,selectedDiffPath:`all`}))}},[d,p,o,O,z]);let B=O===`all`?null:ee.get(O)??null,V=(0,X.useMemo)(()=>_X(R,B),[R,B]),te=(0,X.useMemo)(()=>O===`all`?R:B?[B]:[],[R,O,B]);(0,X.useEffect)(()=>{x(new Map)},[R]),(0,X.useEffect)(()=>{if(V.length===0)return;let e=!1,t=null,n=0,r=()=>{if(e)return;let i=V.slice(n,n+uX);i.length!==0&&(x(e=>{let t=new Map(e);for(let e of i){let n=mX(e);t.has(n)||t.set(n,hX(e))}return t}),n+=uX,n<V.length&&(t=window.setTimeout(r,0)))};return t=window.setTimeout(r,0),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[V]);let ne=(0,X.useMemo)(()=>{let e=new Map;for(let t of V.slice(0,uX))e.set(mX(t),hX(t));return e},[V]),re=(0,X.useMemo)(()=>te.map(e=>({...e,tokens:b.get(mX(e))??ne.get(mX(e))??null})),[ne,b,te]),ie=(0,X.useMemo)(()=>R.map(e=>({...e,tokens:null})),[R]),ae=(0,X.useMemo)(()=>vX(a.reviewComments),[a.reviewComments]),oe=ae.length,se=n&&!S&&oe>0,H=(0,X.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}))},[o]),le=(0,X.useCallback)(({filePath:e,changeKey:t,commentKey:r})=>{let i=N.get(r);if(i){o(e=>({...e,selectedDiffPath:i.filePath,activeReviewTarget:null,editingReviewCommentKey:r,reviewDraftInput:i.comment}));return}n&&o(n=>({...n,activeReviewTarget:{filePath:e,changeKey:t,commentKey:r},editingReviewCommentKey:null,reviewDraftInput:``}))},[n,o,N]),ue=(0,X.useCallback)(()=>{o(e=>({...e,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``}))},[o]),de=(0,X.useCallback)(e=>{let t=N.has(e.commentKey);if(!n&&!t)return;let r=M.trim();if(!r)return;let i=e.change.type===`insert`?null:`oldLineNumber`in e.change?e.change.oldLineNumber:e.change.lineNumber,a=e.change.type===`delete`?null:`newLineNumber`in e.change?e.change.newLineNumber:e.change.lineNumber;o(t=>{let n=new Map(t.reviewComments.map(e=>[pb(e.filePath,e.changeKey),e]));return n.set(e.commentKey,{scope:`uncommitted`,filePath:e.filePath,changeKey:e.changeKey,changeType:e.change.type,oldLineNumber:i,newLineNumber:a,hunkHeader:e.hunk.content,lineContent:e.change.content,diffSnippet:mb(e.hunk,e.change),comment:r}),{...t,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[...n.values()]}})},[n,o,N,M]),G=(0,X.useCallback)(e=>{let t=N.get(e);t&&o(n=>({...n,selectedDiffPath:t.filePath,activeReviewTarget:null,editingReviewCommentKey:e,reviewDraftInput:t.comment}))},[o,N]),fe=(0,X.useCallback)(e=>{o(t=>({...t,activeReviewTarget:t.activeReviewTarget?.commentKey===e?null:t.activeReviewTarget,editingReviewCommentKey:t.editingReviewCommentKey===e?null:t.editingReviewCommentKey,reviewDraftInput:t.activeReviewTarget?.commentKey===e||t.editingReviewCommentKey===e?``:t.reviewDraftInput,reviewComments:t.reviewComments.filter(t=>pb(t.filePath,t.changeKey)!==e)}))},[o]),K=(0,X.useCallback)(async()=>{if(!se)return;C(!0);let e=Cb({drafts:ae,findings:[],githubComments:[],uncommittedFiles:R});try{await i(e),H(),Q.success(`Changes sent to chat.`,{id:`chat-diff-review-submit-success`})}catch(e){Q.error(gX(e,`Unable to send the changes right now.`),{id:`chat-diff-review-submit-error`})}finally{C(!1)}},[se,H,i,R,ae]),q=(0,X.useCallback)(e=>(0,Z.jsx)(kG,{reviewComments:ae,pendingFixCount:oe,triggerMode:e===`wide`?`full`:`compact`,canSendReview:se,isSubmittingReview:S,reviewSubmitDisabledReason:r??void 0,onClearPendingFixes:H,onSubmitReview:()=>{K()}}),[se,H,K,S,oe,ae,r]),me=c?(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close diff panel`,className:`text-muted-foreground hover:text-foreground`,onClick:c,children:(0,Z.jsx)(pe,{className:`h-4 w-4`})}):null,he=l?{"--chat-changes-panel-width":`${l}px`}:void 0;return(0,Z.jsx)(`aside`,{"data-testid":`chat-changes-panel`,"data-desktop-width":l?String(l):void 0,ref:u,style:he,className:W(`flex h-[26rem] min-h-0 w-full shrink-0 flex-col overflow-hidden border-t border-border/70 bg-background/20 xl:h-full xl:border-l xl:border-t-0`,l?`xl:w-[var(--chat-changes-panel-width)]`:`xl:w-[32rem]`),children:(0,Z.jsx)(xK,{selectedDiffPath:O,sidebarFiles:z,diffResponse:d,isDiffLoading:_,diffError:h,allDiffFiles:ie,renderedFiles:re,viewType:`unified`,onViewTypeChange:()=>{},onRetry:()=>{I()},activeReviewTarget:k,editingReviewCommentKey:A,reviewDraftInstanceKey:j,reviewDraftInput:M,reviewComments:ae,reviewFindings:[],githubComments:[],selectedReviewFindingIds:[],selectedGitHubCommentIds:[],canSelectReviewTarget:n,canEditActiveReviewDraft:n,reviewFindingsError:null,gitHubCommentsError:null,hasStaleReviewFindings:!1,onSelectReviewTarget:le,onToggleReviewFindingSelection:()=>{},onToggleGitHubCommentSelection:()=>{},onReviewDraftInputChange:e=>{o(t=>({...t,reviewDraftInput:e}))},onCancelReviewDraft:ue,onEditReviewDraft:G,onRemoveReviewDraft:fe,onSaveReviewDraft:de,diffThemeClassName:DK,resolveFilePath:mX,normalizeDiffPath:fX,emptyStateTitle:`No uncommitted changes.`,emptyStateDescription:`The current project branch is clean.`,filePickerControl:e=>(0,Z.jsx)(CX,{selectedDiffPath:O,sidebarFiles:z,diffStats:d?.stats??null,triggerMode:e===`wide`?`full`:`compact`,onSelectDiffPath:e=>{o(t=>({...t,selectedDiffPath:e}))}}),reviewSummaryControl:q,extraHeaderControl:me,surfaceVariant:`flat`,showViewTypeToggle:!1,gutterVariant:`compact`,isResizing:s,resizePlaceholderLineThreshold:200})})});wX.displayName=`ChatChangesPanel`;var TX=({projectId:e,messages:t,internalLog:n,pendingAgentTitle:r,streamingResponse:i,isRunning:a,isLoading:o=!1,canShowComposer:s,isExternallyResizing:c=!1,pendingAgentRevealKey:l=null,pendingAgentRevealDelayMs:u=0,composerFocusNonce:d=0,header:f,composerControls:p,composerInlineControls:m,composerTheme:h=`default`,layoutKey:g,scrollLayoutKey:_,followUpPrompt:v,followUpPlaceholder:y,emptyStateText:b=null,renderMessageFooter:x,isSendingFollowUp:S,followUpDisabledReason:C,onFollowUpPromptChange:w,onFollowUpKeyDown:T,onFollowUpSubmit:E})=>(0,Z.jsx)(LN,{projectId:e,messages:t,internalLog:n,pendingAgentTitle:r,streamingResponse:i,isRunning:a,isLoading:o,autoScrollBehavior:`sticky`,surfaceVariant:`chat`,canShowComposer:s,header:f,composerControls:p,composerInlineControls:m,composerTheme:h,composerSize:`compact-on-laptop`,showThinkingPlacement:`header`,pinComposerToBottom:!0,isExternallyResizing:c,pendingAgentRevealKey:l,pendingAgentRevealDelayMs:u,composerFocusNonce:d,layoutKey:g,scrollLayoutKey:_,followUpPrompt:v,followUpPlaceholder:y,emptyStateText:b,autoFocusComposer:!0,renderMessageFooter:x,isSendingFollowUp:S,followUpDisabledReason:C,onFollowUpPromptChange:w,onFollowUpKeyDown:T,onFollowUpSubmit:E}),EX={default:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-200`,muted:`h-5 rounded-md border-amber-500/40 bg-amber-500/10 px-1.5 text-[10px] uppercase tracking-[0.16em] text-amber-100`},DX=({tone:e=`default`,className:t,children:n,...r})=>(0,Z.jsx)(J,{variant:`outline`,className:W(EX[e],t),...r,children:n}),OX=()=>({kind:`decision`,title:``,scope:``,content:``,rationale:``,implications:``,stages:``,priority:`normal`}),kX=e=>e.kind===`convention`?{kind:`convention`,title:e.title,scope:e.scope??``,content:e.instruction,rationale:e.rationale??``,implications:``,stages:e.stages.join(`
140
140
  `),priority:e.priority}:{kind:`decision`,title:e.title,scope:e.scope??``,content:e.decision,rationale:e.rationale??``,implications:e.implications.join(`
141
141
  `),stages:``,priority:`normal`},AX=e=>e.split(`
142
- `).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),jX=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},MX=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=a?`Save as new decision`:`Accept`,s=e.kind===`decision`?e.decision:e.instruction;return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsxs)(DX,{children:[`Suggested `,e.kind]}),a?(0,Z.jsx)(DX,{tone:`muted`,children:`Possible duplicate`}):null]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:`Review`}),(0,Z.jsx)(U,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:`Dismiss`})]})]})})},NX=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?`Save as new decision`:`Accept as ${e.kind}`;return(0,Z.jsx)(_l,{open:t,onOpenChange:a,children:(0,Z.jsxs)(xl,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Sl,{children:[(0,Z.jsx)(wl,{children:e.title}),(0,Z.jsx)(Tl,{children:`Review this suggestion before saving it into project memory.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:`Possible duplicate`}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}):null,n?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:`Suggestion title`}),(0,Z.jsx)(`input`,{"aria-label":`Suggestion title`,value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:`Scope`}),(0,Z.jsx)(`input`,{"aria-label":`Scope`,value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:i.kind===`decision`?`Decision`:`Instruction`}),(0,Z.jsx)(`textarea`,{"aria-label":i.kind===`decision`?`Decision`:`Instruction`,value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`min-h-32 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:`Rationale`}),(0,Z.jsx)(`textarea`,{"aria-label":`Rationale`,value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:`Implications (one per line)`}),(0,Z.jsx)(`textarea`,{"aria-label":`Implications`,value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Stages (comma or newline separated)`}),(0,Z.jsx)(`textarea`,{"aria-label":`Stages`,value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Priority`}),(0,Z.jsxs)(`select`,{"aria-label":`Priority`,value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,Z.jsx)(`option`,{value:`low`,children:`Low`}),(0,Z.jsx)(`option`,{value:`normal`,children:`Normal`}),(0,Z.jsx)(`option`,{value:`high`,children:`High`})]})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e.kind===`decision`?`Decision`:`Instruction`}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-foreground`,children:e.kind===`decision`?e.decision:e.instruction})]}),e.rationale?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Rationale`}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-muted-foreground`,children:e.rationale})]}):null,e.kind===`decision`&&e.implications.length>0?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Implications`}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:e.implications.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}):null,e.kind===`convention`?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Stages`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:e.stages.join(`, `)||`None specified`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Priority`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:e.priority})]})]}):null]})]}),(0,Z.jsxs)(Cl,{className:`flex flex-wrap gap-2 sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,Z.jsx)(U,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:`Cancel edits`}):(0,Z.jsx)(U,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:`Edit`}),(0,Z.jsx)(U,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(e),children:`Dismiss`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d?(0,Z.jsx)(U,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:`Update existing decision`}):null,(0,Z.jsx)(U,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})]})]})})},PX=({projectId:e,suggestions:t,title:n,description:r,emptyState:i=null,onSuggestionsChanged:a})=>{let[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(OX),[f,p]=(0,X.useState)(null);(0,X.useEffect)(()=>{l(e=>e&&!t.some(t=>t.id===e)?null:e),s(e=>e&&!t.some(t=>t.id===e)?null:e)},[t]);let m=o?t.find(e=>e.id===o)??null:null,h=()=>{l(null),d(OX())},g=e=>{s(e.id),l(e.id),d(kX(e))},_=e=>{c&&c!==e.id&&h(),s(e.id)},v=e=>{e||(s(null),c&&h())},y=async(t,n)=>{let r=c===t.id?u:kX(t),i=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:AX(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:jX(r.stages),priority:r.priority};p(t.id);try{if(n){if(t.kind!==`decision`)throw Error(`Only decision suggestions can update an existing memory.`);let n=t.duplicate_match?.decision;if(!n)throw Error(`No existing decision is available for this suggestion.`);await ke(e,t.id,n.id,i)}else await S(e,t.id,i);h(),s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:`Unable to save the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{p(null)}},b=async t=>{p(t.id);try{await Pe(e,t.id),c===t.id&&h(),o===t.id&&s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:`Unable to dismiss the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{p(null)}};return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[n||r?(0,Z.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,Z.jsxs)(`div`,{children:[n?(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:n}):null,r?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}):null]})}):null,t.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,Z.jsx)(MX,{suggestion:e,isPending:f===e.id,onReview:_,onAccept:e=>y(e,!1),onDismiss:b},e.id))}):i?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:i}):null,(0,Z.jsx)(NX,{suggestion:m,isOpen:!!m,isEditing:c===m?.id,isPending:f===m?.id,draft:c===m?.id?u:m?kX(m):u,onOpenChange:v,onStartEdit:g,onDraftChange:d,onCancelEdit:h,onAccept:y,onDismiss:b})]})},FX=()=>({selectedDiffPath:`all`,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}),IX=[{key:`today`,label:`Today`},{key:`yesterday`,label:`Yesterday`},{key:`last_7_days`,label:`Last 7 Days`},{key:`older`,label:`Older`}],LX=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},RX=e=>e.activity_at??e.last_user_message_at??e.created_at,zX=(e,t)=>{let n=RX(e),r=RX(t);return n===r?e.created_at===t.created_at?t.id.localeCompare(e.id):t.created_at.localeCompare(e.created_at):r.localeCompare(n)},BX=e=>[...e].sort(zX),VX=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),HX=(e,t=new Date)=>{let n=LX(RX(e));if(!n)return`older`;let r=VX(t),i=new Date(r);i.setDate(i.getDate()-1);let a=new Date(r);return a.setDate(a.getDate()-6),n>=r?`today`:n>=i?`yesterday`:n>=a?`last_7_days`:`older`},UX=(e,t=new Date)=>{let n=new Map;for(let r of BX(e)){let e=HX(r,t);n.set(e,[...n.get(e)??[],r])}return IX.flatMap(e=>{let t=n.get(e.key)??[];return t.length===0?[]:[{key:e.key,label:e.label,sessions:t}]})},WX=e=>{let t={...e};return delete t.messages,t.agent_log=null,t.streaming_response=null,t},GX=1500,KX=`archon.chat-run-config`,qX=`archon.chat-changes-panel-layout`,JX=`archon.chat-session-list-layout`,YX=`archon.chat-draft`,XX=512,ZX=360,QX=.6,$X=6,eZ=`.`,tZ=`/`,nZ=`Slash`,rZ=`NumpadDivide`,iZ=600,aZ=(e,t)=>{let n=Number.isFinite(e)?Math.round(e):XX;if(!Number.isFinite(t))return Math.max(ZX,n);let r=Math.max(ZX,Math.round(t*QX));return Math.max(ZX,Math.min(r,n))},oZ=e=>e===`claude`?`Claude`:`OpenCode`,sZ=({availableModelsById:e,model:t})=>t?e.get(t)??t:null,cZ=e=>e===`plan`?`Plan`:`Build`,lZ=e=>e===`plan`?`Ask Archon to scope, sequence, or reason through project work`:`Ask Archon to build, change, or verify something in this project`,uZ=e=>`${e} pending memory suggestion${e===1?``:`s`}`,dZ=e=>e===`plan`?`build`:`plan`,fZ=e=>!e.defaultPrevented&&!e.altKey&&!e.shiftKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&e.key===eZ,pZ=e=>!e.defaultPrevented&&!e.altKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&(e.key===tZ||e.code===nZ||e.code===rZ),mZ=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??navigator.userAgent;return/mac/i.test(e)},hZ=()=>mZ()?`CMD`:`CTRL`,gZ=({modifierLabel:e,keys:t,ariaHidden:n=!1})=>(0,Z.jsxs)(`span`,{"aria-hidden":n,className:`flex items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(vw,{"aria-hidden":n,children:e}),t.map(e=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(vw,{"aria-hidden":n,children:e})]},e))]}),_Z=({label:e,modifierLabel:t,keys:n})=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(gZ,{modifierLabel:t,keys:n,ariaHidden:!0})]}),vZ=({modelLabel:e,tool:t})=>e??oZ(t),yZ=()=>`You`,bZ=e=>{if(!Number.isFinite(e))return`0`;if(e>=1e6){let t=e/1e6,n=t<10?2:1;return`${t.toFixed(n)}M`}return e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`},xZ=({totalTokens:e,contextWindow:t})=>!Number.isFinite(e)||!Number.isFinite(t)||t<=0?null:Math.round(e/t*100),SZ=({tool:e,model:t,availableModels:n,fallbackContextWindow:r})=>e===`opencode`?(n.find(e=>e.id===t)??null)?.context_window??r:r,CZ=({projectId:e,tool:t})=>`${KX}:${e}:${t}`,wZ=({projectId:e,tool:t,chatSessionId:n})=>n?`${YX}:${e}:session:${n}`:`${YX}:${e}:draft:${t}`,TZ=e=>`${qX}:${e}`,EZ=e=>`${JX}:${e}`,DZ=e=>{if(!e)return``;try{return window.localStorage.getItem(e)??``}catch{return``}},OZ=({storageKey:e,value:t})=>{if(e)try{if(t){window.localStorage.setItem(e,t);return}window.localStorage.removeItem(e)}catch{}},kZ=e=>{if(!e)return{isOpen:!0,width:XX};try{let t=window.localStorage.getItem(TZ(e));if(!t)return{isOpen:!0,width:XX};let n=JSON.parse(t),r=typeof n.width==`number`&&Number.isFinite(n.width)?Math.max(ZX,Math.round(n.width)):XX;return{isOpen:n.isOpen!==!1,width:r}}catch{return{isOpen:!0,width:XX}}},AZ=e=>{if(!e)return{isOpen:!0};try{let t=window.localStorage.getItem(EZ(e));return t?{isOpen:JSON.parse(t).isOpen!==!1}:{isOpen:!0}}catch{return{isOpen:!0}}},jZ=({projectId:e,isOpen:t,width:n})=>{if(e)try{window.localStorage.setItem(TZ(e),JSON.stringify({isOpen:t,width:n}))}catch{}},MZ=({projectId:e,isOpen:t})=>{if(e)try{window.localStorage.setItem(EZ(e),JSON.stringify({isOpen:t}))}catch{}},NZ=({projectId:e,tool:t})=>{if(!e||t!==`opencode`)return null;try{let n=window.localStorage.getItem(CZ({projectId:e,tool:t}));if(!n)return null;let r=JSON.parse(n),i=(typeof r.model==`string`?r.model.trim():``)||null,a=r.mode===`plan`||r.mode===`build`?r.mode:null;return!i&&!a?null:{model:i,variant:i&&typeof r.variant==`string`&&r.variant.trim()||null,mode:a}}catch{return null}},PZ=({projectId:e,tool:t,model:n,variant:r,mode:i})=>{if(!(!e||t!==`opencode`||!n&&!i))try{window.localStorage.setItem(CZ({projectId:e,tool:t}),JSON.stringify({model:n,variant:n?r:null,mode:i}))}catch{}},FZ=({projectId:e,tool:t})=>NZ({projectId:e,tool:t})?.mode??`plan`,IZ=({activeProjectId:e,helperModel:t,helperVariant:n,activeTool:r,availableModels:i})=>{let a=NZ({projectId:e,tool:r}),o=new Set(i.map(e=>e.id)),s=e=>e?o.size===0?!0:o.has(e):!1,c=t??``,l=a?.model??``,u=s(l)?l:s(c)?c:``,d=u===l?a?.variant??null:u&&u===c?n??null:null,f=i.find(e=>e.id===u)??null;return{model:u,variant:f?f.variants.includes(d??``)?d??``:``:u?d??``:``,mode:a?.mode??`plan`}},LZ=e=>e&&e.replace(/\s+/g,` `).trim()||null,RZ=e=>{let t=LZ(e.first_user_message_preview);if(t)return t;let n=e.messages?.find(e=>e.role===`user`)?.content;return LZ(n)},zZ=({chatSessionId:e,instruction:t,createdAt:n})=>({id:`optimistic:${e}:${n}`,chat_session_id:e,role:`user`,kind:`prompt`,content:t,created_at:n}),BZ=({session:e,instruction:t,createdAt:n})=>({...e,messages:[...e.messages??[],zZ({chatSessionId:e.id,instruction:t,createdAt:n})],activity_at:n,last_user_message_at:n,updated_at:n}),VZ=e=>!!(e.first_user_message_preview||e.last_user_message_at||e.messages?.some(e=>e.role===`user`)),HZ=({activeProject:e,activeProjectBranchState:t,session:n})=>!e||n.target_available===!1?!1:n.target_kind===`bundle`?e.active_target_kind===`bundle`&&!!n.target_bundle_id&&e.active_target_bundle_id===n.target_bundle_id:e.active_target_kind===`bundle`?!1:t?!n.target_branch_snapshot||t?.status!==`ready`||!t.branch?!1:t.branch===n.target_branch_snapshot:!0,UZ=e=>e.target_kind===`bundle`?e.target_label_snapshot||`Bundle target`:null,WZ=e=>e.target_kind===`bundle`?UZ(e)||`Bundle target`:e.target_branch_snapshot?`Repo root (${e.target_branch_snapshot})`:`Repo root`,GZ=({activeProject:e,activeProjectBranchState:t})=>e?e.active_target_kind===`bundle`?`selected bundle target`:t?.branch?`Repo root (${t.branch})`:`Repo root`:`current target`,KZ=({title:e,isDeleting:t,onConfirm:n,onCancel:r})=>(0,Z.jsxs)(Ce,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete chat session`}),(0,Z.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`This permanently removes the transcript history for this chat session.`}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,variant:`ghost`,onClick:r,disabled:t,children:`Cancel`}),(0,Z.jsx)(U,{type:`button`,variant:`destructive`,onClick:n,disabled:t,children:t?`Deleting...`:`Delete`})]})]}),qZ=({activeProject:e,activeSessionId:t,chatModeShortcutModifierLabel:n,confirmingDeleteSessionId:r,deletingSessionId:i,finishedBackgroundSessionIds:a,isCreatingSession:o,isDraftOpen:s,isLoadingSessions:c,isOpen:l,isSendingPrompt:u,sessionGroups:d,sessions:f,onConfirmDeleteSession:p,onDraftOpen:m,onSessionSelect:h,onToggleOpen:g})=>(0,Z.jsx)(`aside`,{"data-testid":`chat-sessions-sidebar`,"data-state":l?`expanded`:`collapsed`,"aria-label":`Chat sessions sidebar`,className:W(`relative z-20 flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background/40 transition-[width] duration-200 ease-out motion-reduce:transition-none`,l?`w-72`:`w-16`),children:l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-start gap-2 border-b border-border/70 px-4 py-3`,children:[(0,Z.jsxs)(U,{type:`button`,size:`sm`,className:`gap-2`,onClick:m,disabled:o||u,children:[(0,Z.jsx)(Td,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`New session`}),(0,Z.jsx)(gZ,{modifierLabel:n,keys:[tZ],ariaHidden:!0})]}),(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Collapse sessions panel`,"aria-expanded":l,className:`ml-auto`,onClick:g,children:(0,Z.jsx)(sX,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:c&&f.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground`,children:`Loading chat sessions...`}):f.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:`No chat sessions yet.`}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:d.map(n=>(0,Z.jsxs)(`section`,{"aria-label":n.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`div`,{className:`px-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/80`,children:n.label}),n.sessions.map(n=>{let o=!s&&n.id===t,c=RZ(n),l=UZ(n),u=n.agent_status===`running`?`Wait for the current chat response to finish before deleting this session.`:null,d=r===n.id||i===n.id,f=!!u||i===n.id,m=n.agent_status===`running`?`running`:n.agent_status===`stopped`?`interrupted`:!o&&a.has(n.id)?`finished`:null,g=m===`interrupted`?null:m;return(0,Z.jsxs)(`div`,{className:W(`group relative rounded-xl border transition-colors`,o?`border-sky-400/40 bg-sky-500/10 text-foreground ring-1 ring-sky-400/40`:`border-border/50 bg-card/35 text-muted-foreground hover:border-border/80 hover:bg-card/60 hover:text-foreground`),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":[n.title,cZ(n.mode),oZ(n.tool),e?.memory_enabled&&n.pending_memory_suggestion_count>0?uZ(n.pending_memory_suggestion_count):null,m===`running`?`Running`:m===`interrupted`?`Interrupted`:m===`finished`?`Finished`:null].filter(Boolean).join(` `),className:`flex w-full min-w-0 cursor-pointer items-start gap-2 rounded-xl px-3 py-2 pr-11 text-left transition-colors focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,onClick:()=>{h(n)},children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l?(0,Z.jsx)(`div`,{className:`mb-1 truncate text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75`,children:l}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:n.title}),e?.memory_enabled&&n.pending_memory_suggestion_count>0?(0,Z.jsx)(DX,{tone:o?`default`:`muted`,className:`shrink-0`,"aria-label":uZ(n.pending_memory_suggestion_count),title:uZ(n.pending_memory_suggestion_count),children:n.pending_memory_suggestion_count}):null]}),c?(0,Z.jsx)(`div`,{className:W(`mt-0.5 line-clamp-1 text-xs leading-4`,o?`text-foreground/70`:`text-muted-foreground`),children:c}):null,n.target_available===!1?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-1 text-[11px] leading-4 text-amber-200/90`,children:n.target_unavailable_reason??`Target unavailable`}):null]}),(0,Z.jsx)(lX,{state:g,className:`mt-1`})]})}),(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Delete chat session`,className:W(`absolute top-2 right-2 h-7 w-7 shrink-0 rounded-md border border-transparent text-muted-foreground transition-all duration-150 hover:border-border/70 hover:bg-card/80 hover:text-foreground focus-visible:border-border/70 focus-visible:bg-card/80 focus-visible:text-foreground`,`opacity-100 sm:opacity-0 sm:pointer-events-none sm:group-hover:pointer-events-auto sm:group-focus-within:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,f&&`sm:disabled:opacity-0 sm:group-hover:disabled:opacity-50 sm:group-focus-within:disabled:opacity-50`,(o||d)&&`sm:pointer-events-auto sm:opacity-100 sm:disabled:opacity-50`,u&&`cursor-not-allowed text-muted-foreground/50 hover:border-transparent hover:bg-transparent hover:text-muted-foreground/50 focus-visible:border-transparent focus-visible:bg-transparent focus-visible:text-muted-foreground/50`),title:u??`Delete ${n.title}`,disabled:f,onClick:e=>{e.stopPropagation(),p(n.id)},children:(0,Z.jsx)(Ld,{className:`h-4 w-4`})})]},n.id)})]},n.key))})})]}):(0,Z.jsxs)(`div`,{"data-testid":`chat-sessions-rail`,className:`flex h-full w-full flex-col items-center gap-2 bg-background/80 py-3`,children:[(0,Z.jsx)(cu,{content:(0,Z.jsx)(_Z,{label:`Start new session`,modifierLabel:n,keys:[tZ]}),side:`right`,children:(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,"aria-label":`New session`,className:`h-9 w-9`,onClick:m,disabled:o||u,children:(0,Z.jsx)(Td,{className:`h-4 w-4`})})}),(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Open sessions panel`,"aria-expanded":l,className:`h-9 w-9`,onClick:g,children:(0,Z.jsx)(cX,{className:`h-4 w-4`})})]})}),JZ=({proposals:e,isApplying:t,onApply:n})=>e.status===`applied`?(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:`Tickets created`}),(0,Z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Created `,e.created_tickets.length,` ticket`,e.created_tickets.length===1?``:`s`,` from this proposal.`]}),e.created_tickets.length>0?(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1 text-foreground`,children:e.created_tickets.map(e=>(0,Z.jsx)(`li`,{children:e.title},e.ticket_id))}):null]}):(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:`Proposed tickets`}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:`Review these tickets before adding them to the board.`}),(0,Z.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e.tickets.map(e=>(0,Z.jsxs)(`li`,{className:`rounded border border-border/60 bg-background/80 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-muted-foreground`,children:e.description})]},e.key))}),e.dependencies.length>0?(0,Z.jsxs)(`div`,{className:`mt-3 text-muted-foreground`,children:[`Dependencies: `,e.dependencies.map(e=>`${e.blocker_key} -> ${e.dependent_key}`).join(`, `)]}):null,(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(U,{type:`button`,size:`sm`,onClick:n,disabled:t,children:t?`Creating tickets...`:`Create tickets`})})]}),YZ=({activeProjectId:e,activeProject:t,activeProjectBranchState:n=null,activeTool:r,onRestoreSessionTarget:i,onReviewCapabilityChange:a,isExternallyResizing:o=!1,showChangesPanel:s=!0})=>{let[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(()=>FZ({projectId:e,tool:r})),[b,x]=(0,X.useState)({}),[S,C]=(0,X.useState)([]),[w,T]=(0,X.useState)([]),[E,D]=(0,X.useState)(``),[O,k]=(0,X.useState)(``),[A,j]=(0,X.useState)([]),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),[I,L]=(0,X.useState)(!1),[R,ee]=(0,X.useState)(!1),[z,B]=(0,X.useState)(!1),[V,te]=(0,X.useState)(null),[ne,re]=(0,X.useState)(null),[ae,oe]=(0,X.useState)(null),[se,H]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(!1),[ue,de]=(0,X.useState)(null),[G,fe]=(0,X.useState)([]),[K,pe]=(0,X.useState)(!1),[me,he]=(0,X.useState)(!1),[_e,ve]=(0,X.useState)(0),[ye,be]=(0,X.useState)(FX),[xe,Se]=(0,X.useState)(()=>AZ(e).isOpen),[we,Te]=(0,X.useState)(()=>kZ(e).isOpen),[Ee,De]=(0,X.useState)(!1),[Oe,ke]=(0,X.useState)(!1),[Ae,je]=(0,X.useState)(()=>kZ(e).width),[Me,Ne]=(0,X.useState)(0),[J,Pe]=(0,X.useState)(null),[Fe,Ie]=(0,X.useState)(()=>new Set),Le=(0,X.useRef)({model:``,variant:``,skills:[],showModelSelector:!1}),Re=(0,X.useRef)(!1),ze=(0,X.useRef)(null),Be=(0,X.useRef)(null),Ve=(0,X.useRef)(null),He=(0,X.useRef)(null),Ue=(0,X.useRef)(null),We=(0,X.useRef)(null),Ge=(0,X.useRef)(null),Ke=(0,X.useRef)(!1),Y=(0,X.useRef)(!1),qe=(0,X.useRef)(0),Je=(0,X.useRef)(XX),Ye=(0,X.useRef)(XX),Xe=(0,X.useRef)(!1),Ze=(0,X.useRef)(0),Qe=(0,X.useRef)({id:null,status:null}),$e=(0,X.useRef)(new Map),et=(0,X.useRef)({}),tt=(0,X.useRef)(new Set),nt=(0,X.useRef)(!1),rt=e?wZ({projectId:e,tool:g?r:f?.tool??r,chatSessionId:g?null:u}):null,it=rt?b[rt]??``:``,at=g?r:f?.tool??r;(0,X.useEffect)(()=>{Re.current=g},[g]),(0,X.useEffect)(()=>{et.current=b},[b]),(0,X.useEffect)(()=>{if(!rt||tt.current.has(rt))return;tt.current.add(rt);let e=DZ(rt);e&&x(t=>Object.prototype.hasOwnProperty.call(t,rt)?t:{...t,[rt]:e})},[rt]),(0,X.useEffect)(()=>{!rt||!Object.prototype.hasOwnProperty.call(b,rt)||OZ({storageKey:rt,value:b[rt]??``})},[rt,b]),(0,X.useEffect)(()=>{ze.current=u},[u]),(0,X.useEffect)(()=>{if(!nt.current){nt.current=!0;return}let t=kZ(e),n=AZ(e);Re.current=!1,Xe.current=!1,tt.current=new Set,d(null),p(null),_(!1),x({}),te(null),re(null),oe(null),Pe(null),fe([]),he(!1),F(!1),be(FX()),Ie(new Set),$e.current=new Map,Ye.current=t.width,Se(n.isOpen),je(t.width),Te(t.isOpen)},[e]),(0,X.useEffect)(()=>{Ee||(Ye.current=Ae,He.current&&(He.current.style.setProperty(`--chat-changes-panel-width`,`${Ae}px`),He.current.setAttribute(`data-desktop-width`,String(Ae))))},[Ae,Ee]),(0,X.useEffect)(()=>{if(!s||!Be.current)return;let e=Be.current.getBoundingClientRect().width;if(e<=0)return;let t=aZ(Ae,e);t!==Ae&&(Ye.current=t,je(t))},[Ae,s]),(0,X.useEffect)(()=>{MZ({projectId:e,isOpen:xe})},[e,xe]),(0,X.useEffect)(()=>{s&&jZ({projectId:e,isOpen:we,width:Ae})},[e,Ae,we,s]),(0,X.useEffect)(()=>{he(!1)},[u,g]);let ot=(0,X.useCallback)(e=>{let t=WX(e);l(e=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return BX([...e,t]);let r=[...e];return r[n]=t,BX(r)})},[]),st=(0,X.useCallback)(t=>{let n=ze.current,i=e?wZ({projectId:e,tool:r,chatSessionId:t}):null;x(e=>{if(!i||!Object.prototype.hasOwnProperty.call(e,i))return e;let t={...e};return delete t[i],t}),OZ({storageKey:i,value:``}),l(e=>{let r=e.filter(e=>e.id!==t);if(n===t){let e=r[0]??null;d(e?.id??null),p(null),_(e===null),fe([]),pe(!1),he(!1)}return r}),Ie(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n}),Pe(e=>e?.sessionId===t?null:e),te(e=>e===t?null:e),re(e=>e===t?null:e),oe(e=>e===t?null:e)},[e,r]),ct=(0,X.useCallback)((e,t)=>{e&&x(n=>n[e]===t?n:{...n,[e]:t})},[]),lt=(0,X.useCallback)(e=>{e&&(x(t=>t[e]===``?t:{...t,[e]:``}),OZ({storageKey:e,value:``}))},[]),ut=(0,X.useCallback)(({fromStorageKey:e,toStorageKey:t})=>{if(!e||!t||e===t)return;let n=Object.prototype.hasOwnProperty.call(et.current,e)?et.current[e]??``:DZ(e);x(r=>{let i={...r,[t]:n};return delete i[e],i}),OZ({storageKey:t,value:n}),OZ({storageKey:e,value:``})},[]),dt=(0,X.useCallback)((e,t)=>{l(n=>{let r=n.findIndex(t=>t.id===e);if(r===-1)return n;let i=n[r];if(i.pending_memory_suggestion_count===t)return n;let a=[...n];return a[r]={...i,pending_memory_suggestion_count:t},a}),p(n=>!n||n.id!==e||n.pending_memory_suggestion_count===t?n:{...n,pending_memory_suggestion_count:t})},[]),ft=(0,X.useCallback)(async r=>{if(!e){l([]),d(null),p(null),_(!1),F(!1);return}N(!0);try{let i=await nx(e,r);if(r?.aborted)return;let a=BX(i.map(WX)),o=a[0]??null,s=t?.active_target_kind===`bundle`||n?.status!==`loading`;l(a),d(e=>Re.current?null:e&&a.some(t=>t.id===e)?e:e?a[0]?.id??null:Xe.current?null:o?s?(Xe.current=!0,HZ({activeProject:t,activeProjectBranchState:n,session:o})?o.id:null):null:(Xe.current=!0,null)),a.length===0&&_(!0)}catch(e){ge(e)||Q.error(e instanceof Error?e.message:`Unable to load chat sessions right now.`)}finally{r?.aborted||(N(!1),F(!0))}},[t,n,e]),pt=(0,X.useCallback)(async(t,n)=>{if(!e){p(null);return}L(!0);try{let r=await ix(e,t,n);if(n?.aborted)return;p(r),ot(r)}catch(e){ge(e)||Q.error(e instanceof Error?e.message:`Unable to load the chat session right now.`)}finally{n?.aborted||L(!1)}},[e,ot]),mt=(0,X.useCallback)(async(n,r)=>{if(!e||!t?.memory_enabled){fe([]),pe(!1);return}pe(!0);try{let t=await q(e,null,r,n);if(r?.aborted)return;fe(t.suggestions),dt(n,t.suggestions.length)}catch(e){ge(e)||Q.error(e instanceof Error?e.message:`Unable to load chat memory suggestions right now.`)}finally{r?.aborted||pe(!1)}},[t?.memory_enabled,e,dt]),ht=(0,X.useCallback)(()=>{fe(e=>{let t=e.length>0?e.slice(0,-1):e;return u&&dt(u,t.length),t}),ve(e=>e+1),ft(),u&&pt(u)},[u,pt,ft,dt]);(0,X.useEffect)(()=>{let e=new AbortController;return ft(e.signal),()=>{e.abort()}},[ft]),(0,X.useEffect)(()=>{if(Re.current||g||u||Xe.current||c.length===0||t?.active_target_kind!==`bundle`&&n?.status===`loading`)return;Xe.current=!0;let e=c[0]??null;e&&HZ({activeProject:t,activeProjectBranchState:n,session:e})&&d(e.id)},[t,n,u,g,c]),(0,X.useEffect)(()=>{if(at!==`opencode`){C([]),T([]),le(!1);return}let t=new AbortController;return(async()=>{le(!0);try{let[n,r]=await Promise.all([qt(at,t.signal),yw(at,t.signal,e)]);C(n),T(r)}catch(e){ge(e)||(C(e=>e),T(e=>e))}finally{t.signal.aborted||le(!1)}})(),()=>{t.abort()}},[e,at]),(0,X.useEffect)(()=>{if(g||!u){p(null);return}if(f?.id===u)return;p(null);let e=new AbortController;return pt(u,e.signal),()=>{e.abort()}},[f,u,g,pt]),(0,X.useEffect)(()=>{if(!t?.memory_enabled||g||!u){fe([]),pe(!1);return}let e=new AbortController;return mt(u,e.signal),()=>{e.abort()}},[t?.memory_enabled,u,g,mt,_e]),(0,X.useEffect)(()=>{!me||K||G.length>0||he(!1)},[K,me,G.length]),(0,X.useEffect)(()=>{if(!u||f?.agent_status!==`running`)return;let e=new AbortController,t=window.setInterval(()=>{Promise.all([ft(e.signal),pt(u,e.signal)])},GX);return()=>{e.abort(),window.clearInterval(t)}},[f?.agent_status,u,pt,ft]),(0,X.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||(t.id===u&&p(t),VZ(t)&&ot(t))},n=t=>{!t||t.project_id!==e||st(t.id)};return PW.on(`chat-session:created`,t),PW.on(`chat-session:updated`,t),PW.on(`chat-session:deleted`,n),()=>{PW.off(`chat-session:created`,t),PW.off(`chat-session:updated`,t),PW.off(`chat-session:deleted`,n)}},[e,u,st,ot]),(0,X.useEffect)(()=>{g&&y(FZ({projectId:e,tool:r}))},[e,r,g]),(0,X.useEffect)(()=>{if(at!==`opencode`){D(``),k(``),j([]);return}if(g){let n=IZ({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:at,availableModels:S});D(n.model),k(n.variant),j([]);return}D(f?.model??t?.helper_model??``),k(f?.variant??t?.helper_variant??``),j(f?.skills??[])},[e,t?.helper_model,t?.helper_variant,f?.id,f?.model,f?.skills,f?.variant,S,at,g]),(0,X.useEffect)(()=>{let e=S.find(e=>e.id===E)??null;k(t=>e?e.variants.includes(t)?t:``:t)},[S,E]),(0,X.useEffect)(()=>{if(at!==`opencode`||!g||!E||O)return;let n=IZ({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:at,availableModels:S});n.model===E&&n.variant&&k(n.variant)},[e,t?.helper_model,t?.helper_variant,at,S,g,E,O]),(0,X.useEffect)(()=>{if(!V)return;let e=f?.id===V?f:c.find(e=>e.id===V)??null;(!e||e.agent_status!==`running`)&&te(null)},[f,V,c]),(0,X.useEffect)(()=>{let e=Qe.current,n=f?.id??null,r=f?.agent_status??null;e.id===n&&e.status===`running`&&r===`done`&&t?.memory_enabled&&n&&ve(e=>e+1),Qe.current={id:n,status:r}},[t?.memory_enabled,e,f?.agent_status,f?.id,f?.title]),(0,X.useEffect)(()=>{u&&Ie(e=>{if(!e.has(u))return e;let t=new Set(e);return t.delete(u),t})},[u]),(0,X.useEffect)(()=>{J&&J.sessionId!==u&&Pe(null)},[u,J]),(0,X.useEffect)(()=>{let e=$e.current,t=new Map,n=[];for(let r of c){let i=e.get(r.id)??null,a=r.agent_status??null;i===`running`&&a===`done`&&r.id!==u&&n.push(r),t.set(r.id,a)}$e.current=t,Ie(e=>{let t=new Set(e),r=!1,i=new Set(c.map(e=>e.id));for(let e of t)i.has(e)||(t.delete(e),r=!0);for(let e of c){let i=e.agent_status??null,a=n.some(t=>t.id===e.id);if((e.id===u||i!==`done`)&&t.delete(e.id)){r=!0;continue}a&&!t.has(e.id)&&(t.add(e.id),r=!0)}return r?t:e})},[e,u,c]);let gt=(0,X.useMemo)(()=>new Map(S.map(e=>[e.id,e.label])),[S]),_t=(0,X.useMemo)(()=>UX(c),[c]),vt=(0,X.useMemo)(()=>ne?c.find(e=>e.id===ne)??(f?.id===ne?f:null):null,[f,ne,c]);(0,X.useEffect)(()=>{ne&&!vt&&re(null)},[ne,vt]);let yt=(0,X.useMemo)(()=>f?vZ({modelLabel:sZ({availableModelsById:gt,model:f.model}),tool:f.tool}):null,[f,gt]),bt=(0,X.useMemo)(()=>f?(f.messages??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,ticket_proposals:e.ticket_proposals??null,created_at:e.created_at,displayTitle:e.role===`assistant`?yt??oZ(f.tool):yZ()})):[],[f,yt]),xt=f?.id&&f.agent_status===`running`&&J?.sessionId===f.id?J.turnKey:null,St=at===`opencode`&&S.length>0,Ct=at===`opencode`&&!St&&ce;(0,X.useEffect)(()=>{Le.current={model:E,variant:O,skills:A,showModelSelector:St}},[E,A,O,St]);let wt=(0,X.useMemo)(()=>S.find(e=>e.id===E)??null,[S,E]),Tt=g?v:f?.mode??`build`,Et=g?`New chat`:f?.title??`Chat`,Dt=g?r:f?.tool??r,Ot=(0,X.useMemo)(()=>hZ(),[]),kt=St?E||null:f?.model??null,At=sZ({availableModelsById:gt,model:kt}),jt=(0,X.useMemo)(()=>{let e=f?.usage_snapshot_total_tokens??null;if(e===null)return null;let t=SZ({tool:Dt,model:kt,availableModels:S,fallbackContextWindow:f?.usage_snapshot_context_window??null});if(t===null)return null;let n=xZ({totalTokens:e,contextWindow:t});return n===null?null:`${bZ(e)} (${n}%)`},[f?.usage_snapshot_context_window,f?.usage_snapshot_total_tokens,S,kt,Dt]),Mt=g?`draft:${e??`none`}:${r}`:f?.id,Nt=(0,X.useCallback)(()=>{Re.current=!0,_(!0),y(FZ({projectId:e,tool:r})),h(null),d(null),p(null),te(null),Pe(null)},[e,r]),Pt=(0,X.useCallback)((e,t=null)=>{Re.current=!1,_(!1),h(null),d(e),p(t)},[]),Ft=(0,X.useCallback)(async()=>{if(!(!f||!i)){h(f.id);try{await i(f)}catch(e){Q.error(e instanceof Error?e.message:`Unable to restore the chat target right now.`)}finally{h(e=>e===f.id?null:e)}}},[f,i]),It=!!(f&&f.target_available!==!1&&!g&&!HZ({activeProject:t,activeProjectBranchState:n,session:f})),Lt=It&&f?`This session targets ${WZ(f)}, but the current target is ${GZ({activeProject:t,activeProjectBranchState:n})}. Restore the session target to continue.`:null,Rt=It&&m===null,zt=(0,X.useCallback)(async r=>{h(r.id);let a=r;if(e)try{let t=await ix(e,r.id);a=t,ot(t)}catch(e){Q.error(e instanceof Error?e.message:`Unable to load the chat session right now.`),h(e=>e===r.id?null:e);return}if(a.target_available===!1){Pt(a.id,a);return}if(!HZ({activeProject:t,activeProjectBranchState:n,session:a})&&i)try{if(!await i(a)){h(e=>e===a.id?null:e);return}}catch(e){Q.error(e instanceof Error?e.message:`Unable to restore the chat target right now.`),h(e=>e===a.id?null:e);return}Pt(a.id,a)},[t,n,e,i,Pt,ot]),Bt=(0,X.useCallback)(()=>{Ne(e=>e+1)},[]),Vt=(0,X.useCallback)(async t=>{if(g){let n=Le.current;y(t),PZ({projectId:e,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,mode:t}),Bt();return}if(!(!e||!f||f.mode===t||se)){H(!0);try{let n=await ax(e,f.id,{mode:t});PZ({projectId:e,tool:n.tool,model:n.model,variant:n.variant,mode:n.mode}),p(n),ot(n),Bt()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the chat mode right now.`)}finally{H(!1)}}},[e,f,r,Bt,g,se,ot]),Ht=(0,X.useCallback)(async({instruction:t,targetSession:n})=>{if(!e)return null;let r=Le.current;Ze.current+=1;let i={sessionId:n.id,turnKey:`${n.id}:${Ze.current}`};Pe(i);try{let i=await ox(e,n.id,{instruction:t,tool:n.tool,model:r.showModelSelector&&r.model||null,variant:r.showModelSelector&&r.model&&r.variant||null,skills:r.showModelSelector?r.skills:[]});return PZ({projectId:e,tool:i.tool,model:i.model,variant:i.variant,mode:i.mode}),Re.current=!1,p(i),d(i.id),_(!1),ot(i),i}catch(e){throw Pe(e=>e?.turnKey===i.turnKey?null:e),e}},[e,ot]),Ut=(0,X.useCallback)(async()=>{if(!e)return null;let t=Le.current,n=await rx(e,{mode:Tt,tool:r,model:t.showModelSelector&&t.model||null,variant:t.showModelSelector&&t.model&&t.variant||null,skills:t.showModelSelector?t.skills:[]});return Re.current=!1,_(!1),d(n.id),p(n),n},[e,r,Tt]),Wt=(0,X.useCallback)(async t=>{if(!e||z||R||f?.agent_status===`running`||f?.target_available===!1||Rt)return!1;let n=t.trim();if(!n)return!1;B(!0);let r=null,i=f,a=e&&f?wZ({projectId:e,tool:f.tool,chatSessionId:f.id}):null;try{let t=f;if(t||(ee(!0),r=await Ut(),t=r,a=e&&r?wZ({projectId:e,tool:r.tool,chatSessionId:r.id}):null,ut({fromStorageKey:rt,toStorageKey:a})),!t)return!1;lt(a??rt);let i=BZ({session:t,instruction:n,createdAt:new Date().toISOString()});p(i),d(i.id),ot(i);let o=await Ht({instruction:n,targetSession:t});return lt(o&&e?wZ({projectId:e,tool:o.tool,chatSessionId:o.id}):a),!0}catch(e){throw ct(a??rt,n),r?(p(r),d(r.id),_(!1),ot(r)):i&&(p(i),ot(i)),e}finally{ee(!1),B(!1)}},[e,f,lt,Ut,rt,R,z,ut,Ht,ct,Rt,ot]),Gt=(0,X.useCallback)(async e=>{await Wt(e)},[Wt]),Kt=!!(e&&(g||f&&f.target_available!==!1&&!Rt)),Jt=f?.agent_status===`running`,Yt=f?.agent_status===`stopped`,Xt=Jt&&V===f?.id,Zt=Kt&&!Jt&&!z&&!R,Qt=Kt?f?.target_available===!1?f.target_unavailable_reason??`Target unavailable for this chat session.`:Rt?Lt??`Restore the session target to continue.`:Jt?`Wait for the current chat turn to finish before sending review comments.`:R||z?`Wait for the current chat prompt to finish sending before submitting review comments.`:null:`Open or create a chat session to send review comments.`,$t=(0,X.useCallback)(async()=>{if(!(!e||!f||f.agent_status!==`running`||Xt)){te(f.id);try{await sx(e,f.id)}catch(e){te(e=>e===f.id?null:e),Q.error(e instanceof Error?e.message:`Unable to interrupt the chat response right now.`)}}},[e,f,Xt]),en=(0,X.useCallback)(async()=>{if(!(!e||!vt||ae)){oe(vt.id);try{await cx(e,vt.id),st(vt.id)}catch(e){Q.error(e instanceof Error?e.message:`Unable to delete the chat session right now.`),oe(e=>e===vt.id?null:e)}}},[e,ae,st,vt]),tn=(0,X.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(lu,{value:Tt,items:[{value:`plan`,label:`Plan`,activeVariant:`ghost`,activeClassName:`border-transparent bg-sky-300 text-[#07111a] shadow-[0_10px_30px_rgba(125,211,252,0.24)] hover:bg-sky-200 hover:text-[#07111a]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:(0,Z.jsx)(_Z,{label:`Switch to Plan`,modifierLabel:Ot,keys:[eZ]})},{value:`build`,label:`Build`,activeVariant:`ghost`,activeClassName:`border-transparent bg-emerald-400 text-[#07130d] shadow-[0_10px_30px_rgba(16,185,129,0.28)] hover:bg-emerald-300 hover:text-[#07130d]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:(0,Z.jsx)(_Z,{label:`Switch to Build`,modifierLabel:Ot,keys:[eZ]})}],disabled:se,onChange:e=>{Vt(e)}}),Jt?(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:Xt,onClick:()=>{$t()},children:[Xt?(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Su,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:Xt?`Interrupting...`:`Interrupt`})]}):null]}),[Ot,Tt,$t,Vt,Xt,Jt,se]),nn=(0,X.useMemo)(()=>St?(0,Z.jsx)(mP,{model:E,variant:O,skills:A,showModelSelector:!0,showSkillsSelector:!0,availableModels:S,availableSkills:w,selectedModel:wt,onModelChange:e=>{let t=S.find(t=>t.id===e)??null;D(e),k(e=>t&&t.variants.includes(e)?e:``)},onVariantChange:k,onSkillsChange:j,modelSelectId:`project-chat-model-selector`,variantSelectId:`project-chat-variant-selector`,skillsSelectId:`project-chat-skills-selector`,disabled:z||R||f?.agent_status===`running`}):Ct?(0,Z.jsx)(pP,{dataTestId:`chat-model-selector-skeleton`}):null,[f?.agent_status,S,w,R,z,wt,E,A,O,St,Ct]);(0,X.useEffect)(()=>{if(a)return()=>{a(null)}},[a]),(0,X.useEffect)(()=>{if(a){if(!e||!Kt){a(null);return}a({chatSessionId:f?.id??null,canSubmitReviewPrompt:Zt,reviewSubmitDisabledReason:Qt,mode:Tt,onModeChange:Vt,isUpdatingMode:se,promptPlaceholder:lZ(Tt),promptComposerControls:tn,promptComposerInlineControls:nn,submitPrompt:Gt})}},[e,f,Zt,Tt,Vt,Gt,Kt,se,a,tn,nn,Qt]);let rn=async()=>{if(it.trim())try{if(!await Wt(it))return}catch(e){Q.error(e instanceof Error?e.message:`Unable to send the chat prompt right now.`)}},an=e=>{e.key!==`Enter`||e.shiftKey||f?.agent_status===`running`||R||z||(e.preventDefault(),rn())};(0,X.useEffect)(()=>{let t=t=>{if(pZ(t)){if(!e||R||z)return;t.preventDefault(),Nt(),Bt();return}fZ(t)&&(!e||!g&&!f||(t.preventDefault(),Vt(dZ(Tt))))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,f,Tt,Bt,Nt,Vt,R,g,z]);let on=(0,X.useCallback)(async t=>{if(!(!e||!f)){de(t);try{let n=await dx(e,f.id,t);p(n.chatSession),ot(n.chatSession),Q.success(`Created ${n.created_tickets.length} ticket${n.created_tickets.length===1?``:`s`} from chat.`)}catch(e){Q.error(e instanceof Error?e.message:`Unable to create tickets from the chat proposal right now.`)}finally{de(e=>e===t?null:e)}}},[e,f,ot]),sn=(0,X.useCallback)(e=>{if(!Be.current)return;let t=Be.current.getBoundingClientRect().width,n=aZ(e,t);Ye.current=n,He.current&&(He.current.style.setProperty(`--chat-changes-panel-width`,`${n}px`),He.current.setAttribute(`data-desktop-width`,String(n)))},[]),cn=(0,X.useCallback)(()=>{Ge.current?.(),Ge.current=null},[]),ln=(0,X.useCallback)(e=>{let t=Ue.current,n=We.current,r=Ke.current;if(t!==null){if(Ue.current=null,We.current=null,Ke.current=!1,De(!1),ke(!1),cn(),e!==null&&typeof Ve.current?.hasPointerCapture==`function`&&Ve.current.hasPointerCapture(e)&&typeof Ve.current.releasePointerCapture==`function`&&Ve.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;je(Ye.current),Te(!0);return}je(Ye.current)}},[cn]),un=(0,X.useCallback)((e,t)=>{if(Ue.current!==e)return;let n=t-qe.current,r=Je.current-n;if(We.current===`collapsed`){if(!Ke.current&&r<$X)return;Ke.current||(Ke.current=!0,Y.current=!0,ke(!0),De(!0))}sn(r)},[sn]),dn=(0,X.useCallback)((e,t)=>{if(Ue.current===e){if(t!==null&&(We.current===`inline`||Ke.current)){let e=t-qe.current;sn(Je.current-e)}ln(e)}},[ln,sn]),fn=(0,X.useCallback)(e=>{if(!s)return;e.preventDefault(),Ue.current=e.pointerId,We.current=we?`inline`:`collapsed`,Ke.current=!1,Y.current=!1,qe.current=e.clientX,Je.current=we?Ye.current:0,De(we),cn(),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=e=>{un(e.pointerId,e.clientX)},n=e=>{dn(e.pointerId,e.clientX)},r=e=>{dn(e.pointerId,e.clientX)};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),Ge.current=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r)}},[dn,un,we,s,cn]),pn=(0,X.useCallback)(e=>{un(e.pointerId,e.clientX)},[un]),mn=(0,X.useCallback)(e=>{dn(e.pointerId,e.clientX)},[dn]),hn=(0,X.useCallback)(e=>{dn(e.pointerId,e.clientX)},[dn]),gn=(0,X.useCallback)(e=>{Ue.current===e.pointerId&&ln(e.pointerId)},[ln]),_n=(0,X.useCallback)(()=>{if(Y.current){Y.current=!1;return}Te(!0)},[]),vn=(0,X.useCallback)(()=>{Te(!1)},[]),yn=(0,X.useCallback)(e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),_n())},[_n]);(0,X.useEffect)(()=>{s||(Ue.current=null,We.current=null,Ke.current=!1,Y.current=!1,De(!1),ke(!1),cn())},[s,cn]),(0,X.useEffect)(()=>()=>{cn()},[cn]);let bn=!!u,xn=f?.target_available===!1,Sn=xn?f?.target_unavailable_reason??`Target unavailable for this chat session.`:null,Cn=g||!!(f&&f.target_available!==!1&&!Rt),wn=!!(t?.memory_enabled&&f&&(G.length>0||K)),Tn=s&&(g||bn)&&!xn&&!Rt,En=Tn&&!we&&!Oe,Dn=Tn&&(we||Oe),On=`${Mt??`none`}:${Tn?`changes-enabled`:`changes-disabled`}:${Dn?`panel-visible`:`panel-hidden`}`,kn=f||g?(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(TX,{projectId:e,messages:f?bt:[],internalLog:f?.agent_log??null,pendingAgentTitle:yt,streamingResponse:f?.streaming_response??null,isRunning:f?.agent_status===`running`,isLoading:!g&&I,canShowComposer:Cn,isExternallyResizing:o||Ee,pendingAgentRevealKey:xt,pendingAgentRevealDelayMs:iZ,composerFocusNonce:Me,header:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,children:Et}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[g?null:(0,Z.jsx)(NT,{tool:f?.tool,className:`text-[11px]`}),At?(0,Z.jsx)(`p`,{children:At}):null,Yt?(0,Z.jsx)(`div`,{className:`inline-flex items-center rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100`,children:`Interrupted`}):null,jt?(0,Z.jsx)(`div`,{"data-testid":`chat-context-usage-badge`,className:`inline-flex items-center rounded-full border border-border/80 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-foreground`,children:jt}):null]})]}),wn?(0,Z.jsx)(U,{type:`button`,size:`xs`,variant:`outline`,className:`gap-2`,onClick:()=>he(!0),children:K?`Loading memory...`:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`Memory suggestions`}),(0,Z.jsx)(DX,{children:G.length})]})}):null]}),Rt&&Lt?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{children:Lt}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{Ft()},children:`Switch back`}),(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`ghost`,onClick:Nt,children:`New session`})]})]})}):null,xn&&Sn?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:Sn}):null]}),composerControls:tn,composerInlineControls:nn,composerTheme:Tt,layoutKey:Mt,scrollLayoutKey:On,followUpPrompt:it,followUpPlaceholder:lZ(Tt),emptyStateText:null,renderMessageFooter:e=>e.ticket_proposals?(0,Z.jsx)(JZ,{proposals:e.ticket_proposals,isApplying:ue===e.id,onApply:()=>{on(e.id)}}):null,isSendingFollowUp:z||R,followUpDisabledReason:xn?Sn??void 0:f?.agent_status===`running`?`Wait for the current chat turn to finish.`:void 0,onFollowUpPromptChange:e=>{ct(rt,e)},onFollowUpKeyDown:an,onFollowUpSubmit:()=>{rn()}})}):bn?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:`Loading chat session...`}):!P||M?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:`Loading chat sessions...`}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6`,children:(0,Z.jsxs)(kd,{className:`w-full max-w-lg border-dashed border-border/70 bg-card/40`,children:[(0,Z.jsxs)(Ad,{children:[(0,Z.jsx)(jd,{children:`No session selected`}),(0,Z.jsx)(Md,{children:`Select a chat session to restore its saved target, or start a new session on the current target.`})]}),(0,Z.jsx)(Pd,{children:(0,Z.jsx)(U,{type:`button`,onClick:Nt,disabled:!e||R||z,children:`Start new session`})})]})}),An=Tn?(0,Z.jsx)(`div`,{ref:Ve,"aria-label":En?`Open diff`:`Resize diff panel`,"aria-orientation":En?void 0:`vertical`,className:W(En?`group flex h-8 w-full shrink-0 touch-none select-none items-center justify-center border-t border-border/70 bg-background/90 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground xl:h-auto xl:w-7 xl:cursor-col-resize xl:border-l xl:border-t-0`:`group hidden w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 transition-colors xl:flex`,Ee&&!En&&`bg-background`),"data-testid":En?`collapsed-changes-rail`:void 0,onLostPointerCapture:gn,onPointerCancel:hn,onPointerDown:fn,onPointerMove:pn,onPointerUp:mn,onClick:En?_n:void 0,onKeyDown:En?yn:void 0,role:En?`button`:`separator`,tabIndex:En?0:void 0,children:En?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`hidden h-full w-full items-center justify-center xl:flex`,children:(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(vu,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]})}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium xl:hidden`,children:[(0,Z.jsx)(vu,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:`Diff`})]})]}):(0,Z.jsx)(`div`,{className:W(`h-14 w-1.5 rounded-full transition-colors`,Ee?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`)})}):null,jn=me&&e&&t?.memory_enabled?(0,Z.jsx)(Ce,{onClose:()=>he(!1),overlayClassName:`bg-background/45 p-4 backdrop-blur-sm`,panelClassName:`w-full max-w-3xl`,renderContent:({closeButton:t})=>(0,Z.jsxs)(kd,{size:`sm`,className:`max-h-[calc(100vh-2rem)] w-full gap-0 overflow-hidden border-border/80 bg-card/95 shadow-2xl`,children:[(0,Z.jsxs)(Ad,{className:`border-b border-border/80 pb-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(jd,{children:`Memory suggestions`}),(0,Z.jsx)(Md,{children:`Review pending suggestions from this chat before saving them into project memory.`})]}),(0,Z.jsx)(Nd,{children:t})]}),(0,Z.jsx)(Pd,{className:`min-h-0 flex-1 overflow-y-auto pt-4`,children:(0,Z.jsx)(PX,{projectId:e,suggestions:G,emptyState:`No pending memory suggestions for this chat session.`,onSuggestionsChanged:ht})})]}),closeButtonLabel:`Close memory suggestions`}):null,Mn=vt?(0,Z.jsx)(KZ,{title:vt.title,isDeleting:ae===vt.id,onConfirm:()=>{en()},onCancel:()=>{ae!==vt.id&&re(null)}}):null;return(0,Z.jsxs)(`div`,{"data-testid":`chat-view-shell`,className:`relative flex min-h-0 flex-1 overflow-hidden border-t border-border/70`,children:[(0,Z.jsx)(qZ,{activeProject:t,activeSessionId:u,chatModeShortcutModifierLabel:Ot,confirmingDeleteSessionId:ne,deletingSessionId:ae,finishedBackgroundSessionIds:Fe,isCreatingSession:R||!e,isDraftOpen:g,isLoadingSessions:M,isOpen:xe,isSendingPrompt:z,sessionGroups:_t,sessions:c,onConfirmDeleteSession:e=>{re(e)},onDraftOpen:Nt,onSessionSelect:e=>{zt(e)},onToggleOpen:()=>{Se(e=>!e)}}),(0,Z.jsxs)(`div`,{ref:Be,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden xl:flex-row`,children:[(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:kn}),Tn?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(cu,{content:`Open diff`,disabled:!En,side:`left`,children:An}),Dn?(0,Z.jsx)(wX,{projectId:e,chatSessionId:g?null:u,canSubmitReviewPrompt:Zt,reviewSubmitDisabledReason:Qt,onSubmitReviewPrompt:Gt,state:ye,onStateChange:be,isResizing:Ee,onClose:vn,desktopWidth:Ae,panelElementRef:He}):null]}):null]}),jn,Mn]})},XZ=({className:e})=>(0,Z.jsx)(uc,{"aria-hidden":`true`,className:e}),ZZ=({activeProject:e})=>e?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/60 pb-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Memory archive`}),(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name})]})}),(0,Z.jsx)(wp,{mode:`edit`,projectId:e.id,memoryEnabled:e.memory_enabled,persistedMemoryEnabled:e.memory_enabled,onMemoryEnabledChange:()=>{},showActivationControls:!1,archiveLayout:!0})]})}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Select a project to view memory.`}),QZ=()=>({hasRunning:!1,hasFinishedUnseen:!1,hasErrorUnseen:!1}),$Z=()=>({board:QZ(),memory:QZ(),chat:QZ()}),eQ=(e,t)=>{let n=e[t];return!n.hasFinishedUnseen&&!n.hasErrorUnseen?e:{...e,[t]:{...n,hasFinishedUnseen:!1,hasErrorUnseen:!1}}},tQ=e=>({hasRunning:e.board.hasRunning||e.chat.hasRunning,hasFinishedUnseen:e.board.hasFinishedUnseen||e.chat.hasFinishedUnseen,hasErrorUnseen:e.board.hasErrorUnseen||e.chat.hasErrorUnseen}),nQ=e=>e.hasErrorUnseen?`error`:e.hasRunning?`running`:e.hasFinishedUnseen?`finished`:null,rQ=(e,t)=>t?null:nQ(e),iQ=320,aQ=.7,oQ=28,sQ=6,cQ=(e,t)=>{let n=Math.max(iQ,Math.round(t*aQ));return Math.max(iQ,Math.min(n,Math.round(e)))},lQ=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return[...e,t];let r=e.slice();return r[n]=t,r},uQ=(e,t)=>{if(t.type===`reset`)return $Z();if(t.type===`mark-workspace-visible`)return eQ(e,t.workspace);let n=e[t.workspace],r={...n,hasRunning:t.activity.hasRunning,hasFinishedUnseen:t.visibleWorkspace===t.workspace?!1:n.hasFinishedUnseen||t.activity.didFinish,hasErrorUnseen:t.visibleWorkspace===t.workspace?!1:n.hasErrorUnseen||t.activity.didError};return n.hasRunning===r.hasRunning&&n.hasFinishedUnseen===r.hasFinishedUnseen&&n.hasErrorUnseen===r.hasErrorUnseen?e:{...e,[t.workspace]:r}},dQ=({activeProjectId:e,onActivity:t})=>{let{tickets:n}=DY(),r=(0,X.useRef)(new Map);return(0,X.useEffect)(()=>{r.current=new Map},[e]),(0,X.useEffect)(()=>{let e=r.current,i=new Map,a=!1,o=!1;for(let t of n){let n=e.get(t.id)??null,r=t.agent_status??null;n===`running`&&r===`done`&&(a=!0),n===`running`&&r===`error`&&(o=!0),i.set(t.id,r)}r.current=i,t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:a,didError:o})},[t,n]),null},fQ=({activeProjectId:e,onActivity:t})=>{let[n,r]=(0,X.useState)([]),i=(0,X.useRef)(new Map);return(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController;return(async()=>{try{let n=await nx(e,t.signal);if(t.signal.aborted)return;r(n)}catch(e){ge(e)}})(),()=>{t.abort()}},[e]),(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController,n=UK(()=>{document.visibilityState===`visible`&&nx(e,t.signal).then(e=>{t.signal.aborted||r(e)}).catch(e=>{ge(e)})});return()=>{t.abort(),n()}},[e]),(0,X.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||r(e=>lQ(e,t))},n=t=>{!t||t.project_id!==e||r(e=>e.filter(e=>e.id!==t.id))};return PW.on(`chat-session:created`,t),PW.on(`chat-session:updated`,t),PW.on(`chat-session:deleted`,n),()=>{PW.off(`chat-session:created`,t),PW.off(`chat-session:updated`,t),PW.off(`chat-session:deleted`,n)}},[e]),(0,X.useEffect)(()=>{let r=i.current,a=new Map,o=[],s=!1;for(let e of n){let t=r.get(e.id)??null,n=e.agent_status??null;t===`running`&&n===`done`&&o.push(e),t===`running`&&n===`error`&&(s=!0),a.set(e.id,n)}i.current=a;for(let e of o)e.title&&yY(`Chat response ready`,e.title);o.length>0&&e&&BK(e),t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:o.length>0,didError:s})},[e,t,n]),null},pQ=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onRestoreChatSessionTarget:a,onChatReviewCapabilityChange:o,onPreviewReviewCapabilityChange:s,previewDisplayMode:c=`hidden`,previewPane:l=null,previewPaneWidth:u=480,isPreviewButtonDisabled:d=!1,previewButtonTitle:f,visibleWorkspace:p,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,onBoardLoadedProjectIdChange:_,onPreviewToggle:v,onPreviewPaneWidthChange:y,onRunStopped:b,onRunStatusChange:x,onWorkspaceActivityChange:S,onWorkspaceActivityEvent:C,refreshKey:w=0})=>{let T=(0,X.useRef)(null),E=(0,X.useRef)(null),D=(0,X.useRef)(null),O=(0,X.useRef)(null),k=(0,X.useRef)(!1),A=(0,X.useRef)(!1),j=(0,X.useRef)(0),M=(0,X.useRef)(u),N=(0,X.useRef)(u),P=p===`board`||p===`chat`,F=l!==null,[I,L]=(0,X.useState)(!1),[R,ee]=(0,X.useState)(!1),[z,B]=(0,X.useState)(u),[V,te]=(0,X.useReducer)(uQ,void 0,$Z),ne=P&&F&&c===`expanded`,re=P&&F&&c===`inline`,ie=P&&F&&c===`hidden`&&!R,ae=(re||R)&&!ne,oe=ne||ae,se=P&&F&&!ne,H=I?z:u,ce=p!==`chat`||!ae,U=e=>{let t=D.current,n=O.current,r=k.current;if(t!==null){if(D.current=null,O.current=null,k.current=!1,L(!1),ee(!1),e!==null&&E.current?.hasPointerCapture(e)&&E.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;y?.(N.current),v?.();return}y?.(N.current)}},le=e=>{if(!T.current)return;let t=T.current.getBoundingClientRect().width,n=cQ(e,t);N.current=n,B(n)},ue=e=>{y&&(ie&&d||(e.preventDefault(),D.current=e.pointerId,O.current=ie?`collapsed`:`inline`,k.current=!1,A.current=!1,j.current=e.clientX,M.current=ie?0:N.current,L(!ie),e.currentTarget.setPointerCapture(e.pointerId)))},W=e=>{if(D.current!==e.pointerId)return;let t=e.clientX-j.current,n=M.current-t;if(O.current===`collapsed`){if(!k.current&&n<sQ)return;k.current||(k.current=!0,A.current=!0,ee(!0),L(!0))}le(n)},de=e=>{if(D.current===e.pointerId){if(O.current===`inline`||k.current){let t=e.clientX-j.current;le(M.current-t)}U(e.pointerId)}},G=e=>{D.current===e.pointerId&&U(e.pointerId)},fe=(0,X.useCallback)((e,t)=>{C?.(e,t),te({type:`update-workspace`,workspace:e,activity:t,visibleWorkspace:p})},[C,p]);(0,X.useEffect)(()=>{te({type:`reset`})},[e]),(0,X.useEffect)(()=>{p!==`memory`&&te({type:`mark-workspace-visible`,workspace:p})},[p]),(0,X.useEffect)(()=>{S?.(V)},[S,V]),(0,X.useEffect)(()=>{I||(N.current=u),!F&&(D.current=null,O.current=null,k.current=!1,A.current=!1,N.current=u)},[F,I,u]);let K=()=>{if(A.current){A.current=!1;return}d||v?.()};return(0,Z.jsx)(EY,{activeProjectId:e,refreshKey:w,onLoadedProjectIdChange:_,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,children:(0,Z.jsxs)(`div`,{ref:T,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(dQ,{activeProjectId:e,onActivity:e=>{fe(`board`,e)}}),(0,Z.jsx)(fQ,{activeProjectId:e,onActivity:e=>{fe(`chat`,e)}}),p===`memory`?(0,Z.jsx)(`div`,{id:`project-workspace-panel-memory`,role:`tabpanel`,"aria-labelledby":`project-workspace-tab-memory`,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(ZZ,{activeProject:t})}):(0,Z.jsxs)(`div`,{id:p===`chat`?`project-workspace-panel-chat`:`project-workspace-panel-board`,role:`tabpanel`,"aria-labelledby":p===`chat`?`project-workspace-tab-chat`:`project-workspace-tab-board`,className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:p===`chat`?(0,Z.jsx)(YZ,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeTool:i,isExternallyResizing:I,onRestoreSessionTarget:a,onReviewCapabilityChange:o,showChangesPanel:ce}):(0,Z.jsx)(oX,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:s,onRunStopped:b,onRunStatusChange:x,refreshKey:w})}),[se?(0,Z.jsx)(cu,{content:d?f??`Preview unavailable`:`Open preview`,disabled:!ie,side:`left`,children:(0,Z.jsx)(`div`,{"aria-label":ie?f??`Show preview`:`Resize preview pane`,"aria-orientation":ie?void 0:`vertical`,className:ie?`group flex shrink-0 touch-none select-none items-center justify-center border-l border-border/70 bg-background/90 transition-colors ${d?`cursor-not-allowed text-muted-foreground/60`:`cursor-col-resize text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`:`group flex w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 ${I?`bg-background`:``}`,"data-preview-divider":`true`,"data-testid":ie?`collapsed-preview-rail`:void 0,onLostPointerCapture:G,onPointerCancel:de,onPointerDown:ue,onPointerMove:W,onPointerUp:de,onClick:ie?K:void 0,onKeyDown:ie?e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),K())}:void 0,ref:E,role:ie?`button`:`separator`,style:ie?{width:`${oQ}px`}:void 0,tabIndex:ie?d?-1:0:void 0,children:ie?(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(XZ,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]}):(0,Z.jsx)(`div`,{className:`h-14 w-1.5 rounded-full transition-colors ${I?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`}`})})},`preview-divider`):null,oe?(0,Z.jsx)(`div`,{className:ne?`fixed inset-0 z-50 bg-black/70 p-4 sm:p-6`:`min-h-0 shrink-0 border-l border-border/70 bg-[#11131a]`,style:ne?void 0:{width:`${H}px`},children:(0,Z.jsx)(`div`,{className:`h-full w-full`,children:l})},`preview-container`):null]]})]})})},mQ=({isExpanded:e,isVisible:t,project:n,onClose:r,onToggleExpanded:i})=>(0,Z.jsx)(`div`,{className:[`fixed inset-x-4 bottom-24 z-40`,e?`top-20`:`h-[min(28rem,calc(100vh-8rem))]`,t?`block`:`hidden`].join(` `),children:(0,Z.jsx)(LW,{createSession:()=>kT(n.id),isExpanded:e,isVisible:t,ariaLabel:`Project terminal for ${n.name}`,title:n.name,closeLabel:`Close terminal`,className:e?`h-full w-full rounded-2xl shadow-2xl`:`mx-auto h-full max-w-6xl shadow-2xl`,onClose:r,onToggleExpanded:i})}),hQ=({activeWorkspace:e,activityByWorkspace:t,memoryEnabled:n=!1,onWorkspaceChange:r})=>(0,Z.jsx)(`div`,{role:`tablist`,"aria-label":`Project workspace`,className:`inline-flex items-end gap-1 border-b border-border/70`,children:(n?[`board`,`chat`,`memory`]:[`board`,`chat`]).map(n=>{let i=e===n,a=rQ(t[n],i),o=n===`board`?`border-sky-300/70 bg-sky-500/8 text-sky-200`:n===`memory`?`border-amber-300/70 bg-amber-500/8 text-amber-200`:`border-emerald-300/70 bg-emerald-500/8 text-emerald-200`;return(0,Z.jsx)(`button`,{id:`project-workspace-tab-${n}`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`project-workspace-panel-${n}`,tabIndex:i?0:-1,className:W(`cursor-pointer rounded-t-lg border-b-2 px-4 py-2.5 text-[15px] font-medium transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,i?o:`border-transparent text-muted-foreground hover:border-border hover:bg-background/35 hover:text-foreground`),onClick:()=>r(n),children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:n===`board`?`Board`:n===`memory`?`Memory`:`Chat`}),(0,Z.jsx)(lX,{state:a,className:`mt-0`})]})},n)})}),gQ=32,_Q=5.5,vQ=2,yQ=24,bQ=8,xQ=new Map,SQ={running:{fill:`#fcd34d`,stroke:`#f59e0b`},finished:{fill:`#34d399`,stroke:`#059669`},error:{fill:`#fb7185`,stroke:`#e11d48`}},CQ=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),wQ=e=>{if(!e)return null;let t=e.trim().match(/^([0-9]+(?:\.[0-9]+)?)/);return t?Number(t[1]):null},TQ=e=>{let t=new DOMParser().parseFromString(e,`image/svg+xml`);if(t.querySelector(`parsererror`))return null;let n=t.documentElement;if(n.nodeName.toLowerCase()!==`svg`)return null;let r=n.getAttribute(`viewBox`)?.trim(),i=wQ(n.getAttribute(`width`)),a=wQ(n.getAttribute(`height`)),o=r??(i&&a?`0 0 ${i} ${a}`:`0 0 ${gQ} ${gQ}`);return`<svg ${[Array.from(n.attributes).filter(e=>![`width`,`height`,`viewBox`,`x`,`y`,`preserveAspectRatio`].includes(e.name)).map(e=>`${e.name}="${CQ(e.value)}"`).join(` `),`x="0"`,`y="0"`,`width="${gQ}"`,`height="${gQ}"`,`viewBox="${CQ(o)}"`,`preserveAspectRatio="xMidYMid meet"`].filter(e=>e.length>0).join(` `)}>${n.innerHTML}</svg>`},EQ=async e=>{if(!e)return null;let t=xQ.get(e);if(t)return t;let n=(async()=>{try{if(e.startsWith(`data:image/svg+xml,`))return TQ(decodeURIComponent(e.slice(19)));if(e.startsWith(`data:image/svg+xml;base64,`))return TQ(atob(e.slice(26)));let t=await fetch(e);return t.ok?TQ(await t.text()):null}catch{return null}})();return xQ.set(e,n),n},DQ=async(e,t)=>{let{fill:n,stroke:r}=SQ[e],i=await EQ(t);return i?[`<svg xmlns="http://www.w3.org/2000/svg" width="${gQ}" height="${gQ}" viewBox="0 0 ${gQ} ${gQ}">`,i,`<circle cx="${yQ}" cy="${bQ}" r="${_Q}" fill="${n}" stroke="${r}" stroke-width="${vQ}"/>`,`</svg>`].join(``):null},OQ=async(e,t)=>{if(!e)return t;let n=await DQ(e,t);return n?`data:image/svg+xml,${encodeURIComponent(n)}`:t},kQ=()=>{let e=document.querySelector(`link[rel="icon"]`);if(e)return e;let t=document.createElement(`link`);return t.rel=`icon`,document.head.appendChild(t),t},AQ=({defaultHref:e,state:t})=>{let n=kQ(),r=Number(n.dataset.browserTabActivityRequestId??`0`)+1;if(n.dataset.browserTabActivityState=t??`default`,n.dataset.browserTabActivityRequestId=String(r),!t){if(e){n.href=e;return}n.removeAttribute(`href`);return}OQ(t,e).then(e=>{if(n.dataset.browserTabActivityRequestId===String(r)){if(e){n.href=e;return}n.removeAttribute(`href`)}})},jQ=`archon.active-project-id`,MQ=`archon.workspace-by-project`,NQ=`archon.preview-mode-by-project`,PQ=`archon.dismissed-preview-run-context-by-project`,FQ=5e3,IQ=`archon.preview-pane-width`,LQ=`archon.preview-viewport-preset`,RQ=`archon.preview-zoom`,zQ=480,BQ=`responsive`,VQ=1,HQ={hasMounted:!1,isOpen:!1,isExpanded:!1},UQ=`hidden`,WQ=(0,X.lazy)(()=>VW(()=>Promise.resolve().then(()=>Xq).then(e=>({default:e.TicketChangesModal})),void 0)),GQ=(0,X.lazy)(()=>VW(()=>import(`./TestsDialog-F0VCXRNc.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),KQ=e=>{if(!e)return null;try{return JSON.parse(e)}catch{return null}},qQ=e=>{let t=KQ(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0):[]},JQ=e=>{let t=KQ(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.name==`string`?t.name:``,r=typeof t.cmd==`string`?t.cmd:``,i=typeof t.cwd==`string`?t.cwd:``;return n.trim()===``&&r.trim()===``&&i.trim()===``?[]:[{name:n,cmd:r,cwd:i}]}):[]},YQ=e=>{let t=KQ(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.source==`string`?t.source:``,r=typeof t.target==`string`?t.target:``,i=t.mode===`copy`||t.mode===`symlink`?t.mode:`copy`;return n.trim()===``&&r.trim()===``?[]:[{source:n,target:r,mode:i}]}):[]},XQ=e=>({name:e.name,repoPath:e.repo_path,linkedProjectIds:e.linked_project_ids,runSetup:qQ(e.run_setup),runServices:JQ(e.run_services),testCommands:rY(e.test_commands),runIde:e.run_ide??``,previewServiceName:e.preview_service_name??``,previewPath:e.preview_path??``,previewCapabilityMode:e.preview_capability_mode??`auto`,helperModel:e.helper_model??``,helperVariant:e.helper_variant??``,commitMessageRules:e.commit_message_rules??``,autoParkStaleTickets:e.auto_park_stale_tickets,memoryEnabled:e.memory_enabled,worktreeSync:YQ(e.worktree_sync)}),ZQ=e=>{let t=e.testCommands??[],n=e.previewServiceName?.trim()||null,r=e.previewPath?.trim()||``,i=r===``||r===`/`?null:r,a=n||i||e.previewCapabilityMode===`force_web`||e.previewCapabilityMode===`force_disabled`?e.previewCapabilityMode??`auto`:null;return{name:e.name,repo_path:e.repoPath,linked_project_ids:e.linkedProjectIds,run_setup:e.runSetup.length>0?e.runSetup:null,run_services:e.runServices.length>0?e.runServices.map(e=>({...e.name?{name:e.name}:{},cmd:e.cmd,...e.cwd?{cwd:e.cwd}:{}})):null,...t.length>0?{test_commands:t.map(e=>({id:e.id,name:e.name,command:e.command,runner:e.runner,...e.cwd?{cwd:e.cwd}:{}}))}:{},run_ide:e.runIde||null,preview_service_name:n,preview_path:i,preview_capability_mode:a,helper_model:e.helperModel||null,helper_variant:e.helperModel&&e.helperVariant||null,commit_message_rules:e.commitMessageRules||null,auto_park_stale_tickets:e.autoParkStaleTickets,memory_enabled:e.memoryEnabled,worktree_sync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source,...e.target?{target:e.target}:{},mode:e.mode})):null}},QQ=e=>e?qQ(e.run_setup).length>0||JQ(e.run_services).length>0||(e.run_ide?.trim().length??0)>0:!1,$Q=(e,t,n)=>`${e} ${e===1?t:n}`,e$=e=>{if(!e.repo_path_locked)return null;let t=[];return e.ticket_count>0&&t.push($Q(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&t.push($Q(e.worktree_count,`worktree exists`,`worktrees exist`)),t.length===0?`Repository path is locked for this project.`:`Repository path is locked because ${t.join(` and `)}.`},t$=(e,t)=>{if(t.length<=1)return`Keep at least one project in Archon.`;let n=[];e.ticket_count>0&&n.push($Q(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&n.push($Q(e.worktree_count,`worktree exists`,`worktrees exist`));let r=t.filter(t=>t.linked_project_ids.includes(e.id)).length;return r>0&&n.push($Q(r,`project links to it`,`projects link to it`)),n.length===0?null:`This project can't be deleted while ${n.join(` and `)}.`},n$=(e,t)=>e.id!==t.projectId||e.ticket_count===t.ticketCount&&e.worktree_count===t.worktreeCount&&e.repo_path_locked===t.repoPathLocked?e:{...e,ticket_count:t.ticketCount,worktree_count:t.worktreeCount,repo_path_locked:t.repoPathLocked},r$=(e,t)=>({projectId:e,branch:t.branch,status:t.status,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.has_upstream??!1,canPull:t.can_pull??!1,diffStats:t.diff_stats??null}),i$=e=>({projectId:e,branch:null,status:`loading`,ahead:0,behind:0,hasUpstream:!1,canPull:!1,diffStats:null}),a$=(e,t)=>t?e[t]??HQ:HQ,o$=(e,t)=>t?e[t]??UQ:UQ,s$=()=>{let e=window.localStorage.getItem(IQ),t=Number(e);return Number.isFinite(t)&&t>=320?t:zQ},c$=()=>{let e=window.localStorage.getItem(LQ);return e===`phone`||e===`tablet`||e===`laptop`||e===`responsive`?e:BQ},l$=()=>{let e=Number(window.localStorage.getItem(RQ));return Number.isFinite(e)&&e>0?e:VQ},u$=()=>{let e=KQ(window.localStorage.getItem(MQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`board`||e===`chat`||e===`memory`))},d$=()=>{let e=KQ(window.localStorage.getItem(NQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`hidden`||e===`inline`||e===`expanded`))},f$=()=>{let e=KQ(window.localStorage.getItem(PQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`||e===null))},p$=e=>!!e?.preview_service_name?.trim()&&e?.preview_capability_mode!==`force_disabled`,m$=({activeRun:e,project:t})=>{if(!e||e.kind!==`project`||!t)return!1;let n=t.active_target_kind??`repo_root`,r=t.active_target_bundle_id??null;return e.project_id===t.id&&(e.target_kind??`repo_root`)===n&&((e.target_kind??`repo_root`)!==`bundle`||e.target_bundle_id===r)},h$=({activeRun:e,project:t,projectId:n})=>!e||!n?null:e.kind===`ticket`?e.project_id===n?e:null:m$({activeRun:e,project:t})?e:null,g$=`Project root has uncommitted changes. Confirm branch switch to continue.`,_$=({activeProject:e,activeProjectBranchState:t,nextTarget:n})=>e?n.kind===`bundle`?e.active_target_kind!==`bundle`||e.active_target_bundle_id!==n.bundleId:e.active_target_kind===`bundle`?!0:n.branch?t?.branch!==n.branch:!1:!1,v$=()=>{let[e,t]=(0,X.useState)(`opencode`),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(()=>window.localStorage.getItem(jQ)),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[p,h]=(0,X.useState)(null),[g,_]=(0,X.useState)({}),[v,y]=(0,X.useState)({}),[b,x]=(0,X.useState)({}),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)({}),[E,D]=(0,X.useState)(d$),[O,k]=(0,X.useState)(f$),[A,j]=(0,X.useState)(s$),[N,P]=(0,X.useState)(c$),[F,I]=(0,X.useState)(l$),[L,R]=(0,X.useState)(null),[ee,z]=(0,X.useState)([]),[te,ne]=(0,X.useState)(!1),[ie,ae]=(0,X.useState)(``),[oe,se]=(0,X.useState)(``),[H,U]=(0,X.useState)(!1),[W,de]=(0,X.useState)(null),[G,K]=(0,X.useState)(null),[q,pe]=(0,X.useState)(null),[he,_e]=(0,X.useState)({}),[ye,be]=(0,X.useState)(u$),[xe,Se]=(0,X.useState)(()=>$Z()),[Ce,we]=(0,X.useState)(()=>QZ()),[Te,Ee]=(0,X.useState)(0),[De,Oe]=(0,X.useState)(null),[ke,Ae]=(0,X.useState)(null),[je,Me]=(0,X.useState)({}),[Ne,J]=(0,X.useState)({}),[Pe,Fe]=(0,X.useState)({}),[Ie,Le]=(0,X.useState)({}),[ze,Ve]=(0,X.useState)(!1),[He,Ue]=(0,X.useState)(null),We=(0,X.useRef)(null),Ge=(0,X.useRef)(null),Ke=(0,X.useRef)(null),Y=i.find(e=>e.id===o)??null,qe=!!Y?.memory_enabled,Je=o?ye[o]??`board`:`board`,Ye=Je===`memory`?qe?`memory`:`board`:Je,Ze=Y!==null,Qe=QQ(Y),$e=!!Y?.run_ide?.trim(),et=o!==null&&u===o,tt=o!==null&&(!Qe||p===o),nt=o?g[o]??i$(o):null,rt=o?v[o]??null:null,it=o?!!b[o]:!1,at=o?je[o]??[]:[],ot=o?!!Ne[o]:!1,st=o?Pe[o]??{current_branch:null,default_branch:null,previous_branch:null}:{current_branch:null,default_branch:null,previous_branch:null},ct=o?!!Ie[o]:!1,lt=o?w[o]??null:null,ut=o$(E,o),gt=ut!==`hidden`,_t=h$({activeRun:c,project:Y,projectId:o}),vt=_t?.context_key??null,yt=o?O[o]??null:null,bt=p$(Y),xt=vt===L,St=(0,X.useMemo)(()=>tQ(xe),[xe]),Ct=(0,X.useMemo)(()=>nQ({hasRunning:St.hasRunning,hasFinishedUnseen:Ce.hasFinishedUnseen,hasErrorUnseen:Ce.hasErrorUnseen}),[St.hasRunning,Ce.hasErrorUnseen,Ce.hasFinishedUnseen]);(0,X.useEffect)(()=>{Oe(null),Ae(null),Ge.current=null},[o]),(0,X.useEffect)(()=>{Ae(null)},[Ye]),(0,X.useEffect)(()=>{gt||(Ge.current=null)},[gt]),(0,X.useEffect)(()=>{let e=De?.target?.kind??null;if(e===`ticket`||e===`bundle`){Ge.current=De;return}(Ye===`board`||!gt)&&(Ge.current=De)},[gt,De,Ye]),(0,X.useEffect)(()=>{Se($Z())},[o]),(0,X.useEffect)(()=>{we(QZ())},[o]);let wt=(0,X.useCallback)((e,t)=>{document.visibilityState!==`visible`&&(!t.didFinish&&!t.didError||we(e=>{let n={...e,hasFinishedUnseen:e.hasFinishedUnseen||t.didFinish,hasErrorUnseen:e.hasErrorUnseen||t.didError};return e.hasFinishedUnseen===n.hasFinishedUnseen&&e.hasErrorUnseen===n.hasErrorUnseen?e:n}))},[]);(0,X.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&we(e=>!e.hasFinishedUnseen&&!e.hasErrorUnseen?e:{...e,hasFinishedUnseen:!1,hasErrorUnseen:!1})};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]),(0,X.useEffect)(()=>(We.current===null&&(We.current=document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)??`/favicon.svg`),AQ({defaultHref:We.current,state:Ct}),()=>{AQ({defaultHref:We.current,state:null})}),[Ct]);let Tt=(0,X.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;try{let t=await me(e,r,{refreshRemote:n});if(r?.aborted)return;_(n=>({...n,[e]:r$(e,t)}))}catch(t){if(ge(t))return;if(t instanceof ve&&t.status===404){_(t=>({...t,[e]:{...i$(e),status:`unknown`}}));return}_(t=>({...t,[e]:{projectId:e,branch:t[e]?.branch??null,status:`unknown`,ahead:t[e]?.ahead??0,behind:t[e]?.behind??0,hasUpstream:t[e]?.hasUpstream??!1,canPull:t[e]?.canPull??!1,diffStats:t[e]?.diffStats??null}}))}},[]),Et=(0,X.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;x(t=>({...t,[e]:!0}));try{let t=await ce(e,{refreshRemote:n,signal:r});if(r?.aborted)return;y(n=>({...n,[e]:t}))}catch(t){if(ge(t))return;t instanceof ve&&t.status===404&&y(t=>({...t,[e]:null}))}finally{r?.aborted||x(t=>({...t,[e]:!1}))}},[]);(0,X.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let{tool:n}=await Jt(e.signal);t(n)}catch(e){ge(e)}finally{e.signal.aborted||r(!0)}})(),()=>{e.abort()}},[]),(0,X.useEffect)(()=>{if(!H||i.length>0&&W===null||te)return;let e=new AbortController;return(async()=>{try{z(await qt(`opencode`,e.signal))}catch(e){ge(e)||z(e=>e)}finally{e.signal.aborted||ne(!0)}})(),()=>{e.abort()}},[te,W,i.length,H]),(0,X.useEffect)(()=>{let e=new AbortController,t=window.localStorage.getItem(jQ);return(async()=>{try{let n=await fe(e.signal);if(e.signal.aborted)return;a(n);let r=n[0]?.id??null;s(n.some(e=>e.id===t)?t:r)}catch(e){ge(e)||a([])}finally{e.signal.aborted||U(!0)}})(),()=>{e.abort()}},[]),(0,X.useEffect)(()=>{if(H){if(o){window.localStorage.setItem(jQ,o);return}window.localStorage.removeItem(jQ)}},[o,H]),(0,X.useEffect)(()=>{window.localStorage.setItem(MQ,JSON.stringify(ye))},[ye]),(0,X.useEffect)(()=>{window.localStorage.setItem(NQ,JSON.stringify(E))},[E]),(0,X.useEffect)(()=>{window.localStorage.setItem(PQ,JSON.stringify(O))},[O]),(0,X.useEffect)(()=>{_(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),y(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),x(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,X.useEffect)(()=>{_e(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,X.useEffect)(()=>{let e=new Set(i.map(e=>e.id));Me(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),J(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Fe(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Le(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t))))},[i]),(0,X.useEffect)(()=>{T(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),D(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),k(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,X.useEffect)(()=>{H&&be(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i,H]),(0,X.useEffect)(()=>{if(!H||!o||!Ze)return;let e=!1,t=null,n=null;_(e=>e[o]?e:{...e,[o]:i$(o)});let r=async(r=!1)=>{let i=r?`remote`:`local`;if(t){if(n===`remote`||n===i)return;t.abort()}let a=new AbortController;t=a,n=i;try{await Promise.all([Tt(o,{refreshRemote:r,signal:a.signal}),Et(o,{refreshRemote:r,signal:a.signal})])}catch{if(e||a.signal.aborted)return}finally{t===a&&(t=null,n=null)}};r(!1);let i=UK(()=>{document.visibilityState===`visible`&&r(!1)});return()=>{e=!0,t?.abort(),i()}},[o,Ze,H,Tt,Et]),(0,X.useEffect)(()=>{if(o)return VK(e=>{e===o&&(Tt(e),Et(e))})},[o,Tt,Et]);let Dt=(0,X.useCallback)(async e=>{let t=o;if(!t){l(null),h(null);return}try{let n=await pt(t,e);e?.aborted||(l(n.active_run),h(t))}catch(e){ge(e)}},[o]),Ot=(0,X.useCallback)(async e=>{let t=o;if(t)try{let n=await ft(t,e);e?.aborted||T(e=>({...e,[t]:n}))}catch(e){ge(e)}},[o]);(0,X.useEffect)(()=>{if(!H)return;if(!Qe){l(null),h(null);return}if(!et)return;let e=new AbortController;h(null),Dt(e.signal);let t=window.setInterval(()=>{Dt(e.signal)},FQ),n=UK(()=>{document.visibilityState===`visible`&&Dt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[et,Qe,H,Dt]),(0,X.useEffect)(()=>{if(!H||!o||!et||!bt)return;let e=new AbortController;Ot(e.signal);let t=window.setInterval(()=>{Ot(e.signal)},FQ),n=UK(()=>{document.visibilityState===`visible`&&Ot(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[o,et,bt,H,Ot]),(0,X.useEffect)(()=>{window.localStorage.setItem(IQ,String(A))},[A]),(0,X.useEffect)(()=>{window.localStorage.setItem(LQ,N)},[N]),(0,X.useEffect)(()=>{window.localStorage.setItem(RQ,String(F))},[F]),(0,X.useEffect)(()=>{o&&vt&&k(e=>{let t=e[o]??null;return!t||t===vt?e:{...e,[o]:null}})},[o,vt]),(0,X.useEffect)(()=>{!o||!_t||!p$(Y)||yt!==_t.context_key&&D(e=>o$(e,o)===`hidden`?{...e,[o]:`inline`}:e)},[Y,o,yt,_t]);let kt=async e=>{try{t((await Yt(e)).tool)}catch{}},At=(0,X.useCallback)(e=>{a(t=>t.map(t=>t.id===e.id?e:t))},[]),jt=(0,X.useCallback)((e,t)=>{Me(n=>{let r=[t,...(n[e]??[]).filter(e=>e.id!==t.id)];return{...n,[e]:r}})},[]),Mt=(0,X.useCallback)(async e=>{Le(t=>({...t,[e]:!0}));try{let t=await le(e);Fe(n=>({...n,[e]:t}))}catch(e){Q.error(e instanceof ve?e.message:`Unable to load the project target options right now.`,{id:`project-target-selector-load-error`})}finally{Le(t=>({...t,[e]:!1}))}},[]),Nt=async e=>{try{let t=await M(ZQ(e));return a(e=>[...e,t]),s(t.id),de(null),null}catch(e){return e instanceof ve?e.message:`Unable to create the project right now.`}},Pt=async e=>{if(!Y)return`Select a project before editing settings.`;try{let t=await Be(Y.id,ZQ(e));return a(e=>e.map(e=>e.id===t.id?t:e)),Ee(e=>e+1),de(null),null}catch(e){return e instanceof ve?e.message:`Unable to update the project right now.`}},Ft=async()=>{if(!Y)return`Select a project before deleting it.`;try{await ue(Y.id);let e=i.filter(e=>e.id!==Y.id);return a(e),s(e[0]?.id??null),de(null),null}catch(e){return e instanceof ve?e.message:`Unable to delete the project right now.`}},It=(0,X.useCallback)(e=>{a(t=>t.map(t=>n$(t,e)))},[]),Lt=(0,X.useCallback)((e,t)=>{e&&Me(n=>({...n,[e]:t}))},[]),Rt=(0,X.useCallback)((e,t)=>{e&&J(n=>({...n,[e]:t}))},[]),zt=async(e,t,n)=>await V({repo_path:e,helper_model:t||null,helper_variant:t&&n||null}),Vt=async()=>(await B()).repo_path,Ht=(0,X.useCallback)(async e=>{let t=await f({repo_path:e});return{valid:t.valid,repoRoot:t.repo_root,error:t.error}},[]),Ut=(0,X.useCallback)((e,t)=>{D(t=>({...t,[e]:`hidden`})),t&&k(n=>({...n,[e]:t}))},[]),Wt=(0,X.useCallback)(()=>{o&&Ut(o,vt)},[o,Ut,vt]),Gt=(0,X.useCallback)(e=>{o&&(D(e=>({...e,[o]:`hidden`})),e&&l(t=>t?.context_key===e?null:t))},[o]),Kt=(0,X.useCallback)(async()=>{if(!_t||L===_t.context_key)return;let{context_key:e}=_t;R(e);try{_t.kind===`ticket`?await Bt(_t.ticket_id,_t.project_id):l((await ht(_t.project_id)).active_run),Gt(e),await Promise.all([Dt(),Ot()])}catch(e){Q.error(e instanceof ve?e.message:`Unable to stop the preview run right now.`,{id:`app-preview-run-stop-error`})}finally{R(t=>t===e?null:t)}},[Gt,_t,Ot,Dt,L]),Xt=(0,X.useCallback)(e=>{!e||!o||Mt(o)},[o,Mt]),Zt=(0,X.useCallback)(e=>new Promise(t=>{Ke.current=t,Ue(e)}),[]),Qt=(0,X.useCallback)(e=>{let t=Ke.current;Ke.current=null,Ue(null),t?.(e)},[]),$t=(0,X.useCallback)(async e=>{if(!Y||!o)throw Error(`Select a project first.`);if(!_$({activeProject:Y,activeProjectBranchState:nt,nextTarget:e})||!c||c.kind!==`project`||c.project_id!==Y.id)return!0;if(!await Zt({title:`Stop current run and switch target?`,description:`Switching targets will stop the current run and close its preview.`,confirmLabel:`Stop and switch`,cancelLabel:`Keep current target`,confirmVariant:`destructive`}))return!1;try{let e=c.context_key,t=await ht(Y.id);return Gt(e),l(t.active_run),await Ot(),!0}catch(e){return Q.error(e instanceof ve?e.message:`Unable to stop the project run right now.`,{id:`project-target-switch-stop-run-error`}),!1}},[Y,nt,o,c,Gt,Ot,Zt]),en=(0,X.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);return await $t({kind:`bundle`,bundleId:e})?(At(await m(o,{kind:`bundle`,bundle_id:e})),y(e=>({...e,[o]:null})),await Promise.all([Tt(o),Et(o)]),!0):!1},[o,$t,Tt,Et,At]),tn=(0,X.useCallback)(async(e,t={})=>{if(!o)throw Error(`Select a project first.`);if(!await $t({kind:`repo_root`,branch:e}))return!1;let n=n=>m(o,{kind:`repo_root`,...e?{branch:e}:{},...t.createBranch===!1?{create_branch:!1}:{},...n?{confirm_dirty_switch:!0}:{}}),r;try{r=await n(t.confirmDirtySwitch===!0)}catch(e){if(!t.confirmDirtySwitch&&e instanceof ve&&e.status===409&&e.message===g$){if(!await Zt({title:`Switch repo root branch?`,description:`${g$}\n\nSwitch anyway?`,confirmLabel:`Switch anyway`,cancelLabel:`Keep current branch`}))return!1;r=await n(!0)}else throw e}return At(r),y(e=>({...e,[o]:null})),await Promise.all([Tt(o),Et(o),Mt(o)]),!0},[o,$t,Mt,Tt,Et,At,Zt]),nn=(0,X.useCallback)(async e=>!e.target_kind||e.target_available===!1?!0:e.target_kind===`bundle`?e.target_bundle_id?await en(e.target_bundle_id):!1:await tn(e.target_branch_snapshot??null,{createBranch:!1}),[en,tn]),rn=(0,X.useCallback)(()=>{Ve(!0)},[]),an=(0,X.useCallback)(()=>{Ve(!1)},[]),on=(0,X.useCallback)(e=>{if(e){en(e);return}tn(null)},[en,tn]),sn=(0,X.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);let t=await Xe(o,{name:e,prepare:!0});return jt(o,t),Ee(e=>e+1),t},[o,jt]),cn=(0,X.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);await dt(o,e),Me(t=>({...t,[o]:(t[o]??[]).filter(t=>t.id!==e)})),Ee(e=>e+1)},[o]),ln=(0,X.useCallback)(async()=>{if(!Y)return;let e=Y.active_target_kind??`repo_root`,t=Y.active_target_bundle_id??null,n=c?.kind===`project`&&c.project_id===Y.id&&(c.target_kind??`repo_root`)===e&&((c.target_kind??`repo_root`)!==`bundle`||c.target_bundle_id===t),r=n?c?.context_key??null:null,i=!n&&p$(Y)&&ut===`hidden`;i&&(D(e=>({...e,[Y.id]:`inline`})),k(e=>({...e,[Y.id]:null})));try{let e=n?await ht(Y.id):await mt(Y.id);n&&Gt(r),l(e.active_run),Ot()}catch(e){i&&D(e=>({...e,[Y.id]:`hidden`})),Q.error(e instanceof ve?e.message:`Unable to update the project run right now.`,{id:`app-project-run-error`})}},[ut,Y,c,Gt,Ot]),un=(0,X.useCallback)(async()=>{if(!(!Y||!$e))try{await re(Y.id)}catch(e){Q.error(e instanceof Error?e.message:`Unable to open the IDE right now.`,{id:`app-project-open-ide-error`})}},[Y,$e]),dn=(0,X.useCallback)(async()=>{if(Y){C(Y.id);try{let e=await Re(Y.id);y(t=>({...t,[Y.id]:e})),Y.active_target_kind!==`bundle`&&await Tt(Y.id),BK(Y.id),Q.success(e.behind===0?`Project branch synced.`:`Project branch updated.`,{id:`app-project-pull-success`})}catch(e){Q.error(e instanceof ve?e.message:`Unable to sync the current branch right now.`,{id:`app-project-pull-error`})}finally{C(e=>e===Y.id?null:e)}}},[Y,Tt]),fn=(0,X.useCallback)(()=>{Y&&K({projectId:Y.id,title:Y.name})},[Y]),pn=(0,X.useCallback)(()=>{if(!G)return;let{projectId:e}=G;K(null),Tt(e),Et(e)},[Tt,Et,G]),mn=(0,X.useCallback)(()=>{Y&&pe({projectId:Y.id,targetKind:Y.active_target_kind??`repo_root`,targetBundleId:Y.active_target_bundle_id??null})},[Y]),hn=(0,X.useCallback)(()=>{pe(null)},[]),gn=a$(he,o),_n=Y?rY(Y.test_commands).length>0:!1,vn=Ye===`chat`?ke:null,yn=Ge.current,bn=yn?.target?.kind??null,xn=Ye===`chat`?bn===`ticket`||bn===`bundle`?{target:yn?.target??null,canSelect:!1,disabledReason:`This preview belongs to a ticket run. Return to Board to send preview comments.`,promptMode:yn?.promptMode??null,onPromptModeChange:yn?.onPromptModeChange??null,isUpdatingPromptMode:yn?.isUpdatingPromptMode??!1,promptPlaceholder:yn?.promptPlaceholder??null,promptComposerControls:yn?.promptComposerControls,promptComposerInlineControls:yn?.promptComposerInlineControls,submitPrompt:null}:vn?{target:{kind:`chat_session`,id:vn.chatSessionId??`draft:${o}`},canSelect:vn.canSubmitReviewPrompt,disabledReason:vn.canSubmitReviewPrompt?null:vn.reviewSubmitDisabledReason??`Wait for the current chat turn to finish before sending preview comments.`,promptMode:vn.mode,onPromptModeChange:vn.onModeChange,isUpdatingPromptMode:vn.isUpdatingMode,promptPlaceholder:vn.promptPlaceholder,promptComposerControls:vn.promptComposerControls,promptComposerInlineControls:vn.promptComposerInlineControls,submitPrompt:vn.canSubmitReviewPrompt?vn.submitPrompt:null}:{target:null,canSelect:!1,disabledReason:`Select a chat session to send preview comments.`,submitPrompt:null}:De,Sn=vn?.canSubmitReviewPrompt??!1,Cn=Ye===`chat`?vn?vn.reviewSubmitDisabledReason:`Select a chat session to send review comments.`:void 0,wn=(0,X.useCallback)(()=>{o&&_e(e=>{let t=e[o]??HQ;return{...e,[o]:{hasMounted:!0,isOpen:!t.isOpen,isExpanded:t.isExpanded}}})},[o]),Tn=(0,X.useCallback)(e=>{_e(t=>{let n=t[e]??HQ;return!n.hasMounted||!n.isOpen?t:{...t,[e]:HQ}})},[]),En=(0,X.useCallback)(e=>{_e(t=>{let n=t[e]??HQ;return{...t,[e]:{hasMounted:!0,isOpen:n.isOpen,isExpanded:!n.isExpanded}}})},[]),Dn=(0,X.useCallback)(()=>{de(`create`)},[]),On=(0,X.useCallback)(()=>{if(o){if(gt){Wt();return}D(e=>({...e,[o]:`inline`})),k(e=>({...e,[o]:null}))}},[o,Wt,gt]),kn=(0,X.useCallback)(()=>{o&&D(e=>{let t=o$(e,o);return{...e,[o]:t===`expanded`?`inline`:`expanded`}})},[o]),An=Y?Y.preview_service_name?.trim()?Y.preview_capability_mode===`force_disabled`?`Preview is disabled for this project.`:lt?.state===`unsupported`?lt.message??`Preview is unavailable for this project.`:gt?`Hide preview`:`Show preview`:`Choose a named preview service in project settings first.`:`Select a project first.`,jn=!Y||!Y.preview_service_name?.trim()||Y.preview_capability_mode===`force_disabled`||lt?.state===`unsupported`,Mn=Y&&Y.preview_service_name?.trim()?(0,Z.jsx)(tx,{project:Y,mode:ut===`expanded`?`expanded`:`inline`,status:lt,viewportPreset:N,zoom:F,activeRun:_t,reviewCapability:xn,isStoppingActiveRun:xt,onHide:Wt,onStopActiveRun:()=>{Kt()},onToggleExpanded:kn,onViewportPresetChange:P,onZoomChange:I}):null;return(0,Z.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-[linear-gradient(180deg,_rgba(15,16,21,1),_rgba(9,10,14,1))] text-foreground`,children:[(0,Z.jsx)(Dd,{}),i.length>0&&(0,Z.jsx)(`header`,{className:`border-b border-border bg-background/95 px-6 py-3 backdrop-blur`,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-center`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 lg:justify-self-start`,children:(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-[20rem] sm:max-w-[30rem]`,children:(0,Z.jsx)(pu,{activeProjectId:o,projects:i,onEditProject:()=>de(`edit`),onProjectChange:s})})}),o&&(0,Z.jsx)(`div`,{className:`flex justify-start lg:col-start-2 lg:row-start-1 lg:justify-center`,children:(0,Z.jsx)(hQ,{activeWorkspace:Ye,activityByWorkspace:xe,memoryEnabled:qe,onWorkspaceChange:e=>{o&&(be(t=>({...t,[o]:e})),Se(t=>eQ(t,e)))}})}),(0,Z.jsx)(`div`,{className:`w-full lg:col-start-3 lg:row-start-1 lg:w-auto lg:justify-self-end`,children:(0,Z.jsx)(Ed,{activeTool:e,onCreateProject:Dn,onToolChange:kt})})]})}),H?i.length===0?(0,Z.jsx)(du,{activeTool:e,availableHelperModels:ee,helperModel:ie,helperVariant:oe,isHelperModelsLoaded:te,isToolLoaded:n,onCreateProject:Dn,onHelperModelChange:e=>{ae(e),se(``)},onHelperVariantChange:se,onToolChange:kt}):(0,Z.jsx)(pQ,{activeProjectId:o,activeProject:Y,activeProjectBranchState:nt,activeRun:c,activeTool:e,onRestoreChatSessionTarget:nn,onChatReviewCapabilityChange:Ae,isPreviewButtonDisabled:jn,onPreviewReviewCapabilityChange:Oe,onPreviewToggle:On,onRunStopped:Gt,onWorkspaceActivityChange:Se,onWorkspaceActivityEvent:wt,previewDisplayMode:ut,previewPane:Mn,previewPaneWidth:A,previewButtonTitle:An,visibleWorkspace:Ye,refreshKey:Te,onBoardLoadedProjectIdChange:d,onBundlesChange:Lt,onBundlesLoadingChange:Rt,onPreviewPaneWidthChange:j,onProjectUsageChange:It,onRunStatusChange:()=>{Dt(),Ot()}},o??`no-project`):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading projects...`}),i.length>0&&(0,Z.jsx)(wd,{activeProject:Y,activeRun:c,branchState:nt,targetGitStatus:rt,isBoardLoadedForActiveProject:et,isProjectSyncing:S===o,isProjectIdeAvailable:$e,isProjectRunAvailable:Qe,isRunStatusLoadedForActiveProject:tt,isTerminalOpen:gn.isOpen,targetBundles:at,targetBranchSuggestions:st,isTargetBundleLoading:ot,isTargetSelectorLoading:ct,isTargetGitStatusLoading:it,hasConfiguredTests:_n,onProjectIdeOpen:()=>{un()},onProjectPull:()=>{dn()},onProjectRunToggle:()=>{ln()},onProjectChangesOpen:fn,onProjectTestsOpen:mn,onTerminalToggle:wn,onTargetSelectorOpenChange:Xt,onSelectBundleTarget:en,onSelectRepoRootTarget:tn,onManageBundles:rn}),ze&&Y&&(0,Z.jsx)(Bd,{bundles:at,selectedBundleId:Y.active_target_kind===`bundle`?Y.active_target_bundle_id??null:null,activeTargetBundleId:Y.active_target_kind===`bundle`?Y.active_target_bundle_id??null:null,onSelectBundle:on,onCreateBundle:sn,onDeleteBundle:cn,onClose:an}),He&&(0,Z.jsx)(Od,{title:He.title,description:He.description,confirmLabel:He.confirmLabel,cancelLabel:He.cancelLabel,confirmVariant:He.confirmVariant,onConfirm:()=>Qt(!0),onCancel:()=>Qt(!1)}),i.map(e=>{let t=a$(he,e.id);return t.hasMounted?(0,Z.jsx)(mQ,{project:e,isExpanded:t.isExpanded,isVisible:e.id===o&&t.isOpen,onClose:()=>Tn(e.id),onToggleExpanded:()=>En(e.id)},e.id):null}),W&&(0,Z.jsx)(Jp,{mode:W,projectId:W===`edit`&&Y?Y.id:null,availableHelperModels:ee,isLoadingHelperModels:!te,isAutoConfigReady:n,initialValues:W===`edit`&&Y?XQ(Y):i.length===0?{name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],testCommands:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:ie,helperVariant:oe,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}:void 0,linkedProjectOptions:i.filter(e=>e.id!==Y?.id).map(e=>({id:e.id,name:e.name})),repoPathLocked:W===`edit`&&Y?Y.repo_path_locked:!1,repoPathLockedMessage:W===`edit`&&Y?e$(Y):null,deleteBlockedMessage:W===`edit`&&Y?t$(Y,i):null,onDelete:W===`edit`?Ft:void 0,onAutoConfig:zt,onBrowseRepoPath:Vt,onValidateRepoPath:Ht,onClose:()=>de(null),onSubmit:W===`edit`?Pt:Nt}),G&&G.projectId===o&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(WQ,{scope:`project_root`,projectId:G.projectId,title:G.title,onSubmitReviewPrompt:vn?.submitPrompt,canSubmitReviewPrompt:Sn,reviewSubmitDisabledReason:Cn??void 0,canAddReviewComments:Sn,canModifyChanges:!0,onClose:pn})}),q&&q.projectId===o&&Y&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(GQ,{scope:`project`,projectId:q.projectId,targetKind:q.targetKind,targetBundleId:q.targetBundleId,testCommands:rY(Y.test_commands),onClose:hn})})]})};document.documentElement.classList.add(`dark`),document.documentElement.style.colorScheme=`dark`,(0,Je.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(v$,{}));export{Tl as _,xw as a,yf as c,Su as d,bu as f,xl as g,yl as h,Cw as i,mf as l,_l as m,bw as n,vf as o,_u as p,Sw as r,bf as s,PW as t,Od as u,Cl as v,wl as y};
142
+ `).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t),jX=e=>{let t=[`plan`,`build`,`review`,`follow_up`,`plan_follow_up`,`chat`];return e.split(/\n|,/).map(e=>e.trim()).filter(e=>t.includes(e)).filter((e,t,n)=>n.indexOf(e)===t)},MX=({suggestion:e,isPending:t,onReview:n,onAccept:r,onDismiss:i})=>{let a=e.kind===`decision`?e.duplicate_match?.decision??null:null,o=a?`Save as new decision`:`Accept`,s=e.kind===`decision`?e.decision:e.instruction;return(0,Z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/40`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),(0,Z.jsxs)(DX,{children:[`Suggested `,e.kind]}),a?(0,Z.jsx)(DX,{tone:`muted`,children:`Possible duplicate`}):null]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:s})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,disabled:t,onClick:()=>n(e),children:`Review`}),(0,Z.jsx)(U,{type:`button`,size:`sm`,disabled:t,onClick:()=>void r(e),children:o}),(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void i(e),children:`Dismiss`})]})]})})},NX=({suggestion:e,isOpen:t,isEditing:n,isPending:r,draft:i,onOpenChange:a,onStartEdit:o,onDraftChange:s,onCancelEdit:c,onAccept:l,onDismiss:u})=>{if(!e)return null;let d=e.kind===`decision`?e.duplicate_match?.decision??null:null,f=d?`Save as new decision`:`Accept as ${e.kind}`;return(0,Z.jsx)(_l,{open:t,onOpenChange:a,children:(0,Z.jsxs)(xl,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Z.jsxs)(Sl,{children:[(0,Z.jsx)(wl,{children:e.title}),(0,Z.jsx)(Tl,{children:`Review this suggestion before saving it into project memory.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-5 text-amber-100`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-amber-50`,children:`Possible duplicate`}),(0,Z.jsxs)(`p`,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[d.title,`:`]}),` `,d.decision]})]}):null,n?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:`Suggestion title`}),(0,Z.jsx)(`input`,{"aria-label":`Suggestion title`,value:i.title,onChange:e=>s({...i,title:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:`Scope`}),(0,Z.jsx)(`input`,{"aria-label":`Scope`,value:i.scope,onChange:e=>s({...i,scope:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:i.kind===`decision`?`Decision`:`Instruction`}),(0,Z.jsx)(`textarea`,{"aria-label":i.kind===`decision`?`Decision`:`Instruction`,value:i.content,onChange:e=>s({...i,content:e.target.value}),rows:5,className:`min-h-32 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:`Rationale`}),(0,Z.jsx)(`textarea`,{"aria-label":`Rationale`,value:i.rationale,onChange:e=>s({...i,rationale:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),i.kind===`decision`?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground sm:col-span-2`,children:[(0,Z.jsx)(`span`,{children:`Implications (one per line)`}),(0,Z.jsx)(`textarea`,{"aria-label":`Implications`,value:i.implications,onChange:e=>s({...i,implications:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Stages (comma or newline separated)`}),(0,Z.jsx)(`textarea`,{"aria-label":`Stages`,value:i.stages,onChange:e=>s({...i,stages:e.target.value}),rows:3,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition focus:border-primary/60`})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Priority`}),(0,Z.jsxs)(`select`,{"aria-label":`Priority`,value:i.priority,onChange:e=>s({...i,priority:e.target.value}),className:`h-10 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition focus:border-primary/60`,children:[(0,Z.jsx)(`option`,{value:`low`,children:`Low`}),(0,Z.jsx)(`option`,{value:`normal`,children:`Normal`}),(0,Z.jsx)(`option`,{value:`high`,children:`High`})]})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e.kind===`decision`?`Decision`:`Instruction`}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-foreground`,children:e.kind===`decision`?e.decision:e.instruction})]}),e.rationale?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Rationale`}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-muted-foreground`,children:e.rationale})]}):null,e.kind===`decision`&&e.implications.length>0?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Implications`}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:e.implications.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}):null,e.kind===`convention`?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Stages`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:e.stages.join(`, `)||`None specified`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:`Priority`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:e.priority})]})]}):null]})]}),(0,Z.jsxs)(Cl,{className:`flex flex-wrap gap-2 sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,Z.jsx)(U,{type:`button`,variant:`ghost`,disabled:r,onClick:c,children:`Cancel edits`}):(0,Z.jsx)(U,{type:`button`,variant:`outline`,disabled:r,onClick:()=>o(e),children:`Edit`}),(0,Z.jsx)(U,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(e),children:`Dismiss`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d?(0,Z.jsx)(U,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void l(e,!0),children:`Update existing decision`}):null,(0,Z.jsx)(U,{type:`button`,disabled:r,onClick:()=>void l(e,!1),children:f})]})]})]})})},PX=({projectId:e,suggestions:t,title:n,description:r,emptyState:i=null,onSuggestionsChanged:a})=>{let[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(OX),[f,p]=(0,X.useState)(null);(0,X.useEffect)(()=>{l(e=>e&&!t.some(t=>t.id===e)?null:e),s(e=>e&&!t.some(t=>t.id===e)?null:e)},[t]);let m=o?t.find(e=>e.id===o)??null:null,h=()=>{l(null),d(OX())},g=e=>{s(e.id),l(e.id),d(kX(e))},_=e=>{c&&c!==e.id&&h(),s(e.id)},v=e=>{e||(s(null),c&&h())},y=async(t,n)=>{let r=c===t.id?u:kX(t),i=r.kind===`decision`?{title:r.title.trim(),scope:r.scope.trim()||null,decision:r.content.trim(),rationale:r.rationale.trim()||null,implications:AX(r.implications)}:{title:r.title.trim(),scope:r.scope.trim()||null,instruction:r.content.trim(),rationale:r.rationale.trim()||null,stages:jX(r.stages),priority:r.priority};p(t.id);try{if(n){if(t.kind!==`decision`)throw Error(`Only decision suggestions can update an existing memory.`);let n=t.duplicate_match?.decision;if(!n)throw Error(`No existing decision is available for this suggestion.`);await ke(e,t.id,n.id,i)}else await S(e,t.id,i);h(),s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:`Unable to save the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{p(null)}},b=async t=>{p(t.id);try{await Pe(e,t.id),c===t.id&&h(),o===t.id&&s(null),a?.()}catch(e){Q.error(e instanceof Error?e.message:`Unable to dismiss the memory suggestion right now.`,{id:`project-memory-suggestion-error`})}finally{p(null)}};return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[n||r?(0,Z.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,Z.jsxs)(`div`,{children:[n?(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:n}):null,r?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}):null]})}):null,t.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,Z.jsx)(MX,{suggestion:e,isPending:f===e.id,onReview:_,onAccept:e=>y(e,!1),onDismiss:b},e.id))}):i?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:i}):null,(0,Z.jsx)(NX,{suggestion:m,isOpen:!!m,isEditing:c===m?.id,isPending:f===m?.id,draft:c===m?.id?u:m?kX(m):u,onOpenChange:v,onStartEdit:g,onDraftChange:d,onCancelEdit:h,onAccept:y,onDismiss:b})]})},FX=()=>({selectedDiffPath:`all`,activeReviewTarget:null,editingReviewCommentKey:null,reviewDraftInput:``,reviewComments:[]}),IX=[{key:`today`,label:`Today`},{key:`yesterday`,label:`Yesterday`},{key:`last_7_days`,label:`Last 7 Days`},{key:`older`,label:`Older`}],LX=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},RX=e=>e.activity_at??e.last_user_message_at??e.created_at,zX=(e,t)=>{let n=RX(e),r=RX(t);return n===r?e.created_at===t.created_at?t.id.localeCompare(e.id):t.created_at.localeCompare(e.created_at):r.localeCompare(n)},BX=e=>[...e].sort(zX),VX=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),HX=(e,t=new Date)=>{let n=LX(RX(e));if(!n)return`older`;let r=VX(t),i=new Date(r);i.setDate(i.getDate()-1);let a=new Date(r);return a.setDate(a.getDate()-6),n>=r?`today`:n>=i?`yesterday`:n>=a?`last_7_days`:`older`},UX=(e,t=new Date)=>{let n=new Map;for(let r of BX(e)){let e=HX(r,t);n.set(e,[...n.get(e)??[],r])}return IX.flatMap(e=>{let t=n.get(e.key)??[];return t.length===0?[]:[{key:e.key,label:e.label,sessions:t}]})},WX=e=>{let t={...e};return delete t.messages,t.agent_log=null,t.streaming_response=null,t},GX=1500,KX=`archon.chat-run-config`,qX=`archon.chat-changes-panel-layout`,JX=`archon.chat-session-list-layout`,YX=`archon.chat-draft`,XX=512,ZX=360,QX=.6,$X=6,eZ=`.`,tZ=`/`,nZ=`Slash`,rZ=`NumpadDivide`,iZ=600,aZ=(e,t)=>{let n=Number.isFinite(e)?Math.round(e):XX;if(!Number.isFinite(t))return Math.max(ZX,n);let r=Math.max(ZX,Math.round(t*QX));return Math.max(ZX,Math.min(r,n))},oZ=e=>e===`claude`?`Claude`:`OpenCode`,sZ=({availableModelsById:e,model:t})=>t?e.get(t)??t:null,cZ=e=>e===`plan`?`Plan`:`Build`,lZ=e=>e===`plan`?`Ask Archon to scope, sequence, or reason through project work`:`Ask Archon to build, change, or verify something in this project`,uZ=e=>`${e} pending memory suggestion${e===1?``:`s`}`,dZ=e=>e===`plan`?`build`:`plan`,fZ=e=>!e.defaultPrevented&&!e.altKey&&!e.shiftKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&e.key===eZ,pZ=e=>!e.defaultPrevented&&!e.altKey&&!e.repeat&&(e.ctrlKey||e.metaKey)&&(e.key===tZ||e.code===nZ||e.code===rZ),mZ=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??navigator.userAgent;return/mac/i.test(e)},hZ=()=>mZ()?`CMD`:`CTRL`,gZ=({modifierLabel:e,keys:t,ariaHidden:n=!1})=>(0,Z.jsxs)(`span`,{"aria-hidden":n,className:`flex items-center gap-0.5 text-[10px] leading-none`,children:[(0,Z.jsx)(vw,{"aria-hidden":n,children:e}),t.map(e=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{children:`+`}),(0,Z.jsx)(vw,{"aria-hidden":n,children:e})]},e))]}),_Z=({label:e,modifierLabel:t,keys:n})=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(gZ,{modifierLabel:t,keys:n,ariaHidden:!0})]}),vZ=({modelLabel:e,tool:t})=>e??oZ(t),yZ=()=>`You`,bZ=e=>{if(!Number.isFinite(e))return`0`;if(e>=1e6){let t=e/1e6,n=t<10?2:1;return`${t.toFixed(n)}M`}return e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`},xZ=({totalTokens:e,contextWindow:t})=>!Number.isFinite(e)||!Number.isFinite(t)||t<=0?null:Math.round(e/t*100),SZ=({tool:e,model:t,availableModels:n,fallbackContextWindow:r})=>e===`opencode`?(n.find(e=>e.id===t)??null)?.context_window??r:r,CZ=({projectId:e,tool:t})=>`${KX}:${e}:${t}`,wZ=({projectId:e,tool:t,chatSessionId:n})=>n?`${YX}:${e}:session:${n}`:`${YX}:${e}:draft:${t}`,TZ=e=>`${qX}:${e}`,EZ=e=>`${JX}:${e}`,DZ=e=>{if(!e)return``;try{return window.localStorage.getItem(e)??``}catch{return``}},OZ=({storageKey:e,value:t})=>{if(e)try{if(t){window.localStorage.setItem(e,t);return}window.localStorage.removeItem(e)}catch{}},kZ=e=>{if(!e)return{isOpen:!0,width:XX};try{let t=window.localStorage.getItem(TZ(e));if(!t)return{isOpen:!0,width:XX};let n=JSON.parse(t),r=typeof n.width==`number`&&Number.isFinite(n.width)?Math.max(ZX,Math.round(n.width)):XX;return{isOpen:n.isOpen!==!1,width:r}}catch{return{isOpen:!0,width:XX}}},AZ=e=>{if(!e)return{isOpen:!0};try{let t=window.localStorage.getItem(EZ(e));return t?{isOpen:JSON.parse(t).isOpen!==!1}:{isOpen:!0}}catch{return{isOpen:!0}}},jZ=({projectId:e,isOpen:t,width:n})=>{if(e)try{window.localStorage.setItem(TZ(e),JSON.stringify({isOpen:t,width:n}))}catch{}},MZ=({projectId:e,isOpen:t})=>{if(e)try{window.localStorage.setItem(EZ(e),JSON.stringify({isOpen:t}))}catch{}},NZ=({projectId:e,tool:t})=>{if(!e||t!==`opencode`)return null;try{let n=window.localStorage.getItem(CZ({projectId:e,tool:t}));if(!n)return null;let r=JSON.parse(n),i=(typeof r.model==`string`?r.model.trim():``)||null,a=r.mode===`plan`||r.mode===`build`?r.mode:null;return!i&&!a?null:{model:i,variant:i&&typeof r.variant==`string`&&r.variant.trim()||null,mode:a}}catch{return null}},PZ=({projectId:e,tool:t,model:n,variant:r,mode:i})=>{if(!(!e||t!==`opencode`||!n&&!i))try{window.localStorage.setItem(CZ({projectId:e,tool:t}),JSON.stringify({model:n,variant:n?r:null,mode:i}))}catch{}},FZ=({projectId:e,tool:t})=>NZ({projectId:e,tool:t})?.mode??`plan`,IZ=({activeProjectId:e,helperModel:t,helperVariant:n,activeTool:r,availableModels:i})=>{let a=NZ({projectId:e,tool:r}),o=new Set(i.map(e=>e.id)),s=e=>e?o.size===0?!0:o.has(e):!1,c=t??``,l=a?.model??``,u=s(l)?l:s(c)?c:``,d=u===l?a?.variant??null:u&&u===c?n??null:null,f=i.find(e=>e.id===u)??null;return{model:u,variant:f?f.variants.includes(d??``)?d??``:``:u?d??``:``,mode:a?.mode??`plan`}},LZ=e=>e&&e.replace(/\s+/g,` `).trim()||null,RZ=e=>{let t=LZ(e.first_user_message_preview);if(t)return t;let n=e.messages?.find(e=>e.role===`user`)?.content;return LZ(n)},zZ=({chatSessionId:e,instruction:t,createdAt:n})=>({id:`optimistic:${e}:${n}`,chat_session_id:e,role:`user`,kind:`prompt`,content:t,created_at:n}),BZ=({session:e,instruction:t,createdAt:n})=>({...e,messages:[...e.messages??[],zZ({chatSessionId:e.id,instruction:t,createdAt:n})],activity_at:n,last_user_message_at:n,updated_at:n}),VZ=e=>!!(e.first_user_message_preview||e.last_user_message_at||e.messages?.some(e=>e.role===`user`)),HZ=({activeProject:e,activeProjectBranchState:t,session:n})=>!e||n.target_available===!1?!1:n.target_kind===`bundle`?e.active_target_kind===`bundle`&&!!n.target_bundle_id&&e.active_target_bundle_id===n.target_bundle_id:e.active_target_kind===`bundle`?!1:t?!n.target_branch_snapshot||t?.status!==`ready`||!t.branch?!1:t.branch===n.target_branch_snapshot:!0,UZ=e=>e.target_kind===`bundle`?e.target_label_snapshot||`Bundle target`:null,WZ=e=>e.target_kind===`bundle`?UZ(e)||`Bundle target`:e.target_branch_snapshot?`Repo root (${e.target_branch_snapshot})`:`Repo root`,GZ=({activeProject:e,activeProjectBranchState:t})=>e?e.active_target_kind===`bundle`?`selected bundle target`:t?.branch?`Repo root (${t.branch})`:`Repo root`:`current target`,KZ=({title:e,isDeleting:t,onConfirm:n,onCancel:r})=>(0,Z.jsxs)(Ce,{onClose:r,overlayClassName:`bg-black/60`,panelClassName:`max-w-sm rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,Z.jsx)(`h2`,{className:`mb-3 text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Delete chat session`}),(0,Z.jsx)(`p`,{className:`mb-1 text-sm text-foreground`,children:e}),(0,Z.jsx)(`p`,{className:`mb-6 text-xs text-muted-foreground`,children:`This permanently removes the transcript history for this chat session.`}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,variant:`ghost`,onClick:r,disabled:t,children:`Cancel`}),(0,Z.jsx)(U,{type:`button`,variant:`destructive`,onClick:n,disabled:t,children:t?`Deleting...`:`Delete`})]})]}),qZ=({activeProject:e,activeSessionId:t,chatModeShortcutModifierLabel:n,confirmingDeleteSessionId:r,deletingSessionId:i,finishedBackgroundSessionIds:a,isCreatingSession:o,isDraftOpen:s,isLoadingSessions:c,isOpen:l,isSendingPrompt:u,sessionGroups:d,sessions:f,onConfirmDeleteSession:p,onDraftOpen:m,onSessionSelect:h,onToggleOpen:g})=>(0,Z.jsx)(`aside`,{"data-testid":`chat-sessions-sidebar`,"data-state":l?`expanded`:`collapsed`,"aria-label":`Chat sessions sidebar`,className:W(`relative z-20 flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background/40 transition-[width] duration-200 ease-out motion-reduce:transition-none`,l?`w-72`:`w-16`),children:l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-start gap-2 border-b border-border/70 px-4 py-3`,children:[(0,Z.jsxs)(U,{type:`button`,size:`sm`,className:`gap-2`,onClick:m,disabled:o||u,children:[(0,Z.jsx)(Td,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:`New session`}),(0,Z.jsx)(gZ,{modifierLabel:n,keys:[tZ],ariaHidden:!0})]}),(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Collapse sessions panel`,"aria-expanded":l,className:`ml-auto`,onClick:g,children:(0,Z.jsx)(sX,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:c&&f.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground`,children:`Loading chat sessions...`}):f.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/70 px-3 py-4 text-sm text-muted-foreground`,children:`No chat sessions yet.`}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:d.map(n=>(0,Z.jsxs)(`section`,{"aria-label":n.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`div`,{className:`px-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/80`,children:n.label}),n.sessions.map(n=>{let o=!s&&n.id===t,c=RZ(n),l=UZ(n),u=n.agent_status===`running`?`Wait for the current chat response to finish before deleting this session.`:null,d=r===n.id||i===n.id,f=!!u||i===n.id,m=n.agent_status===`running`?`running`:n.agent_status===`stopped`?`interrupted`:!o&&a.has(n.id)?`finished`:null,g=m===`interrupted`?null:m;return(0,Z.jsxs)(`div`,{className:W(`group relative rounded-xl border transition-colors`,o?`border-sky-400/40 bg-sky-500/10 text-foreground ring-1 ring-sky-400/40`:`border-border/50 bg-card/35 text-muted-foreground hover:border-border/80 hover:bg-card/60 hover:text-foreground`),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":[n.title,cZ(n.mode),oZ(n.tool),e?.memory_enabled&&n.pending_memory_suggestion_count>0?uZ(n.pending_memory_suggestion_count):null,m===`running`?`Running`:m===`interrupted`?`Interrupted`:m===`finished`?`Finished`:null].filter(Boolean).join(` `),className:`flex w-full min-w-0 cursor-pointer items-start gap-2 rounded-xl px-3 py-2 pr-11 text-left transition-colors focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none`,onClick:()=>{h(n)},children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l?(0,Z.jsx)(`div`,{className:`mb-1 truncate text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75`,children:l}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:n.title}),e?.memory_enabled&&n.pending_memory_suggestion_count>0?(0,Z.jsx)(DX,{tone:o?`default`:`muted`,className:`shrink-0`,"aria-label":uZ(n.pending_memory_suggestion_count),title:uZ(n.pending_memory_suggestion_count),children:n.pending_memory_suggestion_count}):null]}),c?(0,Z.jsx)(`div`,{className:W(`mt-0.5 line-clamp-1 text-xs leading-4`,o?`text-foreground/70`:`text-muted-foreground`),children:c}):null,n.target_available===!1?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-1 text-[11px] leading-4 text-amber-200/90`,children:n.target_unavailable_reason??`Target unavailable`}):null]}),(0,Z.jsx)(lX,{state:g,className:`mt-1`})]})}),(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Delete chat session`,className:W(`absolute top-2 right-2 h-7 w-7 shrink-0 rounded-md border border-transparent text-muted-foreground transition-all duration-150 hover:border-border/70 hover:bg-card/80 hover:text-foreground focus-visible:border-border/70 focus-visible:bg-card/80 focus-visible:text-foreground`,`opacity-100 sm:opacity-0 sm:pointer-events-none sm:group-hover:pointer-events-auto sm:group-focus-within:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,f&&`sm:disabled:opacity-0 sm:group-hover:disabled:opacity-50 sm:group-focus-within:disabled:opacity-50`,(o||d)&&`sm:pointer-events-auto sm:opacity-100 sm:disabled:opacity-50`,u&&`cursor-not-allowed text-muted-foreground/50 hover:border-transparent hover:bg-transparent hover:text-muted-foreground/50 focus-visible:border-transparent focus-visible:bg-transparent focus-visible:text-muted-foreground/50`),title:u??`Delete ${n.title}`,disabled:f,onClick:e=>{e.stopPropagation(),p(n.id)},children:(0,Z.jsx)(Ld,{className:`h-4 w-4`})})]},n.id)})]},n.key))})})]}):(0,Z.jsxs)(`div`,{"data-testid":`chat-sessions-rail`,className:`flex h-full w-full flex-col items-center gap-2 bg-background/80 py-3`,children:[(0,Z.jsx)(cu,{content:(0,Z.jsx)(_Z,{label:`Start new session`,modifierLabel:n,keys:[tZ]}),side:`right`,children:(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,"aria-label":`New session`,className:`h-9 w-9`,onClick:m,disabled:o||u,children:(0,Z.jsx)(Td,{className:`h-4 w-4`})})}),(0,Z.jsx)(U,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Open sessions panel`,"aria-expanded":l,className:`h-9 w-9`,onClick:g,children:(0,Z.jsx)(cX,{className:`h-4 w-4`})})]})}),JZ=({proposals:e,isApplying:t,onApply:n})=>e.status===`applied`?(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:`Tickets created`}),(0,Z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Created `,e.created_tickets.length,` ticket`,e.created_tickets.length===1?``:`s`,` from this proposal.`]}),e.created_tickets.length>0?(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1 text-foreground`,children:e.created_tickets.map(e=>(0,Z.jsx)(`li`,{children:e.title},e.ticket_id))}):null]}):(0,Z.jsxs)(`div`,{className:`w-full rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-3 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:`Proposed tickets`}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:`Review these tickets before adding them to the board.`}),(0,Z.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e.tickets.map(e=>(0,Z.jsxs)(`li`,{className:`rounded border border-border/60 bg-background/80 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-muted-foreground`,children:e.description})]},e.key))}),e.dependencies.length>0?(0,Z.jsxs)(`div`,{className:`mt-3 text-muted-foreground`,children:[`Dependencies: `,e.dependencies.map(e=>`${e.blocker_key} -> ${e.dependent_key}`).join(`, `)]}):null,(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(U,{type:`button`,size:`sm`,onClick:n,disabled:t,children:t?`Creating tickets...`:`Create tickets`})})]}),YZ=({activeProjectId:e,activeProject:t,activeProjectBranchState:n=null,activeTool:r,onRestoreSessionTarget:i,onReviewCapabilityChange:a,isExternallyResizing:o=!1,showChangesPanel:s=!0})=>{let[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(()=>FZ({projectId:e,tool:r})),[b,x]=(0,X.useState)({}),[S,C]=(0,X.useState)([]),[w,T]=(0,X.useState)([]),[E,D]=(0,X.useState)(``),[O,k]=(0,X.useState)(``),[A,j]=(0,X.useState)([]),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),[I,L]=(0,X.useState)(!1),[R,ee]=(0,X.useState)(!1),[z,B]=(0,X.useState)(!1),[V,te]=(0,X.useState)(null),[ne,re]=(0,X.useState)(null),[ae,oe]=(0,X.useState)(null),[se,H]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(!1),[ue,de]=(0,X.useState)(null),[G,fe]=(0,X.useState)([]),[K,pe]=(0,X.useState)(!1),[me,he]=(0,X.useState)(!1),[_e,ve]=(0,X.useState)(0),[ye,be]=(0,X.useState)(FX),[xe,Se]=(0,X.useState)(()=>AZ(e).isOpen),[we,Te]=(0,X.useState)(()=>kZ(e).isOpen),[Ee,De]=(0,X.useState)(!1),[Oe,ke]=(0,X.useState)(!1),[Ae,je]=(0,X.useState)(()=>kZ(e).width),[Me,Ne]=(0,X.useState)(0),[J,Pe]=(0,X.useState)(null),[Fe,Ie]=(0,X.useState)(()=>new Set),Le=(0,X.useRef)({model:``,variant:``,skills:[],showModelSelector:!1}),Re=(0,X.useRef)(!1),ze=(0,X.useRef)(null),Be=(0,X.useRef)(null),Ve=(0,X.useRef)(null),He=(0,X.useRef)(null),Ue=(0,X.useRef)(null),We=(0,X.useRef)(null),Ge=(0,X.useRef)(null),Ke=(0,X.useRef)(!1),Y=(0,X.useRef)(!1),qe=(0,X.useRef)(0),Je=(0,X.useRef)(XX),Ye=(0,X.useRef)(XX),Xe=(0,X.useRef)(!1),Ze=(0,X.useRef)(0),Qe=(0,X.useRef)({id:null,status:null}),$e=(0,X.useRef)(new Map),et=(0,X.useRef)({}),tt=(0,X.useRef)(new Set),nt=(0,X.useRef)(!1),rt=e?wZ({projectId:e,tool:g?r:f?.tool??r,chatSessionId:g?null:u}):null,it=rt?b[rt]??``:``,at=g?r:f?.tool??r;(0,X.useEffect)(()=>{Re.current=g},[g]),(0,X.useEffect)(()=>{et.current=b},[b]),(0,X.useEffect)(()=>{if(!rt||tt.current.has(rt))return;tt.current.add(rt);let e=DZ(rt);e&&x(t=>Object.prototype.hasOwnProperty.call(t,rt)?t:{...t,[rt]:e})},[rt]),(0,X.useEffect)(()=>{!rt||!Object.prototype.hasOwnProperty.call(b,rt)||OZ({storageKey:rt,value:b[rt]??``})},[rt,b]),(0,X.useEffect)(()=>{ze.current=u},[u]),(0,X.useEffect)(()=>{if(!nt.current){nt.current=!0;return}let t=kZ(e),n=AZ(e);Re.current=!1,Xe.current=!1,tt.current=new Set,d(null),p(null),_(!1),x({}),te(null),re(null),oe(null),Pe(null),fe([]),he(!1),F(!1),be(FX()),Ie(new Set),$e.current=new Map,Ye.current=t.width,Se(n.isOpen),je(t.width),Te(t.isOpen)},[e]),(0,X.useEffect)(()=>{Ee||(Ye.current=Ae,He.current&&(He.current.style.setProperty(`--chat-changes-panel-width`,`${Ae}px`),He.current.setAttribute(`data-desktop-width`,String(Ae))))},[Ae,Ee]),(0,X.useEffect)(()=>{if(!s||!Be.current)return;let e=Be.current.getBoundingClientRect().width;if(e<=0)return;let t=aZ(Ae,e);t!==Ae&&(Ye.current=t,je(t))},[Ae,s]),(0,X.useEffect)(()=>{MZ({projectId:e,isOpen:xe})},[e,xe]),(0,X.useEffect)(()=>{s&&jZ({projectId:e,isOpen:we,width:Ae})},[e,Ae,we,s]),(0,X.useEffect)(()=>{he(!1)},[u,g]);let ot=(0,X.useCallback)(e=>{let t=WX(e);l(e=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return BX([...e,t]);let r=[...e];return r[n]=t,BX(r)})},[]),st=(0,X.useCallback)(t=>{let n=ze.current,i=e?wZ({projectId:e,tool:r,chatSessionId:t}):null;x(e=>{if(!i||!Object.prototype.hasOwnProperty.call(e,i))return e;let t={...e};return delete t[i],t}),OZ({storageKey:i,value:``}),l(e=>{let r=e.filter(e=>e.id!==t);if(n===t){let e=r[0]??null;d(e?.id??null),p(null),_(e===null),fe([]),pe(!1),he(!1)}return r}),Ie(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n}),Pe(e=>e?.sessionId===t?null:e),te(e=>e===t?null:e),re(e=>e===t?null:e),oe(e=>e===t?null:e)},[e,r]),ct=(0,X.useCallback)((e,t)=>{e&&x(n=>n[e]===t?n:{...n,[e]:t})},[]),lt=(0,X.useCallback)(e=>{e&&(x(t=>t[e]===``?t:{...t,[e]:``}),OZ({storageKey:e,value:``}))},[]),ut=(0,X.useCallback)(({fromStorageKey:e,toStorageKey:t})=>{if(!e||!t||e===t)return;let n=Object.prototype.hasOwnProperty.call(et.current,e)?et.current[e]??``:DZ(e);x(r=>{let i={...r,[t]:n};return delete i[e],i}),OZ({storageKey:t,value:n}),OZ({storageKey:e,value:``})},[]),dt=(0,X.useCallback)((e,t)=>{l(n=>{let r=n.findIndex(t=>t.id===e);if(r===-1)return n;let i=n[r];if(i.pending_memory_suggestion_count===t)return n;let a=[...n];return a[r]={...i,pending_memory_suggestion_count:t},a}),p(n=>!n||n.id!==e||n.pending_memory_suggestion_count===t?n:{...n,pending_memory_suggestion_count:t})},[]),ft=(0,X.useCallback)(async r=>{if(!e){l([]),d(null),p(null),_(!1),F(!1);return}N(!0);try{let i=await nx(e,r);if(r?.aborted)return;let a=BX(i.map(WX)),o=a[0]??null,s=t?.active_target_kind===`bundle`||n?.status!==`loading`;l(a),d(e=>Re.current?null:e&&a.some(t=>t.id===e)?e:e?a[0]?.id??null:Xe.current?null:o?s?(Xe.current=!0,HZ({activeProject:t,activeProjectBranchState:n,session:o})?o.id:null):null:(Xe.current=!0,null)),a.length===0&&_(!0)}catch(e){ge(e)||Q.error(e instanceof Error?e.message:`Unable to load chat sessions right now.`)}finally{r?.aborted||(N(!1),F(!0))}},[t,n,e]),pt=(0,X.useCallback)(async(t,n)=>{if(!e){p(null);return}L(!0);try{let r=await ix(e,t,n);if(n?.aborted)return;p(r),ot(r)}catch(e){ge(e)||Q.error(e instanceof Error?e.message:`Unable to load the chat session right now.`)}finally{n?.aborted||L(!1)}},[e,ot]),mt=(0,X.useCallback)(async(n,r)=>{if(!e||!t?.memory_enabled){fe([]),pe(!1);return}pe(!0);try{let t=await q(e,null,r,n);if(r?.aborted)return;fe(t.suggestions),dt(n,t.suggestions.length)}catch(e){ge(e)||Q.error(e instanceof Error?e.message:`Unable to load chat memory suggestions right now.`)}finally{r?.aborted||pe(!1)}},[t?.memory_enabled,e,dt]),ht=(0,X.useCallback)(()=>{fe(e=>{let t=e.length>0?e.slice(0,-1):e;return u&&dt(u,t.length),t}),ve(e=>e+1),ft(),u&&pt(u)},[u,pt,ft,dt]);(0,X.useEffect)(()=>{let e=new AbortController;return ft(e.signal),()=>{e.abort()}},[ft]),(0,X.useEffect)(()=>{if(Re.current||g||u||Xe.current||c.length===0||t?.active_target_kind!==`bundle`&&n?.status===`loading`)return;Xe.current=!0;let e=c[0]??null;e&&HZ({activeProject:t,activeProjectBranchState:n,session:e})&&d(e.id)},[t,n,u,g,c]),(0,X.useEffect)(()=>{if(at!==`opencode`){C([]),T([]),le(!1);return}let t=new AbortController;return(async()=>{le(!0);try{let[n,r]=await Promise.all([qt(at,t.signal),yw(at,t.signal,e)]);C(n),T(r)}catch(e){ge(e)||(C(e=>e),T(e=>e))}finally{t.signal.aborted||le(!1)}})(),()=>{t.abort()}},[e,at]),(0,X.useEffect)(()=>{if(g||!u){p(null);return}if(f?.id===u)return;p(null);let e=new AbortController;return pt(u,e.signal),()=>{e.abort()}},[f,u,g,pt]),(0,X.useEffect)(()=>{if(!t?.memory_enabled||g||!u){fe([]),pe(!1);return}let e=new AbortController;return mt(u,e.signal),()=>{e.abort()}},[t?.memory_enabled,u,g,mt,_e]),(0,X.useEffect)(()=>{!me||K||G.length>0||he(!1)},[K,me,G.length]),(0,X.useEffect)(()=>{if(!u||f?.agent_status!==`running`)return;let e=new AbortController,t=window.setInterval(()=>{Promise.all([ft(e.signal),pt(u,e.signal)])},GX);return()=>{e.abort(),window.clearInterval(t)}},[f?.agent_status,u,pt,ft]),(0,X.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||(t.id===u&&p(t),VZ(t)&&ot(t))},n=t=>{!t||t.project_id!==e||st(t.id)};return PW.on(`chat-session:created`,t),PW.on(`chat-session:updated`,t),PW.on(`chat-session:deleted`,n),()=>{PW.off(`chat-session:created`,t),PW.off(`chat-session:updated`,t),PW.off(`chat-session:deleted`,n)}},[e,u,st,ot]),(0,X.useEffect)(()=>{g&&y(FZ({projectId:e,tool:r}))},[e,r,g]),(0,X.useEffect)(()=>{if(at!==`opencode`){D(``),k(``),j([]);return}if(g){let n=IZ({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:at,availableModels:S});D(n.model),k(n.variant),j([]);return}D(f?.model??t?.helper_model??``),k(f?.variant??t?.helper_variant??``),j(f?.skills??[])},[e,t?.helper_model,t?.helper_variant,f?.id,f?.model,f?.skills,f?.variant,S,at,g]),(0,X.useEffect)(()=>{let e=S.find(e=>e.id===E)??null;k(t=>e?e.variants.includes(t)?t:``:t)},[S,E]),(0,X.useEffect)(()=>{if(at!==`opencode`||!g||!E||O)return;let n=IZ({activeProjectId:e,helperModel:t?.helper_model??null,helperVariant:t?.helper_variant??null,activeTool:at,availableModels:S});n.model===E&&n.variant&&k(n.variant)},[e,t?.helper_model,t?.helper_variant,at,S,g,E,O]),(0,X.useEffect)(()=>{if(!V)return;let e=f?.id===V?f:c.find(e=>e.id===V)??null;(!e||e.agent_status!==`running`)&&te(null)},[f,V,c]),(0,X.useEffect)(()=>{let e=Qe.current,n=f?.id??null,r=f?.agent_status??null;e.id===n&&e.status===`running`&&r===`done`&&t?.memory_enabled&&n&&ve(e=>e+1),Qe.current={id:n,status:r}},[t?.memory_enabled,e,f?.agent_status,f?.id,f?.title]),(0,X.useEffect)(()=>{u&&Ie(e=>{if(!e.has(u))return e;let t=new Set(e);return t.delete(u),t})},[u]),(0,X.useEffect)(()=>{J&&J.sessionId!==u&&Pe(null)},[u,J]),(0,X.useEffect)(()=>{let e=$e.current,t=new Map,n=[];for(let r of c){let i=e.get(r.id)??null,a=r.agent_status??null;i===`running`&&a===`done`&&r.id!==u&&n.push(r),t.set(r.id,a)}$e.current=t,Ie(e=>{let t=new Set(e),r=!1,i=new Set(c.map(e=>e.id));for(let e of t)i.has(e)||(t.delete(e),r=!0);for(let e of c){let i=e.agent_status??null,a=n.some(t=>t.id===e.id);if((e.id===u||i!==`done`)&&t.delete(e.id)){r=!0;continue}a&&!t.has(e.id)&&(t.add(e.id),r=!0)}return r?t:e})},[e,u,c]);let gt=(0,X.useMemo)(()=>new Map(S.map(e=>[e.id,e.label])),[S]),_t=(0,X.useMemo)(()=>UX(c),[c]),vt=(0,X.useMemo)(()=>ne?c.find(e=>e.id===ne)??(f?.id===ne?f:null):null,[f,ne,c]);(0,X.useEffect)(()=>{ne&&!vt&&re(null)},[ne,vt]);let yt=(0,X.useMemo)(()=>f?vZ({modelLabel:sZ({availableModelsById:gt,model:f.model}),tool:f.tool}):null,[f,gt]),bt=(0,X.useMemo)(()=>f?(f.messages??[]).map(e=>({id:e.id,role:e.role,kind:e.kind,content:e.content,ticket_proposals:e.ticket_proposals??null,created_at:e.created_at,displayTitle:e.role===`assistant`?yt??oZ(f.tool):yZ()})):[],[f,yt]),xt=f?.id&&f.agent_status===`running`&&J?.sessionId===f.id?J.turnKey:null,St=at===`opencode`&&S.length>0,Ct=at===`opencode`&&!St&&ce;(0,X.useEffect)(()=>{Le.current={model:E,variant:O,skills:A,showModelSelector:St}},[E,A,O,St]);let wt=(0,X.useMemo)(()=>S.find(e=>e.id===E)??null,[S,E]),Tt=g?v:f?.mode??`build`,Et=g?`New chat`:f?.title??`Chat`,Dt=g?r:f?.tool??r,Ot=(0,X.useMemo)(()=>hZ(),[]),kt=St?E||null:f?.model??null,At=sZ({availableModelsById:gt,model:kt}),jt=(0,X.useMemo)(()=>{let e=f?.usage_snapshot_total_tokens??null;if(e===null)return null;let t=SZ({tool:Dt,model:kt,availableModels:S,fallbackContextWindow:f?.usage_snapshot_context_window??null});if(t===null)return null;let n=xZ({totalTokens:e,contextWindow:t});return n===null?null:`${bZ(e)} (${n}%)`},[f?.usage_snapshot_context_window,f?.usage_snapshot_total_tokens,S,kt,Dt]),Mt=g?`draft:${e??`none`}:${r}`:f?.id,Nt=(0,X.useCallback)(()=>{Re.current=!0,_(!0),y(FZ({projectId:e,tool:r})),h(null),d(null),p(null),te(null),Pe(null)},[e,r]),Pt=(0,X.useCallback)((e,t=null)=>{Re.current=!1,_(!1),h(null),d(e),p(t)},[]),Ft=(0,X.useCallback)(async()=>{if(!(!f||!i)){h(f.id);try{await i(f)}catch(e){Q.error(e instanceof Error?e.message:`Unable to restore the chat target right now.`)}finally{h(e=>e===f.id?null:e)}}},[f,i]),It=!!(f&&f.target_available!==!1&&!g&&!HZ({activeProject:t,activeProjectBranchState:n,session:f})),Lt=It&&f?`This session targets ${WZ(f)}, but the current target is ${GZ({activeProject:t,activeProjectBranchState:n})}. Restore the session target to continue.`:null,Rt=It&&m===null,zt=(0,X.useCallback)(async r=>{h(r.id);let a=r;if(e)try{let t=await ix(e,r.id);a=t,ot(t)}catch(e){Q.error(e instanceof Error?e.message:`Unable to load the chat session right now.`),h(e=>e===r.id?null:e);return}if(a.target_available===!1){Pt(a.id,a);return}if(!HZ({activeProject:t,activeProjectBranchState:n,session:a})&&i)try{if(!await i(a)){h(e=>e===a.id?null:e);return}}catch(e){Q.error(e instanceof Error?e.message:`Unable to restore the chat target right now.`),h(e=>e===a.id?null:e);return}Pt(a.id,a)},[t,n,e,i,Pt,ot]),Bt=(0,X.useCallback)(()=>{Ne(e=>e+1)},[]),Vt=(0,X.useCallback)(async t=>{if(g){let n=Le.current;y(t),PZ({projectId:e,tool:r,model:n.showModelSelector&&n.model||null,variant:n.showModelSelector&&n.model&&n.variant||null,mode:t}),Bt();return}if(!(!e||!f||f.mode===t||se)){H(!0);try{let n=await ax(e,f.id,{mode:t});PZ({projectId:e,tool:n.tool,model:n.model,variant:n.variant,mode:n.mode}),p(n),ot(n),Bt()}catch(e){Q.error(e instanceof Error?e.message:`Unable to update the chat mode right now.`)}finally{H(!1)}}},[e,f,r,Bt,g,se,ot]),Ht=(0,X.useCallback)(async({instruction:t,targetSession:n})=>{if(!e)return null;let r=Le.current;Ze.current+=1;let i={sessionId:n.id,turnKey:`${n.id}:${Ze.current}`};Pe(i);try{let i=await ox(e,n.id,{instruction:t,tool:n.tool,model:r.showModelSelector&&r.model||null,variant:r.showModelSelector&&r.model&&r.variant||null,skills:r.showModelSelector?r.skills:[]});return PZ({projectId:e,tool:i.tool,model:i.model,variant:i.variant,mode:i.mode}),Re.current=!1,p(i),d(i.id),_(!1),ot(i),i}catch(e){throw Pe(e=>e?.turnKey===i.turnKey?null:e),e}},[e,ot]),Ut=(0,X.useCallback)(async()=>{if(!e)return null;let t=Le.current,n=await rx(e,{mode:Tt,tool:r,model:t.showModelSelector&&t.model||null,variant:t.showModelSelector&&t.model&&t.variant||null,skills:t.showModelSelector?t.skills:[]});return Re.current=!1,_(!1),d(n.id),p(n),n},[e,r,Tt]),Wt=(0,X.useCallback)(async t=>{if(!e||z||R||f?.agent_status===`running`||f?.target_available===!1||Rt)return!1;let n=t.trim();if(!n)return!1;B(!0);let r=null,i=f,a=e&&f?wZ({projectId:e,tool:f.tool,chatSessionId:f.id}):null;try{let t=f;if(t||(ee(!0),r=await Ut(),t=r,a=e&&r?wZ({projectId:e,tool:r.tool,chatSessionId:r.id}):null,ut({fromStorageKey:rt,toStorageKey:a})),!t)return!1;lt(a??rt);let i=BZ({session:t,instruction:n,createdAt:new Date().toISOString()});p(i),d(i.id),ot(i);let o=await Ht({instruction:n,targetSession:t});return lt(o&&e?wZ({projectId:e,tool:o.tool,chatSessionId:o.id}):a),!0}catch(e){throw ct(a??rt,n),r?(p(r),d(r.id),_(!1),ot(r)):i&&(p(i),ot(i)),e}finally{ee(!1),B(!1)}},[e,f,lt,Ut,rt,R,z,ut,Ht,ct,Rt,ot]),Gt=(0,X.useCallback)(async e=>{await Wt(e)},[Wt]),Kt=!!(e&&(g||f&&f.target_available!==!1&&!Rt)),Jt=f?.agent_status===`running`,Yt=f?.agent_status===`stopped`,Xt=Jt&&V===f?.id,Zt=Kt&&!Jt&&!z&&!R,Qt=Kt?f?.target_available===!1?f.target_unavailable_reason??`Target unavailable for this chat session.`:Rt?Lt??`Restore the session target to continue.`:Jt?`Wait for the current chat turn to finish before sending review comments.`:R||z?`Wait for the current chat prompt to finish sending before submitting review comments.`:null:`Open or create a chat session to send review comments.`,$t=(0,X.useCallback)(async()=>{if(!(!e||!f||f.agent_status!==`running`||Xt)){te(f.id);try{await sx(e,f.id)}catch(e){te(e=>e===f.id?null:e),Q.error(e instanceof Error?e.message:`Unable to interrupt the chat response right now.`)}}},[e,f,Xt]),en=(0,X.useCallback)(async()=>{if(!(!e||!vt||ae)){oe(vt.id);try{await cx(e,vt.id),st(vt.id)}catch(e){Q.error(e instanceof Error?e.message:`Unable to delete the chat session right now.`),oe(e=>e===vt.id?null:e)}}},[e,ae,st,vt]),tn=(0,X.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(lu,{value:Tt,items:[{value:`plan`,label:`Plan`,activeVariant:`ghost`,activeClassName:`border-transparent bg-sky-300 text-[#07111a] shadow-[0_10px_30px_rgba(125,211,252,0.24)] hover:bg-sky-200 hover:text-[#07111a]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:(0,Z.jsx)(_Z,{label:`Switch to Plan`,modifierLabel:Ot,keys:[eZ]})},{value:`build`,label:`Build`,activeVariant:`ghost`,activeClassName:`border-transparent bg-emerald-400 text-[#07130d] shadow-[0_10px_30px_rgba(16,185,129,0.28)] hover:bg-emerald-300 hover:text-[#07130d]`,inactiveClassName:`border-transparent text-white/85 hover:bg-white/8 hover:text-white`,inactiveTooltip:(0,Z.jsx)(_Z,{label:`Switch to Build`,modifierLabel:Ot,keys:[eZ]})}],disabled:se,onChange:e=>{Vt(e)}}),Jt?(0,Z.jsxs)(U,{type:`button`,size:`sm`,variant:`outline`,className:`gap-2`,disabled:Xt,onClick:()=>{$t()},children:[Xt?(0,Z.jsx)(ie,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(Su,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:Xt?`Interrupting...`:`Interrupt`})]}):null]}),[Ot,Tt,$t,Vt,Xt,Jt,se]),nn=(0,X.useMemo)(()=>St?(0,Z.jsx)(mP,{model:E,variant:O,skills:A,showModelSelector:!0,showSkillsSelector:!0,availableModels:S,availableSkills:w,selectedModel:wt,onModelChange:e=>{let t=S.find(t=>t.id===e)??null;D(e),k(e=>t&&t.variants.includes(e)?e:``)},onVariantChange:k,onSkillsChange:j,modelSelectId:`project-chat-model-selector`,variantSelectId:`project-chat-variant-selector`,skillsSelectId:`project-chat-skills-selector`,disabled:z||R||f?.agent_status===`running`}):Ct?(0,Z.jsx)(pP,{dataTestId:`chat-model-selector-skeleton`}):null,[f?.agent_status,S,w,R,z,wt,E,A,O,St,Ct]);(0,X.useEffect)(()=>{if(a)return()=>{a(null)}},[a]),(0,X.useEffect)(()=>{if(a){if(!e||!Kt){a(null);return}a({chatSessionId:f?.id??null,canSubmitReviewPrompt:Zt,reviewSubmitDisabledReason:Qt,mode:Tt,onModeChange:Vt,isUpdatingMode:se,promptPlaceholder:lZ(Tt),promptComposerControls:tn,promptComposerInlineControls:nn,submitPrompt:Gt})}},[e,f,Zt,Tt,Vt,Gt,Kt,se,a,tn,nn,Qt]);let rn=async()=>{if(it.trim())try{if(!await Wt(it))return}catch(e){Q.error(e instanceof Error?e.message:`Unable to send the chat prompt right now.`)}},an=e=>{e.key!==`Enter`||e.shiftKey||f?.agent_status===`running`||R||z||(e.preventDefault(),rn())};(0,X.useEffect)(()=>{let t=t=>{if(pZ(t)){if(!e||R||z)return;t.preventDefault(),Nt(),Bt();return}fZ(t)&&(!e||!g&&!f||(t.preventDefault(),Vt(dZ(Tt))))};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,f,Tt,Bt,Nt,Vt,R,g,z]);let on=(0,X.useCallback)(async t=>{if(!(!e||!f)){de(t);try{let n=await dx(e,f.id,t);p(n.chatSession),ot(n.chatSession),Q.success(`Created ${n.created_tickets.length} ticket${n.created_tickets.length===1?``:`s`} from chat.`)}catch(e){Q.error(e instanceof Error?e.message:`Unable to create tickets from the chat proposal right now.`)}finally{de(e=>e===t?null:e)}}},[e,f,ot]),sn=(0,X.useCallback)(e=>{if(!Be.current)return;let t=Be.current.getBoundingClientRect().width,n=aZ(e,t);Ye.current=n,He.current&&(He.current.style.setProperty(`--chat-changes-panel-width`,`${n}px`),He.current.setAttribute(`data-desktop-width`,String(n)))},[]),cn=(0,X.useCallback)(()=>{Ge.current?.(),Ge.current=null},[]),ln=(0,X.useCallback)(e=>{let t=Ue.current,n=We.current,r=Ke.current;if(t!==null){if(Ue.current=null,We.current=null,Ke.current=!1,De(!1),ke(!1),cn(),e!==null&&typeof Ve.current?.hasPointerCapture==`function`&&Ve.current.hasPointerCapture(e)&&typeof Ve.current.releasePointerCapture==`function`&&Ve.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;je(Ye.current),Te(!0);return}je(Ye.current)}},[cn]),un=(0,X.useCallback)((e,t)=>{if(Ue.current!==e)return;let n=t-qe.current,r=Je.current-n;if(We.current===`collapsed`){if(!Ke.current&&r<$X)return;Ke.current||(Ke.current=!0,Y.current=!0,ke(!0),De(!0))}sn(r)},[sn]),dn=(0,X.useCallback)((e,t)=>{if(Ue.current===e){if(t!==null&&(We.current===`inline`||Ke.current)){let e=t-qe.current;sn(Je.current-e)}ln(e)}},[ln,sn]),fn=(0,X.useCallback)(e=>{if(!s)return;e.preventDefault(),Ue.current=e.pointerId,We.current=we?`inline`:`collapsed`,Ke.current=!1,Y.current=!1,qe.current=e.clientX,Je.current=we?Ye.current:0,De(we),cn(),typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=e=>{un(e.pointerId,e.clientX)},n=e=>{dn(e.pointerId,e.clientX)},r=e=>{dn(e.pointerId,e.clientX)};window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,n),window.addEventListener(`pointercancel`,r),Ge.current=()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,n),window.removeEventListener(`pointercancel`,r)}},[dn,un,we,s,cn]),pn=(0,X.useCallback)(e=>{un(e.pointerId,e.clientX)},[un]),mn=(0,X.useCallback)(e=>{dn(e.pointerId,e.clientX)},[dn]),hn=(0,X.useCallback)(e=>{dn(e.pointerId,e.clientX)},[dn]),gn=(0,X.useCallback)(e=>{Ue.current===e.pointerId&&ln(e.pointerId)},[ln]),_n=(0,X.useCallback)(()=>{if(Y.current){Y.current=!1;return}Te(!0)},[]),vn=(0,X.useCallback)(()=>{Te(!1)},[]),yn=(0,X.useCallback)(e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),_n())},[_n]);(0,X.useEffect)(()=>{s||(Ue.current=null,We.current=null,Ke.current=!1,Y.current=!1,De(!1),ke(!1),cn())},[s,cn]),(0,X.useEffect)(()=>()=>{cn()},[cn]);let bn=!!u,xn=f?.target_available===!1,Sn=xn?f?.target_unavailable_reason??`Target unavailable for this chat session.`:null,Cn=g||!!(f&&f.target_available!==!1&&!Rt),wn=!!(t?.memory_enabled&&f&&(G.length>0||K)),Tn=s&&(g||bn)&&!xn&&!Rt,En=Tn&&!we&&!Oe,Dn=Tn&&(we||Oe),On=`${Mt??`none`}:${Tn?`changes-enabled`:`changes-disabled`}:${Dn?`panel-visible`:`panel-hidden`}`,kn=f||g?(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(TX,{projectId:e,messages:f?bt:[],internalLog:f?.agent_log??null,pendingAgentTitle:yt,streamingResponse:f?.streaming_response??null,isRunning:f?.agent_status===`running`,isLoading:!g&&I,canShowComposer:Cn,isExternallyResizing:o||Ee,pendingAgentRevealKey:xt,pendingAgentRevealDelayMs:iZ,composerFocusNonce:Me,header:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,children:Et}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[g?null:(0,Z.jsx)(NT,{tool:f?.tool,className:`text-[11px]`}),At?(0,Z.jsx)(`p`,{children:At}):null,Yt?(0,Z.jsx)(`div`,{className:`inline-flex items-center rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100`,children:`Interrupted`}):null,jt?(0,Z.jsx)(`div`,{"data-testid":`chat-context-usage-badge`,className:`inline-flex items-center rounded-full border border-border/80 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-foreground`,children:jt}):null]})]}),wn?(0,Z.jsx)(U,{type:`button`,size:`xs`,variant:`outline`,className:`gap-2`,onClick:()=>he(!0),children:K?`Loading memory...`:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`Memory suggestions`}),(0,Z.jsx)(DX,{children:G.length})]})}):null]}),Rt&&Lt?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{children:Lt}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{Ft()},children:`Switch back`}),(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`ghost`,onClick:Nt,children:`New session`})]})]})}):null,xn&&Sn?(0,Z.jsx)(`div`,{className:`w-fit max-w-md rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-50`,children:Sn}):null]}),composerControls:tn,composerInlineControls:nn,composerTheme:Tt,layoutKey:Mt,scrollLayoutKey:On,followUpPrompt:it,followUpPlaceholder:lZ(Tt),emptyStateText:null,renderMessageFooter:e=>e.ticket_proposals?(0,Z.jsx)(JZ,{proposals:e.ticket_proposals,isApplying:ue===e.id,onApply:()=>{on(e.id)}}):null,isSendingFollowUp:z||R,followUpDisabledReason:xn?Sn??void 0:f?.agent_status===`running`?`Wait for the current chat turn to finish.`:void 0,onFollowUpPromptChange:e=>{ct(rt,e)},onFollowUpKeyDown:an,onFollowUpSubmit:()=>{rn()}})}):bn?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:`Loading chat session...`}):!P||M?(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-sm text-muted-foreground`,children:`Loading chat sessions...`}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6`,children:(0,Z.jsxs)(kd,{className:`w-full max-w-lg border-dashed border-border/70 bg-card/40`,children:[(0,Z.jsxs)(Ad,{children:[(0,Z.jsx)(jd,{children:`No session selected`}),(0,Z.jsx)(Md,{children:`Select a chat session to restore its saved target, or start a new session on the current target.`})]}),(0,Z.jsx)(Pd,{children:(0,Z.jsx)(U,{type:`button`,onClick:Nt,disabled:!e||R||z,children:`Start new session`})})]})}),An=Tn?(0,Z.jsx)(`div`,{ref:Ve,"aria-label":En?`Open diff`:`Resize diff panel`,"aria-orientation":En?void 0:`vertical`,className:W(En?`group flex h-8 w-full shrink-0 touch-none select-none items-center justify-center border-t border-border/70 bg-background/90 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground xl:h-auto xl:w-7 xl:cursor-col-resize xl:border-l xl:border-t-0`:`group hidden w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 transition-colors xl:flex`,Ee&&!En&&`bg-background`),"data-testid":En?`collapsed-changes-rail`:void 0,onLostPointerCapture:gn,onPointerCancel:hn,onPointerDown:fn,onPointerMove:pn,onPointerUp:mn,onClick:En?_n:void 0,onKeyDown:En?yn:void 0,role:En?`button`:`separator`,tabIndex:En?0:void 0,children:En?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`hidden h-full w-full items-center justify-center xl:flex`,children:(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(vu,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]})}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium xl:hidden`,children:[(0,Z.jsx)(vu,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:`Diff`})]})]}):(0,Z.jsx)(`div`,{className:W(`h-14 w-1.5 rounded-full transition-colors`,Ee?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`)})}):null,jn=me&&e&&t?.memory_enabled?(0,Z.jsx)(Ce,{onClose:()=>he(!1),overlayClassName:`bg-background/45 p-4 backdrop-blur-sm`,panelClassName:`w-full max-w-3xl`,renderContent:({closeButton:t})=>(0,Z.jsxs)(kd,{size:`sm`,className:`max-h-[calc(100vh-2rem)] w-full gap-0 overflow-hidden border-border/80 bg-card/95 shadow-2xl`,children:[(0,Z.jsxs)(Ad,{className:`border-b border-border/80 pb-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(jd,{children:`Memory suggestions`}),(0,Z.jsx)(Md,{children:`Review pending suggestions from this chat before saving them into project memory.`})]}),(0,Z.jsx)(Nd,{children:t})]}),(0,Z.jsx)(Pd,{className:`min-h-0 flex-1 overflow-y-auto pt-4`,children:(0,Z.jsx)(PX,{projectId:e,suggestions:G,emptyState:`No pending memory suggestions for this chat session.`,onSuggestionsChanged:ht})})]}),closeButtonLabel:`Close memory suggestions`}):null,Mn=vt?(0,Z.jsx)(KZ,{title:vt.title,isDeleting:ae===vt.id,onConfirm:()=>{en()},onCancel:()=>{ae!==vt.id&&re(null)}}):null;return(0,Z.jsxs)(`div`,{"data-testid":`chat-view-shell`,className:`relative flex min-h-0 flex-1 overflow-hidden border-t border-border/70`,children:[(0,Z.jsx)(qZ,{activeProject:t,activeSessionId:u,chatModeShortcutModifierLabel:Ot,confirmingDeleteSessionId:ne,deletingSessionId:ae,finishedBackgroundSessionIds:Fe,isCreatingSession:R||!e,isDraftOpen:g,isLoadingSessions:M,isOpen:xe,isSendingPrompt:z,sessionGroups:_t,sessions:c,onConfirmDeleteSession:e=>{re(e)},onDraftOpen:Nt,onSessionSelect:e=>{zt(e)},onToggleOpen:()=>{Se(e=>!e)}}),(0,Z.jsxs)(`div`,{ref:Be,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden xl:flex-row`,children:[(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:kn}),Tn?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(cu,{content:`Open diff`,disabled:!En,side:`left`,children:An}),Dn?(0,Z.jsx)(wX,{projectId:e,chatSessionId:g?null:u,canSubmitReviewPrompt:Zt,reviewSubmitDisabledReason:Qt,onSubmitReviewPrompt:Gt,state:ye,onStateChange:be,isResizing:Ee,onClose:vn,desktopWidth:Ae,panelElementRef:He}):null]}):null]}),jn,Mn]})},XZ=({className:e})=>(0,Z.jsx)(uc,{"aria-hidden":`true`,className:e}),ZZ=({activeProject:e})=>e?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,Z.jsx)(`div`,{className:`border-b border-border/60 pb-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground`,children:`Memory archive`}),(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:e.name})]})}),(0,Z.jsx)(wp,{mode:`edit`,projectId:e.id,memoryEnabled:e.memory_enabled,persistedMemoryEnabled:e.memory_enabled,onMemoryEnabledChange:()=>{},showActivationControls:!1,archiveLayout:!0})]})}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Select a project to view memory.`}),QZ=()=>({hasRunning:!1,hasFinishedUnseen:!1,hasErrorUnseen:!1}),$Z=()=>({board:QZ(),memory:QZ(),chat:QZ()}),eQ=(e,t)=>{let n=e[t];return!n.hasFinishedUnseen&&!n.hasErrorUnseen?e:{...e,[t]:{...n,hasFinishedUnseen:!1,hasErrorUnseen:!1}}},tQ=e=>({hasRunning:e.board.hasRunning||e.chat.hasRunning,hasFinishedUnseen:e.board.hasFinishedUnseen||e.chat.hasFinishedUnseen,hasErrorUnseen:e.board.hasErrorUnseen||e.chat.hasErrorUnseen}),nQ=e=>e.hasErrorUnseen?`error`:e.hasRunning?`running`:e.hasFinishedUnseen?`finished`:null,rQ=(e,t)=>t?null:nQ(e),iQ=320,aQ=.7,oQ=28,sQ=6,cQ=(e,t)=>{let n=Math.max(iQ,Math.round(t*aQ));return Math.max(iQ,Math.min(n,Math.round(e)))},lQ=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return[...e,t];let r=e.slice();return r[n]=t,r},uQ=(e,t)=>{if(t.type===`reset`)return $Z();if(t.type===`mark-workspace-visible`)return eQ(e,t.workspace);let n=e[t.workspace],r={...n,hasRunning:t.activity.hasRunning,hasFinishedUnseen:t.visibleWorkspace===t.workspace?!1:n.hasFinishedUnseen||t.activity.didFinish,hasErrorUnseen:t.visibleWorkspace===t.workspace?!1:n.hasErrorUnseen||t.activity.didError};return n.hasRunning===r.hasRunning&&n.hasFinishedUnseen===r.hasFinishedUnseen&&n.hasErrorUnseen===r.hasErrorUnseen?e:{...e,[t.workspace]:r}},dQ=({activeProjectId:e,onActivity:t})=>{let{tickets:n}=DY(),r=(0,X.useRef)(new Map);return(0,X.useEffect)(()=>{r.current=new Map},[e]),(0,X.useEffect)(()=>{let e=r.current,i=new Map,a=!1,o=!1;for(let t of n){let n=e.get(t.id)??null,r=t.agent_status??null;n===`running`&&r===`done`&&(a=!0),n===`running`&&r===`error`&&(o=!0),i.set(t.id,r)}r.current=i,t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:a,didError:o})},[t,n]),null},fQ=({activeProjectId:e,onActivity:t})=>{let[n,r]=(0,X.useState)([]),i=(0,X.useRef)(new Map);return(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController;return(async()=>{try{let n=await nx(e,t.signal);if(t.signal.aborted)return;r(n)}catch(e){ge(e)}})(),()=>{t.abort()}},[e]),(0,X.useEffect)(()=>{if(!e)return;let t=new AbortController,n=UK(()=>{document.visibilityState===`visible`&&nx(e,t.signal).then(e=>{t.signal.aborted||r(e)}).catch(e=>{ge(e)})});return()=>{t.abort(),n()}},[e]),(0,X.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.project_id!==e||r(e=>lQ(e,t))},n=t=>{!t||t.project_id!==e||r(e=>e.filter(e=>e.id!==t.id))};return PW.on(`chat-session:created`,t),PW.on(`chat-session:updated`,t),PW.on(`chat-session:deleted`,n),()=>{PW.off(`chat-session:created`,t),PW.off(`chat-session:updated`,t),PW.off(`chat-session:deleted`,n)}},[e]),(0,X.useEffect)(()=>{let r=i.current,a=new Map,o=[],s=!1;for(let e of n){let t=r.get(e.id)??null,n=e.agent_status??null;t===`running`&&n===`done`&&o.push(e),t===`running`&&n===`error`&&(s=!0),a.set(e.id,n)}i.current=a;for(let e of o)e.title&&yY(`Chat response ready`,e.title);o.length>0&&e&&BK(e),t({hasRunning:n.some(e=>e.agent_status===`running`),didFinish:o.length>0,didError:s})},[e,t,n]),null},pQ=({activeProjectId:e,activeProject:t=null,activeProjectBranchState:n=null,activeRun:r,activeTool:i,onRestoreChatSessionTarget:a,onChatReviewCapabilityChange:o,onPreviewReviewCapabilityChange:s,previewDisplayMode:c=`hidden`,previewPane:l=null,previewPaneWidth:u=480,isPreviewButtonDisabled:d=!1,previewButtonTitle:f,visibleWorkspace:p,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,onBoardLoadedProjectIdChange:_,onPreviewToggle:v,onPreviewPaneWidthChange:y,onRunStopped:b,onRunStatusChange:x,onWorkspaceActivityChange:S,onWorkspaceActivityEvent:C,refreshKey:w=0})=>{let T=(0,X.useRef)(null),E=(0,X.useRef)(null),D=(0,X.useRef)(null),O=(0,X.useRef)(null),k=(0,X.useRef)(!1),A=(0,X.useRef)(!1),j=(0,X.useRef)(0),M=(0,X.useRef)(u),N=(0,X.useRef)(u),P=p===`board`||p===`chat`,F=l!==null,[I,L]=(0,X.useState)(!1),[R,ee]=(0,X.useState)(!1),[z,B]=(0,X.useState)(u),[V,te]=(0,X.useReducer)(uQ,void 0,$Z),ne=P&&F&&c===`expanded`,re=P&&F&&c===`inline`,ie=P&&F&&c===`hidden`&&!R,ae=(re||R)&&!ne,oe=ne||ae,se=P&&F&&!ne,H=I?z:u,ce=p!==`chat`||!ae,U=e=>{let t=D.current,n=O.current,r=k.current;if(t!==null){if(D.current=null,O.current=null,k.current=!1,L(!1),ee(!1),e!==null&&E.current?.hasPointerCapture(e)&&E.current.releasePointerCapture(e),n===`collapsed`){if(!r)return;y?.(N.current),v?.();return}y?.(N.current)}},le=e=>{if(!T.current)return;let t=T.current.getBoundingClientRect().width,n=cQ(e,t);N.current=n,B(n)},ue=e=>{y&&(ie&&d||(e.preventDefault(),D.current=e.pointerId,O.current=ie?`collapsed`:`inline`,k.current=!1,A.current=!1,j.current=e.clientX,M.current=ie?0:N.current,L(!ie),e.currentTarget.setPointerCapture(e.pointerId)))},W=e=>{if(D.current!==e.pointerId)return;let t=e.clientX-j.current,n=M.current-t;if(O.current===`collapsed`){if(!k.current&&n<sQ)return;k.current||(k.current=!0,A.current=!0,ee(!0),L(!0))}le(n)},de=e=>{if(D.current===e.pointerId){if(O.current===`inline`||k.current){let t=e.clientX-j.current;le(M.current-t)}U(e.pointerId)}},G=e=>{D.current===e.pointerId&&U(e.pointerId)},fe=(0,X.useCallback)((e,t)=>{C?.(e,t),te({type:`update-workspace`,workspace:e,activity:t,visibleWorkspace:p})},[C,p]);(0,X.useEffect)(()=>{te({type:`reset`})},[e]),(0,X.useEffect)(()=>{p!==`memory`&&te({type:`mark-workspace-visible`,workspace:p})},[p]),(0,X.useEffect)(()=>{S?.(V)},[S,V]),(0,X.useEffect)(()=>{I||(N.current=u),!F&&(D.current=null,O.current=null,k.current=!1,A.current=!1,N.current=u)},[F,I,u]);let K=()=>{if(A.current){A.current=!1;return}d||v?.()};return(0,Z.jsx)(EY,{activeProjectId:e,refreshKey:w,onLoadedProjectIdChange:_,onProjectUsageChange:m,onBundlesChange:h,onBundlesLoadingChange:g,children:(0,Z.jsxs)(`div`,{ref:T,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(dQ,{activeProjectId:e,onActivity:e=>{fe(`board`,e)}}),(0,Z.jsx)(fQ,{activeProjectId:e,onActivity:e=>{fe(`chat`,e)}}),p===`memory`?(0,Z.jsx)(`div`,{id:`project-workspace-panel-memory`,role:`tabpanel`,"aria-labelledby":`project-workspace-tab-memory`,className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(ZZ,{activeProject:t})}):(0,Z.jsxs)(`div`,{id:p===`chat`?`project-workspace-panel-chat`:`project-workspace-panel-board`,role:`tabpanel`,"aria-labelledby":p===`chat`?`project-workspace-tab-chat`:`project-workspace-tab-board`,className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:p===`chat`?(0,Z.jsx)(YZ,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeTool:i,isExternallyResizing:I,onRestoreSessionTarget:a,onReviewCapabilityChange:o,showChangesPanel:ce}):(0,Z.jsx)(oX,{activeProjectId:e,activeProject:t,activeProjectBranchState:n,activeRun:r,activeTool:i,onPreviewReviewCapabilityChange:s,onRunStopped:b,onRunStatusChange:x,refreshKey:w})}),[se?(0,Z.jsx)(cu,{content:d?f??`Preview unavailable`:`Open preview`,disabled:!ie,side:`left`,children:(0,Z.jsx)(`div`,{"aria-label":ie?f??`Show preview`:`Resize preview pane`,"aria-orientation":ie?void 0:`vertical`,className:ie?`group flex shrink-0 touch-none select-none items-center justify-center border-l border-border/70 bg-background/90 transition-colors ${d?`cursor-not-allowed text-muted-foreground/60`:`cursor-col-resize text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`:`group flex w-5 shrink-0 cursor-col-resize touch-none select-none items-center justify-center border-l border-border/70 bg-background/80 ${I?`bg-background`:``}`,"data-preview-divider":`true`,"data-testid":ie?`collapsed-preview-rail`:void 0,onLostPointerCapture:G,onPointerCancel:de,onPointerDown:ue,onPointerMove:W,onPointerUp:de,onClick:ie?K:void 0,onKeyDown:ie?e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),K())}:void 0,ref:E,role:ie?`button`:`separator`,style:ie?{width:`${oQ}px`}:void 0,tabIndex:ie?d?-1:0:void 0,children:ie?(0,Z.jsxs)(`span`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-[2.65rem] items-center justify-center text-sky-400/80 transition-colors group-hover:text-sky-300`,children:(0,Z.jsx)(XZ,{className:`h-3 w-3 shrink-0`})}),(0,Z.jsx)(`span`,{className:`absolute top-1/2 left-1/2 h-14 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-muted-foreground/70 transition-colors group-hover:bg-sky-300/90`})]}):(0,Z.jsx)(`div`,{className:`h-14 w-1.5 rounded-full transition-colors ${I?`bg-sky-300/90`:`bg-muted-foreground/70 group-hover:bg-sky-300/90`}`})})},`preview-divider`):null,oe?(0,Z.jsx)(`div`,{className:ne?`fixed inset-0 z-50 bg-black/70 p-4 sm:p-6`:`min-h-0 shrink-0 border-l border-border/70 bg-[#11131a]`,style:ne?void 0:{width:`${H}px`},children:(0,Z.jsx)(`div`,{className:`h-full w-full`,children:l})},`preview-container`):null]]})]})})},mQ=({isExpanded:e,isVisible:t,project:n,onClose:r,onToggleExpanded:i})=>(0,Z.jsx)(`div`,{className:[`fixed inset-x-4 bottom-24 z-40`,e?`top-20`:`h-[min(28rem,calc(100vh-8rem))]`,t?`block`:`hidden`].join(` `),children:(0,Z.jsx)(LW,{createSession:()=>kT(n.id),isExpanded:e,isVisible:t,ariaLabel:`Project terminal for ${n.name}`,title:n.name,closeLabel:`Close terminal`,className:e?`h-full w-full rounded-2xl shadow-2xl`:`mx-auto h-full max-w-6xl shadow-2xl`,onClose:r,onToggleExpanded:i})}),hQ=({activeWorkspace:e,activityByWorkspace:t,memoryEnabled:n=!1,onWorkspaceChange:r})=>(0,Z.jsx)(`div`,{role:`tablist`,"aria-label":`Project workspace`,className:`inline-flex items-end gap-1 border-b border-border/70`,children:(n?[`board`,`chat`,`memory`]:[`board`,`chat`]).map(n=>{let i=e===n,a=rQ(t[n],i),o=n===`board`?`border-sky-300/70 bg-sky-500/8 text-sky-200`:n===`memory`?`border-amber-300/70 bg-amber-500/8 text-amber-200`:`border-emerald-300/70 bg-emerald-500/8 text-emerald-200`;return(0,Z.jsx)(`button`,{id:`project-workspace-tab-${n}`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`project-workspace-panel-${n}`,tabIndex:i?0:-1,className:W(`cursor-pointer rounded-t-lg border-b-2 px-4 py-2.5 text-[15px] font-medium transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60`,i?o:`border-transparent text-muted-foreground hover:border-border hover:bg-background/35 hover:text-foreground`),onClick:()=>r(n),children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:n===`board`?`Board`:n===`memory`?`Memory`:`Chat`}),(0,Z.jsx)(lX,{state:a,className:`mt-0`})]})},n)})}),gQ=32,_Q=5.5,vQ=2,yQ=24,bQ=8,xQ=new Map,SQ={running:{fill:`#fcd34d`,stroke:`#f59e0b`},finished:{fill:`#34d399`,stroke:`#059669`},error:{fill:`#fb7185`,stroke:`#e11d48`}},CQ=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),wQ=e=>{if(!e)return null;let t=e.trim().match(/^([0-9]+(?:\.[0-9]+)?)/);return t?Number(t[1]):null},TQ=e=>{let t=new DOMParser().parseFromString(e,`image/svg+xml`);if(t.querySelector(`parsererror`))return null;let n=t.documentElement;if(n.nodeName.toLowerCase()!==`svg`)return null;let r=n.getAttribute(`viewBox`)?.trim(),i=wQ(n.getAttribute(`width`)),a=wQ(n.getAttribute(`height`)),o=r??(i&&a?`0 0 ${i} ${a}`:`0 0 ${gQ} ${gQ}`);return`<svg ${[Array.from(n.attributes).filter(e=>![`width`,`height`,`viewBox`,`x`,`y`,`preserveAspectRatio`].includes(e.name)).map(e=>`${e.name}="${CQ(e.value)}"`).join(` `),`x="0"`,`y="0"`,`width="${gQ}"`,`height="${gQ}"`,`viewBox="${CQ(o)}"`,`preserveAspectRatio="xMidYMid meet"`].filter(e=>e.length>0).join(` `)}>${n.innerHTML}</svg>`},EQ=async e=>{if(!e)return null;let t=xQ.get(e);if(t)return t;let n=(async()=>{try{if(e.startsWith(`data:image/svg+xml,`))return TQ(decodeURIComponent(e.slice(19)));if(e.startsWith(`data:image/svg+xml;base64,`))return TQ(atob(e.slice(26)));let t=await fetch(e);return t.ok?TQ(await t.text()):null}catch{return null}})();return xQ.set(e,n),n},DQ=async(e,t)=>{let{fill:n,stroke:r}=SQ[e],i=await EQ(t);return i?[`<svg xmlns="http://www.w3.org/2000/svg" width="${gQ}" height="${gQ}" viewBox="0 0 ${gQ} ${gQ}">`,i,`<circle cx="${yQ}" cy="${bQ}" r="${_Q}" fill="${n}" stroke="${r}" stroke-width="${vQ}"/>`,`</svg>`].join(``):null},OQ=async(e,t)=>{if(!e)return t;let n=await DQ(e,t);return n?`data:image/svg+xml,${encodeURIComponent(n)}`:t},kQ=()=>{let e=document.querySelector(`link[rel="icon"]`);if(e)return e;let t=document.createElement(`link`);return t.rel=`icon`,document.head.appendChild(t),t},AQ=({defaultHref:e,state:t})=>{let n=kQ(),r=Number(n.dataset.browserTabActivityRequestId??`0`)+1;if(n.dataset.browserTabActivityState=t??`default`,n.dataset.browserTabActivityRequestId=String(r),!t){if(e){n.href=e;return}n.removeAttribute(`href`);return}OQ(t,e).then(e=>{if(n.dataset.browserTabActivityRequestId===String(r)){if(e){n.href=e;return}n.removeAttribute(`href`)}})},jQ=`archon.active-project-id`,MQ=`archon.workspace-by-project`,NQ=`archon.preview-mode-by-project`,PQ=`archon.dismissed-preview-run-context-by-project`,FQ=5e3,IQ=`archon.preview-pane-width`,LQ=`archon.preview-viewport-preset`,RQ=`archon.preview-zoom`,zQ=480,BQ=`responsive`,VQ=1,HQ={hasMounted:!1,isOpen:!1,isExpanded:!1},UQ=`hidden`,WQ=(0,X.lazy)(()=>VW(()=>Promise.resolve().then(()=>Xq).then(e=>({default:e.TicketChangesModal})),void 0)),GQ=(0,X.lazy)(()=>VW(()=>import(`./TestsDialog-Buw5J9nT.js`).then(e=>({default:e.TestsDialog})),__vite__mapDeps([0,1,2]))),KQ=e=>{if(!e)return null;try{return JSON.parse(e)}catch{return null}},qQ=e=>{let t=KQ(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0):[]},JQ=e=>{let t=KQ(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.name==`string`?t.name:``,r=typeof t.cmd==`string`?t.cmd:``,i=typeof t.cwd==`string`?t.cwd:``;return n.trim()===``&&r.trim()===``&&i.trim()===``?[]:[{name:n,cmd:r,cwd:i}]}):[]},YQ=e=>{let t=KQ(e);return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=typeof t.source==`string`?t.source:``,r=typeof t.target==`string`?t.target:``,i=t.mode===`copy`||t.mode===`symlink`?t.mode:`copy`;return n.trim()===``&&r.trim()===``?[]:[{source:n,target:r,mode:i}]}):[]},XQ=e=>({name:e.name,repoPath:e.repo_path,linkedProjectIds:e.linked_project_ids,runSetup:qQ(e.run_setup),runServices:JQ(e.run_services),testCommands:rY(e.test_commands),runIde:e.run_ide??``,previewServiceName:e.preview_service_name??``,previewPath:e.preview_path??``,previewCapabilityMode:e.preview_capability_mode??`auto`,helperModel:e.helper_model??``,helperVariant:e.helper_variant??``,commitMessageRules:e.commit_message_rules??``,autoParkStaleTickets:e.auto_park_stale_tickets,memoryEnabled:e.memory_enabled,worktreeSync:YQ(e.worktree_sync)}),ZQ=e=>{let t=e.testCommands??[],n=e.previewServiceName?.trim()||null,r=e.previewPath?.trim()||``,i=r===``||r===`/`?null:r,a=n||i||e.previewCapabilityMode===`force_web`||e.previewCapabilityMode===`force_disabled`?e.previewCapabilityMode??`auto`:null;return{name:e.name,repo_path:e.repoPath,linked_project_ids:e.linkedProjectIds,run_setup:e.runSetup.length>0?e.runSetup:null,run_services:e.runServices.length>0?e.runServices.map(e=>({...e.name?{name:e.name}:{},cmd:e.cmd,...e.cwd?{cwd:e.cwd}:{}})):null,...t.length>0?{test_commands:t.map(e=>({id:e.id,name:e.name,command:e.command,runner:e.runner,...e.cwd?{cwd:e.cwd}:{}}))}:{},run_ide:e.runIde||null,preview_service_name:n,preview_path:i,preview_capability_mode:a,helper_model:e.helperModel||null,helper_variant:e.helperModel&&e.helperVariant||null,commit_message_rules:e.commitMessageRules||null,auto_park_stale_tickets:e.autoParkStaleTickets,memory_enabled:e.memoryEnabled,worktree_sync:e.worktreeSync.length>0?e.worktreeSync.map(e=>({source:e.source,...e.target?{target:e.target}:{},mode:e.mode})):null}},QQ=e=>e?qQ(e.run_setup).length>0||JQ(e.run_services).length>0||(e.run_ide?.trim().length??0)>0:!1,$Q=(e,t,n)=>`${e} ${e===1?t:n}`,e$=e=>{if(!e.repo_path_locked)return null;let t=[];return e.ticket_count>0&&t.push($Q(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&t.push($Q(e.worktree_count,`worktree exists`,`worktrees exist`)),t.length===0?`Repository path is locked for this project.`:`Repository path is locked because ${t.join(` and `)}.`},t$=(e,t)=>{if(t.length<=1)return`Keep at least one project in Archon.`;let n=[];e.ticket_count>0&&n.push($Q(e.ticket_count,`ticket is attached`,`tickets are attached`)),e.worktree_count>0&&n.push($Q(e.worktree_count,`worktree exists`,`worktrees exist`));let r=t.filter(t=>t.linked_project_ids.includes(e.id)).length;return r>0&&n.push($Q(r,`project links to it`,`projects link to it`)),n.length===0?null:`This project can't be deleted while ${n.join(` and `)}.`},n$=(e,t)=>e.id!==t.projectId||e.ticket_count===t.ticketCount&&e.worktree_count===t.worktreeCount&&e.repo_path_locked===t.repoPathLocked?e:{...e,ticket_count:t.ticketCount,worktree_count:t.worktreeCount,repo_path_locked:t.repoPathLocked},r$=(e,t)=>({projectId:e,branch:t.branch,status:t.status,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.has_upstream??!1,canPull:t.can_pull??!1,diffStats:t.diff_stats??null}),i$=e=>({projectId:e,branch:null,status:`loading`,ahead:0,behind:0,hasUpstream:!1,canPull:!1,diffStats:null}),a$=(e,t)=>t?e[t]??HQ:HQ,o$=(e,t)=>t?e[t]??UQ:UQ,s$=()=>{let e=window.localStorage.getItem(IQ),t=Number(e);return Number.isFinite(t)&&t>=320?t:zQ},c$=()=>{let e=window.localStorage.getItem(LQ);return e===`phone`||e===`tablet`||e===`laptop`||e===`responsive`?e:BQ},l$=()=>{let e=Number(window.localStorage.getItem(RQ));return Number.isFinite(e)&&e>0?e:VQ},u$=()=>{let e=KQ(window.localStorage.getItem(MQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`board`||e===`chat`||e===`memory`))},d$=()=>{let e=KQ(window.localStorage.getItem(NQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===`hidden`||e===`inline`||e===`expanded`))},f$=()=>{let e=KQ(window.localStorage.getItem(PQ));return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`||e===null))},p$=e=>!!e?.preview_service_name?.trim()&&e?.preview_capability_mode!==`force_disabled`,m$=({activeRun:e,project:t})=>{if(!e||e.kind!==`project`||!t)return!1;let n=t.active_target_kind??`repo_root`,r=t.active_target_bundle_id??null;return e.project_id===t.id&&(e.target_kind??`repo_root`)===n&&((e.target_kind??`repo_root`)!==`bundle`||e.target_bundle_id===r)},h$=({activeRun:e,project:t,projectId:n})=>!e||!n?null:e.kind===`ticket`?e.project_id===n?e:null:m$({activeRun:e,project:t})?e:null,g$=`Project root has uncommitted changes. Confirm branch switch to continue.`,_$=({activeProject:e,activeProjectBranchState:t,nextTarget:n})=>e?n.kind===`bundle`?e.active_target_kind!==`bundle`||e.active_target_bundle_id!==n.bundleId:e.active_target_kind===`bundle`?!0:n.branch?t?.branch!==n.branch:!1:!1,v$=()=>{let[e,t]=(0,X.useState)(`opencode`),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(()=>window.localStorage.getItem(jQ)),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[p,h]=(0,X.useState)(null),[g,_]=(0,X.useState)({}),[v,y]=(0,X.useState)({}),[b,x]=(0,X.useState)({}),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)({}),[E,D]=(0,X.useState)(d$),[O,k]=(0,X.useState)(f$),[A,j]=(0,X.useState)(s$),[N,P]=(0,X.useState)(c$),[F,I]=(0,X.useState)(l$),[L,R]=(0,X.useState)(null),[ee,z]=(0,X.useState)([]),[te,ne]=(0,X.useState)(!1),[ie,ae]=(0,X.useState)(``),[oe,se]=(0,X.useState)(``),[H,U]=(0,X.useState)(!1),[W,de]=(0,X.useState)(null),[G,K]=(0,X.useState)(null),[q,pe]=(0,X.useState)(null),[he,_e]=(0,X.useState)({}),[ye,be]=(0,X.useState)(u$),[xe,Se]=(0,X.useState)(()=>$Z()),[Ce,we]=(0,X.useState)(()=>QZ()),[Te,Ee]=(0,X.useState)(0),[De,Oe]=(0,X.useState)(null),[ke,Ae]=(0,X.useState)(null),[je,Me]=(0,X.useState)({}),[Ne,J]=(0,X.useState)({}),[Pe,Fe]=(0,X.useState)({}),[Ie,Le]=(0,X.useState)({}),[ze,Ve]=(0,X.useState)(!1),[He,Ue]=(0,X.useState)(null),We=(0,X.useRef)(null),Ge=(0,X.useRef)(null),Ke=(0,X.useRef)(null),Y=i.find(e=>e.id===o)??null,qe=!!Y?.memory_enabled,Je=o?ye[o]??`board`:`board`,Ye=Je===`memory`?qe?`memory`:`board`:Je,Ze=Y!==null,Qe=QQ(Y),$e=!!Y?.run_ide?.trim(),et=o!==null&&u===o,tt=o!==null&&(!Qe||p===o),nt=o?g[o]??i$(o):null,rt=o?v[o]??null:null,it=o?!!b[o]:!1,at=o?je[o]??[]:[],ot=o?!!Ne[o]:!1,st=o?Pe[o]??{current_branch:null,default_branch:null,previous_branch:null}:{current_branch:null,default_branch:null,previous_branch:null},ct=o?!!Ie[o]:!1,lt=o?w[o]??null:null,ut=o$(E,o),gt=ut!==`hidden`,_t=h$({activeRun:c,project:Y,projectId:o}),vt=_t?.context_key??null,yt=o?O[o]??null:null,bt=p$(Y),xt=vt===L,St=(0,X.useMemo)(()=>tQ(xe),[xe]),Ct=(0,X.useMemo)(()=>nQ({hasRunning:St.hasRunning,hasFinishedUnseen:Ce.hasFinishedUnseen,hasErrorUnseen:Ce.hasErrorUnseen}),[St.hasRunning,Ce.hasErrorUnseen,Ce.hasFinishedUnseen]);(0,X.useEffect)(()=>{Oe(null),Ae(null),Ge.current=null},[o]),(0,X.useEffect)(()=>{Ae(null)},[Ye]),(0,X.useEffect)(()=>{gt||(Ge.current=null)},[gt]),(0,X.useEffect)(()=>{let e=De?.target?.kind??null;if(e===`ticket`||e===`bundle`){Ge.current=De;return}(Ye===`board`||!gt)&&(Ge.current=De)},[gt,De,Ye]),(0,X.useEffect)(()=>{Se($Z())},[o]),(0,X.useEffect)(()=>{we(QZ())},[o]);let wt=(0,X.useCallback)((e,t)=>{document.visibilityState!==`visible`&&(!t.didFinish&&!t.didError||we(e=>{let n={...e,hasFinishedUnseen:e.hasFinishedUnseen||t.didFinish,hasErrorUnseen:e.hasErrorUnseen||t.didError};return e.hasFinishedUnseen===n.hasFinishedUnseen&&e.hasErrorUnseen===n.hasErrorUnseen?e:n}))},[]);(0,X.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&we(e=>!e.hasFinishedUnseen&&!e.hasErrorUnseen?e:{...e,hasFinishedUnseen:!1,hasErrorUnseen:!1})};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]),(0,X.useEffect)(()=>(We.current===null&&(We.current=document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)??`/favicon.svg`),AQ({defaultHref:We.current,state:Ct}),()=>{AQ({defaultHref:We.current,state:null})}),[Ct]);let Tt=(0,X.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;try{let t=await me(e,r,{refreshRemote:n});if(r?.aborted)return;_(n=>({...n,[e]:r$(e,t)}))}catch(t){if(ge(t))return;if(t instanceof ve&&t.status===404){_(t=>({...t,[e]:{...i$(e),status:`unknown`}}));return}_(t=>({...t,[e]:{projectId:e,branch:t[e]?.branch??null,status:`unknown`,ahead:t[e]?.ahead??0,behind:t[e]?.behind??0,hasUpstream:t[e]?.hasUpstream??!1,canPull:t[e]?.canPull??!1,diffStats:t[e]?.diffStats??null}}))}},[]),Et=(0,X.useCallback)(async(e,t={})=>{let{refreshRemote:n=!1,signal:r}=t;x(t=>({...t,[e]:!0}));try{let t=await ce(e,{refreshRemote:n,signal:r});if(r?.aborted)return;y(n=>({...n,[e]:t}))}catch(t){if(ge(t))return;t instanceof ve&&t.status===404&&y(t=>({...t,[e]:null}))}finally{r?.aborted||x(t=>({...t,[e]:!1}))}},[]);(0,X.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let{tool:n}=await Jt(e.signal);t(n)}catch(e){ge(e)}finally{e.signal.aborted||r(!0)}})(),()=>{e.abort()}},[]),(0,X.useEffect)(()=>{if(!H||i.length>0&&W===null||te)return;let e=new AbortController;return(async()=>{try{z(await qt(`opencode`,e.signal))}catch(e){ge(e)||z(e=>e)}finally{e.signal.aborted||ne(!0)}})(),()=>{e.abort()}},[te,W,i.length,H]),(0,X.useEffect)(()=>{let e=new AbortController,t=window.localStorage.getItem(jQ);return(async()=>{try{let n=await fe(e.signal);if(e.signal.aborted)return;a(n);let r=n[0]?.id??null;s(n.some(e=>e.id===t)?t:r)}catch(e){ge(e)||a([])}finally{e.signal.aborted||U(!0)}})(),()=>{e.abort()}},[]),(0,X.useEffect)(()=>{if(H){if(o){window.localStorage.setItem(jQ,o);return}window.localStorage.removeItem(jQ)}},[o,H]),(0,X.useEffect)(()=>{window.localStorage.setItem(MQ,JSON.stringify(ye))},[ye]),(0,X.useEffect)(()=>{window.localStorage.setItem(NQ,JSON.stringify(E))},[E]),(0,X.useEffect)(()=>{window.localStorage.setItem(PQ,JSON.stringify(O))},[O]),(0,X.useEffect)(()=>{_(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),y(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),x(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,X.useEffect)(()=>{_e(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,X.useEffect)(()=>{let e=new Set(i.map(e=>e.id));Me(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),J(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Fe(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),Le(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t))))},[i]),(0,X.useEffect)(()=>{T(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),D(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)}),k(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i]),(0,X.useEffect)(()=>{H&&be(e=>{let t=new Set(i.map(e=>e.id)),n=Object.entries(e).filter(([e])=>t.has(e));return n.length===Object.keys(e).length?e:Object.fromEntries(n)})},[i,H]),(0,X.useEffect)(()=>{if(!H||!o||!Ze)return;let e=!1,t=null,n=null;_(e=>e[o]?e:{...e,[o]:i$(o)});let r=async(r=!1)=>{let i=r?`remote`:`local`;if(t){if(n===`remote`||n===i)return;t.abort()}let a=new AbortController;t=a,n=i;try{await Promise.all([Tt(o,{refreshRemote:r,signal:a.signal}),Et(o,{refreshRemote:r,signal:a.signal})])}catch{if(e||a.signal.aborted)return}finally{t===a&&(t=null,n=null)}};r(!1);let i=UK(()=>{document.visibilityState===`visible`&&r(!1)});return()=>{e=!0,t?.abort(),i()}},[o,Ze,H,Tt,Et]),(0,X.useEffect)(()=>{if(o)return VK(e=>{e===o&&(Tt(e),Et(e))})},[o,Tt,Et]);let Dt=(0,X.useCallback)(async e=>{let t=o;if(!t){l(null),h(null);return}try{let n=await pt(t,e);e?.aborted||(l(n.active_run),h(t))}catch(e){ge(e)}},[o]),Ot=(0,X.useCallback)(async e=>{let t=o;if(t)try{let n=await ft(t,e);e?.aborted||T(e=>({...e,[t]:n}))}catch(e){ge(e)}},[o]);(0,X.useEffect)(()=>{if(!H)return;if(!Qe){l(null),h(null);return}if(!et)return;let e=new AbortController;h(null),Dt(e.signal);let t=window.setInterval(()=>{Dt(e.signal)},FQ),n=UK(()=>{document.visibilityState===`visible`&&Dt(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[et,Qe,H,Dt]),(0,X.useEffect)(()=>{if(!H||!o||!et||!bt)return;let e=new AbortController;Ot(e.signal);let t=window.setInterval(()=>{Ot(e.signal)},FQ),n=UK(()=>{document.visibilityState===`visible`&&Ot(e.signal)});return()=>{e.abort(),window.clearInterval(t),n()}},[o,et,bt,H,Ot]),(0,X.useEffect)(()=>{window.localStorage.setItem(IQ,String(A))},[A]),(0,X.useEffect)(()=>{window.localStorage.setItem(LQ,N)},[N]),(0,X.useEffect)(()=>{window.localStorage.setItem(RQ,String(F))},[F]),(0,X.useEffect)(()=>{o&&vt&&k(e=>{let t=e[o]??null;return!t||t===vt?e:{...e,[o]:null}})},[o,vt]),(0,X.useEffect)(()=>{!o||!_t||!p$(Y)||yt!==_t.context_key&&D(e=>o$(e,o)===`hidden`?{...e,[o]:`inline`}:e)},[Y,o,yt,_t]);let kt=async e=>{try{t((await Yt(e)).tool)}catch{}},At=(0,X.useCallback)(e=>{a(t=>t.map(t=>t.id===e.id?e:t))},[]),jt=(0,X.useCallback)((e,t)=>{Me(n=>{let r=[t,...(n[e]??[]).filter(e=>e.id!==t.id)];return{...n,[e]:r}})},[]),Mt=(0,X.useCallback)(async e=>{Le(t=>({...t,[e]:!0}));try{let t=await le(e);Fe(n=>({...n,[e]:t}))}catch(e){Q.error(e instanceof ve?e.message:`Unable to load the project target options right now.`,{id:`project-target-selector-load-error`})}finally{Le(t=>({...t,[e]:!1}))}},[]),Nt=async e=>{try{let t=await M(ZQ(e));return a(e=>[...e,t]),s(t.id),de(null),null}catch(e){return e instanceof ve?e.message:`Unable to create the project right now.`}},Pt=async e=>{if(!Y)return`Select a project before editing settings.`;try{let t=await Be(Y.id,ZQ(e));return a(e=>e.map(e=>e.id===t.id?t:e)),Ee(e=>e+1),de(null),null}catch(e){return e instanceof ve?e.message:`Unable to update the project right now.`}},Ft=async()=>{if(!Y)return`Select a project before deleting it.`;try{await ue(Y.id);let e=i.filter(e=>e.id!==Y.id);return a(e),s(e[0]?.id??null),de(null),null}catch(e){return e instanceof ve?e.message:`Unable to delete the project right now.`}},It=(0,X.useCallback)(e=>{a(t=>t.map(t=>n$(t,e)))},[]),Lt=(0,X.useCallback)((e,t)=>{e&&Me(n=>({...n,[e]:t}))},[]),Rt=(0,X.useCallback)((e,t)=>{e&&J(n=>({...n,[e]:t}))},[]),zt=async(e,t,n)=>await V({repo_path:e,helper_model:t||null,helper_variant:t&&n||null}),Vt=async()=>(await B()).repo_path,Ht=(0,X.useCallback)(async e=>{let t=await f({repo_path:e});return{valid:t.valid,repoRoot:t.repo_root,error:t.error}},[]),Ut=(0,X.useCallback)((e,t)=>{D(t=>({...t,[e]:`hidden`})),t&&k(n=>({...n,[e]:t}))},[]),Wt=(0,X.useCallback)(()=>{o&&Ut(o,vt)},[o,Ut,vt]),Gt=(0,X.useCallback)(e=>{o&&(D(e=>({...e,[o]:`hidden`})),e&&l(t=>t?.context_key===e?null:t))},[o]),Kt=(0,X.useCallback)(async()=>{if(!_t||L===_t.context_key)return;let{context_key:e}=_t;R(e);try{_t.kind===`ticket`?await Bt(_t.ticket_id,_t.project_id):l((await ht(_t.project_id)).active_run),Gt(e),await Promise.all([Dt(),Ot()])}catch(e){Q.error(e instanceof ve?e.message:`Unable to stop the preview run right now.`,{id:`app-preview-run-stop-error`})}finally{R(t=>t===e?null:t)}},[Gt,_t,Ot,Dt,L]),Xt=(0,X.useCallback)(e=>{!e||!o||Mt(o)},[o,Mt]),Zt=(0,X.useCallback)(e=>new Promise(t=>{Ke.current=t,Ue(e)}),[]),Qt=(0,X.useCallback)(e=>{let t=Ke.current;Ke.current=null,Ue(null),t?.(e)},[]),$t=(0,X.useCallback)(async e=>{if(!Y||!o)throw Error(`Select a project first.`);if(!_$({activeProject:Y,activeProjectBranchState:nt,nextTarget:e})||!c||c.kind!==`project`||c.project_id!==Y.id)return!0;if(!await Zt({title:`Stop current run and switch target?`,description:`Switching targets will stop the current run and close its preview.`,confirmLabel:`Stop and switch`,cancelLabel:`Keep current target`,confirmVariant:`destructive`}))return!1;try{let e=c.context_key,t=await ht(Y.id);return Gt(e),l(t.active_run),await Ot(),!0}catch(e){return Q.error(e instanceof ve?e.message:`Unable to stop the project run right now.`,{id:`project-target-switch-stop-run-error`}),!1}},[Y,nt,o,c,Gt,Ot,Zt]),en=(0,X.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);return await $t({kind:`bundle`,bundleId:e})?(At(await m(o,{kind:`bundle`,bundle_id:e})),y(e=>({...e,[o]:null})),await Promise.all([Tt(o),Et(o)]),!0):!1},[o,$t,Tt,Et,At]),tn=(0,X.useCallback)(async(e,t={})=>{if(!o)throw Error(`Select a project first.`);if(!await $t({kind:`repo_root`,branch:e}))return!1;let n=n=>m(o,{kind:`repo_root`,...e?{branch:e}:{},...t.createBranch===!1?{create_branch:!1}:{},...n?{confirm_dirty_switch:!0}:{}}),r;try{r=await n(t.confirmDirtySwitch===!0)}catch(e){if(!t.confirmDirtySwitch&&e instanceof ve&&e.status===409&&e.message===g$){if(!await Zt({title:`Switch repo root branch?`,description:`${g$}\n\nSwitch anyway?`,confirmLabel:`Switch anyway`,cancelLabel:`Keep current branch`}))return!1;r=await n(!0)}else throw e}return At(r),y(e=>({...e,[o]:null})),await Promise.all([Tt(o),Et(o),Mt(o)]),!0},[o,$t,Mt,Tt,Et,At,Zt]),nn=(0,X.useCallback)(async e=>!e.target_kind||e.target_available===!1?!0:e.target_kind===`bundle`?e.target_bundle_id?await en(e.target_bundle_id):!1:await tn(e.target_branch_snapshot??null,{createBranch:!1}),[en,tn]),rn=(0,X.useCallback)(()=>{Ve(!0)},[]),an=(0,X.useCallback)(()=>{Ve(!1)},[]),on=(0,X.useCallback)(e=>{if(e){en(e);return}tn(null)},[en,tn]),sn=(0,X.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);let t=await Xe(o,{name:e,prepare:!0});return jt(o,t),Ee(e=>e+1),t},[o,jt]),cn=(0,X.useCallback)(async e=>{if(!o)throw Error(`Select a project first.`);await dt(o,e),Me(t=>({...t,[o]:(t[o]??[]).filter(t=>t.id!==e)})),Ee(e=>e+1)},[o]),ln=(0,X.useCallback)(async()=>{if(!Y)return;let e=Y.active_target_kind??`repo_root`,t=Y.active_target_bundle_id??null,n=c?.kind===`project`&&c.project_id===Y.id&&(c.target_kind??`repo_root`)===e&&((c.target_kind??`repo_root`)!==`bundle`||c.target_bundle_id===t),r=n?c?.context_key??null:null,i=!n&&p$(Y)&&ut===`hidden`;i&&(D(e=>({...e,[Y.id]:`inline`})),k(e=>({...e,[Y.id]:null})));try{let e=n?await ht(Y.id):await mt(Y.id);n&&Gt(r),l(e.active_run),Ot()}catch(e){i&&D(e=>({...e,[Y.id]:`hidden`})),Q.error(e instanceof ve?e.message:`Unable to update the project run right now.`,{id:`app-project-run-error`})}},[ut,Y,c,Gt,Ot]),un=(0,X.useCallback)(async()=>{if(!(!Y||!$e))try{await re(Y.id)}catch(e){Q.error(e instanceof Error?e.message:`Unable to open the IDE right now.`,{id:`app-project-open-ide-error`})}},[Y,$e]),dn=(0,X.useCallback)(async()=>{if(Y){C(Y.id);try{let e=await Re(Y.id);y(t=>({...t,[Y.id]:e})),Y.active_target_kind!==`bundle`&&await Tt(Y.id),BK(Y.id),Q.success(e.behind===0?`Project branch synced.`:`Project branch updated.`,{id:`app-project-pull-success`})}catch(e){Q.error(e instanceof ve?e.message:`Unable to sync the current branch right now.`,{id:`app-project-pull-error`})}finally{C(e=>e===Y.id?null:e)}}},[Y,Tt]),fn=(0,X.useCallback)(()=>{Y&&K({projectId:Y.id,title:Y.name})},[Y]),pn=(0,X.useCallback)(()=>{if(!G)return;let{projectId:e}=G;K(null),Tt(e),Et(e)},[Tt,Et,G]),mn=(0,X.useCallback)(()=>{Y&&pe({projectId:Y.id,targetKind:Y.active_target_kind??`repo_root`,targetBundleId:Y.active_target_bundle_id??null})},[Y]),hn=(0,X.useCallback)(()=>{pe(null)},[]),gn=a$(he,o),_n=Y?rY(Y.test_commands).length>0:!1,vn=Ye===`chat`?ke:null,yn=Ge.current,bn=yn?.target?.kind??null,xn=Ye===`chat`?bn===`ticket`||bn===`bundle`?{target:yn?.target??null,canSelect:!1,disabledReason:`This preview belongs to a ticket run. Return to Board to send preview comments.`,promptMode:yn?.promptMode??null,onPromptModeChange:yn?.onPromptModeChange??null,isUpdatingPromptMode:yn?.isUpdatingPromptMode??!1,promptPlaceholder:yn?.promptPlaceholder??null,promptComposerControls:yn?.promptComposerControls,promptComposerInlineControls:yn?.promptComposerInlineControls,submitPrompt:null}:vn?{target:{kind:`chat_session`,id:vn.chatSessionId??`draft:${o}`},canSelect:vn.canSubmitReviewPrompt,disabledReason:vn.canSubmitReviewPrompt?null:vn.reviewSubmitDisabledReason??`Wait for the current chat turn to finish before sending preview comments.`,promptMode:vn.mode,onPromptModeChange:vn.onModeChange,isUpdatingPromptMode:vn.isUpdatingMode,promptPlaceholder:vn.promptPlaceholder,promptComposerControls:vn.promptComposerControls,promptComposerInlineControls:vn.promptComposerInlineControls,submitPrompt:vn.canSubmitReviewPrompt?vn.submitPrompt:null}:{target:null,canSelect:!1,disabledReason:`Select a chat session to send preview comments.`,submitPrompt:null}:De,Sn=vn?.canSubmitReviewPrompt??!1,Cn=Ye===`chat`?vn?vn.reviewSubmitDisabledReason:`Select a chat session to send review comments.`:void 0,wn=(0,X.useCallback)(()=>{o&&_e(e=>{let t=e[o]??HQ;return{...e,[o]:{hasMounted:!0,isOpen:!t.isOpen,isExpanded:t.isExpanded}}})},[o]),Tn=(0,X.useCallback)(e=>{_e(t=>{let n=t[e]??HQ;return!n.hasMounted||!n.isOpen?t:{...t,[e]:HQ}})},[]),En=(0,X.useCallback)(e=>{_e(t=>{let n=t[e]??HQ;return{...t,[e]:{hasMounted:!0,isOpen:n.isOpen,isExpanded:!n.isExpanded}}})},[]),Dn=(0,X.useCallback)(()=>{de(`create`)},[]),On=(0,X.useCallback)(()=>{if(o){if(gt){Wt();return}D(e=>({...e,[o]:`inline`})),k(e=>({...e,[o]:null}))}},[o,Wt,gt]),kn=(0,X.useCallback)(()=>{o&&D(e=>{let t=o$(e,o);return{...e,[o]:t===`expanded`?`inline`:`expanded`}})},[o]),An=Y?Y.preview_service_name?.trim()?Y.preview_capability_mode===`force_disabled`?`Preview is disabled for this project.`:lt?.state===`unsupported`?lt.message??`Preview is unavailable for this project.`:gt?`Hide preview`:`Show preview`:`Choose a named preview service in project settings first.`:`Select a project first.`,jn=!Y||!Y.preview_service_name?.trim()||Y.preview_capability_mode===`force_disabled`||lt?.state===`unsupported`,Mn=Y&&Y.preview_service_name?.trim()?(0,Z.jsx)(tx,{project:Y,mode:ut===`expanded`?`expanded`:`inline`,status:lt,viewportPreset:N,zoom:F,activeRun:_t,reviewCapability:xn,isStoppingActiveRun:xt,onHide:Wt,onStopActiveRun:()=>{Kt()},onToggleExpanded:kn,onViewportPresetChange:P,onZoomChange:I}):null;return(0,Z.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden bg-[linear-gradient(180deg,_rgba(15,16,21,1),_rgba(9,10,14,1))] text-foreground`,children:[(0,Z.jsx)(Dd,{}),i.length>0&&(0,Z.jsx)(`header`,{className:`border-b border-border bg-background/95 px-6 py-3 backdrop-blur`,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-center`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 lg:justify-self-start`,children:(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-[20rem] sm:max-w-[30rem]`,children:(0,Z.jsx)(pu,{activeProjectId:o,projects:i,onEditProject:()=>de(`edit`),onProjectChange:s})})}),o&&(0,Z.jsx)(`div`,{className:`flex justify-start lg:col-start-2 lg:row-start-1 lg:justify-center`,children:(0,Z.jsx)(hQ,{activeWorkspace:Ye,activityByWorkspace:xe,memoryEnabled:qe,onWorkspaceChange:e=>{o&&(be(t=>({...t,[o]:e})),Se(t=>eQ(t,e)))}})}),(0,Z.jsx)(`div`,{className:`w-full lg:col-start-3 lg:row-start-1 lg:w-auto lg:justify-self-end`,children:(0,Z.jsx)(Ed,{activeTool:e,onCreateProject:Dn,onToolChange:kt})})]})}),H?i.length===0?(0,Z.jsx)(du,{activeTool:e,availableHelperModels:ee,helperModel:ie,helperVariant:oe,isHelperModelsLoaded:te,isToolLoaded:n,onCreateProject:Dn,onHelperModelChange:e=>{ae(e),se(``)},onHelperVariantChange:se,onToolChange:kt}):(0,Z.jsx)(pQ,{activeProjectId:o,activeProject:Y,activeProjectBranchState:nt,activeRun:c,activeTool:e,onRestoreChatSessionTarget:nn,onChatReviewCapabilityChange:Ae,isPreviewButtonDisabled:jn,onPreviewReviewCapabilityChange:Oe,onPreviewToggle:On,onRunStopped:Gt,onWorkspaceActivityChange:Se,onWorkspaceActivityEvent:wt,previewDisplayMode:ut,previewPane:Mn,previewPaneWidth:A,previewButtonTitle:An,visibleWorkspace:Ye,refreshKey:Te,onBoardLoadedProjectIdChange:d,onBundlesChange:Lt,onBundlesLoadingChange:Rt,onPreviewPaneWidthChange:j,onProjectUsageChange:It,onRunStatusChange:()=>{Dt(),Ot()}},o??`no-project`):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading projects...`}),i.length>0&&(0,Z.jsx)(wd,{activeProject:Y,activeRun:c,branchState:nt,targetGitStatus:rt,isBoardLoadedForActiveProject:et,isProjectSyncing:S===o,isProjectIdeAvailable:$e,isProjectRunAvailable:Qe,isRunStatusLoadedForActiveProject:tt,isTerminalOpen:gn.isOpen,targetBundles:at,targetBranchSuggestions:st,isTargetBundleLoading:ot,isTargetSelectorLoading:ct,isTargetGitStatusLoading:it,hasConfiguredTests:_n,onProjectIdeOpen:()=>{un()},onProjectPull:()=>{dn()},onProjectRunToggle:()=>{ln()},onProjectChangesOpen:fn,onProjectTestsOpen:mn,onTerminalToggle:wn,onTargetSelectorOpenChange:Xt,onSelectBundleTarget:en,onSelectRepoRootTarget:tn,onManageBundles:rn}),ze&&Y&&(0,Z.jsx)(Bd,{bundles:at,selectedBundleId:Y.active_target_kind===`bundle`?Y.active_target_bundle_id??null:null,activeTargetBundleId:Y.active_target_kind===`bundle`?Y.active_target_bundle_id??null:null,onSelectBundle:on,onCreateBundle:sn,onDeleteBundle:cn,onClose:an}),He&&(0,Z.jsx)(Od,{title:He.title,description:He.description,confirmLabel:He.confirmLabel,cancelLabel:He.cancelLabel,confirmVariant:He.confirmVariant,onConfirm:()=>Qt(!0),onCancel:()=>Qt(!1)}),i.map(e=>{let t=a$(he,e.id);return t.hasMounted?(0,Z.jsx)(mQ,{project:e,isExpanded:t.isExpanded,isVisible:e.id===o&&t.isOpen,onClose:()=>Tn(e.id),onToggleExpanded:()=>En(e.id)},e.id):null}),W&&(0,Z.jsx)(Jp,{mode:W,projectId:W===`edit`&&Y?Y.id:null,availableHelperModels:ee,isLoadingHelperModels:!te,isAutoConfigReady:n,initialValues:W===`edit`&&Y?XQ(Y):i.length===0?{name:``,repoPath:``,linkedProjectIds:[],runSetup:[],runServices:[],testCommands:[],runIde:``,previewServiceName:``,previewPath:``,previewCapabilityMode:`auto`,helperModel:ie,helperVariant:oe,commitMessageRules:``,autoParkStaleTickets:!1,memoryEnabled:!1,worktreeSync:[]}:void 0,linkedProjectOptions:i.filter(e=>e.id!==Y?.id).map(e=>({id:e.id,name:e.name})),repoPathLocked:W===`edit`&&Y?Y.repo_path_locked:!1,repoPathLockedMessage:W===`edit`&&Y?e$(Y):null,deleteBlockedMessage:W===`edit`&&Y?t$(Y,i):null,onDelete:W===`edit`?Ft:void 0,onAutoConfig:zt,onBrowseRepoPath:Vt,onValidateRepoPath:Ht,onClose:()=>de(null),onSubmit:W===`edit`?Pt:Nt}),G&&G.projectId===o&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(WQ,{scope:`project_root`,projectId:G.projectId,title:G.title,onSubmitReviewPrompt:vn?.submitPrompt,canSubmitReviewPrompt:Sn,reviewSubmitDisabledReason:Cn??void 0,canAddReviewComments:Sn,canModifyChanges:!0,onClose:pn})}),q&&q.projectId===o&&Y&&(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(GQ,{scope:`project`,projectId:q.projectId,targetKind:q.targetKind,targetBundleId:q.targetBundleId,testCommands:rY(Y.test_commands),onClose:hn})})]})};document.documentElement.classList.add(`dark`),document.documentElement.style.colorScheme=`dark`,(0,Je.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(v$,{}));export{Tl as _,xw as a,yf as c,Su as d,bu as f,xl as g,yl as h,Cw as i,mf as l,_l as m,bw as n,vf as o,_u as p,Sw as r,bf as s,PW as t,Od as u,Cl as v,wl as y};