runcastle 1.4.6 → 1.4.7
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.
|
@@ -119,8 +119,8 @@ pnpm --filter @acme/web test`},knownFailures:{label:`Known failing tests`,toolti
|
|
|
119
119
|
.block-interactivity-${e} {pointer-events: none;}
|
|
120
120
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
121
121
|
`},LO=0,RO=[];function zO(e){var t=L.useRef([]),n=L.useRef([0,0]),r=L.useRef(),i=L.useState(LO++)[0],a=L.useState(sO)[0],o=L.useRef(e);L.useEffect(function(){o.current=e},[e]),L.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ID([e.lockRef.current],(e.shards||[]).map(PO),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=L.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=MO(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=TO(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=TO(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return jO(h,t,e,h===`h`?s:c,!0)},[]),c=L.useCallback(function(e){var n=e;if(!(!RO.length||RO[RO.length-1]!==a)){var r=`deltaY`in n?NO(n):MO(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&FO(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(PO).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=L.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:BO(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=L.useCallback(function(e){n.current=MO(e),r.current=void 0},[]),d=L.useCallback(function(t){l(t.type,NO(t),t.target,s(t,e.lockRef.current))},[]),f=L.useCallback(function(t){l(t.type,MO(t),t.target,s(t,e.lockRef.current))},[]);L.useEffect(function(){return RO.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,bO),document.addEventListener(`touchmove`,c,bO),document.addEventListener(`touchstart`,u,bO),function(){RO=RO.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,bO),document.removeEventListener(`touchmove`,c,bO),document.removeEventListener(`touchstart`,u,bO)}},[]);var p=e.removeScrollBar,m=e.inert;return L.createElement(L.Fragment,null,m?L.createElement(a,{styles:IO(i)}):null,p?L.createElement(_O,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function BO(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var VO=XD(ZD,zO),HO=L.forwardRef(function(e,t){return L.createElement($D,PD({},e,{ref:t,sideCar:VO}))});HO.classNames=$D.classNames;var UO=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},WO=new WeakMap,GO=new WeakMap,KO={},qO=0,JO=function(e){return e&&(e.host||JO(e.parentNode))},YO=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=JO(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},XO=function(e,t,n,r){var i=YO(t,Array.isArray(e)?e:[e]);KO[n]||(KO[n]=new WeakMap);var a=KO[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(WO.get(e)||0)+1,l=(a.get(e)||0)+1;WO.set(e,c),a.set(e,l),o.push(e),c===1&&i&&GO.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),qO++,function(){o.forEach(function(e){var t=WO.get(e)-1,i=a.get(e)-1;WO.set(e,t),a.set(e,i),t||(GO.has(e)||e.removeAttribute(r),GO.delete(e)),i||e.removeAttribute(n)}),qO--,qO||(WO=new WeakMap,WO=new WeakMap,GO=new WeakMap,KO={})}},ZO=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||UO(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),XO(r,i,n,`aria-hidden`)):function(){return null}},QO=Object.defineProperty,$O=(e,t)=>QO(e,`name`,{value:t,configurable:!0}),ek=`Dialog`,[tk,nee]=Xx(ek),[nk,rk]=tk(ek),ik=$O(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=L.useRef(null),c=L.useRef(null),[l,u]=RT({prop:r,defaultProp:i??!1,onChange:a,caller:ek}),[d,f]=L.useState(0),[p,m]=L.useState(0);return(0,R.jsx)(nk,{scope:t,triggerRef:s,contentRef:c,contentId:zS(),titleId:zS(),descriptionId:zS(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:L.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),ak=`DialogPortal`,[ok,sk]=tk(ak,{forceMount:void 0}),ck=$O(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=rk(ak,t);return(0,R.jsx)(ok,{scope:t,forceMount:n,children:L.Children.map(r,e=>(0,R.jsx)(wT,{present:n||a.open,children:(0,R.jsx)(bT,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),lk=`DialogOverlay`,uk=L.forwardRef($O(function(e,t){let n=sk(lk,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=rk(lk,e.__scopeDialog);return a.modal?(0,R.jsx)(wT,{present:r||a.open,children:(0,R.jsx)(fk,{...i,ref:t})}):null},`DialogOverlay`)),dk=eS(`DialogOverlay.RemoveScroll`),fk=L.forwardRef($O(function(e,t){let{__scopeDialog:n,...r}=e,i=rk(lk,n),a=Kx(t,OS());return(0,R.jsx)(HO,{as:dk,allowPinchZoom:!0,shards:[i.contentRef],children:(0,R.jsx)(hS.div,{"data-state":vk(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),pk=`DialogContent`,mk=L.forwardRef($O(function(e,t){let n=sk(pk,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=rk(pk,e.__scopeDialog);return(0,R.jsx)(wT,{present:r||a.open,children:a.modal?(0,R.jsx)(hk,{...i,ref:t}):(0,R.jsx)(gk,{...i,ref:t})})},`DialogContent`)),hk=L.forwardRef($O(function(e,t){let n=rk(pk,e.__scopeDialog),r=L.useRef(null),i=Kx(t,n.contentRef,r);return L.useEffect(()=>{let e=r.current;if(e)return ZO(e)},[]),(0,R.jsx)(_k,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:J(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),gk=L.forwardRef($O(function(e,t){let n=rk(pk,e.__scopeDialog),r=L.useRef(!1),i=L.useRef(!1);return(0,R.jsx)(_k,{...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()}})},`DialogContentNonModal`)),_k=L.forwardRef($O(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=rk(pk,n);return MD(),(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(hD,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(DS,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":vk(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`));function vk(e){return e?`open`:`closed`}$O(vk,`getState`);var yk=`[cmdk-group=""]`,bk=`[cmdk-group-items=""]`,xk=`[cmdk-group-heading=""]`,Sk=`[cmdk-item=""]`,Ck=`${Sk}:not([aria-disabled="true"])`,wk=`cmdk-item-select`,Tk=`data-value`,Ek=(e,t,n)=>lD(e,t,n),Dk=L.createContext(void 0),Ok=()=>L.useContext(Dk),kk=L.createContext(void 0),Ak=()=>L.useContext(kk),jk=L.createContext(void 0),Mk=L.forwardRef((e,t)=>{let n=Kk(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Kk(()=>new Set),i=Kk(()=>new Map),a=Kk(()=>new Map),o=Kk(()=>new Set),s=Wk(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=zS(),y=zS(),b=zS(),x=L.useRef(null),S=Yk();Gk(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Gk(()=>{S(6,k)},[]);let C=L.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=L.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Ek;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(bk);t?t.appendChild(e.parentElement===t?e:e.closest(`${bk} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${bk} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${yk}[${Tk}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Tk);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(yk)?.querySelector(xk))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Sk}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Ck)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Tk))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Tk))}function P(e){let t=A()?.closest(yk),n;for(;t&&!n;)t=e>0?Hk(t,yk):Uk(t,yk),n=t?.querySelector(Ck);n?C.setState(`value`,n.getAttribute(Tk)):N(e)}let ee=()=>M(j().length-1),F=e=>{e.preventDefault(),e.metaKey?ee():e.altKey?P(1):N(1)},I=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return L.createElement(hS.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&F(e);break;case`ArrowDown`:F(e);break;case`p`:case`k`:g&&e.ctrlKey&&I(e);break;case`ArrowUp`:I(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ee();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(wk);t.dispatchEvent(e)}}}}},L.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Qk},c),Zk(e,e=>L.createElement(kk.Provider,{value:C},L.createElement(Dk.Provider,{value:w},e))))}),Nk=L.forwardRef((e,t)=>{let n=zS(),r=L.useRef(null),i=L.useContext(jk),a=Ok(),o=Wk(e),s=o.current?.forceMount??i?.forceMount;Gk(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Jk(n,r,[e.value,e.children,r],e.keywords),l=Ak(),u=qk(e=>e.value&&e.value===c.current),d=qk(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);L.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(wk,f),()=>t.removeEventListener(wk,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return L.createElement(hS.div,{ref:Gx(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Pk=L.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=zS(),s=L.useRef(null),c=L.useRef(null),l=zS(),u=Ok(),d=qk(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Gk(()=>u.group(o),[]),Jk(o,s,[e.value,e.heading,c]);let f=L.useMemo(()=>({id:o,forceMount:i}),[i]);return L.createElement(hS.div,{ref:Gx(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&L.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Zk(e,e=>L.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},L.createElement(jk.Provider,{value:f},e))))}),Fk=L.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=L.useRef(null),a=qk(e=>!e.search);return!n&&!a?null:L.createElement(hS.div,{ref:Gx(i,t),...r,"cmdk-separator":``,role:`separator`})}),Ik=L.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Ak(),o=qk(e=>e.search),s=qk(e=>e.selectedItemId),c=Ok();return L.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),L.createElement(hS.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Lk=L.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=L.useRef(null),o=L.useRef(null),s=qk(e=>e.selectedItemId),c=Ok();return L.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),L.createElement(hS.div,{ref:Gx(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Zk(e,e=>L.createElement(`div`,{ref:Gx(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Rk=L.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return L.createElement(ik,{open:n,onOpenChange:r},L.createElement(ck,{container:o},L.createElement(uk,{"cmdk-overlay":``,className:i}),L.createElement(mk,{"aria-label":e.label,"cmdk-dialog":``,className:a},L.createElement(Mk,{ref:t,...s}))))}),zk=L.forwardRef((e,t)=>qk(e=>e.filtered.count===0)?L.createElement(hS.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Bk=L.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return L.createElement(hS.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Zk(e,e=>L.createElement(`div`,{"aria-hidden":!0},e)))}),Vk=Object.assign(Mk,{List:Lk,Item:Nk,Input:Ik,Group:Pk,Separator:Fk,Dialog:Rk,Empty:zk,Loading:Bk});function Hk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Uk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Wk(e){let t=L.useRef(e);return Gk(()=>{t.current=e}),t}var Gk=typeof window>`u`?L.useEffect:L.useLayoutEffect;function Kk(e){let t=L.useRef();return t.current===void 0&&(t.current=e()),t}function qk(e){let t=Ak(),n=()=>e(t.snapshot());return L.useSyncExternalStore(t.subscribe,n,n)}function Jk(e,t,n,r=[]){let i=L.useRef(),a=Ok();return Gk(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Tk,s),i.current=s}),i}var Yk=()=>{let[e,t]=L.useState(),n=Kk(()=>new Map);return Gk(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Xk(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Zk({asChild:e,children:t},n){return e&&L.isValidElement(t)?L.cloneElement(Xk(t),{ref:t.ref},n(t.props.children)):n(t)}var Qk={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},$k=Object.defineProperty,eA=(e,t)=>$k(e,`name`,{value:t,configurable:!0}),tA=`Popover`,[nA,ree]=Xx(tA,[iT]),rA=iT(),[iA,aA]=nA(tA),oA=eA(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=rA(t),c=L.useRef(null),[l,u]=L.useState(!1),[d,f]=RT({prop:r,defaultProp:i??!1,onChange:a,caller:tA});return(0,R.jsx)(gT,{...s,children:(0,R.jsx)(iA,{scope:t,contentId:zS(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:L.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:L.useCallback(()=>u(!0),[]),onCustomAnchorRemove:L.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),sA=`PopoverTrigger`,cA=L.forwardRef(eA(function(e,t){let{__scopePopover:n,...r}=e,i=aA(sA,n),a=rA(n),o=Kx(t,i.triggerRef),s=(0,R.jsx)(hS.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":yA(i.open),...r,ref:o,onClick:J(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,R.jsx)(_T,{asChild:!0,...a,children:s})},`PopoverTrigger`)),lA=`PopoverPortal`,[uA,dA]=nA(lA,{forceMount:void 0}),fA=eA(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=aA(lA,t);return(0,R.jsx)(uA,{scope:t,forceMount:n,children:(0,R.jsx)(wT,{present:n||a.open,children:(0,R.jsx)(bT,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),pA=`PopoverContent`,mA=L.forwardRef(eA(function(e,t){let n=dA(pA,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=aA(pA,e.__scopePopover);return(0,R.jsx)(wT,{present:r||a.open,children:a.modal?(0,R.jsx)(gA,{...i,ref:t}):(0,R.jsx)(_A,{...i,ref:t})})},`PopoverContent`)),hA=eS(`PopoverContent.RemoveScroll`),gA=L.forwardRef(eA(function(e,t){let n=aA(pA,e.__scopePopover),r=L.useRef(null),i=Kx(t,r),a=L.useRef(!1);return L.useEffect(()=>{let e=r.current;if(e)return ZO(e)},[]),(0,R.jsx)(HO,{as:hA,allowPinchZoom:!0,children:(0,R.jsx)(vA,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:J(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),_A=L.forwardRef(eA(function(e,t){let n=aA(pA,e.__scopePopover),r=L.useRef(!1),i=L.useRef(!1);return(0,R.jsx)(vA,{...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()}})},`PopoverContentNonModal`)),vA=L.forwardRef(eA(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=aA(pA,n),p=rA(n);return MD(),(0,R.jsx)(hD,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(DS,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,R.jsx)(vT,{"data-state":yA(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function yA(e){return e?`open`:`closed`}eA(yA,`getState`);var bA=oA,xA=cA,SA=fA,CA=mA,wA=bA,TA=xA;function EA({className:e,align:t=`start`,sideOffset:n=4,collisionPadding:r=8,...i}){return(0,R.jsx)(SA,{children:(0,R.jsx)(CA,{align:t,sideOffset:n,collisionPadding:r,className:q(Ox,`max-h-(--radix-popover-content-available-height) min-w-32 p-1`,e),...i})})}var DA=(0,L.createContext)(()=>{});function OA({open:e,defaultOpen:t=!1,onOpenChange:n,children:r,...i}){let[a,o]=(0,L.useState)(t),s=t=>{e===void 0&&o(t),n?.(t)};return(0,R.jsx)(wA,{open:e??a,onOpenChange:s,...i,children:(0,R.jsx)(DA.Provider,{value:()=>s(!1),children:r})})}var kA=TA;function AA({className:e,loop:t=!0,onEscapeKeyDown:n,children:r,...i}){return(0,R.jsx)(EA,{className:q(`flex max-w-(--radix-popover-content-available-width) min-w-56 flex-col p-0`,e),onEscapeKeyDown:e=>{n?.(e),e.stopPropagation()},...i,children:(0,R.jsx)(Vk,{loop:t,className:`flex min-h-0 flex-col`,children:r})})}function jA({className:e,...t}){return(0,R.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border-subtle px-3 text-icon`,children:[(0,R.jsx)(eb,{size:14,className:`shrink-0`}),(0,R.jsx)(Ik,{className:q(`min-w-0 flex-1 appearance-none border-0 bg-transparent p-0 font-sans text-sm text-text outline-none placeholder:text-text-tertiary`,e),...t})]})}function MA({className:e,...t}){return(0,R.jsx)(Lk,{className:q(`max-h-64 overflow-y-auto overscroll-contain p-1`,e),...t})}function NA({className:e,...t}){return(0,R.jsx)(zk,{className:q(`px-2 py-1.5 text-sm text-text-tertiary`,e),...t})}var PA=Mx;function FA({heading:e,...t}){return(0,R.jsx)(Pk,{heading:e===void 0?void 0:(0,R.jsx)(`span`,{className:PA,children:e}),...t})}var IA=q(kx,Ax,`justify-between gap-3 aria-[current=true]:font-medium`);function LA({className:e,children:t,current:n=!1,onSelect:r,...i}){let a=(0,L.useContext)(DA);return(0,R.jsxs)(Nk,{"aria-current":n||void 0,className:q(IA,e),onSelect:e=>{r?.(e),a()},...i,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),n&&(0,R.jsx)(sb,{size:14,className:`shrink-0 text-text!`})]})}var RA={success:`bg-success`,warning:`bg-warning`,danger:`bg-danger`,accent:`bg-accent`,live:`bg-accent animate-breathe shadow-[0_0_0_3px_var(--color-accent-subtle)]`,neutral:`bg-icon`},zA={success:`text-success`,warning:`text-warning`,danger:`text-danger`,accent:`text-accent`,live:`text-accent`,neutral:`text-icon`};function BA({tone:e=`neutral`,label:t,className:n}){return(0,R.jsx)(`span`,{role:t?`img`:void 0,"aria-label":t,"aria-hidden":!t||void 0,title:t,className:q(`inline-block size-1.5 shrink-0 rounded-full`,RA[e],n)})}var VA={xs:{text:`text-xs`,box:`size-3.5 [&>svg]:size-3.5`},sm:{text:`text-sm`,box:`size-4 [&>svg]:size-4`}};function HA({tone:e=`neutral`,icon:t,phase:n,spinning:r=!1,size:i=`xs`,strong:a=!1,title:o,className:s,children:c}){let l=VA[i],u=r?(0,R.jsx)(KE,{size:`sm`}):n?(0,R.jsx)(sx,{phase:n,size:i===`xs`?14:16,label:``}):t?(0,R.jsx)(`span`,{className:q(`inline-flex`,zA[e]),children:t}):(0,R.jsx)(BA,{tone:e});return(0,R.jsxs)(`span`,{title:o,className:q(`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,l.text,a?`font-medium text-text`:`text-text-secondary`,s),children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:q(`inline-flex shrink-0 items-center justify-center`,l.box),children:u}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:c})]})}function UA({status:e}){switch(e){case`pending`:return(0,R.jsx)(HA,{tone:`neutral`,children:`Pending`});case`burning`:return(0,R.jsx)(HA,{spinning:!0,children:`Burning`});case`done`:return(0,R.jsx)(HA,{tone:`success`,icon:(0,R.jsx)(sb,{}),children:`Done`});case`failed`:return(0,R.jsx)(HA,{tone:`danger`,children:`Failed`});case`cancelled`:return(0,R.jsx)(HA,{tone:`neutral`,className:`text-text-tertiary line-through`,children:`Cancelled`})}}function WA({kind:e,passKind:t}){if(e===`implementation`)return null;let n=t===`verification`;return(0,R.jsx)(HA,{tone:`accent`,icon:(0,R.jsx)(Eb,{}),className:`shrink-0`,title:n?`Confirms the fixes that landed since the last review`:`Verifies the integrated feature branch`,children:n?`Verification`:`Review`})}function GA({author:e}){return e===`human`?null:(0,R.jsx)(HA,{tone:`accent`,icon:(0,R.jsx)(Db,{}),className:`shrink-0`,title:`Written by the review agent`,children:`Agent`})}function KA({severity:e}){switch(e){case`high`:return(0,R.jsx)(HA,{tone:`warning`,icon:(0,R.jsx)(Vb,{}),children:`High`});case`medium`:return(0,R.jsx)(HA,{tone:`neutral`,children:`Medium`});case`low`:return(0,R.jsx)(HA,{tone:`neutral`,className:`text-text-tertiary`,children:`Low`})}}function qA({status:e}){switch(e){case`running`:return(0,R.jsx)(HA,{spinning:!0,children:`Running`});case`succeeded`:return(0,R.jsx)(HA,{tone:`success`,icon:(0,R.jsx)(sb,{}),children:`Succeeded`});case`failed`:return(0,R.jsx)(HA,{tone:`danger`,children:`Failed`});case`cancelled`:return(0,R.jsx)(HA,{tone:`neutral`,className:`text-text-tertiary`,children:`Cancelled`})}}var JA={launching:`warning`,live:`live`,ended:`neutral`},YA={launching:`Starting`,live:`Live`,ended:`Ended`};function XA({status:e}){return(0,R.jsx)(`span`,{title:YA[e],className:q(`inline-block size-1.5 shrink-0 rounded-full`,RA[JA[e]],e===`launching`&&`animate-breathe`)})}var ZA={ok:`success`,warn:`warning`,danger:`danger`,idle:`neutral`};function QA({row:e}){return(0,R.jsxs)(`div`,{className:`flex min-h-7 items-center gap-2 text-sm`,children:[(0,R.jsx)(`span`,{className:`w-28 shrink-0 text-text-tertiary first-letter:uppercase`,children:e.key}),(0,R.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center`,children:(0,R.jsx)(BA,{tone:ZA[e.tone]})}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-text`,children:e.value})]})}function $A({children:e,count:t,action:n,className:r,id:i}){return(0,R.jsxs)(`div`,{id:i,className:q(`flex h-7 min-w-0 items-center gap-2 text-xs font-medium text-text-tertiary`,r),children:[(0,R.jsx)(`span`,{className:`truncate`,children:e}),t!=null&&(0,R.jsx)(`span`,{className:`font-normal text-text-tertiary tabular-nums`,children:t}),n&&(0,R.jsx)(`span`,{className:`ml-auto flex shrink-0 items-center`,children:n})]})}function ej({children:e}){return(0,R.jsx)(`span`,{className:`inline-flex min-h-4 min-w-4 shrink-0 items-center justify-center`,children:e})}function tj({href:e,onClick:t,current:n,title:r,label:i,expanded:a,className:o,children:s}){return e===void 0?(0,R.jsx)(`button`,{type:`button`,onClick:t,"aria-current":n?`page`:void 0,"aria-label":i,"aria-expanded":a,title:r,className:o,children:s}):(0,R.jsx)(`a`,{href:e,onClick:t,"aria-current":n?`page`:void 0,"aria-label":i,title:r,className:q(o,`no-underline`),children:s})}function nj({icon:e,phase:t,label:n,meta:r,dot:i,active:a=!1,href:o,onClick:s,actions:c,onContextMenu:l,onDoubleClick:u,tone:d=`default`,title:f,className:p}){let m=d===`quiet`,h=r!=null,g=t?(0,R.jsx)(sx,{phase:t}):e?(0,R.jsx)(`span`,{className:q(`inline-flex [&>svg]:size-4`,a?`text-text`:`text-icon group-hover/nav:text-text`),children:e}):null;return(0,R.jsxs)(`div`,{onContextMenu:l,onDoubleClick:u,className:q(`group/nav relative flex min-w-0 shrink-0 items-center rounded-md`,`transition-colors duration-(--dur-1) ease-app`,m?`h-7`:`h-(--row-h)`,a?`bg-surface-selected text-text`:m?`text-text-tertiary hover:bg-surface-hover/50 hover:text-text-secondary`:`text-text-secondary hover:bg-surface-hover/50 hover:text-text`,p),children:[(0,R.jsxs)(tj,{href:o,onClick:s,current:a,title:f??(typeof n==`string`?n:void 0),className:q(`flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md pr-3 text-left text-inherit`,m?`pl-8.5 text-xs`:`pl-2.5 text-sm`,a&&`font-medium`),children:[g&&(0,R.jsx)(ej,{children:g}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(i||h)&&(0,R.jsxs)(`span`,{className:q(`flex shrink-0 items-center gap-2`,c!=null&&`transition-opacity duration-(--dur-1) group-focus-within/nav:opacity-0 group-hover/nav:opacity-0 group-has-[[aria-expanded=true]]/nav:opacity-0`),children:[i&&(0,R.jsx)(BA,{tone:i}),h&&(0,R.jsx)(`span`,{className:`text-xs font-normal text-text-tertiary tabular-nums`,children:r})]})]}),c&&(0,R.jsx)(`span`,{className:q(`absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-0.5`,`opacity-0 transition-opacity duration-(--dur-1) group-focus-within/nav:opacity-100 group-hover/nav:opacity-100`,`has-[[aria-expanded=true]]:opacity-100`),children:c})]})}function rj({leading:e,title:t,subtitle:n,description:r,wrap:i=!1,meta:a,onClick:o,href:s,tooltip:c,label:l,expanded:u,control:d,actions:f,actionsOverlay:p=!1,active:m=!1,index:h,animate:g=!1,as:_=`div`,className:v}){let y=o!==void 0||s!==void 0,b=h!==void 0&&h<8,x=i||r!==void 0,S=a!=null,C=p&&!!f,w=S&&(0,R.jsx)(`span`,{className:q(`shrink-0 text-xs text-text-tertiary tabular-nums`,i&&`mt-0.5 self-start`,C&&`transition-opacity duration-(--dur-1) group-focus-within/row:opacity-0 group-hover/row:opacity-0`),children:a}),T=(0,R.jsxs)(R.Fragment,{children:[e&&(0,R.jsx)(`span`,{className:q(`inline-flex shrink-0`,x&&`mt-0.5 self-start`),children:(0,R.jsx)(ej,{children:(0,R.jsx)(`span`,{className:`inline-flex text-icon [&>svg]:size-4`,children:e})})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsxs)(`span`,{className:i?`min-w-0 text-pretty wrap-anywhere`:`min-w-0 truncate`,children:[t,n&&(0,R.jsx)(`span`,{className:`ml-2 text-text-tertiary`,children:n})]}),r!==void 0&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-xs text-text-tertiary`,children:r})]}),!d&&w]}),E=q(`flex min-h-10 min-w-0 flex-1 gap-3 rounded-md px-3 text-left text-sm text-text`,i?`items-start`:`items-center`,x&&`py-2`);return(0,R.jsxs)(_,{"data-list-row":``,style:b?{"--i":h}:void 0,className:q(`group/row relative flex min-w-0 items-center rounded-md transition-colors duration-(--dur-1) ease-app`,`list-none`,m?`bg-surface-selected`:y&&`hover:bg-surface-hover`,(b||g)&&`animate-rise-in`,b&&`[animation-delay:calc(var(--i)*20ms)]`,v),children:[y?(0,R.jsx)(tj,{href:s,onClick:o,current:m,title:c,label:l,expanded:u,className:q(E,`cursor-pointer`),children:T}):(0,R.jsx)(`div`,{className:E,children:T}),d&&(0,R.jsx)(`span`,{className:`flex min-w-0 shrink items-center`,children:d}),d&&S&&(0,R.jsx)(`span`,{className:`flex shrink-0 items-center pr-3 pl-3`,children:w}),f&&(0,R.jsx)(`span`,{className:q(`flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity duration-(--dur-1)`,`group-focus-within/row:opacity-100 group-hover/row:opacity-100 has-[[aria-expanded=true]]:opacity-100`,C?q(`absolute right-2 rounded-md bg-inherit pl-1`,i?`top-1.5`:`top-1/2 -translate-y-1/2`):`mr-2`),children:f})]})}function ij({divided:e=!1,label:t,className:n,children:r}){return(0,R.jsx)(`div`,{"aria-label":t,className:q(`flex flex-col`,e&&`[&>[data-list-row]]:rounded-none [&>[data-list-row]]:border-b [&>[data-list-row]]:border-border-subtle [&>[data-list-row]:last-child]:border-b-0`,n),children:r})}function aj({items:e,className:t}){return(0,R.jsx)(`dl`,{className:q(`m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-1.5 text-sm`,t),children:e.map((e,t)=>{let n=e.leading??(e.phase?(0,R.jsx)(sx,{phase:e.phase,size:14,label:``}):e.tone?(0,R.jsx)(BA,{tone:e.tone}):null);return(0,R.jsxs)(`div`,{className:`contents`,children:[(0,R.jsx)(`dt`,{className:`flex min-h-6 items-center text-text-tertiary`,children:e.label}),(0,R.jsxs)(`dd`,{className:`m-0 flex min-h-6 min-w-0 items-center gap-2 text-text`,children:[n&&(0,R.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center text-icon [&>svg]:size-3.5`,children:n}),(0,R.jsx)(`span`,{className:q(`min-w-0`,e.mono?`truncate font-mono text-xs text-text-secondary`:`font-medium`),children:e.value}),e.sub&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-text-tertiary`,children:e.sub})]})]},t)})})}function oj({items:e,className:t}){return(0,R.jsx)(`div`,{className:q(`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-text-tertiary`,t),children:e.map((e,t)=>{if(!e)return null;let n=e.phase?(0,R.jsx)(sx,{phase:e.phase,size:14,label:``}):e.tone?(0,R.jsx)(BA,{tone:e.tone}):e.icon?(0,R.jsx)(`span`,{className:q(`inline-flex [&>svg]:size-3.5`,zA.neutral),children:e.icon}):null;return(0,R.jsxs)(`span`,{title:e.title,className:`inline-flex min-w-0 items-center gap-1.5`,children:[n,e.strong!==void 0&&(0,R.jsx)(`span`,{className:`font-medium text-text-secondary`,children:e.strong}),e.text!==void 0&&(0,R.jsx)(`span`,{className:q(`min-w-0 truncate`,e.mono&&`font-mono`),children:e.text})]},t)})})}var sj={sm:`h-(--control-sm) px-2 text-sm`,md:`h-(--control-h) px-2.5 text-sm`};function cj({items:e,value:t,onChange:n,size:r=`md`,label:i,className:a}){let o=(0,L.useRef)([]),s=e.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0);return(0,R.jsx)(`div`,{role:`tablist`,"aria-label":i,onKeyDown:r=>{let i=e.findIndex(e=>e.id===t),a=s.indexOf(i),c;if(r.key===`ArrowRight`?c=s[(a+1)%s.length]:r.key===`ArrowLeft`?c=s[(a-1+s.length)%s.length]:r.key===`Home`?c=s[0]:r.key===`End`&&(c=s[s.length-1]),c===void 0)return;r.preventDefault();let l=e[c];l&&(n(l.id),o.current[c]?.focus())},className:q(`flex items-center gap-0.5`,a),children:e.map((e,i)=>{let a=e.id===t;return(0,R.jsxs)(`button`,{ref:e=>{o.current[i]=e},type:`button`,role:`tab`,"aria-selected":a,"aria-controls":e.panelId,tabIndex:a?0:-1,disabled:e.disabled,onClick:()=>n(e.id),className:q(`inline-flex shrink-0 cursor-pointer items-center gap-1.5 rounded-md font-medium whitespace-nowrap`,`transition-colors duration-(--dur-1) ease-app disabled:cursor-not-allowed disabled:text-text-disabled`,sj[r],a?`bg-surface-selected text-text`:`text-text-tertiary enabled:hover:text-text`),children:[e.icon&&(0,R.jsx)(`span`,{className:q(`inline-flex [&>svg]:size-3.5`,a?`text-text`:`text-icon`),children:e.icon}),e.label,e.count!==void 0&&e.count!==null&&(0,R.jsx)(`span`,{className:`text-xs font-normal text-text-tertiary tabular-nums`,children:e.count})]},e.id)})})}var lj=`h-(--control-h) w-full min-w-0 rounded-md border border-border bg-surface-inset px-2.5 text-sm text-text transition-colors duration-(--dur-1) ease-app placeholder:text-text-tertiary hover:border-border-strong focus:border-accent disabled:cursor-not-allowed disabled:text-text-disabled aria-invalid:border-danger`,uj=`flex min-w-0 items-center gap-2 rounded-md border border-border bg-surface-inset pr-1.5 pl-2.5 cursor-text transition-colors duration-(--dur-1) ease-app hover:border-border-strong focus-within:border-accent focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-focus-ring has-[input:disabled]:cursor-not-allowed has-[input[aria-invalid=true]]:border-danger`,dj={md:`h-(--control-h)`,lg:`h-(--control-lg)`};function fj({icon:e,kbd:t,size:n=`md`,mono:r=!1,invalid:i,className:a,inputClassName:o,trailing:s,type:c=`text`,...l}){return(0,R.jsxs)(`div`,{className:q(uj,dj[n],a),children:[e&&(0,R.jsx)(`span`,{className:`inline-flex shrink-0 text-icon [&>svg]:size-3.5`,children:e}),(0,R.jsx)(`input`,{type:c,"data-field-input":``,"aria-invalid":i||void 0,className:q(`h-full min-w-0 flex-1 appearance-none border-0 bg-transparent p-0 text-text outline-none`,`placeholder:text-text-tertiary disabled:cursor-not-allowed disabled:text-text-disabled`,r?`font-mono text-xs`:`font-sans text-sm`,o),...l}),s,t&&(0,R.jsx)(Px,{children:t})]})}function pj({size:e=`lg`,placeholder:t=`Search`,...n}){return(0,R.jsx)(fj,{icon:(0,R.jsx)(eb,{}),size:e,placeholder:t,"aria-label":n[`aria-label`]??t,...n})}function mj({mono:e=!1,invalid:t,className:n,rows:r=4,...i}){return(0,R.jsx)(`textarea`,{rows:r,"aria-invalid":t||void 0,className:q(`block w-full min-w-0 resize-y rounded-md border border-border bg-surface-inset px-2.5 py-1.5`,`text-text transition-colors duration-(--dur-1) ease-app`,`placeholder:text-text-tertiary hover:border-border-strong focus:border-accent`,`disabled:cursor-not-allowed disabled:text-text-disabled aria-invalid:border-danger`,e?`font-mono text-xs leading-[18px]`:`font-sans text-sm`,n),...i})}function hj({label:e,labelAside:t,help:n,error:r,htmlFor:i,layout:a=`flex flex-col gap-1.5`,children:o}){let s=(0,L.useId)(),c=(0,L.isValidElement)(o)?o:null,l=c?.props.id??i??s,u=`${l}-help`,d=`${l}-error`,f=q(n?u:null,r?d:null)||void 0,p=(0,R.jsx)(`label`,{className:`text-sm font-medium text-text-secondary`,htmlFor:l,children:e});return(0,R.jsxs)(`div`,{className:a,children:[t?(0,R.jsxs)(`div`,{className:`flex min-h-(--control-h) items-center gap-1.5`,children:[p,t]}):p,c?(0,L.cloneElement)(c,{id:l,"aria-describedby":q(c.props[`aria-describedby`],f)||void 0}):o,n&&(0,R.jsx)(`div`,{id:u,className:`text-xs text-text-tertiary`,children:n}),r&&(0,R.jsx)(`div`,{id:d,role:`alert`,className:`text-xs text-danger`,children:r})]})}function gj({items:e,className:t}){return(0,R.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:q(`flex min-w-0 items-center`,t),children:(0,R.jsx)(`ol`,{className:`m-0 flex min-w-0 list-none items-center gap-1 p-0 text-sm`,children:e.map((t,n)=>{let r=n===e.length-1,i=(0,R.jsxs)(R.Fragment,{children:[t.icon&&(0,R.jsx)(`span`,{className:`inline-flex shrink-0 text-icon [&>svg]:size-3.5`,children:t.icon}),(0,R.jsx)(`span`,{className:q(`truncate`,t.mono&&`font-mono text-xs`),children:t.label})]}),a=q(`inline-flex min-w-0 items-center gap-1.5 rounded-md px-1 py-0.5`,r?`font-medium text-text`:`shrink-0 text-text-tertiary`);return(0,R.jsxs)(`li`,{className:q(`flex min-w-0 items-center gap-1`,!r&&`shrink-0`),children:[r?(0,R.jsx)(`span`,{"aria-current":`page`,className:a,children:i}):t.href===void 0?t.onClick?(0,R.jsx)(`button`,{type:`button`,onClick:t.onClick,className:q(a,`cursor-pointer hover:text-text`),children:i}):(0,R.jsx)(`span`,{className:a,children:i}):(0,R.jsx)(`a`,{href:t.href,onClick:t.onClick,className:q(a,`no-underline hover:text-text`),children:i}),!r&&(0,R.jsx)(fb,{size:12,className:`shrink-0 text-text-disabled`})]},n)})})})}function _j({leading:e,crumbs:t,tabs:n,actions:r,className:i}){return(0,R.jsxs)(`header`,{className:q(`flex h-(--topbar-h) shrink-0 items-center gap-3 border-b border-border-subtle pr-3 pl-4`,i),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[e,t&&(0,R.jsx)(gj,{items:t})]}),n&&(0,R.jsx)(`div`,{className:`flex shrink-0 items-center`,children:n}),r&&(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:r})]})}var vj={default:`max-w-(--content-max)`,wide:`max-w-(--content-wide)`};function yj({width:e=`default`,routeKey:t,className:n,children:r}){return(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,R.jsx)(`div`,{className:q(`mx-auto w-full px-8 pt-12 pb-16 animate-rise-in`,vj[e],n),children:r},t)})}function bj({title:e,meta:t,actions:n,className:r,children:i}){return(0,R.jsxs)(`header`,{className:q(`flex flex-col`,r),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.jsx)(`h1`,{className:`m-0 min-w-0 flex-1 text-xl font-semibold text-pretty text-text`,children:e}),n&&(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n})]}),t!=null&&(0,R.jsx)(`div`,{className:`mt-2`,children:Array.isArray(t)?(0,R.jsx)(oj,{items:t}):t}),i&&(0,R.jsx)(`div`,{className:`mt-5`,children:i})]})}function xj({title:e,action:t,id:n,className:r,children:i}){return(0,R.jsxs)(`section`,{id:n,className:q(`mt-10 first:mt-0`,r),children:[(e||t)&&(0,R.jsxs)(`div`,{className:`mb-3 flex min-h-7 items-center gap-3`,children:[e&&(0,R.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 text-lg font-semibold text-text`,children:e}),t&&(0,R.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:t})]}),i]})}function Sj({title:e,label:t,onClose:n,actions:r,className:i,bodyClassName:a,children:o}){return(0,R.jsxs)(`aside`,{"aria-label":t??(typeof e==`string`?e:void 0),className:q(`flex h-full w-(--aside-w) min-w-0 shrink-0 flex-col border-l border-border bg-surface animate-slide-in-right`,i),children:[(0,R.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-border-subtle pr-2 pl-4`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-text`,children:e}),r,(0,R.jsx)(UE,{label:`Close`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:n})]}),(0,R.jsx)(`div`,{className:q(`min-h-0 flex-1 overflow-y-auto`,a),children:o})]})}function Cj({aside:e,className:t,asideClassName:n,children:r}){let i=!(e==null||e===!1);return(0,R.jsxs)(`div`,{className:`@container relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsx)(`div`,{className:q(`flex min-h-0 min-w-0 flex-1 flex-col`,t),children:r}),i&&(0,R.jsx)(`div`,{className:q(`flex h-full shrink-0 @max-4xl:absolute @max-4xl:inset-y-0 @max-4xl:right-0 @max-4xl:z-20 @max-4xl:h-auto @max-4xl:shadow-dialog`,n),children:e})]})}var wj={sm:`h-(--control-sm) text-xs`,md:`h-(--control-h) text-sm`};function Tj({items:e,value:t,onChange:n,label:r,size:i=`md`,id:a,className:o}){let s=(0,L.useRef)([]),c=Math.max(0,e.findIndex(e=>e.value===t)),l=(t,r)=>{let i=e.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0);if(i.length===0)return;let a;a=r===`first`?i[0]:r===`last`?i[i.length-1]:i[(i.indexOf(t)+r+i.length)%i.length],s.current[a]?.focus(),n(e[a].value)},u=(e,t)=>{let n=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:e.key===`Home`?`first`:e.key===`End`?`last`:null;n!==null&&(e.preventDefault(),l(t,n))};return(0,R.jsx)(`div`,{id:a,role:`radiogroup`,"aria-label":r,className:q(`inline-flex rounded-md border border-border bg-surface-inset p-0.5`,o),children:(0,R.jsxs)(`div`,{className:`relative grid w-full`,style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-segment-thumb":``,className:`pointer-events-none absolute inset-y-0 left-0 rounded-[5px] bg-surface-selected shadow-popover transition-transform duration-(--dur-2) ease-out-app`,style:{width:`${100/e.length}%`,transform:`translateX(${c*100}%)`}}),e.map((e,t)=>{let r=t===c;return(0,R.jsxs)(`button`,{ref:e=>{s.current[t]=e},type:`button`,role:`radio`,"aria-checked":r,tabIndex:r?0:-1,disabled:e.disabled,onClick:()=>n(e.value),onKeyDown:e=>u(e,t),className:q(`relative inline-flex min-w-0 cursor-pointer items-center justify-center gap-1.5 rounded-[5px] px-2.5 font-medium`,`transition-colors duration-(--dur-1) ease-app disabled:cursor-not-allowed disabled:text-text-disabled`,wj[i],r?`text-text`:`text-text-tertiary enabled:hover:text-text-secondary`),children:[e.icon&&(0,R.jsx)(`span`,{className:q(`inline-flex shrink-0 [&>svg]:size-3.5`,r?`text-text`:`text-icon`),children:e.icon}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})]})})}var Ej=`peer col-start-1 row-start-1 m-0 size-3.5 cursor-pointer appearance-none rounded-sm border border-border-strong bg-surface-inset transition-colors duration-(--dur-1) ease-app hover:border-text-tertiary checked:border-primary checked:bg-primary checked:hover:bg-primary-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:cursor-not-allowed disabled:border-border disabled:checked:bg-text-disabled`;function Dj({checked:e,onChange:t,label:n,disabled:r,size:i=`sm`,id:a,className:o,"aria-label":s}){return(0,R.jsxs)(`label`,{className:q(`inline-flex cursor-pointer items-center gap-2 select-none`,i===`sm`?`text-xs`:`text-sm`,r?`cursor-not-allowed text-text-disabled`:`text-text-secondary hover:text-text`,o),children:[(0,R.jsxs)(`span`,{className:`grid shrink-0 place-items-center`,children:[(0,R.jsx)(`input`,{id:a,type:`checkbox`,className:Ej,checked:e,disabled:r,"aria-label":s,onChange:e=>t(e.target.checked)}),(0,R.jsx)(sb,{size:12,strokeWidth:2,className:`pointer-events-none col-start-1 row-start-1 text-on-primary opacity-0 transition-opacity duration-(--dur-1) peer-checked:opacity-100`})]}),n]})}function Oj({label:e,className:t,children:n}){let r=(0,R.jsx)(`div`,{"aria-hidden":`true`,"data-progress":``,className:`animate-breathe`,children:n});return e===void 0?(0,R.jsx)(`div`,{className:q(Aj,t),children:r}):(0,R.jsxs)(`div`,{role:`status`,className:q(Aj,t),children:[(0,R.jsx)(`span`,{className:`sr-only`,children:e}),r]})}function kj({className:e}){return(0,R.jsx)(`span`,{className:q(`block shrink-0 rounded-sm bg-surface-selected`,e)})}var Aj=`animate-fade-in [animation-delay:300ms]`;function jj({label:e,className:t,children:n}){return(0,R.jsx)(`ol`,{"aria-label":e,className:q(`relative m-0 flex list-none flex-col gap-3 p-0 pt-2 pb-1`,`before:absolute before:top-4 before:bottom-5 before:left-[11px] before:w-px before:bg-border-strong before:content-['']`,t),children:n})}var Mj={success:`text-success bg-[color-mix(in_srgb,var(--color-success)_16%,var(--color-surface))] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-success)_45%,transparent)]`,warning:`text-warning bg-[color-mix(in_srgb,var(--color-warning)_16%,var(--color-surface))] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-warning)_45%,transparent)]`,danger:`text-danger bg-[color-mix(in_srgb,var(--color-danger)_16%,var(--color-surface))] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-danger)_45%,transparent)]`,neutral:`text-icon bg-[color-mix(in_srgb,var(--color-icon)_16%,var(--color-surface))] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-icon)_45%,transparent)]`};function Nj({variant:e=`ring`,tone:t=`neutral`,icon:n,title:r,meta:i,aside:a,children:o}){let s=e===`milestone`;return(0,R.jsxs)(`li`,{"data-node":e,className:q(`relative flex min-w-0 flex-col pl-9`,s&&`pt-1.5 pb-2`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`absolute left-0 grid size-[23px] place-items-center bg-surface`,s?`top-3`:`top-1`),children:s?(0,R.jsx)(`span`,{className:q(`grid size-[23px] place-items-center rounded-full [&>svg]:size-3.5`,Mj[t]),children:n}):(0,R.jsx)(`span`,{className:`size-[9px] rounded-full border-[1.5px] border-border-strong bg-surface`})}),(0,R.jsxs)(`div`,{className:`flex min-h-[30px] flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,R.jsx)(`span`,{className:q(s?`text-base font-medium text-text`:`text-sm text-text-secondary`),children:r}),i&&(0,R.jsx)(`span`,{className:`text-xs text-text-secondary`,children:i}),a&&(0,R.jsx)(`span`,{className:`ml-auto flex items-center gap-2`,children:a})]}),o]})}function Pj({children:e}){return(0,R.jsx)(`div`,{className:`py-0.5 text-xs text-text-tertiary`,children:e})}function Fj({icon:e,title:t,hint:n,action:r,compact:i,className:a}){return(0,R.jsxs)(`div`,{className:q(`flex flex-col items-center justify-center gap-1.5 text-center`,i?`px-6 py-8`:`px-6 py-12`,a),children:[e&&(0,R.jsx)(`div`,{className:`mb-1.5 inline-flex text-text-tertiary [&>svg]:size-5`,children:e}),(0,R.jsx)(`div`,{className:`text-base leading-5 font-medium text-text`,children:t}),n&&(0,R.jsx)(`div`,{className:`max-w-80 text-sm text-pretty text-text-tertiary`,children:n}),r&&(0,R.jsx)(`div`,{className:`mt-3`,children:r})]})}var Ij={md:`h-10 items-center gap-2 text-sm font-medium text-text-secondary hover:text-text`,sm:`min-h-6 items-start gap-1.5 py-1 text-xs text-text-tertiary hover:text-text-secondary`},Lj={md:`pb-4 pl-6 text-sm text-text-secondary`,sm:`pt-0.5 pb-2 pl-4.5 text-xs text-text-secondary`};function Rj({title:e,icon:t,aside:n,defaultOpen:r=!1,bare:i=!1,size:a=`md`,index:o,animate:s=!1,onToggle:c,className:l,bodyClassName:u,children:d}){let[f]=(0,L.useState)(r),p=o!==void 0&&o<8;return(0,R.jsxs)(`details`,{"data-disclosure":``,open:f,onToggle:c&&(e=>c(e.currentTarget.open)),style:p?{"--i":o}:void 0,className:q(`group/disclosure min-w-0`,a===`md`&&!i&&`border-t border-border-subtle`,(p||s)&&`animate-rise-in`,p&&`[animation-delay:calc(var(--i)*20ms)]`,l),children:[(0,R.jsxs)(`summary`,{className:q(`flex cursor-pointer list-none rounded-md`,`transition-colors duration-(--dur-1) ease-app select-none [&::-webkit-details-marker]:hidden`,Ij[a]),children:[(0,R.jsx)(fb,{size:a===`sm`?12:14,className:q(`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app group-open/disclosure:rotate-90`,a===`sm`&&`mt-0.5`)}),t&&(0,R.jsx)(`span`,{className:`inline-flex shrink-0 text-icon [&>svg]:size-3.5`,children:t}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1`,a===`md`&&`truncate`),children:e}),n&&(0,R.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-text-tertiary`,children:n})]}),(0,R.jsx)(`div`,{className:q(Lj[a],u),children:d})]})}function zj({message:e,path:t,hint:n,action:r,id:i}){return(0,R.jsxs)(`div`,{className:`rounded-md bg-danger-subtle px-3 py-2.5`,id:i,role:`alert`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-danger`,children:e}),t&&(0,R.jsx)(`div`,{className:`mt-1 truncate text-left font-mono text-xs text-text-tertiary`,dir:`rtl`,title:t,children:(0,R.jsx)(`bdi`,{children:t})}),n&&(0,R.jsx)(`p`,{className:`mt-1.5 mb-0 text-sm text-text-secondary`,children:n}),r&&(0,R.jsx)(`div`,{className:`mt-2.5`,children:r})]})}var Bj={sm:`max-w-[460px]`,md:`max-w-[620px]`,lg:`max-w-[780px]`,xl:`max-w-[940px]`,palette:`max-w-[560px]`,full:`max-w-[min(1400px,96vw)]`},Vj={dim:`bg-scrim animate-backdrop-in`,light:`bg-scrim/40 animate-backdrop-in`,none:`pointer-events-none bg-transparent`};function Hj({open:e,onClose:t,size:n=`md`,scrim:r=`dim`,label:i,labelledBy:a,dirty:o=!1,discardPrompt:s=`Discard what you have typed?`,initialFocusRef:c,returnFocusRef:l,inline:u=!1,backdropClassName:d,className:f,children:p}){let[m,h]=(0,L.useState)(!1),g=(0,L.useRef)(null);if((0,L.useEffect)(()=>{if(!e)return;let t=l?.current??document.activeElement,n=g.current;return n&&!n.contains(document.activeElement)&&(c?.current??n).focus(),()=>{let e=document.activeElement;if(!(e===null||e===document.body||!e.isConnected||n?.contains(e)))return;let r=t instanceof HTMLElement&&t.isConnected?t:l?.current;r?.isConnected&&(r.focus(),queueMicrotask(()=>{let e=document.activeElement,t=r.isConnected?r:l?.current;t?.isConnected&&(e===null||e===document.body)&&t.focus()}))}},[e]),(0,L.useEffect)(()=>{if(!e)return;let n=e=>{if(e.key!==`Escape`)return;let n=document.activeElement;(n===null||n===document.body||g.current?.contains(n))&&(m?h(!1):o?h(!0):t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,m,o,t]),!e)return null;let _=()=>{o?h(!0):t()},v=(0,R.jsx)(`div`,{className:q(u?`flex flex-1 items-center justify-center p-6`:q(`fixed inset-0 z-[200] flex items-start justify-center px-4 pb-4`,n===`palette`?`pt-[12vh]`:`pt-[8vh]`,Vj[r]),d),onMouseDown:e=>{e.target===e.currentTarget&&(e.preventDefault(),_())},children:(0,R.jsxs)(`div`,{ref:g,role:`dialog`,"aria-modal":!u||void 0,"aria-label":i,"aria-labelledby":a,tabIndex:-1,className:q(`w-full rounded-lg bg-surface-raised text-sm text-text shadow-dialog animate-dialog-in`,r===`none`&&`pointer-events-auto`,Bj[n],f),children:[typeof p==`function`?p(_):p,m&&(0,R.jsxs)(`div`,{className:`m-4 flex items-center gap-2 rounded-md bg-surface-hover px-3 py-2 animate-fade-in`,role:`alert`,children:[(0,R.jsx)(`span`,{className:`flex-1 text-sm text-text`,children:s}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Keep editing`}),(0,R.jsx)(Y,{variant:`danger`,size:`sm`,onClick:t,children:`Discard`})]})]})});return u?v:(0,Dx.createPortal)(v,document.body)}function Uj({title:e,description:t,onClose:n,id:r,className:i}){return(0,R.jsxs)(`div`,{className:q(`flex items-start gap-3 px-5 pt-4 pb-3`,i),children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h2`,{id:r,className:`m-0 text-lg font-semibold text-text`,children:e}),t&&(0,R.jsx)(`p`,{className:`mt-1 mb-0 text-sm text-text-secondary`,children:t})]}),n&&(0,R.jsx)(UE,{label:`Close`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:n,className:`-mr-1`})]})}function Wj({className:e,children:t}){return(0,R.jsx)(`div`,{className:q(`px-5 pb-4`,e),children:t})}function Gj({start:e,className:t,children:n}){return(0,R.jsxs)(`div`,{className:q(`flex items-center gap-2 px-5 pt-1 pb-4`,t),children:[e&&(0,R.jsx)(`div`,{className:`mr-auto flex min-w-0 items-center gap-2 text-xs text-text-tertiary`,children:e}),(0,R.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]})}var Kj=/^(?:runcastle\/|worktree-|afk\/)/,qj=`inline-flex h-(--control-h) min-w-0 items-center gap-1.5 rounded-md border px-2 text-sm transition-colors duration-(--dur-1) ease-app disabled:cursor-not-allowed disabled:text-text-disabled`;function Jj({prefix:e,value:t,branches:n,detected:r,onPick:i,missing:a=!1,disabled:o=!1,className:s}){let c=(n??[]).filter(e=>!Kj.test(e)),l=r&&c.includes(r)?r:null,u=c.filter(e=>e!==l),d=e=>(0,R.jsx)(LA,{value:e,current:e===t,onSelect:()=>i(e),children:e},e);return(0,R.jsxs)(OA,{children:[(0,R.jsxs)(kA,{disabled:o||!n,className:q(qj,a?`border-transparent text-warning`:`border-transparent text-text-secondary enabled:hover:bg-surface-hover enabled:hover:text-text`,s),children:[(0,R.jsxs)(`span`,{className:`truncate`,children:[e,` `,t??`…`]}),(0,R.jsx)(db,{size:12,className:`shrink-0 text-icon`})]}),(0,R.jsxs)(AA,{align:`end`,children:[(0,R.jsx)(jA,{placeholder:`Find a branch…`}),(0,R.jsxs)(MA,{label:`${e} branch`,className:`font-mono text-xs`,children:[(0,R.jsx)(NA,{children:c.length===0?`No branches to land on`:`No branch matches`}),l?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(FA,{heading:`Detected main line`,children:d(l)}),u.length>0&&(0,R.jsx)(FA,{heading:`Other local branches`,children:u.map(d)})]}):u.map(d)]})]})]})}var Yj=`flex items-center gap-2 py-2 text-xs font-medium`;function Xj({groups:e,currentLap:t,meta:n,headClassName:r,children:i}){return t<=1?(0,R.jsx)(R.Fragment,{children:i(e.flatMap(e=>e.rows))}):(0,R.jsx)(R.Fragment,{children:e.map(e=>{let t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{children:[`Lap `,e.lap]}),(0,R.jsx)(`span`,{className:`font-normal text-text-tertiary`,children:n(e)})]});return e.current?(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`div`,{className:q(Yj,r,`text-text-secondary`),children:t}),i(e.rows)]},e.lap):(0,R.jsxs)(`details`,{className:`group/lap`,"data-disclosure":``,children:[(0,R.jsxs)(`summary`,{className:q(Yj,r,`cursor-pointer list-none text-text-tertiary hover:text-text [&::-webkit-details-marker]:hidden`),children:[(0,R.jsx)(fb,{size:12,className:`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app group-open/lap:rotate-90`}),t]}),i(e.rows)]},e.lap)})})}var Zj={md:`h-[54px] w-24 rounded-md`,sm:`h-[26px] w-10 rounded-sm cursor-zoom-in`};function Qj({url:e,onOpen:t,size:n=`md`}){return e?(0,R.jsx)(`button`,{type:`button`,className:q(`shrink-0 cursor-pointer overflow-hidden border border-border bg-surface-inset p-0`,`transition-colors duration-(--dur-1) ease-app hover:border-border-strong`,Zj[n]),title:`see the whole picture`,onClick:()=>t(e),children:(0,R.jsx)(`img`,{src:e,alt:`the picture attached to this note`,className:`h-full w-full object-cover`})}):null}function $j(e,t){return Number.isFinite(t)?Math.min(e.max,Math.max(e.min,Math.round(t))):e.default}function eM(e){let t=null;try{t=localStorage.getItem(e.key)}catch{return e.default}if(t===null)return e.default;let n=Number(t);return Number.isFinite(n)?$j(e,n):e.default}function tM(e,t){try{localStorage.setItem(e.key,String(t))}catch{}}function nM(e){let[t,n]=(0,L.useState)(()=>eM(e));return(0,L.useEffect)(()=>{tM(e,t)},[e,t]),{width:t,setWidth:(0,L.useCallback)(t=>n($j(e,t)),[e])}}var rM={key:`runcastle.sidebar.w`,min:220,max:420,default:248};function iM(e){return $j(rM,e)}function aM(){return nM(rM)}function oM(e,t=``){return/mac|iphone|ipad|ipod/i.test(e)||/mac os x/i.test(t)}function sM(e,t=``){return/win/i.test(e)||/windows/i.test(t)}function cM(e,t,n=``){return oM(t,n)?`⌘${e}`:`Ctrl+${e}`}function lM(e,t=``){return cM(`K`,e,t)}function uM(e,t=``){return sM(e,t)?`C:\\Users\\you\\code\\your-repo`:`/path/to/your/repo`}function dM(e,t,n=``){let r=e.trim();return sM(t,n)?/^[A-Za-z]:[\\/]/.test(r)||/^\\\\/.test(r):r.startsWith(`/`)}function fM(){return typeof navigator>`u`?{platform:``,userAgent:``}:{platform:navigator.platform??``,userAgent:navigator.userAgent??``}}function pM(){let e=fM();return lM(e.platform,e.userAgent)}function mM(e){let t=fM();return cM(e,t.platform,t.userAgent)}function hM(){let e=fM();return uM(e.platform,e.userAgent)}function gM(e){let t=fM();return dM(e,t.platform,t.userAgent)}var _M=`docker`;function vM(e){return e.permission===`denied`?{state:`blocked`,label:`notify blocked`,title:`Your browser has blocked notifications for runcastle. Allow them in site settings (the icon beside the address bar), then click again.`}:e.enabled?{state:`on`,label:`notify on`,title:`Desktop notifications on — click to turn them off`}:{state:`off`,label:`notify off`,title:gv}}function yM(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.status!=`string`||typeof t.summary!=`string`||t.status!==`succeeded`&&t.status!==`failed`&&t.status!==`cancelled`?null:{status:t.status,summary:t.summary}}function bM(e){let t=e.split(`
|
|
122
|
-
`)[0].trim();return t.length>140?`${t.slice(0,139)}…`:t}function xM(e,t){if(e.type!==`run.finished`)return null;let n=yM(e.data);if(!n)return null;let r=t??`your feature`;return n.status===`succeeded`?{title:`Burn complete — review is ready`,body:r}:n.status===`failed`?{title:`Burn failed`,body:`${r}: ${bM(n.summary)}`}:null}var SM=`runcastle:notifications`,CM=typeof Notification<`u`;function wM(){try{return localStorage.getItem(SM)===`on`}catch{return!1}}function TM(e){try{localStorage.setItem(SM,e?`on`:`off`)}catch{}}function EM({title:e,body:t}){try{let n=new Notification(e,{body:t});n.onclick=()=>{window.focus(),n.close()}}catch{}}function DM(e,t){let[n,r]=(0,L.useState)(()=>CM&&wM()),[i,a]=(0,L.useState)(()=>CM?Notification.permission:`default`),[o,s]=(0,L.useState)(void 0),c=(0,L.useRef)(!1),l=(0,L.useRef)(new Map);l.current=new Map(t.map(e=>[e.id,e.title]));let u=B.events.listByProject.useQuery({projectId:e,afterId:o},{refetchInterval:Ch(),enabled:CM&&n});return(0,L.useEffect)(()=>{let e=u.data;if(!e||e.length===0)return;let t=e[e.length-1].id,n=document.hidden||!document.hasFocus();if(c.current&&Notification.permission===`granted`&&n)for(let t of e){let e=xM(t,t.featureId?l.current.get(t.featureId):void 0);e&&EM(e)}c.current=!0,s(t)},[u.data]),{supported:CM,enabled:n,permission:i,toggle:(0,L.useCallback)(()=>{if(CM){if(Notification.permission===`denied`){a(`denied`);return}if(n){r(!1),TM(!1);return}c.current=!1,s(void 0),r(!0),TM(!0),Notification.permission==="default"&&Notification.requestPermission().then(e=>{a(e),e!==`granted`&&(r(!1),TM(!1))})}},[n])}}var OM=`runcastle.theme`,kM=`dark`,AM=`(prefers-color-scheme: light)`;function jM(e){return e===`dark`||e===`light`||e===`system`}function MM(){try{let e=globalThis.localStorage?.getItem(OM);return jM(e)?e:kM}catch{return kM}}function NM(){try{return globalThis.matchMedia?.(AM).matches?`light`:`dark`}catch{return`dark`}}function PM(e){return e===`system`?NM():e}var FM=kM,IM=new Set,LM=null;function RM(){if(typeof document>`u`)return;let e=document.documentElement,t=PM(FM);if(e.dataset.theme===t)return;let n=e.dataset.theme!==void 0;if(n&&e.setAttribute(`data-theme-switching`,``),e.dataset.theme=t,n){let t=()=>e.removeAttribute(`data-theme-switching`);typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>requestAnimationFrame(t)):t()}}function zM(){for(let e of IM)e()}function BM(e){if(!e){LM?.(),LM=null;return}if(LM)return;let t;try{t=globalThis.matchMedia?.(AM)}catch{t=void 0}if(!t)return;let n=()=>{RM(),zM()};t.addEventListener(`change`,n),LM=()=>t.removeEventListener(`change`,n)}function VM(){return FM=MM(),RM(),BM(FM===`system`),FM}function HM(e){FM=e;try{globalThis.localStorage?.setItem(OM,e)}catch{}RM(),BM(e===`system`),zM()}function UM(e){return IM.add(e),()=>IM.delete(e)}var WM=()=>`${FM}:${PM(FM)}`,GM=()=>`${kM}:${kM}`;function KM(){let[e,t]=(0,L.useSyncExternalStore)(UM,WM,GM).split(`:`);return{preference:e,resolved:t,setPreference:HM,toggle:(0,L.useCallback)(()=>{HM(PM(FM)===`dark`?`light`:`dark`)},[])}}var qM=Object.defineProperty,JM=(e,t)=>qM(e,`name`,{value:t,configurable:!0});function YM(e){let t=e+`CollectionProvider`,[n,r]=Xx(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=JM(e=>{let{scope:t,children:n}=e,r=L.useRef(null),a=L.useRef(new Map).current;return(0,R.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=eS(s),l=L.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Kx(t,a(s,n).collectionRef);return(0,R.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=eS(u),p=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),s=Kx(t,o),c=a(u,n);return L.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,R.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return L.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return JM(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}JM(YM,`createCollection`);var XM=new WeakMap,ZM=class e extends Map{static{JM(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],XM.set(this,!0)}set(e,t){return XM.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=eN(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=QM(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=QM(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return QM(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function QM(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=$M(e,t);return n===-1?void 0:e[n]}JM(QM,`at`);function $M(e,t){let n=e.length,r=eN(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}JM($M,`toSafeIndex`);function eN(e){return e!==e||e===0?0:Math.trunc(e)}JM(eN,`toSafeInteger`);function tN(e){let t=e+`CollectionProvider`,[n,r]=Xx(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new ZM,setItemMap:JM(()=>void 0,`setItemMap`)}),o=JM(({state:e,...t})=>e?(0,R.jsx)(c,{...t,state:e}):(0,R.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=JM(e=>{let t=h();return(0,R.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=JM(e=>{let{scope:t,children:n,state:r}=e,a=L.useRef(null),[o,s]=L.useState(null),c=Kx(a,s),[l,u]=r;return L.useEffect(()=>{if(!o)return;let e=aN(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,R.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=eS(l),d=L.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Kx(t,a(l,n).collectionRef);return(0,R.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=eS(f),m=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),[s,c]=L.useState(null),l=Kx(t,o,c),{setItemMap:u}=a(f,n),d=L.useRef(i);nN(d.current,i)||(d.current=i);let m=d.current;return L.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(iN):(t.set(s,{...e,element:s}),t.toSorted(iN)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new ZM(e)))}},[s,m,u]),(0,R.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return L.useState(new ZM)}JM(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return JM(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}JM(tN,`createCollection`);function nN(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}JM(nN,`shallowEqual`);function rN(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}JM(rN,`isElementPreceding`);function iN(e,t){return!e[1].element||!t[1].element?0:rN(e[1].element,t[1].element)?-1:1}JM(iN,`sortByDocumentPosition`);function aN(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}JM(aN,`getChildListObserver`);var oN=Object.defineProperty,sN=(e,t)=>oN(e,`name`,{value:t,configurable:!0}),cN=L.createContext(void 0);function lN(e){let t=L.useContext(cN);return e||t||`ltr`}sN(lN,`useDirection`);var uN=Object.defineProperty,dN=(e,t)=>uN(e,`name`,{value:t,configurable:!0}),fN=!1;function pN(){let[e,t]=L.useState(fN);return L.useEffect(()=>{fN||(fN=!0,t(!0))},[]),e}dN(pN,`useIsHydrated`);var mN=L.useSyncExternalStore;function hN(){return()=>{}}dN(hN,`subscribe`);function gN(){return mN(hN,()=>!0,()=>!1)}dN(gN,`useIsHydratedModern`);var _N=typeof mN==`function`?gN:pN,vN=Object.defineProperty,yN=(e,t)=>vN(e,`name`,{value:t,configurable:!0}),bN=`rovingFocusGroup.onEntryFocus`,xN={bubbles:!1,cancelable:!0},SN=`RovingFocusGroup`,[CN,wN,TN]=YM(SN),[EN,DN]=Xx(SN,[TN]),[ON,kN]=EN(SN),AN=L.forwardRef(yN(function(e,t){return(0,R.jsx)(CN.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(CN.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(jN,{...e,ref:t})})})},`RovingFocusGroup`)),jN=L.forwardRef(yN(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=L.useRef(null),p=Kx(t,f),m=lN(a),[h,g]=RT({prop:o,defaultProp:s??null,onChange:c,caller:SN}),[_,v]=L.useState(!1),y=yS(l),b=wN(n),x=L.useRef(!1),[S,C]=L.useState(0);return L.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(bN,y),()=>e.removeEventListener(bN,y)},[y]),(0,R.jsx)(ON,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:L.useCallback(e=>g(e),[g]),onItemShiftTab:L.useCallback(()=>v(!0),[]),onFocusableItemAdd:L.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:L.useCallback(()=>C(e=>e-1),[]),children:(0,R.jsx)(hS.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:J(e.onMouseDown,()=>{x.current=!0}),onFocus:J(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(bN,xN);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);LN([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:J(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),MN=`RovingFocusGroupItem`,NN=L.forwardRef(yN(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=zS(),l=a||c,u=kN(MN,n),d=u.currentTabStopId===l,f=wN(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=_N();return PS(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),L.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,R.jsx)(CN.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(hS.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:J(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:J(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:J(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=IN(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?RN(n,r+1):n.slice(r+1)}setTimeout(()=>LN(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),PN={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function FN(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}yN(FN,`getDirectionAwareKey`);function IN(e,t,n){let r=FN(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return PN[r]}yN(IN,`getFocusIntent`);function LN(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}yN(LN,`focusFirst`);function RN(e,t){return e.map((n,r)=>e[(t+r)%e.length])}yN(RN,`wrapArray`);var zN=AN,BN=NN,VN=Object.defineProperty,HN=(e,t)=>VN(e,`name`,{value:t,configurable:!0}),UN=[`Enter`,` `],WN=[`ArrowDown`,`PageUp`,`Home`],GN=[`ArrowUp`,`PageDown`,`End`],KN=[...WN,...GN];[...UN],[...UN];var qN=`Menu`,[JN,YN,XN]=YM(qN),[ZN,QN]=Xx(qN,[XN,iT,DN]),$N=iT(),eP=DN(),[tP,nP]=ZN(qN),[rP,iP]=ZN(qN),aP=HN(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=$N(t),[c,l]=L.useState(null),u=L.useRef(!1),d=yS(a),f=lN(i);return L.useEffect(()=>{let e=HN(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=HN(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),L.useEffect(()=>{if(!n)return;let e=HN(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,R.jsx)(gT,{...s,children:(0,R.jsx)(tP,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(rP,{scope:t,onClose:L.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),oP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,...r}=e,i=$N(n);return(0,R.jsx)(_T,{...i,...r,ref:t})},`MenuAnchor`)),sP=`MenuPortal`,[cP,lP]=ZN(sP,{forceMount:void 0}),uP=HN(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=nP(sP,t);return(0,R.jsx)(cP,{scope:t,forceMount:n,children:(0,R.jsx)(wT,{present:n||a.open,children:(0,R.jsx)(bT,{asChild:!0,container:i,children:r})})})},`MenuPortal`),dP=`MenuContent`,[fP,pP]=ZN(dP),mP=L.forwardRef(HN(function(e,t){let n=lP(dP,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=nP(dP,e.__scopeMenu),o=iP(dP,e.__scopeMenu);return(0,R.jsx)(JN.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(wT,{present:r||a.open,children:(0,R.jsx)(JN.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(hP,{...i,ref:t}):(0,R.jsx)(gP,{...i,ref:t})})})})},`MenuContent`)),hP=L.forwardRef(HN(function(e,t){let n=nP(dP,e.__scopeMenu),r=L.useRef(null),i=Kx(t,r);return L.useEffect(()=>{let e=r.current;if(e)return ZO(e)},[]),(0,R.jsx)(vP,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),gP=L.forwardRef(HN(function(e,t){let n=nP(dP,e.__scopeMenu);return(0,R.jsx)(vP,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),_P=eS(`MenuContent.ScrollLock`),vP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=nP(dP,n),_=iP(dP,n),v=$N(n),y=eP(n),b=YN(n),[x,S]=L.useState(null),C=L.useRef(null),w=Kx(t,C,g.onContentChange),T=L.useRef(0),E=L.useRef(``),D=L.useRef(0),O=L.useRef(null),k=L.useRef(`right`),A=L.useRef(0),j=m?HO:L.Fragment,M=m?{as:_P,allowPinchZoom:!0}:void 0,N=HN(e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=AP(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;HN((function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);L.useEffect(()=>()=>window.clearTimeout(T.current),[]),MD();let P=L.useCallback(e=>k.current===O.current?.side&&MP(e,O.current?.area),[]);return(0,R.jsx)(fP,{scope:n,searchRef:E,onItemEnter:L.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:L.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:L.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:L.useCallback(e=>{O.current=e},[]),children:(0,R.jsx)(j,{...M,children:(0,R.jsx)(hD,{asChild:!0,trapped:i,onMountAutoFocus:J(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(DS,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(zN,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:J(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(vT,{role:`menu`,"aria-orientation":`vertical`,"data-state":TP(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:J(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=C.current;if(e.target!==i||!KN.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);GN.includes(e.key)&&a.reverse(),OP(a)}),onBlur:J(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:J(e.onPointerMove,NP(e=>{let t=e.target,n=A.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>A.current?`right`:`left`;k.current=t,A.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),yP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(hS.div,{...r,ref:t})},`MenuLabel`)),bP=`MenuItem`,xP=`menu.itemSelect`,SP=L.forwardRef(HN(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=L.useRef(null),o=iP(bP,e.__scopeMenu),s=pP(bP,e.__scopeMenu),c=Kx(t,a),l=L.useRef(!1),u=HN(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(xP,{bubbles:!0,cancelable:!0});e.addEventListener(xP,e=>r?.(e),{once:!0}),gS(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,R.jsx)(CP,{...i,ref:c,disabled:n,onClick:J(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:J(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:J(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||UN.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),CP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=pP(bP,n),s=eP(n),c=L.useRef(null),l=Kx(t,c),[u,d]=L.useState(!1),[f,p]=L.useState(``);return L.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(JN.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(BN,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(hS.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:J(e.onPointerMove,NP(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:J(e.onPointerLeave,NP(e=>o.onItemLeave(e))),onFocus:J(e.onFocus,()=>d(!0)),onBlur:J(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[iee,aee]=ZN(`MenuRadioGroup`,{value:void 0,onValueChange:HN(()=>{},`onValueChange`)}),[oee,see]=ZN(`MenuItemIndicator`,{checked:!1}),wP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(hS.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[cee,lee]=ZN(`MenuSub`);function TP(e){return e?`open`:`closed`}HN(TP,`getOpenState`);function EP(e){return e===`indeterminate`}HN(EP,`isIndeterminate`);function DP(e){return EP(e)?`indeterminate`:e?`checked`:`unchecked`}HN(DP,`getCheckedState`);function OP(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}HN(OP,`focusFirst`);function kP(e,t){return e.map((n,r)=>e[(t+r)%e.length])}HN(kP,`wrapArray`);function AP(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=kP(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}HN(AP,`getNextMatch`);function jP(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}HN(jP,`isPointInPolygon`);function MP(e,t){return t?jP({x:e.clientX,y:e.clientY},t):!1}HN(MP,`isPointerInGraceArea`);function NP(e){return t=>t.pointerType===`mouse`?e(t):void 0}HN(NP,`whenMouse`);var PP=aP,FP=oP,IP=uP,LP=mP,RP=yP,zP=SP,BP=wP,VP=Object.defineProperty,HP=(e,t)=>VP(e,`name`,{value:t,configurable:!0}),UP=`DropdownMenu`,[WP,uee]=Xx(UP,[QN]),GP=QN(),[KP,qP]=WP(UP),JP=HP(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=GP(t),l=L.useRef(null),[u,d]=RT({prop:i,defaultProp:a??!1,onChange:o,caller:UP});return(0,R.jsx)(KP,{scope:t,triggerId:zS(),triggerRef:l,contentId:zS(),open:u,onOpenChange:d,onOpenToggle:L.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(PP,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),YP=`DropdownMenuTrigger`,XP=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=qP(YP,n),o=GP(n),s=Kx(t,a.triggerRef);return(0,R.jsx)(FP,{asChild:!0,...o,children:(0,R.jsx)(hS.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:J(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:J(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),ZP=HP(e=>{let{__scopeDropdownMenu:t,...n}=e,r=GP(t);return(0,R.jsx)(IP,{...r,...n})},`DropdownMenuPortal`),QP=`DropdownMenuContent`,$P=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=qP(QP,n),a=GP(n),o=L.useRef(!1);return(0,R.jsx)(LP,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:J(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),eF=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=GP(n);return(0,R.jsx)(RP,{...i,...r,ref:t})},`DropdownMenuLabel`)),tF=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=GP(n);return(0,R.jsx)(zP,{...i,...r,ref:t})},`DropdownMenuItem`)),nF=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=GP(n);return(0,R.jsx)(BP,{...i,...r,ref:t})},`DropdownMenuSeparator`)),rF=JP,iF=XP,aF=ZP,oF=$P,sF=eF,cF=tF,lF=nF;function uF({modal:e=!1,...t}){return(0,R.jsx)(rF,{modal:e,...t})}var dF=iF;function fF({className:e,align:t=`start`,sideOffset:n=4,collisionPadding:r=8,onEscapeKeyDown:i,...a}){return(0,R.jsx)(aF,{children:(0,R.jsx)(oF,{align:t,sideOffset:n,collisionPadding:r,onEscapeKeyDown:e=>{i?.(e),e.stopPropagation()},className:q(Ox,`max-h-(--radix-dropdown-menu-content-available-height) min-w-48 p-1`,e),...a})})}function pF({className:e,tone:t=`default`,icon:n,kbd:r,children:i,...a}){return(0,R.jsxs)(cF,{className:q(kx,t===`danger`?jx:Ax,e),...a,children:[n,r?(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i}):i,r&&(0,R.jsx)(Px,{className:`ml-auto`,children:r})]})}function mF({className:e,...t}){return(0,R.jsx)(sF,{className:q(Mx,e),...t})}function hF({className:e,...t}){return(0,R.jsx)(lF,{className:q(Nx,e),...t})}function gF(e,t){navigator.clipboard.writeText(e).then(()=>t.push(`copied ${e}`,`info`)).catch(()=>t.push(`copy failed`))}function _F({width:e,side:t,label:n,clamp:r,onResize:i}){let[a,o]=(0,L.useState)(!1),s=(0,L.useRef)({x:0,width:e});return(0,L.useEffect)(()=>{if(!a)return;let e=e=>{let n=e.clientX-s.current.x;i(r(s.current.width+(t===`left`?n:-n)))},n=()=>o(!1),c=document.body.style.userSelect;return document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n),()=>{document.body.style.userSelect=c,document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n)}},[r,a,i,t]),(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":n,title:`Drag to resize`,className:`absolute top-0 z-10 h-full w-1.5 cursor-col-resize transition-colors duration-(--dur-1) ease-app hover:bg-border-strong ${t===`left`?`-right-[3px]`:`-left-[3px]`} ${a?`bg-border-strong`:``}`,onMouseDown:t=>{t.preventDefault(),s.current={x:t.clientX,width:e},o(!0)}})}var vF={"copy-link":(0,R.jsx)(Fb,{}),"copy-branch":(0,R.jsx)(rb,{}),archive:(0,R.jsx)(jb,{}),unarchive:(0,R.jsx)(jb,{}),rename:(0,R.jsx)(_b,{}),delete:(0,R.jsx)(lb,{}),remove:(0,R.jsx)(lb,{})};function yF({actions:e,label:t=`Feature actions`,size:n=`sm`,align:r=`end`}){let i=(0,L.useRef)(null);if(e.length===0)return null;let a=e.filter(e=>!e.danger),o=e.filter(e=>e.danger),s=e=>(0,R.jsx)(pF,{className:`text-sm`,tone:e.danger?`danger`:`default`,icon:e.icon??vF[e.key],kbd:e.kbd,onSelect:()=>{i.current?.focus(),e.onSelect(i)},children:e.label},e.key);return(0,R.jsxs)(uF,{children:[(0,R.jsx)(dF,{asChild:!0,children:(0,R.jsx)(UE,{ref:i,label:t,size:n,icon:(0,R.jsx)(pb,{}),className:`shrink-0`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation()})}),(0,R.jsxs)(fF,{align:r,className:`font-sans`,onCloseAutoFocus:e=>{let t=document.activeElement;t&&t!==document.body&&t!==i.current&&e.preventDefault()},children:[a.map(s),a.length>0&&o.length>0&&(0,R.jsx)(hF,{}),o.map(s)]})]})}function bF({title:e,slug:t,busy:n,onConfirm:r,onCancel:i,returnFocusRef:a}){let[o,s]=(0,L.useState)(``),c=o.trim()===t;return(0,R.jsxs)(Hj,{open:!0,onClose:i,returnFocusRef:a,labelledBy:`delete-feature-title`,size:`sm`,children:[(0,R.jsx)(Uj,{id:`delete-feature-title`,title:`Delete feature`,onClose:i}),(0,R.jsxs)(Wj,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(`p`,{className:`m-0 text-sm text-pretty text-text-secondary`,children:[`Permanently delete `,(0,R.jsx)(`strong`,{className:`font-medium text-text`,children:e}),`? Its worktree, branches, running agent and all runcastle data go with it; committed docs stay in git history.`,` `,(0,R.jsx)(`strong`,{className:`font-medium text-text`,children:`This cannot be undone.`})]}),(0,R.jsx)(hj,{label:(0,R.jsxs)(R.Fragment,{children:[`Type `,(0,R.jsx)(`code`,{className:`font-mono text-xs text-text`,children:t}),` to confirm`]}),children:(0,R.jsx)(fj,{mono:!0,value:o,onChange:e=>s(e.target.value),autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t})})]}),(0,R.jsxs)(Gj,{children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:i,disabled:n,children:`Cancel`}),(0,R.jsx)(Y,{variant:`danger`,icon:(0,R.jsx)(lb,{}),onClick:r,disabled:!c||n,children:n?`Deleting…`:`Delete feature`})]})]})}var xF=`group flex h-8 min-w-0 cursor-pointer items-center gap-2 rounded-md border border-transparent bg-transparent pr-1.5 pl-2 text-text transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover aria-expanded:bg-surface-selected`,SF=`text-sm`;function CF({nav:e}){let t=e.projects??[],n=e.currentProject?.name??`runcastle`;return(0,R.jsxs)(uF,{children:[(0,R.jsxs)(dF,{className:xF,"aria-label":`${n} — switch project`,children:[(0,R.jsx)(lx,{size:16,className:`shrink-0`}),(0,R.jsx)(`span`,{className:`max-w-56 min-w-0 truncate text-sm font-semibold`,title:n,children:n}),(0,R.jsx)(db,{size:14,className:`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app group-aria-expanded:rotate-180`})]}),(0,R.jsxs)(fF,{className:`w-64`,children:[(0,R.jsx)(mF,{children:`Projects`}),t.map(n=>{let r=n.id===e.currentProjectId,i=ug(n.repoPath),a=i!==n.name||t.some(e=>e.id!==n.id&&e.name===n.name);return(0,R.jsxs)(pF,{className:SF,icon:(0,R.jsx)(yb,{}),"aria-current":r?`true`:void 0,onSelect:()=>e.enterProject(n.id),children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate`,children:n.name}),a&&(0,R.jsx)(`span`,{className:`block truncate font-mono text-xs text-text-tertiary`,children:i})]}),r&&(0,R.jsx)(sb,{size:14,className:`text-text`})]},n.id)}),(0,R.jsx)(hF,{}),(0,R.jsx)(pF,{className:SF,icon:(0,R.jsx)(zb,{}),onSelect:()=>e.goHome(),children:(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`All projects`})}),(0,R.jsx)(pF,{className:SF,icon:(0,R.jsx)(ob,{}),onSelect:()=>e.showOpen(),children:(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Open a project…`})})]})]})}var wF=`runcastle.sidebar.collapsed`,TF=44;function EF(){try{return localStorage.getItem(wF)===`1`}catch{return!1}}var DF=(0,L.createContext)(null);function OF(e){return e instanceof Element&&e.closest(`.xterm`)!==null}function kF({notices:e,children:t}){let{width:n,setWidth:r}=aM(),[i,a]=(0,L.useState)(EF),o=(0,L.useCallback)(()=>{a(e=>{let t=!e;try{localStorage.setItem(wF,t?`1`:`0`)}catch{}return t})},[]);(0,L.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.altKey||e.shiftKey||!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`b`||OF(e.target)||(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let s=(0,L.useMemo)(()=>({width:n,setWidth:r,collapsed:i,toggleSidebar:o,notices:e??null}),[n,r,i,o,e]);return(0,R.jsx)(DF.Provider,{value:s,children:t})}function AF(){return(0,L.useContext)(DF)??{width:iM(NaN),setWidth:()=>void 0,collapsed:!1,toggleSidebar:()=>void 0,notices:null}}function jF(){let{toggleSidebar:e}=AF();return(0,R.jsx)(UE,{label:`Hide sidebar`,kbd:mM(`B`),size:`sm`,icon:(0,R.jsx)(Mb,{}),tooltipSide:`bottom`,onClick:e})}function MF({sidebar:e,rail:t,children:n}){let{width:r,setWidth:i,collapsed:a,toggleSidebar:o,notices:s}=AF(),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let d=e=>{l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),160),i(e)},f=e!==void 0;return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 bg-canvas text-text`,style:{"--sidebar-w":`${r}px`},children:[f&&(0,R.jsxs)(`div`,{"data-sidebar":a?`collapsed`:`expanded`,className:q(`relative h-full shrink-0 overflow-hidden`,!c&&`transition-[width] duration-(--dur-3) ease-out-app motion-reduce:transition-none`),style:{width:a?TF:r},children:[(0,R.jsx)(`div`,{inert:a,"aria-hidden":a||void 0,className:q(`absolute inset-y-0 left-0 flex w-(--sidebar-w) flex-col`,`transition-opacity duration-(--dur-2) ease-app`,a?`pointer-events-none opacity-0`:`opacity-100`),children:e}),(0,R.jsxs)(`div`,{inert:!a,"aria-hidden":!a||void 0,className:q(`absolute inset-y-0 left-0 flex w-11 flex-col items-center gap-1 pt-4`,`transition-[opacity,translate] duration-(--dur-3) ease-out-app`,a?`translate-x-0 opacity-100 delay-75`:`pointer-events-none -translate-x-2 opacity-0`),children:[(0,R.jsx)(UE,{label:`Show sidebar`,kbd:mM(`B`),icon:(0,R.jsx)(Mb,{}),tooltipSide:`right`,onClick:o}),t]}),!a&&(0,R.jsx)(_F,{width:r,side:`left`,label:`Resize the sidebar`,clamp:iM,onResize:d})]}),(0,R.jsxs)(`main`,{className:q(`my-2 mr-2 flex min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-surface`,!f&&`ml-2`),children:[s,(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:n})]})]})}var NF=`runcastle.sidebar.showArchived`;function PF(){try{return localStorage.getItem(NF)===`1`}catch{return!1}}function FF(e){let{projectId:t,nav:n,view:r,selectedFeatureId:i,talk:a,onSelect:o,onSelectProject:s,onNewChat:c,onDraft:l,onOpenPreparation:u,onOpenNote:d,onOpenCmdk:f}=e,p=B.useUtils(),m=gx(),[h,g]=(0,L.useState)(PF),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(null),x=B.feature.list.useQuery({projectId:t},{refetchInterval:Ch()}),S=B.project.prep.useQuery({projectId:t}),C=$y(S.data&&{prepared:S.data.prepared,pendingCount:S.data.pendingKeys.length,staleCount:S.data.findings.filter(im).length}),w=B.projectNotes.openCount.useQuery({projectId:t}).data??0,T=Qh(x.data??[],{showArchived:h}),E=(x.data??[]).filter(e=>e.status===`archived`).length,D=()=>void p.feature.list.invalidate(),O=B.feature.archive.useMutation({onSuccess:D,onError:e=>m.push(e.message)}),k=B.feature.unarchive.useMutation({onSuccess:D,onError:e=>m.push(e.message)}),A=B.feature.delete.useMutation({onSuccess:(e,t)=>{D(),t.featureId===i&&(o(null),s()),b(null)},onError:e=>m.push(e.message)}),j=()=>{g(e=>{let t=!e;try{localStorage.setItem(NF,t?`1`:`0`)}catch{}return t})},M=e=>{let n=[{key:`copy-link`,label:`Copy link`,onSelect:()=>gF(window.location.origin+Sg({kind:`feature`,projectId:t,featureSlug:e.slug}),m)}];return e.status===`archived`?n.push({key:`unarchive`,label:`Unarchive`,onSelect:()=>k.mutate({featureId:e.id})}):e.status!==`draft`&&n.push({key:`archive`,label:`Archive`,onSelect:()=>O.mutate({featureId:e.id})}),e.status!==`shipped`&&n.push({key:`delete`,label:`Delete…`,danger:!0,onSelect:t=>b({feature:e,returnFocusRef:t})}),n},N=n.currentProject?.name??`This project`,P=a.state!==`none`;return(0,R.jsxs)(`nav`,{"aria-label":`Project`,className:`flex h-full min-h-0 flex-col p-2`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-0.5`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:(0,R.jsx)(CF,{nav:n})}),(0,R.jsx)(IF,{onNewChat:c,onDraft:l,onOpenNote:d}),(0,R.jsx)(jF,{})]}),(0,R.jsx)(`div`,{className:`shrink-0 pt-1 pb-2`,children:(0,R.jsx)(RF,{onOpen:f})}),(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-px`,children:[(0,R.jsx)(nj,{icon:(0,R.jsx)(yb,{}),label:`Project`,active:r===`project`,onClick:s,dot:P?`live`:void 0,meta:w>0?(0,R.jsx)(`span`,{title:`${w} note${w===1?``:`s`} waiting to be triaged`,children:w}):void 0,title:w>0?`${N} — ${w} open note${w===1?``:`s`}`:`Talk to the project — intake, decomposition, and portfolio questions`}),C?.variant===`todo`&&(0,R.jsx)(nj,{icon:(0,R.jsx)(Eb,{}),label:C.label,meta:C.badge??void 0,dot:`warning`,active:r===`prepare`,onClick:u,title:C.title})]}),(0,R.jsxs)(`div`,{className:`-mx-2 mt-3 min-h-0 flex-1 overflow-y-auto px-2`,children:[x.isLoading&&(0,R.jsx)(WF,{}),x.data&&x.data.length===0&&(0,R.jsx)(`div`,{className:`px-2.5 py-2 text-xs text-pretty text-text-tertiary`,children:`No features yet. Start a chat to cut the first one.`}),T.map(e=>{let t=ng(e,_);return(0,R.jsxs)(`section`,{"aria-label":e.label,className:`mb-3 flex flex-col gap-px`,children:[(0,R.jsx)($A,{count:e.features.length,className:`px-2.5`,children:e.label}),t.visible.map(e=>(0,R.jsx)(GF,{f:e,active:e.id===i&&r===`feature`,onSelect:o,actions:M(e)},e.id)),t.expanderLabel&&(0,R.jsx)(nj,{tone:`quiet`,label:t.expanderLabel,onClick:()=>v(e=>!e)})]},e.key)}),E>0&&(0,R.jsx)(nj,{tone:`quiet`,label:h?`Hide archived`:`Show archived`,meta:E,onClick:j})]}),(0,R.jsx)(XF,{...e,prepRow:C}),y&&(0,R.jsx)(bF,{title:y.feature.title,slug:y.feature.slug,busy:A.isPending,onConfirm:()=>A.mutate({featureId:y.feature.id}),onCancel:()=>b(null),returnFocusRef:y.returnFocusRef})]})}function IF({onNewChat:e,onDraft:t,onOpenNote:n}){return(0,R.jsxs)(uF,{children:[(0,R.jsx)(dF,{asChild:!0,children:(0,R.jsx)(UE,{label:`Create`,size:`sm`,icon:(0,R.jsx)(_b,{}),tooltipSide:`bottom`})}),(0,R.jsxs)(fF,{align:`end`,className:`w-72`,children:[(0,R.jsx)(LF,{icon:(0,R.jsx)(hb,{}),label:`New chat`,hint:`Features and quick changes alike — a conversation that cuts burn-ready tickets`,onSelect:e}),(0,R.jsx)(LF,{icon:(0,R.jsx)(gb,{}),label:`Draft an idea`,hint:`Write an idea down now, work it out later`,onSelect:t}),n&&(0,R.jsx)(LF,{icon:(0,R.jsx)(_b,{}),label:`Jot a note`,hint:`What you just noticed — triage it later`,kbd:mM(`J`),onSelect:n})]})]})}function LF({icon:e,label:t,hint:n,kbd:r,onSelect:i}){return(0,R.jsxs)(pF,{className:`items-start py-1.5 [&>svg]:mt-0.5`,icon:e,onSelect:i,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block`,children:t}),(0,R.jsx)(`span`,{className:`block text-xs text-pretty text-text-tertiary`,children:n})]}),r&&(0,R.jsx)(Px,{className:`mt-0.5`,children:r})]})}function RF({onOpen:e}){return(0,R.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search or jump to`,className:q(`flex h-(--control-h) w-full cursor-pointer items-center gap-2 rounded-md border border-border bg-surface-inset pr-1.5 pl-2.5`,`text-left text-sm text-text-tertiary transition-colors duration-(--dur-1) ease-app`,`hover:border-border-strong hover:text-text-secondary`),children:[(0,R.jsx)(eb,{size:14,className:`shrink-0 text-icon`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Search`}),(0,R.jsx)(Px,{children:pM()})]})}function zF(e){return e.status===`draft`?`draft`:e.phase}function BF(e){let t=Zh(e);if(t===`agentWorking`)return`live`;if(t===`needsYou`)return Gh(e)?.kind===`attention`?`danger`:`warning`}function VF(e){let t=Zh(e);return t===`agentWorking`?`agent working`:t===`needsYou`?Gh(e)?.label??`needs you`:null}function HF(e){let t=e.currentTarget.querySelector(`[aria-haspopup="menu"]`);t&&(e.preventDefault(),t.dispatchEvent(new PointerEvent(`pointerdown`,{bubbles:!0,cancelable:!0,button:0})))}var UF=[`w-32`,`w-24`,`w-36`,`w-28`];function WF(){return(0,R.jsxs)(Oj,{label:`Loading features…`,children:[(0,R.jsx)(`div`,{className:`flex h-7 items-center px-2.5`,children:(0,R.jsx)(kj,{className:`h-2.5 w-16`})}),(0,R.jsx)(`div`,{className:`flex flex-col gap-px`,children:UF.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex h-(--row-h) items-center gap-2 pr-3 pl-2.5`,"data-skeleton":`feature-row`,children:[(0,R.jsx)(kj,{className:`size-4 rounded-full`}),(0,R.jsx)(kj,{className:q(`h-2.5`,e)})]},t))})]})}function GF({f:e,active:t,onSelect:n,actions:r}){let i=zh(e)?Kh(e):null,a=i?.title??VF(e);return(0,R.jsx)(nj,{phase:zF(e),label:e.title,title:a?`${e.title} — ${a}`:e.title,dot:BF(e),meta:i?.text??(e.status===`shipped`?void 0:qh(e)??void 0),active:t,onClick:()=>n(e.id),actions:r.length>0?(0,R.jsx)(yF,{actions:r}):void 0,onContextMenu:r.length>0?HF:void 0})}function KF(){return typeof window>`u`?`this machine`:window.location.origin}var qF={connecting:{tone:`neutral`,word:`Connecting`},ok:{tone:`success`,word:`Server`},reconnecting:{tone:`warning`,word:`Reconnecting`},down:{tone:`danger`,word:`Server down`}},JF={on:`Notifications on — turn off`,off:`Notifications off — turn on`,blocked:`Notifications blocked by the browser`};function YF({health:e,origin:t,sandbox:n,notify:r,theme:i,onToggleTheme:a,onOpenSettings:o,rows:s}){let c=qF[e],l=e===`ok`?`Server ok — live updates streaming from ${t}/api`:e===`connecting`?`Connecting to the runcastle API at ${t}/api`:e===`reconnecting`?`Live updates paused — reconnecting, and polling meanwhile`:`The runcastle API at ${t}/api is not answering`,u=i===`dark`?`light`:`dark`;return(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-px pt-2`,children:[s,(0,R.jsxs)(`div`,{className:`flex h-8 items-center gap-3 pl-2.5 text-xs text-text-tertiary`,children:[(0,R.jsx)(jE,{label:l,children:(0,R.jsxs)(`span`,{tabIndex:0,className:`inline-flex items-center gap-1.5 rounded-sm whitespace-nowrap`,"data-health":e,children:[(0,R.jsx)(BA,{tone:c.tone}),c.word]})}),(0,R.jsx)(jE,{label:`Agent sessions run sandboxed via ${n}`,children:(0,R.jsxs)(`span`,{tabIndex:0,className:`inline-flex items-center gap-1.5 rounded-sm whitespace-nowrap`,children:[(0,R.jsx)(bb,{size:14,className:`text-icon`}),n]})}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsxs)(`span`,{className:`flex items-center`,children:[r&&(0,R.jsx)(UE,{size:`sm`,label:r.state===`blocked`?r.title:JF[r.state],icon:r.state===`on`?(0,R.jsx)(ib,{}):(0,R.jsx)(ab,{}),active:r.state===`on`,onClick:r.onToggle}),(0,R.jsx)(UE,{size:`sm`,label:`Switch to ${u} theme`,icon:i===`dark`?(0,R.jsx)(Ib,{}):(0,R.jsx)(Lb,{}),onClick:a}),o&&(0,R.jsx)(UE,{size:`sm`,label:`Settings`,icon:(0,R.jsx)(tb,{}),onClick:o})]})]})]})}function XF({projectId:e,nav:t,view:n,onSelect:r,onOpenSettings:i,onOpenPreparation:a,projectDriveBranch:o=null,onOpenProjectDrive:s,driving:c=null,onDriveChange:l,prepRow:u}){let d=gx(),f=B.useUtils(),p=Ch(),m=bh(),h=KM(),g=B.feature.list.useQuery({projectId:e},{refetchInterval:p}),_=!g.isError&&g.data!==void 0,v=DM(e,g.data??[]),y=vM(v),b=t.projects??[],x=B.useQueries(e=>b.map(t=>e.feature.list({projectId:t.id},{refetchInterval:p}))),S=lg(b.map((e,t)=>({projectId:e.id,...cg(x[t]?.data??[])})),t.currentProjectId),C=B.feature.testDrive.useMutation({onSuccess:()=>{l?.(null),c&&f.feature.get.invalidate({id:c.featureId}),f.feature.list.invalidate()},onError:e=>d.push(e.message)}),w=(0,R.jsxs)(R.Fragment,{children:[o!==null&&(0,R.jsx)(nj,{icon:(0,R.jsx)(wb,{}),label:`Project drive`,meta:(0,R.jsx)(`span`,{className:`font-mono`,children:o}),dot:`live`,onClick:s,title:`A project drive is live on ${o} — back to it`}),c&&(0,R.jsx)(nj,{icon:(0,R.jsx)(wb,{}),label:`Test drive`,meta:(0,R.jsx)(`span`,{className:`font-mono`,children:c.branch}),dot:`live`,onClick:()=>r(c.featureId),title:`Driving ${c.branch} — back to its feature`,actions:(0,R.jsx)(UE,{size:`sm`,label:`Stop the test drive`,icon:(0,R.jsx)(Tb,{}),disabled:C.isPending,onClick:()=>C.mutate({featureId:c.featureId,action:`stop`})})}),S>0&&(0,R.jsx)(nj,{icon:(0,R.jsx)(vb,{}),label:`${S} running elsewhere`,dot:`live`,onClick:t.goHome,title:`Runs in flight in other projects — open all projects`}),u?.variant===`done`&&(0,R.jsx)(nj,{icon:(0,R.jsx)(ub,{}),label:`Re-prepare project`,meta:u.badge??void 0,active:n===`prepare`,onClick:a,title:u.title})]});return(0,R.jsx)(YF,{health:g.isError?`down`:_?m===`live`?`ok`:m===`connecting`?`connecting`:`reconnecting`:`connecting`,origin:KF(),sandbox:_M,notify:v.supported?{...y,onToggle:v.toggle}:null,theme:h.resolved,onToggleTheme:h.toggle,onOpenSettings:i,rows:w})}function ZF({onOpenCmdk:e,onNewChat:t}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(UE,{label:`Search`,kbd:pM(),icon:(0,R.jsx)(eb,{}),tooltipSide:`right`,onClick:e}),(0,R.jsx)(UE,{label:`New chat`,icon:(0,R.jsx)(ob,{}),tooltipSide:`right`,onClick:t})]})}function QF(e){let[t,n]=(0,L.useState)([]),r=t.length?t[t.length-1].id:void 0,i=B.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:Ch()});return(0,L.useEffect)(()=>{let e=i.data;!e||e.length===0||n(t=>{let n=new Set(t.map(e=>e.id)),r=e.filter(e=>!n.has(e.id));return r.length===0?t:[...t,...r].sort((e,t)=>e.id-t.id)})},[i.data]),t}var $F=(0,L.createContext)(null);function eI({open:e,children:t}){return(0,R.jsx)($F.Provider,{value:e,children:t})}function tI(){return(0,L.useContext)($F)}function nI({location:e,children:t}){let n=(0,L.useContext)($F);return n?(0,R.jsx)(`button`,{type:`button`,className:JE,onClick:t=>{t.stopPropagation(),n(e)},children:t}):(0,R.jsx)(R.Fragment,{children:t})}function rI({text:e}){let t=(0,L.useContext)($F),n=eh(e);return!t||!n?(0,R.jsx)(R.Fragment,{children:e}):(0,R.jsxs)(R.Fragment,{children:[n.before,(0,R.jsx)(nI,{location:n.location,children:n.phrase}),n.after]})}function iI(e,t){let n=B.useUtils(),r=gx(),i=e=>r.push(e.message),a=()=>{n.feature.get.invalidate({id:e}),n.feature.list.invalidate(),n.events.invalidate()},o=B.feature.endSession.useMutation({onError:i}),s=Ex(e),c=B.feature.launchSession.useMutation({onSuccess:()=>{a(),s()},onError:i});return{pending:o.isPending||c.isPending,resolve:async(n,r)=>{if(r){try{await o.mutateAsync({sessionId:r})}catch{return}a()}c.mutate({featureId:e,kind:`chat`,kickoffLine:m_(n.base,t,n.files),purpose:`resolve-conflict`,purposeData:{mergeFrom:n.base,mergeInto:t}})}}}function aI(e){let[t,n]=(0,L.useState)(null),r=(0,L.useRef)(null),i=e?.id,a=e?.status;return(0,L.useEffect)(()=>{if(!i)return;if(a===`running`){r.current=i;return}if(a!==`succeeded`||r.current!==i)return;r.current=null,n(i);let e=setTimeout(()=>n(null),900);return()=>clearTimeout(e)},[i,a]),t===i?t:null}function oI(e,t,{live:n=!0}={}){let r=Ch(),i=B.docs.read.useQuery({featureId:e,relPath:t??``},{enabled:!!t,...n?{refetchInterval:r}:{}});return{content:t?i.data?.content:void 0,loading:!!t&&i.isLoading,failed:!!t&&!!i.error}}function sI(e,t){return e.find(e=>e.relPath.split(/[\\/]/).pop()===t)?.relPath}function cI({title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c}){return(0,R.jsx)(Hj,{open:!0,onClose:c,labelledBy:`merge-feature-title`,size:r.conflictRow&&s?`md`:`sm`,className:`flex max-h-[82vh] flex-col overflow-hidden`,children:(0,R.jsx)(uI,{title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c})})}function lI({warnings:e}){return e.length===0?null:(0,R.jsx)(`ul`,{"aria-label":`Warnings`,className:`m-0 flex list-none flex-col gap-2 p-0 text-sm text-text-secondary [&>li]:relative [&>li]:pl-6`,children:e.map(e=>(0,R.jsxs)(`li`,{children:[(0,R.jsx)(Vb,{size:16,className:`absolute top-0.5 left-0 text-warning`}),e]},e))})}function uI({title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c}){let l=!!r.conflictRow&&!!s;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{id:`merge-feature-title`,title:`Merge & ship`,onClose:c,description:(0,R.jsxs)(R.Fragment,{children:[`Merge `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:e}),` from`,` `,(0,R.jsx)(`code`,{className:`font-mono text-xs`,children:t}),n?(0,R.jsxs)(R.Fragment,{children:[` `,`into `,(0,R.jsx)(`code`,{className:`font-mono text-xs`,children:n})]}):null,`? This ships the feature.`]})}),(0,R.jsxs)(Wj,{className:`flex min-h-0 flex-col gap-5 overflow-y-auto`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsx)($A,{children:`What lands`}),r.conflictRow&&(0,R.jsx)(`p`,{className:`mt-1 mb-2 rounded-md bg-danger-subtle px-3 py-2 text-sm text-danger`,role:`alert`,children:r.conflictRow}),r.rows.map(e=>(0,R.jsx)(QA,{row:e},e.key))]}),(0,R.jsx)(lI,{warnings:r.warnings}),(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:r.next}),l&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:`Nothing here is disabled — if you resolved it by hand, retry lands it.`})]}),(0,R.jsxs)(Gj,{className:`border-t border-border-subtle pt-4`,children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:c,disabled:i,children:`Cancel`}),l?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{variant:`secondary`,icon:(0,R.jsx)(Gb,{}),onClick:o,disabled:i,children:i?`Merging…`:`Retry merge anyway`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Vb,{}),onClick:s,disabled:a,children:`Resolve the merge conflict`})]}):(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Nb,{}),onClick:o,disabled:i,children:i?`Merging…`:`Merge & ship`})]})]})}function dI({title:e,branch:t,summary:n,busy:r,warningsPending:i,onConfirm:a,onCancel:o}){return(0,R.jsx)(Hj,{open:!0,onClose:o,labelledBy:`burn-feature-title`,size:`sm`,className:`flex max-h-[82vh] flex-col overflow-hidden`,children:(0,R.jsx)(fI,{title:e,branch:t,summary:n,busy:r,warningsPending:i,onConfirm:a,onCancel:o})})}function fI({title:e,branch:t,summary:n,busy:r,warningsPending:i,onConfirm:a,onCancel:o}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{id:`burn-feature-title`,title:`Burn tickets`,onClose:o,description:(0,R.jsxs)(R.Fragment,{children:[`Burn `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:e}),` on`,` `,(0,R.jsx)(`code`,{className:`font-mono text-xs`,children:t}),`? Each ticket runs as its own sandboxed agent.`]})}),(0,R.jsxs)(Wj,{className:`flex min-h-0 flex-col gap-5 overflow-y-auto`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsx)($A,{children:`What burns`}),n.rows.map(e=>(0,R.jsx)(QA,{row:e},e.key))]}),(0,R.jsx)(lI,{warnings:n.warnings}),i&&(0,R.jsxs)(`p`,{className:`m-0 flex items-center gap-2 text-sm text-text-tertiary`,children:[(0,R.jsx)(KE,{size:`sm`}),`Still checking for warnings…`]}),(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:n.next})]}),(0,R.jsxs)(Gj,{className:`border-t border-border-subtle pt-4`,children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:o,disabled:r,children:`Cancel`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(xb,{}),onClick:a,disabled:r,children:r?`Burning…`:`Burn`})]})]})}function pI({url:e,onClose:t}){return(0,R.jsx)(Hj,{open:!!e,onClose:t,size:`xl`,label:`the note’s picture`,className:`overflow-hidden`,children:(0,R.jsxs)(`div`,{className:`relative flex flex-col p-2`,children:[(0,R.jsx)(`img`,{src:e??``,alt:`the picture attached to this note`,className:`block max-h-[80vh] w-full rounded-md bg-surface-inset object-contain`}),(0,R.jsx)(`span`,{className:`absolute top-4 right-4 rounded-md bg-surface-raised shadow-popover`,children:(0,R.jsx)(UE,{label:`Close`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:t})})]})})}var mI=`#F85149`;function hI(e,t,n=1){e.lineWidth=6*n,e.lineCap=`round`,e.lineJoin=`round`,e.strokeStyle=mI;for(let r of t){let[t,...i]=r.points;if(!t)continue;let a=r.points.at(-1)??t;if(e.beginPath(),r.tool===`rect`){let n={x:Math.min(t.x,a.x),y:Math.min(t.y,a.y),width:Math.abs(a.x-t.x),height:Math.abs(a.y-t.y)};e.rect(n.x,n.y,n.width,n.height)}else{e.moveTo(t.x,t.y),i.length===0&&e.lineTo(t.x,t.y);for(let t of i)e.lineTo(t.x,t.y);if(r.tool===`arrow`&&i.length>0){let r=Math.atan2(a.y-t.y,a.x-t.x),i=12*n;e.lineTo(a.x-i*Math.cos(r-Math.PI/6),a.y-i*Math.sin(r-Math.PI/6)),e.moveTo(a.x,a.y),e.lineTo(a.x-i*Math.cos(r+Math.PI/6),a.y-i*Math.sin(r+Math.PI/6))}}e.stroke()}}function gI(e,t){return e.videoTimestamp==null?`png-only`:t&&e.reviewTicketId===t.ticketId?`live-seek`:`orphan-label`}function _I(e,t,n=1){let r=e.filter(e=>e.reviewTicketId===t&&e.videoTimestamp!=null).sort((e,t)=>e.videoTimestamp-t.videoTimestamp),i=[];for(let e of r){let t=e.videoTimestamp,r=i.at(-1);r&&t-r.at<=n?r.noteIds.push(e.id):i.push({at:t,noteIds:[e.id]})}return i}function vI(e){if(Number.isFinite(e.duration)&&e.duration>0)return e.duration;let{seekable:t}=e;return t.length>0?t.end(t.length-1):0}function yI(e,t){return t.annotating||!Number.isFinite(e)||t.playable<=0?null:Math.min(Math.max(e,0),t.playable)}function bI(e,t,n){return e.width<=0||e.height<=0?{x:0,y:0}:{x:(n.x-e.left)/e.width*t.width,y:(n.y-e.top)/e.height*t.height}}async function xI(e,t,n,r=1){e.width=t.videoWidth,e.height=t.videoHeight;let i=e.getContext(`2d`);if(!i)throw Error(`this browser offered no 2d canvas to capture the frame with`);return i.drawImage(t,0,0,e.width,e.height),hI(i,n,r),await new Promise((t,n)=>{e.toBlob(e=>{e?t(e):n(Error(`the browser produced no PNG from the annotated frame`))},`image/png`)})}async function SI(e){let t=await e.createNote();try{return await e.uploadScreenshot(t.id),{note:t}}catch(e){return{note:t,uploadError:e instanceof Error?e.message:String(e)}}}function CI(e){return e.kind===`note`?e.note.id:e.finding.id}function wI(e){return e.kind===`note`?e.note.lap:e.finding.lap}function TI(e){return`work-${e}`}function EI({finding:e}){let{head:t,rest:n}=Ty(e.detail),r=e.location.trim();return(0,R.jsxs)(Rj,{size:`sm`,title:t,bodyClassName:`flex flex-col gap-1`,children:[n&&(0,R.jsx)(`p`,{className:`m-0 text-pretty`,children:n}),r&&(0,R.jsx)(`div`,{className:`font-mono text-xs text-text-tertiary`,children:r}),(0,R.jsx)(`div`,{className:`font-mono text-xs text-text-tertiary`,children:e.citation}),e.reproStep&&(0,R.jsx)(`div`,{className:`font-mono text-xs text-text-tertiary`,children:e.reproStep})]})}var DI={carried:`text-text-tertiary`,attested:`text-warning`,verified:`text-success`};function OI({item:e,onStage:t,readonly:n,controls:r,editor:i,highlighted:a=!1,showLap:o=!1,onSeek:s,onOpenImage:c,onViewLane:l}){let u=e.kind===`note`?e.note:void 0,d=e.kind===`defect`?e.finding:void 0,f=u?.status===`promoted`?`Promoted to ${e.kind===`note`&&e.ticket?`#${e.ticket.seq} ${e.ticket.title}`:`a ticket`}`:u?.status===`carried`?`carried into lap ${u.carriedLap}`:null,p=u?.text??d?.title??``,m=u?.videoTimestamp,h=gI({id:CI(e),videoTimestamp:u?.videoTimestamp??null,reviewTicketId:u?.reviewTicketId??null},t),g=d?hy(d):null,_=d?gy(d):null,v=e.kind===`defect`?e.fixTicket:void 0;return(0,R.jsxs)(`div`,{id:TI(CI(e)),"data-list-row":``,className:q(`group/row flex gap-3 rounded-md px-3 py-3 animate-rise-in`,`transition-colors duration-(--dur-2) ease-app`,a?`bg-accent-subtle`:`hover:bg-surface-hover`),children:[(0,R.jsx)(Qj,{url:u?.screenshotUrl,onOpen:c}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[i??(0,R.jsx)(`p`,{className:q(`m-0 text-sm text-pretty whitespace-pre-wrap`,u?.status===`done`?`text-text-tertiary line-through`:`text-text`),children:p}),(0,R.jsxs)(`div`,{className:`flex min-h-4 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-text-tertiary`,children:[d&&(0,R.jsx)(KA,{severity:d.severity}),u&&(0,R.jsx)(GA,{author:u.author}),o&&(0,R.jsxs)(`span`,{children:[`Lap `,wI(e)]}),m!==void 0&&(h===`live-seek`?(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer rounded-sm font-mono tabular-nums text-text-tertiary transition-colors duration-(--dur-1) hover:text-accent-text`,title:`jump the walkthrough to this moment`,onClick:()=>s?.(m),children:cf(m)}):(0,R.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[cf(m),` · earlier walkthrough`]})),g&&(0,R.jsx)(`span`,{className:`text-warning`,children:g}),f&&(0,R.jsx)(`span`,{children:f}),_&&(0,R.jsx)(`span`,{className:DI[_.evidence],children:_.text}),v&&(n||!l?(0,R.jsxs)(`span`,{className:`text-phase-implementation`,children:[`fixed in the burn by #`,v.seq]}):(0,R.jsxs)(`button`,{type:`button`,className:`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,onClick:()=>l(v.id),children:[`being fixed in the running burn · lane #`,v.seq]}))]}),_?.note&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-pretty text-text-secondary`,children:_.note}),d&&(0,R.jsx)(EI,{finding:d})]}),!n&&r&&(0,R.jsx)(`div`,{className:`-my-0.5 flex shrink-0 items-start gap-1`,children:r})]})}var kI={note:`Delete this note and its picture?`,defect:`Dismiss this defect?`};function AI(e){return e.readonly?null:(0,R.jsx)(Hj,{open:!0,onClose:e.onClose,size:`xl`,label:`Iterate — what goes where`,children:(0,R.jsx)(jI,{...e})})}function jI({lap:e,notes:t,defects:n,standing:r,openedAt:i,busy:a,sessionLive:o,onCommit:s,onClose:c}){let[l,u]=(0,L.useState)(new Set),[d,f]=(0,L.useState)(new Set),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=[...n.map(e=>({kind:`defect`,finding:e})),...t.map(e=>({kind:`note`,note:e}))].filter(e=>!d.has(CI(e))).map(e=>({lap:wI(e),item:e})),v=e=>u(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),y=e=>l.has(CI(e.item)),b=_.filter(y),x=_.filter(e=>e.item.kind===`note`&&!y(e)),S=e+1,C=l_({quickFix:b.length,carried:x.length,nextLap:S,live:!!o}),w=c_({quickFix:b.length,carried:x.length,nextLap:S,standing:r}),T=()=>{if(!p)return;let e=CI(p);f(t=>new Set(t).add(e)),u(t=>{let n=new Set(t);return n.delete(e),n}),m(null)},E=e=>s({quickFixIds:b.flatMap(e=>e.item.kind===`note`?[CI(e.item)]:[]),quickFixFindingIds:b.flatMap(e=>e.item.kind===`defect`?[CI(e.item)]:[]),dismissIds:t.filter(e=>d.has(e.id)).map(e=>e.id),dismissFindingIds:n.filter(e=>d.has(e.id)).map(e=>e.id),carry:e});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{title:`Iterate — what goes where`,description:`Tick the rows that are quick fixes — each becomes a ticket on this lap. Everything you leave goes into lap ${S}’s conversation together.`,onClose:c}),(0,R.jsx)(Wj,{className:`flex flex-col gap-3`,children:_.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(Ab,{}),title:`Nothing open to triage`,hint:`Lap ${S} starts empty-handed.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(sb,{}),disabled:a,onClick:()=>u(new Set(_.map(e=>CI(e.item)))),children:`Mark all as quick fixes`}),(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(cb,{}),disabled:a,onClick:()=>u(new Set),children:`Clear`}),(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-text-tertiary tabular-nums`,children:[b.length,` of `,_.length,` ticked`]})]}),(0,R.jsx)(`div`,{className:`-mx-2 flex max-h-[46vh] flex-col overflow-y-auto`,children:(0,R.jsx)(Xj,{groups:i_(_,e),currentLap:e,meta:e=>`${e.rows.length} open`,headClassName:`px-2`,children:e=>e.map(e=>(0,R.jsx)(OI,{item:e.item,onStage:null,readonly:!1,highlighted:MI(e.item,i),onOpenImage:g,controls:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Dj,{label:`Quick fix`,checked:y(e),disabled:a,onChange:()=>v(CI(e.item)),className:`h-(--control-sm) px-1.5`}),(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:a,onClick:()=>m(e.item),children:`Dismiss`})]})},CI(e.item)))})})]})}),(0,R.jsxs)(Gj,{start:w?(0,R.jsx)(`span`,{className:`text-text-secondary`,children:w}):void 0,children:[(0,R.jsx)(Y,{variant:`ghost`,disabled:a,onClick:c,children:`Cancel`}),C.map((e,t)=>(0,R.jsx)(Y,{variant:t===C.length-1?`primary`:`secondary`,disabled:a,onClick:()=>E(e.carry),children:e.label},e.label))]}),(0,R.jsx)(pI,{url:h,onClose:()=>g(null)}),(0,R.jsxs)(Hj,{open:!!p,onClose:()=>m(null),size:`sm`,label:p?kI[p.kind]:`Dismiss`,children:[(0,R.jsx)(Uj,{title:p?kI[p.kind]:``,description:`It leaves the list now and goes for good when you commit this step.`}),(0,R.jsxs)(Gj,{children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:()=>m(null),children:`Keep it`}),(0,R.jsx)(Y,{variant:`danger`,onClick:T,children:`Dismiss`})]})]})]})}function MI(e,t){return(e.kind===`note`?e.note.createdAt:e.finding.createdAt)>t}function NI(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var PI=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dee=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,FI={};function II(e,t){return((t||FI).jsx?dee:PI).test(e)}var LI=/[ \t\n\f\r]/g;function RI(e){return typeof e==`object`?e.type===`text`&&zI(e.value):zI(e)}function zI(e){return e.replace(LI,``)===``}var BI=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};BI.prototype.normal={},BI.prototype.property={},BI.prototype.space=void 0;function VI(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new BI(n,r,t)}function HI(e){return e.toLowerCase()}var UI=class{constructor(e,t){this.attribute=t,this.property=e}};UI.prototype.attribute=``,UI.prototype.booleanish=!1,UI.prototype.boolean=!1,UI.prototype.commaOrSpaceSeparated=!1,UI.prototype.commaSeparated=!1,UI.prototype.defined=!1,UI.prototype.mustUseProperty=!1,UI.prototype.number=!1,UI.prototype.overloadedBoolean=!1,UI.prototype.property=``,UI.prototype.spaceSeparated=!1,UI.prototype.space=void 0;var WI=s({boolean:()=>KI,booleanish:()=>qI,commaOrSpaceSeparated:()=>ZI,commaSeparated:()=>XI,number:()=>X,overloadedBoolean:()=>JI,spaceSeparated:()=>YI}),GI=0,KI=QI(),qI=QI(),JI=QI(),X=QI(),YI=QI(),XI=QI(),ZI=QI();function QI(){return 2**++GI}var $I=Object.keys(WI),eL=class extends UI{constructor(e,t,n,r){let i=-1;if(super(e,t),tL(this,`space`,r),typeof n==`number`)for(;++i<$I.length;){let e=$I[i];tL(this,$I[i],(n&WI[e])===WI[e])}}};eL.prototype.defined=!0;function tL(e,t,n){n&&(e[t]=n)}function nL(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new eL(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[HI(r)]=r,n[HI(a.attribute)]=r}return new BI(t,n,e.space)}var rL=nL({properties:{ariaActiveDescendant:null,ariaAtomic:qI,ariaAutoComplete:null,ariaBusy:qI,ariaChecked:qI,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:YI,ariaCurrent:null,ariaDescribedBy:YI,ariaDetails:null,ariaDisabled:qI,ariaDropEffect:YI,ariaErrorMessage:null,ariaExpanded:qI,ariaFlowTo:YI,ariaGrabbed:qI,ariaHasPopup:null,ariaHidden:qI,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:YI,ariaLevel:X,ariaLive:null,ariaModal:qI,ariaMultiLine:qI,ariaMultiSelectable:qI,ariaOrientation:null,ariaOwns:YI,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:qI,ariaReadOnly:qI,ariaRelevant:null,ariaRequired:qI,ariaRoleDescription:YI,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:qI,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function iL(e,t){return t in e?e[t]:t}function aL(e,t){return iL(e,t.toLowerCase())}var oL=nL({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:XI,acceptCharset:YI,accessKey:YI,action:null,allow:null,allowFullScreen:KI,allowPaymentRequest:KI,allowUserMedia:KI,alpha:KI,alt:null,as:null,async:KI,autoCapitalize:null,autoComplete:YI,autoFocus:KI,autoPlay:KI,blocking:YI,capture:null,charSet:null,checked:KI,cite:null,className:YI,closedBy:null,colorSpace:null,cols:X,colSpan:X,command:null,commandFor:null,content:null,contentEditable:qI,controls:KI,controlsList:YI,coords:X|XI,crossOrigin:null,data:null,dateTime:null,decoding:null,default:KI,defer:KI,dir:null,dirName:null,disabled:KI,download:JI,draggable:qI,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:KI,formTarget:null,headers:YI,height:X,hidden:JI,high:X,href:null,hrefLang:null,htmlFor:YI,httpEquiv:YI,id:null,imageSizes:null,imageSrcSet:null,inert:KI,inputMode:null,integrity:null,is:null,isMap:KI,itemId:null,itemProp:YI,itemRef:YI,itemScope:KI,itemType:YI,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:KI,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:KI,muted:KI,name:null,nonce:null,noModule:KI,noValidate:KI,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored: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,onScrollEnd: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:KI,optimum:X,pattern:null,ping:YI,placeholder:null,playsInline:KI,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:KI,referrerPolicy:null,rel:YI,required:KI,reversed:KI,rows:X,rowSpan:X,sandbox:YI,scope:null,scoped:KI,seamless:KI,selected:KI,shadowRootClonable:KI,shadowRootCustomElementRegistry:KI,shadowRootDelegatesFocus:KI,shadowRootMode:null,shadowRootSerializable:KI,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:qI,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:KI,useMap:null,value:qI,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:YI,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:KI,declare:KI,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:KI,noHref:KI,noShade:KI,noWrap:KI,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:qI,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:KI,disablePictureInPicture:KI,disableRemotePlayback:KI,exportParts:XI,part:YI,prefix:null,property:null,results:X,security:null,unselectable:null},space:`html`,transform:aL}),sL=nL({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,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`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,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`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,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`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:ZI,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:YI,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:KI,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:XI,g2:XI,glyphName:XI,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:ZI,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose: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,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:YI,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ZI,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ZI,rev:ZI,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ZI,requiredFeatures:ZI,requiredFonts:ZI,requiredFormats:ZI,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:ZI,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ZI,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ZI,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:iL}),cL=nL({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),lL=nL({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:aL}),uL=nL({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),dL={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},fL=/[A-Z]/g,pL=/-[a-z]/g,mL=/^data[-\w.:]+$/i;function hL(e,t){let n=HI(t),r=t,i=UI;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&mL.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(pL,_L);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!pL.test(e)){let n=e.replace(fL,gL);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=eL}return new i(r,t)}function gL(e){return`-`+e.toLowerCase()}function _L(e){return e.charAt(1).toUpperCase()}var vL=VI([rL,oL,cL,lL,uL],`html`),yL=VI([rL,sL,cL,lL,uL],`svg`);function bL(e){return e.join(` `).trim()}var xL=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
123
|
-
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(!(e.charAt(0)!=`/`||e.charAt(1)!=`*`)){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),SL=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(xL());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),CL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),wL=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(SL()),r=CL();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),TL=DL(`end`),EL=DL(`start`);function DL(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function OL(e){let t=EL(e),n=TL(e);if(t&&n)return{start:t,end:n}}function kL(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?jL(e.position):`start`in e||`end`in e?jL(e):`line`in e||`column`in e?AL(e):``}function AL(e){return ML(e&&e.line)+`:`+ML(e&&e.column)}function jL(e){return AL(e&&e.start)+`-`+AL(e&&e.end)}function ML(e){return e&&typeof e==`number`?e:1}var NL=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=kL(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};NL.prototype.file=``,NL.prototype.name=``,NL.prototype.reason=``,NL.prototype.message=``,NL.prototype.stack=``,NL.prototype.column=void 0,NL.prototype.line=void 0,NL.prototype.ancestors=void 0,NL.prototype.cause=void 0,NL.prototype.fatal=void 0,NL.prototype.place=void 0,NL.prototype.ruleId=void 0,NL.prototype.source=void 0;var PL=l(wL(),1),FL={}.hasOwnProperty,IL=new Map,LL=/[A-Z]/g,RL=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),zL=new Set([`td`,`th`]);function BL(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=ZL(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=XL(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?yL:vL,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=VL(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function VL(e,t,n){if(t.type===`element`)return HL(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return UL(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return GL(e,t,n);if(t.type===`mdxjsEsm`)return WL(e,t);if(t.type===`root`)return KL(e,t,n);if(t.type===`text`)return qL(e,t)}function HL(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=yL,e.schema=i),e.ancestors.push(t);let a=rR(e,t.tagName,!1),o=QL(e,t),s=eR(e,t);return RL.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!RI(e)})),JL(e,o,a,t),YL(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function UL(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}iR(e,t.position)}function WL(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);iR(e,t.position)}function GL(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=yL,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:rR(e,t.name,!0),o=$L(e,t),s=eR(e,t);return JL(e,o,a,t),YL(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function KL(e,t,n){let r={};return YL(r,eR(e,t)),e.create(t,e.Fragment,r,n)}function qL(e,t){return t.value}function JL(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function YL(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function XL(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function ZL(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=EL(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function QL(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&FL.call(t.properties,i)){let a=tR(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&zL.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function $L(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else iR(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else iR(e,t.position);else a=r.value===null||r.value;n[i]=a}return n}function eR(e,t){let n=[],r=-1,i=e.passKeys?new Map:IL;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=VL(e,a,o);s!==void 0&&n.push(s)}return n}function tR(e,t,n){let r=hL(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?NI(n):bL(n)),r.property===`style`){let t=typeof n==`object`?n:nR(e,String(n));return e.stylePropertyNameCase===`css`&&(t=aR(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?dL[r.property]||r.property:r.attribute,n]}}function nR(e,t){try{return(0,PL.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new NL("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function rR(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=II(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=II(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return FL.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);iR(e)}function iR(e,t){let n=new NL("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function aR(e){let t={},n;for(n in e)FL.call(e,n)&&(t[oR(n)]=e[n]);return t}function oR(e){let t=e.replace(LL,sR);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function sR(e){return`-`+e.toLowerCase()}var cR={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},lR={};function uR(e,t){let n=t||lR;return dR(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function dR(e,t,n){if(pR(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return fR(e.children,t,n)}return Array.isArray(e)?fR(e,t,n):``}function fR(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=dR(e[i],t,n);return r.join(``)}function pR(e){return!!(e&&typeof e==`object`)}var mR=document.createElement(`i`);function hR(e){let t=`&`+e+`;`;mR.innerHTML=t;let n=mR.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function gR(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function _R(e,t){return e.length>0?(gR(e,e.length,0,t),e):t}var vR={}.hasOwnProperty;function yR(e){let t={},n=-1;for(;++n<e.length;)bR(t,e[n]);return t}function bR(e,t){let n;for(n in t){let r=(vR.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){vR.call(r,a)||(r[a]=[]);let e=i[a];xR(r[a],Array.isArray(e)?e:e?[e]:[])}}}function xR(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);gR(e,0,0,r)}function SR(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function CR(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var wR=IR(/[A-Za-z]/),TR=IR(/[\dA-Za-z]/),ER=IR(/[#-'*+\--9=?A-Z^-~]/);function DR(e){return e!==null&&(e<32||e===127)}var OR=IR(/\d/),kR=IR(/[\dA-Fa-f]/),AR=IR(/[!-/:-@[-`{-~]/);function jR(e){return e!==null&&e<-2}function MR(e){return e!==null&&(e<0||e===32)}function NR(e){return e===-2||e===-1||e===32}var PR=IR(/\p{P}|\p{S}/u),FR=IR(/\s/);function IR(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function LR(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&TR(e.charCodeAt(n+1))&&TR(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function RR(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return NR(r)?(e.enter(n),s(r)):t(r)}function s(r){return NR(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var zR={tokenize:BR};function BR(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),RR(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return jR(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var VR={tokenize:UR},HR={tokenize:WR};function UR(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return gR(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(HR,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(HR,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return jR(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;gR(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function WR(e,t,n){return RR(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function GR(e){if(e===null||MR(e)||FR(e))return 1;if(PR(e))return 2}function KR(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var qR={name:`attention`,resolveAll:JR,tokenize:YR};function JR(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};XR(d,-c),XR(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=_R(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=_R(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=_R(l,KR(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=_R(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=_R(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,gR(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function YR(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=GR(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=GR(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function XR(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var ZR={name:`autolink`,tokenize:QR};function QR(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return wR(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||TR(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||TR(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||DR(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):ER(t)?(e.consume(t),l):n(t)}function u(e){return TR(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||TR(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var $R={partial:!0,tokenize:ez};function ez(e,t,n){return r;function r(t){return NR(t)?RR(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||jR(e)?t(e):n(e)}}var tz={continuation:{tokenize:rz},exit:iz,name:`blockQuote`,tokenize:nz};function nz(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return NR(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function rz(e,t,n){let r=this;return i;function i(t){return NR(t)?RR(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(tz,t,n)(r)}}function iz(e){e.exit(`blockQuote`)}var az={name:`characterEscape`,tokenize:oz};function oz(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return AR(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var sz={name:`characterReference`,tokenize:cz};function cz(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=TR,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=kR,u):(e.enter(`characterReferenceValue`),a=7,o=OR,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===TR&&!hR(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var lz={partial:!0,tokenize:fz},uz={concrete:!0,name:`codeFenced`,tokenize:dz};function dz(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),NR(t)?RR(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||jR(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(lz,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||jR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):NR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),RR(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||jR(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||jR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&NR(t)?RR(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||jR(t)?e.check(lz,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||jR(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),NR(t)?RR(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),NR(t)?RR(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||jR(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function fz(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var pz={name:`codeIndented`,tokenize:hz},mz={partial:!0,tokenize:gz};function hz(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),RR(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):jR(t)?e.attempt(mz,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||jR(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function gz(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):jR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):RR(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):jR(e)?i(e):n(e)}}var _z={name:`codeText`,previous:yz,resolve:vz,tokenize:bz};function vz(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function yz(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function bz(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):jR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||jR(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var xz=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Sz(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Sz(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Sz(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);Sz(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Sz(this.left,t.reverse())}}};function Sz(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Cz(e){let t={},n=-1,r,i,a,o,s,c,l,u=new xz(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,wz(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return gR(e,0,1/0,u.slice(0)),!l}function wz(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Tz={resolve:Dz,tokenize:Oz},Ez={partial:!0,tokenize:kz};function Dz(e){return Cz(e),e}function Oz(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):jR(t)?e.check(Ez,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function kz(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),RR(e,a,`linePrefix`)}function a(i){if(i===null||jR(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Az(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||DR(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||jR(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||MR(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||DR(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function jz(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):jR(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||jR(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!NR(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Mz(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):jR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),RR(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||jR(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Nz(e,t){let n;return r;function r(i){return jR(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):NR(i)?RR(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Pz={name:`definition`,tokenize:Iz},Fz={partial:!0,tokenize:Lz};function Iz(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return jz.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=CR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return MR(t)?Nz(e,l)(t):l(t)}function l(t){return Az(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Fz,d,d)(t)}function d(t){return NR(t)?RR(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||jR(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Lz(e,t,n){return r;function r(t){return MR(t)?Nz(e,i)(t):n(t)}function i(t){return Mz(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return NR(t)?RR(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||jR(e)?t(e):n(e)}}var Rz={name:`hardBreakEscape`,tokenize:zz};function zz(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return jR(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Bz={name:`headingAtx`,resolve:Vz,tokenize:Hz};function Vz(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},gR(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Hz(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||MR(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||jR(n)?(e.exit(`atxHeading`),t(n)):NR(n)?RR(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||MR(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Uz=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Wz=[`pre`,`script`,`style`,`textarea`],Gz={concrete:!0,name:`htmlFlow`,resolveTo:Jz,tokenize:Yz},Kz={partial:!0,tokenize:Zz},qz={partial:!0,tokenize:Xz};function Jz(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Yz(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:F):wR(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):wR(a)?(e.consume(a),i=4,r.interrupt?t:F):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:F):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return wR(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||MR(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Wz.includes(l)?(i=1,r.interrupt?t(s):O(s)):Uz.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||TR(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return NR(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||wR(t)?(e.consume(t),b):NR(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||TR(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):NR(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):NR(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||jR(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||MR(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||NR(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||jR(t)?O(t):NR(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),I):t===63&&i===3?(e.consume(t),F):t===93&&i===5?(e.consume(t),ee):jR(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Kz,te,k)(t)):t===null||jR(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(qz,A,te)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||jR(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),F):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Wz.includes(n)?(e.consume(t),I):O(t)}return wR(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function ee(t){return t===93?(e.consume(t),F):O(t)}function F(t){return t===62?(e.consume(t),I):t===45&&i===2?(e.consume(t),F):O(t)}function I(t){return t===null||jR(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),I)}function te(n){return e.exit(`htmlFlow`),t(n)}}function Xz(e,t,n){let r=this;return i;function i(t){return jR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Zz(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt($R,t,n)}}var Qz={name:`htmlText`,tokenize:$z};function $z(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):wR(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):wR(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):jR(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):jR(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):jR(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):jR(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return wR(t)?(e.consume(t),S):n(t)}function S(t){return t===45||TR(t)?(e.consume(t),S):C(t)}function C(t){return jR(t)?(o=C,N(t)):NR(t)?(e.consume(t),C):M(t)}function w(t){return t===45||TR(t)?(e.consume(t),w):t===47||t===62||MR(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||wR(t)?(e.consume(t),E):jR(t)?(o=T,N(t)):NR(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||TR(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):jR(t)?(o=D,N(t)):NR(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):jR(t)?(o=O,N(t)):NR(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):jR(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||MR(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||MR(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return NR(t)?RR(e,ee,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ee(t)}function ee(t){return e.enter(`htmlTextData`),o(t)}}var eB={name:`labelEnd`,resolveAll:iB,resolveTo:aB,tokenize:oB},tB={tokenize:sB},nB={tokenize:cB},rB={tokenize:lB};function iB(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&gR(e,0,e.length,n),e}function aB(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=_R(s,e.slice(a+1,a+r+3)),s=_R(s,[[`enter`,u,t]]),s=_R(s,KR(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=_R(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=_R(s,e.slice(o+1)),s=_R(s,[[`exit`,c,t]]),gR(e,a,e.length,s),e}function oB(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(CR(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(tB,u,o?u:d)(t):t===91?e.attempt(nB,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(rB,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function sB(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return MR(t)?Nz(e,a)(t):a(t)}function a(t){return t===41?u(t):Az(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return MR(t)?Nz(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Mz(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return MR(t)?Nz(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function cB(e,t,n){let r=this;return i;function i(t){return jz.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(CR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function lB(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var uB={name:`labelStartImage`,resolveAll:eB.resolveAll,tokenize:dB};function dB(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var fB={name:`labelStartLink`,resolveAll:eB.resolveAll,tokenize:pB};function pB(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var mB={name:`lineEnding`,tokenize:hB};function hB(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),RR(e,t,`linePrefix`)}}var gB={name:`thematicBreak`,tokenize:_B};function _B(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||jR(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),NR(t)?RR(e,s,`whitespace`)(t):s(t))}}var vB={continuation:{tokenize:SB},exit:wB,name:`list`,tokenize:xB},yB={partial:!0,tokenize:TB},bB={partial:!0,tokenize:CB};function xB(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:OR(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(gB,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return OR(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check($R,r.interrupt?n:u,e.attempt(yB,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return NR(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function SB(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check($R,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,RR(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!NR(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(bB,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,RR(e,e.attempt(vB,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function CB(e,t,n){let r=this;return RR(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function wB(e){e.exit(this.containerState.type)}function TB(e,t,n){let r=this;return RR(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!NR(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var EB={name:`setextUnderline`,resolveTo:DB,tokenize:OB};function DB(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function OB(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),NR(t)?RR(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||jR(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var kB={tokenize:AB};function AB(e){let t=this,n=e.attempt($R,r,e.attempt(this.parser.constructs.flowInitial,i,RR(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Tz,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var jB={resolveAll:FB()},MB=PB(`string`),NB=PB(`text`);function PB(e){return{resolveAll:FB(e===`text`?IB:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function FB(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function IB(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var LB=s({attentionMarkers:()=>GB,contentInitial:()=>zB,disable:()=>KB,document:()=>RB,flow:()=>VB,flowInitial:()=>BB,insideSpan:()=>WB,string:()=>HB,text:()=>UB}),RB={42:vB,43:vB,45:vB,48:vB,49:vB,50:vB,51:vB,52:vB,53:vB,54:vB,55:vB,56:vB,57:vB,62:tz},zB={91:Pz},BB={[-2]:pz,[-1]:pz,32:pz},VB={35:Bz,42:gB,45:[EB,gB],60:Gz,61:EB,95:gB,96:uz,126:uz},HB={38:sz,92:az},UB={[-5]:mB,[-4]:mB,[-3]:mB,33:uB,38:sz,42:qR,60:[ZR,Qz],91:fB,92:[Rz,az],93:eB,95:qR,96:_z},WB={null:[qR,jB]},GB={null:[42,95]},KB={null:[]};function qB(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=_R(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=KR(a,l.events,l),l.events):[]}function f(e,t){return YB(p(e),t)}function p(e){return JB(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){jR(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&gR(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function JB(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function YB(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
122
|
+
`)[0].trim();return t.length>140?`${t.slice(0,139)}…`:t}function xM(e,t){if(e.type!==`run.finished`)return null;let n=yM(e.data);if(!n)return null;let r=t??`your feature`;return n.status===`succeeded`?{title:`Burn complete — review is ready`,body:r}:n.status===`failed`?{title:`Burn failed`,body:`${r}: ${bM(n.summary)}`}:null}var SM=`runcastle:notifications`,CM=typeof Notification<`u`;function wM(){try{return localStorage.getItem(SM)===`on`}catch{return!1}}function TM(e){try{localStorage.setItem(SM,e?`on`:`off`)}catch{}}function EM({title:e,body:t}){try{let n=new Notification(e,{body:t});n.onclick=()=>{window.focus(),n.close()}}catch{}}function DM(e,t){let[n,r]=(0,L.useState)(()=>CM&&wM()),[i,a]=(0,L.useState)(()=>CM?Notification.permission:`default`),[o,s]=(0,L.useState)(void 0),c=(0,L.useRef)(!1),l=(0,L.useRef)(new Map);l.current=new Map(t.map(e=>[e.id,e.title]));let u=B.events.listByProject.useQuery({projectId:e,afterId:o},{refetchInterval:Ch(),enabled:CM&&n});return(0,L.useEffect)(()=>{let e=u.data;if(!e||e.length===0)return;let t=e[e.length-1].id,n=document.hidden||!document.hasFocus();if(c.current&&Notification.permission===`granted`&&n)for(let t of e){let e=xM(t,t.featureId?l.current.get(t.featureId):void 0);e&&EM(e)}c.current=!0,s(t)},[u.data]),{supported:CM,enabled:n,permission:i,toggle:(0,L.useCallback)(()=>{if(CM){if(Notification.permission===`denied`){a(`denied`);return}if(n){r(!1),TM(!1);return}c.current=!1,s(void 0),r(!0),TM(!0),Notification.permission==="default"&&Notification.requestPermission().then(e=>{a(e),e!==`granted`&&(r(!1),TM(!1))})}},[n])}}var OM=`runcastle.theme`,kM=`dark`,AM=`(prefers-color-scheme: light)`;function jM(e){return e===`dark`||e===`light`||e===`system`}function MM(){try{let e=globalThis.localStorage?.getItem(OM);return jM(e)?e:kM}catch{return kM}}function NM(){try{return globalThis.matchMedia?.(AM).matches?`light`:`dark`}catch{return`dark`}}function PM(e){return e===`system`?NM():e}var FM=kM,IM=new Set,LM=null;function RM(){if(typeof document>`u`)return;let e=document.documentElement,t=PM(FM);if(e.dataset.theme===t)return;let n=e.dataset.theme!==void 0;if(n&&e.setAttribute(`data-theme-switching`,``),e.dataset.theme=t,n){let t=()=>e.removeAttribute(`data-theme-switching`);typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>requestAnimationFrame(t)):t()}}function zM(){for(let e of IM)e()}function BM(e){if(!e){LM?.(),LM=null;return}if(LM)return;let t;try{t=globalThis.matchMedia?.(AM)}catch{t=void 0}if(!t)return;let n=()=>{RM(),zM()};t.addEventListener(`change`,n),LM=()=>t.removeEventListener(`change`,n)}function VM(){return FM=MM(),RM(),BM(FM===`system`),FM}function HM(e){FM=e;try{globalThis.localStorage?.setItem(OM,e)}catch{}RM(),BM(e===`system`),zM()}function UM(e){return IM.add(e),()=>IM.delete(e)}var WM=()=>`${FM}:${PM(FM)}`,GM=()=>`${kM}:${kM}`;function KM(){let[e,t]=(0,L.useSyncExternalStore)(UM,WM,GM).split(`:`);return{preference:e,resolved:t,setPreference:HM,toggle:(0,L.useCallback)(()=>{HM(PM(FM)===`dark`?`light`:`dark`)},[])}}var qM=Object.defineProperty,JM=(e,t)=>qM(e,`name`,{value:t,configurable:!0});function YM(e){let t=e+`CollectionProvider`,[n,r]=Xx(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=JM(e=>{let{scope:t,children:n}=e,r=L.useRef(null),a=L.useRef(new Map).current;return(0,R.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=eS(s),l=L.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Kx(t,a(s,n).collectionRef);return(0,R.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=eS(u),p=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),s=Kx(t,o),c=a(u,n);return L.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,R.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return L.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return JM(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}JM(YM,`createCollection`);var XM=new WeakMap,ZM=class e extends Map{static{JM(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],XM.set(this,!0)}set(e,t){return XM.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=eN(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=QM(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=QM(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return QM(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function QM(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=$M(e,t);return n===-1?void 0:e[n]}JM(QM,`at`);function $M(e,t){let n=e.length,r=eN(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}JM($M,`toSafeIndex`);function eN(e){return e!==e||e===0?0:Math.trunc(e)}JM(eN,`toSafeInteger`);function tN(e){let t=e+`CollectionProvider`,[n,r]=Xx(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new ZM,setItemMap:JM(()=>void 0,`setItemMap`)}),o=JM(({state:e,...t})=>e?(0,R.jsx)(c,{...t,state:e}):(0,R.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=JM(e=>{let t=h();return(0,R.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=JM(e=>{let{scope:t,children:n,state:r}=e,a=L.useRef(null),[o,s]=L.useState(null),c=Kx(a,s),[l,u]=r;return L.useEffect(()=>{if(!o)return;let e=aN(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,R.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=eS(l),d=L.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Kx(t,a(l,n).collectionRef);return(0,R.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=eS(f),m=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),[s,c]=L.useState(null),l=Kx(t,o,c),{setItemMap:u}=a(f,n),d=L.useRef(i);nN(d.current,i)||(d.current=i);let m=d.current;return L.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(iN):(t.set(s,{...e,element:s}),t.toSorted(iN)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new ZM(e)))}},[s,m,u]),(0,R.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return L.useState(new ZM)}JM(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return JM(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}JM(tN,`createCollection`);function nN(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}JM(nN,`shallowEqual`);function rN(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}JM(rN,`isElementPreceding`);function iN(e,t){return!e[1].element||!t[1].element?0:rN(e[1].element,t[1].element)?-1:1}JM(iN,`sortByDocumentPosition`);function aN(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}JM(aN,`getChildListObserver`);var oN=Object.defineProperty,sN=(e,t)=>oN(e,`name`,{value:t,configurable:!0}),cN=L.createContext(void 0);function lN(e){let t=L.useContext(cN);return e||t||`ltr`}sN(lN,`useDirection`);var uN=Object.defineProperty,dN=(e,t)=>uN(e,`name`,{value:t,configurable:!0}),fN=!1;function pN(){let[e,t]=L.useState(fN);return L.useEffect(()=>{fN||(fN=!0,t(!0))},[]),e}dN(pN,`useIsHydrated`);var mN=L.useSyncExternalStore;function hN(){return()=>{}}dN(hN,`subscribe`);function gN(){return mN(hN,()=>!0,()=>!1)}dN(gN,`useIsHydratedModern`);var _N=typeof mN==`function`?gN:pN,vN=Object.defineProperty,yN=(e,t)=>vN(e,`name`,{value:t,configurable:!0}),bN=`rovingFocusGroup.onEntryFocus`,xN={bubbles:!1,cancelable:!0},SN=`RovingFocusGroup`,[CN,wN,TN]=YM(SN),[EN,DN]=Xx(SN,[TN]),[ON,kN]=EN(SN),AN=L.forwardRef(yN(function(e,t){return(0,R.jsx)(CN.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(CN.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(jN,{...e,ref:t})})})},`RovingFocusGroup`)),jN=L.forwardRef(yN(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=L.useRef(null),p=Kx(t,f),m=lN(a),[h,g]=RT({prop:o,defaultProp:s??null,onChange:c,caller:SN}),[_,v]=L.useState(!1),y=yS(l),b=wN(n),x=L.useRef(!1),[S,C]=L.useState(0);return L.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(bN,y),()=>e.removeEventListener(bN,y)},[y]),(0,R.jsx)(ON,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:L.useCallback(e=>g(e),[g]),onItemShiftTab:L.useCallback(()=>v(!0),[]),onFocusableItemAdd:L.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:L.useCallback(()=>C(e=>e-1),[]),children:(0,R.jsx)(hS.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:J(e.onMouseDown,()=>{x.current=!0}),onFocus:J(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(bN,xN);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);LN([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:J(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),MN=`RovingFocusGroupItem`,NN=L.forwardRef(yN(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=zS(),l=a||c,u=kN(MN,n),d=u.currentTabStopId===l,f=wN(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=_N();return PS(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),L.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,R.jsx)(CN.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(hS.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:J(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:J(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:J(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=IN(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?RN(n,r+1):n.slice(r+1)}setTimeout(()=>LN(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),PN={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function FN(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}yN(FN,`getDirectionAwareKey`);function IN(e,t,n){let r=FN(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return PN[r]}yN(IN,`getFocusIntent`);function LN(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}yN(LN,`focusFirst`);function RN(e,t){return e.map((n,r)=>e[(t+r)%e.length])}yN(RN,`wrapArray`);var zN=AN,BN=NN,VN=Object.defineProperty,HN=(e,t)=>VN(e,`name`,{value:t,configurable:!0}),UN=[`Enter`,` `],WN=[`ArrowDown`,`PageUp`,`Home`],GN=[`ArrowUp`,`PageDown`,`End`],KN=[...WN,...GN];[...UN],[...UN];var qN=`Menu`,[JN,YN,XN]=YM(qN),[ZN,QN]=Xx(qN,[XN,iT,DN]),$N=iT(),eP=DN(),[tP,nP]=ZN(qN),[rP,iP]=ZN(qN),aP=HN(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=$N(t),[c,l]=L.useState(null),u=L.useRef(!1),d=yS(a),f=lN(i);return L.useEffect(()=>{let e=HN(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=HN(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),L.useEffect(()=>{if(!n)return;let e=HN(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,R.jsx)(gT,{...s,children:(0,R.jsx)(tP,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(rP,{scope:t,onClose:L.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),oP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,...r}=e,i=$N(n);return(0,R.jsx)(_T,{...i,...r,ref:t})},`MenuAnchor`)),sP=`MenuPortal`,[cP,lP]=ZN(sP,{forceMount:void 0}),uP=HN(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=nP(sP,t);return(0,R.jsx)(cP,{scope:t,forceMount:n,children:(0,R.jsx)(wT,{present:n||a.open,children:(0,R.jsx)(bT,{asChild:!0,container:i,children:r})})})},`MenuPortal`),dP=`MenuContent`,[fP,pP]=ZN(dP),mP=L.forwardRef(HN(function(e,t){let n=lP(dP,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=nP(dP,e.__scopeMenu),o=iP(dP,e.__scopeMenu);return(0,R.jsx)(JN.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(wT,{present:r||a.open,children:(0,R.jsx)(JN.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(hP,{...i,ref:t}):(0,R.jsx)(gP,{...i,ref:t})})})})},`MenuContent`)),hP=L.forwardRef(HN(function(e,t){let n=nP(dP,e.__scopeMenu),r=L.useRef(null),i=Kx(t,r);return L.useEffect(()=>{let e=r.current;if(e)return ZO(e)},[]),(0,R.jsx)(vP,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),gP=L.forwardRef(HN(function(e,t){let n=nP(dP,e.__scopeMenu);return(0,R.jsx)(vP,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),_P=eS(`MenuContent.ScrollLock`),vP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=nP(dP,n),_=iP(dP,n),v=$N(n),y=eP(n),b=YN(n),[x,S]=L.useState(null),C=L.useRef(null),w=Kx(t,C,g.onContentChange),T=L.useRef(0),E=L.useRef(``),D=L.useRef(0),O=L.useRef(null),k=L.useRef(`right`),A=L.useRef(0),j=m?HO:L.Fragment,M=m?{as:_P,allowPinchZoom:!0}:void 0,N=HN(e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=AP(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;HN((function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);L.useEffect(()=>()=>window.clearTimeout(T.current),[]),MD();let P=L.useCallback(e=>k.current===O.current?.side&&MP(e,O.current?.area),[]);return(0,R.jsx)(fP,{scope:n,searchRef:E,onItemEnter:L.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:L.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:L.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:L.useCallback(e=>{O.current=e},[]),children:(0,R.jsx)(j,{...M,children:(0,R.jsx)(hD,{asChild:!0,trapped:i,onMountAutoFocus:J(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(DS,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(zN,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:J(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(vT,{role:`menu`,"aria-orientation":`vertical`,"data-state":TP(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:J(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=C.current;if(e.target!==i||!KN.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);GN.includes(e.key)&&a.reverse(),OP(a)}),onBlur:J(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:J(e.onPointerMove,NP(e=>{let t=e.target,n=A.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>A.current?`right`:`left`;k.current=t,A.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),yP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(hS.div,{...r,ref:t})},`MenuLabel`)),bP=`MenuItem`,xP=`menu.itemSelect`,SP=L.forwardRef(HN(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=L.useRef(null),o=iP(bP,e.__scopeMenu),s=pP(bP,e.__scopeMenu),c=Kx(t,a),l=L.useRef(!1),u=HN(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(xP,{bubbles:!0,cancelable:!0});e.addEventListener(xP,e=>r?.(e),{once:!0}),gS(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,R.jsx)(CP,{...i,ref:c,disabled:n,onClick:J(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:J(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:J(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||UN.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),CP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=pP(bP,n),s=eP(n),c=L.useRef(null),l=Kx(t,c),[u,d]=L.useState(!1),[f,p]=L.useState(``);return L.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(JN.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(BN,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(hS.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:J(e.onPointerMove,NP(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:J(e.onPointerLeave,NP(e=>o.onItemLeave(e))),onFocus:J(e.onFocus,()=>d(!0)),onBlur:J(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[iee,aee]=ZN(`MenuRadioGroup`,{value:void 0,onValueChange:HN(()=>{},`onValueChange`)}),[oee,see]=ZN(`MenuItemIndicator`,{checked:!1}),wP=L.forwardRef(HN(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(hS.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[cee,lee]=ZN(`MenuSub`);function TP(e){return e?`open`:`closed`}HN(TP,`getOpenState`);function EP(e){return e===`indeterminate`}HN(EP,`isIndeterminate`);function DP(e){return EP(e)?`indeterminate`:e?`checked`:`unchecked`}HN(DP,`getCheckedState`);function OP(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}HN(OP,`focusFirst`);function kP(e,t){return e.map((n,r)=>e[(t+r)%e.length])}HN(kP,`wrapArray`);function AP(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=kP(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}HN(AP,`getNextMatch`);function jP(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}HN(jP,`isPointInPolygon`);function MP(e,t){return t?jP({x:e.clientX,y:e.clientY},t):!1}HN(MP,`isPointerInGraceArea`);function NP(e){return t=>t.pointerType===`mouse`?e(t):void 0}HN(NP,`whenMouse`);var PP=aP,FP=oP,IP=uP,LP=mP,RP=yP,zP=SP,BP=wP,VP=Object.defineProperty,HP=(e,t)=>VP(e,`name`,{value:t,configurable:!0}),UP=`DropdownMenu`,[WP,uee]=Xx(UP,[QN]),GP=QN(),[KP,qP]=WP(UP),JP=HP(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=GP(t),l=L.useRef(null),[u,d]=RT({prop:i,defaultProp:a??!1,onChange:o,caller:UP});return(0,R.jsx)(KP,{scope:t,triggerId:zS(),triggerRef:l,contentId:zS(),open:u,onOpenChange:d,onOpenToggle:L.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(PP,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),YP=`DropdownMenuTrigger`,XP=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=qP(YP,n),o=GP(n),s=Kx(t,a.triggerRef);return(0,R.jsx)(FP,{asChild:!0,...o,children:(0,R.jsx)(hS.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:J(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:J(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),ZP=HP(e=>{let{__scopeDropdownMenu:t,...n}=e,r=GP(t);return(0,R.jsx)(IP,{...r,...n})},`DropdownMenuPortal`),QP=`DropdownMenuContent`,$P=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=qP(QP,n),a=GP(n),o=L.useRef(!1);return(0,R.jsx)(LP,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:J(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),eF=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=GP(n);return(0,R.jsx)(RP,{...i,...r,ref:t})},`DropdownMenuLabel`)),tF=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=GP(n);return(0,R.jsx)(zP,{...i,...r,ref:t})},`DropdownMenuItem`)),nF=L.forwardRef(HP(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=GP(n);return(0,R.jsx)(BP,{...i,...r,ref:t})},`DropdownMenuSeparator`)),rF=JP,iF=XP,aF=ZP,oF=$P,sF=eF,cF=tF,lF=nF;function uF({modal:e=!1,...t}){return(0,R.jsx)(rF,{modal:e,...t})}var dF=iF;function fF({className:e,align:t=`start`,sideOffset:n=4,collisionPadding:r=8,onEscapeKeyDown:i,...a}){return(0,R.jsx)(aF,{children:(0,R.jsx)(oF,{align:t,sideOffset:n,collisionPadding:r,onEscapeKeyDown:e=>{i?.(e),e.stopPropagation()},className:q(Ox,`max-h-(--radix-dropdown-menu-content-available-height) min-w-48 p-1`,e),...a})})}function pF({className:e,tone:t=`default`,icon:n,kbd:r,children:i,...a}){return(0,R.jsxs)(cF,{className:q(kx,t===`danger`?jx:Ax,e),...a,children:[n,r?(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i}):i,r&&(0,R.jsx)(Px,{className:`ml-auto`,children:r})]})}function mF({className:e,...t}){return(0,R.jsx)(sF,{className:q(Mx,e),...t})}function hF({className:e,...t}){return(0,R.jsx)(lF,{className:q(Nx,e),...t})}function gF(e,t){navigator.clipboard.writeText(e).then(()=>t.push(`copied ${e}`,`info`)).catch(()=>t.push(`copy failed`))}function _F({width:e,side:t,label:n,clamp:r,onResize:i}){let[a,o]=(0,L.useState)(!1),s=(0,L.useRef)({x:0,width:e});return(0,L.useEffect)(()=>{if(!a)return;let e=e=>{let n=e.clientX-s.current.x;i(r(s.current.width+(t===`left`?n:-n)))},n=()=>o(!1),c=document.body.style.userSelect;return document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n),()=>{document.body.style.userSelect=c,document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n)}},[r,a,i,t]),(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":n,title:`Drag to resize`,className:`absolute top-0 z-10 h-full w-1.5 cursor-col-resize transition-colors duration-(--dur-1) ease-app hover:bg-border-strong ${t===`left`?`-right-[3px]`:`-left-[3px]`} ${a?`bg-border-strong`:``}`,onMouseDown:t=>{t.preventDefault(),s.current={x:t.clientX,width:e},o(!0)}})}var vF={"copy-link":(0,R.jsx)(Fb,{}),"copy-branch":(0,R.jsx)(rb,{}),archive:(0,R.jsx)(jb,{}),unarchive:(0,R.jsx)(jb,{}),rename:(0,R.jsx)(_b,{}),delete:(0,R.jsx)(lb,{}),remove:(0,R.jsx)(lb,{})};function yF({actions:e,label:t=`Feature actions`,size:n=`sm`,align:r=`end`}){let i=(0,L.useRef)(null);if(e.length===0)return null;let a=e.filter(e=>!e.danger),o=e.filter(e=>e.danger),s=e=>(0,R.jsx)(pF,{className:`text-sm`,tone:e.danger?`danger`:`default`,icon:e.icon??vF[e.key],kbd:e.kbd,onSelect:()=>{i.current?.focus(),e.onSelect(i)},children:e.label},e.key);return(0,R.jsxs)(uF,{children:[(0,R.jsx)(dF,{asChild:!0,children:(0,R.jsx)(UE,{ref:i,label:t,size:n,icon:(0,R.jsx)(pb,{}),className:`shrink-0`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation()})}),(0,R.jsxs)(fF,{align:r,className:`font-sans`,onCloseAutoFocus:e=>{let t=document.activeElement;t&&t!==document.body&&t!==i.current&&e.preventDefault()},children:[a.map(s),a.length>0&&o.length>0&&(0,R.jsx)(hF,{}),o.map(s)]})]})}function bF({title:e,slug:t,busy:n,onConfirm:r,onCancel:i,returnFocusRef:a}){let[o,s]=(0,L.useState)(``),c=o.trim()===t;return(0,R.jsxs)(Hj,{open:!0,onClose:i,returnFocusRef:a,labelledBy:`delete-feature-title`,size:`sm`,children:[(0,R.jsx)(Uj,{id:`delete-feature-title`,title:`Delete feature`,onClose:i}),(0,R.jsxs)(Wj,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(`p`,{className:`m-0 text-sm text-pretty text-text-secondary`,children:[`Permanently delete `,(0,R.jsx)(`strong`,{className:`font-medium text-text`,children:e}),`? Its worktree, branches, running agent and all runcastle data go with it; committed docs stay in git history.`,` `,(0,R.jsx)(`strong`,{className:`font-medium text-text`,children:`This cannot be undone.`})]}),(0,R.jsx)(hj,{label:(0,R.jsxs)(R.Fragment,{children:[`Type `,(0,R.jsx)(`code`,{className:`font-mono text-xs text-text`,children:t}),` to confirm`]}),children:(0,R.jsx)(fj,{mono:!0,value:o,onChange:e=>s(e.target.value),autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t})})]}),(0,R.jsxs)(Gj,{children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:i,disabled:n,children:`Cancel`}),(0,R.jsx)(Y,{variant:`danger`,icon:(0,R.jsx)(lb,{}),onClick:r,disabled:!c||n,children:n?`Deleting…`:`Delete feature`})]})]})}var xF=`group flex h-8 min-w-0 cursor-pointer items-center gap-2 rounded-md border border-transparent bg-transparent pr-1.5 pl-2 text-text transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover aria-expanded:bg-surface-selected`,SF=`text-sm`;function CF({nav:e}){let t=e.projects??[],n=e.currentProject?.name??`runcastle`;return(0,R.jsxs)(uF,{children:[(0,R.jsxs)(dF,{className:xF,"aria-label":`${n} — switch project`,children:[(0,R.jsx)(lx,{size:16,className:`shrink-0`}),(0,R.jsx)(`span`,{className:`max-w-56 min-w-0 truncate text-sm font-semibold`,title:n,children:n}),(0,R.jsx)(db,{size:14,className:`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app group-aria-expanded:rotate-180`})]}),(0,R.jsxs)(fF,{className:`w-64`,children:[(0,R.jsx)(mF,{children:`Projects`}),t.map(n=>{let r=n.id===e.currentProjectId,i=ug(n.repoPath),a=i!==n.name||t.some(e=>e.id!==n.id&&e.name===n.name);return(0,R.jsxs)(pF,{className:SF,icon:(0,R.jsx)(yb,{}),"aria-current":r?`true`:void 0,onSelect:()=>e.enterProject(n.id),children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate`,children:n.name}),a&&(0,R.jsx)(`span`,{className:`block truncate font-mono text-xs text-text-tertiary`,children:i})]}),r&&(0,R.jsx)(sb,{size:14,className:`text-text`})]},n.id)}),(0,R.jsx)(hF,{}),(0,R.jsx)(pF,{className:SF,icon:(0,R.jsx)(zb,{}),onSelect:()=>e.goHome(),children:(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`All projects`})}),(0,R.jsx)(pF,{className:SF,icon:(0,R.jsx)(ob,{}),onSelect:()=>e.showOpen(),children:(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Open a project…`})})]})]})}var wF=`runcastle.sidebar.collapsed`,TF=44;function EF(){try{return localStorage.getItem(wF)===`1`}catch{return!1}}var DF=(0,L.createContext)(null);function OF(e){return e instanceof Element&&e.closest(`.xterm`)!==null}function kF({notices:e,children:t}){let{width:n,setWidth:r}=aM(),[i,a]=(0,L.useState)(EF),o=(0,L.useCallback)(()=>{a(e=>{let t=!e;try{localStorage.setItem(wF,t?`1`:`0`)}catch{}return t})},[]);(0,L.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.altKey||e.shiftKey||!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`b`||OF(e.target)||(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let s=(0,L.useMemo)(()=>({width:n,setWidth:r,collapsed:i,toggleSidebar:o,notices:e??null}),[n,r,i,o,e]);return(0,R.jsx)(DF.Provider,{value:s,children:t})}function AF(){return(0,L.useContext)(DF)??{width:iM(NaN),setWidth:()=>void 0,collapsed:!1,toggleSidebar:()=>void 0,notices:null}}function jF(){let{toggleSidebar:e}=AF();return(0,R.jsx)(UE,{label:`Hide sidebar`,kbd:mM(`B`),size:`sm`,icon:(0,R.jsx)(Mb,{}),tooltipSide:`bottom`,onClick:e})}function MF({sidebar:e,rail:t,children:n}){let{width:r,setWidth:i,collapsed:a,toggleSidebar:o,notices:s}=AF(),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let d=e=>{l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),160),i(e)},f=e!==void 0;return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 bg-canvas text-text`,style:{"--sidebar-w":`${r}px`},children:[f&&(0,R.jsxs)(`div`,{"data-sidebar":a?`collapsed`:`expanded`,className:q(`relative h-full shrink-0 overflow-hidden`,!c&&`transition-[width] duration-(--dur-3) ease-out-app motion-reduce:transition-none`),style:{width:a?TF:r},children:[(0,R.jsx)(`div`,{inert:a,"aria-hidden":a||void 0,className:q(`absolute inset-y-0 left-0 flex w-(--sidebar-w) flex-col`,`transition-opacity duration-(--dur-2) ease-app`,a?`pointer-events-none opacity-0`:`opacity-100`),children:e}),(0,R.jsxs)(`div`,{inert:!a,"aria-hidden":!a||void 0,className:q(`absolute inset-y-0 left-0 flex w-11 flex-col items-center gap-1 pt-4`,`transition-[opacity,translate] duration-(--dur-3) ease-out-app`,a?`translate-x-0 opacity-100 delay-75`:`pointer-events-none -translate-x-2 opacity-0`),children:[(0,R.jsx)(UE,{label:`Show sidebar`,kbd:mM(`B`),icon:(0,R.jsx)(Mb,{}),tooltipSide:`right`,onClick:o}),t]}),!a&&(0,R.jsx)(_F,{width:r,side:`left`,label:`Resize the sidebar`,clamp:iM,onResize:d})]}),(0,R.jsxs)(`main`,{className:q(`my-2 mr-2 flex min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-surface`,!f&&`ml-2`),children:[s,(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:n})]})]})}var NF=`runcastle.sidebar.showArchived`;function PF(){try{return localStorage.getItem(NF)===`1`}catch{return!1}}function FF(e){let{projectId:t,nav:n,view:r,selectedFeatureId:i,talk:a,onSelect:o,onSelectProject:s,onNewChat:c,onDraft:l,onOpenPreparation:u,onOpenNote:d,onOpenCmdk:f}=e,p=B.useUtils(),m=gx(),[h,g]=(0,L.useState)(PF),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(null),x=B.feature.list.useQuery({projectId:t},{refetchInterval:Ch()}),S=B.project.prep.useQuery({projectId:t}),C=$y(S.data&&{prepared:S.data.prepared,pendingCount:S.data.pendingKeys.length,staleCount:S.data.findings.filter(im).length}),w=B.projectNotes.openCount.useQuery({projectId:t}).data??0,T=Qh(x.data??[],{showArchived:h}),E=(x.data??[]).filter(e=>e.status===`archived`).length,D=()=>void p.feature.list.invalidate(),O=B.feature.archive.useMutation({onSuccess:D,onError:e=>m.push(e.message)}),k=B.feature.unarchive.useMutation({onSuccess:D,onError:e=>m.push(e.message)}),A=B.feature.delete.useMutation({onSuccess:(e,t)=>{D(),t.featureId===i&&(o(null),s()),b(null)},onError:e=>m.push(e.message)}),j=()=>{g(e=>{let t=!e;try{localStorage.setItem(NF,t?`1`:`0`)}catch{}return t})},M=e=>{let n=[{key:`copy-link`,label:`Copy link`,onSelect:()=>gF(window.location.origin+Sg({kind:`feature`,projectId:t,featureSlug:e.slug}),m)}];return e.status===`archived`?n.push({key:`unarchive`,label:`Unarchive`,onSelect:()=>k.mutate({featureId:e.id})}):e.status!==`draft`&&n.push({key:`archive`,label:`Archive`,onSelect:()=>O.mutate({featureId:e.id})}),e.status!==`shipped`&&n.push({key:`delete`,label:`Delete…`,danger:!0,onSelect:t=>b({feature:e,returnFocusRef:t})}),n},N=n.currentProject?.name??`This project`,P=a.state!==`none`;return(0,R.jsxs)(`nav`,{"aria-label":`Project`,className:`flex h-full min-h-0 flex-col p-2`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-0.5`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:(0,R.jsx)(CF,{nav:n})}),(0,R.jsx)(IF,{onNewChat:c,onDraft:l,onOpenNote:d}),(0,R.jsx)(jF,{})]}),(0,R.jsx)(`div`,{className:`shrink-0 pt-1 pb-2`,children:(0,R.jsx)(RF,{onOpen:f})}),(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-px`,children:[(0,R.jsx)(nj,{icon:(0,R.jsx)(yb,{}),label:`Project`,active:r===`project`,onClick:s,dot:P?`live`:void 0,meta:w>0?(0,R.jsx)(`span`,{title:`${w} note${w===1?``:`s`} waiting to be triaged`,children:w}):void 0,title:w>0?`${N} — ${w} open note${w===1?``:`s`}`:`Talk to the project — intake, decomposition, and portfolio questions`}),C?.variant===`todo`&&(0,R.jsx)(nj,{icon:(0,R.jsx)(Eb,{}),label:C.label,meta:C.badge??void 0,dot:`warning`,active:r===`prepare`,onClick:u,title:C.title})]}),(0,R.jsxs)(`div`,{className:`-mx-2 mt-3 min-h-0 flex-1 overflow-y-auto px-2`,children:[x.isLoading&&(0,R.jsx)(WF,{}),x.data&&x.data.length===0&&(0,R.jsx)(`div`,{className:`px-2.5 py-2 text-xs text-pretty text-text-tertiary`,children:`No features yet. Start a chat to cut the first one.`}),T.map(e=>{let t=ng(e,_);return(0,R.jsxs)(`section`,{"aria-label":e.label,className:`mb-3 flex flex-col gap-px`,children:[(0,R.jsx)($A,{count:e.features.length,className:`px-2.5`,children:e.label}),t.visible.map(e=>(0,R.jsx)(GF,{f:e,active:e.id===i&&r===`feature`,onSelect:o,actions:M(e)},e.id)),t.expanderLabel&&(0,R.jsx)(nj,{tone:`quiet`,label:t.expanderLabel,onClick:()=>v(e=>!e)})]},e.key)}),E>0&&(0,R.jsx)(nj,{tone:`quiet`,label:h?`Hide archived`:`Show archived`,meta:E,onClick:j})]}),(0,R.jsx)(XF,{...e,prepRow:C}),y&&(0,R.jsx)(bF,{title:y.feature.title,slug:y.feature.slug,busy:A.isPending,onConfirm:()=>A.mutate({featureId:y.feature.id}),onCancel:()=>b(null),returnFocusRef:y.returnFocusRef})]})}function IF({onNewChat:e,onDraft:t,onOpenNote:n}){return(0,R.jsxs)(uF,{children:[(0,R.jsx)(dF,{asChild:!0,children:(0,R.jsx)(UE,{label:`Create`,size:`sm`,icon:(0,R.jsx)(_b,{}),tooltipSide:`bottom`})}),(0,R.jsxs)(fF,{align:`end`,className:`w-72`,children:[(0,R.jsx)(LF,{icon:(0,R.jsx)(hb,{}),label:`New chat`,hint:`Features and quick changes alike — a conversation that cuts burn-ready tickets`,onSelect:e}),(0,R.jsx)(LF,{icon:(0,R.jsx)(gb,{}),label:`Draft an idea`,hint:`Write an idea down now, work it out later`,onSelect:t}),n&&(0,R.jsx)(LF,{icon:(0,R.jsx)(_b,{}),label:`Jot a note`,hint:`What you just noticed — triage it later`,kbd:mM(`J`),onSelect:n})]})]})}function LF({icon:e,label:t,hint:n,kbd:r,onSelect:i}){return(0,R.jsxs)(pF,{className:`items-start py-1.5 [&>svg]:mt-0.5`,icon:e,onSelect:i,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block`,children:t}),(0,R.jsx)(`span`,{className:`block text-xs text-pretty text-text-tertiary`,children:n})]}),r&&(0,R.jsx)(Px,{className:`mt-0.5`,children:r})]})}function RF({onOpen:e}){return(0,R.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search or jump to`,className:q(`flex h-(--control-h) w-full cursor-pointer items-center gap-2 rounded-md border border-border bg-surface-inset pr-1.5 pl-2.5`,`text-left text-sm text-text-tertiary transition-colors duration-(--dur-1) ease-app`,`hover:border-border-strong hover:text-text-secondary`),children:[(0,R.jsx)(eb,{size:14,className:`shrink-0 text-icon`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Search`}),(0,R.jsx)(Px,{children:pM()})]})}function zF(e){return e.status===`draft`?`draft`:e.phase}function BF(e){let t=Zh(e);if(t===`agentWorking`)return`live`;if(t===`needsYou`)return Gh(e)?.kind===`attention`?`danger`:`warning`}function VF(e){let t=Zh(e);return t===`agentWorking`?`agent working`:t===`needsYou`?Gh(e)?.label??`needs you`:null}function HF(e){let t=e.currentTarget.querySelector(`[aria-haspopup="menu"]`);t&&(e.preventDefault(),t.dispatchEvent(new PointerEvent(`pointerdown`,{bubbles:!0,cancelable:!0,button:0})))}var UF=[`w-32`,`w-24`,`w-36`,`w-28`];function WF(){return(0,R.jsxs)(Oj,{label:`Loading features…`,children:[(0,R.jsx)(`div`,{className:`flex h-7 items-center px-2.5`,children:(0,R.jsx)(kj,{className:`h-2.5 w-16`})}),(0,R.jsx)(`div`,{className:`flex flex-col gap-px`,children:UF.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex h-(--row-h) items-center gap-2 pr-3 pl-2.5`,"data-skeleton":`feature-row`,children:[(0,R.jsx)(kj,{className:`size-4 rounded-full`}),(0,R.jsx)(kj,{className:q(`h-2.5`,e)})]},t))})]})}function GF({f:e,active:t,onSelect:n,actions:r}){let i=zh(e)?Kh(e):null,a=i?.title??VF(e);return(0,R.jsx)(nj,{phase:zF(e),label:e.title,title:a?`${e.title} — ${a}`:e.title,dot:BF(e),meta:i?.text??(e.status===`shipped`?void 0:qh(e)??void 0),active:t,onClick:()=>n(e.id),actions:r.length>0?(0,R.jsx)(yF,{actions:r}):void 0,onContextMenu:r.length>0?HF:void 0})}function KF(){return typeof window>`u`?`this machine`:window.location.origin}var qF={connecting:{tone:`neutral`,word:`Connecting`},ok:{tone:`success`,word:`Server`},reconnecting:{tone:`warning`,word:`Reconnecting`},down:{tone:`danger`,word:`Server down`}},JF={on:`Notifications on — turn off`,off:`Notifications off — turn on`,blocked:`Notifications blocked by the browser`};function YF({health:e,origin:t,sandbox:n,notify:r,theme:i,onToggleTheme:a,onOpenSettings:o,rows:s}){let c=qF[e],l=e===`ok`?`Server ok — live updates streaming from ${t}/api`:e===`connecting`?`Connecting to the runcastle API at ${t}/api`:e===`reconnecting`?`Live updates paused — reconnecting, and polling meanwhile`:`The runcastle API at ${t}/api is not answering`,u=i===`dark`?`light`:`dark`;return(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-px pt-2`,children:[s,(0,R.jsxs)(`div`,{className:`flex h-8 items-center gap-3 pl-2.5 text-xs text-text-tertiary`,children:[(0,R.jsx)(jE,{label:l,children:(0,R.jsxs)(`span`,{tabIndex:0,className:`inline-flex items-center gap-1.5 rounded-sm whitespace-nowrap`,"data-health":e,children:[(0,R.jsx)(BA,{tone:c.tone}),c.word]})}),(0,R.jsx)(jE,{label:`Agent sessions run sandboxed via ${n}`,children:(0,R.jsxs)(`span`,{tabIndex:0,className:`inline-flex items-center gap-1.5 rounded-sm whitespace-nowrap`,children:[(0,R.jsx)(bb,{size:14,className:`text-icon`}),n]})}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsxs)(`span`,{className:`flex items-center`,children:[r&&(0,R.jsx)(UE,{size:`sm`,label:r.state===`blocked`?r.title:JF[r.state],icon:r.state===`on`?(0,R.jsx)(ib,{}):(0,R.jsx)(ab,{}),active:r.state===`on`,onClick:r.onToggle}),(0,R.jsx)(UE,{size:`sm`,label:`Switch to ${u} theme`,icon:i===`dark`?(0,R.jsx)(Ib,{}):(0,R.jsx)(Lb,{}),onClick:a}),o&&(0,R.jsx)(UE,{size:`sm`,label:`Settings`,icon:(0,R.jsx)(tb,{}),onClick:o})]})]})]})}function XF({projectId:e,nav:t,view:n,onSelect:r,onOpenSettings:i,onOpenPreparation:a,projectDriveBranch:o=null,onOpenProjectDrive:s,driving:c=null,onDriveChange:l,prepRow:u}){let d=gx(),f=B.useUtils(),p=Ch(),m=bh(),h=KM(),g=B.feature.list.useQuery({projectId:e},{refetchInterval:p}),_=!g.isError&&g.data!==void 0,v=DM(e,g.data??[]),y=vM(v),b=t.projects??[],x=B.useQueries(e=>b.map(t=>e.feature.list({projectId:t.id},{refetchInterval:p}))),S=lg(b.map((e,t)=>({projectId:e.id,...cg(x[t]?.data??[])})),t.currentProjectId),C=B.feature.testDrive.useMutation({onSuccess:()=>{l?.(null),c&&f.feature.get.invalidate({id:c.featureId}),f.feature.list.invalidate()},onError:e=>d.push(e.message)}),w=(0,R.jsxs)(R.Fragment,{children:[o!==null&&(0,R.jsx)(nj,{icon:(0,R.jsx)(wb,{}),label:`Project drive`,meta:(0,R.jsx)(`span`,{className:`font-mono`,children:o}),dot:`live`,onClick:s,title:`A project drive is live on ${o} — back to it`}),c&&(0,R.jsx)(nj,{icon:(0,R.jsx)(wb,{}),label:`Test drive`,meta:(0,R.jsx)(`span`,{className:`font-mono`,children:c.branch}),dot:`live`,onClick:()=>r(c.featureId),title:`Driving ${c.branch} — back to its feature`,actions:(0,R.jsx)(UE,{size:`sm`,label:`Stop the test drive`,icon:(0,R.jsx)(Tb,{}),disabled:C.isPending,onClick:()=>C.mutate({featureId:c.featureId,action:`stop`})})}),S>0&&(0,R.jsx)(nj,{icon:(0,R.jsx)(vb,{}),label:`${S} running elsewhere`,dot:`live`,onClick:t.goHome,title:`Runs in flight in other projects — open all projects`}),u?.variant===`done`&&(0,R.jsx)(nj,{icon:(0,R.jsx)(ub,{}),label:`Re-prepare project`,meta:u.badge??void 0,active:n===`prepare`,onClick:a,title:u.title})]});return(0,R.jsx)(YF,{health:g.isError?`down`:_?m===`live`?`ok`:m===`connecting`?`connecting`:`reconnecting`:`connecting`,origin:KF(),sandbox:_M,notify:v.supported?{...y,onToggle:v.toggle}:null,theme:h.resolved,onToggleTheme:h.toggle,onOpenSettings:i,rows:w})}function ZF({onOpenCmdk:e,onNewChat:t}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(UE,{label:`Search`,kbd:pM(),icon:(0,R.jsx)(eb,{}),tooltipSide:`right`,onClick:e}),(0,R.jsx)(UE,{label:`New chat`,icon:(0,R.jsx)(ob,{}),tooltipSide:`right`,onClick:t})]})}function QF(e){let[t,n]=(0,L.useState)([]),r=t.length?t[t.length-1].id:void 0,i=B.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:Ch()});return(0,L.useEffect)(()=>{let e=i.data;!e||e.length===0||n(t=>{let n=new Set(t.map(e=>e.id)),r=e.filter(e=>!n.has(e.id));return r.length===0?t:[...t,...r].sort((e,t)=>e.id-t.id)})},[i.data]),t}var $F=(0,L.createContext)(null);function eI({open:e,children:t}){return(0,R.jsx)($F.Provider,{value:e,children:t})}function tI(){return(0,L.useContext)($F)}function nI({location:e,children:t}){let n=(0,L.useContext)($F);return n?(0,R.jsx)(`button`,{type:`button`,className:JE,onClick:t=>{t.stopPropagation(),n(e)},children:t}):(0,R.jsx)(R.Fragment,{children:t})}function rI({text:e}){let t=(0,L.useContext)($F),n=eh(e);return!t||!n?(0,R.jsx)(R.Fragment,{children:e}):(0,R.jsxs)(R.Fragment,{children:[n.before,(0,R.jsx)(nI,{location:n.location,children:n.phrase}),n.after]})}function iI(e,t){let n=B.useUtils(),r=gx(),i=e=>r.push(e.message),a=()=>{n.feature.get.invalidate({id:e}),n.feature.list.invalidate(),n.events.invalidate()},o=B.feature.endSession.useMutation({onError:i}),s=Ex(e),c=B.feature.launchSession.useMutation({onSuccess:()=>{a(),s()},onError:i});return{pending:o.isPending||c.isPending,resolve:async(n,r)=>{if(r){try{await o.mutateAsync({sessionId:r})}catch{return}a()}c.mutate({featureId:e,kind:`chat`,kickoffLine:m_(n.base,t,n.files),purpose:`resolve-conflict`,purposeData:{mergeFrom:n.base,mergeInto:t}})}}}function aI(e){let[t,n]=(0,L.useState)(null),r=(0,L.useRef)(null),i=e?.id,a=e?.status;return(0,L.useEffect)(()=>{if(!i)return;if(a===`running`){r.current=i;return}if(a!==`succeeded`||r.current!==i)return;r.current=null,n(i);let e=setTimeout(()=>n(null),900);return()=>clearTimeout(e)},[i,a]),t===i?t:null}function oI(e,t,{live:n=!0}={}){let r=Ch(),i=B.docs.read.useQuery({featureId:e,relPath:t??``},{enabled:!!t,...n?{refetchInterval:r}:{}});return{content:t?i.data?.content:void 0,loading:!!t&&i.isLoading,failed:!!t&&!!i.error}}function sI(e,t){return e.find(e=>e.relPath.split(/[\\/]/).pop()===t)?.relPath}function cI({title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c}){return(0,R.jsx)(Hj,{open:!0,onClose:c,labelledBy:`merge-feature-title`,size:r.conflictRow&&s?`md`:`sm`,className:`flex max-h-[82vh] flex-col overflow-hidden`,children:(0,R.jsx)(uI,{title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c})})}function lI({warnings:e}){return e.length===0?null:(0,R.jsx)(`ul`,{"aria-label":`Warnings`,className:`m-0 flex list-none flex-col gap-2 p-0 text-sm text-text-secondary [&>li]:relative [&>li]:pl-6`,children:e.map(e=>(0,R.jsxs)(`li`,{children:[(0,R.jsx)(Vb,{size:16,className:`absolute top-0.5 left-0 text-warning`}),e]},e))})}function uI({title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c}){let l=!!r.conflictRow&&!!s;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{id:`merge-feature-title`,title:`Merge & ship`,onClose:c,description:(0,R.jsxs)(R.Fragment,{children:[`Merge `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:e}),` from`,` `,(0,R.jsx)(`code`,{className:`font-mono text-xs`,children:t}),n?(0,R.jsxs)(R.Fragment,{children:[` `,`into `,(0,R.jsx)(`code`,{className:`font-mono text-xs`,children:n})]}):null,`? This ships the feature.`]})}),(0,R.jsxs)(Wj,{className:`flex min-h-0 flex-col gap-5 overflow-y-auto`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsx)($A,{children:`What lands`}),r.conflictRow&&(0,R.jsx)(`p`,{className:`mt-1 mb-2 rounded-md bg-danger-subtle px-3 py-2 text-sm text-danger`,role:`alert`,children:r.conflictRow}),r.rows.map(e=>(0,R.jsx)(QA,{row:e},e.key))]}),(0,R.jsx)(lI,{warnings:r.warnings}),(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:r.next}),l&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:`Nothing here is disabled — if you resolved it by hand, retry lands it.`})]}),(0,R.jsxs)(Gj,{className:`border-t border-border-subtle pt-4`,children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:c,disabled:i,children:`Cancel`}),l?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{variant:`secondary`,icon:(0,R.jsx)(Gb,{}),onClick:o,disabled:i,children:i?`Merging…`:`Retry merge anyway`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Vb,{}),onClick:s,disabled:a,children:`Resolve the merge conflict`})]}):(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Nb,{}),onClick:o,disabled:i,children:i?`Merging…`:`Merge & ship`})]})]})}function dI({title:e,branch:t,summary:n,busy:r,warningsPending:i,onConfirm:a,onCancel:o}){return(0,R.jsx)(Hj,{open:!0,onClose:o,labelledBy:`burn-feature-title`,size:`sm`,className:`flex max-h-[82vh] flex-col overflow-hidden`,children:(0,R.jsx)(fI,{title:e,branch:t,summary:n,busy:r,warningsPending:i,onConfirm:a,onCancel:o})})}function fI({title:e,branch:t,summary:n,busy:r,warningsPending:i,onConfirm:a,onCancel:o}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{id:`burn-feature-title`,title:`Burn tickets`,onClose:o,description:(0,R.jsxs)(R.Fragment,{children:[`Burn `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:e}),` on`,` `,(0,R.jsx)(`code`,{className:`font-mono text-xs`,children:t}),`? Each ticket runs as its own sandboxed agent.`]})}),(0,R.jsxs)(Wj,{className:`flex min-h-0 flex-col gap-5 overflow-y-auto`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsx)($A,{children:`What burns`}),n.rows.map(e=>(0,R.jsx)(QA,{row:e},e.key))]}),(0,R.jsx)(lI,{warnings:n.warnings}),i&&(0,R.jsxs)(`p`,{className:`m-0 flex items-center gap-2 text-sm text-text-tertiary`,children:[(0,R.jsx)(KE,{size:`sm`}),`Still checking for warnings…`]}),(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:n.next})]}),(0,R.jsxs)(Gj,{className:`border-t border-border-subtle pt-4`,children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:o,disabled:r,children:`Cancel`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(xb,{}),onClick:a,disabled:r,children:r?`Burning…`:`Burn`})]})]})}function pI({url:e,onClose:t}){return(0,R.jsx)(Hj,{open:!!e,onClose:t,size:`xl`,label:`the note’s picture`,className:`overflow-hidden`,children:(0,R.jsxs)(`div`,{className:`relative flex flex-col p-2`,children:[(0,R.jsx)(`img`,{src:e??``,alt:`the picture attached to this note`,className:`block max-h-[80vh] w-full rounded-md bg-surface-inset object-contain`}),(0,R.jsx)(`span`,{className:`absolute top-4 right-4 rounded-md bg-surface-raised shadow-popover`,children:(0,R.jsx)(UE,{label:`Close`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:t})})]})})}var mI=`#F85149`;function hI(e,t,n=1){e.lineWidth=6*n,e.lineCap=`round`,e.lineJoin=`round`,e.strokeStyle=mI;for(let r of t){let[t,...i]=r.points;if(!t)continue;let a=r.points.at(-1)??t;if(e.beginPath(),r.tool===`rect`){let n={x:Math.min(t.x,a.x),y:Math.min(t.y,a.y),width:Math.abs(a.x-t.x),height:Math.abs(a.y-t.y)};e.rect(n.x,n.y,n.width,n.height)}else{e.moveTo(t.x,t.y),i.length===0&&e.lineTo(t.x,t.y);for(let t of i)e.lineTo(t.x,t.y);if(r.tool===`arrow`&&i.length>0){let r=Math.atan2(a.y-t.y,a.x-t.x),i=12*n;e.lineTo(a.x-i*Math.cos(r-Math.PI/6),a.y-i*Math.sin(r-Math.PI/6)),e.moveTo(a.x,a.y),e.lineTo(a.x-i*Math.cos(r+Math.PI/6),a.y-i*Math.sin(r+Math.PI/6))}}e.stroke()}}function gI(e,t){return e.videoTimestamp==null?`png-only`:t&&e.reviewTicketId===t.ticketId?`live-seek`:`orphan-label`}function _I(e,t,n=1){let r=e.filter(e=>e.reviewTicketId===t&&e.videoTimestamp!=null).sort((e,t)=>e.videoTimestamp-t.videoTimestamp),i=[];for(let e of r){let t=e.videoTimestamp,r=i.at(-1);r&&t-r.at<=n?r.noteIds.push(e.id):i.push({at:t,noteIds:[e.id]})}return i}function vI(e){if(Number.isFinite(e.duration)&&e.duration>0)return e.duration;let{seekable:t}=e;return t.length>0?t.end(t.length-1):0}function yI(e,t){return t.annotating||!Number.isFinite(e)||t.playable<=0?null:Math.min(Math.max(e,0),t.playable)}function bI(e,t,n){return e.width<=0||e.height<=0?{x:0,y:0}:{x:(n.x-e.left)/e.width*t.width,y:(n.y-e.top)/e.height*t.height}}async function xI(e,t,n,r=1){e.width=t.videoWidth,e.height=t.videoHeight;let i=e.getContext(`2d`);if(!i)throw Error(`this browser offered no 2d canvas to capture the frame with`);return i.drawImage(t,0,0,e.width,e.height),hI(i,n,r),await new Promise((t,n)=>{e.toBlob(e=>{e?t(e):n(Error(`the browser produced no PNG from the annotated frame`))},`image/png`)})}async function SI(e){let t=await e.createNote();try{return await e.uploadScreenshot(t.id),{note:t}}catch(e){return{note:t,uploadError:e instanceof Error?e.message:String(e)}}}function CI(e){return e.kind===`note`?e.note.id:e.finding.id}function wI(e){return e.kind===`note`?e.note.lap:e.finding.lap}function TI(e){return`work-${e}`}function EI({finding:e}){let{head:t,rest:n}=Ty(e.detail),r=e.location.trim();return(0,R.jsxs)(Rj,{size:`sm`,title:t,bodyClassName:`flex flex-col gap-1`,children:[n&&(0,R.jsx)(`p`,{className:`m-0 text-pretty`,children:n}),r&&(0,R.jsx)(`div`,{className:`font-mono text-xs text-text-tertiary`,children:r}),(0,R.jsx)(`div`,{className:`font-mono text-xs text-text-tertiary`,children:e.citation}),e.reproStep&&(0,R.jsx)(`div`,{className:`font-mono text-xs text-text-tertiary`,children:e.reproStep})]})}var DI={carried:`text-text-tertiary`,attested:`text-warning`,verified:`text-success`};function OI({item:e,onStage:t,readonly:n,controls:r,editor:i,highlighted:a=!1,showLap:o=!1,onSeek:s,onOpenImage:c,onViewLane:l}){let u=e.kind===`note`?e.note:void 0,d=e.kind===`defect`?e.finding:void 0,f=u?.status===`promoted`?`Promoted to ${e.kind===`note`&&e.ticket?`#${e.ticket.seq} ${e.ticket.title}`:`a ticket`}`:u?.status===`carried`?`carried into lap ${u.carriedLap}`:null,p=u?.text??d?.title??``,m=u?.videoTimestamp,h=gI({id:CI(e),videoTimestamp:u?.videoTimestamp??null,reviewTicketId:u?.reviewTicketId??null},t),g=d?hy(d):null,_=d?gy(d):null,v=e.kind===`defect`?e.fixTicket:void 0;return(0,R.jsxs)(`div`,{id:TI(CI(e)),"data-list-row":``,className:q(`group/row flex gap-3 rounded-md px-3 py-3 animate-rise-in`,`transition-colors duration-(--dur-2) ease-app`,a?`bg-accent-subtle`:`hover:bg-surface-hover`),children:[(0,R.jsx)(Qj,{url:u?.screenshotUrl,onOpen:c}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[i??(0,R.jsx)(`p`,{className:q(`m-0 text-sm text-pretty whitespace-pre-wrap`,u?.status===`done`?`text-text-tertiary line-through`:`text-text`),children:p}),(0,R.jsxs)(`div`,{className:`flex min-h-4 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-text-tertiary`,children:[d&&(0,R.jsx)(KA,{severity:d.severity}),u&&(0,R.jsx)(GA,{author:u.author}),o&&(0,R.jsxs)(`span`,{children:[`Lap `,wI(e)]}),m!==void 0&&(h===`live-seek`?(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer rounded-sm font-mono tabular-nums text-text-tertiary transition-colors duration-(--dur-1) hover:text-accent-text`,title:`jump the walkthrough to this moment`,onClick:()=>s?.(m),children:cf(m)}):(0,R.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[cf(m),` · earlier walkthrough`]})),g&&(0,R.jsx)(`span`,{className:`text-warning`,children:g}),f&&(0,R.jsx)(`span`,{children:f}),_&&(0,R.jsx)(`span`,{className:DI[_.evidence],children:_.text}),v&&(n||!l?(0,R.jsxs)(`span`,{className:`text-phase-implementation`,children:[`fixed in the burn by #`,v.seq]}):(0,R.jsxs)(`button`,{type:`button`,className:`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,onClick:()=>l(v.id),children:[`being fixed in the running burn · lane #`,v.seq]}))]}),_?.note&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-pretty text-text-secondary`,children:_.note}),d&&(0,R.jsx)(EI,{finding:d})]}),!n&&r&&(0,R.jsx)(`div`,{className:`-my-0.5 flex shrink-0 items-start gap-1`,children:r})]})}var kI={note:`Delete this note and its picture?`,defect:`Dismiss this defect?`};function AI(e){return e.readonly?null:(0,R.jsx)(Hj,{open:!0,onClose:e.onClose,size:`xl`,label:`Iterate — what goes where`,children:(0,R.jsx)(jI,{...e})})}function jI({lap:e,notes:t,defects:n,standing:r,openedAt:i,busy:a,sessionLive:o,onCommit:s,onClose:c}){let[l,u]=(0,L.useState)(new Set),[d,f]=(0,L.useState)(new Set),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=[...n.map(e=>({kind:`defect`,finding:e})),...t.map(e=>({kind:`note`,note:e}))].filter(e=>!d.has(CI(e))).map(e=>({lap:wI(e),item:e})),v=e=>u(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),y=e=>l.has(CI(e.item)),b=_.filter(y),x=_.filter(e=>e.item.kind===`note`&&!y(e)),S=e+1,C=l_({quickFix:b.length,carried:x.length,nextLap:S,live:!!o}),w=c_({quickFix:b.length,carried:x.length,nextLap:S,standing:r}),T=()=>{if(!p)return;let e=CI(p);f(t=>new Set(t).add(e)),u(t=>{let n=new Set(t);return n.delete(e),n}),m(null)},E=e=>s({quickFixIds:b.flatMap(e=>e.item.kind===`note`?[CI(e.item)]:[]),quickFixFindingIds:b.flatMap(e=>e.item.kind===`defect`?[CI(e.item)]:[]),dismissIds:t.filter(e=>d.has(e.id)).map(e=>e.id),dismissFindingIds:n.filter(e=>d.has(e.id)).map(e=>e.id),carry:e});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{title:`Iterate — what goes where`,description:`Tick the rows that are quick fixes — each becomes a ticket on this lap. Everything you leave goes into lap ${S}’s conversation together.`,onClose:c}),(0,R.jsx)(Wj,{className:`flex flex-col gap-3`,children:_.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(Ab,{}),title:`Nothing open to triage`,hint:`Lap ${S} starts empty-handed.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(sb,{}),disabled:a,onClick:()=>u(new Set(_.map(e=>CI(e.item)))),children:`Mark all as quick fixes`}),(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(cb,{}),disabled:a,onClick:()=>u(new Set),children:`Clear`}),(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-text-tertiary tabular-nums`,children:[b.length,` of `,_.length,` ticked`]})]}),(0,R.jsx)(`div`,{className:`-mx-2 flex max-h-[46vh] flex-col overflow-y-auto`,children:(0,R.jsx)(Xj,{groups:i_(_,e),currentLap:e,meta:e=>`${e.rows.length} open`,headClassName:`px-2`,children:e=>e.map(e=>(0,R.jsx)(OI,{item:e.item,onStage:null,readonly:!1,highlighted:MI(e.item,i),onOpenImage:g,controls:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Dj,{label:`Quick fix`,checked:y(e),disabled:a,onChange:()=>v(CI(e.item)),className:`h-(--control-sm) px-1.5`}),(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:a,onClick:()=>m(e.item),children:`Dismiss`})]})},CI(e.item)))})})]})}),(0,R.jsxs)(Gj,{start:w?(0,R.jsx)(`span`,{className:`text-text-secondary`,children:w}):void 0,children:[(0,R.jsx)(Y,{variant:`ghost`,disabled:a,onClick:c,children:`Cancel`}),C.map((e,t)=>(0,R.jsx)(Y,{variant:t===C.length-1?`primary`:`secondary`,disabled:a,onClick:()=>E(e.carry),children:e.label},e.label))]}),(0,R.jsx)(pI,{url:h,onClose:()=>g(null)}),(0,R.jsxs)(Hj,{open:!!p,onClose:()=>m(null),size:`sm`,label:p?kI[p.kind]:`Dismiss`,children:[(0,R.jsx)(Uj,{title:p?kI[p.kind]:``,description:`It leaves the list now and goes for good when you commit this step.`}),(0,R.jsxs)(Gj,{children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:()=>m(null),children:`Keep it`}),(0,R.jsx)(Y,{variant:`danger`,onClick:T,children:`Dismiss`})]})]})]})}function MI(e,t){return(e.kind===`note`?e.note.createdAt:e.finding.createdAt)>t}function NI(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var PI=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,FI=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,II={};function LI(e,t){return((t||II).jsx?FI:PI).test(e)}var dee=/[ \t\n\f\r]/g;function RI(e){return typeof e==`object`?e.type===`text`&&zI(e.value):zI(e)}function zI(e){return e.replace(dee,``)===``}var BI=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};BI.prototype.normal={},BI.prototype.property={},BI.prototype.space=void 0;function VI(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new BI(n,r,t)}function HI(e){return e.toLowerCase()}var UI=class{constructor(e,t){this.attribute=t,this.property=e}};UI.prototype.attribute=``,UI.prototype.booleanish=!1,UI.prototype.boolean=!1,UI.prototype.commaOrSpaceSeparated=!1,UI.prototype.commaSeparated=!1,UI.prototype.defined=!1,UI.prototype.mustUseProperty=!1,UI.prototype.number=!1,UI.prototype.overloadedBoolean=!1,UI.prototype.property=``,UI.prototype.spaceSeparated=!1,UI.prototype.space=void 0;var WI=s({boolean:()=>KI,booleanish:()=>qI,commaOrSpaceSeparated:()=>ZI,commaSeparated:()=>XI,number:()=>X,overloadedBoolean:()=>JI,spaceSeparated:()=>YI}),GI=0,KI=QI(),qI=QI(),JI=QI(),X=QI(),YI=QI(),XI=QI(),ZI=QI();function QI(){return 2**++GI}var $I=Object.keys(WI),eL=class extends UI{constructor(e,t,n,r){let i=-1;if(super(e,t),tL(this,`space`,r),typeof n==`number`)for(;++i<$I.length;){let e=$I[i];tL(this,$I[i],(n&WI[e])===WI[e])}}};eL.prototype.defined=!0;function tL(e,t,n){n&&(e[t]=n)}function nL(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new eL(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[HI(r)]=r,n[HI(a.attribute)]=r}return new BI(t,n,e.space)}var rL=nL({properties:{ariaActiveDescendant:null,ariaAtomic:qI,ariaAutoComplete:null,ariaBusy:qI,ariaChecked:qI,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:YI,ariaCurrent:null,ariaDescribedBy:YI,ariaDetails:null,ariaDisabled:qI,ariaDropEffect:YI,ariaErrorMessage:null,ariaExpanded:qI,ariaFlowTo:YI,ariaGrabbed:qI,ariaHasPopup:null,ariaHidden:qI,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:YI,ariaLevel:X,ariaLive:null,ariaModal:qI,ariaMultiLine:qI,ariaMultiSelectable:qI,ariaOrientation:null,ariaOwns:YI,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:qI,ariaReadOnly:qI,ariaRelevant:null,ariaRequired:qI,ariaRoleDescription:YI,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:qI,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function iL(e,t){return t in e?e[t]:t}function aL(e,t){return iL(e,t.toLowerCase())}var oL=nL({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:XI,acceptCharset:YI,accessKey:YI,action:null,allow:null,allowFullScreen:KI,allowPaymentRequest:KI,allowUserMedia:KI,alpha:KI,alt:null,as:null,async:KI,autoCapitalize:null,autoComplete:YI,autoFocus:KI,autoPlay:KI,blocking:YI,capture:null,charSet:null,checked:KI,cite:null,className:YI,closedBy:null,colorSpace:null,cols:X,colSpan:X,command:null,commandFor:null,content:null,contentEditable:qI,controls:KI,controlsList:YI,coords:X|XI,crossOrigin:null,data:null,dateTime:null,decoding:null,default:KI,defer:KI,dir:null,dirName:null,disabled:KI,download:JI,draggable:qI,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:KI,formTarget:null,headers:YI,height:X,hidden:JI,high:X,href:null,hrefLang:null,htmlFor:YI,httpEquiv:YI,id:null,imageSizes:null,imageSrcSet:null,inert:KI,inputMode:null,integrity:null,is:null,isMap:KI,itemId:null,itemProp:YI,itemRef:YI,itemScope:KI,itemType:YI,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:KI,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:KI,muted:KI,name:null,nonce:null,noModule:KI,noValidate:KI,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored: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,onScrollEnd: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:KI,optimum:X,pattern:null,ping:YI,placeholder:null,playsInline:KI,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:KI,referrerPolicy:null,rel:YI,required:KI,reversed:KI,rows:X,rowSpan:X,sandbox:YI,scope:null,scoped:KI,seamless:KI,selected:KI,shadowRootClonable:KI,shadowRootCustomElementRegistry:KI,shadowRootDelegatesFocus:KI,shadowRootMode:null,shadowRootSerializable:KI,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:qI,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:KI,useMap:null,value:qI,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:YI,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:KI,declare:KI,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:KI,noHref:KI,noShade:KI,noWrap:KI,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:qI,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:KI,disablePictureInPicture:KI,disableRemotePlayback:KI,exportParts:XI,part:YI,prefix:null,property:null,results:X,security:null,unselectable:null},space:`html`,transform:aL}),sL=nL({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,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`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,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`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,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`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:ZI,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:YI,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:KI,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:XI,g2:XI,glyphName:XI,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:ZI,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose: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,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:YI,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ZI,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ZI,rev:ZI,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ZI,requiredFeatures:ZI,requiredFonts:ZI,requiredFormats:ZI,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:ZI,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ZI,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ZI,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:iL}),cL=nL({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),lL=nL({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:aL}),uL=nL({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),dL={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},fL=/[A-Z]/g,pL=/-[a-z]/g,mL=/^data[-\w.:]+$/i;function hL(e,t){let n=HI(t),r=t,i=UI;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&mL.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(pL,_L);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!pL.test(e)){let n=e.replace(fL,gL);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=eL}return new i(r,t)}function gL(e){return`-`+e.toLowerCase()}function _L(e){return e.charAt(1).toUpperCase()}var vL=VI([rL,oL,cL,lL,uL],`html`),yL=VI([rL,sL,cL,lL,uL],`svg`);function bL(e){return e.join(` `).trim()}var xL=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
123
|
+
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(!(e.charAt(0)!=`/`||e.charAt(1)!=`*`)){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),SL=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(xL());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),CL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),wL=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(SL()),r=CL();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),TL=DL(`end`),EL=DL(`start`);function DL(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function OL(e){let t=EL(e),n=TL(e);if(t&&n)return{start:t,end:n}}function kL(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?jL(e.position):`start`in e||`end`in e?jL(e):`line`in e||`column`in e?AL(e):``}function AL(e){return ML(e&&e.line)+`:`+ML(e&&e.column)}function jL(e){return AL(e&&e.start)+`-`+AL(e&&e.end)}function ML(e){return e&&typeof e==`number`?e:1}var NL=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=kL(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};NL.prototype.file=``,NL.prototype.name=``,NL.prototype.reason=``,NL.prototype.message=``,NL.prototype.stack=``,NL.prototype.column=void 0,NL.prototype.line=void 0,NL.prototype.ancestors=void 0,NL.prototype.cause=void 0,NL.prototype.fatal=void 0,NL.prototype.place=void 0,NL.prototype.ruleId=void 0,NL.prototype.source=void 0;var PL=l(wL(),1),FL={}.hasOwnProperty,IL=new Map,LL=/[A-Z]/g,RL=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),zL=new Set([`td`,`th`]);function BL(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=ZL(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=XL(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?yL:vL,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=VL(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function VL(e,t,n){if(t.type===`element`)return HL(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return UL(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return GL(e,t,n);if(t.type===`mdxjsEsm`)return WL(e,t);if(t.type===`root`)return KL(e,t,n);if(t.type===`text`)return qL(e,t)}function HL(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=yL,e.schema=i),e.ancestors.push(t);let a=rR(e,t.tagName,!1),o=QL(e,t),s=eR(e,t);return RL.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!RI(e)})),JL(e,o,a,t),YL(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function UL(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}iR(e,t.position)}function WL(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);iR(e,t.position)}function GL(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=yL,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:rR(e,t.name,!0),o=$L(e,t),s=eR(e,t);return JL(e,o,a,t),YL(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function KL(e,t,n){let r={};return YL(r,eR(e,t)),e.create(t,e.Fragment,r,n)}function qL(e,t){return t.value}function JL(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function YL(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function XL(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function ZL(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=EL(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function QL(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&FL.call(t.properties,i)){let a=tR(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&zL.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function $L(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else iR(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else iR(e,t.position);else a=r.value===null||r.value;n[i]=a}return n}function eR(e,t){let n=[],r=-1,i=e.passKeys?new Map:IL;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=VL(e,a,o);s!==void 0&&n.push(s)}return n}function tR(e,t,n){let r=hL(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?NI(n):bL(n)),r.property===`style`){let t=typeof n==`object`?n:nR(e,String(n));return e.stylePropertyNameCase===`css`&&(t=aR(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?dL[r.property]||r.property:r.attribute,n]}}function nR(e,t){try{return(0,PL.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new NL("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function rR(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=LI(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=LI(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return FL.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);iR(e)}function iR(e,t){let n=new NL("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function aR(e){let t={},n;for(n in e)FL.call(e,n)&&(t[oR(n)]=e[n]);return t}function oR(e){let t=e.replace(LL,sR);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function sR(e){return`-`+e.toLowerCase()}var cR={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},lR={};function uR(e,t){let n=t||lR;return dR(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function dR(e,t,n){if(pR(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return fR(e.children,t,n)}return Array.isArray(e)?fR(e,t,n):``}function fR(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=dR(e[i],t,n);return r.join(``)}function pR(e){return!!(e&&typeof e==`object`)}var mR=document.createElement(`i`);function hR(e){let t=`&`+e+`;`;mR.innerHTML=t;let n=mR.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function gR(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function _R(e,t){return e.length>0?(gR(e,e.length,0,t),e):t}var vR={}.hasOwnProperty;function yR(e){let t={},n=-1;for(;++n<e.length;)bR(t,e[n]);return t}function bR(e,t){let n;for(n in t){let r=(vR.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){vR.call(r,a)||(r[a]=[]);let e=i[a];xR(r[a],Array.isArray(e)?e:e?[e]:[])}}}function xR(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);gR(e,0,0,r)}function SR(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function CR(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var wR=IR(/[A-Za-z]/),TR=IR(/[\dA-Za-z]/),ER=IR(/[#-'*+\--9=?A-Z^-~]/);function DR(e){return e!==null&&(e<32||e===127)}var OR=IR(/\d/),kR=IR(/[\dA-Fa-f]/),AR=IR(/[!-/:-@[-`{-~]/);function jR(e){return e!==null&&e<-2}function MR(e){return e!==null&&(e<0||e===32)}function NR(e){return e===-2||e===-1||e===32}var PR=IR(/\p{P}|\p{S}/u),FR=IR(/\s/);function IR(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function LR(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&TR(e.charCodeAt(n+1))&&TR(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function RR(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return NR(r)?(e.enter(n),s(r)):t(r)}function s(r){return NR(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var zR={tokenize:BR};function BR(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),RR(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return jR(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var VR={tokenize:UR},HR={tokenize:WR};function UR(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return gR(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(HR,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(HR,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return jR(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;gR(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function WR(e,t,n){return RR(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function GR(e){if(e===null||MR(e)||FR(e))return 1;if(PR(e))return 2}function KR(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var qR={name:`attention`,resolveAll:JR,tokenize:YR};function JR(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};XR(d,-c),XR(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=_R(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=_R(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=_R(l,KR(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=_R(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=_R(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,gR(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function YR(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=GR(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=GR(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function XR(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var ZR={name:`autolink`,tokenize:QR};function QR(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return wR(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||TR(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||TR(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||DR(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):ER(t)?(e.consume(t),l):n(t)}function u(e){return TR(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||TR(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var $R={partial:!0,tokenize:ez};function ez(e,t,n){return r;function r(t){return NR(t)?RR(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||jR(e)?t(e):n(e)}}var tz={continuation:{tokenize:rz},exit:iz,name:`blockQuote`,tokenize:nz};function nz(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return NR(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function rz(e,t,n){let r=this;return i;function i(t){return NR(t)?RR(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(tz,t,n)(r)}}function iz(e){e.exit(`blockQuote`)}var az={name:`characterEscape`,tokenize:oz};function oz(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return AR(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var sz={name:`characterReference`,tokenize:cz};function cz(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=TR,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=kR,u):(e.enter(`characterReferenceValue`),a=7,o=OR,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===TR&&!hR(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var lz={partial:!0,tokenize:fz},uz={concrete:!0,name:`codeFenced`,tokenize:dz};function dz(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),NR(t)?RR(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||jR(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(lz,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||jR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):NR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),RR(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||jR(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||jR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&NR(t)?RR(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||jR(t)?e.check(lz,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||jR(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),NR(t)?RR(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),NR(t)?RR(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||jR(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function fz(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var pz={name:`codeIndented`,tokenize:hz},mz={partial:!0,tokenize:gz};function hz(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),RR(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):jR(t)?e.attempt(mz,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||jR(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function gz(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):jR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):RR(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):jR(e)?i(e):n(e)}}var _z={name:`codeText`,previous:yz,resolve:vz,tokenize:bz};function vz(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function yz(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function bz(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):jR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||jR(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var xz=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Sz(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Sz(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Sz(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);Sz(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Sz(this.left,t.reverse())}}};function Sz(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Cz(e){let t={},n=-1,r,i,a,o,s,c,l,u=new xz(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,wz(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return gR(e,0,1/0,u.slice(0)),!l}function wz(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Tz={resolve:Dz,tokenize:Oz},Ez={partial:!0,tokenize:kz};function Dz(e){return Cz(e),e}function Oz(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):jR(t)?e.check(Ez,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function kz(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),RR(e,a,`linePrefix`)}function a(i){if(i===null||jR(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Az(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||DR(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||jR(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||MR(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||DR(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function jz(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):jR(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||jR(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!NR(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Mz(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):jR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),RR(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||jR(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Nz(e,t){let n;return r;function r(i){return jR(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):NR(i)?RR(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Pz={name:`definition`,tokenize:Iz},Fz={partial:!0,tokenize:Lz};function Iz(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return jz.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=CR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return MR(t)?Nz(e,l)(t):l(t)}function l(t){return Az(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Fz,d,d)(t)}function d(t){return NR(t)?RR(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||jR(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Lz(e,t,n){return r;function r(t){return MR(t)?Nz(e,i)(t):n(t)}function i(t){return Mz(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return NR(t)?RR(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||jR(e)?t(e):n(e)}}var Rz={name:`hardBreakEscape`,tokenize:zz};function zz(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return jR(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Bz={name:`headingAtx`,resolve:Vz,tokenize:Hz};function Vz(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},gR(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Hz(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||MR(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||jR(n)?(e.exit(`atxHeading`),t(n)):NR(n)?RR(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||MR(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Uz=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Wz=[`pre`,`script`,`style`,`textarea`],Gz={concrete:!0,name:`htmlFlow`,resolveTo:Jz,tokenize:Yz},Kz={partial:!0,tokenize:Zz},qz={partial:!0,tokenize:Xz};function Jz(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Yz(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:F):wR(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):wR(a)?(e.consume(a),i=4,r.interrupt?t:F):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:F):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return wR(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||MR(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Wz.includes(l)?(i=1,r.interrupt?t(s):O(s)):Uz.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||TR(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return NR(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||wR(t)?(e.consume(t),b):NR(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||TR(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):NR(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):NR(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||jR(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||MR(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||NR(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||jR(t)?O(t):NR(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),I):t===63&&i===3?(e.consume(t),F):t===93&&i===5?(e.consume(t),ee):jR(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Kz,te,k)(t)):t===null||jR(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(qz,A,te)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||jR(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),F):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Wz.includes(n)?(e.consume(t),I):O(t)}return wR(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function ee(t){return t===93?(e.consume(t),F):O(t)}function F(t){return t===62?(e.consume(t),I):t===45&&i===2?(e.consume(t),F):O(t)}function I(t){return t===null||jR(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),I)}function te(n){return e.exit(`htmlFlow`),t(n)}}function Xz(e,t,n){let r=this;return i;function i(t){return jR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Zz(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt($R,t,n)}}var Qz={name:`htmlText`,tokenize:$z};function $z(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):wR(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):wR(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):jR(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):jR(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):jR(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):jR(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return wR(t)?(e.consume(t),S):n(t)}function S(t){return t===45||TR(t)?(e.consume(t),S):C(t)}function C(t){return jR(t)?(o=C,N(t)):NR(t)?(e.consume(t),C):M(t)}function w(t){return t===45||TR(t)?(e.consume(t),w):t===47||t===62||MR(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||wR(t)?(e.consume(t),E):jR(t)?(o=T,N(t)):NR(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||TR(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):jR(t)?(o=D,N(t)):NR(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):jR(t)?(o=O,N(t)):NR(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):jR(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||MR(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||MR(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return NR(t)?RR(e,ee,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ee(t)}function ee(t){return e.enter(`htmlTextData`),o(t)}}var eB={name:`labelEnd`,resolveAll:iB,resolveTo:aB,tokenize:oB},tB={tokenize:sB},nB={tokenize:cB},rB={tokenize:lB};function iB(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&gR(e,0,e.length,n),e}function aB(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=_R(s,e.slice(a+1,a+r+3)),s=_R(s,[[`enter`,u,t]]),s=_R(s,KR(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=_R(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=_R(s,e.slice(o+1)),s=_R(s,[[`exit`,c,t]]),gR(e,a,e.length,s),e}function oB(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(CR(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(tB,u,o?u:d)(t):t===91?e.attempt(nB,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(rB,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function sB(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return MR(t)?Nz(e,a)(t):a(t)}function a(t){return t===41?u(t):Az(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return MR(t)?Nz(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Mz(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return MR(t)?Nz(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function cB(e,t,n){let r=this;return i;function i(t){return jz.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(CR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function lB(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var uB={name:`labelStartImage`,resolveAll:eB.resolveAll,tokenize:dB};function dB(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var fB={name:`labelStartLink`,resolveAll:eB.resolveAll,tokenize:pB};function pB(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var mB={name:`lineEnding`,tokenize:hB};function hB(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),RR(e,t,`linePrefix`)}}var gB={name:`thematicBreak`,tokenize:_B};function _B(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||jR(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),NR(t)?RR(e,s,`whitespace`)(t):s(t))}}var vB={continuation:{tokenize:SB},exit:wB,name:`list`,tokenize:xB},yB={partial:!0,tokenize:TB},bB={partial:!0,tokenize:CB};function xB(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:OR(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(gB,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return OR(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check($R,r.interrupt?n:u,e.attempt(yB,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return NR(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function SB(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check($R,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,RR(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!NR(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(bB,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,RR(e,e.attempt(vB,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function CB(e,t,n){let r=this;return RR(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function wB(e){e.exit(this.containerState.type)}function TB(e,t,n){let r=this;return RR(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!NR(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var EB={name:`setextUnderline`,resolveTo:DB,tokenize:OB};function DB(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function OB(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),NR(t)?RR(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||jR(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var kB={tokenize:AB};function AB(e){let t=this,n=e.attempt($R,r,e.attempt(this.parser.constructs.flowInitial,i,RR(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Tz,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var jB={resolveAll:FB()},MB=PB(`string`),NB=PB(`text`);function PB(e){return{resolveAll:FB(e===`text`?IB:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function FB(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function IB(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var LB=s({attentionMarkers:()=>GB,contentInitial:()=>zB,disable:()=>KB,document:()=>RB,flow:()=>VB,flowInitial:()=>BB,insideSpan:()=>WB,string:()=>HB,text:()=>UB}),RB={42:vB,43:vB,45:vB,48:vB,49:vB,50:vB,51:vB,52:vB,53:vB,54:vB,55:vB,56:vB,57:vB,62:tz},zB={91:Pz},BB={[-2]:pz,[-1]:pz,32:pz},VB={35:Bz,42:gB,45:[EB,gB],60:Gz,61:EB,95:gB,96:uz,126:uz},HB={38:sz,92:az},UB={[-5]:mB,[-4]:mB,[-3]:mB,33:uB,38:sz,42:qR,60:[ZR,Qz],91:fB,92:[Rz,az],93:eB,95:qR,96:_z},WB={null:[qR,jB]},GB={null:[42,95]},KB={null:[]};function qB(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=_R(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=KR(a,l.events,l),l.events):[]}function f(e,t){return YB(p(e),t)}function p(e){return JB(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){jR(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&gR(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function JB(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function YB(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
124
124
|
`;break;case-3:o=`\r
|
|
125
125
|
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function XB(e){let t={constructs:yR([LB,...(e||{}).extensions||[]]),content:n(zR),defined:[],document:n(VR),flow:n(kB),lazy:{},string:n(MB),text:n(NB)};return t;function n(e){return n;function n(n){return qB(t,e,n)}}}function ZB(e){for(;!Cz(e););return e}var QB=/[\0\t\n\r]/g;function $B(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(QB.lastIndex=u,c=QB.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var eV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tV(e){return e.replace(eV,nV)}function nV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return SR(n.slice(t?2:1),t?16:10)}return hR(n)||e}var rV={}.hasOwnProperty;function iV(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),aV(n)(ZB(XB(n).document().write($B()(e,t,!0))))}function aV(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ve),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(me),blockQuote:a(le),characterEscape:T,characterReference:T,codeFenced:a(ue),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ue,o),codeText:a(de,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(fe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(pe),hardBreakEscape:a(he),hardBreakTrailing:a(he),htmlFlow:a(ge,o),htmlFlowData:T,htmlText:a(ge,o),htmlTextData:T,image:a(_e),label:o,link:a(ve),listItem:a(be),listItemValue:f,listOrdered:a(ye,d),listUnordered:a(ye),paragraph:a(xe),reference:ne,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(me),strong:a(Se),thematicBreak:a(we)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ce,autolinkProtocol:se,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:ae,characterReference:oe,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:ee,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:re,resourceDestinationString:F,resourceTitleString:I,resource:te,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};sV(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];rV.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||lV).call(a,void 0,e[0])}for(r.position={start:oV(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:oV(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:oV(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||lV).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+kL({start:e.start,end:e.end})+`): it’s not open`);n.position.end=oV(e.end)}function u(){return uR(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=CR(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ce(),n.position={start:oV(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=oV(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=oV(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=tV(t),n.identifier=CR(t).toLowerCase()}function ee(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function te(){this.data.inReference=void 0}function ne(){this.data.referenceType=`collapsed`}function re(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=CR(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ie(e){this.data.characterReferenceType=e.type}function ae(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=SR(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=hR(t);let i=this.stack[this.stack.length-1];i.value+=r}function oe(e){let t=this.stack.pop();t.position.end=oV(e.end)}function se(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ce(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function le(){return{type:`blockquote`,children:[]}}function ue(){return{type:`code`,lang:null,meta:null,value:``}}function de(){return{type:`inlineCode`,value:``}}function fe(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function pe(){return{type:`emphasis`,children:[]}}function me(){return{type:`heading`,depth:0,children:[]}}function he(){return{type:`break`}}function ge(){return{type:`html`,value:``}}function _e(){return{type:`image`,title:null,url:``,alt:null}}function ve(){return{type:`link`,title:null,url:``,children:[]}}function ye(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function be(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function xe(){return{type:`paragraph`,children:[]}}function Se(){return{type:`strong`,children:[]}}function Ce(){return{type:`text`,value:``}}function we(){return{type:`thematicBreak`}}}function oV(e){return{line:e.line,column:e.column,offset:e.offset}}function sV(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?sV(e,r):cV(e,r)}}function cV(e,t){let n;for(n in t)if(rV.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function lV(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+kL({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+kL({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+kL({start:t.start,end:t.end})+`) is still open`)}function uV(e){let t=this;t.parser=n;function n(n){return iV(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function dV(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function fV(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
126
126
|
`}]}function pV(e,t){let n=t.value?t.value+`
|
|
@@ -176,13 +176,13 @@ ${s.join(`
|
|
|
176
176
|
`).slice(2).join(`
|
|
177
177
|
`))}},OX=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},kX=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},AX=0,jX=class{constructor(e){this.value=e,this.id=AX++}},MX=2,NX,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=wX>0||this._options?.leakWarningThreshold?new EX(e?.onListenerError??RY,this._options?.leakWarningThreshold??wX):void 0,this._perfMon=this._options?._profName?new CX(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new kX(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||RY)(n),pX.None}if(this._disposed)return pX.None;t&&(e=e.bind(t));let r=new jX(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=DX.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof jX?(this._deliveryQueue??=new PX,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=uX(()=>{NX?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof fX?n.add(a):Array.isArray(n)&&n.push(a),NX){let e=Error().stack.split(`
|
|
178
178
|
`).slice(2,3).join(`
|
|
179
|
-
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);NX.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*MX<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||RY;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof jX)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},PX=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},FX=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};FX.INSTANCE=new FX;var IX=FX;function LX(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}IX.INSTANCE.onDidChangeZoomLevel;function RX(e){return IX.INSTANCE.getZoomFactor(e)}IX.INSTANCE.onDidChangeFullscreen;var zX=typeof navigator==`object`?navigator.userAgent:``,BX=zX.indexOf(`Firefox`)>=0,VX=zX.indexOf(`AppleWebKit`)>=0,HX=zX.indexOf(`Chrome`)>=0,UX=!HX&&zX.indexOf(`Safari`)>=0;zX.indexOf(`Electron/`),zX.indexOf(`Android`);var WX=!1;if(typeof hX.matchMedia==`function`){let e=hX.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=hX.matchMedia(`(display-mode: fullscreen)`);WX=e.matches,LX(hX,e,({matches:e})=>{WX&&t.matches||(WX=e)})}function GX(){return WX}var KX=`en`,qX=!1,JX=!1,YX=!1,XX=!1,ZX=!1,QX=KX,$X,eZ=globalThis,tZ;typeof eZ.vscode<`u`&&typeof eZ.vscode.process<`u`?tZ=eZ.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(tZ=process);var nZ=typeof tZ?.versions?.electron==`string`&&tZ?.type===`renderer`;if(typeof tZ==`object`){qX=tZ.platform===`win32`,JX=tZ.platform===`darwin`,YX=tZ.platform===`linux`,YX&&tZ.env.SNAP&&tZ.env.SNAP_REVISION,tZ.env.CI||tZ.env.BUILD_ARTIFACTSTAGINGDIRECTORY,QX=KX;let e=tZ.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,QX=t.resolvedLanguage||KX,t.languagePack?.translationsConfigFile}catch{}XX=!0}else typeof navigator==`object`&&!nZ?($X=navigator.userAgent,qX=$X.indexOf(`Windows`)>=0,JX=$X.indexOf(`Macintosh`)>=0,($X.indexOf(`Macintosh`)>=0||$X.indexOf(`iPad`)>=0||$X.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,YX=$X.indexOf(`Linux`)>=0,$X?.indexOf(`Mobi`),ZX=!0,QX=globalThis._VSCODE_NLS_LANGUAGE||KX,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var rZ=qX,iZ=JX,aZ=YX,oZ=XX;ZX&&typeof eZ.importScripts==`function`&&eZ.origin;var sZ=$X,cZ=QX,lZ;(e=>{function t(){return cZ}e.value=t;function n(){return cZ.length===2?cZ===`en`:cZ.length>=3&&cZ[0]===`e`&&cZ[1]===`n`&&cZ[2]===`-`}e.isDefaultVariant=n;function r(){return cZ===`en`}e.isDefault=r})(lZ||={});var uZ=typeof eZ.postMessage==`function`&&!eZ.importScripts;(()=>{if(uZ){let e=[];eZ.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),eZ.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var dZ=!!(sZ&&sZ.indexOf(`Chrome`)>=0);sZ&&sZ.indexOf(`Firefox`),!dZ&&sZ&&sZ.indexOf(`Safari`),sZ&&sZ.indexOf(`Edg/`),sZ&&sZ.indexOf(`Android`);var fZ=typeof navigator==`object`?navigator:{};oZ||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||fZ&&fZ.clipboard&&fZ.clipboard.writeText,oZ||fZ&&fZ.clipboard&&fZ.clipboard.readText,oZ||GX()||fZ.keyboard,`ontouchstart`in hX||fZ.maxTouchPoints,hX.PointerEvent&&(`ontouchstart`in hX||navigator.maxTouchPoints);var pZ=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},mZ=new pZ,hZ=new pZ,gZ=new pZ,_Z=Array(230),vZ;(e=>{function t(e){return mZ.keyCodeToStr(e)}e.toString=t;function n(e){return mZ.strToKeyCode(e)}e.fromString=n;function r(e){return hZ.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return gZ.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return hZ.strToKeyCode(e)||gZ.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return mZ.keyCodeToStr(e)}e.toElectronAccelerator=o})(vZ||={});var yZ=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new bZ([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},bZ=class{constructor(e){if(e.length===0)throw HY(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function xZ(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return vZ.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(BX)switch(t){case 59:return 85;case 60:if(aZ)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(iZ)return 57;break}else if(VX&&(iZ&&t===93||!iZ&&t===92))return 57;return _Z[t]||0}var SZ=iZ?256:2048,CZ=512,wZ=1024,TZ=iZ?2048:256,EZ=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=xZ(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=SZ),this.altKey&&(t|=CZ),this.shiftKey&&(t|=wZ),this.metaKey&&(t|=TZ),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new yZ(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},DZ=new WeakMap;function OZ(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var kZ=class{static getSameOriginWindowChain(e){let t=DZ.get(e);if(!t){t=[],DZ.set(e,t);let n=e,r;do r=OZ(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},AZ=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=kZ.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},jZ=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(HX){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)r?this.deltaY=t.wheelDeltaY/(120*i):this.deltaY=t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?BX&&!iZ?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)UX&&rZ?this.deltaX=-(t.wheelDeltaX/120):r?this.deltaX=t.wheelDeltaX/(120*i):this.deltaX=t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?BX&&!iZ?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},MZ=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),NZ;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof PZ?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:xX.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:MZ})})(NZ||={});var PZ=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?MZ:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},FZ=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new WY(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new WY(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},IZ=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new WY(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=uX(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var LZ;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(LZ||={});var RZ=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Q,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await xX.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};RZ.EMPTY=RZ.fromArray([]);function zZ(e){return 55296<=e&&e<=56319}function BZ(e){return 56320<=e&&e<=57343}function VZ(e,t){return(e-55296<<10)+(t-56320)+65536}function HZ(e){return UZ(e,0)}function UZ(e,t){switch(typeof e){case`object`:return e===null?WZ(349,t):Array.isArray(e)?qZ(e,t):JZ(e,t);case`string`:return KZ(e,t);case`boolean`:return GZ(e,t);case`number`:return WZ(e,t);case`undefined`:return WZ(937,t);default:return WZ(617,t)}}function WZ(e,t){return(t<<5)-t+e|0}function GZ(e,t){return WZ(e?433:863,t)}function KZ(e,t){t=WZ(149417,t);for(let n=0,r=e.length;n<r;n++)t=WZ(e.charCodeAt(n),t);return t}function qZ(e,t){return t=WZ(104579,t),e.reduce((e,t)=>UZ(t,e),t)}function JZ(e,t){return t=WZ(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=KZ(n,t),UZ(e[n],t)),t)}function YZ(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function XZ(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function ZZ(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function QZ(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):ZZ((e>>>0).toString(16),t/4)}var $Z=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(zZ(a))if(o+1<t){let t=e.charCodeAt(o+1);BZ(t)?(o++,s=VZ(a,t)):s=65533}else{i=a;break}else BZ(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),QZ(this._h0)+QZ(this._h1)+QZ(this._h2)+QZ(this._h3)+QZ(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,XZ(this._buff,this._buffLen),this._buffLen>56&&(this._step(),XZ(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,YZ(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=YZ(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=YZ(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};$Z._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:pee,getWindow:eQ,getDocument:mee,getWindows:hee,getWindowsCount:gee,getWindowId:tQ,getWindowById:_ee,hasWindow:vee,onDidRegisterWindow:nQ,onWillUnregisterWindow:yee,onDidUnregisterWindow:bee}=function(){let e=new Map,t={window:hX,disposables:new fX};e.set(hX.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return pX.None;let a=new fX,o={window:t,disposables:a.add(new fX)};return e.set(t.vscodeWindowId,o),a.add(uX(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(rQ(t,fQ.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:hX},getDocument(e){return eQ(e).document}}}(),xee=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function rQ(e,t,n,r){return new xee(e,t,n,r)}function iQ(e,t){return function(n){return t(new AZ(e,n))}}function aQ(e){return function(t){return e(new EZ(t))}}var oQ=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=iQ(eQ(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=aQ(n)),rQ(e,t,i,r)},sQ,cQ=class extends IZ{constructor(e){super(),this.defaultTarget=e&&eQ(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},lQ=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){RY(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(lQ.sort),a.shift().execute();r.set(i,!1)};sQ=(t,r,a=0)=>{let o=tQ(t),s=new lQ(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var uQ=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};uQ.None=new uQ(0,0);function dQ(e){let t=e.getBoundingClientRect(),n=eQ(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=HZ(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(uX(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var fQ={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:VX?`webkitAnimationStart`:`animationstart`,ANIMATION_END:VX?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:VX?`webkitAnimationIteration`:`animationiteration`},pQ=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function mQ(e,t,n,...r){let i=pQ.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function hQ(e,t,...n){return mQ(`http://www.w3.org/1999/xhtml`,e,t,...n)}hQ.SVG=function(e,t,...n){return mQ(`http://www.w3.org/2000/svg`,e,t,...n)};var gQ=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=_Q(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=_Q(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=_Q(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=_Q(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=_Q(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=_Q(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=_Q(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=_Q(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=_Q(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=_Q(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=_Q(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=_Q(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=_Q(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=_Q(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function _Q(e){return typeof e==`number`?`${e}px`:e}function vQ(e){return new gQ(e)}var yQ=class{constructor(){this._hooks=new fX,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(uX(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=eQ(e)}this._hooks.add(rQ(a,fQ.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(rQ(a,fQ.POINTER_UP,e=>this.stopMonitoring(!0)))}};function bQ(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var xQ;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(xQ||={});var SQ=class e extends pX{constructor(){super(),this.dispatched=!1,this.targets=new vX,this.ignoreTargets=new vX,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(xX.runAndSubscribe(nQ,({window:e,disposables:t})=>{t.add(rQ(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(rQ(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(rQ(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:hX,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=sX(new e),uX(e.INSTANCE.targets.push(t))):pX.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=sX(new e),uX(e.INSTANCE.ignoreTargets.push(t))):pX.None}static isTouchDevice(){return`ontouchstart`in hX||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(xQ.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-qY(s.rollingPageX))<30&&Math.abs(s.initialPageY-qY(s.rollingPageY))<30){let e=this.newGestureEvent(xQ.Tap,s.initialTarget);e.pageX=qY(s.rollingPageX),e.pageY=qY(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-qY(s.rollingPageX))<30&&Math.abs(s.initialPageY-qY(s.rollingPageY))<30){let e=this.newGestureEvent(xQ.Contextmenu,s.initialTarget);e.pageX=qY(s.rollingPageX),e.pageY=qY(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=qY(s.rollingPageX),n=qY(s.rollingPageY),i=qY(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(xQ.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===xQ.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===xQ.Change||t.type===xQ.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=sQ(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(xQ.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(xQ.Change,i.initialTarget);a.translationX=r.pageX-qY(i.rollingPageX),a.translationY=r.pageY-qY(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};SQ.SCROLL_FRICTION=-.005,SQ.HOLD_DELAY=700,SQ.CLEAR_TAP_COUNT_TIME=400,WJ([bQ],SQ,`isTouchDevice`,1);var CQ=SQ,wQ=class extends pX{onclick(e,t){this._register(rQ(e,fQ.CLICK,n=>t(new AZ(eQ(e),n))))}onmousedown(e,t){this._register(rQ(e,fQ.MOUSE_DOWN,n=>t(new AZ(eQ(e),n))))}onmouseover(e,t){this._register(rQ(e,fQ.MOUSE_OVER,n=>t(new AZ(eQ(e),n))))}onmouseleave(e,t){this._register(rQ(e,fQ.MOUSE_LEAVE,n=>t(new AZ(eQ(e),n))))}onkeydown(e,t){this._register(rQ(e,fQ.KEY_DOWN,e=>t(new EZ(e))))}onkeyup(e,t){this._register(rQ(e,fQ.KEY_UP,e=>t(new EZ(e))))}oninput(e,t){this._register(rQ(e,fQ.INPUT,t))}onblur(e,t){this._register(rQ(e,fQ.BLUR,t))}onfocus(e,t){this._register(rQ(e,fQ.FOCUS,t))}onchange(e,t){this._register(rQ(e,fQ.CHANGE,t))}ignoreGesture(e){return CQ.ignoreTarget(e)}},TQ=11,EQ=class extends wQ{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=TQ+`px`,this.domNode.style.height=TQ+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new yQ),this._register(oQ(this.bgDomNode,fQ.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(oQ(this.domNode,fQ.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new cQ),this._pointerdownScheduleRepeatTimer=this._register(new FZ)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,eQ(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},DQ=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},OQ=class extends pX{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new DQ(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new MQ(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=MQ.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},kQ=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function AQ(e,t){let n=t-e;return function(t){return e+n*PQ(t)}}function jQ(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var MQ=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),jQ(AQ(e,r),AQ(i,t),.33)}return AQ(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new kQ(this.scrollLeft(t),this.scrollTop(t),!1):new kQ(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function NQ(e){return e**3}function PQ(e){return 1-NQ(1-e)}var FQ=class extends pX{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new FZ)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},IQ=140,LQ=class extends wQ{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new FQ(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new yQ),this._shouldRender=!0,this.domNode=vQ(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(rQ(this.domNode.domNode,fQ.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new EQ(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=vQ(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(rQ(this.slider.domNode,fQ.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=dQ(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(rZ&&a>IQ){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},RQ=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize===t?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},zQ=class extends LQ{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new RQ(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},BQ=class extends LQ{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new RQ(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},VQ=500,HQ=50,UQ=!0,WQ=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},GQ=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(HX){let t=RX(eQ(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new WQ(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};GQ.INSTANCE=new GQ;var KQ=GQ,qQ=class extends wQ{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=YQ(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new BQ(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new zQ(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=vQ(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=vQ(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=vQ(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new FZ),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=cX(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,iZ&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new jZ(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=cX(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(rQ(this._listenOnDomNode,fQ.MOUSE_WHEEL,e=>{this._onMouseWheel(new jZ(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=KQ.INSTANCE;UQ&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!iZ&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=HQ*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=HQ*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(UQ&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),VQ)}},JQ=class extends qQ{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function YQ(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,iZ&&(t.className+=` mac`),t}var XQ=class extends pX{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new OQ({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>sQ(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new JQ(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(xX.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(uX(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(uX(()=>this._styleElement.remove())),this._register(xX.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
179
|
+
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);NX.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*MX<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||RY;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof jX)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},PX=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},FX=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};FX.INSTANCE=new FX;var IX=FX;function LX(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}IX.INSTANCE.onDidChangeZoomLevel;function RX(e){return IX.INSTANCE.getZoomFactor(e)}IX.INSTANCE.onDidChangeFullscreen;var zX=typeof navigator==`object`?navigator.userAgent:``,BX=zX.indexOf(`Firefox`)>=0,VX=zX.indexOf(`AppleWebKit`)>=0,HX=zX.indexOf(`Chrome`)>=0,UX=!HX&&zX.indexOf(`Safari`)>=0;zX.indexOf(`Electron/`),zX.indexOf(`Android`);var WX=!1;if(typeof hX.matchMedia==`function`){let e=hX.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=hX.matchMedia(`(display-mode: fullscreen)`);WX=e.matches,LX(hX,e,({matches:e})=>{WX&&t.matches||(WX=e)})}function GX(){return WX}var KX=`en`,qX=!1,JX=!1,YX=!1,XX=!1,ZX=!1,QX=KX,$X,eZ=globalThis,tZ;typeof eZ.vscode<`u`&&typeof eZ.vscode.process<`u`?tZ=eZ.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(tZ=process);var nZ=typeof tZ?.versions?.electron==`string`&&tZ?.type===`renderer`;if(typeof tZ==`object`){qX=tZ.platform===`win32`,JX=tZ.platform===`darwin`,YX=tZ.platform===`linux`,YX&&tZ.env.SNAP&&tZ.env.SNAP_REVISION,tZ.env.CI||tZ.env.BUILD_ARTIFACTSTAGINGDIRECTORY,QX=KX;let e=tZ.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,QX=t.resolvedLanguage||KX,t.languagePack?.translationsConfigFile}catch{}XX=!0}else typeof navigator==`object`&&!nZ?($X=navigator.userAgent,qX=$X.indexOf(`Windows`)>=0,JX=$X.indexOf(`Macintosh`)>=0,($X.indexOf(`Macintosh`)>=0||$X.indexOf(`iPad`)>=0||$X.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,YX=$X.indexOf(`Linux`)>=0,$X?.indexOf(`Mobi`),ZX=!0,QX=globalThis._VSCODE_NLS_LANGUAGE||KX,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var rZ=qX,iZ=JX,aZ=YX,oZ=XX;ZX&&typeof eZ.importScripts==`function`&&eZ.origin;var sZ=$X,cZ=QX,lZ;(e=>{function t(){return cZ}e.value=t;function n(){return cZ.length===2?cZ===`en`:cZ.length>=3&&cZ[0]===`e`&&cZ[1]===`n`&&cZ[2]===`-`}e.isDefaultVariant=n;function r(){return cZ===`en`}e.isDefault=r})(lZ||={});var uZ=typeof eZ.postMessage==`function`&&!eZ.importScripts;(()=>{if(uZ){let e=[];eZ.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),eZ.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var dZ=!!(sZ&&sZ.indexOf(`Chrome`)>=0);sZ&&sZ.indexOf(`Firefox`),!dZ&&sZ&&sZ.indexOf(`Safari`),sZ&&sZ.indexOf(`Edg/`),sZ&&sZ.indexOf(`Android`);var fZ=typeof navigator==`object`?navigator:{};oZ||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||fZ&&fZ.clipboard&&fZ.clipboard.writeText,oZ||fZ&&fZ.clipboard&&fZ.clipboard.readText,oZ||GX()||fZ.keyboard,`ontouchstart`in hX||fZ.maxTouchPoints,hX.PointerEvent&&(`ontouchstart`in hX||navigator.maxTouchPoints);var pZ=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},mZ=new pZ,hZ=new pZ,gZ=new pZ,_Z=Array(230),vZ;(e=>{function t(e){return mZ.keyCodeToStr(e)}e.toString=t;function n(e){return mZ.strToKeyCode(e)}e.fromString=n;function r(e){return hZ.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return gZ.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return hZ.strToKeyCode(e)||gZ.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return mZ.keyCodeToStr(e)}e.toElectronAccelerator=o})(vZ||={});var yZ=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new bZ([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},bZ=class{constructor(e){if(e.length===0)throw HY(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function xZ(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return vZ.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(BX)switch(t){case 59:return 85;case 60:if(aZ)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(iZ)return 57;break}else if(VX&&(iZ&&t===93||!iZ&&t===92))return 57;return _Z[t]||0}var SZ=iZ?256:2048,CZ=512,wZ=1024,TZ=iZ?2048:256,EZ=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=xZ(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=SZ),this.altKey&&(t|=CZ),this.shiftKey&&(t|=wZ),this.metaKey&&(t|=TZ),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new yZ(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},DZ=new WeakMap;function OZ(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var kZ=class{static getSameOriginWindowChain(e){let t=DZ.get(e);if(!t){t=[],DZ.set(e,t);let n=e,r;do r=OZ(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},AZ=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=kZ.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},jZ=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(HX){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)r?this.deltaY=t.wheelDeltaY/(120*i):this.deltaY=t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?BX&&!iZ?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)UX&&rZ?this.deltaX=-(t.wheelDeltaX/120):r?this.deltaX=t.wheelDeltaX/(120*i):this.deltaX=t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?BX&&!iZ?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},MZ=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),NZ;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof PZ?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:xX.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:MZ})})(NZ||={});var PZ=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?MZ:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},FZ=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new WY(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new WY(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},IZ=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new WY(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=uX(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var LZ;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(LZ||={});var RZ=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Q,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await xX.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};RZ.EMPTY=RZ.fromArray([]);function zZ(e){return 55296<=e&&e<=56319}function BZ(e){return 56320<=e&&e<=57343}function VZ(e,t){return(e-55296<<10)+(t-56320)+65536}function HZ(e){return UZ(e,0)}function UZ(e,t){switch(typeof e){case`object`:return e===null?WZ(349,t):Array.isArray(e)?qZ(e,t):JZ(e,t);case`string`:return KZ(e,t);case`boolean`:return GZ(e,t);case`number`:return WZ(e,t);case`undefined`:return WZ(937,t);default:return WZ(617,t)}}function WZ(e,t){return(t<<5)-t+e|0}function GZ(e,t){return WZ(e?433:863,t)}function KZ(e,t){t=WZ(149417,t);for(let n=0,r=e.length;n<r;n++)t=WZ(e.charCodeAt(n),t);return t}function qZ(e,t){return t=WZ(104579,t),e.reduce((e,t)=>UZ(t,e),t)}function JZ(e,t){return t=WZ(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=KZ(n,t),UZ(e[n],t)),t)}function YZ(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function XZ(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function ZZ(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function QZ(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):ZZ((e>>>0).toString(16),t/4)}var $Z=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(zZ(a))if(o+1<t){let t=e.charCodeAt(o+1);BZ(t)?(o++,s=VZ(a,t)):s=65533}else{i=a;break}else BZ(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),QZ(this._h0)+QZ(this._h1)+QZ(this._h2)+QZ(this._h3)+QZ(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,XZ(this._buff,this._buffLen),this._buffLen>56&&(this._step(),XZ(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,YZ(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=YZ(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=YZ(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};$Z._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:pee,getWindow:eQ,getDocument:mee,getWindows:hee,getWindowsCount:gee,getWindowId:tQ,getWindowById:_ee,hasWindow:vee,onDidRegisterWindow:nQ,onWillUnregisterWindow:yee,onDidUnregisterWindow:bee}=function(){let e=new Map,t={window:hX,disposables:new fX};e.set(hX.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return pX.None;let a=new fX,o={window:t,disposables:a.add(new fX)};return e.set(t.vscodeWindowId,o),a.add(uX(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(iQ(t,fQ.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:hX},getDocument(e){return eQ(e).document}}}(),rQ=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function iQ(e,t,n,r){return new rQ(e,t,n,r)}function xee(e,t){return function(n){return t(new AZ(e,n))}}function aQ(e){return function(t){return e(new EZ(t))}}var oQ=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=xee(eQ(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=aQ(n)),iQ(e,t,i,r)},sQ,cQ=class extends IZ{constructor(e){super(),this.defaultTarget=e&&eQ(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},lQ=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){RY(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(lQ.sort),a.shift().execute();r.set(i,!1)};sQ=(t,r,a=0)=>{let o=tQ(t),s=new lQ(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var uQ=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};uQ.None=new uQ(0,0);function dQ(e){let t=e.getBoundingClientRect(),n=eQ(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=HZ(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(uX(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var fQ={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:VX?`webkitAnimationStart`:`animationstart`,ANIMATION_END:VX?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:VX?`webkitAnimationIteration`:`animationiteration`},pQ=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function mQ(e,t,n,...r){let i=pQ.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function hQ(e,t,...n){return mQ(`http://www.w3.org/1999/xhtml`,e,t,...n)}hQ.SVG=function(e,t,...n){return mQ(`http://www.w3.org/2000/svg`,e,t,...n)};var gQ=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=_Q(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=_Q(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=_Q(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=_Q(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=_Q(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=_Q(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=_Q(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=_Q(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=_Q(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=_Q(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=_Q(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=_Q(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=_Q(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=_Q(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function _Q(e){return typeof e==`number`?`${e}px`:e}function vQ(e){return new gQ(e)}var yQ=class{constructor(){this._hooks=new fX,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(uX(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=eQ(e)}this._hooks.add(iQ(a,fQ.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(iQ(a,fQ.POINTER_UP,e=>this.stopMonitoring(!0)))}};function bQ(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var xQ;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(xQ||={});var SQ=class e extends pX{constructor(){super(),this.dispatched=!1,this.targets=new vX,this.ignoreTargets=new vX,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(xX.runAndSubscribe(nQ,({window:e,disposables:t})=>{t.add(iQ(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(iQ(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(iQ(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:hX,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=sX(new e),uX(e.INSTANCE.targets.push(t))):pX.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=sX(new e),uX(e.INSTANCE.ignoreTargets.push(t))):pX.None}static isTouchDevice(){return`ontouchstart`in hX||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(xQ.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-qY(s.rollingPageX))<30&&Math.abs(s.initialPageY-qY(s.rollingPageY))<30){let e=this.newGestureEvent(xQ.Tap,s.initialTarget);e.pageX=qY(s.rollingPageX),e.pageY=qY(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-qY(s.rollingPageX))<30&&Math.abs(s.initialPageY-qY(s.rollingPageY))<30){let e=this.newGestureEvent(xQ.Contextmenu,s.initialTarget);e.pageX=qY(s.rollingPageX),e.pageY=qY(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=qY(s.rollingPageX),n=qY(s.rollingPageY),i=qY(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(xQ.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===xQ.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===xQ.Change||t.type===xQ.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=sQ(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(xQ.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(xQ.Change,i.initialTarget);a.translationX=r.pageX-qY(i.rollingPageX),a.translationY=r.pageY-qY(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};SQ.SCROLL_FRICTION=-.005,SQ.HOLD_DELAY=700,SQ.CLEAR_TAP_COUNT_TIME=400,WJ([bQ],SQ,`isTouchDevice`,1);var CQ=SQ,wQ=class extends pX{onclick(e,t){this._register(iQ(e,fQ.CLICK,n=>t(new AZ(eQ(e),n))))}onmousedown(e,t){this._register(iQ(e,fQ.MOUSE_DOWN,n=>t(new AZ(eQ(e),n))))}onmouseover(e,t){this._register(iQ(e,fQ.MOUSE_OVER,n=>t(new AZ(eQ(e),n))))}onmouseleave(e,t){this._register(iQ(e,fQ.MOUSE_LEAVE,n=>t(new AZ(eQ(e),n))))}onkeydown(e,t){this._register(iQ(e,fQ.KEY_DOWN,e=>t(new EZ(e))))}onkeyup(e,t){this._register(iQ(e,fQ.KEY_UP,e=>t(new EZ(e))))}oninput(e,t){this._register(iQ(e,fQ.INPUT,t))}onblur(e,t){this._register(iQ(e,fQ.BLUR,t))}onfocus(e,t){this._register(iQ(e,fQ.FOCUS,t))}onchange(e,t){this._register(iQ(e,fQ.CHANGE,t))}ignoreGesture(e){return CQ.ignoreTarget(e)}},TQ=11,EQ=class extends wQ{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=TQ+`px`,this.domNode.style.height=TQ+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new yQ),this._register(oQ(this.bgDomNode,fQ.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(oQ(this.domNode,fQ.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new cQ),this._pointerdownScheduleRepeatTimer=this._register(new FZ)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,eQ(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},DQ=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},OQ=class extends pX{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new DQ(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new MQ(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=MQ.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},kQ=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function AQ(e,t){let n=t-e;return function(t){return e+n*PQ(t)}}function jQ(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var MQ=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),jQ(AQ(e,r),AQ(i,t),.33)}return AQ(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new kQ(this.scrollLeft(t),this.scrollTop(t),!1):new kQ(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function NQ(e){return e**3}function PQ(e){return 1-NQ(1-e)}var FQ=class extends pX{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new FZ)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},IQ=140,LQ=class extends wQ{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new FQ(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new yQ),this._shouldRender=!0,this.domNode=vQ(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(iQ(this.domNode.domNode,fQ.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new EQ(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=vQ(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(iQ(this.slider.domNode,fQ.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=dQ(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(rZ&&a>IQ){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},RQ=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize===t?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},zQ=class extends LQ{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new RQ(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},BQ=class extends LQ{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new RQ(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},VQ=500,HQ=50,UQ=!0,WQ=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},GQ=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(HX){let t=RX(eQ(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new WQ(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};GQ.INSTANCE=new GQ;var KQ=GQ,qQ=class extends wQ{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=YQ(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new BQ(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new zQ(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=vQ(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=vQ(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=vQ(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new FZ),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=cX(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,iZ&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new jZ(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=cX(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(iQ(this._listenOnDomNode,fQ.MOUSE_WHEEL,e=>{this._onMouseWheel(new jZ(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=KQ.INSTANCE;UQ&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!iZ&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=HQ*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=HQ*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(UQ&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),VQ)}},JQ=class extends qQ{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function YQ(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,iZ&&(t.className+=` mac`),t}var XQ=class extends pX{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new OQ({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>sQ(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new JQ(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(xX.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(uX(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(uX(()=>this._styleElement.remove())),this._register(xX.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
180
180
|
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};XQ=WJ([Z(2,_Y),Z(3,AY),Z(4,vY),Z(5,FY),Z(6,CY),Z(7,MY)],XQ);var ZQ=class extends pX{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(uX(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};ZQ=WJ([Z(1,_Y),Z(2,AY),Z(3,EY),Z(4,MY)],ZQ);var QQ=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},$Q={full:0,left:0,center:0,right:0},e$={full:0,left:0,center:0,right:0},t$={full:0,left:0,center:0,right:0},n$=class extends pX{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new QQ,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(uX(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);e$.full=this._canvas.width,e$.left=e,e$.center=t,e$.right=e,this._refreshDrawHeightConstants(),t$.full=1,t$.left=1,t$.center=1+e$.left,t$.right=1+e$.left+e$.center}_refreshDrawHeightConstants(){$Q.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);$Q.left=t,$Q.center=t,$Q.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$Q.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$Q.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$Q.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$Q.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(t$[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-$Q[e.position||`full`]/2),e$[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+$Q[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};n$=WJ([Z(2,_Y),Z(3,EY),Z(4,MY),Z(5,CY),Z(6,FY),Z(7,AY)],n$);var $;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
|
|
181
|
-
`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var r$;(e=>(e.PAD=``,e.HOP=``,e.BPH=``,e.NBH=``,e.IND=``,e.NEL=`
`,e.SSA=``,e.ESA=``,e.HTS=``,e.HTJ=``,e.VTS=``,e.PLD=``,e.PLU=``,e.RI=``,e.SS2=``,e.SS3=``,e.DCS=``,e.PU1=``,e.PU2=``,e.STS=``,e.CCH=``,e.MW=``,e.SPA=``,e.EPA=``,e.SOS=``,e.SGCI=``,e.SCI=``,e.CSI=``,e.ST=``,e.OSC=``,e.PM=``,e.APC=``))(r$||={});var i$;(e=>e.ST=`${$.ESC}\\`)(i$||={});var a$=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};a$=WJ([Z(2,_Y),Z(3,CY),Z(4,yY),Z(5,MY)],a$);var o$=0,s$=0,c$=0,l$=0,u$={css:`#00000000`,rgba:0},d$;(e=>{function t(e,t,n,r){return r===void 0?`#${g$(e)}${g$(t)}${g$(n)}`:`#${g$(e)}${g$(t)}${g$(n)}${g$(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(d$||={});var f$;(e=>{function t(e,t){if(l$=(t.rgba&255)/255,l$===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return o$=a+Math.round((n-a)*l$),s$=o+Math.round((r-o)*l$),c$=s+Math.round((i-s)*l$),{css:d$.toCss(o$,s$,c$),rgba:d$.toRgba(o$,s$,c$)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=h$.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return d$.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[o$,s$,c$]=h$.toChannels(t),{css:d$.toCss(o$,s$,c$),rgba:t}}e.opaque=i;function a(e,t){return l$=Math.round(t*255),[o$,s$,c$]=h$.toChannels(e.rgba),{css:d$.toCss(o$,s$,c$,l$),rgba:d$.toRgba(o$,s$,c$,l$)}}e.opacity=a;function o(e,t){return l$=e.rgba&255,a(e,l$*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(f$||={});var p$;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return o$=parseInt(e.slice(1,2).repeat(2),16),s$=parseInt(e.slice(2,3).repeat(2),16),c$=parseInt(e.slice(3,4).repeat(2),16),d$.toColor(o$,s$,c$);case 5:return o$=parseInt(e.slice(1,2).repeat(2),16),s$=parseInt(e.slice(2,3).repeat(2),16),c$=parseInt(e.slice(3,4).repeat(2),16),l$=parseInt(e.slice(4,5).repeat(2),16),d$.toColor(o$,s$,c$,l$);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return o$=parseInt(r[1]),s$=parseInt(r[2]),c$=parseInt(r[3]),l$=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),d$.toColor(o$,s$,c$,l$);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[o$,s$,c$,l$]=t.getImageData(0,0,1,1).data,l$!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:d$.toRgba(o$,s$,c$,l$),css:e}}e.toColor=r})(p$||={});var m$;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(m$||={});var h$;(e=>{function t(e,t){if(l$=(t&255)/255,l$===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return o$=a+Math.round((n-a)*l$),s$=o+Math.round((r-o)*l$),c$=s+Math.round((i-s)*l$),d$.toRgba(o$,s$,c$)}e.blend=t;function n(e,t,n){let a=m$.relativeLuminance(e>>8),o=m$.relativeLuminance(t>>8);if(_$(a,o)<n){if(o<a){let o=r(e,t,n),s=_$(a,m$.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>_$(a,m$.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=_$(a,m$.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>_$(a,m$.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=_$(m$.relativeLuminance2(o,s,c),m$.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=_$(m$.relativeLuminance2(o,s,c),m$.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=_$(m$.relativeLuminance2(o,s,c),m$.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=_$(m$.relativeLuminance2(o,s,c),m$.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(h$||={});function g$(e){let t=e.toString(16);return t.length<2?`0`+t:t}function _$(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var v$=class extends cY{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},y$=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new uY}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||sY.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)y$._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||sY.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};y$=WJ([Z(0,_Y)],y$);function b$(e){return 57508<=e&&e<=57558}function x$(e){return 9472<=e&&e<=9631}function S$(e){return b$(e)||x$(e)}function C$(){return{css:{canvas:w$(),cell:w$()},device:{canvas:w$(),cell:w$(),char:{width:0,height:0,left:0,top:0}}}}function w$(){return{width:0,height:0}}var T$=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new uY,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new v$(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),ee=n&&k===a,F=O&&k>=l&&k<=u,I=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{I=!0});let te=N.getChars()||sY;if(te===` `&&(N.isUnderline()||N.isOverline())&&(te=`\xA0`),T=m*s-c.get(te,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&F===S&&T===C&&!ee&&!A&&!I&&j){N.isInvisible()?_+=sY:_+=te,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=F,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&ee&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`);break;default:break}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?sY:N.getChars()||sY,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${cY.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),F&&(h.style.textDecoration=`underline`);let ne=N.getFgColor(),re=N.getFgColorMode(),ie=N.getBgColor(),ae=N.getBgColorMode(),oe=!!N.isInverse();if(oe){let e=ne;ne=ie,ie=e;let t=re;re=ae,ae=t}let se,ce,le=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&le||(e.backgroundColorRGB&&(ae=50331648,ie=e.backgroundColorRGB.rgba>>8&16777215,se=e.backgroundColorRGB),e.foregroundColorRGB&&(re=50331648,ne=e.foregroundColorRGB.rgba>>8&16777215,ce=e.foregroundColorRGB),le=e.options.layer===`top`)}),!le&&P&&(se=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ie=se.rgba>>8&16777215,ae=50331648,le=!0,p.selectionForeground&&(re=50331648,ne=p.selectionForeground.rgba>>8&16777215,ce=p.selectionForeground)),le&&D.push(`xterm-decoration-top`);let ue;switch(ae){case 16777216:case 33554432:ue=p.ansi[ie],D.push(`xterm-bg-${ie}`);break;case 50331648:ue=d$.toColor(ie>>16,ie>>8&255,ie&255),this._addStyle(h,`background-color:#${E$((ie>>>0).toString(16),`0`,6)}`);break;default:oe?(ue=p.foreground,D.push(`xterm-bg-257`)):ue=p.background}switch(se||N.isDim()&&(se=f$.multiplyOpacity(ue,.5)),re){case 16777216:case 33554432:N.isBold()&&ne<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ne+=8),this._applyMinimumContrast(h,ue,p.ansi[ne],N,se,void 0)||D.push(`xterm-fg-${ne}`);break;case 50331648:let e=d$.toColor(ne>>16&255,ne>>8&255,ne&255);this._applyMinimumContrast(h,ue,e,N,se,ce)||this._addStyle(h,`color:#${E$(ne.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ue,p.foreground,N,se,ce)||oe&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!ee&&!A&&!I&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||S$(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=f$.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};T$=WJ([Z(1,PY),Z(2,CY),Z(3,AY),Z(4,yY),Z(5,EY),Z(6,FY)],T$);function E$(e,t,n){for(;e.length<n;)e=t+e;return e}var D$=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},O$=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function k$(){return new O$}var A$=`xterm-dom-renderer-owner-`,j$=`xterm-rows`,M$=`xterm-fg-`,N$=`xterm-bg-`,P$=`xterm-focus`,F$=`xterm-selection`,I$=1,L$=class extends pX{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=I$++,this._rowElements=[],this._selectionRenderModel=k$(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(j$),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(F$),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=C$(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(T$,document),this._element.classList.add(A$+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(uX(()=>{this._element.classList.remove(A$+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new D$(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${j$} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${j$} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${j$} .xterm-dim { color: ${f$.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${j$}.${P$} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${j$}.${P$} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${j$}.${P$} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${F$} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${F$} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${F$} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${M$}${n} { color: ${r.css}; }${this._terminalSelector} .${M$}${n}.xterm-dim { color: ${f$.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${N$}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${M$}257 { color: ${f$.opaque(e.background).css}; }${this._terminalSelector} .${M$}257.xterm-dim { color: ${f$.multiplyOpacity(f$.opaque(e.background),.5).css}; }${this._terminalSelector} .${N$}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(P$),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(P$),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${A$}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};L$=WJ([Z(7,xY),Z(8,kY),Z(9,CY),Z(10,_Y),Z(11,yY),Z(12,AY),Z(13,FY)],L$);var R$=class extends pX{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new V$(this._optionsService))}catch{this._measureStrategy=this._register(new B$(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};R$=WJ([Z(2,CY)],R$);var z$=class extends pX{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},B$=class extends z${constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},V$=class extends z${constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},H$=class extends pX{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new U$(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(xX.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(rQ(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(rQ(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},U$=class extends pX{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new mX),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(uX(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=rQ(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},W$=class extends pX{constructor(){super(),this.linkProviders=[],this._register(uX(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function G$(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function K$(e,t,n,r,i,a,o,s,c){if(!a)return;let l=G$(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var q$=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return K$(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=G$(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};q$=WJ([Z(0,MY),Z(1,kY)],q$);var J$=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Y$={};UJ(Y$,{getSafariVersion:()=>n1,isChromeOS:()=>c1,isFirefox:()=>$$,isIpad:()=>i1,isIphone:()=>a1,isLegacyEdge:()=>e1,isLinux:()=>s1,isMac:()=>r1,isNode:()=>X$,isSafari:()=>t1,isWindows:()=>o1});var X$=typeof process<`u`&&`title`in process,Z$=X$?`node`:navigator.userAgent,Q$=X$?`node`:navigator.platform,$$=Z$.includes(`Firefox`),e1=Z$.includes(`Edge`),t1=/^((?!chrome|android).)*safari/i.test(Z$);function n1(){if(!t1)return 0;let e=Z$.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var r1=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Q$),i1=Q$===`iPad`,a1=Q$===`iPhone`,o1=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Q$),s1=Q$.indexOf(`Linux`)>=0,c1=/\bCrOS\b/.test(Z$),l1=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},u1=class extends l1{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},d1=class extends l1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},f1=!X$&&`requestIdleCallback`in window?d1:u1,p1=class{constructor(){this._queue=new f1}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},m1=class extends pX{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new mX),this._pausedResizeTask=new p1,this._observerDisposable=this._register(new mX),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new J$((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new h1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(uX(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=uX(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};m1=WJ([Z(2,CY),Z(3,kY),Z(4,yY),Z(5,EY),Z(6,_Y),Z(7,AY),Z(8,FY)],m1);var h1=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function g1(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return y1(i,a,e,t,n,r)+b1(a,t,n,r)+x1(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,O1(Math.abs(i-e),D1(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return O1(v1(a>t?e:i,n)+(s-1)*n.cols+1+_1(a>t?i:e,n),D1(o,r))}function _1(e,t){return e-1}function v1(e,t){return t.cols-e}function y1(e,t,n,r,i,a){return b1(t,r,i,a).length===0?``:O1(E1(e,t,e,t-C1(t,i),!1,i).length,D1(`D`,a))}function b1(e,t,n,r){let i=e-C1(e,n),a=t-C1(t,n);return O1(Math.abs(i-a)-S1(e,t,n),D1(T1(e,t),r))}function x1(e,t,n,r,i,a){let o;o=b1(t,r,i,a).length>0?r-C1(r,i):t;let s=r,c=w1(e,t,n,r,i,a);return O1(E1(e,o,n,s,c===`C`,i).length,D1(c,a))}function S1(e,t,n){let r=0,i=e-C1(e,n),a=t-C1(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=T1(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function C1(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function w1(e,t,n,r,i,a){let o;return o=b1(n,r,i,a).length>0?r-C1(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function T1(e,t){return e>t?`A`:`B`}function E1(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function D1(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function O1(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var k1=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function A1(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var j1=50,M1=15,N1=50,P1=500,F1=RegExp(`\xA0`,`g`),I1=class extends pX{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new uY,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new k1(this._bufferService),this._activeSelectionMode=0,this._register(uX(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(F1,` `)).join(o1?`\r
|
|
181
|
+
`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var r$;(e=>(e.PAD=``,e.HOP=``,e.BPH=``,e.NBH=``,e.IND=``,e.NEL=`
`,e.SSA=``,e.ESA=``,e.HTS=``,e.HTJ=``,e.VTS=``,e.PLD=``,e.PLU=``,e.RI=``,e.SS2=``,e.SS3=``,e.DCS=``,e.PU1=``,e.PU2=``,e.STS=``,e.CCH=``,e.MW=``,e.SPA=``,e.EPA=``,e.SOS=``,e.SGCI=``,e.SCI=``,e.CSI=``,e.ST=``,e.OSC=``,e.PM=``,e.APC=``))(r$||={});var i$;(e=>e.ST=`${$.ESC}\\`)(i$||={});var a$=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};a$=WJ([Z(2,_Y),Z(3,CY),Z(4,yY),Z(5,MY)],a$);var o$=0,s$=0,c$=0,l$=0,u$={css:`#00000000`,rgba:0},d$;(e=>{function t(e,t,n,r){return r===void 0?`#${g$(e)}${g$(t)}${g$(n)}`:`#${g$(e)}${g$(t)}${g$(n)}${g$(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(d$||={});var f$;(e=>{function t(e,t){if(l$=(t.rgba&255)/255,l$===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return o$=a+Math.round((n-a)*l$),s$=o+Math.round((r-o)*l$),c$=s+Math.round((i-s)*l$),{css:d$.toCss(o$,s$,c$),rgba:d$.toRgba(o$,s$,c$)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=h$.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return d$.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[o$,s$,c$]=h$.toChannels(t),{css:d$.toCss(o$,s$,c$),rgba:t}}e.opaque=i;function a(e,t){return l$=Math.round(t*255),[o$,s$,c$]=h$.toChannels(e.rgba),{css:d$.toCss(o$,s$,c$,l$),rgba:d$.toRgba(o$,s$,c$,l$)}}e.opacity=a;function o(e,t){return l$=e.rgba&255,a(e,l$*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(f$||={});var p$;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return o$=parseInt(e.slice(1,2).repeat(2),16),s$=parseInt(e.slice(2,3).repeat(2),16),c$=parseInt(e.slice(3,4).repeat(2),16),d$.toColor(o$,s$,c$);case 5:return o$=parseInt(e.slice(1,2).repeat(2),16),s$=parseInt(e.slice(2,3).repeat(2),16),c$=parseInt(e.slice(3,4).repeat(2),16),l$=parseInt(e.slice(4,5).repeat(2),16),d$.toColor(o$,s$,c$,l$);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return o$=parseInt(r[1]),s$=parseInt(r[2]),c$=parseInt(r[3]),l$=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),d$.toColor(o$,s$,c$,l$);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[o$,s$,c$,l$]=t.getImageData(0,0,1,1).data,l$!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:d$.toRgba(o$,s$,c$,l$),css:e}}e.toColor=r})(p$||={});var m$;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(m$||={});var h$;(e=>{function t(e,t){if(l$=(t&255)/255,l$===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return o$=a+Math.round((n-a)*l$),s$=o+Math.round((r-o)*l$),c$=s+Math.round((i-s)*l$),d$.toRgba(o$,s$,c$)}e.blend=t;function n(e,t,n){let a=m$.relativeLuminance(e>>8),o=m$.relativeLuminance(t>>8);if(_$(a,o)<n){if(o<a){let o=r(e,t,n),s=_$(a,m$.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>_$(a,m$.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=_$(a,m$.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>_$(a,m$.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=_$(m$.relativeLuminance2(o,s,c),m$.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=_$(m$.relativeLuminance2(o,s,c),m$.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=_$(m$.relativeLuminance2(o,s,c),m$.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=_$(m$.relativeLuminance2(o,s,c),m$.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(h$||={});function g$(e){let t=e.toString(16);return t.length<2?`0`+t:t}function _$(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var v$=class extends cY{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},y$=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new uY}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||sY.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)y$._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||sY.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};y$=WJ([Z(0,_Y)],y$);function b$(e){return 57508<=e&&e<=57558}function x$(e){return 9472<=e&&e<=9631}function S$(e){return b$(e)||x$(e)}function C$(){return{css:{canvas:w$(),cell:w$()},device:{canvas:w$(),cell:w$(),char:{width:0,height:0,left:0,top:0}}}}function w$(){return{width:0,height:0}}var T$=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new uY,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new v$(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),ee=n&&k===a,F=O&&k>=l&&k<=u,I=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{I=!0});let te=N.getChars()||sY;if(te===` `&&(N.isUnderline()||N.isOverline())&&(te=`\xA0`),T=m*s-c.get(te,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&F===S&&T===C&&!ee&&!A&&!I&&j){N.isInvisible()?_+=sY:_+=te,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=F,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&ee&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`);break;default:break}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?sY:N.getChars()||sY,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${cY.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),F&&(h.style.textDecoration=`underline`);let ne=N.getFgColor(),re=N.getFgColorMode(),ie=N.getBgColor(),ae=N.getBgColorMode(),oe=!!N.isInverse();if(oe){let e=ne;ne=ie,ie=e;let t=re;re=ae,ae=t}let se,ce,le=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&le||(e.backgroundColorRGB&&(ae=50331648,ie=e.backgroundColorRGB.rgba>>8&16777215,se=e.backgroundColorRGB),e.foregroundColorRGB&&(re=50331648,ne=e.foregroundColorRGB.rgba>>8&16777215,ce=e.foregroundColorRGB),le=e.options.layer===`top`)}),!le&&P&&(se=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ie=se.rgba>>8&16777215,ae=50331648,le=!0,p.selectionForeground&&(re=50331648,ne=p.selectionForeground.rgba>>8&16777215,ce=p.selectionForeground)),le&&D.push(`xterm-decoration-top`);let ue;switch(ae){case 16777216:case 33554432:ue=p.ansi[ie],D.push(`xterm-bg-${ie}`);break;case 50331648:ue=d$.toColor(ie>>16,ie>>8&255,ie&255),this._addStyle(h,`background-color:#${E$((ie>>>0).toString(16),`0`,6)}`);break;default:oe?(ue=p.foreground,D.push(`xterm-bg-257`)):ue=p.background}switch(se||N.isDim()&&(se=f$.multiplyOpacity(ue,.5)),re){case 16777216:case 33554432:N.isBold()&&ne<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ne+=8),this._applyMinimumContrast(h,ue,p.ansi[ne],N,se,void 0)||D.push(`xterm-fg-${ne}`);break;case 50331648:let e=d$.toColor(ne>>16&255,ne>>8&255,ne&255);this._applyMinimumContrast(h,ue,e,N,se,ce)||this._addStyle(h,`color:#${E$(ne.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ue,p.foreground,N,se,ce)||oe&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!ee&&!A&&!I&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||S$(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=f$.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};T$=WJ([Z(1,PY),Z(2,CY),Z(3,AY),Z(4,yY),Z(5,EY),Z(6,FY)],T$);function E$(e,t,n){for(;e.length<n;)e=t+e;return e}var D$=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},O$=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function k$(){return new O$}var A$=`xterm-dom-renderer-owner-`,j$=`xterm-rows`,M$=`xterm-fg-`,N$=`xterm-bg-`,P$=`xterm-focus`,F$=`xterm-selection`,I$=1,L$=class extends pX{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=I$++,this._rowElements=[],this._selectionRenderModel=k$(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(j$),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(F$),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=C$(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(T$,document),this._element.classList.add(A$+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(uX(()=>{this._element.classList.remove(A$+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new D$(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${j$} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${j$} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${j$} .xterm-dim { color: ${f$.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${j$}.${P$} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${j$}.${P$} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${j$}.${P$} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${j$} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${F$} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${F$} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${F$} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${M$}${n} { color: ${r.css}; }${this._terminalSelector} .${M$}${n}.xterm-dim { color: ${f$.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${N$}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${M$}257 { color: ${f$.opaque(e.background).css}; }${this._terminalSelector} .${M$}257.xterm-dim { color: ${f$.multiplyOpacity(f$.opaque(e.background),.5).css}; }${this._terminalSelector} .${N$}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(P$),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(P$),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${A$}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};L$=WJ([Z(7,xY),Z(8,kY),Z(9,CY),Z(10,_Y),Z(11,yY),Z(12,AY),Z(13,FY)],L$);var R$=class extends pX{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new V$(this._optionsService))}catch{this._measureStrategy=this._register(new B$(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};R$=WJ([Z(2,CY)],R$);var z$=class extends pX{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},B$=class extends z${constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},V$=class extends z${constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},H$=class extends pX{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new U$(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(xX.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(iQ(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(iQ(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},U$=class extends pX{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new mX),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(uX(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=iQ(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},W$=class extends pX{constructor(){super(),this.linkProviders=[],this._register(uX(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function G$(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function K$(e,t,n,r,i,a,o,s,c){if(!a)return;let l=G$(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var q$=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return K$(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=G$(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};q$=WJ([Z(0,MY),Z(1,kY)],q$);var J$=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Y$={};UJ(Y$,{getSafariVersion:()=>n1,isChromeOS:()=>c1,isFirefox:()=>$$,isIpad:()=>i1,isIphone:()=>a1,isLegacyEdge:()=>e1,isLinux:()=>s1,isMac:()=>r1,isNode:()=>X$,isSafari:()=>t1,isWindows:()=>o1});var X$=typeof process<`u`&&`title`in process,Z$=X$?`node`:navigator.userAgent,Q$=X$?`node`:navigator.platform,$$=Z$.includes(`Firefox`),e1=Z$.includes(`Edge`),t1=/^((?!chrome|android).)*safari/i.test(Z$);function n1(){if(!t1)return 0;let e=Z$.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var r1=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Q$),i1=Q$===`iPad`,a1=Q$===`iPhone`,o1=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Q$),s1=Q$.indexOf(`Linux`)>=0,c1=/\bCrOS\b/.test(Z$),l1=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},u1=class extends l1{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},d1=class extends l1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},f1=!X$&&`requestIdleCallback`in window?d1:u1,p1=class{constructor(){this._queue=new f1}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},m1=class extends pX{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new mX),this._pausedResizeTask=new p1,this._observerDisposable=this._register(new mX),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new J$((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new h1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(uX(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=uX(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};m1=WJ([Z(2,CY),Z(3,kY),Z(4,yY),Z(5,EY),Z(6,_Y),Z(7,AY),Z(8,FY)],m1);var h1=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function g1(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return y1(i,a,e,t,n,r)+b1(a,t,n,r)+x1(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,O1(Math.abs(i-e),D1(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return O1(v1(a>t?e:i,n)+(s-1)*n.cols+1+_1(a>t?i:e,n),D1(o,r))}function _1(e,t){return e-1}function v1(e,t){return t.cols-e}function y1(e,t,n,r,i,a){return b1(t,r,i,a).length===0?``:O1(E1(e,t,e,t-C1(t,i),!1,i).length,D1(`D`,a))}function b1(e,t,n,r){let i=e-C1(e,n),a=t-C1(t,n);return O1(Math.abs(i-a)-S1(e,t,n),D1(T1(e,t),r))}function x1(e,t,n,r,i,a){let o;o=b1(t,r,i,a).length>0?r-C1(r,i):t;let s=r,c=w1(e,t,n,r,i,a);return O1(E1(e,o,n,s,c===`C`,i).length,D1(c,a))}function S1(e,t,n){let r=0,i=e-C1(e,n),a=t-C1(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=T1(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function C1(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function w1(e,t,n,r,i,a){let o;return o=b1(n,r,i,a).length>0?r-C1(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function T1(e,t){return e>t?`A`:`B`}function E1(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function D1(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function O1(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var k1=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function A1(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var j1=50,M1=15,N1=50,P1=500,F1=RegExp(`\xA0`,`g`),I1=class extends pX{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new uY,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new k1(this._bufferService),this._activeSelectionMode=0,this._register(uX(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(F1,` `)).join(o1?`\r
|
|
182
182
|
`:`
|
|
183
183
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),s1&&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=A1(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=G$(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,-j1),j1),t/=j1,t/Math.abs(t)+Math.round(t*(M1-1)))}shouldForceSelection(e){return r1?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(),N1)}_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&&!(r1&&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<P1&&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=g1(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&&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=A1(n,this._bufferService.cols)}};I1=WJ([Z(3,_Y),Z(4,yY),Z(5,jY),Z(6,CY),Z(7,MY),Z(8,AY)],I1);var L1=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={}}},R1=class{constructor(){this._color=new L1,this._css=new L1}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()}},z1=Object.freeze((()=>{let e=[p$.toColor(`#2e3436`),p$.toColor(`#cc0000`),p$.toColor(`#4e9a06`),p$.toColor(`#c4a000`),p$.toColor(`#3465a4`),p$.toColor(`#75507b`),p$.toColor(`#06989a`),p$.toColor(`#d3d7cf`),p$.toColor(`#555753`),p$.toColor(`#ef2929`),p$.toColor(`#8ae234`),p$.toColor(`#fce94f`),p$.toColor(`#729fcf`),p$.toColor(`#ad7fa8`),p$.toColor(`#34e2e2`),p$.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:d$.toCss(r,i,a),rgba:d$.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:d$.toCss(n,n,n),rgba:d$.toRgba(n,n,n)})}return e})()),B1=p$.toColor(`#ffffff`),V1=p$.toColor(`#000000`),H1=p$.toColor(`#ffffff`),U1=V1,W1={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},G1=B1,K1=class extends pX{constructor(e){super(),this._optionsService=e,this._contrastCache=new R1,this._halfContrastCache=new R1,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:B1,background:V1,cursor:H1,cursorAccent:U1,selectionForeground:void 0,selectionBackgroundTransparent:W1,selectionBackgroundOpaque:f$.blend(V1,W1),selectionInactiveBackgroundTransparent:W1,selectionInactiveBackgroundOpaque:f$.blend(V1,W1),scrollbarSliderBackground:f$.opacity(B1,.2),scrollbarSliderHoverBackground:f$.opacity(B1,.4),scrollbarSliderActiveBackground:f$.opacity(B1,.5),overviewRulerBorder:B1,ansi:z1.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=q1(e.foreground,B1),t.background=q1(e.background,V1),t.cursor=f$.blend(t.background,q1(e.cursor,H1)),t.cursorAccent=f$.blend(t.background,q1(e.cursorAccent,U1)),t.selectionBackgroundTransparent=q1(e.selectionBackground,W1),t.selectionBackgroundOpaque=f$.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=q1(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=f$.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?q1(e.selectionForeground,u$):void 0,t.selectionForeground===u$&&(t.selectionForeground=void 0),f$.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=f$.opacity(t.selectionBackgroundTransparent,.3)),f$.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=f$.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=q1(e.scrollbarSliderBackground,f$.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=q1(e.scrollbarSliderHoverBackground,f$.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=q1(e.scrollbarSliderActiveBackground,f$.opacity(t.foreground,.5)),t.overviewRulerBorder=q1(e.overviewRulerBorder,G1),t.ansi=z1.slice(),t.ansi[0]=q1(e.black,z1[0]),t.ansi[1]=q1(e.red,z1[1]),t.ansi[2]=q1(e.green,z1[2]),t.ansi[3]=q1(e.yellow,z1[3]),t.ansi[4]=q1(e.blue,z1[4]),t.ansi[5]=q1(e.magenta,z1[5]),t.ansi[6]=q1(e.cyan,z1[6]),t.ansi[7]=q1(e.white,z1[7]),t.ansi[8]=q1(e.brightBlack,z1[8]),t.ansi[9]=q1(e.brightRed,z1[9]),t.ansi[10]=q1(e.brightGreen,z1[10]),t.ansi[11]=q1(e.brightYellow,z1[11]),t.ansi[12]=q1(e.brightBlue,z1[12]),t.ansi[13]=q1(e.brightMagenta,z1[13]),t.ansi[14]=q1(e.brightCyan,z1[14]),t.ansi[15]=q1(e.brightWhite,z1[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]=q1(e.extendedAnsi[r],z1[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()}}};K1=WJ([Z(0,CY)],K1);function q1(e,t){if(e!==void 0)try{return p$.toColor(e)}catch{}return t}var J1=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)}},Y1=class{constructor(){this._services=new J1,this._services.set(xY,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=mY(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)}},X1={trace:0,debug:1,info:2,warn:3,error:4,off:5},Z1=`xterm.js: `,Q1=class extends pX{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),$1=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=X1[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?``:Z1)+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)}};Q1=WJ([Z(0,CY)],Q1);var $1,e0=class extends pX{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),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}},t0=3,n0=Object.freeze(new cY),r0=0,i0=2,a0=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*t0);let r=t||uY.fromCharData([0,oY,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*t0+0],n=t&2097151;return[this._data[e*t0+1],t&2097152?this._combined[e]:n?nY(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*t0+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*t0+0]=e|2097152|t[2]<<22):this._data[e*t0+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*t0+0]>>22}hasWidth(e){return this._data[e*t0+0]&12582912}getFg(e){return this._data[e*t0+1]}getBg(e){return this._data[e*t0+2]}hasContent(e){return this._data[e*t0+0]&4194303}getCodePoint(e){let t=this._data[e*t0+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*t0+0]&2097152}getString(e){let t=this._data[e*t0+0];return t&2097152?this._combined[e]:t&2097151?nY(t&2097151):``}isProtected(e){return this._data[e*t0+2]&536870912}loadCell(e,t){return r0=e*t0,t.content=this._data[r0+0],t.fg=this._data[r0+1],t.bg=this._data[r0+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*t0+0]=t.content,this._data[e*t0+1]=t.fg,this._data[e*t0+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*t0+0]=t|n<<22,this._data[e*t0+1]=r.fg,this._data[e*t0+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*t0+0];r&2097152?this._combined[e]+=nY(t):r&2097151?(this._combined[e]=nY(r&2097151)+nY(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*t0+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 uY;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 uY;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*i0<this._data.buffer.byteLength;let n=e*t0;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*i0<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*i0<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*t0+0]&4194303)return e+(this._data[e*t0+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*t0+0]&4194303||this._data[e*t0+2]&50331648)return e+(this._data[e*t0+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<t0;e++)this._data[(n+i)*t0+e]=a[(t+i)*t0+e];a[(t+i)*t0+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<t0;e++)this._data[(n+i)*t0+e]=a[(t+i)*t0+e];a[(t+i)*t0+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*t0+0],n=e&2097151,a=e&2097152?this._combined[t]:n?nY(n):sY;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 o0(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=u0(u,d,t),p=1,m=0;for(;p<u.length;){let e=u0(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 s0(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 c0(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 l0(e,t,n){let r=[],i=e.map((n,r)=>u0(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=u0(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 u0(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 d0=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),cX(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};d0._nextId=1;var f0=d0,p0={},m0=p0.B;p0[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},p0.A={"#":`£`},p0.B=void 0,p0[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},p0.C=p0[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},p0.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},p0.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},p0.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},p0.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},p0.E=p0[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},p0.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},p0.H=p0[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},p0[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var h0=4294967295,g0=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=n0.clone(),this.savedCharset=m0,this.markers=[],this._nullCell=uY.fromCharData([0,oY,1,0]),this._whitespaceCell=uY.fromCharData([0,sY,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new f1,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new e0(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 lY),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 lY),this._whitespaceCell}getBlankLine(e,t){return new a0(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>h0?h0:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=n0);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 e0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(n0),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 a0(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 a0(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=o0(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(n0),n);if(r.length>0){let n=s0(this.lines,r);c0(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(n0),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new a0(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(n0),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=l0(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(n0,!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--,_=u0(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 f0(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)}},_0=class extends pX{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),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 g0(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new g0(!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)}},v0=2,y0=1,b0=class extends pX{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,v0),this.rows=Math.max(e.rawOptions.rows||0,y0),this.buffers=this._register(new _0(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))}};b0=WJ([Z(0,CY)],b0);var x0={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:r1,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},S0=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],C0=class extends pX{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...x0};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(uX(()=>{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 x0))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in x0))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||=x0[e],!w0(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=x0[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=S0.includes(t)?t:x0[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 w0(e){return e===`block`||e===`underline`||e===`bar`}function T0(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]&&T0(e[r],t-1);return n}var E0=Object.freeze({insertMode:!1}),D0=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),O0=class extends pX{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 Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=T0(E0),this.decPrivateModes=T0(D0)}reset(){this.modes=T0(E0),this.decPrivateModes=T0(D0)}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))}};O0=WJ([Z(0,_Y),Z(1,SY),Z(2,CY)],O0);var k0={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 A0(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 j0=String.fromCharCode,M0={DEFAULT:e=>{let t=[A0(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${j0(t[0])}${j0(t[1])}${j0(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${A0(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${A0(e,!0)};${e.x};${e.y}${t}`}},N0=class extends pX{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 Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(k0))this.addProtocol(e,k0[e]);for(let e of Object.keys(M0))this.addEncoding(e,M0[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)}};N0=WJ([Z(0,_Y),Z(1,yY),Z(2,CY)],N0);var P0=[[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]],F0=[[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]],I0;function L0(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 R0=class{constructor(){if(this.version=`6`,!I0){I0=new Uint8Array(65536),I0.fill(1),I0[0]=0,I0.fill(0,1,32),I0.fill(0,127,160),I0.fill(2,4352,4448),I0[9001]=2,I0[9002]=2,I0.fill(2,11904,42192),I0[12351]=1,I0.fill(2,44032,55204),I0.fill(2,63744,64256),I0.fill(2,65040,65050),I0.fill(2,65072,65136),I0.fill(2,65280,65377),I0.fill(2,65504,65511);for(let e=0;e<P0.length;++e)I0.fill(0,P0[e][0],P0[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?I0[e]:L0(e,F0)?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=z0.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return z0.createPropertyValue(0,n,r)}},z0=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new R0;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)}},B0=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 V0(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 H0=2147483647,U0=256,W0=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>U0)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>H0?H0: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>H0?H0: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,H0):e}},G0=[],K0=class{constructor(){this._state=0,this._active=G0,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=G0}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=G0,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||G0,!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`,rY(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=G0,this._id=-1,this._state=0}}},q0=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+=rY(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}},J0=[],Y0=class{constructor(){this._handlers=Object.create(null),this._active=J0,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=J0}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=J0,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||J0,!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`,rY(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=J0,this._ident=0}},X0=new W0;X0.addParam(0);var Z0=class{constructor(e){this._handler=e,this._data=``,this._params=X0,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():X0,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=rY(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=X0,this._data=``,this._hitLimit=!1,e));return this._params=X0,this._data=``,this._hitLimit=!1,t}},Q0=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}},$0=160,e2=function(){let e=new Q0(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($0,0,2,0),e.add($0,8,5,8),e.add($0,6,0,6),e.add($0,11,0,11),e.add($0,13,13,13),e}(),t2=class extends pX{constructor(e=e2){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 W0,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(uX(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new K0),this._dcsParser=this._register(new Y0),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:$0)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<$0){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<$0){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<$0){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<$0){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<$0){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<$0){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}}},n2=/^([\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})$/,r2=/^[\da-f]+$/;function i2(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=n2.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),r2.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 a2(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 o2(e,t=16){let[n,r,i]=e;return`rgb:${a2(n,t)}/${a2(r,t)}/${a2(i,t)}`}var s2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},c2=131072,l2=10;function u2(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 d2=5e3,f2=0,p2=class extends pX{constructor(e,t,n,r,i,a,o,s,c=new t2){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 iY,this._utf8Decoder=new aY,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=n0.clone(),this._eraseAttrDataInternal=n0.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),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 m2(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(r$.IND,()=>this.index()),this._parser.setExecuteHandler(r$.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(r$.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new q0(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new q0(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new q0(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new q0(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new q0(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new q0(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new q0(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new q0(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new q0(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new q0(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new q0(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new q0(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 p0)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 Z0((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`),d2))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${d2} 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>c2&&(a=this._parseStack.position+c2)}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<c2&&(this._parseBuffer=new Uint32Array(Math.min(e.length,c2))),o||this._dirtyRowTracker.clearRange(),e.length>c2)for(let t=a;t<e.length;t+=c2){let a=t+c2<e.length?t+c2: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=z0.extractWidth(t);let n=z0.extractShouldJoin(t),m=n?z0.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(nY(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 a0&&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=>!u2(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Z0(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new q0(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(n0));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=z0.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,m0),this._charsetService.setgCharset(1,m0),this._charsetService.setgCharset(2,m0),this._charsetService.setgCharset(3,m0);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|=cY.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=n0.fg,e.bg=n0.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|=n0.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=n0.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|=n0.fg&16777215,r.bg&=-67108864,r.bg|=n0.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=n0.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(!u2(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>l2&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>l2&&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(h2(n))if(r===`?`)t.push({type:0,index:n});else{let e=i2(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()&&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=i2(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]);h2(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,m0),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(s2[e[0]],p0[e[1]]||m0),!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=n0.clone(),this._eraseAttrDataInternal=n0.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 uY;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)}},m2=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&&(f2=e,e=t,t=f2),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};m2=WJ([Z(0,_Y)],m2);function h2(e){return 0<=e&&e<256}var g2=5e7,_2=12,v2=50,y2=class extends pX{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 Q),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>g2)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>=_2?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>=_2)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>v2&&(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()}},b2=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)))}};b2=WJ([Z(0,_Y)],b2);var x2=!1,S2=class extends pX{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new mX),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new Y1,this.optionsService=this._register(new C0(e)),this._instantiationService.setService(CY,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(b0)),this._instantiationService.setService(_Y,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Q1)),this._instantiationService.setService(SY,this._logService),this.coreService=this._register(this._instantiationService.createInstance(O0)),this._instantiationService.setService(yY,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(N0)),this._instantiationService.setService(vY,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(z0)),this._instantiationService.setService(TY,this.unicodeService),this._charsetService=this._instantiationService.createInstance(B0),this._instantiationService.setService(bY,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(b2),this._instantiationService.setService(wY,this._oscLinkService),this._inputHandler=this._register(new p2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(xX.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(xX.forward(this._bufferService.onResize,this._onResize)),this._register(xX.forward(this.coreService.onData,this._onData)),this._register(xX.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 y2((e,t)=>this._inputHandler.parse(e,t))),this._register(xX.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),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&&!x2&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),x2=!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,v0),t=Math.max(t,y0),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(V0.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(V0(this._bufferService),!1))),this._windowsWrappingHeuristics.value=uX(()=>{for(let t of e)t.dispose()})}}},C2={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 w2(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=C2[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 T2=0,E2=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new f1,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new f1,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||(T2=this._search(t),T2===-1)||this._getKey(this._array[T2])!==t)return!1;do if(this._array[T2]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(T2),!0;while(++T2<this._array.length&&this._getKey(this._array[T2])===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&&(T2=this._search(e),!(T2<0||T2>=this._array.length)&&this._getKey(this._array[T2])===e))do yield this._array[T2];while(++T2<this._array.length&&this._getKey(this._array[T2])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(T2=this._search(e),!(T2<0||T2>=this._array.length)&&this._getKey(this._array[T2])===e))do t(this._array[T2]);while(++T2<this._array.length&&this._getKey(this._array[T2])===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}},D2=0,O2=0,k2=class extends pX{constructor(){super(),this._decorations=new E2(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(uX(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new A2(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=>{D2=t.options.x??0,O2=D2+(t.options.width??1),e>=D2&&e<O2&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},A2=class extends fX{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),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=p$.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=p$.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},j2=1e3,M2=class{constructor(e,t=j2){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)}},N2=20,P2=class extends pX{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 M2(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);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(`
|
|
184
|
-
`))),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(
|
|
185
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===N2+1&&(this._liveRegion.textContent+=JJ.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})`}};P2=WJ([Z(1,xY),Z(2,AY),Z(3,MY)],P2);var F2=class extends pX{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 Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(uX(()=>{cX(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(rQ(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(rQ(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(rQ(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(rQ(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&&I2(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,cX(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||e.link.decorations.underline,pointerCursor:e.link.decorations===void 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}}};F2=WJ([Z(1,jY),Z(2,MY),Z(3,_Y),Z(4,IY)],F2);function I2(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 L2=class extends S2{constructor(e={}){super(e),this._linkifier=this._register(new mX),this.browser=Y$,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new mX),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(k2),this._instantiationService.setService(EY,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(W$),this._instantiationService.setService(IY,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(DY)),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(xX.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(xX.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(xX.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(xX.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(uX(()=>{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=f$.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${o2(r)}${i$.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=d$.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=d$.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(P2,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(rQ(this.element,`copy`,e=>{this.hasSelection()&&ZJ(e,this._selectionService)}));let e=e=>QJ(e,this.textarea,this.coreService,this.optionsService);this._register(rQ(this.textarea,`paste`,e)),this._register(rQ(this.element,`paste`,e)),$$?this._register(rQ(this.element,`mousedown`,e=>{e.button===2&&tY(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(rQ(this.element,`contextmenu`,e=>{tY(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),s1&&this._register(rQ(this.element,`auxclick`,e=>{e.button===1&&eY(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(rQ(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(rQ(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(rQ(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(rQ(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(rQ(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(rQ(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(rQ(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(rQ(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`,KJ.get()),c1||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(H$,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(AY,this._coreBrowserService),this._register(rQ(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(rQ(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(R$,this._document,this._helperContainer),this._instantiationService.setService(kY,this._charSizeService),this._themeService=this._instantiationService.createInstance(K1),this._instantiationService.setService(FY,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(y$),this._instantiationService.setService(PY,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(m1,this.rows,this.screenElement)),this._instantiationService.setService(MY,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(a$,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(q$),this._instantiationService.setService(jY,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(F2,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(XQ,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(I1,this.element,this.screenElement,r)),this._instantiationService.setService(NY,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(xX.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(ZQ,this.screenElement)),this._register(rQ(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(P2,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(n$,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(n$,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(L$,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(rQ(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(rQ(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){$J(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=w2(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)&&(R2(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(n0));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 R2(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var z2=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)}},B2=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 uY)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},V2=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 B2(t)}getNullCell(){return new uY}},H2=class extends pX{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new V2(this._core.buffers.normal,`normal`),this._alternate=new V2(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)}},U2=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)}},W2=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}},G2=[`cols`,`rows`],K2=0,q2=class extends pX{constructor(e){super(),this._core=this._register(new L2(e)),this._addonManager=this._register(new z2),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(G2.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 U2(this._core),this._parser}get unicode(){return this._checkProposedApi(),new W2(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 H2(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
|
|
184
|
+
`))),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(iQ(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(uX(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<N2+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
185
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===N2+1&&(this._liveRegion.textContent+=JJ.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})`}};P2=WJ([Z(1,xY),Z(2,AY),Z(3,MY)],P2);var F2=class extends pX{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 Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(uX(()=>{cX(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(iQ(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(iQ(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(iQ(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(iQ(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&&I2(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,cX(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||e.link.decorations.underline,pointerCursor:e.link.decorations===void 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}}};F2=WJ([Z(1,jY),Z(2,MY),Z(3,_Y),Z(4,IY)],F2);function I2(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 L2=class extends S2{constructor(e={}){super(e),this._linkifier=this._register(new mX),this.browser=Y$,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new mX),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(k2),this._instantiationService.setService(EY,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(W$),this._instantiationService.setService(IY,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(DY)),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(xX.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(xX.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(xX.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(xX.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(uX(()=>{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=f$.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${o2(r)}${i$.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=d$.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=d$.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(P2,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(iQ(this.element,`copy`,e=>{this.hasSelection()&&ZJ(e,this._selectionService)}));let e=e=>QJ(e,this.textarea,this.coreService,this.optionsService);this._register(iQ(this.textarea,`paste`,e)),this._register(iQ(this.element,`paste`,e)),$$?this._register(iQ(this.element,`mousedown`,e=>{e.button===2&&tY(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(iQ(this.element,`contextmenu`,e=>{tY(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),s1&&this._register(iQ(this.element,`auxclick`,e=>{e.button===1&&eY(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(iQ(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(iQ(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(iQ(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(iQ(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(iQ(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(iQ(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(iQ(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(iQ(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`,KJ.get()),c1||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(H$,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(AY,this._coreBrowserService),this._register(iQ(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(iQ(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(R$,this._document,this._helperContainer),this._instantiationService.setService(kY,this._charSizeService),this._themeService=this._instantiationService.createInstance(K1),this._instantiationService.setService(FY,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(y$),this._instantiationService.setService(PY,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(m1,this.rows,this.screenElement)),this._instantiationService.setService(MY,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(a$,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(q$),this._instantiationService.setService(jY,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(F2,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(XQ,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(I1,this.element,this.screenElement,r)),this._instantiationService.setService(NY,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(xX.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(ZQ,this.screenElement)),this._register(iQ(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(P2,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(n$,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(n$,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(L$,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(iQ(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(iQ(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){$J(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=w2(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)&&(R2(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(n0));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 R2(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var z2=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)}},B2=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 uY)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},V2=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 B2(t)}getNullCell(){return new uY}},H2=class extends pX{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new V2(this._core.buffers.normal,`normal`),this._alternate=new V2(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)}},U2=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)}},W2=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}},G2=[`cols`,`rows`],K2=0,q2=class extends pX{constructor(e){super(),this._core=this._register(new L2(e)),this._addonManager=this._register(new z2),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(G2.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 U2(this._core),this._parser}get unicode(){return this._checkProposedApi(),new W2(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 H2(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
|
|
186
186
|
`,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 KJ.get()},set promptLabel(e){KJ.set(e)},get tooMuchOutput(){return JJ.get()},set tooMuchOutput(e){JJ.set(e)}}}_verifyIntegers(...e){for(K2 of e)if(K2===1/0||isNaN(K2)||K2%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(K2 of e)if(K2&&(K2===1/0||isNaN(K2)||K2%1!=0||K2<0))throw Error(`This API only accepts positive integers`)}},J2=250,Y2=5e3,X2=8e3,Z2=3e3;function Q2(e){return`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}`}function $2(){return Q2(window.location)}var e4=class{opts;ws=null;backoff=J2;reconnectTimer=null;connectTimer=null;stallTimer=null;disposed=!1;ended=!1;receivedData=!1;url;constructor(e){this.opts=e;let t=e.wsBase??$2();this.url=`${t.replace(/\/$/,``)}/ws/terminal/${encodeURIComponent(e.sessionId)}`}connect(){if(this.disposed||this.ended)return;this.clearTimer(),this.opts.onStatus(this.backoff===J2?`connecting`:`reconnecting`);let e=new WebSocket(this.url);e.binaryType=`arraybuffer`,this.ws=e,this.connectTimer=setTimeout(()=>{e.readyState===WebSocket.CONNECTING&&this.forceClose(e)},X2),e.onopen=()=>{this.clearConnectTimer(),this.receivedData&&(this.receivedData=!1,this.opts.onReset?.())},e.onmessage=e=>{typeof e.data==`string`?this.handleControl(e.data):(this.receivedData=!0,this.opts.onData(new Uint8Array(e.data)))},e.onclose=()=>{this.ws=null,this.clearConnectTimer(),this.clearStallTimer(),!(this.disposed||this.ended)&&(this.opts.onStatus(`reconnecting`),this.scheduleReconnect())},e.onerror=()=>{this.forceClose(e)}}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.send(new TextEncoder().encode(e)),this.watchForStall())}resize(e,t){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.send(JSON.stringify({t:`resize`,cols:e,rows:t})),this.watchForStall())}dispose(){if(this.disposed=!0,this.clearTimer(),this.clearConnectTimer(),this.clearStallTimer(),this.ws){this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null;try{this.ws.close()}catch{}this.ws=null}}handleControl(e){let t;try{t=JSON.parse(e)}catch{return}t.t===`status`&&(t.status===`live`?(this.backoff=J2,this.opts.onStatus(`live`)):t.status===`ended`&&(this.ended=!0,this.opts.onStatus(`ended`)))}watchForStall(){this.stallTimer===null&&(this.stallTimer=setTimeout(()=>{this.stallTimer=null;let e=this.ws;!e||e.readyState!==WebSocket.OPEN||e.bufferedAmount>0&&this.forceClose(e)},Z2))}forceClose(e){try{e.close()}catch{}if(this.ws===e&&e.readyState===WebSocket.CLOSED){if(e.onclose=null,this.ws=null,this.disposed||this.ended)return;this.opts.onStatus(`reconnecting`),this.scheduleReconnect()}}scheduleReconnect(){this.clearTimer();let e=this.backoff;this.backoff=Math.min(this.backoff*2,Y2),this.reconnectTimer=setTimeout(()=>this.connect(),e)}clearTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}clearConnectTimer(){this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null)}clearStallTimer(){this.stallTimer!==null&&(clearTimeout(this.stallTimer),this.stallTimer=null)}},t4={dark:{"--color-surface-inset":`#0c0e14`,"--color-text":`#eceef4`,"--color-accent":`#4f8ef7`,"--color-accent-subtle":`#16213a`,"--color-surface-selected":`#212636`,"--color-danger":`#f06363`,"--color-success":`#46b67a`,"--color-warning":`#e2a53b`,"--color-accent-text":`#7aaafa`},light:{"--color-surface-inset":`#f4f6f9`,"--color-text":`#161a24`,"--color-accent":`#2f6fe4`,"--color-accent-subtle":`#ecf2fe`,"--color-surface-selected":`#e4e8f1`,"--color-danger":`#c42828`,"--color-success":`#1e8e53`,"--color-warning":`#a86a06`,"--color-accent-text":`#2463d6`}},n4={dark:{black:`#2a2a2f`,magenta:`#c68af0`,cyan:`#56c2d6`,white:`#d4d4d8`,brightBlack:`#6b6b74`,brightRed:`#ff8a8a`,brightGreen:`#72d49c`,brightYellow:`#f2c46e`,brightMagenta:`#d9a9f7`,brightCyan:`#86dbe8`,brightWhite:`#fafafa`},light:{black:`#18181b`,magenta:`#9337be`,cyan:`#0e7488`,white:`#52525b`,brightBlack:`#71717a`,brightRed:`#d63a3a`,brightGreen:`#1f9a5a`,brightYellow:`#b57308`,brightMagenta:`#a64ccf`,brightCyan:`#128399`,brightWhite:`#27272a`}};function r4(e){let t=typeof document>`u`?null:getComputedStyle(document.documentElement);return n=>t?.getPropertyValue(n).trim()||t4[e][n]||``}function i4(e,t=r4(e)){let n=t(`--color-surface-inset`);return{background:n,foreground:t(`--color-text`),cursor:t(`--color-accent`),cursorAccent:n,selectionBackground:t(`--color-accent-subtle`),selectionInactiveBackground:t(`--color-surface-selected`),red:t(`--color-danger`),green:t(`--color-success`),yellow:t(`--color-warning`),blue:t(`--color-accent`),brightBlue:t(`--color-accent-text`),...n4[e]}}function a4(e){return e.key===`v`||e.key===`V`||e.code===`KeyV`}function o4(e){let t=e.type===`keydown`;if(!t&&e.type!==`keypress`)return{intercept:!1};if(e.key===`Enter`&&(e.shiftKey||e.ctrlKey))return{intercept:!0,bytes:t?`\x1B\r`:``};if(yx(e))return{intercept:!0,bytes:``};if(a4(e)&&!e.shiftKey&&!e.metaKey){if(e.ctrlKey&&!e.altKey)return{intercept:!0,bytes:``};if(e.altKey&&!e.ctrlKey)return{intercept:!0,bytes:t?`\x1Bv`:``}}return{intercept:!1}}var s4=`"Geist Mono Variable", "Cascadia Code", Consolas, monospace`;function c4({sessionId:e,wsBase:t,onEnded:n}){let r=(0,L.useRef)(null),[i,a]=(0,L.useState)(`connecting`),o=(0,L.useRef)(n);o.current=n;let{resolved:s}=KM(),c=(0,L.useRef)(s);c.current=s;let l=(0,L.useRef)(null);(0,L.useEffect)(()=>{let e=l.current;e&&(e.options.theme=i4(s))},[s]),(0,L.useEffect)(()=>{let n=r.current;if(!n)return;let i=new q2({theme:i4(c.current),fontFamily:s4,fontSize:12.5,lineHeight:1.2,cursorBlink:!0,allowProposedApi:!0,scrollback:5e3});l.current=i;let s=new BJ;i.loadAddon(s),i.open(n);let u=()=>{try{s.fit()}catch{}};u();let d=requestAnimationFrame(u),f=!1;typeof document<`u`&&document.fonts?.check?.(`12px ${s4}`)||document.fonts?.load(`12px ${s4}`).then(()=>{f||(i.options.fontFamily=`monospace`,i.options.fontFamily=s4,u())});let p;p=new e4({sessionId:e,wsBase:t,onData:e=>i.write(e),onReset:()=>i.reset(),onStatus:e=>{a(e),e===`live`&&p.resize(i.cols,i.rows),e===`ended`&&o.current?.()}});let m=i.onData(e=>p.send(e)),h=i.onResize(({cols:e,rows:t})=>p.resize(e,t));i.attachCustomKeyEventHandler(e=>{let t=o4(e);return t.intercept?(t.bytes&&p.send(t.bytes),!1):!0}),p.connect();let g=new ResizeObserver(()=>u());return g.observe(n),()=>{f=!0,l.current=null,cancelAnimationFrame(d),g.disconnect(),m.dispose(),h.dispose(),p.dispose(),i.dispose()}},[e,t]);let u=i===`connecting`?{text:`Connecting…`,tone:`dim`}:i===`reconnecting`?{text:`Disconnected — reconnecting… keystrokes are dropped until the stream is back`,tone:`down`}:i===`ended`?{text:`Session stream ended — relaunch or end the session above`,tone:`dim`}:null;return(0,R.jsxs)(`div`,{className:q(`relative box-border h-full w-full overflow-hidden bg-surface-inset pt-2 pr-0.5 pb-1.5 pl-2.5`,`[&_.xterm-viewport]:bg-transparent!`),children:[(0,R.jsx)(`div`,{ref:r,className:`h-full w-full`,"data-session-id":e}),u&&(0,R.jsx)(`div`,{role:`status`,className:q(`pointer-events-none absolute inset-x-0 top-0 px-2.5 py-1 text-xs animate-fade-in`,u.tone===`down`?`bg-danger-subtle text-danger`:`border-b border-border-subtle bg-surface-inset text-text-tertiary`),children:u.text})]})}function l4({text:e}){let t=e?.trim();return t?(0,R.jsxs)(Rj,{title:`How to drive this app`,icon:(0,R.jsx)(mb,{}),aside:(0,R.jsx)(nI,{location:{page:`project`,field:`driveInstructions`},children:`Edit in settings`}),children:[(0,R.jsx)(CK,{source:t}),(0,R.jsx)(`p`,{className:`m-0 mt-2 text-xs text-text-tertiary`,children:ym})]}):null}function u4({featureId:e,label:t}){let n=B.useUtils(),r=gx(),i=B.feature.testDrive.useMutation({onSuccess:()=>{n.feature.driveInfo.invalidate(),n.feature.get.invalidate({id:e})},onError:e=>r.push(e.message)});return(0,R.jsx)(Y,{className:`self-start`,icon:(0,R.jsx)(Tb,{}),loading:i.isPending,onClick:()=>i.mutate({featureId:e,action:`stop`}),children:t})}function d4({featureId:e,failure:t,readonly:n}){let r=B.useUtils(),i=gx(),a=Ex(e),o=B.feature.fixDrive.useMutation({onSuccess:()=>{r.feature.get.invalidate({id:e}),r.events.invalidate(),a()},onError:e=>i.push(e.message)});return(0,R.jsx)(f4,{failure:t,explanation:(0,R.jsxs)(R.Fragment,{children:[`The branch is checked out, but `,(0,R.jsx)(`code`,{className:`font-mono`,children:t.command}),` `,t.outcome,` — so whatever it was meant to bring up is probably not running. An agent can read this failure on your machine, repair the environment and retry the drive.`]}),children:!n&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.canFix&&(0,R.jsx)(Y,{icon:(0,R.jsx)(Gb,{}),loading:o.isPending,onClick:()=>o.mutate({featureId:e}),children:`Fix drive`}),(0,R.jsx)(u4,{featureId:e,label:`Stop test drive`})]})})}function f4({failure:e,explanation:t,children:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(HA,{tone:`danger`,size:`sm`,strong:!0,children:`Drive setup failed`}),(0,R.jsx)(`div`,{className:`text-sm text-pretty text-text-secondary`,children:t})]}),e.output&&(0,R.jsx)(Rj,{title:`What the command printed`,icon:(0,R.jsx)(mb,{}),children:(0,R.jsx)(`pre`,{className:`m-0 max-h-55 overflow-auto rounded-md bg-surface-inset px-3 py-2.5 font-mono text-xs whitespace-pre-wrap text-text-secondary`,children:e.output})}),n]})}function p4({branch:e,drive:t}){let[n,r]=(0,L.useState)(!1),i=Mv(t);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-7 flex-wrap items-center gap-x-4 gap-y-1 text-xs text-text-tertiary`,children:[t?.devPaneId&&(0,R.jsx)(HA,{tone:`live`,children:`Dev server`}),(0,R.jsx)(`span`,{className:`truncate font-mono`,children:e}),i&&(0,R.jsx)(`span`,{className:`truncate font-mono`,children:i.state===`ready`?i.url:Nv(i)}),(0,R.jsx)(`span`,{className:`flex-1`}),t?.devPaneId&&(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(mb,{}),"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Hide output`:`Show output`})]}),n&&t?.devPaneId&&(0,R.jsx)(`div`,{className:`relative h-105 min-h-65 overflow-hidden rounded-md bg-surface-inset animate-rise-in`,children:(0,R.jsx)(LJ,{label:`dev terminal`,children:(0,R.jsx)(c4,{sessionId:t.devPaneId})})})]})}function m4(e){let t=e;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable===!0}function h4(e,t){let n=e?.expanded??!1,r=e?.set;(0,L.useEffect)(()=>{if(!t||!r)return;let e=e=>{m4(e.target)||e.metaKey||e.ctrlKey||e.altKey||(e.key===`f`||e.key===`F`?(e.preventDefault(),r(!n)):e.key===`Escape`&&n&&(e.preventDefault(),r(!1)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n,r])}var g4=(e=`pen`)=>({tool:e,shapes:[],redo:[],text:``});function _4(e,t){return{...e,shapes:[...e.shapes,{tool:e.tool,points:[t]}],redo:[]}}function v4(e,t){if(e.shapes.length===0)return e;let n=e.shapes.slice(),r=n[n.length-1];return n[n.length-1]={...r,points:[...r.points,t]},{...e,shapes:n}}function y4(e){return e}function b4(e){let t=e.shapes.at(-1);return t?{...e,shapes:e.shapes.slice(0,-1),redo:[...e.redo,t]}:e}function x4(e){let t=e.redo.at(-1);return t?{...e,shapes:[...e.shapes,t],redo:e.redo.slice(0,-1)}:e}var S4=e=>({...e,shapes:[],redo:[]}),C4=(e,t)=>({...e,tool:t}),w4=(e,t)=>({...e,text:t}),T4=e=>e.shapes.length>0||e.text.trim().length>0,E4=T4;function D4(e,t){switch(t.kind){case`begin`:return _4(e,t.point);case`extend`:return v4(e,t.point);case`commit`:return y4(e);case`undo`:return b4(e);case`redo`:return x4(e);case`clear`:return S4(e);case`tool`:return C4(e,t.tool);case`text`:return w4(e,t.text)}}var O4=[{tool:`pen`,label:`Pen`,key:`P`,icon:(0,R.jsx)(Qb,{})},{tool:`arrow`,label:`Arrow`,key:`A`,icon:(0,R.jsx)($b,{})},{tool:`rect`,label:`Rect`,key:`R`,icon:(0,R.jsx)(ex,{})}],k4=`pointer-events-auto flex items-center gap-0.5 rounded-lg bg-surface-raised p-1 shadow-popover`,A4={p:`pen`,a:`arrow`,r:`rect`};function j4({video:e,timestamp:t,onSave:n,onCancel:r}){let[i,a]=(0,L.useReducer)(D4,void 0,()=>g4()),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(null),f=(0,L.useRef)(null),p=(0,L.useRef)(!1),m=e=>{let t=e.getBoundingClientRect();return t.width>0?e.width/t.width:1};(0,L.useEffect)(()=>{let t=f.current;if(!t)return;t.width!==e.videoWidth&&(t.width=e.videoWidth),t.height!==e.videoHeight&&(t.height=e.videoHeight);let n=t.getContext(`2d`);n&&(n.clearRect(0,0,t.width,t.height),hI(n,i.shapes,m(t)))},[i.shapes,e]);let h=e=>{let t=f.current;return t?bI(t.getBoundingClientRect(),{width:t.width,height:t.height},{x:e.clientX,y:e.clientY}):null},g=e=>{let t=h(e);t&&(f.current?.setPointerCapture?.(e.pointerId),p.current=!0,a({kind:`begin`,point:t}))},_=e=>{if(!p.current)return;let t=h(e);t&&a({kind:`extend`,point:t})},v=e=>{if(!p.current)return;p.current=!1;let t=f.current;t?.hasPointerCapture?.(e.pointerId)&&t.releasePointerCapture(e.pointerId),a({kind:`commit`})},y=()=>{E4(i)?l(!0):r()},b=async()=>{let t=f.current;if(!(!T4(i)||o||!t)){s(!0),d(null);try{await n(await xI(document.createElement(`canvas`),e,i.shapes,m(t)),i.text.trim())}catch(e){d(e instanceof Error?e.message:`the annotated frame could not be saved`)}finally{s(!1)}}};return(0,L.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),c?l(!1):y();return}let t=e.target;if(t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable===!0||e.metaKey||e.ctrlKey||e.altKey)return;let n=A4[e.key.toLowerCase()];n&&(e.preventDefault(),a({kind:`tool`,tool:n}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,i,r]),(0,R.jsxs)(`div`,{className:`absolute inset-0 z-20`,"data-testid":`annotation-overlay`,children:[(0,R.jsx)(`canvas`,{ref:f,"aria-label":`draw on this frame`,className:`absolute inset-0 h-full w-full cursor-crosshair touch-none`,onPointerDown:g,onPointerMove:_,onPointerUp:v,onPointerCancel:v}),(0,R.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 flex flex-wrap items-center gap-2 p-3 animate-fade-in`,children:[(0,R.jsxs)(`div`,{className:k4,children:[O4.map(({tool:e,label:t,key:n,icon:r})=>(0,R.jsx)(UE,{label:t,kbd:n,icon:r,active:i.tool===e,tooltipSide:`bottom`,onClick:()=>a({kind:`tool`,tool:e})},e)),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`mx-1 h-4 w-px bg-border`}),(0,R.jsx)(UE,{label:`Undo`,icon:(0,R.jsx)(ub,{}),tooltipSide:`bottom`,disabled:i.shapes.length===0,onClick:()=>a({kind:`undo`})}),(0,R.jsx)(UE,{label:`Redo`,icon:(0,R.jsx)(tx,{}),tooltipSide:`bottom`,disabled:i.redo.length===0,onClick:()=>a({kind:`redo`})}),(0,R.jsx)(UE,{label:`Clear`,icon:(0,R.jsx)(lb,{}),tooltipSide:`bottom`,disabled:i.shapes.length===0,onClick:()=>a({kind:`clear`})})]}),(0,R.jsx)(`span`,{className:`pointer-events-none rounded-md bg-surface-raised px-2 py-1 font-mono text-xs text-text-secondary tabular-nums shadow-popover`,children:cf(t)})]}),(0,R.jsxs)(`div`,{className:`absolute inset-x-3 bottom-3 flex flex-col gap-2 rounded-lg bg-surface-raised p-2 shadow-popover animate-rise-in`,children:[u&&(0,R.jsx)(`p`,{className:`m-0 px-1 text-sm text-danger`,role:`alert`,children:u}),(0,R.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,R.jsx)(mj,{rows:2,"aria-label":`what’s wrong in this frame?`,className:`min-w-0 flex-1 resize-none`,placeholder:`What’s wrong in this frame? A drawing alone saves too.`,value:i.text,autoFocus:!0,onChange:e=>a({kind:`text`,text:e.target.value}),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),b())}}),(0,R.jsx)(Y,{variant:`ghost`,onClick:y,children:`Cancel`}),(0,R.jsx)(Y,{variant:`primary`,loading:o,disabled:!T4(i),onClick:()=>void b(),children:o?`Saving…`:`Save note`})]})]}),(0,R.jsxs)(Hj,{open:c,onClose:()=>l(!1),size:`sm`,label:`Discard this annotation?`,children:[(0,R.jsx)(Uj,{title:`Discard this annotation?`,description:`The drawing and the words go with it.`}),(0,R.jsxs)(Gj,{children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:()=>l(!1),children:`Keep editing`}),(0,R.jsx)(Y,{variant:`danger`,onClick:r,children:`Discard`})]})]})]})}var M4=[.5,.75,1,1.25,1.5,1.75,2],N4=1.5,P4=5,F4=1/30;function I4(e,t){let n=M4.indexOf(e);return M4[((n===-1?M4.indexOf(N4):n)+t+M4.length)%M4.length]}function L4({url:e,featureId:t,ticketId:n,passKind:r,readonly:i,frameClassName:a,expand:o,markers:s=[],onMarkerClick:c,onAnnotationSaved:l,onDuration:u,handleRef:d}){let f=B.useUtils(),p=gx(),m=(0,L.useRef)(null),[h,g]=(0,L.useState)(!1),[_,v]=(0,L.useState)(0),[y,b]=(0,L.useState)(0),[x,S]=(0,L.useState)(N4),[C,w]=(0,L.useState)(`loading`),[T,E]=(0,L.useState)(null),[D,O]=(0,L.useState)(!1),[k,A]=(0,L.useState)(null),j=B.notes.add.useMutation({onError:e=>p.push(e.message)});(0,L.useEffect)(()=>{let t=!0;return fetch(e,{method:`HEAD`}).then(e=>{let n=Number(e.headers.get(`content-length`));t&&Number.isFinite(n)&&n>0&&E(n)}).catch(()=>void 0),()=>{t=!1}},[e]);let M=(0,L.useCallback)(e=>{let t=m.current;if(!t)return;let n=yI(e,{playable:vI(t),annotating:D});n!==null&&(t.currentTime=n,v(n))},[D]),N=(0,L.useCallback)(e=>{m.current?.pause(),M(e)},[M]);(0,L.useEffect)(()=>{if(d)return d.current={seek:N,pause:()=>m.current?.pause(),getTicketId:()=>n},()=>{d.current=null}},[d,N,n]);let P=(0,L.useCallback)(()=>{let e=m.current;!e||D||C!==`ready`||(e.paused?e.play().catch(()=>p.push(`the browser refused to play this recording`)):e.pause())},[D,C,p]),ee=(0,L.useCallback)(e=>{let t=m.current;t&&M(t.currentTime+e)},[M]),F=(0,L.useCallback)(e=>{let t=m.current;t?.paused&&M(t.currentTime+e)},[M]),I=(0,L.useCallback)(e=>{S(e);let t=m.current;t&&(t.playbackRate=e)},[]),te=()=>{C===`ready`&&(m.current?.pause(),O(!0))};h4(o,!D),(0,L.useEffect)(()=>{if(D)return;let e=e=>{if(m4(e.target)||e.metaKey||e.ctrlKey||e.altKey)return;let t=()=>e.preventDefault();switch(e.key){case` `:case`k`:case`K`:return t(),P();case`j`:case`J`:case`ArrowLeft`:return t(),ee(-5);case`l`:case`L`:case`ArrowRight`:return t(),ee(P4);case`,`:return t(),F(-.03333333333333333);case`.`:return t(),F(F4);case`<`:return t(),I(I4(x,-1));case`>`:return t(),I(I4(x,1))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[D,P,ee,F,I,x]);let ne=()=>{w(`loading`),m.current?.load()},re=async(e,r)=>{let i=m.current;if(!i)return;let a=i.currentTime,o=await SI({createNote:()=>j.mutateAsync({featureId:t,text:r||`Annotated ${cf(a)}`,videoTimestamp:a,reviewTicketId:n}),uploadScreenshot:t=>hh(t,e)});f.notes.list.invalidate({featureId:t}),o.uploadError&&p.push(`the note was saved, but its annotated frame was not: ${o.uploadError}`),O(!1),l?.(o.note.id)},ie=e=>{let t=vI(e);b(t),u?.(t)},ae=y>0&&!D&&C===`ready`,oe=T===null?`Loading the recording`:`Loading the recording — ${Ph(T)}`;return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 animate-fade-in`,children:[(0,R.jsxs)(`div`,{className:a,children:[(0,R.jsx)(`video`,{ref:m,className:`min-h-0 w-full flex-1 cursor-pointer object-contain`,src:e,preload:`metadata`,"aria-label":r===`verification`?`verification walkthrough`:`review walkthrough`,onClick:P,onLoadedMetadata:e=>{let t=e.currentTarget;ie(t),t.playbackRate=x,t.currentTime===0&&(t.currentTime=.01)},onDurationChange:e=>ie(e.currentTarget),onProgress:e=>ie(e.currentTarget),onCanPlay:()=>w(e=>e===`error`?e:`ready`),onError:()=>w(`error`),onTimeUpdate:e=>v(e.currentTarget.currentTime),onPlay:()=>g(!0),onPause:()=>g(!1),onEnded:()=>g(!1)}),C===`loading`&&(0,R.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 bg-surface-inset/70 animate-fade-in`,children:[(0,R.jsx)(KE,{}),(0,R.jsx)(`span`,{className:`text-sm text-text-secondary`,children:oe})]}),C===`error`&&(0,R.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-1.5 bg-surface-inset px-6 text-center animate-fade-in`,role:`alert`,children:[(0,R.jsx)(`span`,{className:`text-base font-medium text-text`,children:`This recording can’t be played`}),(0,R.jsx)(`span`,{className:`text-sm text-text-tertiary`,children:`The file may be corrupt.`}),(0,R.jsx)(`code`,{className:`max-w-full truncate font-mono text-xs text-text-tertiary`,children:e}),(0,R.jsx)(Y,{className:`mt-2`,icon:(0,R.jsx)(Gb,{}),onClick:ne,children:`Retry`})]}),D&&m.current&&(0,R.jsx)(j4,{video:m.current,timestamp:_,onSave:re,onCancel:()=>O(!1)})]}),(0,R.jsxs)(`div`,{className:`flex h-(--control-lg) items-center gap-3`,children:[(0,R.jsx)(UE,{label:h?`pause`:`play`,kbd:`K`,icon:h?(0,R.jsx)(Jb,{}):(0,R.jsx)(wb,{}),disabled:D||C!==`ready`,onClick:P}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-text-secondary tabular-nums`,children:cf(_)}),(0,R.jsxs)(`div`,{className:`relative flex h-full flex-1 items-center`,onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();t.width<=0||y<=0||A((e.clientX-t.left)/t.width*y)},onMouseLeave:()=>A(null),children:[(0,R.jsx)(`input`,{type:`range`,className:`h-1 w-full cursor-pointer accent-accent disabled:cursor-default disabled:opacity-50`,min:0,step:1,max:y||1,value:Math.min(_,y||1),disabled:!ae,"aria-label":`scrub the walkthrough`,onChange:e=>M(Number(e.target.value))}),k!==null&&(0,R.jsx)(`span`,{className:`pointer-events-none absolute -top-5 -translate-x-1/2 rounded-sm bg-surface-raised px-1.5 font-mono text-xs text-text-secondary tabular-nums shadow-popover`,style:{left:`${Math.min(100,Math.max(0,k/(y||1)*100))}%`},children:cf(k)}),y>0&&s.map(e=>(0,R.jsx)(`button`,{type:`button`,className:e.noteIds.length>1?`absolute top-1/2 flex size-4 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full bg-accent text-xs leading-none text-on-primary transition-transform duration-(--dur-1) ease-app hover:scale-110`:`absolute top-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 cursor-pointer rounded-full bg-accent ring-2 ring-surface transition-transform duration-(--dur-1) ease-app hover:scale-125`,style:{left:`${Math.min(100,e.at/y*100)}%`},"aria-label":`${e.noteIds.length} note${e.noteIds.length>1?`s`:``} at ${cf(e.at)}`,title:`${e.noteIds.length} note${e.noteIds.length>1?`s`:``} at ${cf(e.at)}`,onClick:()=>{N(e.at),c?.(e.noteIds)},children:e.noteIds.length>1?e.noteIds.length:``},e.at))]}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-text-tertiary tabular-nums`,children:cf(y)}),(0,R.jsxs)(Y,{size:`sm`,variant:`ghost`,className:`font-mono tabular-nums`,"aria-label":`playback speed ${x}×`,title:`Playback speed (< and >)`,onClick:()=>I(I4(x,1)),children:[x,`×`]}),!i&&!D&&(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(_b,{}),onClick:te,children:`Annotate`})]})]})}function R4(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function z4(e,t,n,r){let i=r>0&&n>0?n/r:1;return{x:Math.round((e.x+t.left)*i),y:Math.round((e.y+t.top)*i),width:Math.round(e.width*i),height:Math.round(e.height*i)}}function B4(e){return e.width>=8&&e.height>=8}function V4(e){return e?typeof e.mediaDevices?.getDisplayMedia==`function`&&`userAgentData`in e:!1}var H4=6e3,U4=120;function W4(e){return new Promise(t=>{if(typeof e.requestVideoFrameCallback==`function`){e.requestVideoFrameCallback(()=>t());return}setTimeout(t,U4)})}function G4({url:e,agentDriving:t=!1,readonly:n=!1,...r}){let i=gx(),a=B.useUtils(),o=B.notes.add.useMutation(),s=(0,L.useRef)(null),c=(0,L.useRef)(null),l=(0,L.useRef)(null),[u]=(0,L.useState)(()=>!n&&V4(typeof navigator>`u`?void 0:navigator)),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(null),_=(0,L.useRef)(null),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(``),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(!1),[E,D]=(0,L.useState)(!1),[O,k]=(0,L.useState)(0);(0,L.useEffect)(()=>{T(!1),D(!1);let e=setTimeout(()=>D(!0),H4);return()=>clearTimeout(e)},[e,O]),(0,L.useEffect)(()=>()=>{l.current?.getTracks().forEach(e=>e.stop()),l.current=null},[]),(0,L.useEffect)(()=>()=>URL.revokeObjectURL(v?.preview??``),[v]);let A=async()=>{if(!l.current){f(!0);try{let e=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:`browser`},audio:!1,preferCurrentTab:!0,selfBrowserSurface:`include`});l.current=e,e.getVideoTracks().forEach(t=>{t.addEventListener(`ended`,()=>{l.current===e&&(l.current=null)})});let t=c.current;t&&(t.srcObject=e,await t.play())}catch(e){i.push(e instanceof Error&&e.name===`NotAllowedError`?`tab sharing was declined — nothing to capture from`:`tab capture failed: ${e instanceof Error?e.message:String(e)}`);return}finally{f(!1)}}m(!0)},j=async e=>{let t=s.current,n=c.current;if(!t||!n)return;if(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),await W4(n),!n.videoWidth){i.push(`the tab is no longer being shared — click Select area again`),l.current=null;return}let r=z4(e,t.getBoundingClientRect(),n.videoWidth,window.innerWidth),a=document.createElement(`canvas`);a.width=r.width,a.height=r.height;let o=a.getContext(`2d`);if(!o)return;o.drawImage(n,r.x,r.y,r.width,r.height,0,0,r.width,r.height);let u=await new Promise(e=>a.toBlob(e,`image/png`));if(!u){i.push(`the selected region could not be turned into a picture`);return}x(``),y({png:u,preview:URL.createObjectURL(u)})},M=e=>{let t=s.current?.getBoundingClientRect();t&&(_.current={x:e.clientX-t.left,y:e.clientY-t.top},e.currentTarget.setPointerCapture?.(e.pointerId))},N=e=>{let t=s.current?.getBoundingClientRect();!_.current||!t||g(R4(_.current,{x:e.clientX-t.left,y:e.clientY-t.top}))},P=e=>{let t=s.current?.getBoundingClientRect(),n=_.current;if(_.current=null,!n||!t)return;let r=R4(n,{x:e.clientX-t.left,y:e.clientY-t.top});m(!1),g(null),B4(r)&&j(r)},ee=()=>{y(null),x(``)},F=async()=>{if(!v||S)return;C(!0);let e=b.trim()||`Screenshot from the test drive`;try{let t;if(r.projectId!==void 0){let n=r.projectId;t=await SI({createNote:()=>a.client.projectNotes.add.mutate({projectId:n,text:e}),uploadScreenshot:e=>vx(e,v.png)}),a.projectNotes.invalidate()}else{let n=r.featureId;t=await SI({createNote:()=>o.mutateAsync({featureId:n,text:e}),uploadScreenshot:e=>hh(e,v.png)}),a.notes.list.invalidate({featureId:n})}t.uploadError&&i.push(`the note was saved, but its screenshot was not: ${t.uploadError}`),ee()}catch(e){i.push(e instanceof Error?e.message:`the note could not be saved`)}finally{C(!1)}};return(0,R.jsxs)(`div`,{ref:s,className:`relative flex min-h-0 flex-1 flex-col overflow-hidden rounded-md bg-surface-inset`,children:[(0,R.jsx)(`iframe`,{className:`min-h-0 flex-1 border-0`,src:e,title:`the app on this branch`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,onLoad:()=>T(!0)},O),(0,R.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 flex flex-wrap items-center gap-2 p-3`,children:[(0,R.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-0.5 rounded-lg bg-surface-raised p-1 shadow-popover`,children:[u?(0,R.jsx)(UE,{label:d?`Sharing…`:p?`Drag a region`:`Select area`,icon:(0,R.jsx)(nx,{}),active:p,disabled:d,tooltipSide:`bottom`,onClick:()=>void A()}):null,(0,R.jsx)(UE,{label:`Reload`,icon:(0,R.jsx)(Gb,{}),tooltipSide:`bottom`,onClick:()=>k(e=>e+1)}),(0,R.jsx)(UE,{label:`Open app`,href:e,target:`_blank`,icon:(0,R.jsx)(Pb,{}),tooltipSide:`bottom`})]}),!u&&!n&&(0,R.jsx)(`span`,{className:`pointer-events-none rounded-md bg-surface-raised px-2 py-1 text-xs text-text-tertiary shadow-popover`,children:`This browser can’t capture its own tab — paste a screenshot into a note instead`}),t&&(0,R.jsx)(`span`,{className:`pointer-events-none rounded-md bg-surface-raised px-2 py-1 shadow-popover`,children:(0,R.jsx)(HA,{tone:`live`,children:`Review agent driving — notes land as it finds things`})}),!w&&E&&(0,R.jsx)(`span`,{className:`pointer-events-none rounded-md bg-surface-raised px-2 py-1 text-xs text-text-tertiary shadow-popover`,children:`Can’t embed? Open the app and paste a screenshot into a note.`})]}),p&&(0,R.jsx)(`div`,{className:`absolute inset-0 z-10 cursor-crosshair touch-none bg-scrim/20 animate-fade-in`,"aria-label":`drag over the part of the app that needs fixing`,onPointerDown:M,onPointerMove:N,onPointerUp:P,onPointerCancel:P,children:h&&(0,R.jsx)(`div`,{className:`absolute rounded-sm border-2 border-accent bg-accent-subtle/40`,style:{left:h.x,top:h.y,width:h.width,height:h.height}})}),v&&(0,R.jsxs)(`div`,{className:`absolute inset-x-3 bottom-3 z-20 flex items-end gap-3 rounded-lg bg-surface-raised p-2 shadow-popover animate-rise-in`,children:[(0,R.jsx)(`img`,{className:`h-14 w-24 rounded-md bg-surface-inset object-contain`,src:v.preview,alt:`the region you selected`}),(0,R.jsx)(mj,{rows:2,"aria-label":`what’s wrong here?`,className:`min-w-0 flex-1 resize-none`,placeholder:`What’s wrong here? Optional — the picture is the note.`,value:b,autoFocus:!0,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),F())}}),(0,R.jsx)(Y,{variant:`ghost`,onClick:ee,children:`Discard`}),(0,R.jsx)(Y,{variant:`primary`,loading:S,onClick:()=>void F(),children:S?`Saving…`:`Save note`})]}),u&&(0,R.jsx)(`video`,{ref:c,muted:!0,playsInline:!0,className:`hidden`})]})}function K4(e,t){return Vv(e).stageKind===`player`&&t?`player`:`drive`}function q4(e,t){return`relative flex w-full flex-col rounded-md bg-surface-inset ${e?`min-h-0 flex-1`:`aspect-video max-h-[calc(100vh-320px)]`} ${t===`screen`?`overflow-hidden`:`overflow-auto p-6`}`}function J4(e,t,n){let r=[`Lap ${e.lap}`,e.passKind===`verification`?`Verification walkthrough`:`Walkthrough`];return t!==null&&t>0&&r.push(cf(t)),e.passKind===`verification`&&n!==null&&n>0&&r.push(`confirms ${n} fix${n===1?``:`es`}`),r.push(e.landedSince===0?`this build`:`reviewed ${e.reviewedCommit?e.reviewedCommit.slice(0,7):`an earlier build`}`),r.join(` · `)}function Y4({featureId:e,branch:t,recordings:n,picked:r=null,notes:i,readonly:a,driveState:o,drive:s,dryRun:c,failure:l,expand:u,handleRef:d,onStageRecording:f,onMarkerClick:p,onAnnotationSaved:m}){let[h,g]=(0,L.useState)(null),_=oy(n),v=n.find(e=>e.ticketId===r)??_,y=K4(o,!!v?.videoUrl);(0,L.useEffect)(()=>g(null),[v?.ticketId]);let b=v?n.indexOf(v):-1,x=b>0?n[b-1]:void 0,S=v&&x?x.landedSince-v.landedSince:null,C=Vv(o),w=C.stageKind===`panel`||C.stageKind===`agent`,T=y===`player`&&v?.videoUrl?v.ticketId:null;(0,L.useEffect)(()=>{f?.(T?{ticketId:T}:null)},[f,T]),h4(u,y!==`player`);let E=u?.expanded??!1;return(0,R.jsxs)(`section`,{id:`evidence-stage`,className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,R.jsxs)(`header`,{className:`flex min-h-7 flex-wrap items-center gap-x-4 gap-y-2`,children:[v&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-sm text-text-secondary`,title:v.passKind===`verification`?`the fix count is derived from what landed between the two passes`:void 0,children:J4(v,h,S)}),u&&(0,R.jsx)(UE,{className:`ml-auto`,label:E?`Collapse`:`Expand`,kbd:`F`,icon:E?(0,R.jsx)(Xb,{}):(0,R.jsx)(Yb,{}),active:E,onClick:()=>u.set(!E)})]}),y===`player`&&v?.videoUrl?(0,R.jsx)(L4,{url:v.videoUrl,featureId:e,ticketId:v.ticketId,passKind:v.passKind,readonly:a,frameClassName:q4(E,`screen`),expand:u,markers:_I(i,v.ticketId),onMarkerClick:p,onAnnotationSaved:m,onDuration:g,handleRef:d},v.ticketId):(0,R.jsx)(`div`,{className:q4(E,w?`screen`:`prose`),children:(0,R.jsx)(X4,{featureId:e,branch:t,driveState:o,drive:s,dryRun:c,failure:l,hasRecording:!!v?.videoUrl,readonly:a})}),C.footer.showDevChip&&(0,R.jsx)(p4,{branch:s?.branch??t,drive:s})]})}function X4({featureId:e,branch:t,driveState:n,drive:r,dryRun:i,failure:a,hasRecording:o,readonly:s}){if(n===`idle`)return i?(0,R.jsx)(`div`,{className:`text-sm text-text-secondary`,children:`A preparation dry-run is holding the drive — it is proving this project’s drive commands on your machine. Stop it from Preparation, and this branch can take the wheel.`}):o?(0,R.jsx)(`div`,{className:`font-mono text-xs text-text-tertiary`,children:t}):(0,R.jsx)(HA,{spinning:!0,size:`sm`,children:`Starting the test drive — the branch is being checked out`});let c=s?null:(0,R.jsx)(u4,{featureId:e,label:`Stop test drive`});switch(Vv(n).stageKind){case`starting`:return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(HA,{spinning:!0,size:`sm`,strong:!0,children:`Starting the dev server`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-xs text-text-tertiary`,children:r?.branch??t})]}),(0,R.jsx)(`div`,{className:`text-sm text-text-secondary`,children:`The branch is checked out and the project’s dev command is running. The app appears here as soon as it answers — its output is under the stage.`})]});case`failed`:return a?(0,R.jsx)(d4,{featureId:e,failure:a,readonly:s}):(0,R.jsx)(`div`,{className:`text-sm text-text-secondary`,children:`The drive’s setup command failed — its output is in the timeline.`});case`bare`:return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(HA,{tone:`neutral`,size:`sm`,strong:!0,children:`Branch checked out — nothing started`}),(0,R.jsx)(`div`,{className:`text-sm text-text-secondary`,children:s?`This project had no dev command, so the drive checked the branch out and started nothing.`:(0,R.jsxs)(R.Fragment,{children:[`This project has no dev command ·`,` `,(0,R.jsx)(nI,{location:{page:`project`,field:`devCommand`},children:`Set one in Settings`}),` `,`and the next drive boots the app right here.`]})}),c]});case`agent`:return(0,R.jsxs)(R.Fragment,{children:[r?.devUrl?(0,R.jsx)(G4,{featureId:e,url:r.devUrl,agentDriving:!0,readonly:s}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 p-6`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(HA,{tone:`live`,size:`sm`,strong:!0,children:`Review agent driving`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-xs text-text-tertiary`,children:r?.branch??t})]}),(0,R.jsx)(`div`,{className:`text-sm text-text-secondary`,children:`Notes land below as it finds things. No dev server answered, so there is nothing to show here.`})]}),!s&&(0,R.jsx)(`div`,{className:`p-2`,children:(0,R.jsx)(u4,{featureId:e,label:`Stop the review drive`})})]});default:return r?.devUrl?(0,R.jsx)(G4,{featureId:e,url:r.devUrl,readonly:s}):(0,R.jsx)(`div`,{className:`p-6 text-sm text-text-secondary`,children:`The dev server is up but has not printed an address yet — its output is under the stage.`})}}function Z4({account:e,tickets:t,observations:n=[],carried:r}){let i=t.filter(e=>e.kind!==`review`&&(e.digest??``).trim().length>0).sort((e,t)=>e.seq-t.seq),a=!!e||i.length>0;if(!a&&!r&&n.length===0)return null;let o=[a?`digest`:null,r?`carried`:null,n.length>0?`${n.length} observation${n.length===1?``:`s`}`:null].filter(e=>e!==null);return(0,R.jsx)(`div`,{id:`full-accounts`,children:(0,R.jsx)(Rj,{title:`Full account`,icon:(0,R.jsx)(gb,{}),aside:o.join(` · `),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-6 pt-1`,children:[e&&(0,R.jsx)($4,{account:e}),i.length>0&&(0,R.jsxs)(`section`,{children:[(0,R.jsx)($A,{children:`Ticket digests`}),(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-5`,children:i.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`text-sm font-medium text-text`,children:[`#`,e.seq,` `,e.title,(0,R.jsxs)(`span`,{className:`ml-2 font-normal text-text-tertiary`,children:[`lap `,e.lap]})]}),(0,R.jsx)(CK,{source:e.digest.trim(),className:`mt-2`})]},e.seq))})]}),r&&(0,R.jsxs)(`section`,{children:[(0,R.jsx)($A,{children:`Carried, quick-fixed and handled`}),(0,R.jsx)(`div`,{className:`mt-2`,children:r})]}),n.length>0&&(0,R.jsxs)(`section`,{children:[(0,R.jsx)($A,{count:n.length,children:`Observations`}),(0,R.jsx)(`ul`,{className:`m-0 mt-2 flex list-none flex-col gap-2 p-0`,children:n.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm text-text`,children:e.title}),(0,R.jsx)(Q4,{detail:e.detail})]},e.id))})]})]})})})}function Q4({detail:e}){let{head:t,rest:n}=Ty(e);return n?(0,R.jsx)(Rj,{bare:!0,title:(0,R.jsx)(`span`,{className:`font-normal text-text-tertiary`,children:t}),children:(0,R.jsx)(`p`,{className:`m-0 text-sm text-pretty text-text-secondary`,children:n})}):(0,R.jsx)(`span`,{className:`text-sm text-text-tertiary`,children:t})}function $4({account:e}){return(0,R.jsxs)(`section`,{children:[(0,R.jsx)($A,{children:`What landed this lap`}),e.source===`review`?(0,R.jsx)(CK,{source:e.prose,className:`mt-2`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`mt-2 text-sm text-text-tertiary`,children:`No review summary this lap — below is each burner’s own account of the ticket it ran.`}),(0,R.jsx)(`div`,{className:`mt-3 flex flex-col gap-4`,children:e.entries.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`text-sm font-medium text-text`,children:[`#`,e.seq,` `,e.title]}),(0,R.jsx)(CK,{source:e.digest,className:`mt-2`})]},e.seq))})]})]})}function e3({lap:e,outcome:t,agenticReview:n}){return(0,R.jsxs)(NJ,{tone:`accent`,title:`Nothing verified this lap`,meta:`lap ${e}`,actions:n&&(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(Eb,{}),disabled:!!n.blocked,...n.blocked?{title:n.blocked}:{},onClick:n.onStart,children:`Agentic review`}),children:[(0,R.jsx)(`p`,{className:`m-0`,children:`The review pass ran and produced no evidence, so nothing on this branch has been checked this lap. Nothing is blocked — run another review, or drive it yourself, before you ship.`}),t.line&&(0,R.jsx)(`p`,{className:`m-0 mt-1.5 break-words text-text`,children:t.line}),t.reason&&(0,R.jsx)(`p`,{className:`m-0 mt-1 font-mono text-xs break-words text-text-tertiary`,children:t.reason})]})}function t3(e){return e.filter(e=>e.item.kind===`defect`&&e.item.fixTicket).length}function n3(e){let t=t3(e),n=[`${e.length-t} open`];return t>0&&n.push(`${t} being fixed`),n.join(` · `)}function r3({featureId:e,lap:t,rows:n,readonly:r,...i}){if(n.length===0&&r)return null;let a=n.length===0,o=t3(n);return(0,R.jsxs)(`section`,{id:`open-work`,className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-7 items-baseline gap-3`,children:[(0,R.jsx)(`h2`,{className:`m-0 text-lg font-semibold text-text`,children:a?`Notes`:`Needs attention`}),o>0&&(0,R.jsxs)(`span`,{className:`text-xs text-text-tertiary tabular-nums`,children:[o,` being fixed`]})]}),a?(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:`Nothing needs attention. Write down what you see while you drive — a pasted screenshot rides along.`}):(0,R.jsx)(kJ,{featureId:e,rows:n,readonly:r,currentLap:t,...i}),!r&&(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(SJ,{featureId:e})})]})}function i3({featureId:e,lap:t,rows:n,readonly:r,scroller:i,...a}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{ref:i,className:`min-h-0 flex-1 overflow-y-auto px-1 py-2`,children:n.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(Ab,{}),title:`Nothing needs attention`,hint:r?`Nothing was left open when this feature shipped.`:`The review found nothing open and you have written no notes. Write what you see.`}):(0,R.jsx)(kJ,{featureId:e,rows:n,readonly:r,currentLap:t,scroller:i,...a})}),!r&&(0,R.jsx)(`div`,{className:`shrink-0 border-t border-border-subtle p-3`,children:(0,R.jsx)(SJ,{featureId:e})})]})}function a3(){return(0,L.useRef)(null)}function o3({onClose:e,className:t,...n}){let r=a3(),i=n.rows.length>0?n3(n.rows):null;return(0,R.jsx)(Sj,{label:`Needs attention`,title:(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[`Needs attention`,i&&(0,R.jsx)(`span`,{className:`text-xs font-normal text-text-tertiary tabular-nums`,children:i})]}),onClose:e,className:t,bodyClassName:`flex flex-col`,children:(0,R.jsx)(i3,{...n,scroller:r})})}function s3({projectId:e,holderLabel:t}){let n=B.useUtils(),r=gx(),i=B.project.testDrive.useMutation({onSuccess:()=>void n.feature.driveInfo.invalidate(),onError:e=>r.push(e.message)});return(0,R.jsx)(NJ,{tone:`quiet`,role:`status`,title:`${Pv(t)} is running`,actions:(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(Tb,{}),disabled:i.isPending,onClick:()=>i.mutate({projectId:e,action:`stop`}),children:i.isPending?`Stopping…`:`Stop it`})})}function c3({history:e,children:t}){return(0,R.jsxs)(`div`,{"data-tier":`reference`,className:`flex flex-col gap-4`,children:[e,(0,R.jsx)(`div`,{className:`flex flex-col [&>*:last-child]:border-b [&>*:last-child]:border-border-subtle`,children:t})]})}function l3({denial:e,readonly:t,primary:n,busy:r,refusal:i,onReview:a,onDismiss:o}){return t?null:(0,R.jsxs)(NJ,{tone:`accent`,title:`Review couldn’t drive — uncommitted changes`,meta:(0,R.jsxs)(`span`,{title:kh(e.at),children:[`denied `,Ih(e.at)]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{size:`sm`,variant:n?`secondary`:`ghost`,icon:(0,R.jsx)(Eb,{}),loading:r,onClick:a,children:r?`Starting…`:`Agentic review`}),(0,R.jsx)(UE,{size:`sm`,label:`Dismiss`,icon:(0,R.jsx)(cb,{}),onClick:o})]}),children:[(0,R.jsx)(`p`,{className:`m-0`,children:`The drive was refused because the working tree had uncommitted changes, so the review ran repo-only — the gates and the diff, with no app to walk. Commit or discard the files below, then run another review: a fresh pass is minted for this lap and burns with the drive available to it.`}),e.dirtyFiles.length>0?(0,R.jsx)(`ul`,{className:`m-0 mt-2 flex list-none flex-col gap-0.5 p-0`,children:e.dirtyFiles.map(e=>(0,R.jsx)(`li`,{className:`truncate font-mono text-xs text-text`,title:e,children:e},e))}):(0,R.jsx)(`p`,{className:`m-0 mt-2 font-mono text-xs break-words text-text-tertiary`,children:e.message}),i&&(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(zj,{message:i})})]})}function u3({featureId:e,denial:t,readonly:n,primary:r,onDismiss:i}){let a=B.useUtils(),[o,s]=(0,L.useState)(null),c=B.feature.agenticReview.useMutation({onSuccess:()=>{a.feature.get.invalidate({id:e}),a.events.invalidate()},onError:e=>s(e.message)});return(0,R.jsx)(l3,{denial:t,readonly:n,primary:r,busy:c.isPending,refusal:o,onReview:()=>{s(null),c.mutate({featureId:e})},onDismiss:i})}function d3(e){switch(e.kind){case`verified`:return{tone:`success`,strong:`Verified`,...e.mode?{text:`${e.mode} mode`}:{}};case`unverified`:return{tone:`warning`,strong:`Unverified`};case`could-not-run`:return{tone:`warning`,strong:`Could not run`};case`none`:return null}}var f3=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function p3(e){return e.completedAt===null?{text:e.reviewed?`Reviewed`:`Not reviewed yet`}:{text:`Reviewed ${Ih(e.completedAt)}`,title:kh(e.completedAt)}}function m3(e){return e.completedAt===null?[]:[{text:Ih(e.completedAt),title:kh(e.completedAt)}]}function h3(e){let{found:t,fixed:n,carried:r}=e.defects;return[d3(e.outcome),e.burned>0?{text:`${f3(e.burned,`ticket`)} burned`}:null,t>0?{text:[f3(t,`defect`)+` found`,n>0?`${n} fixed`:``,r>0?`${r} carried`:``].filter(Boolean).join(`, `)}:null,e.notes>0?{text:f3(e.notes,`test note`)}:null,p3(e)].filter(e=>e!==null)}function g3(e){return e.couldNotRun||e.verdict===`unverified`?`warning`:e.verdict===`verified`?`success`:`neutral`}function _3({pass:e}){let t=e.couldNotRun?`Could not run`:e.verdict===`verified`?`Verified`:e.verdict===`unverified`?`Unverified`:null;return(0,R.jsx)(R.Fragment,{children:[e.mode?`${e.mode} mode`:null,t&&(0,R.jsx)(`span`,{className:`font-medium ${zA[g3(e)]}`,children:t},`verdict`),e.found>0?`${f3(e.found,`defect`)} found`:null,e.fixed>0?`${e.fixed} fixed`:null].filter(Boolean).flatMap((e,t)=>t===0?[e]:[` · `,e])})}var v3={passed:{word:`passed`,tone:`success`},failed:{word:`failed`,tone:`danger`},couldnt_run:{word:`couldn't run`,tone:`warning`}};function y3(e){return{text:(0,R.jsx)(`a`,{className:JE,href:e,target:`_blank`,rel:`noreferrer noopener`,children:`output`})}}function b3({gateRun:e}){let t=ay(e);return(0,R.jsxs)(`div`,{role:`group`,"aria-label":`Checks`,className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(oj,{items:[{tone:ZA[t.tone],strong:t.summary},t.commit!==null&&{text:`@${t.commit}`,mono:!0,title:`the feature-branch commit the checks ran on`},t.outputUrl!==void 0&&y3(t.outputUrl)]}),t.lines.map((e,t)=>(0,R.jsx)(oj,{items:[{tone:v3[e.state].tone,strong:v3[e.state].word},{text:e.label,mono:!0},e.detail!==void 0&&{text:e.detail},e.outputUrl!==void 0&&y3(e.outputUrl)]},t))]})}function x3({pass:e,staged:t,onStage:n}){let r=e.verdict===`unverified`;return(0,R.jsxs)(Nj,{variant:`milestone`,tone:g3(e),icon:e.passKind===`verification`?(0,R.jsx)(sb,{}):(0,R.jsx)(Eb,{}),title:`${e.passKind===`verification`?`Verification`:`Review`} #${e.seq}`,meta:(0,R.jsx)(_3,{pass:e}),aside:(0,R.jsxs)(R.Fragment,{children:[e.completedAt?(0,R.jsx)(`span`,{className:`text-xs text-text-tertiary`,title:kh(e.completedAt),children:Ih(e.completedAt)}):null,e.videoUrl&&(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(wb,{}),"aria-pressed":t===e.ticketId,onClick:()=>n(e.ticketId),children:`Recording`})]}),children:[(e.account||e.reason)&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-sm text-pretty`,children:[e.account&&(0,R.jsx)(`span`,{className:r?`text-warning`:`text-text-secondary`,children:e.account}),e.reason&&(0,R.jsx)(`span`,{className:`text-text-tertiary`,children:e.reason})]}),e.gateRun&&(0,R.jsx)(b3,{gateRun:e.gateRun})]})}function S3(e){let t=e.tickets.some(e=>e.status===`burning`)?`Burning`:e.tickets.some(e=>e.status===`done`)?`Burned`:`Queued`,n=e.tickets.filter(e=>e.status!==`cancelled`).length;return(0,R.jsxs)(R.Fragment,{children:[t,` `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:`${n} ${e.fixes?n===1?`fix`:`fixes`:n===1?`ticket`:`tickets`}`})]})}function C3({node:e,lap:t,onViewRun:n}){return(0,R.jsx)(Nj,{title:S3(e),children:(0,R.jsx)(ij,{label:`Lap ${t} ${e.fixes?`fixes`:`tickets`}`,children:e.tickets.map(e=>(0,R.jsx)(rj,{className:`-ml-3`,title:`#${e.seq??`?`} · ${e.title??`Ticket`}`,meta:e.status===`done`?e.completedAt?Ih(e.completedAt):void 0:(0,R.jsx)(UA,{status:e.status}),...n?{onClick:n}:{}},e.id))})})}function w3({entry:e,tickets:t,findings:n,staged:r,onStage:i,onViewRun:a}){let o=Cy(e,t,n);return o.length===0?null:(0,R.jsx)(jj,{label:`Lap ${e.lap}`,children:o.map(t=>t.kind===`pass`?(0,R.jsx)(x3,{pass:t,staged:r,onStage:i},t.ticketId):(0,R.jsx)(C3,{node:t,lap:e.lap,...a?{onViewRun:a}:{}},t.tickets[0].id))})}function T3({passes:e,tickets:t,findings:n,notes:r,currentLap:i,staged:a,onStage:o,onViewRun:s}){if(e.length===0&&t.length===0)return null;let c=yy({passes:e,tickets:t,findings:n,notes:r,currentLap:i}).filter(e=>e.lap===i||e.passes.length>0||t.some(t=>t.lap===e.lap)||e.defects.found>0||e.notes>0).reverse(),l=c.find(e=>e.lap===i),u=c.filter(e=>e!==l),d=e=>(0,R.jsx)(w3,{entry:e,tickets:t,findings:n,staged:a,onStage:o,...s?{onViewRun:s}:{}});return(0,R.jsxs)(`section`,{id:`lap-trail`,className:`flex flex-col gap-1`,children:[(0,R.jsx)($A,{children:`History`}),u.map(e=>(0,R.jsx)(Rj,{bare:!0,title:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-4`,children:[(0,R.jsxs)(`span`,{className:`font-medium text-text`,children:[`Lap `,e.lap]}),(0,R.jsx)(oj,{items:h3(e),className:`min-w-0`})]}),children:d(e)},e.lap)),(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,R.jsxs)(`h3`,{className:`m-0 text-sm font-medium text-text`,children:[`Lap `,l.lap]}),(0,R.jsx)(oj,{items:m3(l)})]}),d(l)]})]})}function E3({missing:e}){return e.length===0?null:(0,R.jsx)(NJ,{tone:`warning`,role:`status`,title:(0,R.jsxs)(`span`,{title:e.map(e=>e.reason).join(`; `),children:[`Walkthrough videos off on this machine: `,e.map(e=>e.notice).join(`; `)]})})}var D3={ok:`success`,warn:`warning`,danger:`danger`,idle:`neutral`};function O3(e){let t=D3[e.tone],n=(0,R.jsx)(`span`,{className:`whitespace-nowrap`,...e.detail?{title:e.detail}:{},children:e.value}),r=e.sub&&e.detail?(0,R.jsx)(`span`,{className:`text-warning`,title:e.detail,children:e.sub}):e.sub,i=e.key===`tickets`?(0,R.jsx)(bb,{}):void 0;return{label:e.label,value:n,...r?{sub:r}:{},...i&&e.tone===`idle`?{leading:i}:{tone:t}}}function k3({artifact:e,outcome:t,currentLap:n,landedSince:r,tickets:i,runState:a,verification:o,driveLap:s,unverifiedKeys:c,testDrive:l,agenticReview:u,shipped:d=!1,driving:f,noWalkthrough:p=!1,building:m}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-8 gap-y-4`,children:[(0,R.jsx)(aj,{className:`min-w-0 flex-1`,items:dy({artifact:e,...t?{outcome:t}:{},currentLap:n,landedSince:r,tickets:i,...d?{}:{runState:a},...o?{verification:o}:{},...s===void 0?{}:{driveLap:s},...f===void 0?{}:{driving:f},...p?{noWalkthrough:p}:{},...c?{unverifiedKeys:c}:{},shipped:d,...m?{building:m}:{}}).map(O3)}),(l||u)&&(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[l&&(0,R.jsx)(Y,{icon:(0,R.jsx)(wb,{}),disabled:!!l.blocked,...l.blocked?{title:l.blocked}:{},onClick:l.onStart,children:`Test drive`}),u&&(0,R.jsx)(Y,{variant:`ghost`,icon:(0,R.jsx)(Eb,{}),disabled:!!u.blocked,...u.blocked?{title:u.blocked}:{},onClick:u.onStart,children:`Agentic review`})]})]})}function A3({lap:e,laterLaps:t,currentLap:n,readonly:r}){return t?(0,R.jsxs)(Rj,{title:`Deferred to a later lap`,icon:(0,R.jsx)(ub,{}),children:[(0,R.jsxs)(`p`,{className:`m-0`,children:[e.story,`.`]}),e.promotedFromEarlier>0&&(0,R.jsxs)(`p`,{className:`m-0 mt-2 text-text-tertiary`,children:[`Includes `,e.promotedFromEarlier,` ticket`,e.promotedFromEarlier===1?``:`s`,` promoted in an earlier lap.`]}),(0,R.jsx)(`p`,{className:`m-0 mt-3 text-text-tertiary`,children:r?`The spec kept this out of lap ${n} on purpose, and it was still deferred when this feature shipped.`:`The spec kept this out of lap ${n} on purpose. Start lap ${n+1} from the next step to take it on — or ship what landed, if lap ${n} is enough.`}),(0,R.jsx)(CK,{source:t,className:`mt-2`})]}):null}function j3({full:e,driving:t,conflict:n,readonly:r=!1,onViewPhase:i}){let{feature:a,tickets:o,runs:s}=e,c=gx(),l=B.useUtils(),u=Tv(e.sessions),d=Xh(s),f=QF(a.id),p=!n&&b_(f),m=B.feature.driveInfo.useQuery(void 0,{refetchInterval:Ch()}),h=m.data?.featureId===a.id?m.data:void 0,g=Ch(),_=a.phase===`review`&&g,v=B.notes.list.useQuery({featureId:a.id},{refetchInterval:_}),y=B.findings.listByFeature.useQuery({featureId:a.id},{refetchInterval:_}),b=Ey(e),x=B.docs.read.useQuery({featureId:a.id,relPath:b??`spec.md`},{enabled:!!b}),S=fh(a.id).data??[],C=S.filter(e=>e.hasVideo&&e.videoUrl),w=sy(S,o),T=em(B.project.prep.useQuery({projectId:a.projectId}).data?.findings??[]),E=B.project.list.useQuery().data?.find(e=>e.id===a.projectId),D=B.project.drivePrerequisites.useQuery({projectId:a.projectId},{enabled:!r});B.feature.testDrive.useMutation({onSuccess:()=>{l.feature.driveInfo.invalidate(),l.feature.get.invalidate({id:a.id})},onError:e=>c.push(e.message)});let O=B.feature.agenticReview.useMutation({onSuccess:()=>{l.feature.get.invalidate({id:a.id}),l.events.invalidate()},onError:e=>c.push(e.message)}),k=(0,L.useRef)(null),[A,j]=(0,L.useState)(null),[M,N]=(0,L.useState)(null),[P,ee]=(0,L.useState)(!1),[F,I]=(0,L.useState)(!0);(0,L.useEffect)(()=>{P&&I(!0)},[P]);let[te,ne]=(0,L.useState)(null),[re,ie]=(0,L.useState)({ids:[],scrollTo:null});(0,L.useEffect)(()=>{if(re.ids.length===0)return;let e=setTimeout(()=>ie({ids:[],scrollTo:null}),2e3);return()=>clearTimeout(e)},[re]);let ae=(0,L.useCallback)(e=>{j(e),document.getElementById(`evidence-stage`)?.scrollIntoView({behavior:`smooth`,block:`start`})},[]),oe=(0,L.useCallback)(e=>{k.current?.seek(e),document.getElementById(`evidence-stage`)?.scrollIntoView({behavior:`smooth`,block:`start`})},[]),se=i?e=>{i(`building`),requestAnimationFrame(()=>document.getElementById(`lane-${e}`)?.scrollIntoView({behavior:`smooth`,block:`center`}))}:void 0,ce=h?.state??`idle`,le=ce!==`idle`||!!t,ue=C.length>0||le,de={expanded:P&&ue,set:ee},fe=m.data&&m.data.featureId!==a.id?m.data:void 0,pe=fe?.projectDrive&&fe.projectId?fe.projectId:void 0,me=a.phase===`review`?Rv(f,s,te):null,he=r?null:by({passes:S,tickets:o,currentLap:a.lap}),ge=r?null:{onStart:()=>O.mutate({featureId:a.id}),...O.isPending?{blocked:`starting…`}:d?.status===`running`?{blocked:`a burn is running`}:{}},{attention:_e,settled:ve}=OJ({findings:y.data?.findings??[],notes:v.data??[],tickets:o,openDefects:y.data?.openDefects??[]}),ye=(y.data?.findings??[]).filter(e=>e.kind===`observation`),be=n_(o,a.lap),xe=o_(o,{lap:a.lap,lapSessionRan:o.some(e=>e.lap===a.lap)}),Se=Oy(x.data?.content),Ce=ue?(0,R.jsx)(Y4,{featureId:a.id,branch:a.branch,recordings:C,picked:A,notes:v.data??[],readonly:r,driveState:ce,drive:h,dryRun:m.data?.dryRun??!1,failure:Iv(h,{sessionLive:!!u}),expand:de,handleRef:k,onStageRecording:N,onMarkerClick:e=>ie({ids:e,scrollTo:null}),onAnnotationSaved:e=>ie({ids:[e],scrollTo:e})}):null,we=(0,R.jsxs)(R.Fragment,{children:[n&&(0,R.jsx)(IJ,{featureId:a.id,branch:a.branch,conflict:n,readonly:r,liveSessionId:u?.sessionId??null,resolveEnded:S_(f,e.sessions)}),p&&(0,R.jsx)(FJ,{readonly:r}),me&&(0,R.jsx)(u3,{featureId:a.id,denial:me,readonly:r,primary:!he,onDismiss:()=>ne(me.eventId)},me.eventId),he&&(0,R.jsx)(e3,{lap:a.lap,outcome:he,agenticReview:ge}),!r&&!le&&fe&&pe&&(0,R.jsx)(s3,{projectId:pe,holderLabel:fe.holderLabel})]}),Te={featureId:a.id,lap:a.lap,rows:_e,readonly:r,onStage:ue?M:null,onSeek:oe,highlight:re.ids,scrollTo:re.scrollTo,onViewLane:se},Ee=de.expanded,De=!!n||p&&!r||!!me||!!he||!r&&!le&&!!pe,Oe=Ee?(0,R.jsx)(`div`,{"data-stage-overlay":``,className:`fixed inset-0 z-[100] flex bg-surface animate-fade-in`,children:(0,R.jsx)(Cj,{aside:F&&(0,R.jsx)(o3,{...Te,onClose:()=>I(!1)}),children:(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col p-6`,children:Ce})})}):null;return(0,R.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[De&&(0,R.jsx)(`div`,{"data-tier":`now`,className:`flex flex-col gap-4`,children:we}),(0,R.jsxs)(`div`,{"data-tier":`status`,className:`flex flex-col gap-4`,children:[(0,R.jsx)(k3,{artifact:w,outcome:xy({passes:S,tickets:o}),currentLap:a.lap,landedSince:w?.landedSince??0,tickets:o,runState:d?.status??`no run recorded`,verification:ly(o),driveLap:C_(f),...r?{}:{unverifiedKeys:T},...r?{}:{driving:le},...ge?{agenticReview:ge}:{}}),!r&&(0,R.jsx)(E3,{missing:D.data?.missing??[]})]}),(0,R.jsxs)(`div`,{"data-tier":`work`,className:`flex flex-col gap-10 empty:hidden`,children:[!Ee&&Ce,(0,R.jsx)(r3,{...Te}),(0,R.jsx)(AJ,{featureId:a.id,findings:y.data?.carriedFindings??[],readonly:r})]}),(0,R.jsxs)(c3,{history:(0,R.jsx)(T3,{passes:S,tickets:o,findings:y.data?.findings??[],notes:v.data??[],currentLap:a.lap,staged:M?.ticketId??null,onStage:ae,...i?{onViewRun:()=>i(`building`)}:{}}),children:[(0,R.jsx)(l4,{text:E?.driveInstructions}),(0,R.jsx)(Z4,{account:be,tickets:o,observations:ye,carried:ve.length>0?(0,R.jsx)(kJ,{featureId:a.id,rows:ve,readonly:r,onStage:ue?M:null,onSeek:oe,onViewLane:se}):null}),(0,R.jsx)(A3,{lap:xe,laterLaps:Se,currentLap:a.lap,readonly:r})]})]}),Oe&&(typeof document>`u`?Oe:(0,Dx.createPortal)(Oe,document.body))]})}var M3=`Untitled chat`,N3=RegExp(`\x1B\\[[0-9;]*[A-Za-z]`,`g`),P3=/<\/?[a-z][a-z0-9_-]*(?:\s[^<>]*)?>/g,F3=/^(?:[#>▎❯•*\-.]+\s*)+/,I3=/[`▎]|\*\*/g;function L3(e){if(!e)return M3;let t=e.replace(N3,``).replace(P3,` `).replace(I3,``).replace(/\s+/g,` `).trim().replace(F3,``).trim();return!t||t===`…`||/^untitled$/i.test(t)?M3:t}function R3(e){return e.charAt(0).toUpperCase()+e.slice(1)}var z3=/<command-name>([\s\S]*?)<\/command-name>/,B3=/<command-args>([\s\S]*?)<\/command-args>/,V3=/^\s*<local-command-(?:stdout|stderr)>([\s\S]*?)<\/local-command-(?:stdout|stderr)>\s*$/,H3=/^\s*<local-command-caveat>[\s\S]*?<\/local-command-caveat>\s*$/;function U3(e){if(H3.test(e))return{kind:`skip`};let t=z3.exec(e);if(t){let n=t[1].trim(),r=B3.exec(e)?.[1]?.trim()??``,i=n.startsWith(`/`)?n:`/${n}`;return{kind:`command`,command:r?`${i} ${r}`:i}}let n=V3.exec(e);if(n){let e=n[1].replace(N3,``).trim();return e?{kind:`output`,text:e}:{kind:`skip`}}return{kind:`text`,text:e}}function W3({sessionId:e,className:t}){let n=B.project.conversationTranscript.useQuery({sessionId:e});if(n.isPending)return(0,R.jsx)(Pj,{children:`Reading the transcript…`});if(n.data?.status===`unavailable`)return(0,R.jsx)(Pj,{children:`Transcript not available for this session.`});let r=n.data?.turns??[];return r.length===0?(0,R.jsx)(Pj,{children:`No transcript kept for this conversation.`}):(0,R.jsx)(K3,{turns:r,assistant:pv(n.data?.runtime),runtime:n.data?.runtime,...t?{className:t}:{}})}var G3=`flex max-h-[clamp(300px,calc(100dvh-340px),1200px)] flex-col gap-6 overflow-y-auto pr-1`;function K3({turns:e,assistant:t,runtime:n,className:r=G3}){let i=n===`codex`?kb:Ob,a=(0,L.useRef)(null);a.current===null&&e.length>0&&(a.current=e.length);let o=a.current??0;return(0,R.jsx)(`div`,{className:r,children:e.map((e,n)=>{let r=U3(e.text);if(r.kind===`skip`)return null;let a=n<8?{"--i":n}:void 0,s=n<8?q(`animate-rise-in`,`[animation-delay:calc(var(--i)*20ms)]`):n>=o?`animate-rise-in`:void 0;if(r.kind===`command`||r.kind===`output`)return(0,R.jsxs)(`div`,{style:a,"data-turn-kind":r.kind,className:q(`flex min-w-0 items-start gap-1.5 font-mono text-xs text-text-tertiary`,s),children:[(0,R.jsx)(mb,{size:12,className:`mt-0.5 shrink-0 text-icon`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words whitespace-pre-wrap`,children:r.kind===`command`?r.command:r.text})]},n);let c=e.role===`user`;return(0,R.jsxs)(`article`,{style:a,className:q(`flex flex-col gap-1.5`,s),children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium text-text-secondary`,children:[c?(0,R.jsx)(Kb,{size:14,className:`shrink-0 text-icon`}):(0,R.jsx)(i,{size:14,className:`shrink-0 text-icon`}),c?`You`:t]}),c?(0,R.jsx)(`div`,{className:`rounded-md bg-surface-inset px-3 py-2 text-base break-words whitespace-pre-wrap text-text`,children:r.text}):(0,R.jsx)(CK,{source:r.text,size:`base`,tone:`primary`})]},n)})})}function q3({featureId:e,relPath:t,title:n,onClose:r,returnFocusRef:i}){let a=B.docs.read.useQuery({featureId:e,relPath:t});return(0,R.jsxs)(Hj,{open:!0,onClose:r,labelledBy:`doc-peek-title`,size:`lg`,returnFocusRef:i,className:`flex max-h-[84vh] flex-col overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-border-subtle pr-2 pl-5`,children:[(0,R.jsx)(gb,{size:16,className:`shrink-0 text-icon`}),(0,R.jsx)(`h2`,{id:`doc-peek-title`,className:`m-0 min-w-0 truncate text-sm font-medium text-text`,children:n||t.split(/[\\/]/).pop()}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-text-tertiary`,title:t,children:t}),(0,R.jsx)(UE,{label:`Close`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:r})]}),(0,R.jsx)(`div`,{className:`min-h-0 overflow-y-auto px-10 pt-8 pb-12`,children:(0,R.jsxs)(`div`,{className:`mx-auto max-w-[680px]`,children:[a.isLoading&&(0,R.jsxs)(Pj,{children:[`Loading `,n,`…`]}),a.error&&(0,R.jsxs)(Pj,{children:[`Could not read `,t,`: `,a.error.message]}),a.data&&(0,R.jsx)(CK,{source:jh(a.data.content),size:`base`})]})})]})}function J3({full:e}){let{feature:t,tickets:n,runs:r}=e,i=QF(t.id),[a,o]=(0,L.useState)(!1),s=Dy(e),c=fh(t.id).data??[],l=c.filter(e=>e.hasVideo&&e.videoUrl),u=sy(c,n),d=B.findings.listByFeature.useQuery({featureId:t.id}),f=B.notes.list.useQuery({featureId:t.id}),p=Ey(e),m=B.docs.read.useQuery({featureId:t.id,relPath:p??`spec.md`},{enabled:!!p}),h=B.project.list.useQuery().data?.find(e=>e.id===t.projectId),g=Cv(e.sessions),_=Xh(r),v=n_(n,t.lap),y=(d.data?.findings??[]).filter(e=>e.kind===`observation`),[b,x]=(0,L.useState)(null),S=!!s||l.length>0;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,R.jsx)(`div`,{"data-tier":`status`,children:(0,R.jsx)(k3,{artifact:u,outcome:xy({passes:c,tickets:n}),currentLap:t.lap,landedSince:u?.landedSince??0,tickets:n,runState:_?.status??`no run recorded`,shipped:!0,driveLap:C_(i),noWalkthrough:l.length===0})}),S&&(0,R.jsxs)(`section`,{"data-tier":`work`,className:`flex flex-col gap-3 [&>*+*+*]:mt-7`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-7 items-center gap-3`,children:[(0,R.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 text-lg font-semibold text-text`,children:`What shipped`}),s&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(gb,{}),onClick:()=>o(!0),children:`Outcome doc`})]}),l.length>0&&(0,R.jsx)(Y4,{featureId:t.id,branch:t.branch,recordings:l,picked:b,notes:[],readonly:!0,driveState:`idle`,dryRun:!1,failure:null})]}),(0,R.jsxs)(c3,{history:(0,R.jsx)(T3,{passes:c,tickets:n,findings:d.data?.findings??[],notes:f.data??[],currentLap:t.lap,staged:l.length>0?b:null,onStage:x}),children:[(0,R.jsx)(Y3,{sessions:g}),(0,R.jsx)(l4,{text:h?.driveInstructions}),(0,R.jsx)(Z4,{account:v,tickets:n,observations:y}),(0,R.jsx)(A3,{lap:o_(n,{lap:t.lap,lapSessionRan:!0}),laterLaps:Oy(m.data?.content),currentLap:t.lap,readonly:!0})]}),a&&s&&(0,R.jsx)(q3,{featureId:t.id,relPath:s,title:`outcome`,onClose:()=>o(!1)})]})}function Y3({sessions:e}){return e.length===0?null:(0,R.jsx)(Rj,{title:`Questions asked`,icon:(0,R.jsx)(hb,{}),aside:`${e.length} conversation${e.length===1?``:`s`}`,children:(0,R.jsx)(ij,{divided:!0,label:`Questions asked`,children:e.map((e,t)=>{let n=e.createdAt===void 0?void 0:Ih(e.createdAt);return e.transcriptMissing?(0,R.jsx)(rj,{index:t,leading:(0,R.jsx)(hb,{}),title:(0,R.jsx)(`span`,{className:`text-text-tertiary`,children:`Session opened, nothing recorded`}),meta:n},e.id):(0,R.jsx)(X3,{title:e.title??`Conversation`,when:n,sessionId:e.id},e.id)})})})}function X3({title:e,when:t,sessionId:n}){let[r,i]=(0,L.useState)(!1);return(0,R.jsx)(`div`,{"data-list-row":``,className:`px-3`,children:(0,R.jsx)(Rj,{bare:!0,icon:(0,R.jsx)(hb,{}),title:(0,R.jsx)(`span`,{className:`font-normal text-text`,children:e}),aside:t,onToggle:e=>e&&i(!0),children:r&&(0,R.jsx)(W3,{sessionId:n})})})}function Z3({featureId:e}){let t=gx(),n=B.useUtils(),r=B.feature.get.useQuery({id:e},{refetchInterval:Ch()}),[i,a]=(0,L.useState)(null),o=B.ticket.edit.useMutation({onSuccess:()=>{n.feature.get.invalidate({id:e})},onError:e=>t.push(e.message)}),s=B.ticket.cancel.useMutation({onSuccess:()=>{n.feature.get.invalidate({id:e}),t.push(`ticket cancelled`,`success`)},onError:e=>t.push(e.message)}),c=r.data?.feature.projectId,l=B.settings.get.useQuery({projectId:c??``},{enabled:!!c}),u=um(l.data),d=Lm(l.data,`implement`)??`…`,f=r.data;if(r.isLoading)return(0,R.jsx)($3,{});if(!f)return(0,R.jsxs)(Pj,{children:[`Could not load tickets: `,r.error?.message??`unknown`]});let{feature:p,tickets:m,docs:h}=f,g=async(e,n)=>{await o.mutateAsync({ticketId:e,...n}),t.push(`ticket updated`,`success`)},_=(e,t)=>o.mutate({ticketId:e,model:t}),v=async r=>{let i=e6(m,p.lap);try{for(let e of i)await n.client.ticket.edit.mutate({ticketId:e.id,model:r});await n.feature.get.invalidate({id:e}),t.push(`${i.length} tickets set to ${r||`the default model`}`,`success`)}catch(e){t.push(e instanceof Error?e.message:`could not update ticket models`)}},y=(0,R.jsx)(cJ,{tickets:m,currentLap:p.lap,roster:u,docs:h,sandbox:_M,defaultModel:d,onDoc:a,onEdit:g,onModel:_,onBulkModel:e=>{v(e)},onCancel:e=>s.mutate({ticketId:e}),onCopySha:e=>{navigator.clipboard.writeText(e),t.push(`copied ${Mh(e)}`,`info`)}});return(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto`,children:[(0,R.jsxs)(`section`,{"aria-label":`Tickets`,className:`flex min-h-0 flex-col`,children:[(0,R.jsx)(`h2`,{className:`m-0 mb-2 text-lg font-semibold text-text`,children:`Tickets`}),y]}),i&&(0,R.jsx)(q3,{featureId:e,relPath:i,title:h.find(e=>e.relPath===i)?.title??i,onClose:()=>a(null)})]})}var Q3=[`w-2/3`,`w-1/2`,`w-3/5`,`w-2/5`];function $3(){return(0,R.jsxs)(Oj,{label:`Loading tickets…`,className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`mb-2 flex h-7 items-center`,children:(0,R.jsx)(kj,{className:`h-4 w-20`})}),(0,R.jsx)(`div`,{className:`mb-2 flex min-h-7 items-center`,children:(0,R.jsx)(kj,{className:`h-2.5 w-40`})}),(0,R.jsx)(`div`,{children:Q3.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-border-subtle px-3 last:border-b-0`,"data-skeleton":`ticket-row`,children:[(0,R.jsx)(kj,{className:`size-3`}),(0,R.jsx)(kj,{className:`h-2.5 w-5`}),(0,R.jsx)(kj,{className:q(`h-3`,e)})]},t))})]})}function e6(e,t){return e.filter(e=>e.lap===t&&e.status===`pending`)}function t6({open:e,title:t,body:n,confirmLabel:r,confirmIcon:i,busy:a,onConfirm:o,onClose:s}){let c=(0,L.useId)();return(0,R.jsxs)(Hj,{open:e,onClose:s,size:`sm`,labelledBy:c,children:[(0,R.jsx)(Uj,{id:c,title:t,onClose:s}),(0,R.jsx)(Wj,{children:(0,R.jsx)(`p`,{className:`m-0 text-sm text-pretty text-text-secondary`,children:n})}),(0,R.jsxs)(Gj,{children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:s,disabled:a,children:`Keep going`}),(0,R.jsx)(Y,{variant:`danger`,icon:i,autoFocus:!0,disabled:a,onClick:()=>{o(),s()},children:r})]})]})}var n6=[`pending`,`failed`],r6={pending:{tone:`neutral`,word:`Pending`},burning:{tone:`live`,word:`Burning`},done:{tone:`success`,word:`Done`,icon:(0,R.jsx)(sb,{})},failed:{tone:`danger`,word:`Failed`},"launch-failed":{tone:`danger`,word:`Launch failed`},stopped:{tone:`warning`,word:`Stopped`},waived:{tone:`neutral`,word:`Set aside`,muted:!0}},i6={"claude-code":Ob,codex:kb},a6=`shrink-0 text-xs text-text-tertiary tabular-nums`;function o6({ticket:e,featureBranch:t,readonly:n,expanded:r,onToggle:i,index:a,hadOutput:o,elapsed:s,duration:c,model:l,roster:u,defectTitle:d,busy:f,stopping:p,waiving:m,terminalBlocked:h,onModel:g,onRetry:_,onRetryWithModel:v,onRetryFresh:y,onWaive:b,onStop:x,onResolveInTerminal:S,onCopySha:C,children:w}){let[T,E]=(0,L.useState)(!1),D=R_({...e,hadOutput:o}),O=z_({...e,hadOutput:o}),k=e.status===`failed`?e.conflictFiles:void 0,A=e.error?.split(`
|
|
187
187
|
`)[0],j=D===`failed`||D===`launch-failed`,M=j||D===`stopped`,N=!n&&u&&g&&n6.includes(e.status)?{roster:u,onChange:g}:null,P=l?i6[l.runtime]:null,ee=D===`done`?e.commits[0]:void 0,F=r6[D],I=D===`burning`?s:c,te=a!==void 0&&a<8,ne=!n&&(M||D===`burning`||N),re=`lane-${e.id}-detail`,ie=A&&!k&&!(r&&O);return(0,R.jsxs)(`div`,{id:`lane-${e.id}`,"data-lane-state":D,style:te?{"--i":a}:void 0,className:q(`border-b border-border-subtle animate-rise-in`,te&&`[animation-delay:calc(var(--i)*20ms)]`),children:[(0,R.jsxs)(`div`,{className:q(`group/lane flex min-h-10 items-center gap-3 rounded-md pr-2`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,F.muted&&`opacity-60`),children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":r?re:void 0,onClick:i,className:`flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2.5 rounded-md py-2 pl-2 text-left`,children:[(0,R.jsx)(fb,{size:14,className:q(`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app`,r&&`rotate-90`)}),(0,R.jsxs)(`span`,{className:`w-7 shrink-0 text-xs text-text-tertiary tabular-nums`,children:[`#`,e.seq]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-sm text-text`,F.muted&&`line-through`),title:d?`${e.title} — fixes: ${d}`:e.title,children:e.title}),d&&(0,R.jsxs)(`span`,{className:`hidden max-w-60 min-w-0 shrink truncate text-xs text-text-tertiary @3xl:block`,title:`Fixes: ${d}`,children:[`fixes “`,d,`”`]}),(0,R.jsx)(`span`,{className:`hidden shrink-0 @lg:inline-flex`,children:(0,R.jsx)(WA,{kind:e.kind,passKind:e.passKind})})]}),(0,R.jsx)(`span`,{className:`hidden w-16 shrink-0 @xl:inline-flex`,children:ee&&(C?(0,R.jsx)(jE,{label:`Copy commit SHA`,children:(0,R.jsx)(`button`,{type:`button`,className:q(a6,`cursor-pointer rounded-sm px-1 font-mono transition-colors duration-(--dur-1) hover:bg-surface-selected hover:text-text`),onClick:()=>C(ee),children:Mh(ee)})}):(0,R.jsx)(`span`,{className:q(a6,`px-1 font-mono`),title:ee,children:Mh(ee)}))}),(0,R.jsx)(`span`,{className:`hidden w-44 shrink-0 @2xl:inline-flex`,children:l&&P&&(0,R.jsxs)(`span`,{className:q(a6,`inline-flex max-w-full items-center gap-1.5 font-mono`),title:`Burns on ${l.id} (${l.runtimeLabel})`,children:[(0,R.jsx)(P,{size:12,className:`shrink-0 text-icon`}),(0,R.jsx)(`span`,{className:`truncate`,children:l.id})]})}),(0,R.jsx)(`span`,{className:q(a6,`hidden w-14 text-right @md:block`),children:I}),(0,R.jsx)(`span`,{className:`flex shrink-0 animate-fade-in @md:w-28`,children:(0,R.jsx)(HA,{tone:F.tone,icon:F.icon,className:F.muted?`text-text-tertiary`:void 0,children:F.word})},D)]}),(ie||k||ne)&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 pr-2 pb-3 pl-17.5`,children:[ie&&(0,R.jsx)(`div`,{className:q(`min-w-0 truncate text-xs`,j?`text-danger`:`text-text-tertiary`),title:e.error,children:(0,R.jsx)(rI,{text:A})}),k&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`p`,{className:`m-0 flex items-start gap-1.5 text-sm text-text-secondary`,children:[(0,R.jsx)(Vb,{size:14,className:`mt-[3px] shrink-0 text-danger`}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[`Merge conflict — the work is committed but could not land on`,` `,(0,R.jsx)(`code`,{className:`font-mono text-xs text-text`,children:t})]})]}),k.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-0.5 p-0 pl-5`,children:k.map(e=>(0,R.jsx)(`li`,{className:`truncate font-mono text-xs text-text-secondary`,title:e,children:e},e))}),A&&(0,R.jsx)(`div`,{className:`truncate pl-5 text-xs text-text-tertiary`,title:e.error,children:(0,R.jsx)(rI,{text:A})})]}),ne&&(0,R.jsxs)(`div`,{className:`-ml-2 flex flex-wrap items-center gap-1`,children:[M&&_&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),disabled:f,title:k?`run an agent that merges the feature branch into this ticket’s branch and resolves the conflict — it gets the ticket, the feature docs, and the commits it is reconciling against`:`retry this ticket — continues from any commits preserved by previous attempts`,onClick:_,children:k?`Resolve with agent`:`Retry`}),M&&u&&v&&(0,R.jsx)(nJ,{value:``,roster:u,label:`Retry on…`,ticketKind:e.kind,onChange:v}),k&&S&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(mb,{}),disabled:f||h,title:h?`available once this run finishes and no terminal is open`:`open a terminal on the feature branch, briefed with this ticket and its conflicting files, and resolve it yourself`,onClick:S,children:`Resolve in terminal`}),M&&y&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(ub,{}),disabled:f,title:k?`throw away the conflicting branch and re-implement the ticket from the current feature branch tip`:`discard any preserved commits from previous attempts and redo the ticket from the feature branch tip`,onClick:()=>E(!0),children:`Retry fresh`}),M&&b&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(cb,{}),loading:m,disabled:f,title:`set this ticket aside — it stops asking to be retried and is carried into review as explicitly unfinished work`,onClick:b,children:m?`Waiving…`:`Waive`}),D===`burning`&&x&&(0,R.jsx)(Y,{variant:`danger-ghost`,size:`sm`,icon:(0,R.jsx)(Tb,{}),loading:p,disabled:f,title:`stop this ticket's agent — other lanes keep burning; committed work is preserved for retry`,onClick:x,children:p?`Stopping…`:`Stop ticket`}),N&&(0,R.jsx)(nJ,{value:e.model??``,roster:N.roster,ticketKind:e.kind,onChange:N.onChange})]})]}),r&&(0,R.jsxs)(`div`,{id:re,className:q(`flex flex-col gap-3 overflow-hidden pr-2 pb-4 pl-17.5`,`h-auto transition-[height,opacity] duration-(--dur-2) ease-out-app starting:h-0 starting:opacity-0`),children:[O&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`p`,{className:`m-0 flex items-start gap-1.5 text-sm text-text`,children:[(0,R.jsx)(Vb,{size:14,className:`mt-[3px] shrink-0 text-danger`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:O.text})]}),O.hint&&(0,R.jsx)(`p`,{className:`m-0 pl-5 text-sm text-text-secondary`,children:O.hint}),e.error&&(0,R.jsx)(Rj,{size:`sm`,title:`What the engine reported`,className:`pl-5`,children:(0,R.jsx)(`pre`,{className:`m-0 overflow-x-auto rounded-md bg-surface-inset px-3 py-2 font-mono text-xs whitespace-pre-wrap text-text-secondary`,children:e.error})})]}),w]}),y&&(0,R.jsx)(t6,{open:T,title:`Start ticket #${e.seq} over?`,body:`Any commits preserved from previous attempts are discarded and the ticket is redone from the feature branch tip.`,confirmLabel:`Retry fresh`,confirmIcon:(0,R.jsx)(ub,{}),busy:f,onConfirm:y,onClose:()=>E(!1)})]})}function s6({digest:e}){return e?.trim()?(0,R.jsx)(Rj,{bare:!0,title:`What this ticket produced`,icon:(0,R.jsx)(gb,{}),children:(0,R.jsx)(CK,{source:e})}):null}var c6={"claude-code":Ob,codex:kb};function l6({ticketId:e,bootEvents:t,runtime:n,poll:r=!0}){let{chunks:i,live:a,trimmed:o}=f6(e,r),s=(0,L.useRef)(null),[c,l]=(0,L.useState)(!0),{blocks:u,completed:d}=(0,L.useMemo)(()=>Z_(i),[i]);(0,L.useEffect)(()=>{if(!c)return;let e=s.current;e&&(e.scrollTop=e.scrollHeight)},[u,a,c]);let f=()=>{let e=s.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<24;l(t)},p=n?c6[n]:null,m=u.length>0||a;return(0,R.jsxs)(`div`,{className:`relative max-h-120 overflow-y-auto rounded-md bg-surface-inset px-4 py-3`,ref:s,onScroll:f,children:[o&&(0,R.jsx)(`div`,{className:`pb-2 text-center text-xs text-text-tertiary`,children:`Earlier output trimmed`}),!m&&(0,R.jsx)(Pj,{children:`No agent output captured — transcripts are held in server memory for the current burn; older runs keep only the event timeline.`}),m&&(0,R.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-text-secondary`,children:[p&&(0,R.jsx)(p,{size:14,className:`shrink-0 text-icon`}),n?pv(n):`Agent`]}),u.length===0&&a&&(0,R.jsx)(d6,{events:t}),u.length>0&&(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:u.map((e,t)=>(0,R.jsx)(u6,{block:e},t))}),d&&(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(HA,{tone:`success`,icon:(0,R.jsx)(sb,{}),children:`Agent reported complete`})}),a&&(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(HA,{tone:`live`,children:`Burning…`})}),!c&&(0,R.jsx)(`div`,{className:`pointer-events-none sticky bottom-0 flex justify-end`,children:(0,R.jsx)(`span`,{className:`pointer-events-auto rounded-md bg-surface-raised shadow-popover animate-fade-in`,children:(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(db,{}),onClick:()=>l(!0),children:`Follow`})})})]})}function u6({block:e}){return e.kind===`text`?(0,R.jsx)(`div`,{className:`py-1 animate-rise-in`,children:(0,R.jsx)(CK,{source:e.text,size:`base`,tone:`primary`})}):(0,R.jsx)(Rj,{size:`sm`,animate:!0,title:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,title:e.args||void 0,children:[(0,R.jsx)(`span`,{className:`shrink-0 font-medium text-text-secondary`,children:e.name}),e.args&&(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-text-tertiary`,children:e.args})]}),bodyClassName:`pb-1`,children:e.args&&(0,R.jsx)(`pre`,{className:`m-0 font-mono text-xs break-words whitespace-pre-wrap text-text-tertiary`,children:e.args})})}function d6({events:e}){return e.length===0?(0,R.jsx)(Pj,{children:`Starting the container…`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs animate-rise-in`,children:[(0,R.jsx)(`span`,{className:`shrink-0 text-text-tertiary tabular-nums`,children:Oh(e.ts)}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-text-secondary`,children:e.message})]},e.id))})}function f6(e,t){let[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1),c=n.length>0?n[n.length-1].i:void 0,l=Ch(1e3),u=B.run.agentTranscript.useQuery({ticketId:e,after:c},{refetchInterval:t?l:!1});return(0,L.useEffect)(()=>{let e=u.data;e&&(a(e.live),s(e.firstIndex>0),r(t=>{let n=t.length>0?t[t.length-1].i:-1;if(e.nextIndex<=n)return[];if(e.chunks.length===0)return t;let r=e.chunks.filter(e=>e.i>n);return r.length===0?t:[...t,...r]}))},[u.data]),{chunks:n,live:i,trimmed:o}}function p6({runs:e,selectedId:t,latestId:n,onPick:r}){if(e.length<2)return null;let i=e.findIndex(e=>e.id===t),a=i>=0?e[i]:void 0,o=a?`${a.id===n?`Latest`:Ih(a.startedAt)} · ${e.length} runs`:`${e.length} runs`;return(0,R.jsxs)(Wq,{value:t??void 0,onValueChange:r,children:[(0,R.jsxs)(Jq,{"aria-label":`Run history`,title:a?kh(a.startedAt):void 0,className:qq,children:[(0,R.jsx)(Bb,{size:14,className:`shrink-0 text-icon`}),(0,R.jsx)(Yq,{children:o})]}),(0,R.jsx)(Xq,{align:`end`,"aria-label":`Run history`,className:`min-w-72`,children:e.map(e=>(0,R.jsx)(eJ,{value:e.id,title:kh(e.startedAt),children:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,R.jsx)(`span`,{className:`w-16 shrink-0 text-xs text-text-tertiary tabular-nums`,children:Ih(e.startedAt)}),(0,R.jsx)(`span`,{className:`w-24 shrink-0`,children:(0,R.jsx)(qA,{status:e.status})}),(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Lap `,e.lap,` · `,e.ticketIds.length,` lane`,e.ticketIds.length===1?``:`s`]}),e.id===n&&(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-text-tertiary`,children:`latest`})]})},e.id))})]})}var m6=[/^All \d+ tickets? landed$/,/^(Burned|Burning) \d+ tickets?$/,/^\d+ (done|failed|waived)$/,/^Succeeded-unverified$/,/^nothing verified$/];function h6({headline:e,status:t,summary:n,burning:r,busy:i,cancelling:a,onCancelRun:o,runs:s=[],selectedRunId:c=null,latestRunId:l=null,onPickRun:u,onBackToLatest:d}){let[f,p]=(0,L.useState)(!1),m=e.split(` · `).filter(e=>!m6.some(t=>t.test(e))).join(`, `);return(0,R.jsxs)(`header`,{className:`mb-4 flex flex-col gap-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-7 items-center gap-2`,children:[(0,R.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 text-lg font-semibold text-text`,children:d?`Past run`:`Run`}),u&&(0,R.jsx)(p6,{runs:s,selectedId:c,latestId:l,onPick:u}),d&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Ub,{}),onClick:d,children:`Back to latest`}),o&&(0,R.jsx)(Y,{variant:`danger-ghost`,size:`sm`,icon:(0,R.jsx)(Tb,{}),loading:a,disabled:i,onClick:()=>p(!0),children:a?`Stopping…`:`Cancel run`})]}),m&&(0,R.jsx)(oj,{items:[{text:m}]}),t===`failed`&&n&&d&&(0,R.jsx)(`p`,{className:`m-0 text-sm text-pretty text-text-secondary`,children:(0,R.jsx)(rI,{text:n})}),o&&(0,R.jsx)(t6,{open:f,title:`Cancel this run?`,body:r>0?`Stops ${r} burning agent${r===1?``:`s`}. Finished work is kept; the burn can resume later.`:`Stops the run before its remaining tickets start. Finished work is kept; the burn can resume later.`,confirmLabel:`Cancel run`,confirmIcon:(0,R.jsx)(Tb,{}),busy:i,onConfirm:o,onClose:()=>p(!1)})]})}function g6({tickets:e,currentLap:t,lane:n}){let r=0;return(0,R.jsx)(`div`,{className:`@container flex flex-col border-t border-border-subtle`,children:(0,R.jsx)(Xj,{groups:i_(e,t),currentLap:t,meta:e=>`${e.rows.length} lane${e.rows.length===1?``:`s`}`,headClassName:`mt-2 px-2`,children:e=>(0,R.jsx)(`div`,{className:`flex flex-col`,children:$_(e).map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.title&&(0,R.jsx)($A,{className:`mt-4 px-2`,children:e.title}),e.rows.map(e=>n(e,r++))]},e.kind))})})})}var _6=140,v6=64;function y6(e){return e.replace(/```[^\n]*\n?/g,``).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/^\s{0,3}>\s?/gm,``).replace(/^\s*[-*+]\s+/gm,``).replace(/^\s*\d+\.\s+/gm,``).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/(\*\*|__)(.+?)\1/g,`$2`).replace(/~~(.+?)~~/g,`$1`).replace(/(^|[\s(])[*_](\S(?:.*?\S)?)[*_]($|[\s.,;:)!?])/g,`$1$2$3`).replace(/`([^`]+)`/g,`$1`).trim()}function b6(e){for(let t of e.split(`
|
|
188
|
-
`)){let e=t.trim();if(e!==``)return e}return``}function x6(e,t){return e.length>t?`${e.slice(0,t-1).trimEnd()}…`:e}function S6(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.name!=`string`||t.name===``?null:{name:t.name,args:typeof t.args==`string`?t.args:``}}function C6(e){return e.endsWith(`.tool`)}function w6(e){let t=e.replace(/[._]+/g,` `).trim();return t===``?``:`${t[0].toUpperCase()}${t.slice(1)}`}function T6(e,t){if(!t.startsWith(e))return null;let n=t.slice(e.length).replace(/^[\s:;,—–-]+/,``).trim().replace(/^\((.*)\)$/s,`$1`).trim(),r=w6(e);return n===``?r:`${r} — ${n}`}function E6(e){return typeof e==`object`&&e?e:null}function D6(e){return typeof e==`string`&&e!==``?e:null}function O6(e){if(e.type!==`feature.created`)return null;let t=E6(e.data),n=D6(t?.branch);if(!t||!n)return null;if(t.draft===!0)return`Feature created as a draft — ${n} is not cut yet`;if(t.branchReady!==!0)return`Feature created — branch ${n} is still being cut`;let r=D6(t.baseBranch);return r?`Feature created on branch ${n}, from ${r}`:`Feature created on branch ${n}`}function k6(e){if(C6(e.type)){let t=S6(e.data);if(!t){let t=b6(e.message);return{summary:x6(t,_6)||w6(e.type),detail:e.message.trim()===t?null:e.message.trim()}}let n=x6(b6(t.args),v6);return{summary:n?`${t.name} — ${n}`:`${t.name}`,detail:t.args.trim()===``?null:t.args.trim()}}let t=y6(e.message),n=O6(e)??T6(e.type,t)??t,r=x6(b6(n),_6),i=n===r?null:n;return{summary:r||w6(e.type),detail:i}}function A6(e){return e===`lap.started`}function j6(e){if(e.type!==`run.finished`||typeof e.data!=`object`||e.data===null)return null;let t=e.data.status;return t===`succeeded`||t===`failed`||t===`cancelled`?t:null}function M6(e){let t=j6(e);if(t)return t===`succeeded`?`ok`:`error`;let n=e.type;return n===`merge.conflict.resolved`?`ok`:n===`merge.conflict.resolving`?`active`:/(error|fail|conflict|cancel|stopped|timeout)/i.test(n)?`error`:/(done|succeed|finished|shipped|merged)/i.test(n)?`ok`:/(start|burn|launch|advance|running|retry|resum)/i.test(n)?`active`:`info`}function N6(e){if(typeof e.data!=`object`||e.data===null)return!1;let t=e.data;return t.oversized===!0||t.warning===!0}var P6={error:`danger`,ok:`success`,active:`neutral`,info:`neutral`};function F6({events:e}){let t=e.some(N6);return(0,R.jsxs)(Rj,{defaultOpen:t,title:`Run timeline`,icon:(0,R.jsx)(vb,{}),aside:(0,R.jsx)(`span`,{className:`tabular-nums`,children:e.length}),children:[e.length===0&&(0,R.jsx)(Pj,{children:`Waiting for events…`}),(0,R.jsx)(`ol`,{className:`@container m-0 flex max-h-96 list-none flex-col overflow-y-auto p-0`,children:e.map(e=>{let t=N6(e);return(0,R.jsxs)(`li`,{className:`flex min-h-7 items-start gap-3 py-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`w-20 shrink-0 pt-px text-xs whitespace-nowrap text-text-tertiary tabular-nums`,children:Oh(e.ts)}),(0,R.jsx)(`span`,{className:`inline-flex h-5 w-2 shrink-0 items-center justify-center`,children:(0,R.jsx)(BA,{tone:t?`warning`:P6[M6(e)]??`neutral`})}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1`,t?`break-words text-warning`:`truncate text-text-secondary`),children:t?(0,R.jsx)(rI,{text:e.message}):e.message}),(0,R.jsx)(`span`,{className:`hidden w-40 shrink-0 truncate pt-px text-right font-mono text-xs text-text-tertiary @xl:block`,children:e.type})]},e.id)})})]},t?`warned`:`quiet`)}function I6({gates:e}){return e.length===0?null:(0,R.jsxs)(`section`,{className:`mb-6 flex flex-col gap-2`,role:`alert`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(HA,{tone:`warning`,icon:(0,R.jsx)(Vb,{}),size:`sm`,strong:!0,children:`Verification unavailable`}),(0,R.jsx)(`p`,{className:`m-0 pl-5.5 text-sm text-text-secondary`,children:`The sandbox lacked a command or runtime. Ticket results were kept; these gates still need checking.`})]}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0 pl-5.5`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-0.5 border-t border-border-subtle py-2 first:border-t-0`,children:[(0,R.jsx)(`code`,{className:`font-mono text-xs text-text`,children:e.command}),(0,R.jsx)(`span`,{className:`font-mono text-xs break-words text-text-tertiary`,children:e.error})]},e.command))})]})}function L6({featureId:e,runId:t,readonly:n=!1}){let r=Ch(),i=gx(),a=B.useUtils(),[o,s]=(0,L.useState)(null),c=!!o&&o!==t,l=o??t,u=n||c,d=B.feature.get.useQuery({id:e},{refetchInterval:r}),f=B.run.get.useQuery({runId:l},{refetchInterval:!c&&r,enabled:!!l}),p=B.run.listByFeature.useQuery({featureId:e},{refetchInterval:r}),m=QF(e),h=d.data?.feature.projectId,g=B.settings.get.useQuery({projectId:h},{enabled:!!h}),_=B.findings.listByFeature.useQuery({featureId:e}),v={onSuccess:()=>a.feature.get.invalidate({id:e}),onError:e=>i.push(e.message)},y=B.ticket.retry.useMutation(v),b=B.ticket.edit.useMutation(v),x=B.ticket.stop.useMutation(v),S=B.ticket.cancel.useMutation(v),C=Ex(e),w=B.feature.launchSession.useMutation({...v,onSuccess:()=>{v.onSuccess(),C()}}),T=B.run.cancel.useMutation(v),E=y.isPending||b.isPending||x.isPending||S.isPending||w.isPending||T.isPending,D=d.data?.tickets??[],O=c?f.data?.tickets??[]:D,k=fh(e).data??[],A=sy(k,D),j=d.data?.feature.branch??``,M=d.data?.feature.lap??1,N=(0,L.useMemo)(()=>m.filter(e=>e.runId===l),[m,l]),P=(0,L.useMemo)(()=>E_(N),[N]),ee=(0,L.useMemo)(()=>ev(N),[N]),F=(0,L.useMemo)(()=>F_(N),[N]),[I,te]=(0,L.useState)(null),ne=O.find(e=>e.status===`burning`)?.id,re=I??new Set(ne?[ne]:[]),ie=e=>te(()=>{let t=new Set(re);return t.has(e)?t.delete(e):t.add(e),t}),ae=um(g.data),oe=(0,L.useMemo)(()=>new Map((_.data?.findings??[]).map(e=>[e.id,e.title])),[_.data]),se=e=>a_(e,ae)??a_({model:Lm(g.data,e.kind===`review`?`review`:`implement`)},ae),ce=(d.data?.sessions??[]).some(k_),le=ce||f.data?.status===`running`,ue=f.data?f.data.status===`running`:!!l;if(!t&&!ce)return(0,R.jsx)(Fj,{icon:(0,R.jsx)(xb,{}),title:`No run yet`,hint:`${hv} Every ticket gets its own lane here.`});let de=O.filter(e=>e.status===`burning`).length,fe=e=>{navigator.clipboard?.writeText(e).then(()=>i.push(`copied ${Mh(e)}`,`info`),()=>i.push(`copy failed`))},pe=e=>y.mutate({ticketId:e.id},{onSuccess:t=>{t.resolvingConflict?i.push(`resolving ticket #${e.seq}'s conflict with an agent`,`info`):t.resumedFrom&&i.push(`resuming ticket #${e.seq} from ${t.preservedCommits} preserved commit(s)`,`info`)}}),me=(t,n)=>{let r=ee.get(t.id),a=P.get(t.id),o=t.status===`failed`?t.conflictFiles:void 0;return(0,R.jsxs)(o6,{ticket:t,featureBranch:j,readonly:u,expanded:re.has(t.id),index:n,onToggle:()=>ie(t.id),hadOutput:r?.hadOutput,elapsed:r?Lh(r.startedAt,Date.now()):void 0,duration:a===void 0?void 0:Lh(0,a),model:se(t),roster:ae,defectTitle:t.originFindingId?oe.get(t.originFindingId):void 0,busy:E,stopping:x.isPending&&x.variables?.ticketId===t.id,waiving:S.isPending&&S.variables?.ticketId===t.id,terminalBlocked:le,onCopySha:fe,onModel:e=>b.mutate({ticketId:t.id,model:e}),onRetry:()=>pe(t),onRetryWithModel:ue?void 0:e=>b.mutate({ticketId:t.id,model:e},{onSuccess:()=>pe(t)}),onRetryFresh:()=>y.mutate({ticketId:t.id,fresh:!0}),onWaive:()=>S.mutate({ticketId:t.id,reason:`waived from the run view`},{onSuccess:e=>{i.push(`ticket #${t.seq} set aside — it stays visible as unfinished work at review`,`info`),e.confirmed||i.push(_v)}}),onStop:()=>x.mutate({ticketId:t.id},{onSuccess:e=>{e.swept?i.push(`no live agent — the lane was orphaned; marked failed, retry to resume it`,`info`):e.stopped?e.confirmed||i.push(_v):i.push(`no live agent for this ticket (already finishing?)`,`info`)}}),onResolveInTerminal:o?()=>w.mutate({featureId:e,kind:`chat`,kickoffLine:__({seq:t.seq,title:t.title,branch:t.attemptBranch??``,featureBranch:j,files:o}),purpose:`resolve-conflict`,purposeData:{mergeFrom:t.attemptBranch??``,mergeInto:j}}):void 0,children:[(0,R.jsx)(s6,{digest:t.digest}),(0,R.jsx)(LJ,{label:`agent transcript`,children:(0,R.jsx)(l6,{ticketId:t.id,bootEvents:N.filter(e=>e.ticketId===t.id),runtime:se(t)?.runtime,poll:!c})})]},t.id)};return(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[f.data&&(0,R.jsx)(`div`,{"data-tier":`status`,className:`mb-10`,children:(0,R.jsx)(k3,{artifact:A,outcome:xy({passes:k,tickets:D}),currentLap:M,landedSince:A?.landedSince??0,tickets:O,runState:f.data.status,verification:ly(D),building:{elapsed:Lh(f.data.startedAt,f.data.endedAt??Date.now()),lap:p.data?.find(e=>e.id===l)?.lap??M}})}),(0,R.jsx)(h6,{headline:V_(O.map(e=>({...e,hadOutput:ee.get(e.id)?.hadOutput,reviewFix:!!e.originFindingId})),{status:f.data?.status},tv(O,N)),status:f.data?.status,summary:f.data?.summary,burning:de,busy:E,cancelling:T.isPending,onCancelRun:u||!t||f.data?.status!==`running`?void 0:()=>T.mutate({runId:t},{onSuccess:e=>{e.confirmed||i.push(_v)}}),runs:p.data??[],selectedRunId:l,latestRunId:t,onPickRun:s,...c?{onBackToLatest:()=>s(null)}:{}}),(0,R.jsx)(I6,{gates:F}),O.length===0?(0,R.jsx)(Fj,{icon:(0,R.jsx)(xb,{}),title:`No ticket lanes`,hint:`This run has nothing to burn — a session breaks the work into tickets, and they appear here as lanes.`}):(0,R.jsx)(g6,{tickets:O,currentLap:M,lane:me}),(0,R.jsxs)(`div`,{className:`mt-8 flex flex-col`,children:[(0,R.jsx)(F6,{events:N}),f.data?.digest&&(0,R.jsx)(R6,{digest:f.data.digest})]})]})}function R6({digest:e}){return(0,R.jsx)(Rj,{title:`What this run produced`,icon:(0,R.jsx)(gb,{}),children:(0,R.jsx)(CK,{source:e})})}var z6={error:`danger`,ok:`success`,active:`accent`,info:`neutral`};function B6(e){return e.replace(/_/g,` `).replace(`.`,` · `)}function V6({events:e}){let t=e.slice(-50).reverse();return t.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(vb,{}),title:`Nothing yet`,hint:`Everything that happens to this feature shows up here.`}):(0,R.jsx)(`div`,{className:`flex flex-col`,children:t.map(e=>A6(e.type)?(0,R.jsx)(H6,{event:e},e.id):(0,R.jsx)(U6,{event:e},e.id))})}function H6({event:e}){return(0,R.jsxs)(`div`,{className:`my-2 flex items-center gap-2 text-xs font-medium text-accent-text`,role:`separator`,children:[(0,R.jsx)(`span`,{className:`first-letter:uppercase`,children:k6(e).summary}),(0,R.jsx)(`span`,{className:`h-px flex-1 bg-border-subtle`}),(0,R.jsx)(`span`,{className:`font-normal text-text-tertiary tabular-nums`,children:Fh(e.ts)})]})}function U6({event:e}){let[t,n]=(0,L.useState)(!1),r=k6(e);return(0,R.jsxs)(`div`,{className:`flex gap-3 py-2`,children:[(0,R.jsx)(`span`,{className:`flex h-5 w-1.5 shrink-0 items-center`,children:(0,R.jsx)(BA,{tone:z6[M6(e)]})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r.detail?(0,R.jsxs)(`button`,{type:`button`,className:`group/ev m-0 flex w-full cursor-pointer items-start gap-1 bg-transparent p-0 text-left text-sm text-text-secondary transition-colors duration-(--dur-1) ease-app hover:text-text`,"aria-expanded":t,title:t?`Show less`:`Show the whole event`,onClick:()=>n(e=>!e),children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:r.summary}),(0,R.jsx)(fb,{size:14,"aria-hidden":`true`,className:q(`mt-0.5 shrink-0 text-icon transition-transform duration-(--dur-2) ease-app`,t&&`rotate-90`)})]}):(0,R.jsx)(`div`,{className:`text-sm text-text-secondary`,children:r.summary}),t&&r.detail&&(0,R.jsx)(`pre`,{className:`m-0 mt-2 max-h-[260px] overflow-auto rounded-md bg-surface-inset px-2.5 py-2 font-mono text-xs break-words whitespace-pre-wrap text-text-secondary animate-fade-in`,children:r.detail}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex items-baseline gap-2 text-xs text-text-tertiary`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:B6(e.type)}),(0,R.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:Fh(e.ts)})]})]})]})}function W6(e){return e.split(/[\\/]/).pop()??e}function G6({featureId:e,docs:t}){let[n,r]=(0,L.useState)(null),i=(0,L.useRef)(null);return(0,R.jsxs)(`section`,{"aria-label":`Knowledge`,children:[t.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(gb,{}),title:`No docs yet`,hint:`Docs the sessions write — decisions, the spec, the brief — collect here.`}):(0,R.jsx)(ij,{label:`Feature docs`,className:`-mx-2`,children:t.map((e,t)=>(0,R.jsx)(rj,{index:t,leading:(0,R.jsx)(gb,{}),title:e.title||W6(e.relPath),meta:(0,R.jsx)(`span`,{className:`font-mono`,children:W6(e.relPath)}),onClick:t=>{i.current=t.currentTarget,r({relPath:e.relPath,title:e.title})}},e.relPath))}),n&&(0,R.jsx)(q3,{featureId:e,relPath:n.relPath,title:n.title,returnFocusRef:i,onClose:()=>r(null)})]})}var K6=[{id:`knowledge`,label:`Knowledge`,icon:(0,R.jsx)(gb,{})},{id:`activity`,label:`Activity`,icon:(0,R.jsx)(vb,{})}];function q6({featureId:e,onClose:t}){return t?(0,R.jsx)(J6,{featureId:e,onClose:t}):null}function J6({featureId:e,onClose:t}){let[n,r]=(0,L.useState)(`knowledge`),i=B.feature.get.useQuery({id:e},{refetchInterval:Ch()}),a=QF(e);return(0,R.jsx)(Sj,{label:`Details`,title:(0,R.jsx)(cj,{items:K6,value:n,onChange:r,size:`sm`,label:`Details`}),onClose:t,bodyClassName:`px-4 py-4`,children:i.isLoading?(0,R.jsx)(X6,{}):i.data?(0,R.jsx)(`div`,{role:`tabpanel`,"aria-label":n===`knowledge`?`Knowledge`:`Activity`,className:`animate-fade-in`,children:n===`knowledge`?(0,R.jsx)(G6,{featureId:e,docs:i.data.docs}):(0,R.jsx)(V6,{events:a})},n):(0,R.jsx)(Pj,{children:i.error?.message??`Could not load the details`})})}var Y6=[`w-28`,`w-20`,`w-32`];function X6(){return(0,R.jsx)(Oj,{label:`Loading the details…`,children:(0,R.jsx)(`div`,{className:`-mx-2 flex flex-col`,children:Y6.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 px-3`,"data-skeleton":`doc-row`,children:[(0,R.jsx)(kj,{className:`size-4`}),(0,R.jsx)(kj,{className:q(`h-3`,e)}),(0,R.jsx)(kj,{className:`ml-auto h-2.5 w-16`})]},t))})})}function Z6({featureId:e,sessionId:t,onEnded:n}){let r=B.useUtils(),i=gx(),a=B.feature.endSession.useMutation({onSuccess:()=>{e&&(r.feature.get.invalidate({id:e}),r.feature.list.invalidate()),n?.(),i.push(`session ended`,`info`)},onError:e=>i.push(e.message)});return(0,R.jsx)(Y,{variant:`danger-ghost`,size:`sm`,icon:(0,R.jsx)(Tb,{}),loading:a.isPending,title:`end this session — recoverable, you can relaunch it`,onClick:()=>a.mutate({sessionId:t}),children:a.isPending?`Ending…`:`End session`})}function Q6({session:e,contextLine:t,meta:n,featureId:r,onEnded:i,notices:a,headless:o,transcriptId:s,onLaunch:c,launchLabel:l,launching:u=!1,hidden:d=!1,label:f=`Chat`,children:p}){return(0,R.jsxs)(`section`,{"aria-label":f,"aria-hidden":d,hidden:d,"data-chat-view":``,className:d?`hidden`:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex h-10 flex-none items-center gap-3 border-b border-border-subtle px-4 text-xs text-text-tertiary`,children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 shrink-0 items-center gap-2 text-sm font-medium text-text`,children:[e&&(0,R.jsx)(BA,{tone:e.status===`launching`?`accent`:`live`,label:e.status===`launching`?`Starting`:`Live`}),t]}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-4 truncate`,children:n}),e&&(0,R.jsx)(Z6,{featureId:r,sessionId:e.id,onEnded:i})]}),e&&a&&(0,R.jsx)(`div`,{className:`flex-none px-4 pt-2`,children:a}),(0,R.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col bg-surface-inset animate-fade-in`,children:[e&&o?(0,R.jsx)(`div`,{className:`px-6 py-6 text-sm text-text-secondary`,children:o}):e?(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,"data-chat-terminal":``,children:(0,R.jsx)(LJ,{label:`terminal`,children:(0,R.jsx)(c4,{sessionId:e.id})})}):(0,R.jsx)($6,{transcriptId:s,onLaunch:c,launchLabel:l,launching:u}),p]})]})}function $6({transcriptId:e,onLaunch:t,launchLabel:n,launching:r}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,R.jsx)(`div`,{className:`mx-auto w-full max-w-(--content-max)`,children:e?(0,R.jsx)(W3,{sessionId:e,className:`flex flex-col gap-4`}):(0,R.jsx)(Fj,{icon:(0,R.jsx)(hb,{}),title:`No conversation yet`,hint:`One chat per feature — it knows the state, answers questions, and edits the next burn's tickets.`})})}),t&&(0,R.jsx)(`div`,{className:`flex flex-none items-center justify-center gap-3 border-t border-border-subtle bg-surface px-4 py-3`,children:(0,R.jsx)(Y,{variant:`primary`,icon:e?(0,R.jsx)(Gb,{}):(0,R.jsx)(wb,{}),loading:r,onClick:t,children:n??(e?`Resume the conversation`:`Start the conversation`)})})]})}var e8=new Set([`tickets.stored`,`ticket.edited`,`ticket.cancelled`]),t8=/^ticket (\d+) failed(?::\s*(.*))?$/s,n8=/(\d+)\/(\d+) tickets done/;function r8(e,t=[]){let n=t=>({...t,count:1,eventId:e.id});if(e.type===`docs.changed`){let t=i8(e),r=e=>t.some(t=>t===e||t.endsWith(`/${e}`));return r(`preview.html`)?n({kind:`preview`,hue:`planning`,title:`Preview ready`,subtitle:ui,actionLabel:`View preview`,target:`overview`}):r(`spec.md`)?n({kind:`spec`,hue:`planning`,title:`Spec written`,subtitle:`spec.md`,actionLabel:`View spec`,target:`overview`}):null}if(e8.has(e.type))return n({kind:`tickets`,hue:`tickets`,title:`Tickets updated`,subtitle:e.message,actionLabel:`View tickets`,target:`overview`});if(e.type===`ticket.failed`){let t=t8.exec(e.message);return n({kind:`ticket-failed`,hue:`danger`,title:t?`Ticket #${t[1]} failed`:`Ticket failed`,subtitle:t?.[2]?.trim()||e.message,actionLabel:`View run`,target:`overview`})}if(e.type===`run.finished`){let t=e.data??{},r=t.status!==`succeeded`,i=typeof t.summary==`string`?t.summary:e.message,a=n8.exec(i);return n({kind:`run`,hue:r?`danger`:`building`,title:r?`Run finished with failures`:`Run finished`,subtitle:a?`${a[1]} of ${a[2]} landed`:i,actionLabel:`View run`,target:`overview`})}if(e.type===`ticket.done`){let r=t.find(t=>t.id===e.ticketId);return r?.kind!==`review`||r.passKind===`verification`?null:n({kind:`review`,hue:`review`,title:`Review ready`,subtitle:r.title,actionLabel:`View review`,target:`overview`})}if(e.type===`testdrive.url`){let t=e.data??{};return n({kind:`drive`,hue:`review`,title:`Test drive running`,subtitle:typeof t.url==`string`?t.url:e.message,actionLabel:`Open`,target:`overview`})}return null}function i8(e){let t=e.data?.files;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function a8(e,t){switch(t.type){case`push`:{let n=e.find(e=>e.kind===t.notice.kind);return[n?{...t.notice,count:n.count+t.notice.count}:t.notice,...e.filter(e=>e.kind!==t.notice.kind)].slice(0,4)}case`dismiss`:case`act`:return e.filter(e=>e.kind!==t.kind)}}var o8=2,s8=9,c8={planning:{text:`text-phase-planning`,chip:`bg-phase-planning/15 ring-phase-planning/30`,tint:`bg-phase-planning/15`,action:`bg-phase-planning/15 hover:bg-phase-planning/25`,glow:`from-phase-planning/10`},tickets:{text:`text-phase-tickets`,chip:`bg-phase-tickets/15 ring-phase-tickets/30`,tint:`bg-phase-tickets/15`,action:`bg-phase-tickets/15 hover:bg-phase-tickets/25`,glow:`from-phase-tickets/10`},building:{text:`text-phase-building`,chip:`bg-phase-building/15 ring-phase-building/30`,tint:`bg-phase-building/15`,action:`bg-phase-building/15 hover:bg-phase-building/25`,glow:`from-phase-building/10`},review:{text:`text-phase-review`,chip:`bg-phase-review/15 ring-phase-review/30`,tint:`bg-phase-review/15`,action:`bg-phase-review/15 hover:bg-phase-review/25`,glow:`from-phase-review/10`},danger:{text:`text-danger`,chip:`bg-danger/15 ring-danger/30`,tint:`bg-danger/15`,action:`bg-danger/15 hover:bg-danger/25`,glow:`from-danger/10`}},l8={planning:ix.planning,tickets:ix.tickets,building:ix.building,review:ix.review,danger:ix.building};function u8(e){return e===`danger`?(0,R.jsx)(Vb,{size:16}):(0,R.jsx)(sx,{phase:e,label:``})}function d8({notices:e,onAct:t,onDismiss:n}){let[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(!1),s=r||a;function c(e){e.currentTarget.contains(e.relatedTarget)||o(!1)}return(0,R.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":`Chat notifications`,"data-open":s||void 0,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>o(!0),onBlur:c,className:`absolute right-4 bottom-4 z-20 w-[360px] max-w-[calc(100%-2rem)]`,children:[!s&&e.length>1&&(0,R.jsxs)(`p`,{className:`m-0 mb-1 text-right text-xs text-text-tertiary`,children:[e.length,` notifications`]}),(0,R.jsx)(`ol`,{className:q(`m-0 list-none p-0`,s?`flex flex-col-reverse gap-2`:`relative`,!s&&e.length>1&&`mt-[18px]`),children:e.map((e,r)=>{let i=!s&&r>0,a=i?{transform:`translateY(${-r*s8}px) scale(${1-r*.05})`,zIndex:-r}:void 0;return(0,R.jsx)(`li`,{"aria-hidden":i||void 0,style:a,className:q(`origin-bottom transition-[transform,opacity] duration-(--dur-3) ease-out-app`,`motion-reduce:transition-none`,i&&`absolute inset-0`,i&&r>o8&&`opacity-0`),children:(0,R.jsx)(f8,{notice:e,hidden:i,onAct:t,onDismiss:n})},`${e.kind}-${e.eventId}`)})})]})}function f8({notice:e,hidden:t,onAct:n,onDismiss:r}){let i=c8[e.hue],a=q(`transition-opacity duration-(--dur-2) ease-app`,t&&`invisible opacity-0`);return(0,R.jsxs)(`article`,{"data-hue":e.hue,className:`relative grid h-full animate-rise-in grid-cols-[32px_1fr_24px] gap-x-3 overflow-hidden rounded-lg bg-surface-raised py-3 pr-3 pl-3.5 text-sm shadow-popover motion-reduce:animate-none`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`pointer-events-none absolute inset-0 bg-radial-[120%_90%_at_0%_0%] to-transparent to-60%`,i.glow)}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`relative grid size-8 place-items-center rounded-lg ring-1 ring-inset`,i.chip,i.text,a),children:u8(e.hue)}),(0,R.jsxs)(`div`,{className:q(`relative flex min-w-0 flex-col gap-px`,a),children:[(0,R.jsx)(`span`,{className:q(`text-xs font-semibold tracking-wide uppercase`,i.text),children:l8[e.hue]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-text`,children:[e.title,e.count>1&&(0,R.jsxs)(`span`,{"aria-label":`${e.count} times`,className:q(`rounded-full px-1.5 text-xs font-semibold tabular-nums`,i.tint,i.text),children:[`×`,e.count]})]}),(0,R.jsx)(`span`,{className:`text-xs [overflow-wrap:anywhere] text-text-secondary`,children:e.subtitle}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(e.kind),className:q(qE,`mt-2 inline-flex cursor-pointer items-center gap-1.5 self-start rounded-md px-2.5 py-1 text-xs font-semibold`,`transition-colors duration-(--dur-1) ease-app`,i.action,i.text),children:[e.actionLabel,(0,R.jsx)(Cb,{size:12})]})]}),(0,R.jsx)(UE,{label:`Dismiss`,size:`sm`,icon:(0,R.jsx)(cb,{size:12}),onClick:()=>r(e.kind),className:q(`relative`,a)})]})}function p8({events:e,tickets:t,active:n,onView:r}){let[i,a]=(0,L.useReducer)(a8,[]),o=(0,L.useRef)(null),s=(0,L.useRef)(0);return(0,L.useEffect)(()=>{if(!n){o.current=null;return}let r=o.current??=Date.now();for(let n of e){if(n.id<=s.current||(s.current=n.id,n.ts<r))continue;let e=r8(n,t);e&&a({type:`push`,notice:e})}},[n,e,t]),(0,R.jsx)(d8,{notices:i,onAct:e=>{let t=i.find(t=>t.kind===e);a({type:`act`,kind:e}),t&&r(t.target)},onDismiss:e=>a({type:`dismiss`,kind:e})})}function m8({featureId:e,session:t}){let n=QF(e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(g8,{session:t,events:n}),(0,R.jsx)(v8,{session:t,notReady:O_(n,t.id)})]})}var h8=5e3;function g8({session:e,events:t}){return D_(e,t,_8(h8))?(0,R.jsx)(`p`,{className:`m-0 pb-1.5 text-xs text-text-tertiary animate-fade-in`,children:`The agent hasn’t checked in yet.`}):null}function _8(e){let[t,n]=(0,L.useState)(()=>Date.now());return(0,L.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function v8({session:e,notReady:t}){return t?(0,R.jsxs)(`div`,{className:`flex items-start gap-1.5 pb-2 text-sm text-text-secondary animate-fade-in`,role:`status`,children:[(0,R.jsx)(HA,{tone:`warning`,icon:(0,R.jsx)(Vb,{}),size:`sm`,strong:!0,className:`shrink-0`,children:`Not ready`}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[`— `,mv(e),` has not started on its briefing. Answer anything waiting in the terminal (a trust or login prompt).`]})]}):null}function y8({full:e,events:t,hidden:n,launching:r,onLaunch:i,onView:a}){let o=j_(e.sessions),s=bv(e.sessions);return(0,R.jsx)(Q6,{label:`Feature chat`,session:o??null,contextLine:o?Sv(o):`Chat · lap ${e.feature.lap}`,meta:`One transcript per feature`,featureId:e.feature.id,notices:o&&(0,R.jsx)(m8,{featureId:e.feature.id,session:o}),headless:o&&xv(o)?`This feature is planning itself. There is no terminal to watch; the plan appears on the Overview as it is written.`:void 0,transcriptId:s?.id,onLaunch:i,launching:r,hidden:n,children:(0,R.jsx)(p8,{events:t,tickets:e.tickets,active:!n,onView:a})})}function b8({isDraft:e,value:t,onChange:n,sessionLive:r}){return e?null:(0,R.jsx)(cj,{label:`Feature views`,size:`sm`,value:t,onChange:n,items:[{id:`overview`,label:`Overview`,icon:(0,R.jsx)(zb,{})},{id:`chat`,label:(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Chat`,r&&(0,R.jsx)(BA,{tone:`live`,label:`Session live`})]}),icon:(0,R.jsx)(hb,{})}]})}function x8({featureId:e,line:t,onOpen:n}){return(0,R.jsx)(NJ,{tone:`quiet`,role:`status`,icon:(0,R.jsx)(XA,{status:`live`}),title:t.text,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(Cb,{}),onClick:n,children:`Open chat`}),(0,R.jsx)(Z6,{featureId:e,sessionId:t.sessionId})]})})}function S8({tag:e,details:t,children:n}){let r=gx();return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md bg-danger-subtle px-4 py-3`,role:`alert`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,R.jsx)(Vb,{size:16,className:`shrink-0`}),e]}),(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-secondary`,children:n}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-text-tertiary`,title:t,children:t}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Fb,{}),onClick:()=>gF(t,r),children:`Copy details`})]})]})}function C8({crumb:e,children:t}){return(0,R.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface`,children:[(0,R.jsx)(_j,{crumbs:[{label:e,icon:(0,R.jsx)(Vb,{})}]}),(0,R.jsx)(yj,{children:t})]})}function w8({featureId:e,error:t}){return(0,R.jsx)(C8,{crumb:`Feature`,children:(0,R.jsx)(S8,{tag:`Broken`,details:`feature ${e} — ${t.name}: ${t.message}`,children:`This feature couldn't be rendered. Everything else still works.`})})}function T8({feature:e}){return(0,R.jsxs)(C8,{crumb:e.title,children:[(0,R.jsx)(bj,{title:e.title,meta:[{text:`Unknown phase`}]}),(0,R.jsx)(`div`,{className:`mt-8`,children:(0,R.jsxs)(S8,{tag:`Unrecognized phase`,details:`feature ${e.id} (${e.slug}) has phase "${e.phase}"`,children:[`This feature's phase is `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-text`,children:e.phase}),`, which this version of runcastle doesn't know. Nothing here can be acted on until the row is fixed.`]})})]})}var E8=`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-text-tertiary`;function D8(e){return e.satisfied?`success`:e.status===`archived`||e.status===`draft`?`neutral`:`accent`}function O8({dep:e,onRemove:t}){return(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm text-text`,children:e.title}),(0,R.jsx)(HA,{tone:D8(e),...e.satisfied?{icon:(0,R.jsx)(sb,{size:12})}:{},title:e.slug,children:Bh(e)}),t&&(0,R.jsx)(UE,{label:`Stop waiting on ${e.slug}`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:t})]})}function k8({isDraft:e,dependsOn:t,candidates:n,onChange:r}){let[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(!1);if(!e)return t.length===0?null:(0,R.jsxs)(`p`,{className:E8,children:[(0,R.jsx)(`span`,{children:`Waited on:`}),t.map(e=>(0,R.jsx)(O8,{dep:e},e.featureId))]});let c=t.map(e=>e.featureId),l=e=>{a(null),s(!0),r(e).catch(e=>a(y6(e instanceof Error?e.message:String(e)))).finally(()=>s(!1))};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`div`,{className:E8,children:[(0,R.jsx)(`span`,{children:`Waits on`}),t.length===0&&(0,R.jsx)(`span`,{children:`nothing`}),t.map(e=>(0,R.jsx)(O8,{dep:e,...e.satisfied?{}:{onRemove:()=>l(c.filter(t=>t!==e.featureId))}},e.featureId)),(0,R.jsxs)(OA,{children:[(0,R.jsx)(kA,{asChild:!0,children:(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(ob,{}),loading:o,children:`Add`})}),(0,R.jsxs)(AA,{align:`start`,children:[(0,R.jsx)(jA,{placeholder:`Find a feature…`}),(0,R.jsxs)(MA,{label:`Features to wait on`,children:[(0,R.jsx)(NA,{children:`No unmerged feature to wait on`}),n.map(e=>(0,R.jsx)(LA,{value:`${e.title} ${e.slug}`,onSelect:()=>l([...c,e.id]),children:e.title},e.id))]})]})]})]}),i&&(0,R.jsx)(`p`,{className:`m-0 text-xs text-danger`,role:`alert`,children:i})]})}function A8({projectId:e,blocks:t}){return t.length===0?null:(0,R.jsxs)(`p`,{className:E8,children:[(0,R.jsx)(`span`,{children:`Blocks:`}),t.map((n,r)=>(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`a`,{className:q(JE,`font-mono`),href:Sg({kind:`feature`,projectId:e,featureSlug:n.slug}),title:n.title,children:n.slug}),r<t.length-1&&`,`]},n.featureId))]})}function j8({step:e}){return e.state===`done`?(0,R.jsx)(sx,{phase:`shipped`,size:14,label:``}):e.state===`current`?(0,R.jsx)(sx,{phase:e.phase,size:14,label:``}):(0,R.jsx)(sx,{phase:`draft`,size:14,label:``,className:`text-text-tertiary`})}var M8={done:`text-text-secondary`,current:`font-medium text-text bg-[color-mix(in_srgb,var(--step-hue)_14%,transparent)]`,upcoming:`text-text-tertiary`};function N8({steps:e,onView:t,readonly:n=!1}){return(0,R.jsx)(`nav`,{"aria-label":`Pipeline`,className:`-ml-2 flex flex-wrap items-center gap-x-0.5 gap-y-1`,children:e.map((r,i)=>{let a=n&&r.isViewed;return(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,className:q(`inline-flex h-(--control-sm) shrink-0 items-center gap-1.5 rounded-md px-2 text-xs`,`transition-colors duration-(--dur-1) ease-app`,M8[r.state],a&&`bg-surface-selected text-text`,r.clickable&&!a?`cursor-pointer hover:bg-surface-hover hover:text-text`:r.clickable?`cursor-pointer`:`cursor-default`),style:{"--step-hue":`var(--color-phase-${r.phase})`},title:r.tip,"aria-current":r.state===`current`?`step`:void 0,"aria-pressed":r.clickable?a:void 0,disabled:!r.clickable,onClick:()=>r.clickable&&t(r.phase),children:[(0,R.jsx)(j8,{step:r}),(0,R.jsx)(`span`,{children:ix[r.phase]})]}),i<e.length-1&&(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-px w-3 shrink-0 bg-border-strong`})]},r.phase)})})}function P8({feature:e,isDraft:t,steps:n,onViewPhase:r,readonly:i=!1,facts:a=[],className:o,children:s}){let c=gx(),l=(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1.5`,children:[!t&&e.branch&&(0,R.jsxs)(`button`,{type:`button`,className:q(`inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1.5 rounded-sm bg-transparent p-0`,`font-mono text-xs text-text-tertiary transition-colors duration-(--dur-1) ease-app hover:text-text`),title:`Copy branch name`,onClick:()=>gF(e.branch,c),children:[(0,R.jsx)(rb,{size:14,className:`shrink-0 text-icon`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.branch})]}),(0,R.jsx)(oj,{items:a})]});return(0,R.jsx)(bj,{title:e.title,meta:l,className:o,children:(!t||s)&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[!t&&(0,R.jsx)(N8,{steps:n,readonly:i,onView:t=>r(t===e.phase?null:t)}),s]})})}var F8=[[`w-12`,`w-40`],[`w-12`,`w-32`],[`w-16`,`w-24`]];function I8(){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(_j,{leading:(0,R.jsx)(Oj,{children:(0,R.jsx)(kj,{className:`h-3 w-40`})})}),(0,R.jsx)(yj,{children:(0,R.jsxs)(Oj,{label:`Loading feature…`,children:[(0,R.jsx)(`div`,{className:`flex h-7 items-center`,"data-skeleton":`title`,children:(0,R.jsx)(kj,{className:`h-5 w-2/5`})}),(0,R.jsxs)(`div`,{className:`mt-2 flex h-4 items-center gap-1.5`,"data-skeleton":`branch`,children:[(0,R.jsx)(kj,{className:`size-3.5`}),(0,R.jsx)(kj,{className:`h-2.5 w-64`})]}),(0,R.jsx)(`div`,{className:`mt-5 -ml-2 flex items-center gap-x-0.5`,children:Kv.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-x-0.5`,children:[t>0&&(0,R.jsx)(`span`,{className:`mx-0.5 h-px w-3 bg-border-subtle`}),(0,R.jsxs)(`div`,{className:`flex h-(--control-sm) items-center gap-1.5 px-2`,"data-skeleton":`step`,children:[(0,R.jsx)(kj,{className:`size-3.5 rounded-full`}),(0,R.jsx)(kj,{className:`h-2.5 w-14`})]})]},e))}),(0,R.jsx)(`div`,{className:`mt-10 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-1.5`,children:F8.map(([e,t],n)=>(0,R.jsxs)(`div`,{className:`contents`,"data-skeleton":`row`,children:[(0,R.jsx)(`div`,{className:`flex min-h-6 items-center`,children:(0,R.jsx)(kj,{className:q(`h-3`,e)})}),(0,R.jsx)(`div`,{className:`flex min-h-6 items-center`,children:(0,R.jsx)(kj,{className:q(`h-3`,t)})})]},n))})]})})]})}var L8={startDraft:(0,R.jsx)(wb,{}),chat:(0,R.jsx)(hb,{}),selfPlan:(0,R.jsx)(Db,{}),stopSelfPlan:(0,R.jsx)(Tb,{}),burn:(0,R.jsx)(xb,{}),cancelRun:(0,R.jsx)(Tb,{}),openBurnSettings:(0,R.jsx)(tb,{}),testDriveStart:(0,R.jsx)(wb,{}),testDriveStop:(0,R.jsx)(Tb,{}),stopDriveAndIterate:(0,R.jsx)(Tb,{}),fixDrive:(0,R.jsx)(mb,{}),merge:(0,R.jsx)(Nb,{}),resolveConflict:(0,R.jsx)(Vb,{}),iterate:(0,R.jsx)(Gb,{}),endSessionAndIterate:(0,R.jsx)(Gb,{}),unarchive:(0,R.jsx)(jb,{})},R8={danger:`danger`,note:`neutral`,clear:`success`};function z8(e){return/[.!?…:]$/.test(e)?e:`${e}.`}function B8({ns:e,guidance:t,busy:n,onAction:r,draftBranch:i,demote:a}){let o=e.secondary,s=[...o,e.primary].filter(e=>!!e?.disabled),c=!!e.primary||o.length>0,l=o.filter(e=>!a?.includes(e.kind)),u=o.filter(e=>a?.includes(e.kind)),d=l.length>2?l.slice(0,2):l,f=[...l.length>2?l.slice(2):[],...u],p=s.filter(t=>!a?.includes(t.kind)||t===e.primary);if(!c&&!e.busy&&!e.alert&&!e.counts&&!e.note)return null;let m=e.title??(t?void 0:e.desc),h=t&&e.desc&&e.desc!==m?e.desc:void 0;return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-3 animate-fade-in`,role:e.alert?`alert`:void 0,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 basis-80 text-sm text-text-secondary`,children:[(m||h)&&(0,R.jsxs)(`p`,{className:`m-0 text-pretty`,children:[e.busy?(0,R.jsx)(KE,{size:`sm`,className:`mr-2 inline-block align-[-2px]`}):e.alert?(0,R.jsx)(BA,{tone:`warning`,className:`mr-2 align-middle`}):null,m&&(0,R.jsx)(`span`,{className:`font-medium text-text`,children:h?z8(m):m}),m&&h&&` `,h]}),e.counts&&(0,R.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1`,children:[e.counts.pills.map(e=>(0,R.jsx)(HA,{tone:R8[e.tone],size:`sm`,children:e.label},e.label)),e.counts.trailing&&(0,R.jsx)(`span`,{className:`text-sm text-text-tertiary`,children:e.counts.trailing})]}),e.note&&(0,R.jsx)(`p`,{className:`mt-1.5 mb-0 text-xs text-text-tertiary first-letter:uppercase`,role:`note`,children:e.note})]}),c&&(0,R.jsxs)(`div`,{className:`ml-auto flex min-w-0 flex-col items-end gap-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:[d.map((e,t)=>(0,R.jsx)(Y,{variant:`ghost`,icon:L8[e.kind],disabled:n||!!e.disabled,title:e.disabled??e.hint,onClick:()=>r(e.kind),children:e.label},t)),f.length>0&&(0,R.jsxs)(uF,{children:[(0,R.jsx)(dF,{asChild:!0,children:(0,R.jsx)(UE,{label:`More actions`,icon:(0,R.jsx)(pb,{}),disabled:n})}),(0,R.jsx)(fF,{align:`end`,children:f.map(e=>(0,R.jsx)(pF,{icon:L8[e.kind],disabled:!!e.disabled,title:e.disabled??e.hint,onSelect:()=>r(e.kind),children:e.label},e.kind))})]}),e.primary&&(0,R.jsxs)(R.Fragment,{children:[i&&(0,R.jsx)(Jj,{prefix:`from`,value:i.value,branches:i.branches,detected:i.detected,missing:i.missing,onPick:i.onPick}),(0,R.jsx)(Y,{variant:e.primary.danger?`danger`:`primary`,icon:L8[e.primary.kind],disabled:n||!!e.primary.disabled,title:e.primary.disabled??e.primary.hint,onClick:()=>r(e.primary.kind),children:n?`Working…`:e.primary.label})]})]}),p.map(e=>(0,R.jsxs)(`div`,{className:q(`flex flex-wrap items-center justify-end gap-2 text-right text-xs`,i&&e.kind===`startDraft`&&i.missing?`text-warning`:`text-text-tertiary`),children:[(0,R.jsx)(`span`,{children:e.disabled}),e.escape&&(0,R.jsx)(Y,{size:`sm`,variant:`secondary`,icon:L8[e.escape.kind],onClick:()=>r(e.escape.kind),disabled:n,children:e.escape.label})]},e.kind))]})]},`${e.title??``}|${e.primary?.kind??``}`)}function V8({phase:e,livePhase:t,facts:n,onBack:r}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2 animate-fade-in`,role:`status`,children:[(0,R.jsxs)(`p`,{className:`m-0 min-w-0 flex-1 basis-60 text-sm text-text-secondary`,children:[(0,R.jsxs)(`span`,{className:`font-medium text-text`,children:[`Viewing `,ix[e].toLowerCase()]}),n?(0,R.jsxs)(`span`,{className:`text-text-tertiary`,children:[` — `,n]}):null]}),(0,R.jsxs)(Y,{variant:`ghost`,icon:(0,R.jsx)(Ub,{}),onClick:r,children:[`Back to `,ix[t].toLowerCase()]})]})}function H8(e){let t=QF(e),[n,r]=(0,L.useState)(null),i=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(t.length===0)return;let e=t[t.length-1].id;if(i.current===null){i.current=e;return}let n=i.current;i.current=e;let a=t.filter(e=>e.id>n&&e.type===`session.resume_failed`),o=a[a.length-1];o&&r(o.message||`session resume failed — relaunch to continue`)},[t]),(0,L.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>r(null),8e3);return()=>clearTimeout(e)},[n]),{message:n,dismiss:()=>r(null)}}var U8=`flex h-full min-h-0 min-w-0 flex-1 flex-col bg-surface`,W8=`runcastle.feature.details`;function G8(e){try{return sessionStorage.getItem(e)}catch{return null}}function K8(e,t){try{sessionStorage.setItem(e,t)}catch{}}function q8({featureId:e,view:t,onViewChange:n,viewedPhase:r,onViewPhase:i,guidance:a,driving:o,onDriveChange:s,onDeleted:c,detailsOpen:l,onToggleDetails:u}){let d=B.useUtils(),f=gx(),p=tI(),m=B.feature.get.useQuery({id:e},{refetchInterval:Ch()}),h=H8(e),g=QF(e),_=Qd(g),v=C_(g),y=m.data?.feature.phase===`review`,b=B.feature.mergeDelta.useQuery({featureId:e},{refetchInterval:Ch(5e3),enabled:y}),x=Ch(),S=y?x:!1,C=B.notes.list.useQuery({featureId:e},{refetchInterval:S}),w=C.data?.filter(e=>e.status===`open`)??[],T=C.data?w.length:void 0,E=B.findings.listByFeature.useQuery({featureId:e},{refetchInterval:S}),D=E.data?.openDefects??[],O=E.data?.summary.open,k=fh(e,y),A=sy(k.data??[],m.data?.tickets??[]),j=cy(A,{landedSince:A?.landedSince??0,lap:m.data?.feature.lap??1},ly(m.data?.tickets??[])),M=by({passes:k.data??[],tickets:m.data?.tickets??[],currentLap:m.data?.feature.lap??1}),[N,P]=(0,L.useState)(!1),[ee,F]=(0,L.useState)(!1),I=!!m.data&&m.data.feature.phase!==`shipped`,te=B.feature.burnWarnings.useQuery({featureId:e},{refetchInterval:Ch(),enabled:I}),[ne,re]=(0,L.useState)(null),ie=B.notes.triagePreview.useQuery({featureId:e},{enabled:ne!==null}),ae=m.data?.feature.phase===`review`?Ey(m.data):void 0,oe=Oy(B.docs.read.useQuery({featureId:e,relPath:ae??`spec.md`},{enabled:!!ae}).data?.content),se=m.data?.feature.projectId,ce=B.project.prep.useQuery({projectId:se??``},{enabled:!!se,refetchInterval:Ch()}),le=B.feature.driveInfo.useQuery(void 0,{refetchInterval:Ch()}),ue=B.ticket.durationStats.useQuery({projectId:se??``},{enabled:!!se}),de=Lm(B.settings.get.useQuery({projectId:se??``},{enabled:!!se&&I}).data,`implement`),fe=m.data?.feature.phase===`planning`||m.data?.feature.phase===`building`,pe=B.docs.digestSize.useQuery({featureId:e},{enabled:fe}),me=m.data?.feature.status===`draft`,he=B.project.branches.useQuery({projectId:se??``},{enabled:!!se&&me}),[ge,_e]=(0,L.useState)(null),ve=(ge?.featureId===e?ge.base:``)||(he.data?Zg(he.data):``),ye=!me||ve?void 0:he.data?`unpicked`:`loading`,be=aI(Xh(m.data?.runs??[])),xe=oI(e,sI(m.data?.docs??[],`decisions.md`)).content,Se=()=>{d.feature.get.invalidate({id:e}),d.feature.list.invalidate(),d.events.invalidate()},Ce=Ex(e),we=()=>{Se(),Ce()},Te=B.feature.launchSession.useMutation({onSuccess:we,onError:e=>f.push(e.message)}),Ee=B.feature.burn.useMutation({onSuccess:()=>{Se(),i(null)},onError:e=>f.push(e.message)}),De=B.feature.endSession.useMutation({onError:e=>f.push(e.message)}),Oe=B.notes.triage.useMutation(),ke=B.findings.dismiss.useMutation(),Ae=B.run.cancel.useMutation({onSuccess:e=>{Se(),e.confirmed?f.push(`run cancelled — its agents are stopped`,`info`):f.push(_v)},onError:e=>f.push(e.message)}),je=B.feature.fixDrive.useMutation({onSuccess:we,onError:e=>f.push(e.message)}),Me=B.feature.testDrive.useMutation({onSuccess:e=>{if(Se(),e.hookFailure){let t=e.hookFailure;f.push(`${t.phase===`setup`?`Test drive setup`:`Test drive teardown`} failed: ${t.command}${t.timedOut?` (timed out)`:``} — see the timeline for its output`)}e.dbDrift&&f.push(e.dbDrift.resetCommand?`Migrations differ between the branches — your dev database may be ahead. Rebuild it with: ${e.dbDrift.resetCommand}`:`Migrations differ between the branches — your dev database may be ahead. Set a database reset command in settings for a one-line fix here.`,`info`),e.carriedChanges?.length&&f.push(`${e.carriedChanges.length} uncommitted file(s) came back with you onto ${e.branch}`,`info`)},onError:e=>f.push(e.message)}),Ne=B.feature.merge.useMutation({onSettled:Se,onError:e=>f.push(e.message)}),Pe=B.feature.unarchive.useMutation({onSuccess:()=>{Se(),f.push(`feature unarchived`,`success`)},onError:e=>f.push(e.message)}),Fe=B.feature.list.useQuery({projectId:se??``},{enabled:!!se&&me}),Ie=B.feature.setDependencies.useMutation({onSuccess:Se,onError:()=>void 0}),Le=B.feature.start.useMutation({onSuccess:(e,t)=>{Se(),Qg(e)&&Te.mutate({featureId:t.featureId,kind:`chat`})},onError:e=>f.push(e.message)}),Re=B.feature.launchSession.useMutation({onSuccess:Se,onError:e=>f.push(e.message)}),ze=B.feature.start.useMutation({onSuccess:(e,t)=>{Se(),Qg(e)&&Re.mutate({featureId:t.featureId,kind:`chat`,purpose:`self-plan`})},onError:e=>f.push(e.message)}),Be=iI(e,m.data?.feature.branch??``),[Ve,He]=(0,L.useState)(()=>G8(W8)===`1`),Ue=l!==void 0,We=Ue?l:Ve,Ge=e=>{if(Ue){e!==l&&u?.();return}He(e),K8(W8,e?`1`:`0`)},[Ke,qe]=(0,L.useState)(null),Je=B.feature.archive.useMutation({onSuccess:()=>{Se(),f.push(`feature archived`,`success`)},onError:e=>f.push(e.message)}),Ye=B.feature.delete.useMutation({onSuccess:()=>{d.feature.list.invalidate(),qe(null),c?.()},onError:e=>f.push(e.message)});if(m.isLoading)return(0,R.jsx)(`section`,{className:U8,children:(0,R.jsx)(I8,{})});if(!m.data)return(0,R.jsxs)(`section`,{className:U8,children:[(0,R.jsx)(_j,{}),(0,R.jsx)(yj,{children:(0,R.jsxs)(Pj,{children:[`Could not load the feature`,m.error?`: ${m.error.message}`:``]})})]});let Xe=!!m.error,Ze=m.data,Qe=Ze.feature;if(Cd(Qe.phase)===null)return(0,R.jsx)(T8,{feature:Qe});let $e=$v(Qe,r),et=ey(Qe,$e),tt=ty(Qe,$e,{planning:(e=>Vy({phase:e,full:Ze,events:g,decisions:xe}))(`planning`)}),nt=Xh(Ze.runs),rt=P_(g,nt?.id),it=be&&nt?.id===be&&$e===`review`?`building`:$e,at=Gv(Ze,{driving:o?.featureId===Qe.id,driveState:le.data?.featureId===Qe.id?le.data.state:`idle`,conflict:_,unverifiedDriveKeys:em(ce.data?.findings??[]),...le.data&&le.data.featureId!==Qe.id?{slotHolder:le.data.holderLabel}:{},...ue.data?{burnStats:ue.data}:{},...pe.data?{docsDigestBytes:pe.data.bytes}:{},...ye?{draftBaseMissing:ye}:{},openNotes:T,openDefects:O,...M?{unverifiedReview:{reason:M.reason}}:{},laterLaps:oe,interruptedBurn:rt}),ot=j_(Ze.sessions),st=Le.isPending||Te.isPending||ze.isPending||Re.isPending||Ee.isPending||Ae.isPending||Me.isPending||Ne.isPending||Oe.isPending||ke.isPending||je.isPending||Pe.isPending||De.isPending||Be.pending,ct=()=>{(T??0)+(O??0)>0?re(Date.now()):Te.mutate({featureId:e,kind:`chat`,purpose:`start-lap`})},lt=async()=>{if(!ot)return!0;try{await De.mutateAsync({sessionId:ot.id})}catch{return!1}return Se(),!0},ut=async t=>{let{dismissFindingIds:n,...r}=t;try{for(let e of n)await ke.mutateAsync({findingId:e});await Oe.mutateAsync({featureId:e,...r}),re(null),Se(),d.notes.list.invalidate({featureId:e}),d.findings.listByFeature.invalidate({featureId:e}),t.carry?await lt()&&Te.mutate({featureId:e,kind:`chat`,purpose:`start-lap`}):Ee.mutate({featureId:e})}catch(e){f.push(e instanceof Error?e.message:String(e))}},dt=()=>{Te.mutate({featureId:e,kind:`chat`})},ft=()=>{ot&&xv(ot)?f.push(`This feature is planning itself — stop the run to open the chat.`,`info`):ot?Ce():dt()},pt=t=>{switch(t){case`startDraft`:Le.mutate({featureId:e,baseBranch:ve});break;case`chat`:ft();break;case`selfPlan`:me?ze.mutate({featureId:e,baseBranch:ve}):Re.mutate({featureId:e,kind:`chat`,purpose:`self-plan`});break;case`stopSelfPlan`:lt();break;case`iterate`:ct();break;case`endSessionAndIterate`:lt().then(e=>{e&&ct()});break;case`burn`:F(!0);break;case`cancelRun`:nt&&Ae.mutate({runId:nt.id});break;case`openBurnSettings`:{let e=nt?.summary?Qm(nt.summary):null;e&&p?.(e);break}case`unarchive`:Pe.mutate({featureId:e});break;case`testDriveStart`:Me.mutate({featureId:e,action:`start`},{onSuccess:t=>{Se(),t.ok&&t.branch?s({featureId:e,branch:t.branch}):t.ok||f.push(t.deniedReason??`test drive denied`)}});break;case`testDriveStop`:Me.mutate({featureId:e,action:`stop`},{onSuccess:()=>{Se(),s(null)}});break;case`stopDriveAndIterate`:Me.mutate({featureId:e,action:`stop`},{onSuccess:()=>{Se(),s(null),ct()}});break;case`fixDrive`:je.mutate({featureId:e});break;case`merge`:P(!0);break;case`resolveConflict`:_&&Be.resolve(_,ot?.id);break;default:}},mt=()=>{Ee.mutate({featureId:e},{onSuccess:()=>F(!1)})},ht=()=>{Ne.mutate({featureId:e},{onSuccess:e=>{if(Se(),P(!1),e.ok)s(null),f.push(`merged — feature shipped`,`success`);else if(e.conflict){let t=e.files.length;f.push(t>0?`merge conflict in ${t} file${t===1?``:`s`} — resolve below and retry`:`merge conflict — resolve below and retry`)}}})},gt=ny({full:Ze,phase:it,readonly:et,hasRun:!!nt}),_t=me?`overview`:t,vt=e=>{n(`overview`),i(e)},yt=_t===`overview`&&!me&&ry({full:Ze,phase:it,readonly:et,ticketsIsBody:gt}),bt=!me&&it!==`shipped`,xt=`${e}:${me?`draft`:it}:${_t}`,St=Tv(Ze.sessions),Ct=Qe.status===`shipped`?wv([...g]):null,wt=[me?{phase:`draft`,text:`Parked ${Ih(Qe.createdAt)}`}:Ct?{tone:`success`,text:`Merged ${Ih(Ct)}`}:{text:`Started ${Ih(Qe.createdAt)}`},Qe.status===`archived`&&{tone:`neutral`,text:`Archived`},Qe.lap>1&&{text:`Lap ${Qe.lap}`,title:yv(Qe.lap)}].filter(e=>!!e),Tt=[{key:`copy-link`,label:`Copy link`,onSelect:()=>gF(window.location.origin+Sg({kind:`feature`,projectId:Qe.projectId,featureSlug:Qe.slug}),f)},...!me&&Qe.branch?[{key:`copy-branch`,label:`Copy branch name`,onSelect:()=>gF(Qe.branch,f)}]:[],...Qe.status===`archived`?[{key:`unarchive`,label:`Unarchive`,onSelect:()=>Pe.mutate({featureId:e})}]:Qe.status===`draft`?[]:[{key:`archive`,label:`Archive`,onSelect:()=>Je.mutate({featureId:e})}],...c&&Qe.status!==`shipped`?[{key:`delete`,label:`Delete…`,danger:!0,onSelect:e=>qe(e)}]:[]],Et=et?(0,R.jsx)(V8,{phase:$e,livePhase:Qe.phase,facts:Hy({phase:$e,full:Ze,events:g,decisions:xe}),onBack:()=>vt(null)}):(0,R.jsx)(B8,{ns:at,guidance:a,busy:st,onAction:pt,...it===`planning`||it===`building`?{demote:[`merge`]}:{},draftBranch:me?{branches:he.data?.branches,value:ve||null,detected:he.data?.detected,missing:ye===`unpicked`,onPick:t=>_e({featureId:e,base:t})}:void 0}),Dt=(0,R.jsxs)(P8,{feature:Qe,isDraft:me,steps:tt,readonly:et,facts:wt,onViewPhase:vt,children:[h.message&&(0,R.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md bg-danger-subtle px-3 py-2 text-sm text-danger`,role:`alert`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Resume failed.`}),` `,h.message]}),(0,R.jsx)(UE,{label:`Dismiss`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:h.dismiss})]}),(0,R.jsx)(k8,{isDraft:me,dependsOn:Ze.dependsOn,candidates:Uh(Fe.data??[],Qe,Ze.dependsOn),onChange:t=>Ie.mutateAsync({featureId:e,dependsOn:t})}),(0,R.jsx)(A8,{projectId:Qe.projectId,blocks:Ze.blocks}),Et,_t===`overview`&&!et&&St&&(0,R.jsx)(x8,{featureId:e,line:St,onOpen:()=>n(`chat`)})]}),Ot=me?(0,R.jsx)(wK,{full:Ze}):(0,R.jsx)(J8,{effective:it,full:Ze,events:g,driving:o,conflict:_,runId:nt?.id??null,ticketsIsBody:gt,readonly:et,onViewPhase:vt});return(0,R.jsxs)(`section`,{className:q(U8,`overflow-clip`),"aria-label":Qe.title,children:[(0,R.jsxs)(Cj,{asideClassName:`@max-4xl:top-(--topbar-h)`,aside:We&&(0,R.jsx)(q6,{featureId:e,onClose:()=>Ge(!1)}),children:[(0,R.jsx)(_j,{crumbs:[{label:Qe.title,icon:(0,R.jsx)(sx,{phase:me?`draft`:Qe.phase,size:14,label:``})}],tabs:(0,R.jsx)(b8,{isDraft:me,value:_t,onChange:n,sessionLive:!!ot}),actions:(0,R.jsxs)(R.Fragment,{children:[Xe&&(0,R.jsx)(HA,{tone:`warning`,className:`mr-2`,title:`The server is unreachable — retrying`,children:`Offline, retrying`}),(0,R.jsx)(yF,{actions:Tt,size:`md`}),(0,R.jsx)(UE,{label:We?`Hide details`:`Show details`,icon:(0,R.jsx)(nb,{}),active:We,onClick:()=>Ge(!We)})]})}),_t===`chat`?null:yt?(0,R.jsxs)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-(--content-wide) min-w-0 flex-1 flex-col px-8 pt-12 animate-rise-in`,children:[(0,R.jsx)(`div`,{className:`shrink-0 pb-5`,children:Dt}),(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 pb-6`,children:Ot})]},xt):(0,R.jsxs)(yj,{width:bt?`wide`:`default`,routeKey:xt,children:[Dt,(0,R.jsx)(`div`,{className:`mt-10`,children:Ot})]}),!me&&(0,R.jsx)(y8,{full:Ze,events:g,hidden:_t!==`chat`,launching:Te.isPending,onLaunch:dt,onView:n})]}),ee&&(0,R.jsx)(dI,{title:Qe.title,branch:Qe.branch,summary:zy({branch:Qe.branch,pendingTickets:u_(Ze.tickets),lap:Ly(Ze.runs),...de?{defaultModel:de}:{},warnings:te.data}),busy:Ee.isPending,warningsPending:!te.data,onConfirm:mt,onCancel:()=>F(!1)}),N&&(0,R.jsx)(cI,{title:Qe.title,branch:Qe.branch,base:b.data?.base,summary:Iy({branch:Qe.branch,...b.data?.base?{base:b.data.base}:{},...b.data?{delta:b.data}:{},tickets:Ze.tickets,lap:Qe.lap,driveLap:v,openNotes:T,...le.data?.projectDrive&&le.data.projectId===Qe.projectId?{projectDrive:{holderLabel:le.data.holderLabel}}:{},freshness:j,conflict:_,laterLaps:oe,burning:nt?.status===`running`}),busy:Ne.isPending,resolving:Be.pending,onConfirm:ht,onResolve:_?()=>void Be.resolve(_,ot?.id??void 0):void 0,onCancel:()=>P(!1)}),Ke&&(0,R.jsx)(bF,{title:Qe.title,slug:Qe.slug,busy:Ye.isPending,onConfirm:()=>Ye.mutate({featureId:e}),onCancel:()=>qe(null),returnFocusRef:Ke}),ne!==null&&(0,R.jsx)(AI,{lap:Qe.lap,notes:w,defects:D,standing:ie.data?.standingFixTickets??[],openedAt:ne,busy:st,readonly:et,sessionLive:!!ot,onCommit:e=>void ut(e),onClose:()=>re(null)})]})}function J8({effective:e,full:t,events:n,driving:r,conflict:i,runId:a,ticketsIsBody:o,readonly:s,onViewPhase:c}){if(s&&e===`planning`)return(0,R.jsx)(_J,{full:t,live:!1,children:(0,R.jsx)(lJ,{full:t,effective:e,events:n})});switch(e){case`planning`:return(0,R.jsx)(_J,{full:t,children:o?(0,R.jsx)(Z3,{featureId:t.feature.id}):(0,R.jsx)(AK,{full:t})});case`building`:return a?(0,R.jsx)(L6,{featureId:t.feature.id,runId:a,readonly:s}):(0,R.jsx)(Z3,{featureId:t.feature.id});case`review`:return(0,R.jsx)(j3,{full:t,driving:r,conflict:i,readonly:s,onViewPhase:c});case`shipped`:return(0,R.jsx)(J3,{full:t})}}function Y8(e){let t=B.useUtils(),n=gx(),r=B.project.sessionBranch.useQuery({projectId:e}),i=B.project.branches.useQuery({projectId:e,includeFeatureBranches:!0}),a=Gy(r.data,i.data?.branches),o=B.settings.update.useMutation({onSuccess:()=>{t.project.sessionBranch.invalidate(),t.settings.get.invalidate()},onError:e=>n.push(e.message)});return{value:a?.value??null,branches:i.data?.branches,detected:r.data?.detected,missing:a?.origin===`vanished`,pick:t=>o.mutate({projectId:e,key:`sessionBranch`,value:t}),picking:o.isPending}}var X8=10,Z8=8;function Q8({conversations:e,pending:t,busy:n,onResume:r,onOpen:i,onView:a}){let[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(!1),u=(0,L.useMemo)(()=>[...e].sort((e,t)=>Number(t.status!==`ended`)-Number(e.status!==`ended`)).map(e=>({c:e,title:L3(e.title)})),[e]);if(t)return null;let d=o.trim().toLowerCase(),f=d?u.filter(e=>e.title.toLowerCase().includes(d)):u,p=c||d?f:f.slice(0,X8),m=f.length-p.length;return(0,R.jsxs)(xj,{title:`Chats`,action:e.length>Z8?(0,R.jsx)(fj,{icon:(0,R.jsx)(eb,{}),placeholder:`Filter`,"aria-label":`Filter chats`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Escape`&&s(``)},className:`w-50`}):void 0,children:[e.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(hb,{}),title:`No chats yet`,hint:`A new chat starts from the row above.`}):p.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(eb,{}),title:`No chat matches`,hint:`Nothing titled “${o.trim()}”.`}):(0,R.jsx)(ij,{label:`Chats`,children:p.map(({c:e,title:t},o)=>{let s=e.status!==`ended`;return(0,R.jsx)(rj,{index:o,leading:s?(0,R.jsx)(BA,{tone:`live`,label:e.status}):(0,R.jsx)(hb,{}),title:t,meta:e.createdAt===null?void 0:Fh(e.createdAt),onClick:()=>a(e),actionsOverlay:!0,actions:(0,R.jsx)(UE,{size:`sm`,label:e.resumable?s?`Open`:`Reopen`:`Reopen — this one never got started`,"aria-label":s?`Open`:`Reopen`,icon:s?(0,R.jsx)(Cb,{}):(0,R.jsx)(Gb,{}),disabled:n||!e.resumable,onClick:()=>s?i?.(e.id):r(e.id)})},e.id)})}),m>0&&(0,R.jsxs)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(db,{}),className:`mt-2`,onClick:()=>l(!0),children:[`Show `,m,` more`]})]})}function $8({icon:e,title:t,status:n,hint:r,actions:i,caption:a,children:o,rule:s=!0,className:c}){return(0,R.jsxs)(`div`,{className:q(`py-4`,s&&`border-b border-border-subtle`,c),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`grid size-8 shrink-0 place-items-center rounded-md bg-surface-hover text-icon [&>svg]:size-4`,children:e}),(0,R.jsxs)(`div`,{className:`flex min-w-60 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,R.jsx)(`h2`,{className:`m-0 text-sm font-medium text-text`,children:t}),n]}),(0,R.jsx)(`p`,{className:`m-0 text-sm text-pretty text-text-tertiary`,children:r})]}),(0,R.jsxs)(`div`,{className:`ml-auto flex shrink-0 flex-col items-end gap-1`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:i}),a&&(0,R.jsx)(`span`,{className:`max-w-[32ch] text-right text-xs text-text-tertiary`,children:a})]})]}),o]})}function e5({landing:e,onStart:t,starting:n,openSession:r}){return(0,R.jsx)($8,{icon:(0,R.jsx)(Db,{}),title:`Talk it through`,hint:`Bring a raw idea; the chat checks it against what’s built and cuts it into features.`,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Jj,{prefix:`landing on`,value:e.value,branches:e.branches,detected:e.detected,missing:e.missing,disabled:e.picking,onPick:e.pick}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(ob,{}),loading:n,disabled:n||e.missing,title:e.missing?`the branch this chat would land on is gone — pick another`:void 0,onClick:t,children:`New chat`})]}),caption:e.missing?`The landing branch is gone — pick another.`:void 0,children:r&&(0,R.jsxs)(`div`,{role:`status`,className:`mt-3 ml-12 flex flex-wrap items-center gap-2 animate-rise-in`,children:[(0,R.jsx)(`span`,{className:`mr-auto text-sm text-text-secondary`,children:`A chat is already open.`}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(hb,{}),onClick:r.onOpen,children:`Open it`}),(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(Gb,{}),loading:n,disabled:n,onClick:r.onReplace,children:`End it and start new`})]})})}function t5({lead:e,when:t,actions:n,className:r,children:i}){return(0,R.jsx)(rj,{as:`li`,animate:!0,wrap:!0,leading:e,title:(0,R.jsx)(`span`,{className:`flex flex-col`,children:i}),meta:t,actions:n,actionsOverlay:!0,className:q(`focus-within:bg-surface-hover hover:bg-surface-hover`,r)})}function n5(){return(0,R.jsx)(`span`,{className:`grid w-10 place-items-center`,"aria-hidden":!0,children:(0,R.jsx)(`i`,{className:`size-1.5 rounded-full bg-text-disabled`})})}function r5({note:e}){let t=Cx(e);return t?(0,R.jsx)(`span`,{className:`mt-0.5 font-mono text-xs text-text-tertiary`,title:t.title,children:t.label}):null}function i5({projectId:e,onTriage:t,triaging:n,reveal:r=!1,onRevealed:i}){let a=B.useUtils(),o=gx(),s=B.projectNotes.list.useQuery({projectId:e},{refetchInterval:Ch()}),c=B.feature.list.useQuery({projectId:e},{refetchInterval:Ch()}),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(``),[p,m]=(0,L.useState)(null),h=e=>o.push(e.message),g=()=>void a.projectNotes.invalidate(),_=B.projectNotes.edit.useMutation({onSuccess:()=>{g(),u(null)},onError:h}),v=B.projectNotes.delete.useMutation({onSuccess:g,onError:h}),y=B.projectNotes.dismiss.useMutation({onSuccess:g,onError:h}),b=B.projectNotes.reopen.useMutation({onSuccess:g,onError:h}),x=s.data??[],S=_.isPending||v.isPending||y.isPending||b.isPending,C=o5(x.filter(e=>e.status===`open`)),w=o5(x.filter(e=>e.status===`triaged`)),T=(0,L.useRef)(null),E=x.length>0;if((0,L.useEffect)(()=>{!r||!T.current||(T.current.scrollIntoView?.({block:`center`}),i?.())},[r,E,i]),!E)return null;let D=e=>{d.trim()&&!_.isPending&&_.mutate({noteId:e,text:d})},O=e=>e.screenshotUrl?(0,R.jsx)(Qj,{size:`sm`,url:e.screenshotUrl,onOpen:m}):(0,R.jsx)(n5,{});return(0,R.jsxs)(`section`,{ref:T,"aria-label":`Notes`,className:`flex flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-4 pt-3 pb-2`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 text-xs text-pretty text-text-tertiary`,children:`Grouped, questioned and routed in a triage chat.`}),(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(Db,{}),className:`shrink-0`,loading:n,disabled:C.length===0||n,title:C.length===0?`nothing is open to triage`:void 0,onClick:t,children:`Triage ${C.length}`})]}),C.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(Ab,{}),title:`Inbox clear`,hint:`Every note has been triaged.`}):(0,R.jsx)(`ul`,{className:a5,children:C.map(e=>(0,R.jsx)(t5,{lead:O(e),when:Fh(e.createdAt),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(UE,{size:`sm`,label:`Edit`,icon:(0,R.jsx)(_b,{}),onClick:()=>{u(e.id),f(e.text)}}),(0,R.jsx)(UE,{size:`sm`,label:`Dismiss`,icon:(0,R.jsx)(sb,{}),disabled:S,onClick:()=>y.mutate({noteId:e.id})}),(0,R.jsx)(UE,{size:`sm`,label:`Delete`,icon:(0,R.jsx)(lb,{}),variant:`danger-ghost`,disabled:S,onClick:()=>v.mutate({noteId:e.id})})]}),children:l===e.id?(0,R.jsx)(`input`,{"aria-label":`edit this note`,className:lj,value:d,autoFocus:!0,onChange:e=>f(e.target.value),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),u(null)):t.key===`Enter`&&(t.preventDefault(),D(e.id))}}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-text`,children:e.text}),(0,R.jsx)(r5,{note:e})]})},e.id))}),w.length>0&&(0,R.jsx)(Rj,{title:`${w.length} triaged`,className:`mx-4 mt-2`,children:(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:w.map(t=>(0,R.jsxs)(t5,{lead:t.screenshotUrl?O(t):null,actions:(0,R.jsx)(UE,{size:`sm`,label:`Reopen`,icon:(0,R.jsx)(ub,{}),disabled:S,onClick:()=>b.mutate({noteId:t.id})}),children:[(0,R.jsx)(`span`,{className:`text-text-secondary`,children:t.text}),(0,R.jsx)(r5,{note:t}),(0,R.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-baseline gap-x-2 text-xs text-text-tertiary`,children:[(0,R.jsx)(`span`,{children:t.outcome}),(0,R.jsx)(s5,{projectId:e,feature:c.data?.find(e=>e.id===t.featureId)})]})]},t.id))})}),(0,R.jsx)(pI,{url:p,onClose:()=>m(null)})]})}var a5=`m-0 flex list-none flex-col px-1 py-1`;function o5(e){return[...e].sort((e,t)=>t.createdAt-e.createdAt)}function s5({projectId:e,feature:t}){return t?(0,R.jsx)(`a`,{className:JE,href:Sg({kind:`feature`,projectId:e,featureSlug:t.slug}),children:t.title}):null}function c5({session:e,transcriptId:t,onResume:n,resuming:r=!1,title:i,projectName:a=`Project`,branch:o,hidden:s,onBack:c,onEnded:l,switcher:u}){let d=e?e.ccSessionId??e.id:null;return(0,R.jsxs)(`div`,{className:s?`hidden`:`flex min-h-0 flex-1 flex-col`,"data-live-chat":e?``:void 0,"aria-hidden":s,children:[(0,R.jsx)(_j,{crumbs:[{label:a,icon:(0,R.jsx)(yb,{}),onClick:c},{label:L3(i),icon:(0,R.jsx)(hb,{})}],tabs:u}),(0,R.jsx)(Q6,{label:`Project chat`,session:e,contextLine:`Project chat`,meta:(0,R.jsxs)(R.Fragment,{children:[o&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(Cb,{size:14,className:`text-icon`}),`lands on `,(0,R.jsx)(`span`,{className:`font-mono`,children:o})]}),d&&(0,R.jsx)(`span`,{className:`hidden font-mono xl:inline`,title:d,children:d.slice(0,8)})]}),onEnded:l,transcriptId:t,onLaunch:n,launching:r})]})}function l5({projectId:e,startedAt:t,onClose:n}){let r=B.projectNotes.list.useQuery({projectId:e},{refetchInterval:Ch()}),[i,a]=(0,L.useState)(null),{thisDrive:o,alreadyOpen:s}=Sx(r.data??[],t),c=o.length+s.length;return(0,R.jsxs)(Sj,{title:`Notes`,actions:c>0?(0,R.jsxs)(`span`,{className:`pr-1 text-xs text-text-tertiary tabular-nums`,title:`${c} open`,children:[c,` open`]}):void 0,onClose:n,bodyClassName:`flex flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[(0,R.jsx)(u5,{title:`This drive`,children:o.length===0?(0,R.jsx)(d5,{children:`Nothing yet. Select an area of the app, or type below.`}):o.map(e=>(0,R.jsx)(f5,{note:e,onOpen:a},e.id))}),(0,R.jsx)(u5,{title:`Already open`,children:s.length===0?(0,R.jsx)(d5,{children:`No other open notes.`}):s.map(e=>(0,R.jsx)(f5,{note:e,onOpen:a},e.id))})]}),(0,R.jsx)(p5,{projectId:e})]}),(0,R.jsx)(pI,{url:i,onClose:()=>a(null)})]})}function u5({title:e,children:t}){return(0,R.jsxs)(`section`,{"aria-label":e,className:`pt-2`,children:[(0,R.jsx)($A,{className:`px-4`,children:e}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col px-1 py-0`,children:t})]})}function d5({children:e}){return(0,R.jsx)(`li`,{className:`px-3 py-1.5 text-sm text-text-tertiary`,children:e})}function f5({note:e,onOpen:t}){return(0,R.jsxs)(t5,{lead:e.screenshotUrl?(0,R.jsx)(Qj,{size:`sm`,url:e.screenshotUrl,onOpen:t}):(0,R.jsx)(n5,{}),when:Fh(e.createdAt),children:[(0,R.jsx)(`span`,{className:`text-text`,children:e.text}),(0,R.jsx)(r5,{note:e})]})}function p5({projectId:e}){let t=B.useUtils(),n=gx(),r=B.projectNotes.add.useMutation(),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>URL.revokeObjectURL(o?.preview??``),[o]);let d=e=>{let t=ph(e.clipboardData);t&&(e.preventDefault(),mh(t).then(e=>s({png:e,preview:URL.createObjectURL(e)})).catch(e=>n.push(e instanceof Error?e.message:`that image could not be read`)))},f=async()=>{if(!(!i.trim()||c)){l(!0);try{let c=await r.mutateAsync({projectId:e,text:i});if(o)try{await vx(c.id,o.png)}catch(e){n.push(`the note was saved, but its picture was not: ${e instanceof Error?e.message:String(e)}`)}t.projectNotes.invalidate(),a(``),s(null),u.current?.focus()}catch(e){n.push(e instanceof Error?e.message:`the note could not be saved`)}finally{l(!1)}}};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border-subtle p-3`,onPaste:d,children:[(0,R.jsx)(fj,{ref:u,autoComplete:`off`,"aria-label":`New note`,placeholder:`What did you just notice?`,value:i,disabled:c,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())}}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-text-tertiary`,children:[o?(0,R.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-1.5 rounded-md bg-surface-hover pr-0.5 pl-1 text-text-secondary animate-pop-in`,children:[(0,R.jsx)(`img`,{src:o.preview,alt:`the picture this note will carry`,className:`h-4 w-6 rounded-sm bg-surface-inset object-cover`}),`Screenshot`,(0,R.jsx)(UE,{size:`sm`,label:`Remove the picture`,icon:(0,R.jsx)(cb,{}),onClick:()=>s(null)})]}):(0,R.jsx)(`span`,{children:`Paste a screenshot`}),(0,R.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,R.jsx)(Px,{children:`↵`}),` save`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(Px,{children:mM(`J`)}),` anywhere`]})]})]})}function m5({projectId:e,projectName:t=`Project`,repoPath:n,drive:r,hidden:i,onProjectPage:a,onStop:o,stopping:s,onOpenPreparation:c,switcher:l}){let[u,d]=(0,L.useState)(!0),f=Vv(r.state).stageKind,p=f===`failed`?(0,R.jsx)(HA,{tone:`danger`,children:`Setup failed`}):f===`starting`?(0,R.jsx)(HA,{spinning:!0,children:`Starting`}):(0,R.jsx)(HA,{tone:`live`,children:`Running`}),m=(0,R.jsx)(Y,{icon:(0,R.jsx)(Tb,{}),loading:s,disabled:s,onClick:o,children:`Stop drive`}),h=`${n??``}${r.commit?` @ ${r.commit}`:``}`;return(0,R.jsxs)(`div`,{className:i?`hidden`:`flex min-h-0 flex-1 flex-col`,"aria-hidden":i,"data-project-drive":!0,children:[(0,R.jsx)(_j,{crumbs:[{label:t,icon:(0,R.jsx)(yb,{}),onClick:a},{label:`Test drive`,icon:(0,R.jsx)(wb,{})}],tabs:l,actions:(0,R.jsxs)(R.Fragment,{children:[m,(0,R.jsx)(UE,{label:u?`Hide notes`:`Show notes`,icon:(0,R.jsx)(nb,{}),active:u,onClick:()=>d(e=>!e)})]})}),(0,R.jsx)(Cj,{aside:u&&(0,R.jsx)(l5,{projectId:e,startedAt:r.startedAt,onClose:()=>d(!1)}),children:(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4 overflow-y-auto px-6 pt-5 pb-4 animate-fade-in`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,R.jsxs)(`h2`,{className:`m-0 text-lg font-semibold text-text`,children:[`Driving `,(0,R.jsx)(`span`,{className:`font-mono text-base font-medium`,children:r.branch})]}),p]}),(0,R.jsx)(oj,{items:[{icon:(0,R.jsx)(yb,{}),mono:!0,text:h,title:h},{icon:(0,R.jsx)(Kb,{}),mono:!0,text:`project-drive`,title:`the identity this drive runs as`}]})]}),(0,R.jsx)(h5,{projectId:e,drive:r,stop:m,onOpenPreparation:c}),(0,R.jsx)(p4,{branch:r.branch,drive:r})]})})]})}function h5({projectId:e,drive:t,stop:n,onOpenPreparation:r}){let i=Iv(t);switch(Vv(t.state).stageKind){case`failed`:return i?(0,R.jsx)(_5,{children:(0,R.jsx)(f4,{failure:i,explanation:(0,R.jsxs)(R.Fragment,{children:[`Your checkout is as it was, but`,` `,(0,R.jsx)(`code`,{className:`font-mono text-xs`,children:i.command}),` `,i.outcome,` — so whatever it was meant to bring up is probably not running. Preparation is where this project’s drive commands are repaired and proven.`]}),children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Eb,{}),onClick:r,children:`Open preparation`}),n]})})}):(0,R.jsx)(_5,{children:(0,R.jsx)(Fj,{icon:(0,R.jsx)(Vb,{}),title:`The drive’s setup command failed`,hint:`Its output is in the timeline.`})});case`bare`:return(0,R.jsx)(_5,{children:(0,R.jsx)(Fj,{icon:(0,R.jsx)(mb,{}),title:`Setup ran — nothing started.`,hint:(0,R.jsxs)(R.Fragment,{children:[`This project has no dev command ·`,` `,(0,R.jsx)(nI,{location:{page:`project`,field:`devCommand`},children:`Set one in Settings`}),` `,`and the next drive boots the app right here.`]})})});case`panel`:case`agent`:return t.devUrl?(0,R.jsx)(`div`,{className:`flex min-h-100 flex-1 flex-col`,children:(0,R.jsx)(G4,{projectId:e,url:t.devUrl})}):(0,R.jsx)(_5,{children:(0,R.jsx)(Fj,{icon:(0,R.jsx)(Bb,{}),title:`Waiting for an address`,hint:`The dev server is up but has not printed an address yet — its output is under the stage.`})});default:return(0,R.jsx)(_5,{children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center`,children:[(0,R.jsx)(HA,{tone:`live`,size:`sm`,strong:!0,children:`Starting the dev server…`}),(0,R.jsx)(`p`,{className:`m-0 max-w-[52ch] text-sm text-pretty text-text-tertiary`,children:`Your checkout is driven as it is and the project’s dev command is running. The app appears here as soon as it answers — its output is under the stage.`})]})})}}function g5({value:e,chat:t,drive:n,onPick:r}){return(0,R.jsx)(cj,{label:`Project views`,size:`sm`,value:e,onChange:r,items:[{id:`overview`,label:`Overview`,icon:(0,R.jsx)(yb,{})},...t?[{id:`chat`,label:`Live chat`,icon:(0,R.jsx)(hb,{})}]:[],...n?[{id:`drive`,label:`Drive`,icon:(0,R.jsx)(wb,{})}]:[]]})}function _5({children:e}){return(0,R.jsx)(`div`,{className:`flex min-h-65 flex-1 flex-col justify-center rounded-md bg-surface-inset p-6`,children:e})}var v5=`project-drive`;function y5({card:e,branch:t,setupCommand:n,devCommand:r,stopCommand:i,starting:a,onStart:o,onPrepare:s,onReturn:c}){if(e.state===`hidden`)return null;let l=e.state===`running`,u=[{label:`Branch`,value:t??`…`,mono:!0,sub:`your checkout, as it is — no branch switch`},{label:`As`,value:v5,mono:!0},b5(`Setup`,n,`driveSetupCommand`),b5(`Dev`,r,`devCommand`),b5(`Stop`,i,`driveStopCommand`)];return(0,R.jsxs)(`section`,{"aria-label":`Test drive`,children:[(0,R.jsx)($8,{icon:(0,R.jsx)(wb,{}),title:`Test drive`,status:l?(0,R.jsx)(HA,{tone:`live`,children:`Running`}):void 0,hint:`Run everything that has shipped and jot what you notice. Notes land in the inbox.`,actions:e.state===`prepare`?(0,R.jsx)(Y,{icon:(0,R.jsx)(Eb,{}),onClick:s,children:`Prepare drive`}):l?(0,R.jsx)(Y,{icon:(0,R.jsx)(Cb,{}),onClick:c,children:`Return to drive`}):(0,R.jsx)(Y,{icon:(0,R.jsx)(wb,{}),loading:a,disabled:e.state===`blocked`||a,title:e.state===`blocked`?e.reason:void 0,onClick:o,children:`Test drive`}),caption:e.state===`blocked`?e.reason:e.state===`prepare`?`No setup or dev command yet.`:void 0,rule:!1}),(0,R.jsx)(Rj,{title:`Drive setup`,icon:(0,R.jsx)(mb,{}),aside:(0,R.jsxs)(`span`,{className:`font-mono`,children:[v5,` · `,t??`…`]}),children:(0,R.jsx)(`div`,{className:`rounded-md border border-border-subtle bg-surface-inset px-4 py-3`,children:(0,R.jsx)(aj,{items:u,className:`gap-x-8`})})})]})}function b5(e,t,n){return t?.trim()?{label:e,value:t,mono:!0}:{label:e,value:(0,R.jsxs)(`span`,{className:`font-normal text-text-tertiary`,children:[`Nothing set ·`,` `,(0,R.jsx)(nI,{location:{page:`project`,field:n},children:`Settings`})]})}}function x5(e){let t=B.useUtils(),n=gx(),r=B.feature.driveInfo.useQuery(void 0,{refetchInterval:Ch()}),i=B.project.testDrive.useMutation({onSuccess:()=>void t.feature.driveInfo.invalidate(),onError:e=>n.push(e.message)}),a=r.data??null,o=(t,r)=>i.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok?r?.():n.push(e.deniedReason??`the drive could not ${t}`)}});return{slot:a,drive:bx(a,e)?a:null,start:e=>o(`start`,e),stop:e=>o(`stop`,e),starting:i.isPending&&i.variables?.action===`start`,stopping:i.isPending&&i.variables?.action===`stop`}}function S5({projectId:e,talk:t,newChatRequest:n=0,onConsumeNewChatRequest:r,inboxRequest:i=0,onConsumeInboxRequest:a,empty:o=!1,onOpenPreparation:s,driveRequest:c=0,onConsumeDriveRequest:l}){let u=B.useUtils(),d=B.project.list.useQuery().data?.find(t=>t.id===e),f=Y8(e),p=B.project.branches.useQuery({projectId:e,includeFeatureBranches:!0}),m=x5(e),h=m.drive,g=t.session,[_,v]=(0,L.useState)(null),y=B.projectNotes.list.useQuery({projectId:e},{refetchInterval:Ch()}),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!!(g&&n>0)),[w,T]=(0,L.useState)(`chat`),[E,D]=(0,L.useState)(!!(g&&n>0)),[O,k]=(0,L.useState)(void 0);(0,L.useEffect)(()=>{n>0&&g&&(C(!0),D(!0),k(void 0),r?.())},[n,r,g]),(0,L.useEffect)(()=>{i>0&&(v(null),C(!0),x(!0))},[i]),(0,L.useEffect)(()=>{g||(D(!1),k(void 0))},[g]);let A=g?.id;(0,L.useEffect)(()=>{A&&T(`chat`)},[A]);let j=()=>{v(null),C(!1),T(`drive`)},M=()=>{C(!1),T(`chat`)},N=()=>{T(`chat`),g&&C(!0)};(0,L.useEffect)(()=>{c>0&&(j(),l?.())},[c,l]);let P=_,ee=P!==null||S||!g&&!(h&&w===`drive`),F=!!h&&!ee&&(w===`drive`||!g),I=!!g&&!ee&&!F,te=g||h?(0,R.jsx)(g5,{value:F?`drive`:I?`chat`:`overview`,chat:!!g,drive:!!h,onPick:e=>{e===`overview`?(v(null),N()):e===`chat`?(v(null),M()):j()}}):void 0,ne=e=>{t.resume(e),v(null),M()},re=d?.name??`This project`,ie=(y.data??[]).filter(e=>e.status===`open`).length,ae=(y.data??[]).length>0,oe=ae&&(b??ie>0);return(0,R.jsxs)(`section`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`div`,{className:ee?`flex min-h-0 flex-1 flex-col`:`hidden`,hidden:!ee,children:P?(0,R.jsx)(c5,{session:null,transcriptId:P.id,onResume:P.resumable?()=>ne(P.id):void 0,resuming:t.starting,projectName:re,title:P.title??`project`,branch:f.value,hidden:!1,onBack:()=>v(null)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(_j,{crumbs:[{label:re,icon:(0,R.jsx)(yb,{})}],tabs:te,actions:(0,R.jsx)(R.Fragment,{children:ae&&(0,R.jsx)(UE,{label:`Notes`,badge:ie,icon:(0,R.jsx)(nb,{}),active:oe,onClick:()=>x(!oe)})})}),(0,R.jsx)(Cj,{aside:oe&&(0,R.jsx)(Sj,{title:`Notes`,onClose:()=>x(!1),children:(0,R.jsx)(i5,{projectId:e,triaging:t.starting,reveal:i>0,onRevealed:a,onTriage:()=>{if(!g){t.triage();return}k(`triage`),D(!0)}})}),children:(0,R.jsxs)(yj,{routeKey:`project-${e}`,children:[(0,R.jsx)(bj,{title:re,meta:[{icon:(0,R.jsx)(rb,{}),text:Uy,mono:!0,title:`the branch project chats run on`},f.value?{icon:(0,R.jsx)(Cb,{}),text:`lands on ${f.value}`}:null]}),(0,R.jsxs)(`div`,{className:`mt-8`,children:[(0,R.jsx)(e5,{landing:f,onStart:t.start,starting:t.starting,openSession:g&&E?{onOpen:()=>{D(!1),k(void 0),M()},onReplace:()=>{D(!1),t.replace(O),M()}}:void 0}),(0,R.jsx)(y5,{card:xx({empty:o||!d,setupCommand:d?.driveSetupCommand,devCommand:d?.devCommand,drive:m.slot,projectId:e}),branch:h?.branch??(p.data?.current||null),setupCommand:d?.driveSetupCommand,devCommand:d?.devCommand,stopCommand:d?.driveStopCommand,starting:m.starting,onStart:()=>m.start(j),onPrepare:()=>s?.(),onReturn:j})]}),(0,R.jsx)(Q8,{conversations:t.conversations,pending:t.conversationsPending,busy:t.starting,onResume:ne,onOpen:M,onView:e=>e.status===`ended`?v(e):M()})]})})]})}),h&&(0,R.jsx)(m5,{projectId:e,projectName:re,repoPath:d?.repoPath,drive:h,hidden:!F,onProjectPage:N,onStop:()=>m.stop(N),stopping:m.stopping,onOpenPreparation:()=>s?.(),switcher:te}),g&&(0,R.jsx)(c5,{session:g,projectName:re,title:C5(t.conversations,g.id)??`project`,branch:f.value,hidden:!I,switcher:te,onBack:()=>{D(!1),C(!0)},onEnded:()=>{u.project.projectSession.invalidate(),u.project.conversations.invalidate()}})]})}function C5(e,t){return e.find(e=>e.id===t)?.title??null}function w5({dirty:e,onDismiss:t,children:n}){return(0,R.jsx)(Hj,{open:!0,onClose:t,dirty:e,inline:!0,labelledBy:`park-draft-title`,backdropClassName:`min-h-0 overflow-y-auto bg-surface`,className:`max-w-[560px]`,children:n})}function T5({title:e,slug:t,oneLiner:n,notes:r,duplicate:i,busy:a,ready:o,onTitleChange:s,onOneLinerChange:c,onNotesChange:l,onSubmit:u,onCancel:d}){let f=()=>u(r.trim()||void 0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{id:`park-draft-title`,title:`Park it for later`,description:`Write it down now, work it out later. Nothing is cut until you Start it.`,onClose:d}),(0,R.jsxs)(Wj,{className:`flex flex-col gap-4 pt-1`,children:[(0,R.jsx)(hj,{label:`Title`,error:i,children:(0,R.jsx)(fj,{value:e,onChange:e=>s(e.target.value),placeholder:`e.g. Slack alerts on failed runs`,autoFocus:!0,invalid:!!i,onKeyDown:e=>{e.key===`Enter`&&f()}})}),(0,R.jsx)(hj,{label:`One-liner (optional)`,children:(0,R.jsx)(fj,{value:n,onChange:e=>c(e.target.value),placeholder:`What and why, in a sentence`,onKeyDown:e=>{e.key===`Enter`&&f()}})}),(0,R.jsx)(hj,{label:`Notes (optional — becomes the brief)`,children:(0,R.jsx)(mj,{rows:5,value:r,onChange:e=>l(e.target.value),placeholder:`Anything Start should know`})})]}),(0,R.jsxs)(Gj,{className:`mt-2 border-t border-border-subtle pt-4`,start:(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(rb,{size:14,className:`shrink-0 text-icon`}),(0,R.jsxs)(`span`,{className:`truncate font-mono`,children:[`feature/`,t||`…`,` · draft`]})]}),children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:d,disabled:a,children:`Cancel`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(gb,{}),onClick:f,disabled:!o||a,children:a?`Parking…`:`Park draft`})]})]})}function E5({projectId:e,onCancel:t,onCreated:n}){let[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),l=B.useUtils(),u=gx(),d=e_(r,B.feature.list.useQuery({projectId:e},{refetchInterval:Ch()}).data??[]),f=async e=>{await l.feature.list.invalidate(),n(e)},p=B.feature.create.useMutation({onSuccess:e=>void f(e.id),onError:e=>u.push(e.message)}),m=p.isPending,h=!!r.trim(),g=!!r.trim()||!!a.trim()||!!s.trim(),_=t=>{!h||m||p.mutate({projectId:e,title:r.trim(),oneLiner:a.trim(),draft:!0,...t?{brief:t}:{}})};return(0,R.jsx)(w5,{dirty:g,onDismiss:t,children:e=>(0,R.jsx)(T5,{title:r,slug:$g(r),oneLiner:a,notes:s,duplicate:d,busy:m,ready:h,onTitleChange:i,onOneLinerChange:o,onNotesChange:c,onSubmit:_,onCancel:e})})}var D5=`Repo facts an agent establishes once — how to install, how to verify, what is already red — so no burn agent re-derives them per ticket.`;function O5({projectId:e,onClose:t}){let n=B.useUtils(),r=gx(),i=B.project.list.useQuery().data?.find(t=>t.id===e),a=B.project.prep.useQuery({projectId:e},{refetchInterval:Ch(3e3)}),o=B.project.prepSession.useQuery({projectId:e},{refetchInterval:Ch()}),s=B.project.talkToPrep.useMutation({onSuccess:()=>void n.project.prepSession.invalidate(),onError:e=>r.push(e.message)}),c=B.project.dryRunStop.useMutation({onSuccess:()=>{n.project.prep.invalidate(),n.feature.driveInfo.invalidate()},onError:e=>r.push(e.message)}),[l,u]=(0,L.useState)(!1),d=a.data,f=o.data??null,p=d?.findings??[],m=d?.pendingKeys??[],h=p.filter(im).length,g=f?f.ccSessionId??f.id:``;return(0,R.jsxs)(`section`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(_j,{crumbs:[{label:i?.name??`This project`,icon:(0,R.jsx)(yb,{}),...t?{onClick:t}:{}},{label:`Preparation`,icon:(0,R.jsx)(Eb,{})}],actions:f?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mr-2 hidden items-center gap-4 text-xs text-text-tertiary md:flex`,children:[(0,R.jsx)(HA,{tone:f.status===`live`?`live`:`accent`,children:R3(A_(f))}),(0,R.jsx)(`span`,{className:`font-mono`,title:g,children:g.slice(0,8)})]}),(0,R.jsx)(Z6,{sessionId:f.id,onEnded:()=>{n.project.prepSession.invalidate(),n.project.prep.invalidate()}}),p.length>0&&(0,R.jsx)(UE,{label:l?`Hide what is established`:`Show what is established`,icon:(0,R.jsx)(nb,{}),active:l,onClick:()=>u(e=>!e)})]}):void 0}),d?.dryRun&&(0,R.jsx)(M5,{open:Mv(d.dryRun),stopping:c.isPending,onStop:()=>c.mutate({projectId:e})}),f?(0,R.jsx)(Cj,{aside:l&&p.length>0&&(0,R.jsx)(Sj,{title:`Established`,onClose:()=>u(!1),bodyClassName:`px-4 py-3`,children:(0,R.jsx)(j5,{findings:p,staleCount:h,compact:!0})}),children:(0,R.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 bg-surface-inset animate-fade-in`,children:(0,R.jsx)(LJ,{label:`terminal`,children:(0,R.jsx)(c4,{sessionId:f.id})})})}):(0,R.jsxs)(yj,{routeKey:`prepare-${e}`,children:[a.isLoading&&(0,R.jsx)(k5,{}),a.error&&(0,R.jsx)(Fj,{icon:(0,R.jsx)(Vb,{}),title:`Could not load preparation`,hint:a.error.message}),d&&(0,R.jsx)(A5,{prepared:d.prepared,preparedAt:d.preparedAt,pending:m,findings:p,staleCount:h,starting:s.isPending,onStart:()=>s.mutate({projectId:e}),onStartFresh:()=>s.mutate({projectId:e,fresh:!0})})]})]})}function k5(){return(0,R.jsxs)(Oj,{label:`Loading preparation…`,children:[(0,R.jsx)(`div`,{className:`flex h-7 items-center`,"data-skeleton":`title`,children:(0,R.jsx)(kj,{className:`h-5 w-3/5`})}),(0,R.jsx)(`div`,{className:`mt-2 flex h-5 items-center`,children:(0,R.jsx)(kj,{className:`h-2.5 w-32`})}),(0,R.jsxs)(`div`,{className:`mt-5 max-w-[60ch]`,"data-skeleton":`sentence`,children:[(0,R.jsx)(`div`,{className:`flex h-[22px] items-center`,children:(0,R.jsx)(kj,{className:`h-3 w-full`})}),(0,R.jsx)(`div`,{className:`flex h-[22px] items-center`,children:(0,R.jsx)(kj,{className:`h-3 w-3/4`})})]}),(0,R.jsx)(kj,{className:`mt-6 h-(--control-h) w-40 rounded-md`}),(0,R.jsx)(`div`,{className:`mt-2 flex h-4 max-w-[60ch] items-center`,children:(0,R.jsx)(kj,{className:`h-2.5 w-5/6`})})]})}function A5({prepared:e,preparedAt:t,pending:n,findings:r,staleCount:i,starting:a,onStart:o,onStartFresh:s}){let c=r.length>0,l=[e&&{icon:(0,R.jsx)(Bb,{}),text:t===null?`No preparation conversation on record`:`Prepared ${Qp(t)}`},!e&&n.length>0&&{strong:n.length,text:`to establish`},c&&{strong:r.length,text:`established`},i>0&&{tone:`warning`,strong:i,text:`stale`}];return e?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(bj,{title:`Re-prepare this project`,meta:l,children:[(0,R.jsxs)(`p`,{className:`m-0 max-w-[60ch] text-base text-pretty text-text-secondary`,children:[t===null&&`Every field already had a value. `,D5,` Repo facts drift; re-preparing measures them again with you there.`]}),(0,R.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Gb,{}),loading:a,disabled:a,onClick:o,children:`Resume`}),(0,R.jsx)(Y,{icon:(0,R.jsx)(ob,{}),disabled:a,onClick:s,children:`Start fresh`})]}),(0,R.jsx)(`p`,{className:`mt-2 mb-0 max-w-[60ch] text-xs text-pretty text-text-tertiary`,children:`Resume continues your last preparation conversation; Start fresh opens one that has never seen it — values you typed by hand are never overwritten.`})]}),(0,R.jsx)(j5,{findings:r,staleCount:i})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(bj,{title:c?`Finish preparing this project`:`Prepare this project first`,meta:l,children:[(0,R.jsx)(`p`,{className:`m-0 max-w-[60ch] text-base text-pretty text-text-secondary`,children:D5}),(0,R.jsx)(`div`,{className:`mt-6 flex flex-wrap items-center gap-2`,children:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(wb,{}),loading:a,disabled:a,onClick:o,children:`Start preparation`})}),(0,R.jsx)(`p`,{className:`mt-2 mb-0 max-w-[60ch] text-xs text-pretty text-text-tertiary`,children:`Opens a terminal session here with an agent in your own checkout — it runs this repo's commands, records the answers, and asks you the ones only you know.`})]}),n.length>0&&(0,R.jsx)(xj,{title:`To establish`,children:(0,R.jsx)(ij,{divided:!0,label:`To establish`,children:n.map((e,t)=>(0,R.jsx)(rj,{index:t,leading:(0,R.jsx)(qb,{}),title:Xp[e]??e,meta:`Not yet`},e))})}),(0,R.jsx)(j5,{findings:r,staleCount:i})]})}function j5({findings:e,staleCount:t,compact:n=!1}){if(e.length===0)return null;let r=(0,R.jsxs)(R.Fragment,{children:[t>0&&(0,R.jsx)(N5,{count:t}),(0,R.jsx)(P5,{findings:e})]});return n?r:(0,R.jsx)(xj,{title:`Established`,children:r})}function M5({open:e,stopping:t,onStop:n}){return(0,R.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-3 border-b border-border-subtle px-4 animate-fade-in`,children:[(0,R.jsx)(HA,{tone:`live`,size:`sm`,strong:!0,children:`Preparation dry run in progress`}),e&&(e.state===`ready`?(0,R.jsxs)(`a`,{className:q(`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,`inline-flex min-w-0 items-center gap-1 truncate font-mono text-xs`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.url,(0,R.jsx)(Pb,{size:12,className:`shrink-0`})]}):(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-tertiary`,children:Nv(e)})),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Tb,{}),loading:t,disabled:t,onClick:n,children:`Stop`})]})}function N5({count:e}){return(0,R.jsxs)(`div`,{className:`mb-4 flex max-w-[64ch] items-start gap-2 text-sm text-pretty text-text-secondary`,children:[(0,R.jsx)(Vb,{size:16,className:`mt-0.5 shrink-0 text-warning`}),(0,R.jsxs)(`span`,{children:[e,` finding`,e===1?` has`:`s have`,` not been re-measured in a long time. A stale test baseline is worse than none — agents trust it and file their own breakage under “already red on main”.`]})]})}function P5({findings:e}){return(0,R.jsx)(`div`,{className:`flex flex-col [&>details:last-child]:border-b [&>details:last-child]:border-border-subtle`,children:e.map((e,t)=>(0,R.jsx)(F5,{finding:e,label:Xp[e.key]??e.key,index:t},e.key))})}function F5({finding:e,label:t,index:n}){let[r,i]=(0,L.useState)(!1),a=am(e),o=im(e);return(0,R.jsx)(Rj,{title:t,index:n,aside:(0,R.jsxs)(`span`,{className:`flex items-center gap-4`,children:[o&&(0,R.jsx)(HA,{tone:`warning`,children:`Stale`}),(0,R.jsx)(I5,{finding:e}),(0,R.jsx)(HA,{title:a.title,children:a.label})]}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`div`,{className:q(`text-xs`,o?`text-warning`:`text-text-tertiary`),children:tm(e)}),e.evidence&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`rounded-md border border-border-subtle bg-surface-inset px-3 py-2`,children:(0,R.jsx)(`div`,{className:q(`font-mono text-xs leading-[1.5] break-words whitespace-pre-wrap text-text-secondary`,!r&&`line-clamp-3`),children:e.evidence})}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,className:`-ml-2 self-start`,onClick:()=>i(e=>!e),"aria-expanded":r,"aria-label":`${r?`Collapse`:`Show full`} evidence for ${t}`,children:r?`Show less`:`Show full evidence`})]})]})})}function I5({finding:e}){return $p(e.key)?e.verifiedAt===void 0?(0,R.jsx)(HA,{tone:`warning`,title:`No dry run has ever proven this value — a drive that depends on it may fall over`,children:`Unproven`}):(0,R.jsxs)(HA,{tone:`success`,icon:(0,R.jsx)(sb,{size:14}),title:`A preparation dry run ran this value on the real drive machinery and it worked`,children:[`Proven `,Qp(e.verifiedAt)]}):null}var L5=(e,t)=>e===``||t.includes(e);function R5(e){let{open:t,onClose:n,features:r,selectedFeatureId:i,onSelect:a,onOpenSettings:o,onOpenPreparation:s,onOpenProjectChat:c,onOpenNote:l,onToggleSidebar:u,onToggleDetails:d,nav:f}=e,p=KM(),[m,h]=(0,L.useState)(``),[g,_]=(0,L.useState)(0),v=(0,L.useRef)(null),y=(0,L.useRef)([]);(0,L.useEffect)(()=>{if(!t)return;h(``),_(0),v.current?.focus();let e=requestAnimationFrame(()=>v.current?.focus());return()=>cancelAnimationFrame(e)},[t]),(0,L.useEffect)(()=>{if(!t)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]),(0,L.useEffect)(()=>{_(0)},[m]);let b=m.trim().toLowerCase(),x=(0,L.useMemo)(()=>b===``?r:r.filter(e=>e.slug.toLowerCase().includes(b)||e.title.toLowerCase().includes(b)),[r,b]),S=(0,L.useMemo)(()=>(f.projects??[]).filter(e=>e.id!==f.currentProjectId),[f.projects,f.currentProjectId]),C=(0,L.useMemo)(()=>b===``?S:S.filter(e=>e.name.toLowerCase().includes(b)),[S,b]),w=(0,L.useMemo)(()=>{let e=p.resolved===`dark`?`light`:`dark`;return[{kind:`projectChat`,shows:Qy(b),glyph:(0,R.jsx)(zb,{}),label:`Project chat`,run:c},{kind:`newNote`,shows:L5(b,`new note jot capture`),glyph:(0,R.jsx)(_b,{}),label:`New note`,kbd:mM(`J`),run:l},{kind:`preparation`,shows:Zy(b),glyph:(0,R.jsx)(Eb,{}),label:`Preparation`,run:s},{kind:`settings`,shows:L5(b,`settings preferences`),glyph:(0,R.jsx)(tb,{}),label:`Settings`,run:o},{kind:`theme`,shows:L5(b,`toggle theme dark light appearance ${e}`),glyph:p.resolved===`dark`?(0,R.jsx)(Ib,{}):(0,R.jsx)(Lb,{}),label:`Toggle theme — switch to ${e}`,run:p.toggle},...u?[{kind:`sidebar`,shows:L5(b,`toggle sidebar hide show collapse expand`),glyph:(0,R.jsx)(Mb,{}),label:`Toggle sidebar`,kbd:mM(`B`),run:u}]:[],...d?[{kind:`details`,shows:L5(b,`toggle details panel inspector hide show`),glyph:(0,R.jsx)(nb,{}),label:`Toggle details panel`,run:d}]:[],{kind:`home`,shows:L5(b,`all projects home`),glyph:(0,R.jsx)(yb,{}),label:`All projects`,run:f.goHome},{kind:`openProject`,shows:L5(b,`open a project`),glyph:(0,R.jsx)(ob,{}),label:`Open a project…`,run:f.showOpen}].filter(e=>e.shows)},[b,p.resolved,p.toggle,c,l,o,s,u,d,f]),T=(0,L.useMemo)(()=>{let e=x.map(e=>({kind:`feature`,feature:e}));for(let t of C)e.push({kind:`project`,id:t.id,name:t.name});for(let t of w)e.push({kind:`action`,action:t});return e},[x,C,w]);if(!t)return null;let E=e=>{if(T.length===0)return;let t=(g+e+T.length)%T.length;_(t),y.current[t]?.scrollIntoView({block:`nearest`})},D=e=>{let t=T[e];if(t){switch(t.kind){case`feature`:a(t.feature.id);break;case`project`:f.enterProject(t.id);break;case`action`:t.action.run();break}n()}},O=e=>{e.key===`ArrowDown`?(e.preventDefault(),E(1)):e.key===`ArrowUp`?(e.preventDefault(),E(-1)):e.key===`Enter`?(e.preventDefault(),D(g)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=x.length,A=k+C.length,j=(e,t,n,r,i,a)=>(0,R.jsxs)(`div`,{ref:t=>{y.current[e]=t},role:`option`,"aria-selected":e===g,"data-selected":e===g,className:q(kx,Ax,`min-h-8 hover:bg-transparent`),onMouseMove:()=>e!==g&&_(e),onClick:()=>D(e),children:[(0,R.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center [&>svg]:size-4`,children:n}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:r}),i]},t),M=e=>(0,R.jsx)(`div`,{className:q(Mx,`pt-2.5`),children:e});return(0,R.jsx)(`div`,{className:`fixed inset-0 z-[300] flex animate-backdrop-in items-start justify-center bg-scrim px-4 pt-[12vh] pb-4`,onMouseDown:e=>{e.target===e.currentTarget&&n()},children:(0,R.jsxs)(`div`,{role:`dialog`,"aria-label":`Command palette`,className:`flex max-h-[min(520px,76vh)] w-full max-w-[560px] animate-dialog-in flex-col overflow-hidden rounded-lg bg-surface-raised text-text shadow-dialog`,children:[(0,R.jsxs)(`div`,{className:`flex h-13 shrink-0 items-center gap-3 border-b border-border-subtle px-4`,children:[(0,R.jsx)(eb,{size:16,className:`shrink-0 text-icon`}),(0,R.jsx)(`input`,{ref:v,className:`h-full min-w-0 flex-1 border-0 bg-transparent p-0 font-sans text-base text-text outline-none placeholder:text-text-tertiary`,placeholder:`Search features, projects, or jump to…`,value:m,onChange:e=>h(e.target.value),onKeyDown:O,"aria-label":`Search features, projects, or jump to`})]}),(0,R.jsxs)(`div`,{role:`listbox`,"aria-label":`Results`,className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:[x.length>0&&M(`Features`),x.map((e,t)=>j(t,e.id,(0,R.jsx)(sx,{phase:e.status===`draft`?`draft`:e.phase,label:``}),e.title,(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-text-tertiary`,children:[e.id===i&&(0,R.jsx)(`span`,{className:`text-text-secondary`,children:`Current`}),(0,R.jsx)(`span`,{children:e.status===`draft`?ix.draft:ix[e.phase]})]}),e.title)),C.length>0&&M(`Projects`),C.map((e,t)=>j(k+t,e.id,(0,R.jsx)(yb,{className:`text-icon`}),e.name,(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-text-tertiary`,children:`Switch`}),e.name)),w.length>0&&M(`Actions`),w.map((e,t)=>j(A+t,e.kind,e.glyph,e.label,e.kbd?(0,R.jsx)(Px,{children:e.kbd}):null,e.label)),T.length===0&&(0,R.jsx)(`div`,{className:`p-6 text-center text-sm text-text-tertiary`,children:`No matches`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4 border-t border-border-subtle px-4 py-2 text-xs text-text-tertiary`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`↑`}),(0,R.jsx)(Px,{children:`↓`}),` to move`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`Enter`}),` to open`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`Esc`}),` to close`]})]})]})})}var z5=1500,B5=`flex h-13 items-center gap-3 px-4`,V5=160;function H5(e){let t=e.style.height;e.style.height=`auto`;let n=e.scrollHeight;e.style.height=t,e.offsetHeight,e.style.height=`${Math.min(n,V5)}px`,e.style.overflowY=n>V5?`auto`:`hidden`}function U5({projectId:e,projectName:t,open:n,openRequest:r=0,onClose:i,onOpenInbox:a}){let o=B.useUtils(),s=gx(),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(null),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(!1),g=(0,L.useRef)(null),_=(0,L.useRef)(0),v=()=>{l(``),d(null),p(!1),h(!1)},[y,b]=(0,L.useState)(n);n!==y&&(b(n),_.current+=1,n&&v());let[x,S]=(0,L.useState)(r);r!==x&&(S(r),n&&m&&v()),(0,L.useEffect)(()=>{n&&g.current?.focus()},[r]),(0,L.useLayoutEffect)(()=>{g.current&&H5(g.current)},[c,n,m]);let C=B.projectNotes.add.useMutation(),w=B.projectNotes.openCount.useQuery({projectId:e},{enabled:n}),T=(0,L.useRef)(null);(0,L.useEffect)(()=>{T.current=u?.preview??null},[u]),(0,L.useEffect)(()=>{if(n)return()=>{T.current&&URL.revokeObjectURL(T.current)}},[n]);let E=(0,L.useRef)(i);E.current=i,(0,L.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>E.current(),z5);return()=>clearTimeout(e)},[m]);let D=async e=>{try{let t=await mh(e),n={png:t,preview:URL.createObjectURL(t)};d(e=>(e&&URL.revokeObjectURL(e.preview),n))}catch(e){s.push(e instanceof Error?e.message:`that image could not be read`)}},O=()=>{d(e=>(e&&URL.revokeObjectURL(e.preview),null)),g.current?.focus()},k=e=>{let t=ph(e.clipboardData);t&&(e.preventDefault(),D(t))},A=async()=>{if(!c.trim()||f)return;let t=_.current,n=()=>_.current===t;p(!0);try{let t=await C.mutateAsync({projectId:e,text:c});if(u)try{await vx(t.id,u.png)}catch(e){s.push(`the note was saved, but its picture was not: ${e instanceof Error?e.message:String(e)}`)}o.projectNotes.openCount.setData({projectId:e},e=>e===void 0?e:e+1),o.projectNotes.invalidate(),n()&&h(!0)}catch(e){s.push(e instanceof Error?e.message:`the note could not be saved`)}finally{n()&&p(!1)}};return(0,R.jsx)(Hj,{open:n,onClose:i,size:`palette`,scrim:m?`none`:`light`,className:`overflow-hidden`,label:`Jot a note`,initialFocusRef:g,children:m?(0,R.jsxs)(`div`,{className:q(B5,`text-sm animate-fade-in`),role:`status`,children:[(0,R.jsx)(`span`,{className:`flex shrink-0 items-center text-success`,children:(0,R.jsx)(sb,{size:16})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:[`Noted in `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:t}),w.data!==void 0&&(0,R.jsxs)(R.Fragment,{children:[` · `,w.data,` open`]})]}),(0,R.jsx)(`button`,{className:q(JE,`text-sm`),onClick:()=>{a(),i()},title:`Read the pile on the project workspace`,children:`View`})]}):(0,R.jsxs)(`div`,{onPaste:k,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border-subtle px-4`,children:[(0,R.jsx)(`span`,{className:`flex h-13 shrink-0 items-center text-icon`,children:(0,R.jsx)(_b,{size:16})}),(0,R.jsx)(`textarea`,{ref:g,rows:1,className:`box-border block min-w-0 flex-1 resize-none border-0 bg-transparent px-0 py-3.75 font-sans text-base text-text outline-none transition-[height] duration-(--dur-2) ease-app placeholder:text-text-tertiary`,autoComplete:`off`,"aria-label":`what did you just notice?`,placeholder:`What did you just notice?`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),A())}})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-2 text-xs text-text-tertiary`,children:[u?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-text-secondary animate-fade-in`,children:[(0,R.jsx)(`img`,{src:u.preview,alt:`the picture this note will carry`,className:`h-5 w-8 rounded-sm bg-surface-inset object-cover`}),`Screenshot`,(0,R.jsx)(UE,{size:`sm`,label:`Remove the picture`,icon:(0,R.jsx)(cb,{}),onClick:O})]}):(0,R.jsx)(`span`,{children:`Paste a screenshot`}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsxs)(`span`,{children:[`to `,(0,R.jsx)(`span`,{className:`font-medium text-text-secondary`,children:t})]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`↵`}),` save`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`⇧↵`}),` new line`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`esc`}),` close`]})]})]})})}var W5={"claude-code":{check:`afk-key`,kind:`token`},codex:{check:`auth`,kind:`sign-in`}};function G5(e){return sd.flatMap(t=>{let{check:n,kind:r}=W5[t],i=e.find(e=>e.runtime===t&&e.check===n);return i?[{runtime:t,kind:r,probe:i}]:[]})}function K5(e){return`${W5[e].check}-${e}`}function q5(e){let t=sm[e],n=W5[e].kind===`token`;return{field:K5(e),label:n?`${t} token`:t,reason:n?`burns with ${t} need a token`:`sign in to ${t}`,terms:n?[t,`token`,`AFK credential`]:[t,`sign in`,`login`]}}var J5=[{field:`container-runtime`,label:`Container runtime`,reason:`no container runtime on this machine`,terms:[`Container runtime`,`Docker`,`Podman`]},{field:`sandcastle-image`,label:`Sandcastle image`,reason:`the sandcastle image needs building`,terms:[`Sandcastle image`,`build`,`rebuild`]},...sd.map(q5),{field:`burn-cache`,label:`Burn cache`,terms:[`Burn cache`,`volume`,`clear`]}];function Y5(e){let t=e.find(e=>!e.ok);return t?{count:`${e.filter(e=>e.ok).length} of ${e.length}`,text:`ready — ${t.reason}`}:{count:null,text:`Ready for unattended burns`}}var X5=[{page:`general`,label:`General`,Icon:tb},{page:`models`,label:`Models`,Icon:bb},{page:`burns`,label:`Burns`,Icon:xb},{page:`project`,label:`This project`,Icon:yb}];function Z5({page:e,filter:t,filterRef:n,projectName:r,onFilter:i,onSelect:a}){let o=t.query.trim()!==``;return(0,R.jsxs)(`nav`,{"aria-label":`Settings pages`,className:`flex min-h-0 flex-col gap-0.5 border-r border-border-subtle bg-canvas px-2 pt-4 pb-3`,children:[(0,R.jsx)(`div`,{className:`mb-2 px-2.5 text-sm font-medium text-text`,children:`Settings`}),(0,R.jsx)(pj,{ref:n,size:`md`,"aria-label":`Filter settings`,placeholder:`Filter`,kbd:`Ctrl F`,autoComplete:`off`,value:t.query,onChange:e=>i(e.target.value),className:`mb-3`}),X5.map(({page:n,label:r,Icon:i})=>(0,R.jsx)(nj,{label:r,icon:(0,R.jsx)(i,{}),active:n===e,onClick:()=>a(n),meta:o?t.counts[n]||``:void 0},n)),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 px-2.5 pt-3`,children:[(0,R.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:`This project is`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-xs text-text-secondary`,title:r,children:r})]})]})}var Q5=1500;function $5(e){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{if(!e)return;t.current?.scrollIntoView?.({block:`center`}),r(!0);let n=setTimeout(()=>r(!1),Q5);return()=>clearTimeout(n)},[e]),{ref:t,flash:n}}function e7(e,t){return e.query.trim()===``||e.matches.has(t)}var t7=1400;function n7({title:e,rows:t,projectId:n,filter:r,highlightField:i,onOpenEvidence:a,evidence:o}){let s=t.filter(e=>e7(r,e.key));return s.length===0?null:(0,R.jsx)(i7,{title:e,children:s.map(e=>(0,R.jsx)(o7,{row:e,projectId:n,highlight:i===e.key,...a&&e.provenanceChip?.evidence?{onOpenEvidence:()=>a(e.key)}:{},...o?{evidence:o(e)}:{}},e.key))})}function r7({groups:e,className:t}){return(0,R.jsx)(Oj,{label:`Loading settings…`,className:t,children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`mt-9 first:mt-0`,children:[(0,R.jsx)(`div`,{className:`flex min-h-7 items-center border-b border-border-subtle pb-2`,children:(0,R.jsx)(kj,{className:`h-3 w-16`})}),e.map((e,t)=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,300px)] items-start gap-x-8 border-b border-border-subtle py-4 last:border-b-0`,"data-skeleton":`setting-row`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 pt-1`,children:[(0,R.jsx)(kj,{className:q(`h-3`,e)}),(0,R.jsx)(kj,{className:`h-2.5 w-4/5`})]}),(0,R.jsx)(kj,{className:`h-(--control-h) w-full rounded-md`})]},t))]},t))})}function i7({title:e,action:t,description:n,children:r}){return(0,R.jsxs)(`section`,{className:`mt-9 first:mt-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-7 items-center gap-3 border-b border-border-subtle pb-2`,children:[(0,R.jsx)(`h3`,{className:`m-0 min-w-0 flex-1 text-sm font-medium text-text`,children:e}),t&&(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:t})]}),n&&(0,R.jsx)(`div`,{className:`mt-2.5 text-xs text-pretty text-text-tertiary`,children:n}),(0,R.jsx)(`div`,{children:r})]})}function a7({label:e,htmlFor:t,description:n,descriptionId:r,aside:i,control:a,below:o,stacked:s=!1,flash:c=!1,rowRef:l}){return(0,R.jsxs)(`div`,{ref:l,className:q(`border-b border-border-subtle py-4 last:border-b-0`,`transition-[outline-color] duration-(--dur-3) ease-app`,s?`flex flex-col gap-2.5`:`grid grid-cols-[minmax(0,1fr)_minmax(0,300px)] items-start gap-x-8 gap-y-1.5`,c&&`rounded-md outline-2 outline-offset-4 outline-accent`),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 pt-1`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-5 items-center gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:t,className:`text-sm font-medium text-text`,children:e}),i]}),n&&(0,R.jsx)(`p`,{id:r,className:`m-0 text-xs text-pretty text-text-tertiary`,children:n})]}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[a,o]})]})}function o7({row:e,projectId:t,highlight:n,onOpenEvidence:r,evidence:i}){let a=B.useUtils(),o=e.ghostValue?``:e.value,[s,c]=(0,L.useState)(o),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(!1),{ref:h,flash:g}=$5(n),_=(0,L.useRef)(void 0);(0,L.useEffect)(()=>c(o),[o]),(0,L.useEffect)(()=>()=>clearTimeout(_.current),[]);let v=B.settings.update.useMutation({onSuccess:()=>{u(null),f(!0),clearTimeout(_.current),_.current=setTimeout(()=>f(!1),t7),e.restartRequired&&m(!0),a.settings.get.invalidate(),a.project.prep.invalidate()},onError:e=>{c(o),u(e.message)}}),y=e=>{c(e),l&&u(null)},b=n=>{u(null),v.mutate({...t?{projectId:t}:{},key:e.key,value:n})},x=t=>{if(t.trim()===o.trim())return;let n=Em(e.control,t);if(`error`in n){u(n.error);return}b(n.value)},S=()=>b(null),C=`set-${t?`project`:`global`}-${e.key}`,w=`${C}-help`,T=`${C}-error`,E=`${C}-about`,D=q(E,e.shortHelp?w:null,l?T:null)||void 0,O=e.sourceChip||e.clearable||e.provenanceChip;return(0,R.jsx)(a7,{rowRef:h,flash:g,stacked:e.control===`textarea`,label:e.label,htmlFor:C,description:e.tooltip||void 0,descriptionId:E,aside:d&&(0,R.jsx)(s7,{}),control:(0,R.jsx)(c7,{id:C,describedBy:D,row:e,draft:s,disabled:v.isPending,onDraft:y,onCommit:x,onRevert:()=>c(o)}),below:(0,R.jsxs)(R.Fragment,{children:[e.shortHelp&&(0,R.jsx)(`div`,{id:w,className:`text-xs text-text-tertiary`,children:e.shortHelp}),O&&(0,R.jsxs)(`div`,{className:`flex min-h-5 flex-wrap items-center gap-x-3 gap-y-1`,children:[e.sourceChip&&(0,R.jsx)(u7,{kind:e.sourceChip,envVar:om[e.key]}),e.sourceChip===`project`&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:S,className:`-ml-1.5`,children:`Use global`}),e.clearable&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:S,className:`-ml-1.5`,children:`Clear`}),e.provenanceChip&&(0,R.jsxs)(`div`,{className:`relative flex min-w-0`,children:[(0,R.jsx)(f7,{chip:e.provenanceChip,onOpenEvidence:r}),i]}),e.stale&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-warning`,title:`Measured a long time ago — “Re-prepare the project”, at the foot of the features rail, refreshes it`,children:[(0,R.jsx)(BA,{tone:`warning`}),`Stale`]})]}),p&&(0,R.jsx)(`div`,{className:`text-xs text-warning`,children:`Restart the server to apply`}),l&&(0,R.jsx)(`div`,{id:T,role:`alert`,className:`text-xs text-danger`,children:l})]})})}function s7(){return(0,R.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-text-tertiary animate-fade-in`,children:[(0,R.jsx)(sb,{size:12,className:`text-success`}),`Saved`]})}function c7({id:e,describedBy:t,row:n,draft:r,disabled:i,onDraft:a,onCommit:o,onRevert:s}){let c={id:e,"aria-describedby":t,disabled:i},l=e=>{e.key===`Escape`&&(s(),e.currentTarget.blur())},u=e=>{e.key===`Enter`&&e.currentTarget.blur(),l(e)},d=n.unit?(0,R.jsx)(`span`,{className:`min-w-0 text-xs text-pretty text-text-tertiary`,children:n.unit}):void 0;if(n.readOnly)return(0,R.jsx)(fj,{...c,disabled:!0,readOnly:!0,mono:n.control!==`select`,icon:(0,R.jsx)(Sb,{}),className:`w-full`,inputClassName:n.control===`number`?`tabular-nums`:void 0,value:n.optionLabels[n.value]??n.value});if(n.control===`select`)return(0,R.jsxs)(Wq,{value:r,onValueChange:e=>{a(e),o(e)},children:[(0,R.jsx)(Jq,{...c,className:q(Kq,`w-full`),children:(0,R.jsx)(Yq,{})}),(0,R.jsxs)(Xq,{children:[n.ghostValue&&(0,R.jsxs)(eJ,{value:``,children:[`Use global (`,n.optionLabels[n.ghostValue]??n.ghostValue,`)`]}),n.modelGroups.length>0?n.modelGroups.map(e=>(0,R.jsxs)(Zq,{children:[(0,R.jsx)(Qq,{children:e.label}),e.entries.map(e=>(0,R.jsx)(eJ,{value:e.id,title:e.note,children:e.note?`${e.id} — ${e.note}`:e.id},e.id))]},e.runtime)):n.options.map(e=>(0,R.jsx)(eJ,{value:e,children:n.optionLabels[e]??e},e))]})]});if(n.control===`textarea`)return(0,R.jsx)(mj,{...c,mono:!0,rows:3,placeholder:n.ghostValue??n.placeholder,value:r,onChange:e=>a(e.target.value),onBlur:e=>o(e.target.value),onKeyDown:l});let f=(0,R.jsx)(fj,{...c,type:n.control===`number`?`number`:`text`,mono:!0,className:n.control===`number`?`w-24 shrink-0`:`w-full`,inputClassName:n.control===`number`?`tabular-nums`:void 0,placeholder:n.ghostValue??n.placeholder,value:r,onChange:e=>a(e.target.value),onBlur:e=>o(e.target.value),onKeyDown:u});return d?(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[f,d]}):f}var l7={global:{text:`Global`,tone:`neutral`,word:`text-text-tertiary`},project:{text:`This project`,tone:`accent`,word:`text-text-secondary`},env:{text:`Env`,tone:`neutral`,word:`text-text-tertiary`}};function u7({kind:e,envVar:t}){let n=l7[e];return(0,R.jsxs)(`span`,{className:q(`inline-flex shrink-0 items-center gap-1.5 text-xs`,n.word),...e===`env`&&t?{title:`Set by ${t}`}:{},children:[e===`env`?(0,R.jsx)(Sb,{size:12,className:`text-icon`}):(0,R.jsx)(BA,{tone:n.tone}),(0,R.jsx)(`span`,{children:n.text})]})}var d7={ok:`success`,muted:`neutral`,warn:`warning`};function f7({chip:e,onOpenEvidence:t}){let n=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(BA,{tone:d7[e.tone]}),(0,R.jsx)(`span`,{className:`truncate`,children:e.text})]}),r=e.tone===`warn`?`text-warning`:`text-text-secondary`;return t?(0,R.jsx)(`button`,{type:`button`,onClick:t,className:q(`-mx-1.5 inline-flex h-6 min-w-0 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-1.5 text-xs`,`underline decoration-border-strong decoration-dotted underline-offset-4`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,r),children:n}):(0,R.jsx)(`span`,{className:q(`inline-flex min-w-0 items-center gap-1.5 text-xs`,r),children:n})}var p7=`theme`,m7=[{value:`dark`,label:`Dark`,icon:(0,R.jsx)(Lb,{size:14})},{value:`light`,label:`Light`,icon:(0,R.jsx)(Ib,{size:14})},{value:`system`,label:`System`,icon:(0,R.jsx)(Rb,{size:14})}];function h7({globals:e,filter:t,highlightField:n}){let r=e7(t,`theme`)&&(0,R.jsx)(i7,{title:`Appearance`,children:(0,R.jsx)(_7,{})});if(e.isLoading)return(0,R.jsxs)(R.Fragment,{children:[r,(0,R.jsx)(r7,{groups:g7,className:`mt-9`})]});if(e.error)return(0,R.jsxs)(R.Fragment,{children:[r,(0,R.jsxs)(Pj,{children:[`Could not load settings: `,e.error.message]})]});if(!e.data)return(0,R.jsx)(R.Fragment,{children:r});let i=Im(e.data,`general`),a=e=>i.filter(t=>t.group===e);return(0,R.jsxs)(R.Fragment,{children:[r,(0,R.jsx)(n7,{title:`Server`,rows:a(`server`),filter:t,highlightField:n}),(0,R.jsx)(n7,{title:`Sessions`,rows:a(`sessions`),filter:t,highlightField:n})]})}var g7=[[`w-20`,`w-28`],[`w-24`,`w-32`,`w-20`]];function _7(){let{preference:e,setPreference:t}=KM();return(0,R.jsx)(a7,{label:`Theme`,description:`Dark is the default; System follows your operating system as it changes.`,control:(0,R.jsx)(Tj,{id:`settings-theme`,label:`Theme`,items:m7.map(e=>({value:e.value,label:e.label,icon:e.icon})),value:e,onChange:t,className:`w-full`})})}var v7=`grid grid-cols-[minmax(0,1.5fr)_minmax(0,1.3fr)_minmax(0,0.8fr)_88px_24px] items-center gap-3`,y7=`min-h-8 border-b border-border-subtle px-2 text-xs font-medium text-text-tertiary`,b7=e=>`models:${e}`,x7=`models:new`,S7=`opacity-0 transition-opacity duration-(--dur-1) group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100`;function C7({rows:e,stepLabels:t,customModels:n,filter:r,writes:i}){let[a,o]=(0,L.useState)(!1),s=r.query.trim()!==``,c=(a||s?e:Wm(e)).filter(e=>e7(r,e.id)),l=a||s?0:Gm(e);return(0,R.jsxs)(`div`,{className:`mt-3`,children:[(0,R.jsxs)(`div`,{className:q(v7,y7),children:[(0,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{children:`Use-case note`}),(0,R.jsx)(`span`,{children:`Used for`}),(0,R.jsx)(`span`,{children:`Default`}),(0,R.jsx)(`span`,{})]}),c.map((e,r)=>(0,R.jsx)(w7,{index:r,row:e,stepLabels:t,customModels:n,writes:i},e.id)),l>0&&(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 border-b border-border-subtle px-2 text-xs text-text-tertiary`,children:[l,` more `,l===1?`model`:`models`,` nobody uses`,(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>o(!0),children:`Show all`})]}),!s&&(0,R.jsx)(D7,{customModels:n,writes:i})]})}function w7({row:e,index:t,stepLabels:n,customModels:r,writes:i}){let a=b7(e.id),o=e.usedFor.map(e=>n.get(e)??e).join(`, `),s=t=>{let n=t.trim(),o=n===``&&!e.custom?r.filter(t=>t.id!==e.id):hd(r,[{id:e.id,runtime:e.runtime,...n?{note:n}:{}}]);i.save(a,`models`,o)},c=()=>{if(e.isDefault){i.refuse(a,`${e.id} is the default model — make another model the default first.`);return}if(e.usedFor.length>0){i.refuse(a,`${e.id} runs ${o} — reset those steps first.`);return}i.save(a,`models`,r.filter(t=>t.id!==e.id))},l=t<8;return(0,R.jsxs)(`div`,{className:q(`group border-b border-border-subtle transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,l&&`animate-rise-in`),style:l?{animationDelay:`${t*20}ms`}:void 0,children:[(0,R.jsxs)(`div`,{className:q(v7,`min-h-10 px-2 text-sm`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(k7,{runtime:e.runtime}),(0,R.jsx)(`span`,{className:`truncate text-text`,title:e.displayName?`${e.displayName} — ${e.id}`:e.id,children:e.id}),e.isNew&&(0,R.jsx)(HA,{tone:`accent`,className:`shrink-0`,children:`New`})]}),(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(E7,{row:e,onCommit:s}),i.saved===a&&(0,R.jsx)(s7,{})]}),(0,R.jsxs)(`span`,{className:`truncate text-xs text-text-tertiary`,title:o||void 0,children:[e.isDefault&&(0,R.jsx)(`span`,{className:`text-text-secondary`,children:`Default`}),e.isDefault&&o!==``&&`, `,o===``?e.isDefault?``:`—`:o]}),e.isDefault?(0,R.jsx)(`span`,{"data-default-mark":``,className:`inline-flex`,children:(0,R.jsx)(HA,{strong:!0,icon:(0,R.jsx)(sb,{}),children:`Default`})}):(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,"aria-label":`Make ${e.id} the default`,onClick:()=>i.save(a,`model`,e.id),className:q(`-ml-2 justify-self-start`,S7),children:`Make default`}),e.custom?(0,R.jsx)(UE,{label:`Remove ${e.id}`,size:`sm`,icon:(0,R.jsx)(lb,{}),onClick:c,variant:`danger-ghost`,className:S7}):(0,R.jsx)(`span`,{})]}),(0,R.jsx)(T7,{row:e}),(0,R.jsx)(O7,{writes:i,cell:a})]})}function T7({row:e}){return!e.noLongerOffered&&!e.retirement?null:(0,R.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-4 pr-2 pb-2.5 pl-8 text-xs text-warning`,children:[e.noLongerOffered&&(0,R.jsxs)(`span`,{children:[`no longer offered by `,Bm[e.noLongerOffered]]}),e.retirement&&(0,R.jsxs)(`span`,{children:[`retires `,e.retirement.at,` → `,e.retirement.replacement]})]})}function E7({row:e,onCommit:t}){let[n,r]=(0,L.useState)(e.note);return(0,L.useEffect)(()=>r(e.note),[e.note]),(0,R.jsx)(`input`,{type:`text`,"aria-label":`Note for ${e.id}`,placeholder:e.isDefault?`e.g. UI/UX work, design-heavy tickets`:`Add a note`,className:q(`-ml-2 h-7 min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-2 text-sm text-text`,`transition-colors duration-(--dur-1) ease-app placeholder:text-text-disabled`,`hover:border-border focus:border-accent focus:bg-surface-inset`),value:n,onChange:e=>r(e.target.value),onBlur:()=>n.trim()!==e.note.trim()&&t(n),onKeyDown:e=>e.key===`Enter`&&e.currentTarget.blur()})}function D7({customModels:e,writes:t}){let[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(``),c=()=>{let c=fm(n,i,o);if(`error`in c){t.refuse(x7,c.error);return}t.save(x7,`models`,hd(e,[c.entry])),r(``),a(``),s(``)},l=e=>{e.key===`Enter`&&c()};return(0,R.jsxs)(`div`,{className:`pt-3`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_132px_minmax(0,1.2fr)_auto] items-center gap-2`,children:[(0,R.jsx)(fj,{mono:!0,"aria-label":`New model id`,placeholder:`Model id, e.g. claude-opus-5[1m]`,value:n,onChange:e=>r(e.target.value),onKeyDown:l}),(0,R.jsxs)(Wq,{value:i,onValueChange:a,children:[(0,R.jsx)(Jq,{"aria-label":`Runtime (required)`,className:q(Kq,`w-full`,i===``&&`text-text-tertiary`),children:(0,R.jsx)(Yq,{})}),(0,R.jsxs)(Xq,{children:[(0,R.jsx)(eJ,{value:``,children:`Runs on…`}),sd.map(e=>(0,R.jsx)(eJ,{value:e,children:sm[e]},e))]})]}),(0,R.jsx)(fj,{"aria-label":`New model note`,placeholder:`Use-case note (optional)`,value:o,onChange:e=>s(e.target.value),onKeyDown:l}),(0,R.jsx)(Y,{icon:(0,R.jsx)(ob,{}),onClick:c,children:`Add model`})]}),(0,R.jsx)(O7,{writes:t,cell:x7,className:`pt-1.5`})]})}function O7({writes:e,cell:t,className:n=`pr-2 pb-2.5 pl-8`}){return e.error?.cell===t?(0,R.jsx)(`p`,{role:`alert`,className:q(`m-0 text-xs text-danger`,n),children:e.error.message}):null}function k7({runtime:e}){let t=e===`codex`?kb:Ob;return(0,R.jsx)(`span`,{role:`img`,"aria-label":sm[e],title:sm[e],className:`inline-flex size-4 shrink-0 items-center justify-center text-icon`,children:(0,R.jsx)(t,{size:14})})}function A7({groups:e}){return(0,R.jsx)(R.Fragment,{children:e.map(e=>(0,R.jsxs)(Zq,{children:[(0,R.jsx)(Qq,{children:e.label}),e.entries.map(e=>(0,R.jsx)(eJ,{value:e.id,title:e.note,children:e.note?`${e.id} — ${e.note}`:e.id},e.id))]},e.runtime))})}var j7=[{group:`sessions`,title:`Sessions`,caption:`Interactive — you are in the terminal`},{group:`unattended`,title:`Unattended`,caption:`Burns and scripted runs`}],M7=`grid grid-cols-[minmax(0,1fr)_260px_24px] items-center gap-3`;function N7({rows:e,groups:t,defaultModel:n,projectModel:r,filter:i,writes:a}){return(0,R.jsxs)(R.Fragment,{children:[r&&(0,R.jsxs)(`p`,{className:`m-0 mt-3 flex items-center gap-2 text-xs text-text-secondary`,children:[(0,R.jsx)(BA,{tone:`warning`}),(0,R.jsxs)(`span`,{children:[`This project runs everything on `,(0,R.jsx)(`span`,{className:`font-mono`,children:r}),` — these apply to other projects.`]})]}),j7.map(({group:r,title:o,caption:s})=>{let c=e.filter(e=>e.group===r&&e7(i,vm(e.step)));return c.length===0?null:(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(`div`,{className:q(M7,y7,`mt-4`),children:[(0,R.jsxs)(`span`,{children:[o,(0,R.jsx)(`span`,{className:`ml-2 font-normal text-text-disabled`,children:s})]}),(0,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{})]}),c.map(e=>(0,R.jsx)(P7,{row:e,groups:t,defaultModel:n,writes:a},e.step))]},r)})]})}function P7({row:e,groups:t,defaultModel:n,writes:r}){let i=vm(e.step),a=e.value!==null;return(0,R.jsxs)(`div`,{className:`group border-b border-border-subtle transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,children:[(0,R.jsxs)(`div`,{className:q(M7,`min-h-12 px-2 py-1.5`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-text`,children:[e.label,r.saved===i&&(0,R.jsx)(s7,{})]}),(0,R.jsx)(`span`,{className:`truncate text-xs text-text-tertiary`,title:e.description,children:e.description})]}),(0,R.jsxs)(Wq,{value:e.value??``,onValueChange:e=>r.save(i,i,e===``?null:e),children:[(0,R.jsx)(Jq,{"aria-label":`Model for ${e.label}`,className:q(Kq,`w-full`,!a&&`text-text-tertiary`),children:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 [&>span:last-child]:truncate`,children:[(0,R.jsx)(k7,{runtime:e.effectiveRuntime}),(0,R.jsx)(Yq,{})]})}),(0,R.jsxs)(Xq,{children:[(0,R.jsxs)(eJ,{value:``,children:[`Default (`,n,`)`]}),(0,R.jsx)(A7,{groups:t})]})]}),a?(0,R.jsx)(UE,{label:`Reset ${e.label} to default`,size:`sm`,icon:(0,R.jsx)(ub,{}),onClick:()=>r.save(i,i,null),className:S7}):(0,R.jsx)(`span`,{})]}),(0,R.jsx)(O7,{writes:r,cell:i,className:`px-2 pb-2.5`})]})}var F7=1400,I7=`model`;function L7(){let e=B.useUtils(),[t,n]=(0,L.useState)(null),[r,i]=(0,L.useState)(null),a=(0,L.useRef)([]),o=(0,L.useRef)(null),s=(0,L.useRef)(void 0);(0,L.useEffect)(()=>()=>clearTimeout(s.current),[]);let c=()=>{let e=a.current.shift();if(!e){o.current=null;return}o.current=e.cell,l.mutate({key:e.key,value:e.value})},l=B.settings.update.useMutation({onSuccess:()=>{n(o.current),clearTimeout(s.current),s.current=setTimeout(()=>n(null),F7),e.settings.get.invalidate(),c()},onError:e=>{let t=o.current;t&&i({cell:t,message:e.message}),a.current=[],o.current=null}}),u=e=>i(t=>t&&t.cell===e?null:t);return{saved:t,error:r,save:(e,t,n)=>{u(e),a.current.push({cell:e,key:t,value:n}),o.current===null&&c()},refuse:(e,t)=>i({cell:e,message:t})}}var R7=[[`w-28`],[`w-32`,`w-24`,`w-28`],[`w-20`,`w-28`,`w-24`]];function z7({globals:e,scoped:t,filter:n,highlightField:r}){let i=L7();if(e.isLoading)return(0,R.jsx)(r7,{groups:R7});if(e.error)return(0,R.jsxs)(Pj,{children:[`Could not load settings: `,e.error.message]});if(!e.data)return null;let a=e.data,o=Um(a),s=qm(a),c=dm(um(a)),l=Rm(a),u=new Map(s.map(e=>[e.step,e.label]));return(0,R.jsxs)(R.Fragment,{children:[e7(n,`model`)&&(0,R.jsx)(`div`,{className:`-mt-3.5`,children:(0,R.jsx)(H7,{value:l,groups:c,writes:i,highlight:r===`model`})}),o.some(e=>e7(n,e.id))&&(0,R.jsxs)(i7,{title:`Roster`,action:(0,R.jsx)(V7,{}),description:(0,R.jsxs)(R.Fragment,{children:[`A model with a `,(0,R.jsx)(`span`,{className:`text-text-secondary`,children:`use-case note`}),` is offered to the tickets agent, which may pick it per ticket; models without a note are never picked automatically.`]}),children:[(0,R.jsx)(B7,{view:a}),(0,R.jsx)(C7,{rows:o,stepLabels:u,customModels:lm(a),filter:n,writes:i})]}),s.some(e=>e7(n,vm(e.step)))&&(0,R.jsx)(i7,{title:`Per step`,description:`Every step runs the default unless it names a model of its own.`,children:(0,R.jsx)(N7,{rows:s,groups:c,defaultModel:l,projectModel:Jm(t.data),filter:n,writes:i})})]})}function B7({view:e}){return(0,R.jsx)(`ul`,{"aria-label":`Model discovery`,className:`m-0 mt-1.5 flex list-none flex-wrap gap-x-5 gap-y-1 p-0 text-xs`,children:Km(e).map(e=>(0,R.jsxs)(`li`,{className:q(`inline-flex items-center gap-1.5`,e.failed?`text-warning`:`text-text-tertiary`),children:[(0,R.jsx)(k7,{runtime:e.runtime}),e.text]},e.runtime))})}function V7(){let e=B.useUtils(),t=B.settings.refreshModels.useMutation({onSuccess:()=>void e.settings.get.invalidate()});return(0,R.jsxs)(R.Fragment,{children:[t.error&&(0,R.jsxs)(`span`,{role:`alert`,className:`text-xs text-danger`,children:[`Refresh failed: `,t.error.message]}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),loading:t.isPending,onClick:()=>t.mutate(),children:t.isPending?`Refreshing…`:`Refresh`})]})}function H7({value:e,groups:t,writes:n,highlight:r}){let{ref:i,flash:a}=$5(r);return(0,R.jsx)(a7,{rowRef:i,flash:a,label:`Default model`,htmlFor:`settings-default-model`,description:`Runs every step that has no model of its own below — and every project that has not set one.`,aside:n.saved===I7&&(0,R.jsx)(s7,{}),control:(0,R.jsxs)(Wq,{value:e,onValueChange:e=>n.save(I7,`model`,e),children:[(0,R.jsx)(Jq,{id:`settings-default-model`,className:q(Kq,`w-full`),children:(0,R.jsx)(Yq,{})}),(0,R.jsx)(Xq,{children:(0,R.jsx)(A7,{groups:t})})]}),below:(0,R.jsx)(O7,{writes:n,cell:I7,className:``})})}function U7({projectId:e,filter:t,highlightField:n,onDismiss:r}){let i=B.useUtils(),a=B.setup.doctor.useQuery(e?{projectId:e}:void 0,{refetchOnWindowFocus:!1}),o=a.data,s=e=>o?.results.find(t=>t.id===e),c=s(`container-runtime`),l=s(`sandcastle-image`),u=G5(o?.results??[]),[d,f]=(0,L.useState)(0),p=()=>{f(e=>e+1),i.setup.doctor.cancel().then(()=>a.refetch())},m=J7(a.isLoading,d),h=e=>!t||e7(t,e),g=m?K7:`checking prerequisites…`,_=a.error?.message??(m?q7:null),v=Y5([...c?[{field:`container-runtime`,ok:c.status===`ok`}]:[],...l?[{field:`sandcastle-image`,ok:W7(l)}]:[],...u.map(e=>({field:K5(e.runtime),ok:e.probe.status===`ok`}))].map(({field:e,ok:t})=>({ok:t,reason:Y7[e].reason??Y7[e].label}))),y=e=>({field:e,label:Y7[e].label,visible:h(e),highlight:n===e}),b=o!==void 0&&v.count===null;return(0,R.jsxs)(`section`,{"aria-label":`Unattended burn prerequisites`,className:`flex flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-3 pb-3`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:q(`mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-surface-hover [&>svg]:size-4`,b?`text-success`:`text-icon`),children:b?(0,R.jsx)(sb,{}):(0,R.jsx)(xb,{})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex min-h-7 items-center gap-2 text-sm font-medium text-text`,children:a.isLoading?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(KE,{}),(0,R.jsx)(`span`,{className:`font-normal text-text-secondary`,children:g})]}):a.error?`Could not run the checks`:(0,R.jsxs)(`span`,{className:`min-w-0`,children:[v.count&&(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[v.count,` `]}),v.text]})}),!r&&(0,R.jsx)(`p`,{className:`m-0 text-xs text-pretty text-text-tertiary`,children:`A burn you walk away from runs its tickets in containers, so it needs what an interactive session never does. Fix any of these now, or leave them for later.`})]}),r&&(0,R.jsx)(Y,{variant:`ghost`,className:`shrink-0`,onClick:r,children:`Set up later`})]}),_&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5 py-2 pl-10`,children:[(0,R.jsx)(BA,{tone:`warning`}),(0,R.jsx)(`span`,{className:`min-w-0 grow text-xs text-text-secondary`,children:_}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),onClick:p,children:`Retry`})]}),o&&(0,R.jsxs)(Z7,{children:[(0,R.jsx)($7,{...y(`container-runtime`),probe:c,onRecheck:p}),(0,R.jsx)(e9,{...y(`sandcastle-image`),probe:l,runtimeOk:c?.status===`ok`,projectId:e,onDone:p}),u.map(e=>e.kind===`token`?(0,R.jsx)(o9,{...y(K5(e.runtime)),probe:e.probe,onDone:p},e.runtime):(0,R.jsx)(s9,{...y(K5(e.runtime)),row:e,onDone:p},e.runtime)),e&&(0,R.jsx)(i9,{...y(`burn-cache`),projectId:e})]})]})}function W7(e){return e.status===`ok`||e.severity===`info`}var G7=1e4,K7=`still checking — this is taking longer than usual`,q7=`The container runtime has not answered yet. A runtime that is starting up — or wedged — can leave the checks outstanding for minutes.`;function J7(e,t){let[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{if(r(!1),!e)return;let t=setTimeout(()=>r(!0),G7);return()=>clearTimeout(t)},[e,t]),n}var Y7=Object.fromEntries(J5.map(e=>[e.field,e]));function X7({field:e,label:t,visible:n=!0,highlight:r=!1,detail:i,ok:a,status:o,children:s,below:c}){let{ref:l,flash:u}=$5(r);return n?(0,R.jsxs)(`li`,{ref:l,...e?{"data-field":e}:{},className:q(`grid grid-cols-[28px_minmax(0,1fr)_auto] items-start gap-x-3 gap-y-2.5 py-3 [counter-increment:checklist]`,`border-t border-border-subtle first:border-t-0`,u&&`rounded-md outline-2 outline-offset-4 outline-accent`),children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`flex h-5 items-center justify-center text-xs text-text-tertiary tabular-nums before:content-[counter(checklist)]`}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-5 flex-wrap items-center gap-x-3 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-text`,children:t}),a?(0,R.jsx)(HA,{tone:`success`,icon:(0,R.jsx)(sb,{}),children:o??`Ready`}):(0,R.jsx)(HA,{tone:`warning`,children:o??`Needed`})]}),(0,R.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-text-tertiary`,title:i,children:i})]}),(0,R.jsx)(`div`,{className:`flex max-w-96 flex-wrap items-center justify-end gap-2`,children:s}),c]}):null}function Z7({children:e}){return(0,R.jsx)(`ol`,{className:`m-0 list-none border-t border-border-subtle p-0 [counter-reset:checklist]`,children:e})}function Q7({sessionId:e,label:t,onDone:n,onEnded:r}){return(0,R.jsxs)(`div`,{className:`col-span-full flex flex-col gap-2`,children:[(0,R.jsx)(`div`,{className:`h-70 overflow-hidden rounded-md border border-border bg-surface-inset animate-rise-in`,children:(0,R.jsx)(LJ,{label:t,children:(0,R.jsx)(c4,{sessionId:e,onEnded:r})})}),n&&(0,R.jsx)(`div`,{className:`flex justify-end`,children:(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),onClick:n,children:`Done — re-check`})})]})}function $7({probe:e,onRecheck:t,...n}){let r=B.setup.runtimeGuide.useQuery(void 0,{enabled:e?.status===`missing`,refetchOnWindowFocus:!1}),i=gx();if(!e)return null;let a=e.status===`missing`?r.data:void 0,o=a?.command??e.fix??``,s=e.status===`ok`;return(0,R.jsxs)(X7,{...n,detail:e.detail,ok:s,children:[!s&&o&&(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(c9,{command:o,onCopy:()=>{navigator.clipboard?.writeText(o),i.push(`copied`,`info`)}})}),!s&&a?.note&&(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:a.note}),!s&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),onClick:t,children:`Re-check`})]})}function e9({probe:e,runtimeOk:t,projectId:n,onDone:r,...i}){let[a,o]=(0,L.useState)(null),s=gx(),c=B.setup.imageBuildTarget.useQuery(n?{projectId:n}:void 0),l=B.setup.startTerminal.useMutation({onSuccess:({sessionId:e,notices:t})=>{o(e);for(let e of t)s.push(e)},onError:e=>s.push(e.message)});return e?(0,R.jsx)(X7,{...i,detail:e.detail,ok:W7(e),below:a&&(0,R.jsx)(Q7,{sessionId:a,label:`build-image`,onEnded:r,onDone:()=>{o(null),r()}}),children:!a&&(0,R.jsx)(n9,{probe:e,target:t9(c),runtimeOk:t,pending:l.isPending,onStart:()=>l.mutate({kind:`build-image`,...n?{projectId:n}:{}})})}):null}function t9(e){let{data:t}=e;return t?t.kind===`refused`?{kind:`refused`,reason:t.reason}:{kind:`ready`,dockerfile:t.dockerfile,tag:t.tag}:e.error?{kind:`error`,message:e.error.message}:{kind:`loading`}}function n9({probe:e,target:t,runtimeOk:n,pending:r,onStart:i}){if(e.status===`custom`)return(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:e.fix});if(t.kind===`refused`)return(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:t.reason});let a=e.status===`missing`||e.status===`not-built-yet`?`Build`:`Rebuild`,o=r?`Starting…`:t.kind===`ready`?`${a} image · ${t.tag}`:t.kind===`loading`?`${a} image · resolving…`:`${a} image`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{variant:`secondary`,size:`sm`,icon:(0,R.jsx)(bb,{}),"aria-label":`${a} image`,disabled:!n||r||t.kind!==`ready`,title:n?t.kind===`ready`?`Dockerfile: ${t.dockerfile}\nImage: ${t.tag}`:void 0:`Install a container runtime first`,onClick:i,children:o}),t.kind===`error`&&(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-warning`,children:t.message})]})}function r9({status:e,pending:t,refusal:n,onClear:r,...i}){return e?.mode===`volume`?(0,R.jsxs)(X7,{field:Y7[`burn-cache`].field,label:Y7[`burn-cache`].label,...i,ok:!0,detail:`${e.volumeName} — ${e.sizeBytes===null?`empty`:Ph(e.sizeBytes)}`,children:[(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(lb,{}),disabled:t,onClick:r,children:t?`Clearing…`:`Clear`}),n&&(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-warning`,children:n})]}):null}function i9({projectId:e,...t}){let n=B.useUtils(),[r,i]=(0,L.useState)(null),a=B.system.burnCache.status.useQuery({projectId:e},{refetchOnWindowFocus:!1}),o=B.system.burnCache.clear.useMutation({onSuccess:()=>{i(null),n.system.burnCache.status.invalidate()},onError:e=>i(e.message)});return(0,R.jsx)(r9,{...t,status:a.data,pending:o.isPending,refusal:r,onClear:()=>o.mutate({projectId:e})})}var a9={"claude-code":{mint:{kind:`setup-token`,label:`Run claude setup-token`},placeholder:`paste sk-ant-oat01-…`}};function o9({probe:e,onDone:t,...n}){let[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(null),l=gx(),u=B.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>l.push(e.message)}),d=B.setup.afkToken.useMutation({onSuccess:e=>{c(e),e.valid&&t()},onError:e=>l.push(e.message)});if(!e?.runtime)return null;let f=e.runtime,p=a9[f];return p?(0,R.jsxs)(X7,{...n,detail:e.detail,ok:e.status===`ok`,below:r&&(0,R.jsx)(Q7,{sessionId:r,label:`setup-token`}),children:[p.mint&&!r&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(mb,{}),onClick:()=>p.mint&&u.mutate({kind:p.mint.kind}),disabled:u.isPending,children:u.isPending?`Starting…`:p.mint.label}),(0,R.jsx)(fj,{"aria-label":n.label,mono:!0,className:`w-52`,value:a,onChange:e=>o(e.target.value),placeholder:p.placeholder,spellCheck:!1,autoComplete:`off`}),(0,R.jsx)(Y,{variant:`primary`,disabled:a.trim()===``||d.isPending,onClick:()=>d.mutate({token:a,runtime:f}),children:d.isPending?`Verifying…`:`Save & verify`}),s&&(0,R.jsxs)(`span`,{className:`basis-full text-right text-xs`,children:[(0,R.jsx)(HA,{tone:s.valid?`success`:`warning`,icon:s.valid?(0,R.jsx)(sb,{}):(0,R.jsx)(Vb,{}),children:s.detail}),s.fix&&(0,R.jsx)(`span`,{className:`mt-0.5 block text-text-tertiary`,children:s.fix})]})]}):null}function s9({row:e,onDone:t,...n}){let[r,i]=(0,L.useState)(null),a=gx(),o=B.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>a.push(e.message)}),s=ah[e.runtime],c=e.probe.status===`ok`;return(0,R.jsx)(X7,{...n,ok:c,status:c?`Signed in`:`Not signed in`,detail:e.probe.detail,below:r&&(0,R.jsx)(Q7,{sessionId:r,label:s.kind,onDone:()=>{i(null),t()}}),children:!c&&!r&&(0,R.jsx)(Y,{variant:`secondary`,size:`sm`,icon:(0,R.jsx)(Kb,{}),disabled:o.isPending,onClick:()=>o.mutate({kind:s.kind}),children:o.isPending?`Starting…`:`Sign in`})})}function c9({command:e,onCopy:t}){return(0,R.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-surface-inset py-0.5 pr-0.5 pl-2`,children:[(0,R.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,title:e,children:e}),(0,R.jsx)(UE,{label:`Copy`,size:`sm`,icon:(0,R.jsx)(Fb,{}),onClick:t})]})}var l9=[[`w-32`,`w-28`,`w-36`],[`w-20`,`w-24`]];function u9({globals:e,projectId:t,filter:n,highlightField:r}){return e.isLoading?(0,R.jsx)(r7,{groups:l9}):e.error?(0,R.jsxs)(Pj,{children:[`Could not load settings: `,e.error.message]}):e.data?(0,R.jsxs)(R.Fragment,{children:[J5.some(e=>e7(n,e.field))&&(0,R.jsx)(i7,{title:`Prerequisites for unattended burns`,children:(0,R.jsx)(U7,{projectId:t,filter:n,highlightField:r})}),(0,R.jsx)(n7,{title:`Width & retries`,rows:Im(e.data,`burns`),filter:n,highlightField:r})]}):null}var d9={prep:`established by preparation`,session:`established in a conversation on this machine`,human:`set by you`,build:`built by runcastle from this repo's own Dockerfile`};function f9({source:e,evidence:t,onClose:n}){let r=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())},t=e=>{let t=r.current?.parentElement;e.target instanceof Node&&t?.contains(e.target)||n()};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`mousedown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`mousedown`,t)}},[n]),(0,R.jsxs)(`div`,{ref:r,className:`absolute top-7 left-0 z-10 max-h-72 w-105 overflow-auto rounded-lg bg-surface-raised px-3.5 py-3 shadow-popover animate-pop-in`,children:[(0,R.jsxs)(`h4`,{className:`m-0 mb-2 text-xs font-medium text-text-tertiary`,children:[`Evidence · `,d9[e]]}),(0,R.jsx)(`pre`,{className:`m-0 font-mono text-xs leading-[18px] whitespace-pre-wrap text-text-secondary`,children:t})]})}var p9=[{group:`model`,title:`Model & sandbox`},{group:`commands`,title:`Commands`},{group:`chat`,title:`Project chat`}],m9=[[`w-24`,`w-32`],[`w-28`,`w-20`,`w-32`],[`w-24`]];function h9({scoped:e,projectId:t,filter:n,highlightField:r}){let i=B.project.prep.useQuery({projectId:t}),[a,o]=(0,L.useState)(null);if(e.isLoading)return(0,R.jsx)(r7,{groups:m9});if(e.error)return(0,R.jsxs)(Pj,{children:[`Could not load settings: `,e.error.message]});if(!e.data)return null;let s=i.data?.findings??[],c=new Map(s.map(e=>[e.key,e])),l=Im(e.data,`project`,s),u=e=>{let t=c.get(e.key);return a!==e.key||!t?.evidence?null:(0,R.jsx)(f9,{source:t.source,evidence:t.evidence,onClose:()=>o(null)})};return(0,R.jsx)(R.Fragment,{children:p9.map(({group:e,title:i})=>(0,R.jsx)(n7,{title:i,rows:l.filter(t=>t.group===e),projectId:t,filter:n,highlightField:r,onOpenEvidence:e=>o(t=>t===e?null:e),evidence:u},e))})}var g9={general:`How runcastle looks, where its server listens, and how sessions are sandboxed.`,models:`The default model, the roster this machine offers, and which model runs each step.`,burns:`What an unattended run needs before it starts, and how hard it tries once it does.`,project:`Values this project sets for itself. Unset fields inherit the global value, shown as ghost text.`},_9={general:h7,models:z7,burns:u9,project:h9};function v9({projectId:e,projectName:t,location:n,onClose:r}){let i=B.settings.get.useQuery(),a=B.settings.get.useQuery({projectId:e}),[o,s]=(0,L.useState)(n.page),[c,l]=(0,L.useState)(``),u=(0,L.useRef)(null),d=(0,L.useMemo)(()=>Zm(c,b9(i.data,a.data)),[c,i.data,a.data]),f={query:c,...d},p=c.trim()!==``;(0,L.useEffect)(()=>{if(!p||d.counts[o]>0)return;let e=X5.find(e=>d.counts[e.page]>0);e&&s(e.page)},[p,d,o]);let m=e=>{!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`f`||(e.preventDefault(),u.current?.focus(),u.current?.select())},h=_9[o],g=X5.find(e=>e.page===o)?.label??``,_=p&&d.matches.size===0;return(0,R.jsx)(Hj,{open:!0,onClose:r,size:`xl`,label:`Settings`,className:`overflow-hidden`,children:(0,R.jsxs)(`div`,{className:`relative grid h-[min(720px,84vh)] grid-cols-[208px_minmax(0,1fr)]`,onKeyDown:m,children:[(0,R.jsx)(Z5,{page:o,filter:f,filterRef:u,projectName:t,onFilter:l,onSelect:s}),(0,R.jsx)(`section`,{className:`grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] bg-surface`,children:(0,R.jsx)(`div`,{className:`min-h-0 overflow-x-hidden overflow-y-auto px-8 pt-9 pb-12`,children:(0,R.jsxs)(`div`,{className:`animate-rise-in`,children:[(0,R.jsxs)(`header`,{className:`mb-8`,children:[(0,R.jsx)(`h2`,{className:`m-0 text-lg font-semibold text-text`,children:g}),(0,R.jsx)(`p`,{className:`mt-1 mb-0 text-sm text-text-tertiary`,children:g9[o]})]}),(0,R.jsx)(`div`,{children:(0,R.jsx)(h,{globals:i,scoped:a,projectId:e,filter:f,...o===n.page&&n.field?{highlightField:n.field}:{}})}),_&&(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(eb,{}),title:`Nothing matches`,hint:`Try “model”, “verify” or “image”.`})]},o)})}),(0,R.jsx)(UE,{label:`Close`,kbd:`Esc`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:r,className:`absolute top-3 right-3`})]})})}var y9={id:p7,page:`general`,terms:[`Theme`,`Appearance`,`Dark`,`Light`,`System`]};function b9(e,t){let n=X5.flatMap(({page:n})=>{let r=n===`project`?t:e;return r?Xm(r,n):[]}),r=J5.map(e=>({id:e.field,page:`burns`,terms:[e.label,...e.terms]}));return[y9,...n,...r]}function x9({projectId:e,nav:t}){let n=Xg(e),{selectedFeatureId:r,projectSelected:i,preparing:a,select:o,selectView:s,selectProject:c,startPreparation:l,setCmdk:u}=n,[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(0),[h,g]=(0,L.useState)(!1),[_,v]=(0,L.useState)(0),y=()=>{g(!0),v(e=>e+1)},[b,x]=(0,L.useState)(0),S=()=>{c(),x(e=>e+1)},C=()=>x(0),[w,T]=(0,L.useState)(0),E=()=>{c(),T(e=>e+1)},D=()=>T(0),O=AF(),k=B.feature.list.useQuery({projectId:e},{refetchInterval:Ch()}),A=_x(e),j=B.project.prep.useQuery({projectId:e}),M=j.data?.prepared??!0,N=j.data?.empty??!0,P=B.feature.driveInfo.useQuery(void 0,{refetchInterval:Ch()}).data,ee=bx(P,e)?P:null,F=k.data,I=(0,L.useCallback)((e,t)=>{if(!e)return o(null);o(e,t??Kg(e,F?.find(t=>t.id===e)))},[o,F]),te=(0,L.useCallback)(e=>o(e,`chat`),[o]),[ne,re]=(0,L.useState)(!1),[ie]=(0,L.useState)(()=>wg(Dg()));(0,L.useEffect)(()=>{if(ne||!F)return;let t=Tg(ie,e);if(t?.kind===`chat`)c();else if(t?.kind===`prepare`)l();else if(t){let e=F.find(e=>e.slug===t.featureSlug);e?I(e.id,t.tab):I(eg(F)?.id??null)}else if(!r&&!i&&!a){let e=eg(F);e&&I(e.id)}else r&&!i&&!a&&s(Kg(r,F.find(e=>e.id===r)));re(!0)},[ne,F,e,ie,r,i,a,I,s,c,l]);let ae=F?.find(e=>e.id===r),oe=ae?.slug??null,se=ae?.status===`draft`?`overview`:n.featureView;Ag(ne&&!n.creating?Eg({projectId:e,preparing:a,projectSelected:i,featureSlug:oe,featureView:se}):null,t=>{if(!t||xg(t)!==e)return;let n=Tg(t,e);if(!n)o(null);else if(n.kind===`chat`)c();else if(n.kind===`prepare`)l();else{let e=F?.find(e=>e.slug===n.featureSlug);e?o(e.id,bg(n)):I(eg(F??[])?.id??null)}});let ce=()=>{c(),A.session?m(e=>e+1):A.start()};(0,L.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),u(!0)):yx(e)&&(e.preventDefault(),y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u]);let le=Ky({...n,featureCount:F?.length??0,prepared:M,empty:N}),ue=F?.find(e=>e.id===r)?.phase,de=Bg(n.inspectorPreference,n.viewedPhase??ue),fe=qy(le,de),pe=le===`feature`?()=>n.toggleInspector(de):void 0,me=le===`create`?(0,R.jsx)(`section`,{className:`relative flex min-h-0 min-w-0 flex-col`,children:(0,R.jsx)(E5,{projectId:e,onCancel:n.cancelCreate,onCreated:I})}):le===`prepare`?(0,R.jsx)(O5,{projectId:e,...n.preparing?{onClose:n.closePreparation}:{}}):le===`project`?(0,R.jsx)(S5,{projectId:e,talk:A,newChatRequest:p,onConsumeNewChatRequest:()=>m(0),inboxRequest:b,onConsumeInboxRequest:C,empty:N,onOpenPreparation:n.startPreparation,driveRequest:w,onConsumeDriveRequest:D}):le===`feature`&&r?(0,R.jsx)(LJ,{label:`feature view`,fallback:e=>(0,R.jsx)(w8,{featureId:r,error:e}),children:(0,R.jsx)(q8,{featureId:r,view:se,onViewChange:n.selectView,viewedPhase:n.viewedPhase,onViewPhase:n.viewPhase,guidance:n.guidance,driving:d,onDriveChange:f,detailsOpen:fe,onToggleDetails:()=>n.toggleInspector(de),onDeleted:()=>{n.select(null),n.selectProject()}})},`ws-${r}`):null,he=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(MF,{sidebar:(0,R.jsx)(FF,{projectId:e,nav:t,view:le,selectedFeatureId:n.selectedFeatureId,talk:A,onSelect:I,onSelectProject:n.selectProject,onNewChat:ce,onDraft:n.startDraft,onOpenPreparation:n.startPreparation,onOpenNote:y,onOpenCmdk:()=>u(!0),onOpenSettings:()=>n.openSettings(),projectDriveBranch:ee?.branch??null,onOpenProjectDrive:E,driving:d,onDriveChange:f}),rail:(0,R.jsx)(ZF,{onOpenCmdk:()=>u(!0),onNewChat:ce}),children:(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col [&>*]:min-h-0 [&>*]:flex-1`,children:me})}),(0,R.jsx)(R5,{open:n.cmdkOpen,onClose:()=>n.setCmdk(!1),features:F??[],selectedFeatureId:n.selectedFeatureId,onSelect:I,onOpenSettings:()=>n.openSettings(),onOpenPreparation:n.startPreparation,onOpenProjectChat:n.selectProject,onOpenNote:y,onToggleSidebar:O.toggleSidebar,onToggleDetails:pe,nav:t}),(0,R.jsx)(U5,{projectId:e,projectName:t.currentProject?.name??``,open:h,openRequest:_,onClose:()=>g(!1),onOpenInbox:S}),n.settings&&(0,R.jsx)(v9,{projectId:e,projectName:t.currentProject?.name??``,location:n.settings,onClose:n.closeSettings})]});return(0,R.jsx)(eI,{open:n.openSettings,children:(0,R.jsx)(Tx,{value:te,children:he})})}var S9=`${lj} h-7 w-full font-medium`,C9=`A run is in flight — it has to finish before this project can go.`;function w9({project:e,stats:t,loading:n,onOpen:r,index:i}){let a=gx(),o=B.useUtils(),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(e.name),p=B.project.rename.useMutation({onSuccess:async()=>{await o.project.list.invalidate(),c(!1)},onError:e=>a.push(e.message)}),m=B.project.close.useMutation({onSuccess:async()=>{await o.project.list.invalidate(),a.push(`removed ${e.name}`,`info`)},onError:e=>a.push(e.message)});(0,L.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]);let h=t.activeRuns>0,g=()=>{let t=d.trim();t&&t!==e.name?p.mutate({projectId:e.id,name:t}):c(!1)},_=s?(0,R.jsx)(`input`,{className:S9,value:d,"aria-label":`Project name`,maxLength:80,autoFocus:!0,onChange:e=>f(e.target.value),onKeyDown:t=>{t.stopPropagation(),t.key===`Enter`&&g(),t.key===`Escape`&&(f(e.name),c(!1))},onBlur:g}):(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e.name});return l?(0,R.jsx)(rj,{className:`animate-fade-in`,wrap:!0,title:(0,R.jsxs)(`span`,{className:`text-text-secondary`,children:[`Remove `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:e.name}),`? The repo on disk is untouched.`,h&&(0,R.jsx)(`span`,{className:`block text-xs text-text-tertiary`,children:C9})]}),control:(0,R.jsxs)(`span`,{className:`flex shrink-0 gap-2 pr-3`,children:[(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>u(!1),children:`Cancel`}),(0,R.jsx)(Y,{size:`sm`,variant:`danger`,icon:(0,R.jsx)(lb,{}),disabled:h||m.isPending,onClick:()=>m.mutate({projectId:e.id}),children:m.isPending?`Removing…`:`Remove`})]})}):(0,R.jsx)(rj,{index:i,leading:(0,R.jsx)(yb,{}),title:_,description:(0,R.jsx)(`span`,{className:`block truncate text-left font-mono`,dir:`rtl`,title:e.repoPath,children:(0,R.jsx)(`bdi`,{children:e.repoPath})}),meta:n?`Loading…`:(0,R.jsx)(oj,{className:`flex-nowrap`,items:[{strong:t.total,text:t.total===1?`feature`:`features`},t.activeRuns>0&&{tone:`live`,strong:t.activeRuns,text:`running`},t.needsYou>0&&{tone:`warning`,strong:t.needsYou,text:`needs you`}]}),onClick:s?void 0:r,tooltip:`Open ${e.name}`,actionsOverlay:!0,actions:!s&&(0,R.jsx)(yF,{label:`${e.name} actions`,actions:[{key:`rename`,label:`Rename`,onSelect:()=>{f(e.name),c(!0)}},{key:`remove`,label:`Remove from list`,danger:!0,onSelect:()=>u(!0)}]})})}function T9({nav:e}){let t=e.projects??[],n=Ch(),r=B.useQueries(e=>t.map(t=>e.feature.list({projectId:t.id},{refetchInterval:n}))),i=t.map((e,t)=>cg(r[t]?.data??[])),a=i.reduce((e,t)=>e+t.activeRuns,0),o=i.reduce((e,t)=>e+t.needsYou,0);return(0,R.jsx)(MF,{sidebar:(0,R.jsx)(E9,{nav:e}),children:(0,R.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(_j,{crumbs:[{label:`Projects`,icon:(0,R.jsx)(zb,{})}]}),(0,R.jsxs)(yj,{routeKey:`portfolio`,children:[(0,R.jsx)(bj,{title:`Projects`,meta:[{strong:t.length,text:t.length===1?`project open`:`projects open`},a>0&&{tone:`live`,strong:a,text:`running`},o>0&&{tone:`warning`,strong:o,text:o===1?`needs you`:`need you`}],actions:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(ob,{}),onClick:e.showOpen,children:`Open a project`})}),(0,R.jsx)(ij,{divided:!0,label:`Open projects`,className:`mt-8`,children:t.map((t,n)=>(0,R.jsx)(w9,{index:n,project:t,stats:i[n],loading:r[n]?.data===void 0,onOpen:()=>e.enterProject(t.id)},t.id))})]})]})})}function E9({nav:e}){let t=bh(),n=KM();return(0,R.jsxs)(`nav`,{"aria-label":`Projects`,className:`flex h-full min-h-0 flex-col p-2`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-0.5`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:(0,R.jsx)(CF,{nav:e})}),(0,R.jsx)(jF,{})]}),(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-px`,children:(0,R.jsx)(nj,{icon:(0,R.jsx)(zb,{}),label:`All projects`,meta:e.projects?.length,active:!0})}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsx)(YF,{health:t===`live`?`ok`:t===`connecting`?`connecting`:`reconnecting`,origin:typeof window>`u`?`this machine`:window.location.origin,sandbox:_M,notify:null,theme:n.resolved,onToggleTheme:n.toggle})]})}var D9=4;function O9({crumbs:e,value:t,onNavigate:n,onEnterPath:r,placeholder:i}){let[a,o]=(0,L.useState)(null),s=a!==null,c=e.length>D9,l=c?e.slice(-3):e;return s?(0,R.jsx)(`input`,{className:`${lj} flex-1 font-mono text-xs`,"aria-label":`Path`,spellCheck:!1,autoComplete:`off`,autoFocus:!0,value:a,placeholder:i,onChange:e=>o(e.target.value),onBlur:()=>o(null),onKeyDown:e=>{e.key===`Enter`&&(r(a.trim()),o(null)),e.key===`Escape`&&(e.stopPropagation(),o(null))}}):(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 cursor-text items-center gap-0.5 truncate`,onClick:()=>o(t),role:`group`,"aria-label":`Current path`,children:[c&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(k9,{crumb:e[0],onNavigate:n}),(0,R.jsx)(fb,{size:12,className:`shrink-0 text-text-disabled`}),(0,R.jsx)(`span`,{className:`shrink-0 px-1 text-sm text-text-tertiary`,title:e[e.length-1].path,children:`…`})]}),l.map((e,t)=>(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:[(t>0||c)&&(0,R.jsx)(fb,{size:12,className:`shrink-0 text-text-disabled`}),(0,R.jsx)(k9,{crumb:e,onNavigate:n})]},e.path)),(0,R.jsx)(`button`,{type:`button`,className:`${qE} ml-1 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-icon transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,"aria-label":`Edit path`,title:`Edit path`,onClick:()=>o(t),children:(0,R.jsx)(_b,{size:14})})]})}function k9({crumb:e,onNavigate:t}){return(0,R.jsx)(`button`,{type:`button`,className:`${qE} shrink-0 rounded-sm px-1 py-0.5 cursor-pointer font-mono text-xs text-text-secondary transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,onClick:n=>{n.stopPropagation(),t(e.path)},children:e.name})}function A9({initialPath:e,onPick:t,onCancel:n}){let r=e?.trim()||void 0,[i,a]=(0,L.useState)(r),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(r??null),[u,d]=(0,L.useState)(null),f=B.project.roots.useQuery(),p=B.project.browse.useQuery({dir:i,showHidden:o},{placeholderData:e=>e,retry:!1}),m=p.data,h=m?.dir??i,g=e=>{l(null),d(null),a(e)},_=e=>{l(e||null),d(null),a(e||void 0)},v=c!==null&&p.isError?pg(i,p.error.message):null,y=v!==null&&v.dir!==i,b=v?.dir,x=p.error?.message;(0,L.useEffect)(()=>{y&&(i===c&&x&&d(gg(x)),a(b))},[y,b,i,c,x]);let S=e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=[...e.currentTarget.querySelectorAll(`[data-dir-row] button`)];if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n===-1?0:n-1)]?.focus()};return(0,R.jsxs)(Hj,{open:!0,onClose:n,size:`lg`,labelledBy:`dir-picker-title`,className:`flex h-[min(620px,76vh)] flex-col overflow-hidden`,children:[(0,R.jsx)(Uj,{id:`dir-picker-title`,title:`Choose a repository`,description:`Browse this machine for a git repository to open.`,onClose:n}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-y border-border-subtle px-3 py-2`,children:[(0,R.jsx)(UE,{label:`Up one level`,icon:(0,R.jsx)(Wb,{}),onClick:()=>m?.parent&&g(m.parent),disabled:!m?.parent}),(0,R.jsx)(O9,{crumbs:m?.crumbs??[],value:c??h??``,onNavigate:g,onEnterPath:_,placeholder:hM()}),(0,R.jsx)(Dj,{label:`Hidden`,checked:o,onChange:s,className:`shrink-0 px-2`})]}),u&&(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border-subtle px-4 py-3`,children:(0,R.jsx)(zj,{message:u.message,path:u.path,hint:`Showing the closest folder that could be listed. Edit the path to try again.`})}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex w-44 shrink-0 flex-col gap-0.5 overflow-y-auto border-r border-border-subtle p-2`,onKeyDown:S,children:[(0,R.jsx)($A,{className:`px-2.5`,children:`Locations`}),(f.data??[]).map(e=>(0,R.jsx)(`div`,{"data-dir-row":``,children:(0,R.jsx)(nj,{label:(0,R.jsx)(`span`,{className:`font-mono text-xs`,children:e.label}),title:e.path,icon:e.label===`~`?(0,R.jsx)(zb,{}):(0,R.jsx)(yb,{}),active:h===e.path,onClick:()=>g(e.path)})},e.path))]}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto p-2`,onKeyDown:S,children:[y||p.isLoading?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-2 text-sm text-text-tertiary`,children:[(0,R.jsx)(KE,{}),` Loading…`]}):p.isError?(0,R.jsx)(`div`,{className:`p-2`,children:(0,R.jsx)(zj,{...gg(p.error.message)})}):(m?.entries.length??0)===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(yb,{}),title:`No subfolders here`,hint:o?void 0:`Hidden folders, junctions and node_modules are filtered.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5 animate-rise-in`,role:`list`,children:(m?.entries??[]).map(e=>(0,R.jsx)(`div`,{role:`listitem`,"data-dir-row":``,children:(0,R.jsx)(nj,{onDoubleClick:()=>e.isRepo&&t(e.path),label:e.name,title:e.path,icon:e.isRepo?(0,R.jsx)(rb,{}):(0,R.jsx)(yb,{}),onClick:()=>g(e.path),className:e.isRepo?`text-text`:void 0,meta:e.isRepo?(0,R.jsx)(`span`,{className:`text-text-secondary`,children:`git`}):e.isSymlink?`link`:void 0})},e.path))},h),m?.truncated&&(0,R.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-xs text-text-tertiary`,children:`Listing truncated — this folder is very large.`})]})]}),(0,R.jsxs)(Gj,{className:`border-t border-border-subtle pt-3 pb-3`,start:(0,R.jsx)(`div`,{className:`min-w-0 truncate text-left font-mono text-xs`,dir:`rtl`,title:h,children:(0,R.jsx)(`bdi`,{children:h??`—`})}),children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(yb,{}),onClick:()=>h&&t(h),disabled:!h||p.isError,children:`Open this folder`})]})]})}function j9({rail:e,stepKey:t,direction:n=`forward`,onKeyDown:r,children:i}){return(0,R.jsx)(`div`,{className:`flex min-h-full`,onKeyDown:r,children:(0,R.jsxs)(`div`,{className:q(`m-auto grid w-full gap-12 px-8 py-12`,e?`max-w-[860px] grid-cols-[176px_minmax(0,1fr)]`:`max-w-[560px]`),children:[e&&(0,R.jsx)(`div`,{className:`pt-1`,children:e}),(0,R.jsx)(`div`,{className:q(`min-w-0`,n===`forward`?`animate-slide-in-right`:`animate-rise-in`),children:i},t)]})})}function M9({title:e,children:t}){return(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`h1`,{className:`m-0 text-xl font-semibold tracking-tight text-pretty text-text`,children:e}),(0,R.jsx)(`p`,{className:`mt-2 mb-0 text-base text-pretty text-text-secondary`,children:t})]})}function N9({onBack:e,note:t,children:n}){return(0,R.jsxs)(`footer`,{className:`mt-10 border-t border-border-subtle pt-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e&&(0,R.jsx)(Y,{variant:`ghost`,icon:(0,R.jsx)(Ub,{}),onClick:e,children:`Back`}),(0,R.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]}),t&&(0,R.jsx)(`p`,{className:`mt-2 mb-0 text-right text-xs text-text-tertiary`,children:t})]})}function P9({firstRun:e,rail:t,variant:n=`screen`,onOpened:r,onCancel:i}){let[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(!1),p=gx(),m=B.useUtils(),h=B.project.open.useMutation({onSuccess:async e=>{await m.project.list.invalidate(),p.push(`opened ${e.name}`,`info`),r(e.id)},onError:()=>void 0}),g=B.project.initRepo.useMutation({onSuccess:({repoPath:e})=>{u(e),h.mutate({repoPath:e})},onError:()=>void 0}),_=()=>{h.reset(),g.reset(),f(!1)},v=e=>{let t=(e??a).trim();if(t){if(_(),!gM(t)){f(!0);return}u(t),h.mutate({repoPath:t})}},y=()=>{_(),c(!0)},b=h.isPending||g.isPending,x=g.error??h.error,S=d?{message:`Enter an absolute path`,hint:`A path from the root of this machine, like ${hM()}.`,path:null}:x?_g(x.message,l):null,C=e=>{o(e),c(!1),v(e)},w=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:q(`flex items-center gap-2`,n===`screen`&&`mt-8`),children:[(0,R.jsx)(fj,{id:`open-repo-path`,size:`lg`,mono:!0,icon:(0,R.jsx)(yb,{}),className:`flex-1`,value:a,onChange:e=>o(e.target.value),placeholder:hM(),"aria-label":`Repository path`,autoFocus:!0,spellCheck:!1,invalid:!!S,"aria-describedby":S?`open-repo-error`:`open-repo-hint`,onKeyDown:e=>{e.key===`Enter`&&v()}}),(0,R.jsx)(Y,{size:`lg`,icon:(0,R.jsx)(eb,{}),onClick:y,disabled:b,children:`Browse…`}),(0,R.jsx)(Y,{variant:`primary`,size:`lg`,icon:(0,R.jsx)(Cb,{}),loading:h.isPending,onClick:()=>v(),disabled:b||a.trim()===``,children:`Open`})]}),S?(0,R.jsx)(`div`,{className:`mt-3 animate-rise-in`,children:(0,R.jsx)(zj,{...S,id:`open-repo-error`,action:S.offer===`init-repo`?(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(rb,{}),loading:g.isPending,onClick:()=>g.mutate({repoPath:l}),disabled:b,children:`Initialize repository`}):void 0})}):(0,R.jsx)(`p`,{id:`open-repo-hint`,className:`mt-2.5 mb-0 text-xs text-text-tertiary`,children:`Paste an absolute path, or browse for one. The default branch is detected when the project opens.`})]}),T=(0,R.jsx)(R.Fragment,{children:s&&(0,R.jsx)(A9,{initialPath:a,onPick:C,onCancel:()=>c(!1)})});return n===`dialog`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{title:`Open a project`,description:`Point runcastle at a local git repository — every feature runs its pipeline against it.`,onClose:b?void 0:i}),(0,R.jsx)(Wj,{className:`pt-1`,children:w}),T]}):(0,R.jsxs)(j9,{rail:t,stepKey:`project`,onKeyDown:t=>{t.key===`Escape`&&!e&&!s&&i()},children:[!t&&(0,R.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs text-text-tertiary`,children:[(0,R.jsx)(lx,{size:14}),e?`Welcome to runcastle`:`Your projects`]}),(0,R.jsx)(M9,{title:e?`Open your first project`:`Open a project`,children:`Point runcastle at a local git repository — every feature runs its pipeline against it.`}),w,!e&&(0,R.jsx)(`footer`,{className:`mt-10 flex items-center border-t border-border-subtle pt-5`,children:(0,R.jsx)(Y,{variant:`ghost`,icon:(0,R.jsx)(Ub,{}),onClick:i,disabled:b,children:`Cancel`})}),T]})}function F9({onBack:e,onNext:t}){let[n,r]=(0,L.useState)(!1);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(M9,{title:`Run burns unattended?`,children:vv}),n&&(0,R.jsx)(`div`,{className:`mt-8 animate-rise-in`,children:(0,R.jsx)(U7,{onDismiss:t})}),(0,R.jsx)(N9,{onBack:e,children:!n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{variant:`ghost`,icon:(0,R.jsx)(xb,{}),onClick:()=>r(!0),children:`Set up now`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Cb,{}),onClick:t,children:`Skip for now`})]})})]})}function I9({onBack:e,onNext:t}){let[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(``),o=gx(),s=B.useUtils(),c=B.setup.gitIdentity.useMutation({onSuccess:async()=>{await s.setup.doctor.invalidate(),t()},onError:e=>o.push(e.message)}),l=n.trim()!==``&&i.includes(`@`),u=()=>l&&c.mutate({name:n.trim(),email:i.trim()}),d=e=>e.key===`Enter`&&u();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(M9,{title:`Set your git identity`,children:[`runcastle commits documentation and merges on your behalf, so it needs a name and email. This writes to `,(0,R.jsx)(`code`,{className:`font-mono text-sm text-text`,children:`git config --global`}),`.`]}),(0,R.jsxs)(`div`,{className:`mt-8 flex max-w-sm flex-col gap-4`,children:[(0,R.jsx)(hj,{label:`Name`,children:(0,R.jsx)(fj,{id:`wiz-name`,size:`lg`,value:n,onChange:e=>r(e.target.value),placeholder:`Ada Lovelace`,autoFocus:!0,spellCheck:!1,onKeyDown:d})}),(0,R.jsx)(hj,{label:`Email`,children:(0,R.jsx)(fj,{id:`wiz-email`,size:`lg`,type:`email`,value:i,onChange:e=>a(e.target.value),placeholder:`ada@example.com`,spellCheck:!1,onKeyDown:d})})]}),(0,R.jsx)(N9,{onBack:e,children:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Cb,{}),loading:c.isPending,onClick:u,disabled:!l,children:`Continue`})})]})}function L9({onNext:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(lx,{size:32,variant:`solid`,className:`mb-6`}),(0,R.jsx)(M9,{title:`Your coding agent, driven through a pipeline`,children:`Describe a feature and runcastle runs the agent sessions that carry it from idea to merged, stopping at each gate until you say go.`}),(0,R.jsx)(`ol`,{className:`m-0 mt-8 flex list-none flex-col p-0`,children:Kv.map((e,t)=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[16px_96px_minmax(0,1fr)] items-center gap-3 border-b border-border-subtle py-2.5 text-sm last:border-b-0 animate-rise-in`,style:{animationDelay:`${120+t*40}ms`},children:[(0,R.jsx)(sx,{phase:e,size:16,label:``}),(0,R.jsx)(`span`,{className:`font-medium text-text`,children:ix[e]}),(0,R.jsx)(`span`,{className:`text-text-tertiary`,children:Jv[e]})]},e))}),(0,R.jsx)(N9,{children:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Cb,{}),onClick:e,autoFocus:!0,children:`Set up runcastle`})})]})}function R9({runtimes:e,onBack:t,onNext:n}){let r=sh(e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(M9,{title:`Connect a coding agent`,children:`runcastle drives whichever agent you have — sign in to one or both. The ones you connect here are the ones whose models you can pick later.`}),(0,R.jsx)(`div`,{className:`mt-8`,children:(0,R.jsx)(Z7,{children:e.map(e=>(0,R.jsx)(z9,{runtime:e},e.runtime))})}),(0,R.jsx)(N9,{onBack:t,note:r.length===0&&`Connect at least one agent to continue — runcastle has nothing to run without one.`,children:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Cb,{}),onClick:n,disabled:r.length===0,children:`Continue`})})]})}function z9({runtime:e}){let[t,n]=(0,L.useState)(null),r=gx(),i=B.useUtils(),a=B.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>n(e),onError:e=>r.push(e.message)}),o=ah[e.runtime],s=e.talkReady?`Ready`:e.installed?`Not signed in`:`Not installed`;return(0,R.jsxs)(X7,{label:e.label,status:s,detail:e.detail,ok:e.talkReady,below:t&&(0,R.jsx)(Q7,{sessionId:t,label:o.kind,onDone:()=>{n(null),i.setup.doctor.invalidate()}}),children:[e.installFix&&(0,R.jsx)(c9,{command:e.installFix,onCopy:()=>{navigator.clipboard?.writeText(e.installFix??``),r.push(`copied`,`info`)}}),e.installed&&!e.talkReady&&!t&&(0,R.jsxs)(Y,{size:`sm`,icon:(0,R.jsx)(mb,{}),loading:a.isPending,onClick:()=>a.mutate({kind:o.kind}),children:[`Run `,o.command]}),e.talkReady&&!e.afkReady&&(0,R.jsxs)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:[`Signed in for sessions you watch. Unattended burns on `,e.label,` also need its key — the next step sets that up.`]})]})}var B9={passed:`shipped`,done:`shipped`,current:`review`,todo:`draft`},V9={passed:`text-text-secondary`,done:`text-text-secondary`,current:`bg-surface-selected font-medium text-text`,todo:`text-text-tertiary`};function H9({steps:e}){return(0,R.jsxs)(`nav`,{"aria-label":`Setup`,className:`flex flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 text-sm font-medium text-text`,children:[(0,R.jsx)(lx,{size:16}),`Set up runcastle`]}),(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,"aria-label":`Setup progress`,children:e.map(e=>(0,R.jsxs)(`li`,{"data-state":e.state,"aria-current":e.state===`current`?`step`:void 0,className:q(`flex flex-col rounded-md px-2.5 py-1.5 text-sm transition-colors duration-(--dur-2) ease-app`,V9[e.state]),children:[(0,R.jsxs)(`span`,{className:`flex min-h-5 items-center gap-2`,children:[(0,R.jsx)(sx,{phase:B9[e.state],size:14,label:``}),e.label]}),e.detected&&(0,R.jsx)(`span`,{className:`mt-0.5 pl-5.5 text-xs font-normal text-pretty text-text-tertiary`,children:e.detected})]},e.key))})]})}function U9({onOpened:e,onCancel:t}){let n=B.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),r=n.data?.results.find(e=>e.id===`git-identity`),i=oh(n.data?.results??[]),[a,o]=(0,L.useState)(`intro`),[s,c]=(0,L.useState)(`forward`),l=(e,t)=>{c(t),o(e)},u=B.setup.seedModelDefaults.useMutation(),d=()=>{u.mutate({runtimes:sh(i)}),l(`project`,`forward`)};if(n.isLoading)return(0,R.jsx)(j9,{children:(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-text-tertiary`,children:[(0,R.jsx)(KE,{}),` Preparing setup…`]})});if(a===`project`)return(0,R.jsx)(P9,{firstRun:!0,rail:(0,R.jsx)(H9,{steps:uh(`project`,r)}),onOpened:e,onCancel:t});if(a===`intro`)return(0,R.jsx)(j9,{stepKey:`intro`,direction:s,children:(0,R.jsx)(L9,{onNext:()=>l(nh(r),`forward`)})});let f=()=>{let e=rh(a);e===`project`||e===void 0?d():l(e,`forward`)},p=()=>l(ih(a,r)??`intro`,`back`);return(0,R.jsxs)(j9,{rail:(0,R.jsx)(H9,{steps:uh(a,r)}),stepKey:a,direction:s,children:[a===`identity`&&(0,R.jsx)(I9,{onBack:p,onNext:f}),a===`runtimes`&&(0,R.jsx)(R9,{runtimes:i,onBack:p,onNext:f}),a===`afk`&&(0,R.jsx)(F9,{onBack:p,onNext:f})]})}var W9=`runcastle.update.dismissed`;function G9(e,t){return e.updateAvailable&&e.latest!==null&&e.latest!==t}function K9({tone:e=`neutral`,icon:t,children:n,action:r,onDismiss:i,dismissLabel:a=`Dismiss`}){return(0,R.jsxs)(`div`,{role:`status`,className:q(`flex h-10 shrink-0 animate-fade-in items-center gap-2.5 overflow-hidden border-b border-border-subtle pr-2 pl-4 text-sm`,e===`danger`?`bg-danger-subtle`:`bg-surface`),children:[(0,R.jsx)(`span`,{className:q(`inline-flex shrink-0 [&>svg]:size-4`,e===`danger`?`text-danger`:`text-accent`),children:t}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 truncate text-text-secondary`,children:n}),r,i&&(0,R.jsx)(UE,{size:`sm`,label:a,icon:(0,R.jsx)(cb,{}),onClick:i})]})}function q9(){let e=gx(),t=B.system.checkUpdate.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),[n,r]=(0,L.useState)(()=>{try{return localStorage.getItem(W9)}catch{return null}}),i=t.data;return!i||!i.latest||!G9(i,n)?null:(0,R.jsxs)(K9,{icon:(0,R.jsx)(Cb,{}),onDismiss:()=>{try{localStorage.setItem(W9,i.latest)}catch{}r(i.latest)},dismissLabel:`Dismiss update notice`,action:(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(Fb,{}),onClick:()=>navigator.clipboard.writeText(i.command).then(()=>e.push(`Update command copied`,`info`),()=>e.push(`Copy failed`)),children:`Copy command`}),children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-text`,children:[`runcastle `,i.latest,` is available`]}),(0,R.jsxs)(`span`,{className:`shrink-0 text-text-tertiary`,children:[`you're on `,i.current]}),(0,R.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-text-tertiary select-all`,children:i.command})]})}function J9({error:e,onRecheck:t}){return e?(0,R.jsxs)(K9,{tone:`danger`,icon:(0,R.jsx)(Vb,{}),action:(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(Gb,{}),onClick:t,children:`Re-run checks`}),children:[(0,R.jsx)(`span`,{className:`shrink-0 font-medium text-text`,children:`Setup checks could not run`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,title:e,children:e})]}):null}function Y9(){let e=Pg(),t,n=null;return e.loading||e.projects===void 0?t=(0,R.jsx)(MF,{children:(0,R.jsx)(yj,{children:(0,R.jsx)(Z9,{})})}):e.view===`setup`?t=(0,R.jsx)(MF,{children:(0,R.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:(0,R.jsx)(U9,{onOpened:e.enterProject,onCancel:e.cancelOpen})})}):e.view===`open`&&e.projects.length>0?(t=e.currentProjectId?(0,R.jsx)(x9,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,R.jsx)(T9,{nav:e}),n=(0,R.jsx)(Hj,{open:!0,onClose:e.cancelOpen,size:`md`,label:`Open a project`,children:(0,R.jsx)(P9,{variant:`dialog`,firstRun:!1,onOpened:e.enterProject,onCancel:e.cancelOpen})})):t=e.view===`open`?(0,R.jsx)(MF,{children:(0,R.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:(0,R.jsx)(P9,{firstRun:e.projects.length===0,onOpened:e.enterProject,onCancel:e.cancelOpen})})}):e.view===`project`&&e.currentProjectId?(0,R.jsx)(x9,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,R.jsx)(T9,{nav:e}),(0,R.jsx)(kF,{notices:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(q9,{}),(0,R.jsx)(J9,{error:e.doctorError,onRecheck:e.recheckDoctor})]}),children:(0,R.jsxs)(`div`,{className:`h-full bg-canvas`,children:[t,n]})})}var X9=[{name:`w-40`,path:`w-56`},{name:`w-28`,path:`w-44`},{name:`w-48`,path:`w-64`}];function Z9(){return(0,R.jsxs)(Oj,{label:`Loading projects…`,children:[(0,R.jsx)(`div`,{className:`flex h-7 items-center`,"data-skeleton":`title`,children:(0,R.jsx)(kj,{className:`h-5 w-32`})}),(0,R.jsx)(`div`,{className:`mt-2 flex h-5 items-center`,children:(0,R.jsx)(kj,{className:`h-2.5 w-28`})}),(0,R.jsx)(`div`,{className:`mt-8 flex flex-col`,children:X9.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-border-subtle px-3 py-2 last:border-b-0`,"data-skeleton":`project-row`,children:[(0,R.jsx)(kj,{className:`mt-0.5 size-4 self-start`}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`div`,{className:`flex h-5 items-center`,children:(0,R.jsx)(kj,{className:q(`h-3`,e.name)})}),(0,R.jsx)(`div`,{className:`flex h-4 items-center`,"data-skeleton":`repo-path`,children:(0,R.jsx)(kj,{className:q(`h-2.5`,e.path)})})]}),(0,R.jsx)(kj,{className:`h-2.5 w-16`})]},t))})]})}function Q9(){return Dh(),(0,R.jsx)(Y9,{})}function See(e){return e instanceof Error&&e.message?e.message:typeof e==`string`&&e!==``?e:`something went wrong`}function Cee(e,t){return typeof t.options.onError==`function`?null:See(e)}VM();function wee(){let[e]=(0,L.useState)(()=>new Ve({mutationCache:new Pe({onError:(e,t,n,r)=>{let i=Cee(e,r);i&&mx(i)}}),defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}}})),[t]=(0,L.useState)(()=>B.createClient({links:li(`/api/trpc`)}));return(0,R.jsx)(B.Provider,{client:t,queryClient:e,children:(0,R.jsx)(Je,{client:e,children:(0,R.jsx)(AE,{children:(0,R.jsx)(hx,{children:(0,R.jsx)(Q9,{})})})})})}var $9=document.getElementById(`root`);if(!$9)throw Error(`#root not found`);(0,Tt.createRoot)($9).render((0,R.jsx)(L.StrictMode,{children:(0,R.jsx)(wee,{})}));
|
|
188
|
+
`)){let e=t.trim();if(e!==``)return e}return``}function x6(e,t){return e.length>t?`${e.slice(0,t-1).trimEnd()}…`:e}function S6(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.name!=`string`||t.name===``?null:{name:t.name,args:typeof t.args==`string`?t.args:``}}function C6(e){return e.endsWith(`.tool`)}function w6(e){let t=e.replace(/[._]+/g,` `).trim();return t===``?``:`${t[0].toUpperCase()}${t.slice(1)}`}function T6(e,t){if(!t.startsWith(e))return null;let n=t.slice(e.length).replace(/^[\s:;,—–-]+/,``).trim().replace(/^\((.*)\)$/s,`$1`).trim(),r=w6(e);return n===``?r:`${r} — ${n}`}function E6(e){return typeof e==`object`&&e?e:null}function D6(e){return typeof e==`string`&&e!==``?e:null}function O6(e){if(e.type!==`session.self_plan_ended`)return null;let t=E6(e.data)?.complete;return typeof t==`boolean`?t:null}var k6={"session.self_plan_ended":`self-planning run`};function A6(e){return k6[e]??e.replace(/_/g,` `).replace(`.`,` · `)}function j6(e){let t=O6(e);if(t!==null)return t?`Planned without you — the plan is finished`:`Planning without you stopped before the plan was complete`;if(e.type!==`feature.created`)return null;let n=E6(e.data),r=D6(n?.branch);if(!n||!r)return null;if(n.draft===!0)return`Feature created as a draft — ${r} is not cut yet`;if(n.branchReady!==!0)return`Feature created — branch ${r} is still being cut`;let i=D6(n.baseBranch);return i?`Feature created on branch ${r}, from ${i}`:`Feature created on branch ${r}`}function M6(e){if(C6(e.type)){let t=S6(e.data);if(!t){let t=b6(e.message);return{summary:x6(t,_6)||w6(e.type),detail:e.message.trim()===t?null:e.message.trim()}}let n=x6(b6(t.args),v6);return{summary:n?`${t.name} — ${n}`:`${t.name}`,detail:t.args.trim()===``?null:t.args.trim()}}let t=y6(e.message),n=j6(e)??T6(e.type,t)??t,r=x6(b6(n),_6),i=n===r?null:n;return{summary:r||w6(e.type),detail:i}}function N6(e){return e===`lap.started`}function P6(e){if(e.type!==`run.finished`||typeof e.data!=`object`||e.data===null)return null;let t=e.data.status;return t===`succeeded`||t===`failed`||t===`cancelled`?t:null}function F6(e){let t=P6(e);if(t)return t===`succeeded`?`ok`:`error`;let n=O6(e);if(n!==null)return n?`ok`:`error`;let r=e.type;return r===`merge.conflict.resolved`?`ok`:r===`merge.conflict.resolving`?`active`:/(error|fail|conflict|cancel|stopped|timeout)/i.test(r)?`error`:/(done|succeed|finished|shipped|merged)/i.test(r)?`ok`:/(start|burn|launch|advance|running|retry|resum)/i.test(r)?`active`:`info`}function I6(e){if(typeof e.data!=`object`||e.data===null)return!1;let t=e.data;return t.oversized===!0||t.warning===!0}var L6={error:`danger`,ok:`success`,active:`neutral`,info:`neutral`};function R6({events:e}){let t=e.some(I6);return(0,R.jsxs)(Rj,{defaultOpen:t,title:`Run timeline`,icon:(0,R.jsx)(vb,{}),aside:(0,R.jsx)(`span`,{className:`tabular-nums`,children:e.length}),children:[e.length===0&&(0,R.jsx)(Pj,{children:`Waiting for events…`}),(0,R.jsx)(`ol`,{className:`@container m-0 flex max-h-96 list-none flex-col overflow-y-auto p-0`,children:e.map(e=>{let t=I6(e);return(0,R.jsxs)(`li`,{className:`flex min-h-7 items-start gap-3 py-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`w-20 shrink-0 pt-px text-xs whitespace-nowrap text-text-tertiary tabular-nums`,children:Oh(e.ts)}),(0,R.jsx)(`span`,{className:`inline-flex h-5 w-2 shrink-0 items-center justify-center`,children:(0,R.jsx)(BA,{tone:t?`warning`:L6[F6(e)]??`neutral`})}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1`,t?`break-words text-warning`:`truncate text-text-secondary`),children:t?(0,R.jsx)(rI,{text:e.message}):e.message}),(0,R.jsx)(`span`,{className:`hidden w-40 shrink-0 truncate pt-px text-right font-mono text-xs text-text-tertiary @xl:block`,children:e.type})]},e.id)})})]},t?`warned`:`quiet`)}function z6({gates:e}){return e.length===0?null:(0,R.jsxs)(`section`,{className:`mb-6 flex flex-col gap-2`,role:`alert`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(HA,{tone:`warning`,icon:(0,R.jsx)(Vb,{}),size:`sm`,strong:!0,children:`Verification unavailable`}),(0,R.jsx)(`p`,{className:`m-0 pl-5.5 text-sm text-text-secondary`,children:`The sandbox lacked a command or runtime. Ticket results were kept; these gates still need checking.`})]}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0 pl-5.5`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-0.5 border-t border-border-subtle py-2 first:border-t-0`,children:[(0,R.jsx)(`code`,{className:`font-mono text-xs text-text`,children:e.command}),(0,R.jsx)(`span`,{className:`font-mono text-xs break-words text-text-tertiary`,children:e.error})]},e.command))})]})}function B6({featureId:e,runId:t,readonly:n=!1}){let r=Ch(),i=gx(),a=B.useUtils(),[o,s]=(0,L.useState)(null),c=!!o&&o!==t,l=o??t,u=n||c,d=B.feature.get.useQuery({id:e},{refetchInterval:r}),f=B.run.get.useQuery({runId:l},{refetchInterval:!c&&r,enabled:!!l}),p=B.run.listByFeature.useQuery({featureId:e},{refetchInterval:r}),m=QF(e),h=d.data?.feature.projectId,g=B.settings.get.useQuery({projectId:h},{enabled:!!h}),_=B.findings.listByFeature.useQuery({featureId:e}),v={onSuccess:()=>a.feature.get.invalidate({id:e}),onError:e=>i.push(e.message)},y=B.ticket.retry.useMutation(v),b=B.ticket.edit.useMutation(v),x=B.ticket.stop.useMutation(v),S=B.ticket.cancel.useMutation(v),C=Ex(e),w=B.feature.launchSession.useMutation({...v,onSuccess:()=>{v.onSuccess(),C()}}),T=B.run.cancel.useMutation(v),E=y.isPending||b.isPending||x.isPending||S.isPending||w.isPending||T.isPending,D=d.data?.tickets??[],O=c?f.data?.tickets??[]:D,k=fh(e).data??[],A=sy(k,D),j=d.data?.feature.branch??``,M=d.data?.feature.lap??1,N=(0,L.useMemo)(()=>m.filter(e=>e.runId===l),[m,l]),P=(0,L.useMemo)(()=>E_(N),[N]),ee=(0,L.useMemo)(()=>ev(N),[N]),F=(0,L.useMemo)(()=>F_(N),[N]),[I,te]=(0,L.useState)(null),ne=O.find(e=>e.status===`burning`)?.id,re=I??new Set(ne?[ne]:[]),ie=e=>te(()=>{let t=new Set(re);return t.has(e)?t.delete(e):t.add(e),t}),ae=um(g.data),oe=(0,L.useMemo)(()=>new Map((_.data?.findings??[]).map(e=>[e.id,e.title])),[_.data]),se=e=>a_(e,ae)??a_({model:Lm(g.data,e.kind===`review`?`review`:`implement`)},ae),ce=(d.data?.sessions??[]).some(k_),le=ce||f.data?.status===`running`,ue=f.data?f.data.status===`running`:!!l;if(!t&&!ce)return(0,R.jsx)(Fj,{icon:(0,R.jsx)(xb,{}),title:`No run yet`,hint:`${hv} Every ticket gets its own lane here.`});let de=O.filter(e=>e.status===`burning`).length,fe=e=>{navigator.clipboard?.writeText(e).then(()=>i.push(`copied ${Mh(e)}`,`info`),()=>i.push(`copy failed`))},pe=e=>y.mutate({ticketId:e.id},{onSuccess:t=>{t.resolvingConflict?i.push(`resolving ticket #${e.seq}'s conflict with an agent`,`info`):t.resumedFrom&&i.push(`resuming ticket #${e.seq} from ${t.preservedCommits} preserved commit(s)`,`info`)}}),me=(t,n)=>{let r=ee.get(t.id),a=P.get(t.id),o=t.status===`failed`?t.conflictFiles:void 0;return(0,R.jsxs)(o6,{ticket:t,featureBranch:j,readonly:u,expanded:re.has(t.id),index:n,onToggle:()=>ie(t.id),hadOutput:r?.hadOutput,elapsed:r?Lh(r.startedAt,Date.now()):void 0,duration:a===void 0?void 0:Lh(0,a),model:se(t),roster:ae,defectTitle:t.originFindingId?oe.get(t.originFindingId):void 0,busy:E,stopping:x.isPending&&x.variables?.ticketId===t.id,waiving:S.isPending&&S.variables?.ticketId===t.id,terminalBlocked:le,onCopySha:fe,onModel:e=>b.mutate({ticketId:t.id,model:e}),onRetry:()=>pe(t),onRetryWithModel:ue?void 0:e=>b.mutate({ticketId:t.id,model:e},{onSuccess:()=>pe(t)}),onRetryFresh:()=>y.mutate({ticketId:t.id,fresh:!0}),onWaive:()=>S.mutate({ticketId:t.id,reason:`waived from the run view`},{onSuccess:e=>{i.push(`ticket #${t.seq} set aside — it stays visible as unfinished work at review`,`info`),e.confirmed||i.push(_v)}}),onStop:()=>x.mutate({ticketId:t.id},{onSuccess:e=>{e.swept?i.push(`no live agent — the lane was orphaned; marked failed, retry to resume it`,`info`):e.stopped?e.confirmed||i.push(_v):i.push(`no live agent for this ticket (already finishing?)`,`info`)}}),onResolveInTerminal:o?()=>w.mutate({featureId:e,kind:`chat`,kickoffLine:__({seq:t.seq,title:t.title,branch:t.attemptBranch??``,featureBranch:j,files:o}),purpose:`resolve-conflict`,purposeData:{mergeFrom:t.attemptBranch??``,mergeInto:j}}):void 0,children:[(0,R.jsx)(s6,{digest:t.digest}),(0,R.jsx)(LJ,{label:`agent transcript`,children:(0,R.jsx)(l6,{ticketId:t.id,bootEvents:N.filter(e=>e.ticketId===t.id),runtime:se(t)?.runtime,poll:!c})})]},t.id)};return(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[f.data&&(0,R.jsx)(`div`,{"data-tier":`status`,className:`mb-10`,children:(0,R.jsx)(k3,{artifact:A,outcome:xy({passes:k,tickets:D}),currentLap:M,landedSince:A?.landedSince??0,tickets:O,runState:f.data.status,verification:ly(D),building:{elapsed:Lh(f.data.startedAt,f.data.endedAt??Date.now()),lap:p.data?.find(e=>e.id===l)?.lap??M}})}),(0,R.jsx)(h6,{headline:V_(O.map(e=>({...e,hadOutput:ee.get(e.id)?.hadOutput,reviewFix:!!e.originFindingId})),{status:f.data?.status},tv(O,N)),status:f.data?.status,summary:f.data?.summary,burning:de,busy:E,cancelling:T.isPending,onCancelRun:u||!t||f.data?.status!==`running`?void 0:()=>T.mutate({runId:t},{onSuccess:e=>{e.confirmed||i.push(_v)}}),runs:p.data??[],selectedRunId:l,latestRunId:t,onPickRun:s,...c?{onBackToLatest:()=>s(null)}:{}}),(0,R.jsx)(z6,{gates:F}),O.length===0?(0,R.jsx)(Fj,{icon:(0,R.jsx)(xb,{}),title:`No ticket lanes`,hint:`This run has nothing to burn — a session breaks the work into tickets, and they appear here as lanes.`}):(0,R.jsx)(g6,{tickets:O,currentLap:M,lane:me}),(0,R.jsxs)(`div`,{className:`mt-8 flex flex-col`,children:[(0,R.jsx)(R6,{events:N}),f.data?.digest&&(0,R.jsx)(V6,{digest:f.data.digest})]})]})}function V6({digest:e}){return(0,R.jsx)(Rj,{title:`What this run produced`,icon:(0,R.jsx)(gb,{}),children:(0,R.jsx)(CK,{source:e})})}var H6={error:`danger`,ok:`success`,active:`accent`,info:`neutral`};function U6({events:e}){let t=e.slice(-50).reverse();return t.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(vb,{}),title:`Nothing yet`,hint:`Everything that happens to this feature shows up here.`}):(0,R.jsx)(`div`,{className:`flex flex-col`,children:t.map(e=>N6(e.type)?(0,R.jsx)(W6,{event:e},e.id):(0,R.jsx)(G6,{event:e},e.id))})}function W6({event:e}){return(0,R.jsxs)(`div`,{className:`my-2 flex items-center gap-2 text-xs font-medium text-accent-text`,role:`separator`,children:[(0,R.jsx)(`span`,{className:`first-letter:uppercase`,children:M6(e).summary}),(0,R.jsx)(`span`,{className:`h-px flex-1 bg-border-subtle`}),(0,R.jsx)(`span`,{className:`font-normal text-text-tertiary tabular-nums`,children:Fh(e.ts)})]})}function G6({event:e}){let[t,n]=(0,L.useState)(!1),r=M6(e);return(0,R.jsxs)(`div`,{className:`flex gap-3 py-2`,children:[(0,R.jsx)(`span`,{className:`flex h-5 w-1.5 shrink-0 items-center`,children:(0,R.jsx)(BA,{tone:H6[F6(e)]})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r.detail?(0,R.jsxs)(`button`,{type:`button`,className:`group/ev m-0 flex w-full cursor-pointer items-start gap-1 bg-transparent p-0 text-left text-sm text-text-secondary transition-colors duration-(--dur-1) ease-app hover:text-text`,"aria-expanded":t,title:t?`Show less`:`Show the whole event`,onClick:()=>n(e=>!e),children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:r.summary}),(0,R.jsx)(fb,{size:14,"aria-hidden":`true`,className:q(`mt-0.5 shrink-0 text-icon transition-transform duration-(--dur-2) ease-app`,t&&`rotate-90`)})]}):(0,R.jsx)(`div`,{className:`text-sm text-text-secondary`,children:r.summary}),t&&r.detail&&(0,R.jsx)(`pre`,{className:`m-0 mt-2 max-h-[260px] overflow-auto rounded-md bg-surface-inset px-2.5 py-2 font-mono text-xs break-words whitespace-pre-wrap text-text-secondary animate-fade-in`,children:r.detail}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex items-baseline gap-2 text-xs text-text-tertiary`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:A6(e.type)}),(0,R.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:Fh(e.ts)})]})]})]})}function K6(e){return e.split(/[\\/]/).pop()??e}function q6({featureId:e,docs:t}){let[n,r]=(0,L.useState)(null),i=(0,L.useRef)(null);return(0,R.jsxs)(`section`,{"aria-label":`Knowledge`,children:[t.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(gb,{}),title:`No docs yet`,hint:`Docs the sessions write — decisions, the spec, the brief — collect here.`}):(0,R.jsx)(ij,{label:`Feature docs`,className:`-mx-2`,children:t.map((e,t)=>(0,R.jsx)(rj,{index:t,leading:(0,R.jsx)(gb,{}),title:e.title||K6(e.relPath),meta:(0,R.jsx)(`span`,{className:`font-mono`,children:K6(e.relPath)}),onClick:t=>{i.current=t.currentTarget,r({relPath:e.relPath,title:e.title})}},e.relPath))}),n&&(0,R.jsx)(q3,{featureId:e,relPath:n.relPath,title:n.title,returnFocusRef:i,onClose:()=>r(null)})]})}var J6=[{id:`knowledge`,label:`Knowledge`,icon:(0,R.jsx)(gb,{})},{id:`activity`,label:`Activity`,icon:(0,R.jsx)(vb,{})}];function Y6({featureId:e,onClose:t}){return t?(0,R.jsx)(X6,{featureId:e,onClose:t}):null}function X6({featureId:e,onClose:t}){let[n,r]=(0,L.useState)(`knowledge`),i=B.feature.get.useQuery({id:e},{refetchInterval:Ch()}),a=QF(e);return(0,R.jsx)(Sj,{label:`Details`,title:(0,R.jsx)(cj,{items:J6,value:n,onChange:r,size:`sm`,label:`Details`}),onClose:t,bodyClassName:`px-4 py-4`,children:i.isLoading?(0,R.jsx)(Q6,{}):i.data?(0,R.jsx)(`div`,{role:`tabpanel`,"aria-label":n===`knowledge`?`Knowledge`:`Activity`,className:`animate-fade-in`,children:n===`knowledge`?(0,R.jsx)(q6,{featureId:e,docs:i.data.docs}):(0,R.jsx)(U6,{events:a})},n):(0,R.jsx)(Pj,{children:i.error?.message??`Could not load the details`})})}var Z6=[`w-28`,`w-20`,`w-32`];function Q6(){return(0,R.jsx)(Oj,{label:`Loading the details…`,children:(0,R.jsx)(`div`,{className:`-mx-2 flex flex-col`,children:Z6.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 px-3`,"data-skeleton":`doc-row`,children:[(0,R.jsx)(kj,{className:`size-4`}),(0,R.jsx)(kj,{className:q(`h-3`,e)}),(0,R.jsx)(kj,{className:`ml-auto h-2.5 w-16`})]},t))})})}function $6({featureId:e,sessionId:t,onEnded:n}){let r=B.useUtils(),i=gx(),a=B.feature.endSession.useMutation({onSuccess:()=>{e&&(r.feature.get.invalidate({id:e}),r.feature.list.invalidate()),n?.(),i.push(`session ended`,`info`)},onError:e=>i.push(e.message)});return(0,R.jsx)(Y,{variant:`danger-ghost`,size:`sm`,icon:(0,R.jsx)(Tb,{}),loading:a.isPending,title:`end this session — recoverable, you can relaunch it`,onClick:()=>a.mutate({sessionId:t}),children:a.isPending?`Ending…`:`End session`})}function e8({session:e,contextLine:t,meta:n,featureId:r,onEnded:i,notices:a,headless:o,transcriptId:s,onLaunch:c,launchLabel:l,launching:u=!1,hidden:d=!1,label:f=`Chat`,children:p}){return(0,R.jsxs)(`section`,{"aria-label":f,"aria-hidden":d,hidden:d,"data-chat-view":``,className:d?`hidden`:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex h-10 flex-none items-center gap-3 border-b border-border-subtle px-4 text-xs text-text-tertiary`,children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 shrink-0 items-center gap-2 text-sm font-medium text-text`,children:[e&&(0,R.jsx)(BA,{tone:e.status===`launching`?`accent`:`live`,label:e.status===`launching`?`Starting`:`Live`}),t]}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-4 truncate`,children:n}),e&&(0,R.jsx)($6,{featureId:r,sessionId:e.id,onEnded:i})]}),e&&a&&(0,R.jsx)(`div`,{className:`flex-none px-4 pt-2`,children:a}),(0,R.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col bg-surface-inset animate-fade-in`,children:[e&&o?(0,R.jsx)(`div`,{className:`px-6 py-6 text-sm text-text-secondary`,children:o}):e?(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,"data-chat-terminal":``,children:(0,R.jsx)(LJ,{label:`terminal`,children:(0,R.jsx)(c4,{sessionId:e.id})})}):(0,R.jsx)(t8,{transcriptId:s,onLaunch:c,launchLabel:l,launching:u}),p]})]})}function t8({transcriptId:e,onLaunch:t,launchLabel:n,launching:r}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-6`,children:(0,R.jsx)(`div`,{className:`mx-auto w-full max-w-(--content-max)`,children:e?(0,R.jsx)(W3,{sessionId:e,className:`flex flex-col gap-4`}):(0,R.jsx)(Fj,{icon:(0,R.jsx)(hb,{}),title:`No conversation yet`,hint:`One chat per feature — it knows the state, answers questions, and edits the next burn's tickets.`})})}),t&&(0,R.jsx)(`div`,{className:`flex flex-none items-center justify-center gap-3 border-t border-border-subtle bg-surface px-4 py-3`,children:(0,R.jsx)(Y,{variant:`primary`,icon:e?(0,R.jsx)(Gb,{}):(0,R.jsx)(wb,{}),loading:r,onClick:t,children:n??(e?`Resume the conversation`:`Start the conversation`)})})]})}var n8=new Set([`tickets.stored`,`ticket.edited`,`ticket.cancelled`]),r8=/^ticket (\d+) failed(?::\s*(.*))?$/s,i8=/(\d+)\/(\d+) tickets done/;function a8(e,t=[]){let n=t=>({...t,count:1,eventId:e.id});if(e.type===`docs.changed`){let t=o8(e),r=e=>t.some(t=>t===e||t.endsWith(`/${e}`));return r(`preview.html`)?n({kind:`preview`,hue:`planning`,title:`Preview ready`,subtitle:ui,actionLabel:`View preview`,target:`overview`}):r(`spec.md`)?n({kind:`spec`,hue:`planning`,title:`Spec written`,subtitle:`spec.md`,actionLabel:`View spec`,target:`overview`}):null}if(n8.has(e.type))return n({kind:`tickets`,hue:`tickets`,title:`Tickets updated`,subtitle:e.message,actionLabel:`View tickets`,target:`overview`});if(e.type===`ticket.failed`){let t=r8.exec(e.message);return n({kind:`ticket-failed`,hue:`danger`,title:t?`Ticket #${t[1]} failed`:`Ticket failed`,subtitle:t?.[2]?.trim()||e.message,actionLabel:`View run`,target:`overview`})}if(e.type===`run.finished`){let t=e.data??{},r=t.status!==`succeeded`,i=typeof t.summary==`string`?t.summary:e.message,a=i8.exec(i);return n({kind:`run`,hue:r?`danger`:`building`,title:r?`Run finished with failures`:`Run finished`,subtitle:a?`${a[1]} of ${a[2]} landed`:i,actionLabel:`View run`,target:`overview`})}if(e.type===`ticket.done`){let r=t.find(t=>t.id===e.ticketId);return r?.kind!==`review`||r.passKind===`verification`?null:n({kind:`review`,hue:`review`,title:`Review ready`,subtitle:r.title,actionLabel:`View review`,target:`overview`})}if(e.type===`testdrive.url`){let t=e.data??{};return n({kind:`drive`,hue:`review`,title:`Test drive running`,subtitle:typeof t.url==`string`?t.url:e.message,actionLabel:`Open`,target:`overview`})}return null}function o8(e){let t=e.data?.files;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function s8(e,t){switch(t.type){case`push`:{let n=e.find(e=>e.kind===t.notice.kind);return[n?{...t.notice,count:n.count+t.notice.count}:t.notice,...e.filter(e=>e.kind!==t.notice.kind)].slice(0,4)}case`dismiss`:case`act`:return e.filter(e=>e.kind!==t.kind)}}var c8=2,l8=9,u8={planning:{text:`text-phase-planning`,chip:`bg-phase-planning/15 ring-phase-planning/30`,tint:`bg-phase-planning/15`,action:`bg-phase-planning/15 hover:bg-phase-planning/25`,glow:`from-phase-planning/10`},tickets:{text:`text-phase-tickets`,chip:`bg-phase-tickets/15 ring-phase-tickets/30`,tint:`bg-phase-tickets/15`,action:`bg-phase-tickets/15 hover:bg-phase-tickets/25`,glow:`from-phase-tickets/10`},building:{text:`text-phase-building`,chip:`bg-phase-building/15 ring-phase-building/30`,tint:`bg-phase-building/15`,action:`bg-phase-building/15 hover:bg-phase-building/25`,glow:`from-phase-building/10`},review:{text:`text-phase-review`,chip:`bg-phase-review/15 ring-phase-review/30`,tint:`bg-phase-review/15`,action:`bg-phase-review/15 hover:bg-phase-review/25`,glow:`from-phase-review/10`},danger:{text:`text-danger`,chip:`bg-danger/15 ring-danger/30`,tint:`bg-danger/15`,action:`bg-danger/15 hover:bg-danger/25`,glow:`from-danger/10`}},d8={planning:ix.planning,tickets:ix.tickets,building:ix.building,review:ix.review,danger:ix.building};function f8(e){return e===`danger`?(0,R.jsx)(Vb,{size:16}):(0,R.jsx)(sx,{phase:e,label:``})}function p8({notices:e,onAct:t,onDismiss:n}){let[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(!1),s=r||a;function c(e){e.currentTarget.contains(e.relatedTarget)||o(!1)}return(0,R.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":`Chat notifications`,"data-open":s||void 0,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>o(!0),onBlur:c,className:`absolute right-4 bottom-4 z-20 w-[360px] max-w-[calc(100%-2rem)]`,children:[!s&&e.length>1&&(0,R.jsxs)(`p`,{className:`m-0 mb-1 text-right text-xs text-text-tertiary`,children:[e.length,` notifications`]}),(0,R.jsx)(`ol`,{className:q(`m-0 list-none p-0`,s?`flex flex-col-reverse gap-2`:`relative`,!s&&e.length>1&&`mt-[18px]`),children:e.map((e,r)=>{let i=!s&&r>0,a=i?{transform:`translateY(${-r*l8}px) scale(${1-r*.05})`,zIndex:-r}:void 0;return(0,R.jsx)(`li`,{"aria-hidden":i||void 0,style:a,className:q(`origin-bottom transition-[transform,opacity] duration-(--dur-3) ease-out-app`,`motion-reduce:transition-none`,i&&`absolute inset-0`,i&&r>c8&&`opacity-0`),children:(0,R.jsx)(m8,{notice:e,hidden:i,onAct:t,onDismiss:n})},`${e.kind}-${e.eventId}`)})})]})}function m8({notice:e,hidden:t,onAct:n,onDismiss:r}){let i=u8[e.hue],a=q(`transition-opacity duration-(--dur-2) ease-app`,t&&`invisible opacity-0`);return(0,R.jsxs)(`article`,{"data-hue":e.hue,className:`relative grid h-full animate-rise-in grid-cols-[32px_1fr_24px] gap-x-3 overflow-hidden rounded-lg bg-surface-raised py-3 pr-3 pl-3.5 text-sm shadow-popover motion-reduce:animate-none`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`pointer-events-none absolute inset-0 bg-radial-[120%_90%_at_0%_0%] to-transparent to-60%`,i.glow)}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`relative grid size-8 place-items-center rounded-lg ring-1 ring-inset`,i.chip,i.text,a),children:f8(e.hue)}),(0,R.jsxs)(`div`,{className:q(`relative flex min-w-0 flex-col gap-px`,a),children:[(0,R.jsx)(`span`,{className:q(`text-xs font-semibold tracking-wide uppercase`,i.text),children:d8[e.hue]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-text`,children:[e.title,e.count>1&&(0,R.jsxs)(`span`,{"aria-label":`${e.count} times`,className:q(`rounded-full px-1.5 text-xs font-semibold tabular-nums`,i.tint,i.text),children:[`×`,e.count]})]}),(0,R.jsx)(`span`,{className:`text-xs [overflow-wrap:anywhere] text-text-secondary`,children:e.subtitle}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(e.kind),className:q(qE,`mt-2 inline-flex cursor-pointer items-center gap-1.5 self-start rounded-md px-2.5 py-1 text-xs font-semibold`,`transition-colors duration-(--dur-1) ease-app`,i.action,i.text),children:[e.actionLabel,(0,R.jsx)(Cb,{size:12})]})]}),(0,R.jsx)(UE,{label:`Dismiss`,size:`sm`,icon:(0,R.jsx)(cb,{size:12}),onClick:()=>r(e.kind),className:q(`relative`,a)})]})}function h8({events:e,tickets:t,active:n,onView:r}){let[i,a]=(0,L.useReducer)(s8,[]),o=(0,L.useRef)(null),s=(0,L.useRef)(0);return(0,L.useEffect)(()=>{if(!n){o.current=null;return}let r=o.current??=Date.now();for(let n of e){if(n.id<=s.current||(s.current=n.id,n.ts<r))continue;let e=a8(n,t);e&&a({type:`push`,notice:e})}},[n,e,t]),(0,R.jsx)(p8,{notices:i,onAct:e=>{let t=i.find(t=>t.kind===e);a({type:`act`,kind:e}),t&&r(t.target)},onDismiss:e=>a({type:`dismiss`,kind:e})})}function g8({featureId:e,session:t}){let n=QF(e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(v8,{session:t,events:n}),(0,R.jsx)(b8,{session:t,notReady:O_(n,t.id)})]})}var _8=5e3;function v8({session:e,events:t}){return D_(e,t,y8(_8))?(0,R.jsx)(`p`,{className:`m-0 pb-1.5 text-xs text-text-tertiary animate-fade-in`,children:`The agent hasn’t checked in yet.`}):null}function y8(e){let[t,n]=(0,L.useState)(()=>Date.now());return(0,L.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function b8({session:e,notReady:t}){return t?(0,R.jsxs)(`div`,{className:`flex items-start gap-1.5 pb-2 text-sm text-text-secondary animate-fade-in`,role:`status`,children:[(0,R.jsx)(HA,{tone:`warning`,icon:(0,R.jsx)(Vb,{}),size:`sm`,strong:!0,className:`shrink-0`,children:`Not ready`}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[`— `,mv(e),` has not started on its briefing. Answer anything waiting in the terminal (a trust or login prompt).`]})]}):null}function x8({full:e,events:t,hidden:n,launching:r,onLaunch:i,onView:a}){let o=j_(e.sessions),s=bv(e.sessions);return(0,R.jsx)(e8,{label:`Feature chat`,session:o??null,contextLine:o?Sv(o):`Chat · lap ${e.feature.lap}`,meta:`One transcript per feature`,featureId:e.feature.id,notices:o&&(0,R.jsx)(g8,{featureId:e.feature.id,session:o}),headless:o&&xv(o)?`This feature is planning itself. There is no terminal to watch; the plan appears on the Overview as it is written.`:void 0,transcriptId:s?.id,onLaunch:i,launching:r,hidden:n,children:(0,R.jsx)(h8,{events:t,tickets:e.tickets,active:!n,onView:a})})}function S8({isDraft:e,value:t,onChange:n,sessionLive:r}){return e?null:(0,R.jsx)(cj,{label:`Feature views`,size:`sm`,value:t,onChange:n,items:[{id:`overview`,label:`Overview`,icon:(0,R.jsx)(zb,{})},{id:`chat`,label:(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Chat`,r&&(0,R.jsx)(BA,{tone:`live`,label:`Session live`})]}),icon:(0,R.jsx)(hb,{})}]})}function C8({featureId:e,line:t,onOpen:n}){return(0,R.jsx)(NJ,{tone:`quiet`,role:`status`,icon:(0,R.jsx)(XA,{status:`live`}),title:t.text,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(Cb,{}),onClick:n,children:`Open chat`}),(0,R.jsx)($6,{featureId:e,sessionId:t.sessionId})]})})}function w8({tag:e,details:t,children:n}){let r=gx();return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md bg-danger-subtle px-4 py-3`,role:`alert`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,R.jsx)(Vb,{size:16,className:`shrink-0`}),e]}),(0,R.jsx)(`p`,{className:`m-0 text-sm text-text-secondary`,children:n}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-text-tertiary`,title:t,children:t}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Fb,{}),onClick:()=>gF(t,r),children:`Copy details`})]})]})}function T8({crumb:e,children:t}){return(0,R.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface`,children:[(0,R.jsx)(_j,{crumbs:[{label:e,icon:(0,R.jsx)(Vb,{})}]}),(0,R.jsx)(yj,{children:t})]})}function E8({featureId:e,error:t}){return(0,R.jsx)(T8,{crumb:`Feature`,children:(0,R.jsx)(w8,{tag:`Broken`,details:`feature ${e} — ${t.name}: ${t.message}`,children:`This feature couldn't be rendered. Everything else still works.`})})}function D8({feature:e}){return(0,R.jsxs)(T8,{crumb:e.title,children:[(0,R.jsx)(bj,{title:e.title,meta:[{text:`Unknown phase`}]}),(0,R.jsx)(`div`,{className:`mt-8`,children:(0,R.jsxs)(w8,{tag:`Unrecognized phase`,details:`feature ${e.id} (${e.slug}) has phase "${e.phase}"`,children:[`This feature's phase is `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-text`,children:e.phase}),`, which this version of runcastle doesn't know. Nothing here can be acted on until the row is fixed.`]})})]})}var O8=`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-text-tertiary`;function k8(e){return e.satisfied?`success`:e.status===`archived`||e.status===`draft`?`neutral`:`accent`}function A8({dep:e,onRemove:t}){return(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm text-text`,children:e.title}),(0,R.jsx)(HA,{tone:k8(e),...e.satisfied?{icon:(0,R.jsx)(sb,{size:12})}:{},title:e.slug,children:Bh(e)}),t&&(0,R.jsx)(UE,{label:`Stop waiting on ${e.slug}`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:t})]})}function j8({isDraft:e,dependsOn:t,candidates:n,onChange:r}){let[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(!1);if(!e)return t.length===0?null:(0,R.jsxs)(`p`,{className:O8,children:[(0,R.jsx)(`span`,{children:`Waited on:`}),t.map(e=>(0,R.jsx)(A8,{dep:e},e.featureId))]});let c=t.map(e=>e.featureId),l=e=>{a(null),s(!0),r(e).catch(e=>a(y6(e instanceof Error?e.message:String(e)))).finally(()=>s(!1))};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`div`,{className:O8,children:[(0,R.jsx)(`span`,{children:`Waits on`}),t.length===0&&(0,R.jsx)(`span`,{children:`nothing`}),t.map(e=>(0,R.jsx)(A8,{dep:e,...e.satisfied?{}:{onRemove:()=>l(c.filter(t=>t!==e.featureId))}},e.featureId)),(0,R.jsxs)(OA,{children:[(0,R.jsx)(kA,{asChild:!0,children:(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(ob,{}),loading:o,children:`Add`})}),(0,R.jsxs)(AA,{align:`start`,children:[(0,R.jsx)(jA,{placeholder:`Find a feature…`}),(0,R.jsxs)(MA,{label:`Features to wait on`,children:[(0,R.jsx)(NA,{children:`No unmerged feature to wait on`}),n.map(e=>(0,R.jsx)(LA,{value:`${e.title} ${e.slug}`,onSelect:()=>l([...c,e.id]),children:e.title},e.id))]})]})]})]}),i&&(0,R.jsx)(`p`,{className:`m-0 text-xs text-danger`,role:`alert`,children:i})]})}function M8({projectId:e,blocks:t}){return t.length===0?null:(0,R.jsxs)(`p`,{className:O8,children:[(0,R.jsx)(`span`,{children:`Blocks:`}),t.map((n,r)=>(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`a`,{className:q(JE,`font-mono`),href:Sg({kind:`feature`,projectId:e,featureSlug:n.slug}),title:n.title,children:n.slug}),r<t.length-1&&`,`]},n.featureId))]})}function N8({step:e}){return e.state===`done`?(0,R.jsx)(sx,{phase:`shipped`,size:14,label:``}):e.state===`current`?(0,R.jsx)(sx,{phase:e.phase,size:14,label:``}):(0,R.jsx)(sx,{phase:`draft`,size:14,label:``,className:`text-text-tertiary`})}var P8={done:`text-text-secondary`,current:`font-medium text-text bg-[color-mix(in_srgb,var(--step-hue)_14%,transparent)]`,upcoming:`text-text-tertiary`};function F8({steps:e,onView:t,readonly:n=!1}){return(0,R.jsx)(`nav`,{"aria-label":`Pipeline`,className:`-ml-2 flex flex-wrap items-center gap-x-0.5 gap-y-1`,children:e.map((r,i)=>{let a=n&&r.isViewed;return(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,className:q(`inline-flex h-(--control-sm) shrink-0 items-center gap-1.5 rounded-md px-2 text-xs`,`transition-colors duration-(--dur-1) ease-app`,P8[r.state],a&&`bg-surface-selected text-text`,r.clickable&&!a?`cursor-pointer hover:bg-surface-hover hover:text-text`:r.clickable?`cursor-pointer`:`cursor-default`),style:{"--step-hue":`var(--color-phase-${r.phase})`},title:r.tip,"aria-current":r.state===`current`?`step`:void 0,"aria-pressed":r.clickable?a:void 0,disabled:!r.clickable,onClick:()=>r.clickable&&t(r.phase),children:[(0,R.jsx)(N8,{step:r}),(0,R.jsx)(`span`,{children:ix[r.phase]})]}),i<e.length-1&&(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-px w-3 shrink-0 bg-border-strong`})]},r.phase)})})}function I8({feature:e,isDraft:t,steps:n,onViewPhase:r,readonly:i=!1,facts:a=[],className:o,children:s}){let c=gx(),l=(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1.5`,children:[!t&&e.branch&&(0,R.jsxs)(`button`,{type:`button`,className:q(`inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1.5 rounded-sm bg-transparent p-0`,`font-mono text-xs text-text-tertiary transition-colors duration-(--dur-1) ease-app hover:text-text`),title:`Copy branch name`,onClick:()=>gF(e.branch,c),children:[(0,R.jsx)(rb,{size:14,className:`shrink-0 text-icon`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.branch})]}),(0,R.jsx)(oj,{items:a})]});return(0,R.jsx)(bj,{title:e.title,meta:l,className:o,children:(!t||s)&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[!t&&(0,R.jsx)(F8,{steps:n,readonly:i,onView:t=>r(t===e.phase?null:t)}),s]})})}var L8=[[`w-12`,`w-40`],[`w-12`,`w-32`],[`w-16`,`w-24`]];function R8(){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(_j,{leading:(0,R.jsx)(Oj,{children:(0,R.jsx)(kj,{className:`h-3 w-40`})})}),(0,R.jsx)(yj,{children:(0,R.jsxs)(Oj,{label:`Loading feature…`,children:[(0,R.jsx)(`div`,{className:`flex h-7 items-center`,"data-skeleton":`title`,children:(0,R.jsx)(kj,{className:`h-5 w-2/5`})}),(0,R.jsxs)(`div`,{className:`mt-2 flex h-4 items-center gap-1.5`,"data-skeleton":`branch`,children:[(0,R.jsx)(kj,{className:`size-3.5`}),(0,R.jsx)(kj,{className:`h-2.5 w-64`})]}),(0,R.jsx)(`div`,{className:`mt-5 -ml-2 flex items-center gap-x-0.5`,children:Kv.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-x-0.5`,children:[t>0&&(0,R.jsx)(`span`,{className:`mx-0.5 h-px w-3 bg-border-subtle`}),(0,R.jsxs)(`div`,{className:`flex h-(--control-sm) items-center gap-1.5 px-2`,"data-skeleton":`step`,children:[(0,R.jsx)(kj,{className:`size-3.5 rounded-full`}),(0,R.jsx)(kj,{className:`h-2.5 w-14`})]})]},e))}),(0,R.jsx)(`div`,{className:`mt-10 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-1.5`,children:L8.map(([e,t],n)=>(0,R.jsxs)(`div`,{className:`contents`,"data-skeleton":`row`,children:[(0,R.jsx)(`div`,{className:`flex min-h-6 items-center`,children:(0,R.jsx)(kj,{className:q(`h-3`,e)})}),(0,R.jsx)(`div`,{className:`flex min-h-6 items-center`,children:(0,R.jsx)(kj,{className:q(`h-3`,t)})})]},n))})]})})]})}var z8={startDraft:(0,R.jsx)(wb,{}),chat:(0,R.jsx)(hb,{}),selfPlan:(0,R.jsx)(Db,{}),stopSelfPlan:(0,R.jsx)(Tb,{}),burn:(0,R.jsx)(xb,{}),cancelRun:(0,R.jsx)(Tb,{}),openBurnSettings:(0,R.jsx)(tb,{}),testDriveStart:(0,R.jsx)(wb,{}),testDriveStop:(0,R.jsx)(Tb,{}),stopDriveAndIterate:(0,R.jsx)(Tb,{}),fixDrive:(0,R.jsx)(mb,{}),merge:(0,R.jsx)(Nb,{}),resolveConflict:(0,R.jsx)(Vb,{}),iterate:(0,R.jsx)(Gb,{}),endSessionAndIterate:(0,R.jsx)(Gb,{}),unarchive:(0,R.jsx)(jb,{})},B8={danger:`danger`,note:`neutral`,clear:`success`};function V8(e){return/[.!?…:]$/.test(e)?e:`${e}.`}function H8({ns:e,guidance:t,busy:n,onAction:r,draftBranch:i,demote:a}){let o=e.secondary,s=[...o,e.primary].filter(e=>!!e?.disabled),c=!!e.primary||o.length>0,l=o.filter(e=>!a?.includes(e.kind)),u=o.filter(e=>a?.includes(e.kind)),d=l.length>2?l.slice(0,2):l,f=[...l.length>2?l.slice(2):[],...u],p=s.filter(t=>!a?.includes(t.kind)||t===e.primary);if(!c&&!e.busy&&!e.alert&&!e.counts&&!e.note)return null;let m=e.title??(t?void 0:e.desc),h=t&&e.desc&&e.desc!==m?e.desc:void 0;return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-3 animate-fade-in`,role:e.alert?`alert`:void 0,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 basis-80 text-sm text-text-secondary`,children:[(m||h)&&(0,R.jsxs)(`p`,{className:`m-0 text-pretty`,children:[e.busy?(0,R.jsx)(KE,{size:`sm`,className:`mr-2 inline-block align-[-2px]`}):e.alert?(0,R.jsx)(BA,{tone:`warning`,className:`mr-2 align-middle`}):null,m&&(0,R.jsx)(`span`,{className:`font-medium text-text`,children:h?V8(m):m}),m&&h&&` `,h]}),e.counts&&(0,R.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1`,children:[e.counts.pills.map(e=>(0,R.jsx)(HA,{tone:B8[e.tone],size:`sm`,children:e.label},e.label)),e.counts.trailing&&(0,R.jsx)(`span`,{className:`text-sm text-text-tertiary`,children:e.counts.trailing})]}),e.note&&(0,R.jsx)(`p`,{className:`mt-1.5 mb-0 text-xs text-text-tertiary first-letter:uppercase`,role:`note`,children:e.note})]}),c&&(0,R.jsxs)(`div`,{className:`ml-auto flex min-w-0 flex-col items-end gap-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:[d.map((e,t)=>(0,R.jsx)(Y,{variant:`ghost`,icon:z8[e.kind],disabled:n||!!e.disabled,title:e.disabled??e.hint,onClick:()=>r(e.kind),children:e.label},t)),f.length>0&&(0,R.jsxs)(uF,{children:[(0,R.jsx)(dF,{asChild:!0,children:(0,R.jsx)(UE,{label:`More actions`,icon:(0,R.jsx)(pb,{}),disabled:n})}),(0,R.jsx)(fF,{align:`end`,children:f.map(e=>(0,R.jsx)(pF,{icon:z8[e.kind],disabled:!!e.disabled,title:e.disabled??e.hint,onSelect:()=>r(e.kind),children:e.label},e.kind))})]}),e.primary&&(0,R.jsxs)(R.Fragment,{children:[i&&(0,R.jsx)(Jj,{prefix:`from`,value:i.value,branches:i.branches,detected:i.detected,missing:i.missing,onPick:i.onPick}),(0,R.jsx)(Y,{variant:e.primary.danger?`danger`:`primary`,icon:z8[e.primary.kind],disabled:n||!!e.primary.disabled,title:e.primary.disabled??e.primary.hint,onClick:()=>r(e.primary.kind),children:n?`Working…`:e.primary.label})]})]}),p.map(e=>(0,R.jsxs)(`div`,{className:q(`flex flex-wrap items-center justify-end gap-2 text-right text-xs`,i&&e.kind===`startDraft`&&i.missing?`text-warning`:`text-text-tertiary`),children:[(0,R.jsx)(`span`,{children:e.disabled}),e.escape&&(0,R.jsx)(Y,{size:`sm`,variant:`secondary`,icon:z8[e.escape.kind],onClick:()=>r(e.escape.kind),disabled:n,children:e.escape.label})]},e.kind))]})]},`${e.title??``}|${e.primary?.kind??``}`)}function U8({phase:e,livePhase:t,facts:n,onBack:r}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2 animate-fade-in`,role:`status`,children:[(0,R.jsxs)(`p`,{className:`m-0 min-w-0 flex-1 basis-60 text-sm text-text-secondary`,children:[(0,R.jsxs)(`span`,{className:`font-medium text-text`,children:[`Viewing `,ix[e].toLowerCase()]}),n?(0,R.jsxs)(`span`,{className:`text-text-tertiary`,children:[` — `,n]}):null]}),(0,R.jsxs)(Y,{variant:`ghost`,icon:(0,R.jsx)(Ub,{}),onClick:r,children:[`Back to `,ix[t].toLowerCase()]})]})}function W8(e){let t=QF(e),[n,r]=(0,L.useState)(null),i=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(t.length===0)return;let e=t[t.length-1].id;if(i.current===null){i.current=e;return}let n=i.current;i.current=e;let a=t.filter(e=>e.id>n&&e.type===`session.resume_failed`),o=a[a.length-1];o&&r(o.message||`session resume failed — relaunch to continue`)},[t]),(0,L.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>r(null),8e3);return()=>clearTimeout(e)},[n]),{message:n,dismiss:()=>r(null)}}var G8=`flex h-full min-h-0 min-w-0 flex-1 flex-col bg-surface`,K8=`runcastle.feature.details`;function q8(e){try{return sessionStorage.getItem(e)}catch{return null}}function J8(e,t){try{sessionStorage.setItem(e,t)}catch{}}function Y8({featureId:e,view:t,onViewChange:n,viewedPhase:r,onViewPhase:i,guidance:a,driving:o,onDriveChange:s,onDeleted:c,detailsOpen:l,onToggleDetails:u}){let d=B.useUtils(),f=gx(),p=tI(),m=B.feature.get.useQuery({id:e},{refetchInterval:Ch()}),h=W8(e),g=QF(e),_=Qd(g),v=C_(g),y=m.data?.feature.phase===`review`,b=B.feature.mergeDelta.useQuery({featureId:e},{refetchInterval:Ch(5e3),enabled:y}),x=Ch(),S=y?x:!1,C=B.notes.list.useQuery({featureId:e},{refetchInterval:S}),w=C.data?.filter(e=>e.status===`open`)??[],T=C.data?w.length:void 0,E=B.findings.listByFeature.useQuery({featureId:e},{refetchInterval:S}),D=E.data?.openDefects??[],O=E.data?.summary.open,k=fh(e,y),A=sy(k.data??[],m.data?.tickets??[]),j=cy(A,{landedSince:A?.landedSince??0,lap:m.data?.feature.lap??1},ly(m.data?.tickets??[])),M=by({passes:k.data??[],tickets:m.data?.tickets??[],currentLap:m.data?.feature.lap??1}),[N,P]=(0,L.useState)(!1),[ee,F]=(0,L.useState)(!1),I=!!m.data&&m.data.feature.phase!==`shipped`,te=B.feature.burnWarnings.useQuery({featureId:e},{refetchInterval:Ch(),enabled:I}),[ne,re]=(0,L.useState)(null),ie=B.notes.triagePreview.useQuery({featureId:e},{enabled:ne!==null}),ae=m.data?.feature.phase===`review`?Ey(m.data):void 0,oe=Oy(B.docs.read.useQuery({featureId:e,relPath:ae??`spec.md`},{enabled:!!ae}).data?.content),se=m.data?.feature.projectId,ce=B.project.prep.useQuery({projectId:se??``},{enabled:!!se,refetchInterval:Ch()}),le=B.feature.driveInfo.useQuery(void 0,{refetchInterval:Ch()}),ue=B.ticket.durationStats.useQuery({projectId:se??``},{enabled:!!se}),de=Lm(B.settings.get.useQuery({projectId:se??``},{enabled:!!se&&I}).data,`implement`),fe=m.data?.feature.phase===`planning`||m.data?.feature.phase===`building`,pe=B.docs.digestSize.useQuery({featureId:e},{enabled:fe}),me=m.data?.feature.status===`draft`,he=B.project.branches.useQuery({projectId:se??``},{enabled:!!se&&me}),[ge,_e]=(0,L.useState)(null),ve=(ge?.featureId===e?ge.base:``)||(he.data?Zg(he.data):``),ye=!me||ve?void 0:he.data?`unpicked`:`loading`,be=aI(Xh(m.data?.runs??[])),xe=oI(e,sI(m.data?.docs??[],`decisions.md`)).content,Se=()=>{d.feature.get.invalidate({id:e}),d.feature.list.invalidate(),d.events.invalidate()},Ce=Ex(e),we=()=>{Se(),Ce()},Te=B.feature.launchSession.useMutation({onSuccess:we,onError:e=>f.push(e.message)}),Ee=B.feature.burn.useMutation({onSuccess:()=>{Se(),i(null)},onError:e=>f.push(e.message)}),De=B.feature.endSession.useMutation({onError:e=>f.push(e.message)}),Oe=B.notes.triage.useMutation(),ke=B.findings.dismiss.useMutation(),Ae=B.run.cancel.useMutation({onSuccess:e=>{Se(),e.confirmed?f.push(`run cancelled — its agents are stopped`,`info`):f.push(_v)},onError:e=>f.push(e.message)}),je=B.feature.fixDrive.useMutation({onSuccess:we,onError:e=>f.push(e.message)}),Me=B.feature.testDrive.useMutation({onSuccess:e=>{if(Se(),e.hookFailure){let t=e.hookFailure;f.push(`${t.phase===`setup`?`Test drive setup`:`Test drive teardown`} failed: ${t.command}${t.timedOut?` (timed out)`:``} — see the timeline for its output`)}e.dbDrift&&f.push(e.dbDrift.resetCommand?`Migrations differ between the branches — your dev database may be ahead. Rebuild it with: ${e.dbDrift.resetCommand}`:`Migrations differ between the branches — your dev database may be ahead. Set a database reset command in settings for a one-line fix here.`,`info`),e.carriedChanges?.length&&f.push(`${e.carriedChanges.length} uncommitted file(s) came back with you onto ${e.branch}`,`info`)},onError:e=>f.push(e.message)}),Ne=B.feature.merge.useMutation({onSettled:Se,onError:e=>f.push(e.message)}),Pe=B.feature.unarchive.useMutation({onSuccess:()=>{Se(),f.push(`feature unarchived`,`success`)},onError:e=>f.push(e.message)}),Fe=B.feature.list.useQuery({projectId:se??``},{enabled:!!se&&me}),Ie=B.feature.setDependencies.useMutation({onSuccess:Se,onError:()=>void 0}),Le=B.feature.start.useMutation({onSuccess:(e,t)=>{Se(),Qg(e)&&Te.mutate({featureId:t.featureId,kind:`chat`})},onError:e=>f.push(e.message)}),Re=B.feature.launchSession.useMutation({onSuccess:Se,onError:e=>f.push(e.message)}),ze=B.feature.start.useMutation({onSuccess:(e,t)=>{Se(),Qg(e)&&Re.mutate({featureId:t.featureId,kind:`chat`,purpose:`self-plan`})},onError:e=>f.push(e.message)}),Be=iI(e,m.data?.feature.branch??``),[Ve,He]=(0,L.useState)(()=>q8(K8)===`1`),Ue=l!==void 0,We=Ue?l:Ve,Ge=e=>{if(Ue){e!==l&&u?.();return}He(e),J8(K8,e?`1`:`0`)},[Ke,qe]=(0,L.useState)(null),Je=B.feature.archive.useMutation({onSuccess:()=>{Se(),f.push(`feature archived`,`success`)},onError:e=>f.push(e.message)}),Ye=B.feature.delete.useMutation({onSuccess:()=>{d.feature.list.invalidate(),qe(null),c?.()},onError:e=>f.push(e.message)});if(m.isLoading)return(0,R.jsx)(`section`,{className:G8,children:(0,R.jsx)(R8,{})});if(!m.data)return(0,R.jsxs)(`section`,{className:G8,children:[(0,R.jsx)(_j,{}),(0,R.jsx)(yj,{children:(0,R.jsxs)(Pj,{children:[`Could not load the feature`,m.error?`: ${m.error.message}`:``]})})]});let Xe=!!m.error,Ze=m.data,Qe=Ze.feature;if(Cd(Qe.phase)===null)return(0,R.jsx)(D8,{feature:Qe});let $e=$v(Qe,r),et=ey(Qe,$e),tt=ty(Qe,$e,{planning:(e=>Vy({phase:e,full:Ze,events:g,decisions:xe}))(`planning`)}),nt=Xh(Ze.runs),rt=P_(g,nt?.id),it=be&&nt?.id===be&&$e===`review`?`building`:$e,at=Gv(Ze,{driving:o?.featureId===Qe.id,driveState:le.data?.featureId===Qe.id?le.data.state:`idle`,conflict:_,unverifiedDriveKeys:em(ce.data?.findings??[]),...le.data&&le.data.featureId!==Qe.id?{slotHolder:le.data.holderLabel}:{},...ue.data?{burnStats:ue.data}:{},...pe.data?{docsDigestBytes:pe.data.bytes}:{},...ye?{draftBaseMissing:ye}:{},openNotes:T,openDefects:O,...M?{unverifiedReview:{reason:M.reason}}:{},laterLaps:oe,interruptedBurn:rt}),ot=j_(Ze.sessions),st=Le.isPending||Te.isPending||ze.isPending||Re.isPending||Ee.isPending||Ae.isPending||Me.isPending||Ne.isPending||Oe.isPending||ke.isPending||je.isPending||Pe.isPending||De.isPending||Be.pending,ct=()=>{(T??0)+(O??0)>0?re(Date.now()):Te.mutate({featureId:e,kind:`chat`,purpose:`start-lap`})},lt=async()=>{if(!ot)return!0;try{await De.mutateAsync({sessionId:ot.id})}catch{return!1}return Se(),!0},ut=async t=>{let{dismissFindingIds:n,...r}=t;try{for(let e of n)await ke.mutateAsync({findingId:e});await Oe.mutateAsync({featureId:e,...r}),re(null),Se(),d.notes.list.invalidate({featureId:e}),d.findings.listByFeature.invalidate({featureId:e}),t.carry?await lt()&&Te.mutate({featureId:e,kind:`chat`,purpose:`start-lap`}):Ee.mutate({featureId:e})}catch(e){f.push(e instanceof Error?e.message:String(e))}},dt=()=>{Te.mutate({featureId:e,kind:`chat`})},ft=()=>{ot&&xv(ot)?f.push(`This feature is planning itself — stop the run to open the chat.`,`info`):ot?Ce():dt()},pt=t=>{switch(t){case`startDraft`:Le.mutate({featureId:e,baseBranch:ve});break;case`chat`:ft();break;case`selfPlan`:me?ze.mutate({featureId:e,baseBranch:ve}):Re.mutate({featureId:e,kind:`chat`,purpose:`self-plan`});break;case`stopSelfPlan`:lt();break;case`iterate`:ct();break;case`endSessionAndIterate`:lt().then(e=>{e&&ct()});break;case`burn`:F(!0);break;case`cancelRun`:nt&&Ae.mutate({runId:nt.id});break;case`openBurnSettings`:{let e=nt?.summary?Qm(nt.summary):null;e&&p?.(e);break}case`unarchive`:Pe.mutate({featureId:e});break;case`testDriveStart`:Me.mutate({featureId:e,action:`start`},{onSuccess:t=>{Se(),t.ok&&t.branch?s({featureId:e,branch:t.branch}):t.ok||f.push(t.deniedReason??`test drive denied`)}});break;case`testDriveStop`:Me.mutate({featureId:e,action:`stop`},{onSuccess:()=>{Se(),s(null)}});break;case`stopDriveAndIterate`:Me.mutate({featureId:e,action:`stop`},{onSuccess:()=>{Se(),s(null),ct()}});break;case`fixDrive`:je.mutate({featureId:e});break;case`merge`:P(!0);break;case`resolveConflict`:_&&Be.resolve(_,ot?.id);break;default:}},mt=()=>{Ee.mutate({featureId:e},{onSuccess:()=>F(!1)})},ht=()=>{Ne.mutate({featureId:e},{onSuccess:e=>{if(Se(),P(!1),e.ok)s(null),f.push(`merged — feature shipped`,`success`);else if(e.conflict){let t=e.files.length;f.push(t>0?`merge conflict in ${t} file${t===1?``:`s`} — resolve below and retry`:`merge conflict — resolve below and retry`)}}})},gt=ny({full:Ze,phase:it,readonly:et,hasRun:!!nt}),_t=me?`overview`:t,vt=e=>{n(`overview`),i(e)},yt=_t===`overview`&&!me&&ry({full:Ze,phase:it,readonly:et,ticketsIsBody:gt}),bt=!me&&it!==`shipped`,xt=`${e}:${me?`draft`:it}:${_t}`,St=Tv(Ze.sessions),Ct=Qe.status===`shipped`?wv([...g]):null,wt=[me?{phase:`draft`,text:`Parked ${Ih(Qe.createdAt)}`}:Ct?{tone:`success`,text:`Merged ${Ih(Ct)}`}:{text:`Started ${Ih(Qe.createdAt)}`},Qe.status===`archived`&&{tone:`neutral`,text:`Archived`},Qe.lap>1&&{text:`Lap ${Qe.lap}`,title:yv(Qe.lap)}].filter(e=>!!e),Tt=[{key:`copy-link`,label:`Copy link`,onSelect:()=>gF(window.location.origin+Sg({kind:`feature`,projectId:Qe.projectId,featureSlug:Qe.slug}),f)},...!me&&Qe.branch?[{key:`copy-branch`,label:`Copy branch name`,onSelect:()=>gF(Qe.branch,f)}]:[],...Qe.status===`archived`?[{key:`unarchive`,label:`Unarchive`,onSelect:()=>Pe.mutate({featureId:e})}]:Qe.status===`draft`?[]:[{key:`archive`,label:`Archive`,onSelect:()=>Je.mutate({featureId:e})}],...c&&Qe.status!==`shipped`?[{key:`delete`,label:`Delete…`,danger:!0,onSelect:e=>qe(e)}]:[]],Et=et?(0,R.jsx)(U8,{phase:$e,livePhase:Qe.phase,facts:Hy({phase:$e,full:Ze,events:g,decisions:xe}),onBack:()=>vt(null)}):(0,R.jsx)(H8,{ns:at,guidance:a,busy:st,onAction:pt,...it===`planning`||it===`building`?{demote:[`merge`]}:{},draftBranch:me?{branches:he.data?.branches,value:ve||null,detected:he.data?.detected,missing:ye===`unpicked`,onPick:t=>_e({featureId:e,base:t})}:void 0}),Dt=(0,R.jsxs)(I8,{feature:Qe,isDraft:me,steps:tt,readonly:et,facts:wt,onViewPhase:vt,children:[h.message&&(0,R.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md bg-danger-subtle px-3 py-2 text-sm text-danger`,role:`alert`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Resume failed.`}),` `,h.message]}),(0,R.jsx)(UE,{label:`Dismiss`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:h.dismiss})]}),(0,R.jsx)(j8,{isDraft:me,dependsOn:Ze.dependsOn,candidates:Uh(Fe.data??[],Qe,Ze.dependsOn),onChange:t=>Ie.mutateAsync({featureId:e,dependsOn:t})}),(0,R.jsx)(M8,{projectId:Qe.projectId,blocks:Ze.blocks}),Et,_t===`overview`&&!et&&St&&(0,R.jsx)(C8,{featureId:e,line:St,onOpen:()=>n(`chat`)})]}),Ot=me?(0,R.jsx)(wK,{full:Ze}):(0,R.jsx)(X8,{effective:it,full:Ze,events:g,driving:o,conflict:_,runId:nt?.id??null,ticketsIsBody:gt,readonly:et,onViewPhase:vt});return(0,R.jsxs)(`section`,{className:q(G8,`overflow-clip`),"aria-label":Qe.title,children:[(0,R.jsxs)(Cj,{asideClassName:`@max-4xl:top-(--topbar-h)`,aside:We&&(0,R.jsx)(Y6,{featureId:e,onClose:()=>Ge(!1)}),children:[(0,R.jsx)(_j,{crumbs:[{label:Qe.title,icon:(0,R.jsx)(sx,{phase:me?`draft`:Qe.phase,size:14,label:``})}],tabs:(0,R.jsx)(S8,{isDraft:me,value:_t,onChange:n,sessionLive:!!ot}),actions:(0,R.jsxs)(R.Fragment,{children:[Xe&&(0,R.jsx)(HA,{tone:`warning`,className:`mr-2`,title:`The server is unreachable — retrying`,children:`Offline, retrying`}),(0,R.jsx)(yF,{actions:Tt,size:`md`}),(0,R.jsx)(UE,{label:We?`Hide details`:`Show details`,icon:(0,R.jsx)(nb,{}),active:We,onClick:()=>Ge(!We)})]})}),_t===`chat`?null:yt?(0,R.jsxs)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-(--content-wide) min-w-0 flex-1 flex-col px-8 pt-12 animate-rise-in`,children:[(0,R.jsx)(`div`,{className:`shrink-0 pb-5`,children:Dt}),(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 pb-6`,children:Ot})]},xt):(0,R.jsxs)(yj,{width:bt?`wide`:`default`,routeKey:xt,children:[Dt,(0,R.jsx)(`div`,{className:`mt-10`,children:Ot})]}),!me&&(0,R.jsx)(x8,{full:Ze,events:g,hidden:_t!==`chat`,launching:Te.isPending,onLaunch:dt,onView:n})]}),ee&&(0,R.jsx)(dI,{title:Qe.title,branch:Qe.branch,summary:zy({branch:Qe.branch,pendingTickets:u_(Ze.tickets),lap:Ly(Ze.runs),...de?{defaultModel:de}:{},warnings:te.data}),busy:Ee.isPending,warningsPending:!te.data,onConfirm:mt,onCancel:()=>F(!1)}),N&&(0,R.jsx)(cI,{title:Qe.title,branch:Qe.branch,base:b.data?.base,summary:Iy({branch:Qe.branch,...b.data?.base?{base:b.data.base}:{},...b.data?{delta:b.data}:{},tickets:Ze.tickets,lap:Qe.lap,driveLap:v,openNotes:T,...le.data?.projectDrive&&le.data.projectId===Qe.projectId?{projectDrive:{holderLabel:le.data.holderLabel}}:{},freshness:j,conflict:_,laterLaps:oe,burning:nt?.status===`running`}),busy:Ne.isPending,resolving:Be.pending,onConfirm:ht,onResolve:_?()=>void Be.resolve(_,ot?.id??void 0):void 0,onCancel:()=>P(!1)}),Ke&&(0,R.jsx)(bF,{title:Qe.title,slug:Qe.slug,busy:Ye.isPending,onConfirm:()=>Ye.mutate({featureId:e}),onCancel:()=>qe(null),returnFocusRef:Ke}),ne!==null&&(0,R.jsx)(AI,{lap:Qe.lap,notes:w,defects:D,standing:ie.data?.standingFixTickets??[],openedAt:ne,busy:st,readonly:et,sessionLive:!!ot,onCommit:e=>void ut(e),onClose:()=>re(null)})]})}function X8({effective:e,full:t,events:n,driving:r,conflict:i,runId:a,ticketsIsBody:o,readonly:s,onViewPhase:c}){if(s&&e===`planning`)return(0,R.jsx)(_J,{full:t,live:!1,children:(0,R.jsx)(lJ,{full:t,effective:e,events:n})});switch(e){case`planning`:return(0,R.jsx)(_J,{full:t,children:o?(0,R.jsx)(Z3,{featureId:t.feature.id}):(0,R.jsx)(AK,{full:t})});case`building`:return a?(0,R.jsx)(B6,{featureId:t.feature.id,runId:a,readonly:s}):(0,R.jsx)(Z3,{featureId:t.feature.id});case`review`:return(0,R.jsx)(j3,{full:t,driving:r,conflict:i,readonly:s,onViewPhase:c});case`shipped`:return(0,R.jsx)(J3,{full:t})}}function Z8(e){let t=B.useUtils(),n=gx(),r=B.project.sessionBranch.useQuery({projectId:e}),i=B.project.branches.useQuery({projectId:e,includeFeatureBranches:!0}),a=Gy(r.data,i.data?.branches),o=B.settings.update.useMutation({onSuccess:()=>{t.project.sessionBranch.invalidate(),t.settings.get.invalidate()},onError:e=>n.push(e.message)});return{value:a?.value??null,branches:i.data?.branches,detected:r.data?.detected,missing:a?.origin===`vanished`,pick:t=>o.mutate({projectId:e,key:`sessionBranch`,value:t}),picking:o.isPending}}var Q8=10,$8=8;function e5({conversations:e,pending:t,busy:n,onResume:r,onOpen:i,onView:a}){let[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(!1),u=(0,L.useMemo)(()=>[...e].sort((e,t)=>Number(t.status!==`ended`)-Number(e.status!==`ended`)).map(e=>({c:e,title:L3(e.title)})),[e]);if(t)return null;let d=o.trim().toLowerCase(),f=d?u.filter(e=>e.title.toLowerCase().includes(d)):u,p=c||d?f:f.slice(0,Q8),m=f.length-p.length;return(0,R.jsxs)(xj,{title:`Chats`,action:e.length>$8?(0,R.jsx)(fj,{icon:(0,R.jsx)(eb,{}),placeholder:`Filter`,"aria-label":`Filter chats`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Escape`&&s(``)},className:`w-50`}):void 0,children:[e.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(hb,{}),title:`No chats yet`,hint:`A new chat starts from the row above.`}):p.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(eb,{}),title:`No chat matches`,hint:`Nothing titled “${o.trim()}”.`}):(0,R.jsx)(ij,{label:`Chats`,children:p.map(({c:e,title:t},o)=>{let s=e.status!==`ended`;return(0,R.jsx)(rj,{index:o,leading:s?(0,R.jsx)(BA,{tone:`live`,label:e.status}):(0,R.jsx)(hb,{}),title:t,meta:e.createdAt===null?void 0:Fh(e.createdAt),onClick:()=>a(e),actionsOverlay:!0,actions:(0,R.jsx)(UE,{size:`sm`,label:e.resumable?s?`Open`:`Reopen`:`Reopen — this one never got started`,"aria-label":s?`Open`:`Reopen`,icon:s?(0,R.jsx)(Cb,{}):(0,R.jsx)(Gb,{}),disabled:n||!e.resumable,onClick:()=>s?i?.(e.id):r(e.id)})},e.id)})}),m>0&&(0,R.jsxs)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(db,{}),className:`mt-2`,onClick:()=>l(!0),children:[`Show `,m,` more`]})]})}function t5({icon:e,title:t,status:n,hint:r,actions:i,caption:a,children:o,rule:s=!0,className:c}){return(0,R.jsxs)(`div`,{className:q(`py-4`,s&&`border-b border-border-subtle`,c),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`grid size-8 shrink-0 place-items-center rounded-md bg-surface-hover text-icon [&>svg]:size-4`,children:e}),(0,R.jsxs)(`div`,{className:`flex min-w-60 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,R.jsx)(`h2`,{className:`m-0 text-sm font-medium text-text`,children:t}),n]}),(0,R.jsx)(`p`,{className:`m-0 text-sm text-pretty text-text-tertiary`,children:r})]}),(0,R.jsxs)(`div`,{className:`ml-auto flex shrink-0 flex-col items-end gap-1`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:i}),a&&(0,R.jsx)(`span`,{className:`max-w-[32ch] text-right text-xs text-text-tertiary`,children:a})]})]}),o]})}function n5({landing:e,onStart:t,starting:n,openSession:r}){return(0,R.jsx)(t5,{icon:(0,R.jsx)(Db,{}),title:`Talk it through`,hint:`Bring a raw idea; the chat checks it against what’s built and cuts it into features.`,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Jj,{prefix:`landing on`,value:e.value,branches:e.branches,detected:e.detected,missing:e.missing,disabled:e.picking,onPick:e.pick}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(ob,{}),loading:n,disabled:n||e.missing,title:e.missing?`the branch this chat would land on is gone — pick another`:void 0,onClick:t,children:`New chat`})]}),caption:e.missing?`The landing branch is gone — pick another.`:void 0,children:r&&(0,R.jsxs)(`div`,{role:`status`,className:`mt-3 ml-12 flex flex-wrap items-center gap-2 animate-rise-in`,children:[(0,R.jsx)(`span`,{className:`mr-auto text-sm text-text-secondary`,children:`A chat is already open.`}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(hb,{}),onClick:r.onOpen,children:`Open it`}),(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(Gb,{}),loading:n,disabled:n,onClick:r.onReplace,children:`End it and start new`})]})})}function r5({lead:e,when:t,actions:n,className:r,children:i}){return(0,R.jsx)(rj,{as:`li`,animate:!0,wrap:!0,leading:e,title:(0,R.jsx)(`span`,{className:`flex flex-col`,children:i}),meta:t,actions:n,actionsOverlay:!0,className:q(`focus-within:bg-surface-hover hover:bg-surface-hover`,r)})}function i5(){return(0,R.jsx)(`span`,{className:`grid w-10 place-items-center`,"aria-hidden":!0,children:(0,R.jsx)(`i`,{className:`size-1.5 rounded-full bg-text-disabled`})})}function a5({note:e}){let t=Cx(e);return t?(0,R.jsx)(`span`,{className:`mt-0.5 font-mono text-xs text-text-tertiary`,title:t.title,children:t.label}):null}function o5({projectId:e,onTriage:t,triaging:n,reveal:r=!1,onRevealed:i}){let a=B.useUtils(),o=gx(),s=B.projectNotes.list.useQuery({projectId:e},{refetchInterval:Ch()}),c=B.feature.list.useQuery({projectId:e},{refetchInterval:Ch()}),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(``),[p,m]=(0,L.useState)(null),h=e=>o.push(e.message),g=()=>void a.projectNotes.invalidate(),_=B.projectNotes.edit.useMutation({onSuccess:()=>{g(),u(null)},onError:h}),v=B.projectNotes.delete.useMutation({onSuccess:g,onError:h}),y=B.projectNotes.dismiss.useMutation({onSuccess:g,onError:h}),b=B.projectNotes.reopen.useMutation({onSuccess:g,onError:h}),x=s.data??[],S=_.isPending||v.isPending||y.isPending||b.isPending,C=c5(x.filter(e=>e.status===`open`)),w=c5(x.filter(e=>e.status===`triaged`)),T=(0,L.useRef)(null),E=x.length>0;if((0,L.useEffect)(()=>{!r||!T.current||(T.current.scrollIntoView?.({block:`center`}),i?.())},[r,E,i]),!E)return null;let D=e=>{d.trim()&&!_.isPending&&_.mutate({noteId:e,text:d})},O=e=>e.screenshotUrl?(0,R.jsx)(Qj,{size:`sm`,url:e.screenshotUrl,onOpen:m}):(0,R.jsx)(i5,{});return(0,R.jsxs)(`section`,{ref:T,"aria-label":`Notes`,className:`flex flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-4 pt-3 pb-2`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 text-xs text-pretty text-text-tertiary`,children:`Grouped, questioned and routed in a triage chat.`}),(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(Db,{}),className:`shrink-0`,loading:n,disabled:C.length===0||n,title:C.length===0?`nothing is open to triage`:void 0,onClick:t,children:`Triage ${C.length}`})]}),C.length===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(Ab,{}),title:`Inbox clear`,hint:`Every note has been triaged.`}):(0,R.jsx)(`ul`,{className:s5,children:C.map(e=>(0,R.jsx)(r5,{lead:O(e),when:Fh(e.createdAt),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(UE,{size:`sm`,label:`Edit`,icon:(0,R.jsx)(_b,{}),onClick:()=>{u(e.id),f(e.text)}}),(0,R.jsx)(UE,{size:`sm`,label:`Dismiss`,icon:(0,R.jsx)(sb,{}),disabled:S,onClick:()=>y.mutate({noteId:e.id})}),(0,R.jsx)(UE,{size:`sm`,label:`Delete`,icon:(0,R.jsx)(lb,{}),variant:`danger-ghost`,disabled:S,onClick:()=>v.mutate({noteId:e.id})})]}),children:l===e.id?(0,R.jsx)(`input`,{"aria-label":`edit this note`,className:lj,value:d,autoFocus:!0,onChange:e=>f(e.target.value),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),u(null)):t.key===`Enter`&&(t.preventDefault(),D(e.id))}}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-text`,children:e.text}),(0,R.jsx)(a5,{note:e})]})},e.id))}),w.length>0&&(0,R.jsx)(Rj,{title:`${w.length} triaged`,className:`mx-4 mt-2`,children:(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:w.map(t=>(0,R.jsxs)(r5,{lead:t.screenshotUrl?O(t):null,actions:(0,R.jsx)(UE,{size:`sm`,label:`Reopen`,icon:(0,R.jsx)(ub,{}),disabled:S,onClick:()=>b.mutate({noteId:t.id})}),children:[(0,R.jsx)(`span`,{className:`text-text-secondary`,children:t.text}),(0,R.jsx)(a5,{note:t}),(0,R.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-baseline gap-x-2 text-xs text-text-tertiary`,children:[(0,R.jsx)(`span`,{children:t.outcome}),(0,R.jsx)(l5,{projectId:e,feature:c.data?.find(e=>e.id===t.featureId)})]})]},t.id))})}),(0,R.jsx)(pI,{url:p,onClose:()=>m(null)})]})}var s5=`m-0 flex list-none flex-col px-1 py-1`;function c5(e){return[...e].sort((e,t)=>t.createdAt-e.createdAt)}function l5({projectId:e,feature:t}){return t?(0,R.jsx)(`a`,{className:JE,href:Sg({kind:`feature`,projectId:e,featureSlug:t.slug}),children:t.title}):null}function u5({session:e,transcriptId:t,onResume:n,resuming:r=!1,title:i,projectName:a=`Project`,branch:o,hidden:s,onBack:c,onEnded:l,switcher:u}){let d=e?e.ccSessionId??e.id:null;return(0,R.jsxs)(`div`,{className:s?`hidden`:`flex min-h-0 flex-1 flex-col`,"data-live-chat":e?``:void 0,"aria-hidden":s,children:[(0,R.jsx)(_j,{crumbs:[{label:a,icon:(0,R.jsx)(yb,{}),onClick:c},{label:L3(i),icon:(0,R.jsx)(hb,{})}],tabs:u}),(0,R.jsx)(e8,{label:`Project chat`,session:e,contextLine:`Project chat`,meta:(0,R.jsxs)(R.Fragment,{children:[o&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(Cb,{size:14,className:`text-icon`}),`lands on `,(0,R.jsx)(`span`,{className:`font-mono`,children:o})]}),d&&(0,R.jsx)(`span`,{className:`hidden font-mono xl:inline`,title:d,children:d.slice(0,8)})]}),onEnded:l,transcriptId:t,onLaunch:n,launching:r})]})}function d5({projectId:e,startedAt:t,onClose:n}){let r=B.projectNotes.list.useQuery({projectId:e},{refetchInterval:Ch()}),[i,a]=(0,L.useState)(null),{thisDrive:o,alreadyOpen:s}=Sx(r.data??[],t),c=o.length+s.length;return(0,R.jsxs)(Sj,{title:`Notes`,actions:c>0?(0,R.jsxs)(`span`,{className:`pr-1 text-xs text-text-tertiary tabular-nums`,title:`${c} open`,children:[c,` open`]}):void 0,onClose:n,bodyClassName:`flex flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[(0,R.jsx)(f5,{title:`This drive`,children:o.length===0?(0,R.jsx)(p5,{children:`Nothing yet. Select an area of the app, or type below.`}):o.map(e=>(0,R.jsx)(m5,{note:e,onOpen:a},e.id))}),(0,R.jsx)(f5,{title:`Already open`,children:s.length===0?(0,R.jsx)(p5,{children:`No other open notes.`}):s.map(e=>(0,R.jsx)(m5,{note:e,onOpen:a},e.id))})]}),(0,R.jsx)(h5,{projectId:e})]}),(0,R.jsx)(pI,{url:i,onClose:()=>a(null)})]})}function f5({title:e,children:t}){return(0,R.jsxs)(`section`,{"aria-label":e,className:`pt-2`,children:[(0,R.jsx)($A,{className:`px-4`,children:e}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col px-1 py-0`,children:t})]})}function p5({children:e}){return(0,R.jsx)(`li`,{className:`px-3 py-1.5 text-sm text-text-tertiary`,children:e})}function m5({note:e,onOpen:t}){return(0,R.jsxs)(r5,{lead:e.screenshotUrl?(0,R.jsx)(Qj,{size:`sm`,url:e.screenshotUrl,onOpen:t}):(0,R.jsx)(i5,{}),when:Fh(e.createdAt),children:[(0,R.jsx)(`span`,{className:`text-text`,children:e.text}),(0,R.jsx)(a5,{note:e})]})}function h5({projectId:e}){let t=B.useUtils(),n=gx(),r=B.projectNotes.add.useMutation(),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>URL.revokeObjectURL(o?.preview??``),[o]);let d=e=>{let t=ph(e.clipboardData);t&&(e.preventDefault(),mh(t).then(e=>s({png:e,preview:URL.createObjectURL(e)})).catch(e=>n.push(e instanceof Error?e.message:`that image could not be read`)))},f=async()=>{if(!(!i.trim()||c)){l(!0);try{let c=await r.mutateAsync({projectId:e,text:i});if(o)try{await vx(c.id,o.png)}catch(e){n.push(`the note was saved, but its picture was not: ${e instanceof Error?e.message:String(e)}`)}t.projectNotes.invalidate(),a(``),s(null),u.current?.focus()}catch(e){n.push(e instanceof Error?e.message:`the note could not be saved`)}finally{l(!1)}}};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border-subtle p-3`,onPaste:d,children:[(0,R.jsx)(fj,{ref:u,autoComplete:`off`,"aria-label":`New note`,placeholder:`What did you just notice?`,value:i,disabled:c,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())}}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-text-tertiary`,children:[o?(0,R.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-1.5 rounded-md bg-surface-hover pr-0.5 pl-1 text-text-secondary animate-pop-in`,children:[(0,R.jsx)(`img`,{src:o.preview,alt:`the picture this note will carry`,className:`h-4 w-6 rounded-sm bg-surface-inset object-cover`}),`Screenshot`,(0,R.jsx)(UE,{size:`sm`,label:`Remove the picture`,icon:(0,R.jsx)(cb,{}),onClick:()=>s(null)})]}):(0,R.jsx)(`span`,{children:`Paste a screenshot`}),(0,R.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,R.jsx)(Px,{children:`↵`}),` save`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(Px,{children:mM(`J`)}),` anywhere`]})]})]})}function g5({projectId:e,projectName:t=`Project`,repoPath:n,drive:r,hidden:i,onProjectPage:a,onStop:o,stopping:s,onOpenPreparation:c,switcher:l}){let[u,d]=(0,L.useState)(!0),f=Vv(r.state).stageKind,p=f===`failed`?(0,R.jsx)(HA,{tone:`danger`,children:`Setup failed`}):f===`starting`?(0,R.jsx)(HA,{spinning:!0,children:`Starting`}):(0,R.jsx)(HA,{tone:`live`,children:`Running`}),m=(0,R.jsx)(Y,{icon:(0,R.jsx)(Tb,{}),loading:s,disabled:s,onClick:o,children:`Stop drive`}),h=`${n??``}${r.commit?` @ ${r.commit}`:``}`;return(0,R.jsxs)(`div`,{className:i?`hidden`:`flex min-h-0 flex-1 flex-col`,"aria-hidden":i,"data-project-drive":!0,children:[(0,R.jsx)(_j,{crumbs:[{label:t,icon:(0,R.jsx)(yb,{}),onClick:a},{label:`Test drive`,icon:(0,R.jsx)(wb,{})}],tabs:l,actions:(0,R.jsxs)(R.Fragment,{children:[m,(0,R.jsx)(UE,{label:u?`Hide notes`:`Show notes`,icon:(0,R.jsx)(nb,{}),active:u,onClick:()=>d(e=>!e)})]})}),(0,R.jsx)(Cj,{aside:u&&(0,R.jsx)(d5,{projectId:e,startedAt:r.startedAt,onClose:()=>d(!1)}),children:(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4 overflow-y-auto px-6 pt-5 pb-4 animate-fade-in`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,R.jsxs)(`h2`,{className:`m-0 text-lg font-semibold text-text`,children:[`Driving `,(0,R.jsx)(`span`,{className:`font-mono text-base font-medium`,children:r.branch})]}),p]}),(0,R.jsx)(oj,{items:[{icon:(0,R.jsx)(yb,{}),mono:!0,text:h,title:h},{icon:(0,R.jsx)(Kb,{}),mono:!0,text:`project-drive`,title:`the identity this drive runs as`}]})]}),(0,R.jsx)(_5,{projectId:e,drive:r,stop:m,onOpenPreparation:c}),(0,R.jsx)(p4,{branch:r.branch,drive:r})]})})]})}function _5({projectId:e,drive:t,stop:n,onOpenPreparation:r}){let i=Iv(t);switch(Vv(t.state).stageKind){case`failed`:return i?(0,R.jsx)(y5,{children:(0,R.jsx)(f4,{failure:i,explanation:(0,R.jsxs)(R.Fragment,{children:[`Your checkout is as it was, but`,` `,(0,R.jsx)(`code`,{className:`font-mono text-xs`,children:i.command}),` `,i.outcome,` — so whatever it was meant to bring up is probably not running. Preparation is where this project’s drive commands are repaired and proven.`]}),children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Eb,{}),onClick:r,children:`Open preparation`}),n]})})}):(0,R.jsx)(y5,{children:(0,R.jsx)(Fj,{icon:(0,R.jsx)(Vb,{}),title:`The drive’s setup command failed`,hint:`Its output is in the timeline.`})});case`bare`:return(0,R.jsx)(y5,{children:(0,R.jsx)(Fj,{icon:(0,R.jsx)(mb,{}),title:`Setup ran — nothing started.`,hint:(0,R.jsxs)(R.Fragment,{children:[`This project has no dev command ·`,` `,(0,R.jsx)(nI,{location:{page:`project`,field:`devCommand`},children:`Set one in Settings`}),` `,`and the next drive boots the app right here.`]})})});case`panel`:case`agent`:return t.devUrl?(0,R.jsx)(`div`,{className:`flex min-h-100 flex-1 flex-col`,children:(0,R.jsx)(G4,{projectId:e,url:t.devUrl})}):(0,R.jsx)(y5,{children:(0,R.jsx)(Fj,{icon:(0,R.jsx)(Bb,{}),title:`Waiting for an address`,hint:`The dev server is up but has not printed an address yet — its output is under the stage.`})});default:return(0,R.jsx)(y5,{children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center`,children:[(0,R.jsx)(HA,{tone:`live`,size:`sm`,strong:!0,children:`Starting the dev server…`}),(0,R.jsx)(`p`,{className:`m-0 max-w-[52ch] text-sm text-pretty text-text-tertiary`,children:`Your checkout is driven as it is and the project’s dev command is running. The app appears here as soon as it answers — its output is under the stage.`})]})})}}function v5({value:e,chat:t,drive:n,onPick:r}){return(0,R.jsx)(cj,{label:`Project views`,size:`sm`,value:e,onChange:r,items:[{id:`overview`,label:`Overview`,icon:(0,R.jsx)(yb,{})},...t?[{id:`chat`,label:`Live chat`,icon:(0,R.jsx)(hb,{})}]:[],...n?[{id:`drive`,label:`Drive`,icon:(0,R.jsx)(wb,{})}]:[]]})}function y5({children:e}){return(0,R.jsx)(`div`,{className:`flex min-h-65 flex-1 flex-col justify-center rounded-md bg-surface-inset p-6`,children:e})}var b5=`project-drive`;function x5({card:e,branch:t,setupCommand:n,devCommand:r,stopCommand:i,starting:a,onStart:o,onPrepare:s,onReturn:c}){if(e.state===`hidden`)return null;let l=e.state===`running`,u=[{label:`Branch`,value:t??`…`,mono:!0,sub:`your checkout, as it is — no branch switch`},{label:`As`,value:b5,mono:!0},S5(`Setup`,n,`driveSetupCommand`),S5(`Dev`,r,`devCommand`),S5(`Stop`,i,`driveStopCommand`)];return(0,R.jsxs)(`section`,{"aria-label":`Test drive`,children:[(0,R.jsx)(t5,{icon:(0,R.jsx)(wb,{}),title:`Test drive`,status:l?(0,R.jsx)(HA,{tone:`live`,children:`Running`}):void 0,hint:`Run everything that has shipped and jot what you notice. Notes land in the inbox.`,actions:e.state===`prepare`?(0,R.jsx)(Y,{icon:(0,R.jsx)(Eb,{}),onClick:s,children:`Prepare drive`}):l?(0,R.jsx)(Y,{icon:(0,R.jsx)(Cb,{}),onClick:c,children:`Return to drive`}):(0,R.jsx)(Y,{icon:(0,R.jsx)(wb,{}),loading:a,disabled:e.state===`blocked`||a,title:e.state===`blocked`?e.reason:void 0,onClick:o,children:`Test drive`}),caption:e.state===`blocked`?e.reason:e.state===`prepare`?`No setup or dev command yet.`:void 0,rule:!1}),(0,R.jsx)(Rj,{title:`Drive setup`,icon:(0,R.jsx)(mb,{}),aside:(0,R.jsxs)(`span`,{className:`font-mono`,children:[b5,` · `,t??`…`]}),children:(0,R.jsx)(`div`,{className:`rounded-md border border-border-subtle bg-surface-inset px-4 py-3`,children:(0,R.jsx)(aj,{items:u,className:`gap-x-8`})})})]})}function S5(e,t,n){return t?.trim()?{label:e,value:t,mono:!0}:{label:e,value:(0,R.jsxs)(`span`,{className:`font-normal text-text-tertiary`,children:[`Nothing set ·`,` `,(0,R.jsx)(nI,{location:{page:`project`,field:n},children:`Settings`})]})}}function C5(e){let t=B.useUtils(),n=gx(),r=B.feature.driveInfo.useQuery(void 0,{refetchInterval:Ch()}),i=B.project.testDrive.useMutation({onSuccess:()=>void t.feature.driveInfo.invalidate(),onError:e=>n.push(e.message)}),a=r.data??null,o=(t,r)=>i.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok?r?.():n.push(e.deniedReason??`the drive could not ${t}`)}});return{slot:a,drive:bx(a,e)?a:null,start:e=>o(`start`,e),stop:e=>o(`stop`,e),starting:i.isPending&&i.variables?.action===`start`,stopping:i.isPending&&i.variables?.action===`stop`}}function w5({projectId:e,talk:t,newChatRequest:n=0,onConsumeNewChatRequest:r,inboxRequest:i=0,onConsumeInboxRequest:a,empty:o=!1,onOpenPreparation:s,driveRequest:c=0,onConsumeDriveRequest:l}){let u=B.useUtils(),d=B.project.list.useQuery().data?.find(t=>t.id===e),f=Z8(e),p=B.project.branches.useQuery({projectId:e,includeFeatureBranches:!0}),m=C5(e),h=m.drive,g=t.session,[_,v]=(0,L.useState)(null),y=B.projectNotes.list.useQuery({projectId:e},{refetchInterval:Ch()}),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!!(g&&n>0)),[w,T]=(0,L.useState)(`chat`),[E,D]=(0,L.useState)(!!(g&&n>0)),[O,k]=(0,L.useState)(void 0);(0,L.useEffect)(()=>{n>0&&g&&(C(!0),D(!0),k(void 0),r?.())},[n,r,g]),(0,L.useEffect)(()=>{i>0&&(v(null),C(!0),x(!0))},[i]),(0,L.useEffect)(()=>{g||(D(!1),k(void 0))},[g]);let A=g?.id;(0,L.useEffect)(()=>{A&&T(`chat`)},[A]);let j=()=>{v(null),C(!1),T(`drive`)},M=()=>{C(!1),T(`chat`)},N=()=>{T(`chat`),g&&C(!0)};(0,L.useEffect)(()=>{c>0&&(j(),l?.())},[c,l]);let P=_,ee=P!==null||S||!g&&!(h&&w===`drive`),F=!!h&&!ee&&(w===`drive`||!g),I=!!g&&!ee&&!F,te=g||h?(0,R.jsx)(v5,{value:F?`drive`:I?`chat`:`overview`,chat:!!g,drive:!!h,onPick:e=>{e===`overview`?(v(null),N()):e===`chat`?(v(null),M()):j()}}):void 0,ne=e=>{t.resume(e),v(null),M()},re=d?.name??`This project`,ie=(y.data??[]).filter(e=>e.status===`open`).length,ae=(y.data??[]).length>0,oe=ae&&(b??ie>0);return(0,R.jsxs)(`section`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`div`,{className:ee?`flex min-h-0 flex-1 flex-col`:`hidden`,hidden:!ee,children:P?(0,R.jsx)(u5,{session:null,transcriptId:P.id,onResume:P.resumable?()=>ne(P.id):void 0,resuming:t.starting,projectName:re,title:P.title??`project`,branch:f.value,hidden:!1,onBack:()=>v(null)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(_j,{crumbs:[{label:re,icon:(0,R.jsx)(yb,{})}],tabs:te,actions:(0,R.jsx)(R.Fragment,{children:ae&&(0,R.jsx)(UE,{label:`Notes`,badge:ie,icon:(0,R.jsx)(nb,{}),active:oe,onClick:()=>x(!oe)})})}),(0,R.jsx)(Cj,{aside:oe&&(0,R.jsx)(Sj,{title:`Notes`,onClose:()=>x(!1),children:(0,R.jsx)(o5,{projectId:e,triaging:t.starting,reveal:i>0,onRevealed:a,onTriage:()=>{if(!g){t.triage();return}k(`triage`),D(!0)}})}),children:(0,R.jsxs)(yj,{routeKey:`project-${e}`,children:[(0,R.jsx)(bj,{title:re,meta:[{icon:(0,R.jsx)(rb,{}),text:Uy,mono:!0,title:`the branch project chats run on`},f.value?{icon:(0,R.jsx)(Cb,{}),text:`lands on ${f.value}`}:null]}),(0,R.jsxs)(`div`,{className:`mt-8`,children:[(0,R.jsx)(n5,{landing:f,onStart:t.start,starting:t.starting,openSession:g&&E?{onOpen:()=>{D(!1),k(void 0),M()},onReplace:()=>{D(!1),t.replace(O),M()}}:void 0}),(0,R.jsx)(x5,{card:xx({empty:o||!d,setupCommand:d?.driveSetupCommand,devCommand:d?.devCommand,drive:m.slot,projectId:e}),branch:h?.branch??(p.data?.current||null),setupCommand:d?.driveSetupCommand,devCommand:d?.devCommand,stopCommand:d?.driveStopCommand,starting:m.starting,onStart:()=>m.start(j),onPrepare:()=>s?.(),onReturn:j})]}),(0,R.jsx)(e5,{conversations:t.conversations,pending:t.conversationsPending,busy:t.starting,onResume:ne,onOpen:M,onView:e=>e.status===`ended`?v(e):M()})]})})]})}),h&&(0,R.jsx)(g5,{projectId:e,projectName:re,repoPath:d?.repoPath,drive:h,hidden:!F,onProjectPage:N,onStop:()=>m.stop(N),stopping:m.stopping,onOpenPreparation:()=>s?.(),switcher:te}),g&&(0,R.jsx)(u5,{session:g,projectName:re,title:T5(t.conversations,g.id)??`project`,branch:f.value,hidden:!I,switcher:te,onBack:()=>{D(!1),C(!0)},onEnded:()=>{u.project.projectSession.invalidate(),u.project.conversations.invalidate()}})]})}function T5(e,t){return e.find(e=>e.id===t)?.title??null}function E5({dirty:e,onDismiss:t,children:n}){return(0,R.jsx)(Hj,{open:!0,onClose:t,dirty:e,inline:!0,labelledBy:`park-draft-title`,backdropClassName:`min-h-0 overflow-y-auto bg-surface`,className:`max-w-[560px]`,children:n})}function D5({title:e,slug:t,oneLiner:n,notes:r,duplicate:i,busy:a,ready:o,onTitleChange:s,onOneLinerChange:c,onNotesChange:l,onSubmit:u,onCancel:d}){let f=()=>u(r.trim()||void 0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{id:`park-draft-title`,title:`Park it for later`,description:`Write it down now, work it out later. Nothing is cut until you Start it.`,onClose:d}),(0,R.jsxs)(Wj,{className:`flex flex-col gap-4 pt-1`,children:[(0,R.jsx)(hj,{label:`Title`,error:i,children:(0,R.jsx)(fj,{value:e,onChange:e=>s(e.target.value),placeholder:`e.g. Slack alerts on failed runs`,autoFocus:!0,invalid:!!i,onKeyDown:e=>{e.key===`Enter`&&f()}})}),(0,R.jsx)(hj,{label:`One-liner (optional)`,children:(0,R.jsx)(fj,{value:n,onChange:e=>c(e.target.value),placeholder:`What and why, in a sentence`,onKeyDown:e=>{e.key===`Enter`&&f()}})}),(0,R.jsx)(hj,{label:`Notes (optional — becomes the brief)`,children:(0,R.jsx)(mj,{rows:5,value:r,onChange:e=>l(e.target.value),placeholder:`Anything Start should know`})})]}),(0,R.jsxs)(Gj,{className:`mt-2 border-t border-border-subtle pt-4`,start:(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(rb,{size:14,className:`shrink-0 text-icon`}),(0,R.jsxs)(`span`,{className:`truncate font-mono`,children:[`feature/`,t||`…`,` · draft`]})]}),children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:d,disabled:a,children:`Cancel`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(gb,{}),onClick:f,disabled:!o||a,children:a?`Parking…`:`Park draft`})]})]})}function O5({projectId:e,onCancel:t,onCreated:n}){let[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),l=B.useUtils(),u=gx(),d=e_(r,B.feature.list.useQuery({projectId:e},{refetchInterval:Ch()}).data??[]),f=async e=>{await l.feature.list.invalidate(),n(e)},p=B.feature.create.useMutation({onSuccess:e=>void f(e.id),onError:e=>u.push(e.message)}),m=p.isPending,h=!!r.trim(),g=!!r.trim()||!!a.trim()||!!s.trim(),_=t=>{!h||m||p.mutate({projectId:e,title:r.trim(),oneLiner:a.trim(),draft:!0,...t?{brief:t}:{}})};return(0,R.jsx)(E5,{dirty:g,onDismiss:t,children:e=>(0,R.jsx)(D5,{title:r,slug:$g(r),oneLiner:a,notes:s,duplicate:d,busy:m,ready:h,onTitleChange:i,onOneLinerChange:o,onNotesChange:c,onSubmit:_,onCancel:e})})}var k5=`Repo facts an agent establishes once — how to install, how to verify, what is already red — so no burn agent re-derives them per ticket.`;function A5({projectId:e,onClose:t}){let n=B.useUtils(),r=gx(),i=B.project.list.useQuery().data?.find(t=>t.id===e),a=B.project.prep.useQuery({projectId:e},{refetchInterval:Ch(3e3)}),o=B.project.prepSession.useQuery({projectId:e},{refetchInterval:Ch()}),s=B.project.talkToPrep.useMutation({onSuccess:()=>void n.project.prepSession.invalidate(),onError:e=>r.push(e.message)}),c=B.project.dryRunStop.useMutation({onSuccess:()=>{n.project.prep.invalidate(),n.feature.driveInfo.invalidate()},onError:e=>r.push(e.message)}),[l,u]=(0,L.useState)(!1),d=a.data,f=o.data??null,p=d?.findings??[],m=d?.pendingKeys??[],h=p.filter(im).length,g=f?f.ccSessionId??f.id:``;return(0,R.jsxs)(`section`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(_j,{crumbs:[{label:i?.name??`This project`,icon:(0,R.jsx)(yb,{}),...t?{onClick:t}:{}},{label:`Preparation`,icon:(0,R.jsx)(Eb,{})}],actions:f?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mr-2 hidden items-center gap-4 text-xs text-text-tertiary md:flex`,children:[(0,R.jsx)(HA,{tone:f.status===`live`?`live`:`accent`,children:R3(A_(f))}),(0,R.jsx)(`span`,{className:`font-mono`,title:g,children:g.slice(0,8)})]}),(0,R.jsx)($6,{sessionId:f.id,onEnded:()=>{n.project.prepSession.invalidate(),n.project.prep.invalidate()}}),p.length>0&&(0,R.jsx)(UE,{label:l?`Hide what is established`:`Show what is established`,icon:(0,R.jsx)(nb,{}),active:l,onClick:()=>u(e=>!e)})]}):void 0}),d?.dryRun&&(0,R.jsx)(P5,{open:Mv(d.dryRun),stopping:c.isPending,onStop:()=>c.mutate({projectId:e})}),f?(0,R.jsx)(Cj,{aside:l&&p.length>0&&(0,R.jsx)(Sj,{title:`Established`,onClose:()=>u(!1),bodyClassName:`px-4 py-3`,children:(0,R.jsx)(N5,{findings:p,staleCount:h,compact:!0})}),children:(0,R.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 bg-surface-inset animate-fade-in`,children:(0,R.jsx)(LJ,{label:`terminal`,children:(0,R.jsx)(c4,{sessionId:f.id})})})}):(0,R.jsxs)(yj,{routeKey:`prepare-${e}`,children:[a.isLoading&&(0,R.jsx)(j5,{}),a.error&&(0,R.jsx)(Fj,{icon:(0,R.jsx)(Vb,{}),title:`Could not load preparation`,hint:a.error.message}),d&&(0,R.jsx)(M5,{prepared:d.prepared,preparedAt:d.preparedAt,pending:m,findings:p,staleCount:h,starting:s.isPending,onStart:()=>s.mutate({projectId:e}),onStartFresh:()=>s.mutate({projectId:e,fresh:!0})})]})]})}function j5(){return(0,R.jsxs)(Oj,{label:`Loading preparation…`,children:[(0,R.jsx)(`div`,{className:`flex h-7 items-center`,"data-skeleton":`title`,children:(0,R.jsx)(kj,{className:`h-5 w-3/5`})}),(0,R.jsx)(`div`,{className:`mt-2 flex h-5 items-center`,children:(0,R.jsx)(kj,{className:`h-2.5 w-32`})}),(0,R.jsxs)(`div`,{className:`mt-5 max-w-[60ch]`,"data-skeleton":`sentence`,children:[(0,R.jsx)(`div`,{className:`flex h-[22px] items-center`,children:(0,R.jsx)(kj,{className:`h-3 w-full`})}),(0,R.jsx)(`div`,{className:`flex h-[22px] items-center`,children:(0,R.jsx)(kj,{className:`h-3 w-3/4`})})]}),(0,R.jsx)(kj,{className:`mt-6 h-(--control-h) w-40 rounded-md`}),(0,R.jsx)(`div`,{className:`mt-2 flex h-4 max-w-[60ch] items-center`,children:(0,R.jsx)(kj,{className:`h-2.5 w-5/6`})})]})}function M5({prepared:e,preparedAt:t,pending:n,findings:r,staleCount:i,starting:a,onStart:o,onStartFresh:s}){let c=r.length>0,l=[e&&{icon:(0,R.jsx)(Bb,{}),text:t===null?`No preparation conversation on record`:`Prepared ${Qp(t)}`},!e&&n.length>0&&{strong:n.length,text:`to establish`},c&&{strong:r.length,text:`established`},i>0&&{tone:`warning`,strong:i,text:`stale`}];return e?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(bj,{title:`Re-prepare this project`,meta:l,children:[(0,R.jsxs)(`p`,{className:`m-0 max-w-[60ch] text-base text-pretty text-text-secondary`,children:[t===null&&`Every field already had a value. `,k5,` Repo facts drift; re-preparing measures them again with you there.`]}),(0,R.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Gb,{}),loading:a,disabled:a,onClick:o,children:`Resume`}),(0,R.jsx)(Y,{icon:(0,R.jsx)(ob,{}),disabled:a,onClick:s,children:`Start fresh`})]}),(0,R.jsx)(`p`,{className:`mt-2 mb-0 max-w-[60ch] text-xs text-pretty text-text-tertiary`,children:`Resume continues your last preparation conversation; Start fresh opens one that has never seen it — values you typed by hand are never overwritten.`})]}),(0,R.jsx)(N5,{findings:r,staleCount:i})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(bj,{title:c?`Finish preparing this project`:`Prepare this project first`,meta:l,children:[(0,R.jsx)(`p`,{className:`m-0 max-w-[60ch] text-base text-pretty text-text-secondary`,children:k5}),(0,R.jsx)(`div`,{className:`mt-6 flex flex-wrap items-center gap-2`,children:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(wb,{}),loading:a,disabled:a,onClick:o,children:`Start preparation`})}),(0,R.jsx)(`p`,{className:`mt-2 mb-0 max-w-[60ch] text-xs text-pretty text-text-tertiary`,children:`Opens a terminal session here with an agent in your own checkout — it runs this repo's commands, records the answers, and asks you the ones only you know.`})]}),n.length>0&&(0,R.jsx)(xj,{title:`To establish`,children:(0,R.jsx)(ij,{divided:!0,label:`To establish`,children:n.map((e,t)=>(0,R.jsx)(rj,{index:t,leading:(0,R.jsx)(qb,{}),title:Xp[e]??e,meta:`Not yet`},e))})}),(0,R.jsx)(N5,{findings:r,staleCount:i})]})}function N5({findings:e,staleCount:t,compact:n=!1}){if(e.length===0)return null;let r=(0,R.jsxs)(R.Fragment,{children:[t>0&&(0,R.jsx)(F5,{count:t}),(0,R.jsx)(I5,{findings:e})]});return n?r:(0,R.jsx)(xj,{title:`Established`,children:r})}function P5({open:e,stopping:t,onStop:n}){return(0,R.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-3 border-b border-border-subtle px-4 animate-fade-in`,children:[(0,R.jsx)(HA,{tone:`live`,size:`sm`,strong:!0,children:`Preparation dry run in progress`}),e&&(e.state===`ready`?(0,R.jsxs)(`a`,{className:q(`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,`inline-flex min-w-0 items-center gap-1 truncate font-mono text-xs`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.url,(0,R.jsx)(Pb,{size:12,className:`shrink-0`})]}):(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-tertiary`,children:Nv(e)})),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Tb,{}),loading:t,disabled:t,onClick:n,children:`Stop`})]})}function F5({count:e}){return(0,R.jsxs)(`div`,{className:`mb-4 flex max-w-[64ch] items-start gap-2 text-sm text-pretty text-text-secondary`,children:[(0,R.jsx)(Vb,{size:16,className:`mt-0.5 shrink-0 text-warning`}),(0,R.jsxs)(`span`,{children:[e,` finding`,e===1?` has`:`s have`,` not been re-measured in a long time. A stale test baseline is worse than none — agents trust it and file their own breakage under “already red on main”.`]})]})}function I5({findings:e}){return(0,R.jsx)(`div`,{className:`flex flex-col [&>details:last-child]:border-b [&>details:last-child]:border-border-subtle`,children:e.map((e,t)=>(0,R.jsx)(L5,{finding:e,label:Xp[e.key]??e.key,index:t},e.key))})}function L5({finding:e,label:t,index:n}){let[r,i]=(0,L.useState)(!1),a=am(e),o=im(e);return(0,R.jsx)(Rj,{title:t,index:n,aside:(0,R.jsxs)(`span`,{className:`flex items-center gap-4`,children:[o&&(0,R.jsx)(HA,{tone:`warning`,children:`Stale`}),(0,R.jsx)(R5,{finding:e}),(0,R.jsx)(HA,{title:a.title,children:a.label})]}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`div`,{className:q(`text-xs`,o?`text-warning`:`text-text-tertiary`),children:tm(e)}),e.evidence&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`rounded-md border border-border-subtle bg-surface-inset px-3 py-2`,children:(0,R.jsx)(`div`,{className:q(`font-mono text-xs leading-[1.5] break-words whitespace-pre-wrap text-text-secondary`,!r&&`line-clamp-3`),children:e.evidence})}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,className:`-ml-2 self-start`,onClick:()=>i(e=>!e),"aria-expanded":r,"aria-label":`${r?`Collapse`:`Show full`} evidence for ${t}`,children:r?`Show less`:`Show full evidence`})]})]})})}function R5({finding:e}){return $p(e.key)?e.verifiedAt===void 0?(0,R.jsx)(HA,{tone:`warning`,title:`No dry run has ever proven this value — a drive that depends on it may fall over`,children:`Unproven`}):(0,R.jsxs)(HA,{tone:`success`,icon:(0,R.jsx)(sb,{size:14}),title:`A preparation dry run ran this value on the real drive machinery and it worked`,children:[`Proven `,Qp(e.verifiedAt)]}):null}var z5=(e,t)=>e===``||t.includes(e);function B5(e){let{open:t,onClose:n,features:r,selectedFeatureId:i,onSelect:a,onOpenSettings:o,onOpenPreparation:s,onOpenProjectChat:c,onOpenNote:l,onToggleSidebar:u,onToggleDetails:d,nav:f}=e,p=KM(),[m,h]=(0,L.useState)(``),[g,_]=(0,L.useState)(0),v=(0,L.useRef)(null),y=(0,L.useRef)([]);(0,L.useEffect)(()=>{if(!t)return;h(``),_(0),v.current?.focus();let e=requestAnimationFrame(()=>v.current?.focus());return()=>cancelAnimationFrame(e)},[t]),(0,L.useEffect)(()=>{if(!t)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]),(0,L.useEffect)(()=>{_(0)},[m]);let b=m.trim().toLowerCase(),x=(0,L.useMemo)(()=>b===``?r:r.filter(e=>e.slug.toLowerCase().includes(b)||e.title.toLowerCase().includes(b)),[r,b]),S=(0,L.useMemo)(()=>(f.projects??[]).filter(e=>e.id!==f.currentProjectId),[f.projects,f.currentProjectId]),C=(0,L.useMemo)(()=>b===``?S:S.filter(e=>e.name.toLowerCase().includes(b)),[S,b]),w=(0,L.useMemo)(()=>{let e=p.resolved===`dark`?`light`:`dark`;return[{kind:`projectChat`,shows:Qy(b),glyph:(0,R.jsx)(zb,{}),label:`Project chat`,run:c},{kind:`newNote`,shows:z5(b,`new note jot capture`),glyph:(0,R.jsx)(_b,{}),label:`New note`,kbd:mM(`J`),run:l},{kind:`preparation`,shows:Zy(b),glyph:(0,R.jsx)(Eb,{}),label:`Preparation`,run:s},{kind:`settings`,shows:z5(b,`settings preferences`),glyph:(0,R.jsx)(tb,{}),label:`Settings`,run:o},{kind:`theme`,shows:z5(b,`toggle theme dark light appearance ${e}`),glyph:p.resolved===`dark`?(0,R.jsx)(Ib,{}):(0,R.jsx)(Lb,{}),label:`Toggle theme — switch to ${e}`,run:p.toggle},...u?[{kind:`sidebar`,shows:z5(b,`toggle sidebar hide show collapse expand`),glyph:(0,R.jsx)(Mb,{}),label:`Toggle sidebar`,kbd:mM(`B`),run:u}]:[],...d?[{kind:`details`,shows:z5(b,`toggle details panel inspector hide show`),glyph:(0,R.jsx)(nb,{}),label:`Toggle details panel`,run:d}]:[],{kind:`home`,shows:z5(b,`all projects home`),glyph:(0,R.jsx)(yb,{}),label:`All projects`,run:f.goHome},{kind:`openProject`,shows:z5(b,`open a project`),glyph:(0,R.jsx)(ob,{}),label:`Open a project…`,run:f.showOpen}].filter(e=>e.shows)},[b,p.resolved,p.toggle,c,l,o,s,u,d,f]),T=(0,L.useMemo)(()=>{let e=x.map(e=>({kind:`feature`,feature:e}));for(let t of C)e.push({kind:`project`,id:t.id,name:t.name});for(let t of w)e.push({kind:`action`,action:t});return e},[x,C,w]);if(!t)return null;let E=e=>{if(T.length===0)return;let t=(g+e+T.length)%T.length;_(t),y.current[t]?.scrollIntoView({block:`nearest`})},D=e=>{let t=T[e];if(t){switch(t.kind){case`feature`:a(t.feature.id);break;case`project`:f.enterProject(t.id);break;case`action`:t.action.run();break}n()}},O=e=>{e.key===`ArrowDown`?(e.preventDefault(),E(1)):e.key===`ArrowUp`?(e.preventDefault(),E(-1)):e.key===`Enter`?(e.preventDefault(),D(g)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=x.length,A=k+C.length,j=(e,t,n,r,i,a)=>(0,R.jsxs)(`div`,{ref:t=>{y.current[e]=t},role:`option`,"aria-selected":e===g,"data-selected":e===g,className:q(kx,Ax,`min-h-8 hover:bg-transparent`),onMouseMove:()=>e!==g&&_(e),onClick:()=>D(e),children:[(0,R.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center [&>svg]:size-4`,children:n}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:r}),i]},t),M=e=>(0,R.jsx)(`div`,{className:q(Mx,`pt-2.5`),children:e});return(0,R.jsx)(`div`,{className:`fixed inset-0 z-[300] flex animate-backdrop-in items-start justify-center bg-scrim px-4 pt-[12vh] pb-4`,onMouseDown:e=>{e.target===e.currentTarget&&n()},children:(0,R.jsxs)(`div`,{role:`dialog`,"aria-label":`Command palette`,className:`flex max-h-[min(520px,76vh)] w-full max-w-[560px] animate-dialog-in flex-col overflow-hidden rounded-lg bg-surface-raised text-text shadow-dialog`,children:[(0,R.jsxs)(`div`,{className:`flex h-13 shrink-0 items-center gap-3 border-b border-border-subtle px-4`,children:[(0,R.jsx)(eb,{size:16,className:`shrink-0 text-icon`}),(0,R.jsx)(`input`,{ref:v,className:`h-full min-w-0 flex-1 border-0 bg-transparent p-0 font-sans text-base text-text outline-none placeholder:text-text-tertiary`,placeholder:`Search features, projects, or jump to…`,value:m,onChange:e=>h(e.target.value),onKeyDown:O,"aria-label":`Search features, projects, or jump to`})]}),(0,R.jsxs)(`div`,{role:`listbox`,"aria-label":`Results`,className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:[x.length>0&&M(`Features`),x.map((e,t)=>j(t,e.id,(0,R.jsx)(sx,{phase:e.status===`draft`?`draft`:e.phase,label:``}),e.title,(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-text-tertiary`,children:[e.id===i&&(0,R.jsx)(`span`,{className:`text-text-secondary`,children:`Current`}),(0,R.jsx)(`span`,{children:e.status===`draft`?ix.draft:ix[e.phase]})]}),e.title)),C.length>0&&M(`Projects`),C.map((e,t)=>j(k+t,e.id,(0,R.jsx)(yb,{className:`text-icon`}),e.name,(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-text-tertiary`,children:`Switch`}),e.name)),w.length>0&&M(`Actions`),w.map((e,t)=>j(A+t,e.kind,e.glyph,e.label,e.kbd?(0,R.jsx)(Px,{children:e.kbd}):null,e.label)),T.length===0&&(0,R.jsx)(`div`,{className:`p-6 text-center text-sm text-text-tertiary`,children:`No matches`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4 border-t border-border-subtle px-4 py-2 text-xs text-text-tertiary`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`↑`}),(0,R.jsx)(Px,{children:`↓`}),` to move`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`Enter`}),` to open`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`Esc`}),` to close`]})]})]})})}var V5=1500,H5=`flex h-13 items-center gap-3 px-4`,U5=160;function W5(e){let t=e.style.height;e.style.height=`auto`;let n=e.scrollHeight;e.style.height=t,e.offsetHeight,e.style.height=`${Math.min(n,U5)}px`,e.style.overflowY=n>U5?`auto`:`hidden`}function G5({projectId:e,projectName:t,open:n,openRequest:r=0,onClose:i,onOpenInbox:a}){let o=B.useUtils(),s=gx(),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(null),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(!1),g=(0,L.useRef)(null),_=(0,L.useRef)(0),v=()=>{l(``),d(null),p(!1),h(!1)},[y,b]=(0,L.useState)(n);n!==y&&(b(n),_.current+=1,n&&v());let[x,S]=(0,L.useState)(r);r!==x&&(S(r),n&&m&&v()),(0,L.useEffect)(()=>{n&&g.current?.focus()},[r]),(0,L.useLayoutEffect)(()=>{g.current&&W5(g.current)},[c,n,m]);let C=B.projectNotes.add.useMutation(),w=B.projectNotes.openCount.useQuery({projectId:e},{enabled:n}),T=(0,L.useRef)(null);(0,L.useEffect)(()=>{T.current=u?.preview??null},[u]),(0,L.useEffect)(()=>{if(n)return()=>{T.current&&URL.revokeObjectURL(T.current)}},[n]);let E=(0,L.useRef)(i);E.current=i,(0,L.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>E.current(),V5);return()=>clearTimeout(e)},[m]);let D=async e=>{try{let t=await mh(e),n={png:t,preview:URL.createObjectURL(t)};d(e=>(e&&URL.revokeObjectURL(e.preview),n))}catch(e){s.push(e instanceof Error?e.message:`that image could not be read`)}},O=()=>{d(e=>(e&&URL.revokeObjectURL(e.preview),null)),g.current?.focus()},k=e=>{let t=ph(e.clipboardData);t&&(e.preventDefault(),D(t))},A=async()=>{if(!c.trim()||f)return;let t=_.current,n=()=>_.current===t;p(!0);try{let t=await C.mutateAsync({projectId:e,text:c});if(u)try{await vx(t.id,u.png)}catch(e){s.push(`the note was saved, but its picture was not: ${e instanceof Error?e.message:String(e)}`)}o.projectNotes.openCount.setData({projectId:e},e=>e===void 0?e:e+1),o.projectNotes.invalidate(),n()&&h(!0)}catch(e){s.push(e instanceof Error?e.message:`the note could not be saved`)}finally{n()&&p(!1)}};return(0,R.jsx)(Hj,{open:n,onClose:i,size:`palette`,scrim:m?`none`:`light`,className:`overflow-hidden`,label:`Jot a note`,initialFocusRef:g,children:m?(0,R.jsxs)(`div`,{className:q(H5,`text-sm animate-fade-in`),role:`status`,children:[(0,R.jsx)(`span`,{className:`flex shrink-0 items-center text-success`,children:(0,R.jsx)(sb,{size:16})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:[`Noted in `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:t}),w.data!==void 0&&(0,R.jsxs)(R.Fragment,{children:[` · `,w.data,` open`]})]}),(0,R.jsx)(`button`,{className:q(JE,`text-sm`),onClick:()=>{a(),i()},title:`Read the pile on the project workspace`,children:`View`})]}):(0,R.jsxs)(`div`,{onPaste:k,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border-subtle px-4`,children:[(0,R.jsx)(`span`,{className:`flex h-13 shrink-0 items-center text-icon`,children:(0,R.jsx)(_b,{size:16})}),(0,R.jsx)(`textarea`,{ref:g,rows:1,className:`box-border block min-w-0 flex-1 resize-none border-0 bg-transparent px-0 py-3.75 font-sans text-base text-text outline-none transition-[height] duration-(--dur-2) ease-app placeholder:text-text-tertiary`,autoComplete:`off`,"aria-label":`what did you just notice?`,placeholder:`What did you just notice?`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),A())}})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-2 text-xs text-text-tertiary`,children:[u?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-text-secondary animate-fade-in`,children:[(0,R.jsx)(`img`,{src:u.preview,alt:`the picture this note will carry`,className:`h-5 w-8 rounded-sm bg-surface-inset object-cover`}),`Screenshot`,(0,R.jsx)(UE,{size:`sm`,label:`Remove the picture`,icon:(0,R.jsx)(cb,{}),onClick:O})]}):(0,R.jsx)(`span`,{children:`Paste a screenshot`}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsxs)(`span`,{children:[`to `,(0,R.jsx)(`span`,{className:`font-medium text-text-secondary`,children:t})]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`↵`}),` save`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`⇧↵`}),` new line`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Px,{children:`esc`}),` close`]})]})]})})}var K5={"claude-code":{check:`afk-key`,kind:`token`},codex:{check:`auth`,kind:`sign-in`}};function q5(e){return sd.flatMap(t=>{let{check:n,kind:r}=K5[t],i=e.find(e=>e.runtime===t&&e.check===n);return i?[{runtime:t,kind:r,probe:i}]:[]})}function J5(e){return`${K5[e].check}-${e}`}function Y5(e){let t=sm[e],n=K5[e].kind===`token`;return{field:J5(e),label:n?`${t} token`:t,reason:n?`burns with ${t} need a token`:`sign in to ${t}`,terms:n?[t,`token`,`AFK credential`]:[t,`sign in`,`login`]}}var X5=[{field:`container-runtime`,label:`Container runtime`,reason:`no container runtime on this machine`,terms:[`Container runtime`,`Docker`,`Podman`]},{field:`sandcastle-image`,label:`Sandcastle image`,reason:`the sandcastle image needs building`,terms:[`Sandcastle image`,`build`,`rebuild`]},...sd.map(Y5),{field:`burn-cache`,label:`Burn cache`,terms:[`Burn cache`,`volume`,`clear`]}];function Z5(e){let t=e.find(e=>!e.ok);return t?{count:`${e.filter(e=>e.ok).length} of ${e.length}`,text:`ready — ${t.reason}`}:{count:null,text:`Ready for unattended burns`}}var Q5=[{page:`general`,label:`General`,Icon:tb},{page:`models`,label:`Models`,Icon:bb},{page:`burns`,label:`Burns`,Icon:xb},{page:`project`,label:`This project`,Icon:yb}];function $5({page:e,filter:t,filterRef:n,projectName:r,onFilter:i,onSelect:a}){let o=t.query.trim()!==``;return(0,R.jsxs)(`nav`,{"aria-label":`Settings pages`,className:`flex min-h-0 flex-col gap-0.5 border-r border-border-subtle bg-canvas px-2 pt-4 pb-3`,children:[(0,R.jsx)(`div`,{className:`mb-2 px-2.5 text-sm font-medium text-text`,children:`Settings`}),(0,R.jsx)(pj,{ref:n,size:`md`,"aria-label":`Filter settings`,placeholder:`Filter`,kbd:`Ctrl F`,autoComplete:`off`,value:t.query,onChange:e=>i(e.target.value),className:`mb-3`}),Q5.map(({page:n,label:r,Icon:i})=>(0,R.jsx)(nj,{label:r,icon:(0,R.jsx)(i,{}),active:n===e,onClick:()=>a(n),meta:o?t.counts[n]||``:void 0},n)),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 px-2.5 pt-3`,children:[(0,R.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:`This project is`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-xs text-text-secondary`,title:r,children:r})]})]})}var e7=1500;function t7(e){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{if(!e)return;t.current?.scrollIntoView?.({block:`center`}),r(!0);let n=setTimeout(()=>r(!1),e7);return()=>clearTimeout(n)},[e]),{ref:t,flash:n}}function n7(e,t){return e.query.trim()===``||e.matches.has(t)}var r7=1400;function i7({title:e,rows:t,projectId:n,filter:r,highlightField:i,onOpenEvidence:a,evidence:o}){let s=t.filter(e=>n7(r,e.key));return s.length===0?null:(0,R.jsx)(o7,{title:e,children:s.map(e=>(0,R.jsx)(c7,{row:e,projectId:n,highlight:i===e.key,...a&&e.provenanceChip?.evidence?{onOpenEvidence:()=>a(e.key)}:{},...o?{evidence:o(e)}:{}},e.key))})}function a7({groups:e,className:t}){return(0,R.jsx)(Oj,{label:`Loading settings…`,className:t,children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`mt-9 first:mt-0`,children:[(0,R.jsx)(`div`,{className:`flex min-h-7 items-center border-b border-border-subtle pb-2`,children:(0,R.jsx)(kj,{className:`h-3 w-16`})}),e.map((e,t)=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,300px)] items-start gap-x-8 border-b border-border-subtle py-4 last:border-b-0`,"data-skeleton":`setting-row`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 pt-1`,children:[(0,R.jsx)(kj,{className:q(`h-3`,e)}),(0,R.jsx)(kj,{className:`h-2.5 w-4/5`})]}),(0,R.jsx)(kj,{className:`h-(--control-h) w-full rounded-md`})]},t))]},t))})}function o7({title:e,action:t,description:n,children:r}){return(0,R.jsxs)(`section`,{className:`mt-9 first:mt-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-7 items-center gap-3 border-b border-border-subtle pb-2`,children:[(0,R.jsx)(`h3`,{className:`m-0 min-w-0 flex-1 text-sm font-medium text-text`,children:e}),t&&(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:t})]}),n&&(0,R.jsx)(`div`,{className:`mt-2.5 text-xs text-pretty text-text-tertiary`,children:n}),(0,R.jsx)(`div`,{children:r})]})}function s7({label:e,htmlFor:t,description:n,descriptionId:r,aside:i,control:a,below:o,stacked:s=!1,flash:c=!1,rowRef:l}){return(0,R.jsxs)(`div`,{ref:l,className:q(`border-b border-border-subtle py-4 last:border-b-0`,`transition-[outline-color] duration-(--dur-3) ease-app`,s?`flex flex-col gap-2.5`:`grid grid-cols-[minmax(0,1fr)_minmax(0,300px)] items-start gap-x-8 gap-y-1.5`,c&&`rounded-md outline-2 outline-offset-4 outline-accent`),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 pt-1`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-5 items-center gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:t,className:`text-sm font-medium text-text`,children:e}),i]}),n&&(0,R.jsx)(`p`,{id:r,className:`m-0 text-xs text-pretty text-text-tertiary`,children:n})]}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[a,o]})]})}function c7({row:e,projectId:t,highlight:n,onOpenEvidence:r,evidence:i}){let a=B.useUtils(),o=e.ghostValue?``:e.value,[s,c]=(0,L.useState)(o),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(!1),{ref:h,flash:g}=t7(n),_=(0,L.useRef)(void 0);(0,L.useEffect)(()=>c(o),[o]),(0,L.useEffect)(()=>()=>clearTimeout(_.current),[]);let v=B.settings.update.useMutation({onSuccess:()=>{u(null),f(!0),clearTimeout(_.current),_.current=setTimeout(()=>f(!1),r7),e.restartRequired&&m(!0),a.settings.get.invalidate(),a.project.prep.invalidate()},onError:e=>{c(o),u(e.message)}}),y=e=>{c(e),l&&u(null)},b=n=>{u(null),v.mutate({...t?{projectId:t}:{},key:e.key,value:n})},x=t=>{if(t.trim()===o.trim())return;let n=Em(e.control,t);if(`error`in n){u(n.error);return}b(n.value)},S=()=>b(null),C=`set-${t?`project`:`global`}-${e.key}`,w=`${C}-help`,T=`${C}-error`,E=`${C}-about`,D=q(E,e.shortHelp?w:null,l?T:null)||void 0,O=e.sourceChip||e.clearable||e.provenanceChip;return(0,R.jsx)(s7,{rowRef:h,flash:g,stacked:e.control===`textarea`,label:e.label,htmlFor:C,description:e.tooltip||void 0,descriptionId:E,aside:d&&(0,R.jsx)(l7,{}),control:(0,R.jsx)(u7,{id:C,describedBy:D,row:e,draft:s,disabled:v.isPending,onDraft:y,onCommit:x,onRevert:()=>c(o)}),below:(0,R.jsxs)(R.Fragment,{children:[e.shortHelp&&(0,R.jsx)(`div`,{id:w,className:`text-xs text-text-tertiary`,children:e.shortHelp}),O&&(0,R.jsxs)(`div`,{className:`flex min-h-5 flex-wrap items-center gap-x-3 gap-y-1`,children:[e.sourceChip&&(0,R.jsx)(f7,{kind:e.sourceChip,envVar:om[e.key]}),e.sourceChip===`project`&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:S,className:`-ml-1.5`,children:`Use global`}),e.clearable&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:S,className:`-ml-1.5`,children:`Clear`}),e.provenanceChip&&(0,R.jsxs)(`div`,{className:`relative flex min-w-0`,children:[(0,R.jsx)(m7,{chip:e.provenanceChip,onOpenEvidence:r}),i]}),e.stale&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-warning`,title:`Measured a long time ago — “Re-prepare the project”, at the foot of the features rail, refreshes it`,children:[(0,R.jsx)(BA,{tone:`warning`}),`Stale`]})]}),p&&(0,R.jsx)(`div`,{className:`text-xs text-warning`,children:`Restart the server to apply`}),l&&(0,R.jsx)(`div`,{id:T,role:`alert`,className:`text-xs text-danger`,children:l})]})})}function l7(){return(0,R.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-text-tertiary animate-fade-in`,children:[(0,R.jsx)(sb,{size:12,className:`text-success`}),`Saved`]})}function u7({id:e,describedBy:t,row:n,draft:r,disabled:i,onDraft:a,onCommit:o,onRevert:s}){let c={id:e,"aria-describedby":t,disabled:i},l=e=>{e.key===`Escape`&&(s(),e.currentTarget.blur())},u=e=>{e.key===`Enter`&&e.currentTarget.blur(),l(e)},d=n.unit?(0,R.jsx)(`span`,{className:`min-w-0 text-xs text-pretty text-text-tertiary`,children:n.unit}):void 0;if(n.readOnly)return(0,R.jsx)(fj,{...c,disabled:!0,readOnly:!0,mono:n.control!==`select`,icon:(0,R.jsx)(Sb,{}),className:`w-full`,inputClassName:n.control===`number`?`tabular-nums`:void 0,value:n.optionLabels[n.value]??n.value});if(n.control===`select`)return(0,R.jsxs)(Wq,{value:r,onValueChange:e=>{a(e),o(e)},children:[(0,R.jsx)(Jq,{...c,className:q(Kq,`w-full`),children:(0,R.jsx)(Yq,{})}),(0,R.jsxs)(Xq,{children:[n.ghostValue&&(0,R.jsxs)(eJ,{value:``,children:[`Use global (`,n.optionLabels[n.ghostValue]??n.ghostValue,`)`]}),n.modelGroups.length>0?n.modelGroups.map(e=>(0,R.jsxs)(Zq,{children:[(0,R.jsx)(Qq,{children:e.label}),e.entries.map(e=>(0,R.jsx)(eJ,{value:e.id,title:e.note,children:e.note?`${e.id} — ${e.note}`:e.id},e.id))]},e.runtime)):n.options.map(e=>(0,R.jsx)(eJ,{value:e,children:n.optionLabels[e]??e},e))]})]});if(n.control===`textarea`)return(0,R.jsx)(mj,{...c,mono:!0,rows:3,placeholder:n.ghostValue??n.placeholder,value:r,onChange:e=>a(e.target.value),onBlur:e=>o(e.target.value),onKeyDown:l});let f=(0,R.jsx)(fj,{...c,type:n.control===`number`?`number`:`text`,mono:!0,className:n.control===`number`?`w-24 shrink-0`:`w-full`,inputClassName:n.control===`number`?`tabular-nums`:void 0,placeholder:n.ghostValue??n.placeholder,value:r,onChange:e=>a(e.target.value),onBlur:e=>o(e.target.value),onKeyDown:u});return d?(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[f,d]}):f}var d7={global:{text:`Global`,tone:`neutral`,word:`text-text-tertiary`},project:{text:`This project`,tone:`accent`,word:`text-text-secondary`},env:{text:`Env`,tone:`neutral`,word:`text-text-tertiary`}};function f7({kind:e,envVar:t}){let n=d7[e];return(0,R.jsxs)(`span`,{className:q(`inline-flex shrink-0 items-center gap-1.5 text-xs`,n.word),...e===`env`&&t?{title:`Set by ${t}`}:{},children:[e===`env`?(0,R.jsx)(Sb,{size:12,className:`text-icon`}):(0,R.jsx)(BA,{tone:n.tone}),(0,R.jsx)(`span`,{children:n.text})]})}var p7={ok:`success`,muted:`neutral`,warn:`warning`};function m7({chip:e,onOpenEvidence:t}){let n=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(BA,{tone:p7[e.tone]}),(0,R.jsx)(`span`,{className:`truncate`,children:e.text})]}),r=e.tone===`warn`?`text-warning`:`text-text-secondary`;return t?(0,R.jsx)(`button`,{type:`button`,onClick:t,className:q(`-mx-1.5 inline-flex h-6 min-w-0 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-1.5 text-xs`,`underline decoration-border-strong decoration-dotted underline-offset-4`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,r),children:n}):(0,R.jsx)(`span`,{className:q(`inline-flex min-w-0 items-center gap-1.5 text-xs`,r),children:n})}var h7=`theme`,g7=[{value:`dark`,label:`Dark`,icon:(0,R.jsx)(Lb,{size:14})},{value:`light`,label:`Light`,icon:(0,R.jsx)(Ib,{size:14})},{value:`system`,label:`System`,icon:(0,R.jsx)(Rb,{size:14})}];function _7({globals:e,filter:t,highlightField:n}){let r=n7(t,`theme`)&&(0,R.jsx)(o7,{title:`Appearance`,children:(0,R.jsx)(y7,{})});if(e.isLoading)return(0,R.jsxs)(R.Fragment,{children:[r,(0,R.jsx)(a7,{groups:v7,className:`mt-9`})]});if(e.error)return(0,R.jsxs)(R.Fragment,{children:[r,(0,R.jsxs)(Pj,{children:[`Could not load settings: `,e.error.message]})]});if(!e.data)return(0,R.jsx)(R.Fragment,{children:r});let i=Im(e.data,`general`),a=e=>i.filter(t=>t.group===e);return(0,R.jsxs)(R.Fragment,{children:[r,(0,R.jsx)(i7,{title:`Server`,rows:a(`server`),filter:t,highlightField:n}),(0,R.jsx)(i7,{title:`Sessions`,rows:a(`sessions`),filter:t,highlightField:n})]})}var v7=[[`w-20`,`w-28`],[`w-24`,`w-32`,`w-20`]];function y7(){let{preference:e,setPreference:t}=KM();return(0,R.jsx)(s7,{label:`Theme`,description:`Dark is the default; System follows your operating system as it changes.`,control:(0,R.jsx)(Tj,{id:`settings-theme`,label:`Theme`,items:g7.map(e=>({value:e.value,label:e.label,icon:e.icon})),value:e,onChange:t,className:`w-full`})})}var b7=`grid grid-cols-[minmax(0,1.5fr)_minmax(0,1.3fr)_minmax(0,0.8fr)_88px_24px] items-center gap-3`,x7=`min-h-8 border-b border-border-subtle px-2 text-xs font-medium text-text-tertiary`,S7=e=>`models:${e}`,C7=`models:new`,w7=`opacity-0 transition-opacity duration-(--dur-1) group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100`;function T7({rows:e,stepLabels:t,customModels:n,filter:r,writes:i}){let[a,o]=(0,L.useState)(!1),s=r.query.trim()!==``,c=(a||s?e:Wm(e)).filter(e=>n7(r,e.id)),l=a||s?0:Gm(e);return(0,R.jsxs)(`div`,{className:`mt-3`,children:[(0,R.jsxs)(`div`,{className:q(b7,x7),children:[(0,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{children:`Use-case note`}),(0,R.jsx)(`span`,{children:`Used for`}),(0,R.jsx)(`span`,{children:`Default`}),(0,R.jsx)(`span`,{})]}),c.map((e,r)=>(0,R.jsx)(E7,{index:r,row:e,stepLabels:t,customModels:n,writes:i},e.id)),l>0&&(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 border-b border-border-subtle px-2 text-xs text-text-tertiary`,children:[l,` more `,l===1?`model`:`models`,` nobody uses`,(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>o(!0),children:`Show all`})]}),!s&&(0,R.jsx)(k7,{customModels:n,writes:i})]})}function E7({row:e,index:t,stepLabels:n,customModels:r,writes:i}){let a=S7(e.id),o=e.usedFor.map(e=>n.get(e)??e).join(`, `),s=t=>{let n=t.trim(),o=n===``&&!e.custom?r.filter(t=>t.id!==e.id):hd(r,[{id:e.id,runtime:e.runtime,...n?{note:n}:{}}]);i.save(a,`models`,o)},c=()=>{if(e.isDefault){i.refuse(a,`${e.id} is the default model — make another model the default first.`);return}if(e.usedFor.length>0){i.refuse(a,`${e.id} runs ${o} — reset those steps first.`);return}i.save(a,`models`,r.filter(t=>t.id!==e.id))},l=t<8;return(0,R.jsxs)(`div`,{className:q(`group border-b border-border-subtle transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,l&&`animate-rise-in`),style:l?{animationDelay:`${t*20}ms`}:void 0,children:[(0,R.jsxs)(`div`,{className:q(b7,`min-h-10 px-2 text-sm`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(j7,{runtime:e.runtime}),(0,R.jsx)(`span`,{className:`truncate text-text`,title:e.displayName?`${e.displayName} — ${e.id}`:e.id,children:e.id}),e.isNew&&(0,R.jsx)(HA,{tone:`accent`,className:`shrink-0`,children:`New`})]}),(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(O7,{row:e,onCommit:s}),i.saved===a&&(0,R.jsx)(l7,{})]}),(0,R.jsxs)(`span`,{className:`truncate text-xs text-text-tertiary`,title:o||void 0,children:[e.isDefault&&(0,R.jsx)(`span`,{className:`text-text-secondary`,children:`Default`}),e.isDefault&&o!==``&&`, `,o===``?e.isDefault?``:`—`:o]}),e.isDefault?(0,R.jsx)(`span`,{"data-default-mark":``,className:`inline-flex`,children:(0,R.jsx)(HA,{strong:!0,icon:(0,R.jsx)(sb,{}),children:`Default`})}):(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,"aria-label":`Make ${e.id} the default`,onClick:()=>i.save(a,`model`,e.id),className:q(`-ml-2 justify-self-start`,w7),children:`Make default`}),e.custom?(0,R.jsx)(UE,{label:`Remove ${e.id}`,size:`sm`,icon:(0,R.jsx)(lb,{}),onClick:c,variant:`danger-ghost`,className:w7}):(0,R.jsx)(`span`,{})]}),(0,R.jsx)(D7,{row:e}),(0,R.jsx)(A7,{writes:i,cell:a})]})}function D7({row:e}){return!e.noLongerOffered&&!e.retirement?null:(0,R.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-4 pr-2 pb-2.5 pl-8 text-xs text-warning`,children:[e.noLongerOffered&&(0,R.jsxs)(`span`,{children:[`no longer offered by `,Bm[e.noLongerOffered]]}),e.retirement&&(0,R.jsxs)(`span`,{children:[`retires `,e.retirement.at,` → `,e.retirement.replacement]})]})}function O7({row:e,onCommit:t}){let[n,r]=(0,L.useState)(e.note);return(0,L.useEffect)(()=>r(e.note),[e.note]),(0,R.jsx)(`input`,{type:`text`,"aria-label":`Note for ${e.id}`,placeholder:e.isDefault?`e.g. UI/UX work, design-heavy tickets`:`Add a note`,className:q(`-ml-2 h-7 min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-2 text-sm text-text`,`transition-colors duration-(--dur-1) ease-app placeholder:text-text-disabled`,`hover:border-border focus:border-accent focus:bg-surface-inset`),value:n,onChange:e=>r(e.target.value),onBlur:()=>n.trim()!==e.note.trim()&&t(n),onKeyDown:e=>e.key===`Enter`&&e.currentTarget.blur()})}function k7({customModels:e,writes:t}){let[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(``),c=()=>{let c=fm(n,i,o);if(`error`in c){t.refuse(C7,c.error);return}t.save(C7,`models`,hd(e,[c.entry])),r(``),a(``),s(``)},l=e=>{e.key===`Enter`&&c()};return(0,R.jsxs)(`div`,{className:`pt-3`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_132px_minmax(0,1.2fr)_auto] items-center gap-2`,children:[(0,R.jsx)(fj,{mono:!0,"aria-label":`New model id`,placeholder:`Model id, e.g. claude-opus-5[1m]`,value:n,onChange:e=>r(e.target.value),onKeyDown:l}),(0,R.jsxs)(Wq,{value:i,onValueChange:a,children:[(0,R.jsx)(Jq,{"aria-label":`Runtime (required)`,className:q(Kq,`w-full`,i===``&&`text-text-tertiary`),children:(0,R.jsx)(Yq,{})}),(0,R.jsxs)(Xq,{children:[(0,R.jsx)(eJ,{value:``,children:`Runs on…`}),sd.map(e=>(0,R.jsx)(eJ,{value:e,children:sm[e]},e))]})]}),(0,R.jsx)(fj,{"aria-label":`New model note`,placeholder:`Use-case note (optional)`,value:o,onChange:e=>s(e.target.value),onKeyDown:l}),(0,R.jsx)(Y,{icon:(0,R.jsx)(ob,{}),onClick:c,children:`Add model`})]}),(0,R.jsx)(A7,{writes:t,cell:C7,className:`pt-1.5`})]})}function A7({writes:e,cell:t,className:n=`pr-2 pb-2.5 pl-8`}){return e.error?.cell===t?(0,R.jsx)(`p`,{role:`alert`,className:q(`m-0 text-xs text-danger`,n),children:e.error.message}):null}function j7({runtime:e}){let t=e===`codex`?kb:Ob;return(0,R.jsx)(`span`,{role:`img`,"aria-label":sm[e],title:sm[e],className:`inline-flex size-4 shrink-0 items-center justify-center text-icon`,children:(0,R.jsx)(t,{size:14})})}function M7({groups:e}){return(0,R.jsx)(R.Fragment,{children:e.map(e=>(0,R.jsxs)(Zq,{children:[(0,R.jsx)(Qq,{children:e.label}),e.entries.map(e=>(0,R.jsx)(eJ,{value:e.id,title:e.note,children:e.note?`${e.id} — ${e.note}`:e.id},e.id))]},e.runtime))})}var N7=[{group:`sessions`,title:`Sessions`,caption:`Interactive — you are in the terminal`},{group:`unattended`,title:`Unattended`,caption:`Burns and scripted runs`}],P7=`grid grid-cols-[minmax(0,1fr)_260px_24px] items-center gap-3`;function F7({rows:e,groups:t,defaultModel:n,projectModel:r,filter:i,writes:a}){return(0,R.jsxs)(R.Fragment,{children:[r&&(0,R.jsxs)(`p`,{className:`m-0 mt-3 flex items-center gap-2 text-xs text-text-secondary`,children:[(0,R.jsx)(BA,{tone:`warning`}),(0,R.jsxs)(`span`,{children:[`This project runs everything on `,(0,R.jsx)(`span`,{className:`font-mono`,children:r}),` — these apply to other projects.`]})]}),N7.map(({group:r,title:o,caption:s})=>{let c=e.filter(e=>e.group===r&&n7(i,vm(e.step)));return c.length===0?null:(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(`div`,{className:q(P7,x7,`mt-4`),children:[(0,R.jsxs)(`span`,{children:[o,(0,R.jsx)(`span`,{className:`ml-2 font-normal text-text-disabled`,children:s})]}),(0,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{})]}),c.map(e=>(0,R.jsx)(I7,{row:e,groups:t,defaultModel:n,writes:a},e.step))]},r)})]})}function I7({row:e,groups:t,defaultModel:n,writes:r}){let i=vm(e.step),a=e.value!==null;return(0,R.jsxs)(`div`,{className:`group border-b border-border-subtle transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,children:[(0,R.jsxs)(`div`,{className:q(P7,`min-h-12 px-2 py-1.5`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-text`,children:[e.label,r.saved===i&&(0,R.jsx)(l7,{})]}),(0,R.jsx)(`span`,{className:`truncate text-xs text-text-tertiary`,title:e.description,children:e.description})]}),(0,R.jsxs)(Wq,{value:e.value??``,onValueChange:e=>r.save(i,i,e===``?null:e),children:[(0,R.jsx)(Jq,{"aria-label":`Model for ${e.label}`,className:q(Kq,`w-full`,!a&&`text-text-tertiary`),children:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 [&>span:last-child]:truncate`,children:[(0,R.jsx)(j7,{runtime:e.effectiveRuntime}),(0,R.jsx)(Yq,{})]})}),(0,R.jsxs)(Xq,{children:[(0,R.jsxs)(eJ,{value:``,children:[`Default (`,n,`)`]}),(0,R.jsx)(M7,{groups:t})]})]}),a?(0,R.jsx)(UE,{label:`Reset ${e.label} to default`,size:`sm`,icon:(0,R.jsx)(ub,{}),onClick:()=>r.save(i,i,null),className:w7}):(0,R.jsx)(`span`,{})]}),(0,R.jsx)(A7,{writes:r,cell:i,className:`px-2 pb-2.5`})]})}var L7=1400,R7=`model`;function z7(){let e=B.useUtils(),[t,n]=(0,L.useState)(null),[r,i]=(0,L.useState)(null),a=(0,L.useRef)([]),o=(0,L.useRef)(null),s=(0,L.useRef)(void 0);(0,L.useEffect)(()=>()=>clearTimeout(s.current),[]);let c=()=>{let e=a.current.shift();if(!e){o.current=null;return}o.current=e.cell,l.mutate({key:e.key,value:e.value})},l=B.settings.update.useMutation({onSuccess:()=>{n(o.current),clearTimeout(s.current),s.current=setTimeout(()=>n(null),L7),e.settings.get.invalidate(),c()},onError:e=>{let t=o.current;t&&i({cell:t,message:e.message}),a.current=[],o.current=null}}),u=e=>i(t=>t&&t.cell===e?null:t);return{saved:t,error:r,save:(e,t,n)=>{u(e),a.current.push({cell:e,key:t,value:n}),o.current===null&&c()},refuse:(e,t)=>i({cell:e,message:t})}}var B7=[[`w-28`],[`w-32`,`w-24`,`w-28`],[`w-20`,`w-28`,`w-24`]];function V7({globals:e,scoped:t,filter:n,highlightField:r}){let i=z7();if(e.isLoading)return(0,R.jsx)(a7,{groups:B7});if(e.error)return(0,R.jsxs)(Pj,{children:[`Could not load settings: `,e.error.message]});if(!e.data)return null;let a=e.data,o=Um(a),s=qm(a),c=dm(um(a)),l=Rm(a),u=new Map(s.map(e=>[e.step,e.label]));return(0,R.jsxs)(R.Fragment,{children:[n7(n,`model`)&&(0,R.jsx)(`div`,{className:`-mt-3.5`,children:(0,R.jsx)(W7,{value:l,groups:c,writes:i,highlight:r===`model`})}),o.some(e=>n7(n,e.id))&&(0,R.jsxs)(o7,{title:`Roster`,action:(0,R.jsx)(U7,{}),description:(0,R.jsxs)(R.Fragment,{children:[`A model with a `,(0,R.jsx)(`span`,{className:`text-text-secondary`,children:`use-case note`}),` is offered to the tickets agent, which may pick it per ticket; models without a note are never picked automatically.`]}),children:[(0,R.jsx)(H7,{view:a}),(0,R.jsx)(T7,{rows:o,stepLabels:u,customModels:lm(a),filter:n,writes:i})]}),s.some(e=>n7(n,vm(e.step)))&&(0,R.jsx)(o7,{title:`Per step`,description:`Every step runs the default unless it names a model of its own.`,children:(0,R.jsx)(F7,{rows:s,groups:c,defaultModel:l,projectModel:Jm(t.data),filter:n,writes:i})})]})}function H7({view:e}){return(0,R.jsx)(`ul`,{"aria-label":`Model discovery`,className:`m-0 mt-1.5 flex list-none flex-wrap gap-x-5 gap-y-1 p-0 text-xs`,children:Km(e).map(e=>(0,R.jsxs)(`li`,{className:q(`inline-flex items-center gap-1.5`,e.failed?`text-warning`:`text-text-tertiary`),children:[(0,R.jsx)(j7,{runtime:e.runtime}),e.text]},e.runtime))})}function U7(){let e=B.useUtils(),t=B.settings.refreshModels.useMutation({onSuccess:()=>void e.settings.get.invalidate()});return(0,R.jsxs)(R.Fragment,{children:[t.error&&(0,R.jsxs)(`span`,{role:`alert`,className:`text-xs text-danger`,children:[`Refresh failed: `,t.error.message]}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),loading:t.isPending,onClick:()=>t.mutate(),children:t.isPending?`Refreshing…`:`Refresh`})]})}function W7({value:e,groups:t,writes:n,highlight:r}){let{ref:i,flash:a}=t7(r);return(0,R.jsx)(s7,{rowRef:i,flash:a,label:`Default model`,htmlFor:`settings-default-model`,description:`Runs every step that has no model of its own below — and every project that has not set one.`,aside:n.saved===R7&&(0,R.jsx)(l7,{}),control:(0,R.jsxs)(Wq,{value:e,onValueChange:e=>n.save(R7,`model`,e),children:[(0,R.jsx)(Jq,{id:`settings-default-model`,className:q(Kq,`w-full`),children:(0,R.jsx)(Yq,{})}),(0,R.jsx)(Xq,{children:(0,R.jsx)(M7,{groups:t})})]}),below:(0,R.jsx)(A7,{writes:n,cell:R7,className:``})})}function G7({projectId:e,filter:t,highlightField:n,onDismiss:r}){let i=B.useUtils(),a=B.setup.doctor.useQuery(e?{projectId:e}:void 0,{refetchOnWindowFocus:!1}),o=a.data,s=e=>o?.results.find(t=>t.id===e),c=s(`container-runtime`),l=s(`sandcastle-image`),u=q5(o?.results??[]),[d,f]=(0,L.useState)(0),p=()=>{f(e=>e+1),i.setup.doctor.cancel().then(()=>a.refetch())},m=X7(a.isLoading,d),h=e=>!t||n7(t,e),g=m?J7:`checking prerequisites…`,_=a.error?.message??(m?Y7:null),v=Z5([...c?[{field:`container-runtime`,ok:c.status===`ok`}]:[],...l?[{field:`sandcastle-image`,ok:K7(l)}]:[],...u.map(e=>({field:J5(e.runtime),ok:e.probe.status===`ok`}))].map(({field:e,ok:t})=>({ok:t,reason:Z7[e].reason??Z7[e].label}))),y=e=>({field:e,label:Z7[e].label,visible:h(e),highlight:n===e}),b=o!==void 0&&v.count===null;return(0,R.jsxs)(`section`,{"aria-label":`Unattended burn prerequisites`,className:`flex flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-3 pb-3`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:q(`mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-surface-hover [&>svg]:size-4`,b?`text-success`:`text-icon`),children:b?(0,R.jsx)(sb,{}):(0,R.jsx)(xb,{})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex min-h-7 items-center gap-2 text-sm font-medium text-text`,children:a.isLoading?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(KE,{}),(0,R.jsx)(`span`,{className:`font-normal text-text-secondary`,children:g})]}):a.error?`Could not run the checks`:(0,R.jsxs)(`span`,{className:`min-w-0`,children:[v.count&&(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[v.count,` `]}),v.text]})}),!r&&(0,R.jsx)(`p`,{className:`m-0 text-xs text-pretty text-text-tertiary`,children:`A burn you walk away from runs its tickets in containers, so it needs what an interactive session never does. Fix any of these now, or leave them for later.`})]}),r&&(0,R.jsx)(Y,{variant:`ghost`,className:`shrink-0`,onClick:r,children:`Set up later`})]}),_&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5 py-2 pl-10`,children:[(0,R.jsx)(BA,{tone:`warning`}),(0,R.jsx)(`span`,{className:`min-w-0 grow text-xs text-text-secondary`,children:_}),(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),onClick:p,children:`Retry`})]}),o&&(0,R.jsxs)($7,{children:[(0,R.jsx)(t9,{...y(`container-runtime`),probe:c,onRecheck:p}),(0,R.jsx)(n9,{...y(`sandcastle-image`),probe:l,runtimeOk:c?.status===`ok`,projectId:e,onDone:p}),u.map(e=>e.kind===`token`?(0,R.jsx)(c9,{...y(J5(e.runtime)),probe:e.probe,onDone:p},e.runtime):(0,R.jsx)(l9,{...y(J5(e.runtime)),row:e,onDone:p},e.runtime)),e&&(0,R.jsx)(o9,{...y(`burn-cache`),projectId:e})]})]})}function K7(e){return e.status===`ok`||e.severity===`info`}var q7=1e4,J7=`still checking — this is taking longer than usual`,Y7=`The container runtime has not answered yet. A runtime that is starting up — or wedged — can leave the checks outstanding for minutes.`;function X7(e,t){let[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{if(r(!1),!e)return;let t=setTimeout(()=>r(!0),q7);return()=>clearTimeout(t)},[e,t]),n}var Z7=Object.fromEntries(X5.map(e=>[e.field,e]));function Q7({field:e,label:t,visible:n=!0,highlight:r=!1,detail:i,ok:a,status:o,children:s,below:c}){let{ref:l,flash:u}=t7(r);return n?(0,R.jsxs)(`li`,{ref:l,...e?{"data-field":e}:{},className:q(`grid grid-cols-[28px_minmax(0,1fr)_auto] items-start gap-x-3 gap-y-2.5 py-3 [counter-increment:checklist]`,`border-t border-border-subtle first:border-t-0`,u&&`rounded-md outline-2 outline-offset-4 outline-accent`),children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`flex h-5 items-center justify-center text-xs text-text-tertiary tabular-nums before:content-[counter(checklist)]`}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-5 flex-wrap items-center gap-x-3 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-text`,children:t}),a?(0,R.jsx)(HA,{tone:`success`,icon:(0,R.jsx)(sb,{}),children:o??`Ready`}):(0,R.jsx)(HA,{tone:`warning`,children:o??`Needed`})]}),(0,R.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-text-tertiary`,title:i,children:i})]}),(0,R.jsx)(`div`,{className:`flex max-w-96 flex-wrap items-center justify-end gap-2`,children:s}),c]}):null}function $7({children:e}){return(0,R.jsx)(`ol`,{className:`m-0 list-none border-t border-border-subtle p-0 [counter-reset:checklist]`,children:e})}function e9({sessionId:e,label:t,onDone:n,onEnded:r}){return(0,R.jsxs)(`div`,{className:`col-span-full flex flex-col gap-2`,children:[(0,R.jsx)(`div`,{className:`h-70 overflow-hidden rounded-md border border-border bg-surface-inset animate-rise-in`,children:(0,R.jsx)(LJ,{label:t,children:(0,R.jsx)(c4,{sessionId:e,onEnded:r})})}),n&&(0,R.jsx)(`div`,{className:`flex justify-end`,children:(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),onClick:n,children:`Done — re-check`})})]})}function t9({probe:e,onRecheck:t,...n}){let r=B.setup.runtimeGuide.useQuery(void 0,{enabled:e?.status===`missing`,refetchOnWindowFocus:!1}),i=gx();if(!e)return null;let a=e.status===`missing`?r.data:void 0,o=a?.command??e.fix??``,s=e.status===`ok`;return(0,R.jsxs)(Q7,{...n,detail:e.detail,ok:s,children:[!s&&o&&(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(u9,{command:o,onCopy:()=>{navigator.clipboard?.writeText(o),i.push(`copied`,`info`)}})}),!s&&a?.note&&(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:a.note}),!s&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(Gb,{}),onClick:t,children:`Re-check`})]})}function n9({probe:e,runtimeOk:t,projectId:n,onDone:r,...i}){let[a,o]=(0,L.useState)(null),s=gx(),c=B.setup.imageBuildTarget.useQuery(n?{projectId:n}:void 0),l=B.setup.startTerminal.useMutation({onSuccess:({sessionId:e,notices:t})=>{o(e);for(let e of t)s.push(e)},onError:e=>s.push(e.message)});return e?(0,R.jsx)(Q7,{...i,detail:e.detail,ok:K7(e),below:a&&(0,R.jsx)(e9,{sessionId:a,label:`build-image`,onEnded:r,onDone:()=>{o(null),r()}}),children:!a&&(0,R.jsx)(i9,{probe:e,target:r9(c),runtimeOk:t,pending:l.isPending,onStart:()=>l.mutate({kind:`build-image`,...n?{projectId:n}:{}})})}):null}function r9(e){let{data:t}=e;return t?t.kind===`refused`?{kind:`refused`,reason:t.reason}:{kind:`ready`,dockerfile:t.dockerfile,tag:t.tag}:e.error?{kind:`error`,message:e.error.message}:{kind:`loading`}}function i9({probe:e,target:t,runtimeOk:n,pending:r,onStart:i}){if(e.status===`custom`)return(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:e.fix});if(t.kind===`refused`)return(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:t.reason});let a=e.status===`missing`||e.status===`not-built-yet`?`Build`:`Rebuild`,o=r?`Starting…`:t.kind===`ready`?`${a} image · ${t.tag}`:t.kind===`loading`?`${a} image · resolving…`:`${a} image`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{variant:`secondary`,size:`sm`,icon:(0,R.jsx)(bb,{}),"aria-label":`${a} image`,disabled:!n||r||t.kind!==`ready`,title:n?t.kind===`ready`?`Dockerfile: ${t.dockerfile}\nImage: ${t.tag}`:void 0:`Install a container runtime first`,onClick:i,children:o}),t.kind===`error`&&(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-warning`,children:t.message})]})}function a9({status:e,pending:t,refusal:n,onClear:r,...i}){return e?.mode===`volume`?(0,R.jsxs)(Q7,{field:Z7[`burn-cache`].field,label:Z7[`burn-cache`].label,...i,ok:!0,detail:`${e.volumeName} — ${e.sizeBytes===null?`empty`:Ph(e.sizeBytes)}`,children:[(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(lb,{}),disabled:t,onClick:r,children:t?`Clearing…`:`Clear`}),n&&(0,R.jsx)(`span`,{className:`basis-full text-right text-xs text-warning`,children:n})]}):null}function o9({projectId:e,...t}){let n=B.useUtils(),[r,i]=(0,L.useState)(null),a=B.system.burnCache.status.useQuery({projectId:e},{refetchOnWindowFocus:!1}),o=B.system.burnCache.clear.useMutation({onSuccess:()=>{i(null),n.system.burnCache.status.invalidate()},onError:e=>i(e.message)});return(0,R.jsx)(a9,{...t,status:a.data,pending:o.isPending,refusal:r,onClear:()=>o.mutate({projectId:e})})}var s9={"claude-code":{mint:{kind:`setup-token`,label:`Run claude setup-token`},placeholder:`paste sk-ant-oat01-…`}};function c9({probe:e,onDone:t,...n}){let[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(null),l=gx(),u=B.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>l.push(e.message)}),d=B.setup.afkToken.useMutation({onSuccess:e=>{c(e),e.valid&&t()},onError:e=>l.push(e.message)});if(!e?.runtime)return null;let f=e.runtime,p=s9[f];return p?(0,R.jsxs)(Q7,{...n,detail:e.detail,ok:e.status===`ok`,below:r&&(0,R.jsx)(e9,{sessionId:r,label:`setup-token`}),children:[p.mint&&!r&&(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,icon:(0,R.jsx)(mb,{}),onClick:()=>p.mint&&u.mutate({kind:p.mint.kind}),disabled:u.isPending,children:u.isPending?`Starting…`:p.mint.label}),(0,R.jsx)(fj,{"aria-label":n.label,mono:!0,className:`w-52`,value:a,onChange:e=>o(e.target.value),placeholder:p.placeholder,spellCheck:!1,autoComplete:`off`}),(0,R.jsx)(Y,{variant:`primary`,disabled:a.trim()===``||d.isPending,onClick:()=>d.mutate({token:a,runtime:f}),children:d.isPending?`Verifying…`:`Save & verify`}),s&&(0,R.jsxs)(`span`,{className:`basis-full text-right text-xs`,children:[(0,R.jsx)(HA,{tone:s.valid?`success`:`warning`,icon:s.valid?(0,R.jsx)(sb,{}):(0,R.jsx)(Vb,{}),children:s.detail}),s.fix&&(0,R.jsx)(`span`,{className:`mt-0.5 block text-text-tertiary`,children:s.fix})]})]}):null}function l9({row:e,onDone:t,...n}){let[r,i]=(0,L.useState)(null),a=gx(),o=B.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>a.push(e.message)}),s=ah[e.runtime],c=e.probe.status===`ok`;return(0,R.jsx)(Q7,{...n,ok:c,status:c?`Signed in`:`Not signed in`,detail:e.probe.detail,below:r&&(0,R.jsx)(e9,{sessionId:r,label:s.kind,onDone:()=>{i(null),t()}}),children:!c&&!r&&(0,R.jsx)(Y,{variant:`secondary`,size:`sm`,icon:(0,R.jsx)(Kb,{}),disabled:o.isPending,onClick:()=>o.mutate({kind:s.kind}),children:o.isPending?`Starting…`:`Sign in`})})}function u9({command:e,onCopy:t}){return(0,R.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-surface-inset py-0.5 pr-0.5 pl-2`,children:[(0,R.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,title:e,children:e}),(0,R.jsx)(UE,{label:`Copy`,size:`sm`,icon:(0,R.jsx)(Fb,{}),onClick:t})]})}var d9=[[`w-32`,`w-28`,`w-36`],[`w-20`,`w-24`]];function f9({globals:e,projectId:t,filter:n,highlightField:r}){return e.isLoading?(0,R.jsx)(a7,{groups:d9}):e.error?(0,R.jsxs)(Pj,{children:[`Could not load settings: `,e.error.message]}):e.data?(0,R.jsxs)(R.Fragment,{children:[X5.some(e=>n7(n,e.field))&&(0,R.jsx)(o7,{title:`Prerequisites for unattended burns`,children:(0,R.jsx)(G7,{projectId:t,filter:n,highlightField:r})}),(0,R.jsx)(i7,{title:`Width & retries`,rows:Im(e.data,`burns`),filter:n,highlightField:r})]}):null}var p9={prep:`established by preparation`,session:`established in a conversation on this machine`,human:`set by you`,build:`built by runcastle from this repo's own Dockerfile`};function m9({source:e,evidence:t,onClose:n}){let r=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())},t=e=>{let t=r.current?.parentElement;e.target instanceof Node&&t?.contains(e.target)||n()};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`mousedown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`mousedown`,t)}},[n]),(0,R.jsxs)(`div`,{ref:r,className:`absolute top-7 left-0 z-10 max-h-72 w-105 overflow-auto rounded-lg bg-surface-raised px-3.5 py-3 shadow-popover animate-pop-in`,children:[(0,R.jsxs)(`h4`,{className:`m-0 mb-2 text-xs font-medium text-text-tertiary`,children:[`Evidence · `,p9[e]]}),(0,R.jsx)(`pre`,{className:`m-0 font-mono text-xs leading-[18px] whitespace-pre-wrap text-text-secondary`,children:t})]})}var h9=[{group:`model`,title:`Model & sandbox`},{group:`commands`,title:`Commands`},{group:`chat`,title:`Project chat`}],g9=[[`w-24`,`w-32`],[`w-28`,`w-20`,`w-32`],[`w-24`]];function _9({scoped:e,projectId:t,filter:n,highlightField:r}){let i=B.project.prep.useQuery({projectId:t}),[a,o]=(0,L.useState)(null);if(e.isLoading)return(0,R.jsx)(a7,{groups:g9});if(e.error)return(0,R.jsxs)(Pj,{children:[`Could not load settings: `,e.error.message]});if(!e.data)return null;let s=i.data?.findings??[],c=new Map(s.map(e=>[e.key,e])),l=Im(e.data,`project`,s),u=e=>{let t=c.get(e.key);return a!==e.key||!t?.evidence?null:(0,R.jsx)(m9,{source:t.source,evidence:t.evidence,onClose:()=>o(null)})};return(0,R.jsx)(R.Fragment,{children:h9.map(({group:e,title:i})=>(0,R.jsx)(i7,{title:i,rows:l.filter(t=>t.group===e),projectId:t,filter:n,highlightField:r,onOpenEvidence:e=>o(t=>t===e?null:e),evidence:u},e))})}var v9={general:`How runcastle looks, where its server listens, and how sessions are sandboxed.`,models:`The default model, the roster this machine offers, and which model runs each step.`,burns:`What an unattended run needs before it starts, and how hard it tries once it does.`,project:`Values this project sets for itself. Unset fields inherit the global value, shown as ghost text.`},y9={general:_7,models:V7,burns:f9,project:_9};function b9({projectId:e,projectName:t,location:n,onClose:r}){let i=B.settings.get.useQuery(),a=B.settings.get.useQuery({projectId:e}),[o,s]=(0,L.useState)(n.page),[c,l]=(0,L.useState)(``),u=(0,L.useRef)(null),d=(0,L.useMemo)(()=>Zm(c,S9(i.data,a.data)),[c,i.data,a.data]),f={query:c,...d},p=c.trim()!==``;(0,L.useEffect)(()=>{if(!p||d.counts[o]>0)return;let e=Q5.find(e=>d.counts[e.page]>0);e&&s(e.page)},[p,d,o]);let m=e=>{!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`f`||(e.preventDefault(),u.current?.focus(),u.current?.select())},h=y9[o],g=Q5.find(e=>e.page===o)?.label??``,_=p&&d.matches.size===0;return(0,R.jsx)(Hj,{open:!0,onClose:r,size:`xl`,label:`Settings`,className:`overflow-hidden`,children:(0,R.jsxs)(`div`,{className:`relative grid h-[min(720px,84vh)] grid-cols-[208px_minmax(0,1fr)]`,onKeyDown:m,children:[(0,R.jsx)($5,{page:o,filter:f,filterRef:u,projectName:t,onFilter:l,onSelect:s}),(0,R.jsx)(`section`,{className:`grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] bg-surface`,children:(0,R.jsx)(`div`,{className:`min-h-0 overflow-x-hidden overflow-y-auto px-8 pt-9 pb-12`,children:(0,R.jsxs)(`div`,{className:`animate-rise-in`,children:[(0,R.jsxs)(`header`,{className:`mb-8`,children:[(0,R.jsx)(`h2`,{className:`m-0 text-lg font-semibold text-text`,children:g}),(0,R.jsx)(`p`,{className:`mt-1 mb-0 text-sm text-text-tertiary`,children:v9[o]})]}),(0,R.jsx)(`div`,{children:(0,R.jsx)(h,{globals:i,scoped:a,projectId:e,filter:f,...o===n.page&&n.field?{highlightField:n.field}:{}})}),_&&(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(eb,{}),title:`Nothing matches`,hint:`Try “model”, “verify” or “image”.`})]},o)})}),(0,R.jsx)(UE,{label:`Close`,kbd:`Esc`,size:`sm`,icon:(0,R.jsx)(cb,{}),onClick:r,className:`absolute top-3 right-3`})]})})}var x9={id:h7,page:`general`,terms:[`Theme`,`Appearance`,`Dark`,`Light`,`System`]};function S9(e,t){let n=Q5.flatMap(({page:n})=>{let r=n===`project`?t:e;return r?Xm(r,n):[]}),r=X5.map(e=>({id:e.field,page:`burns`,terms:[e.label,...e.terms]}));return[x9,...n,...r]}function C9({projectId:e,nav:t}){let n=Xg(e),{selectedFeatureId:r,projectSelected:i,preparing:a,select:o,selectView:s,selectProject:c,startPreparation:l,setCmdk:u}=n,[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(0),[h,g]=(0,L.useState)(!1),[_,v]=(0,L.useState)(0),y=()=>{g(!0),v(e=>e+1)},[b,x]=(0,L.useState)(0),S=()=>{c(),x(e=>e+1)},C=()=>x(0),[w,T]=(0,L.useState)(0),E=()=>{c(),T(e=>e+1)},D=()=>T(0),O=AF(),k=B.feature.list.useQuery({projectId:e},{refetchInterval:Ch()}),A=_x(e),j=B.project.prep.useQuery({projectId:e}),M=j.data?.prepared??!0,N=j.data?.empty??!0,P=B.feature.driveInfo.useQuery(void 0,{refetchInterval:Ch()}).data,ee=bx(P,e)?P:null,F=k.data,I=(0,L.useCallback)((e,t)=>{if(!e)return o(null);o(e,t??Kg(e,F?.find(t=>t.id===e)))},[o,F]),te=(0,L.useCallback)(e=>o(e,`chat`),[o]),[ne,re]=(0,L.useState)(!1),[ie]=(0,L.useState)(()=>wg(Dg()));(0,L.useEffect)(()=>{if(ne||!F)return;let t=Tg(ie,e);if(t?.kind===`chat`)c();else if(t?.kind===`prepare`)l();else if(t){let e=F.find(e=>e.slug===t.featureSlug);e?I(e.id,t.tab):I(eg(F)?.id??null)}else if(!r&&!i&&!a){let e=eg(F);e&&I(e.id)}else r&&!i&&!a&&s(Kg(r,F.find(e=>e.id===r)));re(!0)},[ne,F,e,ie,r,i,a,I,s,c,l]);let ae=F?.find(e=>e.id===r),oe=ae?.slug??null,se=ae?.status===`draft`?`overview`:n.featureView;Ag(ne&&!n.creating?Eg({projectId:e,preparing:a,projectSelected:i,featureSlug:oe,featureView:se}):null,t=>{if(!t||xg(t)!==e)return;let n=Tg(t,e);if(!n)o(null);else if(n.kind===`chat`)c();else if(n.kind===`prepare`)l();else{let e=F?.find(e=>e.slug===n.featureSlug);e?o(e.id,bg(n)):I(eg(F??[])?.id??null)}});let ce=()=>{c(),A.session?m(e=>e+1):A.start()};(0,L.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),u(!0)):yx(e)&&(e.preventDefault(),y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u]);let le=Ky({...n,featureCount:F?.length??0,prepared:M,empty:N}),ue=F?.find(e=>e.id===r)?.phase,de=Bg(n.inspectorPreference,n.viewedPhase??ue),fe=qy(le,de),pe=le===`feature`?()=>n.toggleInspector(de):void 0,me=le===`create`?(0,R.jsx)(`section`,{className:`relative flex min-h-0 min-w-0 flex-col`,children:(0,R.jsx)(O5,{projectId:e,onCancel:n.cancelCreate,onCreated:I})}):le===`prepare`?(0,R.jsx)(A5,{projectId:e,...n.preparing?{onClose:n.closePreparation}:{}}):le===`project`?(0,R.jsx)(w5,{projectId:e,talk:A,newChatRequest:p,onConsumeNewChatRequest:()=>m(0),inboxRequest:b,onConsumeInboxRequest:C,empty:N,onOpenPreparation:n.startPreparation,driveRequest:w,onConsumeDriveRequest:D}):le===`feature`&&r?(0,R.jsx)(LJ,{label:`feature view`,fallback:e=>(0,R.jsx)(E8,{featureId:r,error:e}),children:(0,R.jsx)(Y8,{featureId:r,view:se,onViewChange:n.selectView,viewedPhase:n.viewedPhase,onViewPhase:n.viewPhase,guidance:n.guidance,driving:d,onDriveChange:f,detailsOpen:fe,onToggleDetails:()=>n.toggleInspector(de),onDeleted:()=>{n.select(null),n.selectProject()}})},`ws-${r}`):null,he=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(MF,{sidebar:(0,R.jsx)(FF,{projectId:e,nav:t,view:le,selectedFeatureId:n.selectedFeatureId,talk:A,onSelect:I,onSelectProject:n.selectProject,onNewChat:ce,onDraft:n.startDraft,onOpenPreparation:n.startPreparation,onOpenNote:y,onOpenCmdk:()=>u(!0),onOpenSettings:()=>n.openSettings(),projectDriveBranch:ee?.branch??null,onOpenProjectDrive:E,driving:d,onDriveChange:f}),rail:(0,R.jsx)(ZF,{onOpenCmdk:()=>u(!0),onNewChat:ce}),children:(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col [&>*]:min-h-0 [&>*]:flex-1`,children:me})}),(0,R.jsx)(B5,{open:n.cmdkOpen,onClose:()=>n.setCmdk(!1),features:F??[],selectedFeatureId:n.selectedFeatureId,onSelect:I,onOpenSettings:()=>n.openSettings(),onOpenPreparation:n.startPreparation,onOpenProjectChat:n.selectProject,onOpenNote:y,onToggleSidebar:O.toggleSidebar,onToggleDetails:pe,nav:t}),(0,R.jsx)(G5,{projectId:e,projectName:t.currentProject?.name??``,open:h,openRequest:_,onClose:()=>g(!1),onOpenInbox:S}),n.settings&&(0,R.jsx)(b9,{projectId:e,projectName:t.currentProject?.name??``,location:n.settings,onClose:n.closeSettings})]});return(0,R.jsx)(eI,{open:n.openSettings,children:(0,R.jsx)(Tx,{value:te,children:he})})}var w9=`${lj} h-7 w-full font-medium`,T9=`A run is in flight — it has to finish before this project can go.`;function E9({project:e,stats:t,loading:n,onOpen:r,index:i}){let a=gx(),o=B.useUtils(),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(e.name),p=B.project.rename.useMutation({onSuccess:async()=>{await o.project.list.invalidate(),c(!1)},onError:e=>a.push(e.message)}),m=B.project.close.useMutation({onSuccess:async()=>{await o.project.list.invalidate(),a.push(`removed ${e.name}`,`info`)},onError:e=>a.push(e.message)});(0,L.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]);let h=t.activeRuns>0,g=()=>{let t=d.trim();t&&t!==e.name?p.mutate({projectId:e.id,name:t}):c(!1)},_=s?(0,R.jsx)(`input`,{className:w9,value:d,"aria-label":`Project name`,maxLength:80,autoFocus:!0,onChange:e=>f(e.target.value),onKeyDown:t=>{t.stopPropagation(),t.key===`Enter`&&g(),t.key===`Escape`&&(f(e.name),c(!1))},onBlur:g}):(0,R.jsx)(`span`,{className:`block truncate font-medium`,children:e.name});return l?(0,R.jsx)(rj,{className:`animate-fade-in`,wrap:!0,title:(0,R.jsxs)(`span`,{className:`text-text-secondary`,children:[`Remove `,(0,R.jsx)(`span`,{className:`font-medium text-text`,children:e.name}),`? The repo on disk is untouched.`,h&&(0,R.jsx)(`span`,{className:`block text-xs text-text-tertiary`,children:T9})]}),control:(0,R.jsxs)(`span`,{className:`flex shrink-0 gap-2 pr-3`,children:[(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>u(!1),children:`Cancel`}),(0,R.jsx)(Y,{size:`sm`,variant:`danger`,icon:(0,R.jsx)(lb,{}),disabled:h||m.isPending,onClick:()=>m.mutate({projectId:e.id}),children:m.isPending?`Removing…`:`Remove`})]})}):(0,R.jsx)(rj,{index:i,leading:(0,R.jsx)(yb,{}),title:_,description:(0,R.jsx)(`span`,{className:`block truncate text-left font-mono`,dir:`rtl`,title:e.repoPath,children:(0,R.jsx)(`bdi`,{children:e.repoPath})}),meta:n?`Loading…`:(0,R.jsx)(oj,{className:`flex-nowrap`,items:[{strong:t.total,text:t.total===1?`feature`:`features`},t.activeRuns>0&&{tone:`live`,strong:t.activeRuns,text:`running`},t.needsYou>0&&{tone:`warning`,strong:t.needsYou,text:`needs you`}]}),onClick:s?void 0:r,tooltip:`Open ${e.name}`,actionsOverlay:!0,actions:!s&&(0,R.jsx)(yF,{label:`${e.name} actions`,actions:[{key:`rename`,label:`Rename`,onSelect:()=>{f(e.name),c(!0)}},{key:`remove`,label:`Remove from list`,danger:!0,onSelect:()=>u(!0)}]})})}function D9({nav:e}){let t=e.projects??[],n=Ch(),r=B.useQueries(e=>t.map(t=>e.feature.list({projectId:t.id},{refetchInterval:n}))),i=t.map((e,t)=>cg(r[t]?.data??[])),a=i.reduce((e,t)=>e+t.activeRuns,0),o=i.reduce((e,t)=>e+t.needsYou,0);return(0,R.jsx)(MF,{sidebar:(0,R.jsx)(O9,{nav:e}),children:(0,R.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(_j,{crumbs:[{label:`Projects`,icon:(0,R.jsx)(zb,{})}]}),(0,R.jsxs)(yj,{routeKey:`portfolio`,children:[(0,R.jsx)(bj,{title:`Projects`,meta:[{strong:t.length,text:t.length===1?`project open`:`projects open`},a>0&&{tone:`live`,strong:a,text:`running`},o>0&&{tone:`warning`,strong:o,text:o===1?`needs you`:`need you`}],actions:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(ob,{}),onClick:e.showOpen,children:`Open a project`})}),(0,R.jsx)(ij,{divided:!0,label:`Open projects`,className:`mt-8`,children:t.map((t,n)=>(0,R.jsx)(E9,{index:n,project:t,stats:i[n],loading:r[n]?.data===void 0,onOpen:()=>e.enterProject(t.id)},t.id))})]})]})})}function O9({nav:e}){let t=bh(),n=KM();return(0,R.jsxs)(`nav`,{"aria-label":`Projects`,className:`flex h-full min-h-0 flex-col p-2`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-0.5`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:(0,R.jsx)(CF,{nav:e})}),(0,R.jsx)(jF,{})]}),(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-px`,children:(0,R.jsx)(nj,{icon:(0,R.jsx)(zb,{}),label:`All projects`,meta:e.projects?.length,active:!0})}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsx)(YF,{health:t===`live`?`ok`:t===`connecting`?`connecting`:`reconnecting`,origin:typeof window>`u`?`this machine`:window.location.origin,sandbox:_M,notify:null,theme:n.resolved,onToggleTheme:n.toggle})]})}var k9=4;function A9({crumbs:e,value:t,onNavigate:n,onEnterPath:r,placeholder:i}){let[a,o]=(0,L.useState)(null),s=a!==null,c=e.length>k9,l=c?e.slice(-3):e;return s?(0,R.jsx)(`input`,{className:`${lj} flex-1 font-mono text-xs`,"aria-label":`Path`,spellCheck:!1,autoComplete:`off`,autoFocus:!0,value:a,placeholder:i,onChange:e=>o(e.target.value),onBlur:()=>o(null),onKeyDown:e=>{e.key===`Enter`&&(r(a.trim()),o(null)),e.key===`Escape`&&(e.stopPropagation(),o(null))}}):(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 cursor-text items-center gap-0.5 truncate`,onClick:()=>o(t),role:`group`,"aria-label":`Current path`,children:[c&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(j9,{crumb:e[0],onNavigate:n}),(0,R.jsx)(fb,{size:12,className:`shrink-0 text-text-disabled`}),(0,R.jsx)(`span`,{className:`shrink-0 px-1 text-sm text-text-tertiary`,title:e[e.length-1].path,children:`…`})]}),l.map((e,t)=>(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:[(t>0||c)&&(0,R.jsx)(fb,{size:12,className:`shrink-0 text-text-disabled`}),(0,R.jsx)(j9,{crumb:e,onNavigate:n})]},e.path)),(0,R.jsx)(`button`,{type:`button`,className:`${qE} ml-1 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-icon transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,"aria-label":`Edit path`,title:`Edit path`,onClick:()=>o(t),children:(0,R.jsx)(_b,{size:14})})]})}function j9({crumb:e,onNavigate:t}){return(0,R.jsx)(`button`,{type:`button`,className:`${qE} shrink-0 rounded-sm px-1 py-0.5 cursor-pointer font-mono text-xs text-text-secondary transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,onClick:n=>{n.stopPropagation(),t(e.path)},children:e.name})}function M9({initialPath:e,onPick:t,onCancel:n}){let r=e?.trim()||void 0,[i,a]=(0,L.useState)(r),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(r??null),[u,d]=(0,L.useState)(null),f=B.project.roots.useQuery(),p=B.project.browse.useQuery({dir:i,showHidden:o},{placeholderData:e=>e,retry:!1}),m=p.data,h=m?.dir??i,g=e=>{l(null),d(null),a(e)},_=e=>{l(e||null),d(null),a(e||void 0)},v=c!==null&&p.isError?pg(i,p.error.message):null,y=v!==null&&v.dir!==i,b=v?.dir,x=p.error?.message;(0,L.useEffect)(()=>{y&&(i===c&&x&&d(gg(x)),a(b))},[y,b,i,c,x]);let S=e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=[...e.currentTarget.querySelectorAll(`[data-dir-row] button`)];if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n===-1?0:n-1)]?.focus()};return(0,R.jsxs)(Hj,{open:!0,onClose:n,size:`lg`,labelledBy:`dir-picker-title`,className:`flex h-[min(620px,76vh)] flex-col overflow-hidden`,children:[(0,R.jsx)(Uj,{id:`dir-picker-title`,title:`Choose a repository`,description:`Browse this machine for a git repository to open.`,onClose:n}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-y border-border-subtle px-3 py-2`,children:[(0,R.jsx)(UE,{label:`Up one level`,icon:(0,R.jsx)(Wb,{}),onClick:()=>m?.parent&&g(m.parent),disabled:!m?.parent}),(0,R.jsx)(A9,{crumbs:m?.crumbs??[],value:c??h??``,onNavigate:g,onEnterPath:_,placeholder:hM()}),(0,R.jsx)(Dj,{label:`Hidden`,checked:o,onChange:s,className:`shrink-0 px-2`})]}),u&&(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border-subtle px-4 py-3`,children:(0,R.jsx)(zj,{message:u.message,path:u.path,hint:`Showing the closest folder that could be listed. Edit the path to try again.`})}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex w-44 shrink-0 flex-col gap-0.5 overflow-y-auto border-r border-border-subtle p-2`,onKeyDown:S,children:[(0,R.jsx)($A,{className:`px-2.5`,children:`Locations`}),(f.data??[]).map(e=>(0,R.jsx)(`div`,{"data-dir-row":``,children:(0,R.jsx)(nj,{label:(0,R.jsx)(`span`,{className:`font-mono text-xs`,children:e.label}),title:e.path,icon:e.label===`~`?(0,R.jsx)(zb,{}):(0,R.jsx)(yb,{}),active:h===e.path,onClick:()=>g(e.path)})},e.path))]}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto p-2`,onKeyDown:S,children:[y||p.isLoading?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-2 text-sm text-text-tertiary`,children:[(0,R.jsx)(KE,{}),` Loading…`]}):p.isError?(0,R.jsx)(`div`,{className:`p-2`,children:(0,R.jsx)(zj,{...gg(p.error.message)})}):(m?.entries.length??0)===0?(0,R.jsx)(Fj,{compact:!0,icon:(0,R.jsx)(yb,{}),title:`No subfolders here`,hint:o?void 0:`Hidden folders, junctions and node_modules are filtered.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5 animate-rise-in`,role:`list`,children:(m?.entries??[]).map(e=>(0,R.jsx)(`div`,{role:`listitem`,"data-dir-row":``,children:(0,R.jsx)(nj,{onDoubleClick:()=>e.isRepo&&t(e.path),label:e.name,title:e.path,icon:e.isRepo?(0,R.jsx)(rb,{}):(0,R.jsx)(yb,{}),onClick:()=>g(e.path),className:e.isRepo?`text-text`:void 0,meta:e.isRepo?(0,R.jsx)(`span`,{className:`text-text-secondary`,children:`git`}):e.isSymlink?`link`:void 0})},e.path))},h),m?.truncated&&(0,R.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-xs text-text-tertiary`,children:`Listing truncated — this folder is very large.`})]})]}),(0,R.jsxs)(Gj,{className:`border-t border-border-subtle pt-3 pb-3`,start:(0,R.jsx)(`div`,{className:`min-w-0 truncate text-left font-mono text-xs`,dir:`rtl`,title:h,children:(0,R.jsx)(`bdi`,{children:h??`—`})}),children:[(0,R.jsx)(Y,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(yb,{}),onClick:()=>h&&t(h),disabled:!h||p.isError,children:`Open this folder`})]})]})}function N9({rail:e,stepKey:t,direction:n=`forward`,onKeyDown:r,children:i}){return(0,R.jsx)(`div`,{className:`flex min-h-full`,onKeyDown:r,children:(0,R.jsxs)(`div`,{className:q(`m-auto grid w-full gap-12 px-8 py-12`,e?`max-w-[860px] grid-cols-[176px_minmax(0,1fr)]`:`max-w-[560px]`),children:[e&&(0,R.jsx)(`div`,{className:`pt-1`,children:e}),(0,R.jsx)(`div`,{className:q(`min-w-0`,n===`forward`?`animate-slide-in-right`:`animate-rise-in`),children:i},t)]})})}function P9({title:e,children:t}){return(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`h1`,{className:`m-0 text-xl font-semibold tracking-tight text-pretty text-text`,children:e}),(0,R.jsx)(`p`,{className:`mt-2 mb-0 text-base text-pretty text-text-secondary`,children:t})]})}function F9({onBack:e,note:t,children:n}){return(0,R.jsxs)(`footer`,{className:`mt-10 border-t border-border-subtle pt-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e&&(0,R.jsx)(Y,{variant:`ghost`,icon:(0,R.jsx)(Ub,{}),onClick:e,children:`Back`}),(0,R.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]}),t&&(0,R.jsx)(`p`,{className:`mt-2 mb-0 text-right text-xs text-text-tertiary`,children:t})]})}function I9({firstRun:e,rail:t,variant:n=`screen`,onOpened:r,onCancel:i}){let[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(!1),p=gx(),m=B.useUtils(),h=B.project.open.useMutation({onSuccess:async e=>{await m.project.list.invalidate(),p.push(`opened ${e.name}`,`info`),r(e.id)},onError:()=>void 0}),g=B.project.initRepo.useMutation({onSuccess:({repoPath:e})=>{u(e),h.mutate({repoPath:e})},onError:()=>void 0}),_=()=>{h.reset(),g.reset(),f(!1)},v=e=>{let t=(e??a).trim();if(t){if(_(),!gM(t)){f(!0);return}u(t),h.mutate({repoPath:t})}},y=()=>{_(),c(!0)},b=h.isPending||g.isPending,x=g.error??h.error,S=d?{message:`Enter an absolute path`,hint:`A path from the root of this machine, like ${hM()}.`,path:null}:x?_g(x.message,l):null,C=e=>{o(e),c(!1),v(e)},w=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:q(`flex items-center gap-2`,n===`screen`&&`mt-8`),children:[(0,R.jsx)(fj,{id:`open-repo-path`,size:`lg`,mono:!0,icon:(0,R.jsx)(yb,{}),className:`flex-1`,value:a,onChange:e=>o(e.target.value),placeholder:hM(),"aria-label":`Repository path`,autoFocus:!0,spellCheck:!1,invalid:!!S,"aria-describedby":S?`open-repo-error`:`open-repo-hint`,onKeyDown:e=>{e.key===`Enter`&&v()}}),(0,R.jsx)(Y,{size:`lg`,icon:(0,R.jsx)(eb,{}),onClick:y,disabled:b,children:`Browse…`}),(0,R.jsx)(Y,{variant:`primary`,size:`lg`,icon:(0,R.jsx)(Cb,{}),loading:h.isPending,onClick:()=>v(),disabled:b||a.trim()===``,children:`Open`})]}),S?(0,R.jsx)(`div`,{className:`mt-3 animate-rise-in`,children:(0,R.jsx)(zj,{...S,id:`open-repo-error`,action:S.offer===`init-repo`?(0,R.jsx)(Y,{size:`sm`,icon:(0,R.jsx)(rb,{}),loading:g.isPending,onClick:()=>g.mutate({repoPath:l}),disabled:b,children:`Initialize repository`}):void 0})}):(0,R.jsx)(`p`,{id:`open-repo-hint`,className:`mt-2.5 mb-0 text-xs text-text-tertiary`,children:`Paste an absolute path, or browse for one. The default branch is detected when the project opens.`})]}),T=(0,R.jsx)(R.Fragment,{children:s&&(0,R.jsx)(M9,{initialPath:a,onPick:C,onCancel:()=>c(!1)})});return n===`dialog`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uj,{title:`Open a project`,description:`Point runcastle at a local git repository — every feature runs its pipeline against it.`,onClose:b?void 0:i}),(0,R.jsx)(Wj,{className:`pt-1`,children:w}),T]}):(0,R.jsxs)(N9,{rail:t,stepKey:`project`,onKeyDown:t=>{t.key===`Escape`&&!e&&!s&&i()},children:[!t&&(0,R.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs text-text-tertiary`,children:[(0,R.jsx)(lx,{size:14}),e?`Welcome to runcastle`:`Your projects`]}),(0,R.jsx)(P9,{title:e?`Open your first project`:`Open a project`,children:`Point runcastle at a local git repository — every feature runs its pipeline against it.`}),w,!e&&(0,R.jsx)(`footer`,{className:`mt-10 flex items-center border-t border-border-subtle pt-5`,children:(0,R.jsx)(Y,{variant:`ghost`,icon:(0,R.jsx)(Ub,{}),onClick:i,disabled:b,children:`Cancel`})}),T]})}function L9({onBack:e,onNext:t}){let[n,r]=(0,L.useState)(!1);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P9,{title:`Run burns unattended?`,children:vv}),n&&(0,R.jsx)(`div`,{className:`mt-8 animate-rise-in`,children:(0,R.jsx)(G7,{onDismiss:t})}),(0,R.jsx)(F9,{onBack:e,children:!n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{variant:`ghost`,icon:(0,R.jsx)(xb,{}),onClick:()=>r(!0),children:`Set up now`}),(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Cb,{}),onClick:t,children:`Skip for now`})]})})]})}function R9({onBack:e,onNext:t}){let[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(``),o=gx(),s=B.useUtils(),c=B.setup.gitIdentity.useMutation({onSuccess:async()=>{await s.setup.doctor.invalidate(),t()},onError:e=>o.push(e.message)}),l=n.trim()!==``&&i.includes(`@`),u=()=>l&&c.mutate({name:n.trim(),email:i.trim()}),d=e=>e.key===`Enter`&&u();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(P9,{title:`Set your git identity`,children:[`runcastle commits documentation and merges on your behalf, so it needs a name and email. This writes to `,(0,R.jsx)(`code`,{className:`font-mono text-sm text-text`,children:`git config --global`}),`.`]}),(0,R.jsxs)(`div`,{className:`mt-8 flex max-w-sm flex-col gap-4`,children:[(0,R.jsx)(hj,{label:`Name`,children:(0,R.jsx)(fj,{id:`wiz-name`,size:`lg`,value:n,onChange:e=>r(e.target.value),placeholder:`Ada Lovelace`,autoFocus:!0,spellCheck:!1,onKeyDown:d})}),(0,R.jsx)(hj,{label:`Email`,children:(0,R.jsx)(fj,{id:`wiz-email`,size:`lg`,type:`email`,value:i,onChange:e=>a(e.target.value),placeholder:`ada@example.com`,spellCheck:!1,onKeyDown:d})})]}),(0,R.jsx)(F9,{onBack:e,children:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Cb,{}),loading:c.isPending,onClick:u,disabled:!l,children:`Continue`})})]})}function z9({onNext:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(lx,{size:32,variant:`solid`,className:`mb-6`}),(0,R.jsx)(P9,{title:`Your coding agent, driven through a pipeline`,children:`Describe a feature and runcastle runs the agent sessions that carry it from idea to merged, stopping at each gate until you say go.`}),(0,R.jsx)(`ol`,{className:`m-0 mt-8 flex list-none flex-col p-0`,children:Kv.map((e,t)=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[16px_96px_minmax(0,1fr)] items-center gap-3 border-b border-border-subtle py-2.5 text-sm last:border-b-0 animate-rise-in`,style:{animationDelay:`${120+t*40}ms`},children:[(0,R.jsx)(sx,{phase:e,size:16,label:``}),(0,R.jsx)(`span`,{className:`font-medium text-text`,children:ix[e]}),(0,R.jsx)(`span`,{className:`text-text-tertiary`,children:Jv[e]})]},e))}),(0,R.jsx)(F9,{children:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Cb,{}),onClick:e,autoFocus:!0,children:`Set up runcastle`})})]})}function B9({runtimes:e,onBack:t,onNext:n}){let r=sh(e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P9,{title:`Connect a coding agent`,children:`runcastle drives whichever agent you have — sign in to one or both. The ones you connect here are the ones whose models you can pick later.`}),(0,R.jsx)(`div`,{className:`mt-8`,children:(0,R.jsx)($7,{children:e.map(e=>(0,R.jsx)(V9,{runtime:e},e.runtime))})}),(0,R.jsx)(F9,{onBack:t,note:r.length===0&&`Connect at least one agent to continue — runcastle has nothing to run without one.`,children:(0,R.jsx)(Y,{variant:`primary`,icon:(0,R.jsx)(Cb,{}),onClick:n,disabled:r.length===0,children:`Continue`})})]})}function V9({runtime:e}){let[t,n]=(0,L.useState)(null),r=gx(),i=B.useUtils(),a=B.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>n(e),onError:e=>r.push(e.message)}),o=ah[e.runtime],s=e.talkReady?`Ready`:e.installed?`Not signed in`:`Not installed`;return(0,R.jsxs)(Q7,{label:e.label,status:s,detail:e.detail,ok:e.talkReady,below:t&&(0,R.jsx)(e9,{sessionId:t,label:o.kind,onDone:()=>{n(null),i.setup.doctor.invalidate()}}),children:[e.installFix&&(0,R.jsx)(u9,{command:e.installFix,onCopy:()=>{navigator.clipboard?.writeText(e.installFix??``),r.push(`copied`,`info`)}}),e.installed&&!e.talkReady&&!t&&(0,R.jsxs)(Y,{size:`sm`,icon:(0,R.jsx)(mb,{}),loading:a.isPending,onClick:()=>a.mutate({kind:o.kind}),children:[`Run `,o.command]}),e.talkReady&&!e.afkReady&&(0,R.jsxs)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:[`Signed in for sessions you watch. Unattended burns on `,e.label,` also need its key — the next step sets that up.`]})]})}var H9={passed:`shipped`,done:`shipped`,current:`review`,todo:`draft`},U9={passed:`text-text-secondary`,done:`text-text-secondary`,current:`bg-surface-selected font-medium text-text`,todo:`text-text-tertiary`};function W9({steps:e}){return(0,R.jsxs)(`nav`,{"aria-label":`Setup`,className:`flex flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 text-sm font-medium text-text`,children:[(0,R.jsx)(lx,{size:16}),`Set up runcastle`]}),(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,"aria-label":`Setup progress`,children:e.map(e=>(0,R.jsxs)(`li`,{"data-state":e.state,"aria-current":e.state===`current`?`step`:void 0,className:q(`flex flex-col rounded-md px-2.5 py-1.5 text-sm transition-colors duration-(--dur-2) ease-app`,U9[e.state]),children:[(0,R.jsxs)(`span`,{className:`flex min-h-5 items-center gap-2`,children:[(0,R.jsx)(sx,{phase:H9[e.state],size:14,label:``}),e.label]}),e.detected&&(0,R.jsx)(`span`,{className:`mt-0.5 pl-5.5 text-xs font-normal text-pretty text-text-tertiary`,children:e.detected})]},e.key))})]})}function G9({onOpened:e,onCancel:t}){let n=B.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),r=n.data?.results.find(e=>e.id===`git-identity`),i=oh(n.data?.results??[]),[a,o]=(0,L.useState)(`intro`),[s,c]=(0,L.useState)(`forward`),l=(e,t)=>{c(t),o(e)},u=B.setup.seedModelDefaults.useMutation(),d=()=>{u.mutate({runtimes:sh(i)}),l(`project`,`forward`)};if(n.isLoading)return(0,R.jsx)(N9,{children:(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-text-tertiary`,children:[(0,R.jsx)(KE,{}),` Preparing setup…`]})});if(a===`project`)return(0,R.jsx)(I9,{firstRun:!0,rail:(0,R.jsx)(W9,{steps:uh(`project`,r)}),onOpened:e,onCancel:t});if(a===`intro`)return(0,R.jsx)(N9,{stepKey:`intro`,direction:s,children:(0,R.jsx)(z9,{onNext:()=>l(nh(r),`forward`)})});let f=()=>{let e=rh(a);e===`project`||e===void 0?d():l(e,`forward`)},p=()=>l(ih(a,r)??`intro`,`back`);return(0,R.jsxs)(N9,{rail:(0,R.jsx)(W9,{steps:uh(a,r)}),stepKey:a,direction:s,children:[a===`identity`&&(0,R.jsx)(R9,{onBack:p,onNext:f}),a===`runtimes`&&(0,R.jsx)(B9,{runtimes:i,onBack:p,onNext:f}),a===`afk`&&(0,R.jsx)(L9,{onBack:p,onNext:f})]})}var K9=`runcastle.update.dismissed`;function q9(e,t){return e.updateAvailable&&e.latest!==null&&e.latest!==t}function J9({tone:e=`neutral`,icon:t,children:n,action:r,onDismiss:i,dismissLabel:a=`Dismiss`}){return(0,R.jsxs)(`div`,{role:`status`,className:q(`flex h-10 shrink-0 animate-fade-in items-center gap-2.5 overflow-hidden border-b border-border-subtle pr-2 pl-4 text-sm`,e===`danger`?`bg-danger-subtle`:`bg-surface`),children:[(0,R.jsx)(`span`,{className:q(`inline-flex shrink-0 [&>svg]:size-4`,e===`danger`?`text-danger`:`text-accent`),children:t}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 truncate text-text-secondary`,children:n}),r,i&&(0,R.jsx)(UE,{size:`sm`,label:a,icon:(0,R.jsx)(cb,{}),onClick:i})]})}function Y9(){let e=gx(),t=B.system.checkUpdate.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),[n,r]=(0,L.useState)(()=>{try{return localStorage.getItem(K9)}catch{return null}}),i=t.data;return!i||!i.latest||!q9(i,n)?null:(0,R.jsxs)(J9,{icon:(0,R.jsx)(Cb,{}),onDismiss:()=>{try{localStorage.setItem(K9,i.latest)}catch{}r(i.latest)},dismissLabel:`Dismiss update notice`,action:(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(Fb,{}),onClick:()=>navigator.clipboard.writeText(i.command).then(()=>e.push(`Update command copied`,`info`),()=>e.push(`Copy failed`)),children:`Copy command`}),children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-text`,children:[`runcastle `,i.latest,` is available`]}),(0,R.jsxs)(`span`,{className:`shrink-0 text-text-tertiary`,children:[`you're on `,i.current]}),(0,R.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-text-tertiary select-all`,children:i.command})]})}function X9({error:e,onRecheck:t}){return e?(0,R.jsxs)(J9,{tone:`danger`,icon:(0,R.jsx)(Vb,{}),action:(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,icon:(0,R.jsx)(Gb,{}),onClick:t,children:`Re-run checks`}),children:[(0,R.jsx)(`span`,{className:`shrink-0 font-medium text-text`,children:`Setup checks could not run`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,title:e,children:e})]}):null}function Z9(){let e=Pg(),t,n=null;return e.loading||e.projects===void 0?t=(0,R.jsx)(MF,{children:(0,R.jsx)(yj,{children:(0,R.jsx)(See,{})})}):e.view===`setup`?t=(0,R.jsx)(MF,{children:(0,R.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:(0,R.jsx)(G9,{onOpened:e.enterProject,onCancel:e.cancelOpen})})}):e.view===`open`&&e.projects.length>0?(t=e.currentProjectId?(0,R.jsx)(C9,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,R.jsx)(D9,{nav:e}),n=(0,R.jsx)(Hj,{open:!0,onClose:e.cancelOpen,size:`md`,label:`Open a project`,children:(0,R.jsx)(I9,{variant:`dialog`,firstRun:!1,onOpened:e.enterProject,onCancel:e.cancelOpen})})):t=e.view===`open`?(0,R.jsx)(MF,{children:(0,R.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:(0,R.jsx)(I9,{firstRun:e.projects.length===0,onOpened:e.enterProject,onCancel:e.cancelOpen})})}):e.view===`project`&&e.currentProjectId?(0,R.jsx)(C9,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,R.jsx)(D9,{nav:e}),(0,R.jsx)(kF,{notices:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y9,{}),(0,R.jsx)(X9,{error:e.doctorError,onRecheck:e.recheckDoctor})]}),children:(0,R.jsxs)(`div`,{className:`h-full bg-canvas`,children:[t,n]})})}var Q9=[{name:`w-40`,path:`w-56`},{name:`w-28`,path:`w-44`},{name:`w-48`,path:`w-64`}];function See(){return(0,R.jsxs)(Oj,{label:`Loading projects…`,children:[(0,R.jsx)(`div`,{className:`flex h-7 items-center`,"data-skeleton":`title`,children:(0,R.jsx)(kj,{className:`h-5 w-32`})}),(0,R.jsx)(`div`,{className:`mt-2 flex h-5 items-center`,children:(0,R.jsx)(kj,{className:`h-2.5 w-28`})}),(0,R.jsx)(`div`,{className:`mt-8 flex flex-col`,children:Q9.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-border-subtle px-3 py-2 last:border-b-0`,"data-skeleton":`project-row`,children:[(0,R.jsx)(kj,{className:`mt-0.5 size-4 self-start`}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`div`,{className:`flex h-5 items-center`,children:(0,R.jsx)(kj,{className:q(`h-3`,e.name)})}),(0,R.jsx)(`div`,{className:`flex h-4 items-center`,"data-skeleton":`repo-path`,children:(0,R.jsx)(kj,{className:q(`h-2.5`,e.path)})})]}),(0,R.jsx)(kj,{className:`h-2.5 w-16`})]},t))})]})}function Cee(){return Dh(),(0,R.jsx)(Z9,{})}function wee(e){return e instanceof Error&&e.message?e.message:typeof e==`string`&&e!==``?e:`something went wrong`}function Tee(e,t){return typeof t.options.onError==`function`?null:wee(e)}VM();function Eee(){let[e]=(0,L.useState)(()=>new Ve({mutationCache:new Pe({onError:(e,t,n,r)=>{let i=Tee(e,r);i&&mx(i)}}),defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}}})),[t]=(0,L.useState)(()=>B.createClient({links:li(`/api/trpc`)}));return(0,R.jsx)(B.Provider,{client:t,queryClient:e,children:(0,R.jsx)(Je,{client:e,children:(0,R.jsx)(AE,{children:(0,R.jsx)(hx,{children:(0,R.jsx)(Cee,{})})})})})}var $9=document.getElementById(`root`);if(!$9)throw Error(`#root not found`);(0,Tt.createRoot)($9).render((0,R.jsx)(L.StrictMode,{children:(0,R.jsx)(Eee,{})}));
|